From f176678abacad2aa68930211a7d99bd270fa061e Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Sat, 9 Apr 2016 01:22:30 +0200 Subject: [PATCH 01/12] Fixes case sensitive includes --- src/MultiTuProcessor.hpp | 2 +- src/annotate.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MultiTuProcessor.hpp b/src/MultiTuProcessor.hpp index 47ebd23..b3d1d34 100644 --- a/src/MultiTuProcessor.hpp +++ b/src/MultiTuProcessor.hpp @@ -1,7 +1,7 @@ #ifndef SYNTH_MULTI_TU_PROCESSOR_HPP_INCLUDED #define SYNTH_MULTI_TU_PROCESSOR_HPP_INCLUDED -#include "fileidsupport.hpp" +#include "FileIdSupport.hpp" #include "output.hpp" #include diff --git a/src/annotate.cpp b/src/annotate.cpp index 091d0a4..9d7fe07 100644 --- a/src/annotate.cpp +++ b/src/annotate.cpp @@ -3,7 +3,7 @@ #include "CgStr.hpp" #include "MultiTuProcessor.hpp" #include "cgWrappers.hpp" -#include "fileIdSupport.hpp" +#include "FileIdSupport.hpp" #include "highlight.hpp" #include "output.hpp" #include "xref.hpp" From a8a1680eb23253650c6a6ee862b2b1ec74330db3 Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Sat, 9 Apr 2016 01:22:32 +0200 Subject: [PATCH 02/12] Puts the CMake build directory on the .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 3159f7f..823af82 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.kdev4 +build From 97b527a8483edc56a33237d65393752ea29c2739 Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Sat, 9 Apr 2016 01:22:34 +0200 Subject: [PATCH 03/12] std::hash lives in the functional header, fixes compilation --- src/FileIdSupport.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/FileIdSupport.hpp b/src/FileIdSupport.hpp index d0dd52f..c06b6c7 100644 --- a/src/FileIdSupport.hpp +++ b/src/FileIdSupport.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace std { template <> From 2a3abbc2fa693749ca002c691b0d8d707817091a Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Sat, 9 Apr 2016 01:32:42 +0200 Subject: [PATCH 04/12] Move for rvalue-ref taking CgStr constructor --- src/CgStr.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/CgStr.hpp b/src/CgStr.hpp index 19b7cb9..65ec961 100644 --- a/src/CgStr.hpp +++ b/src/CgStr.hpp @@ -6,13 +6,14 @@ #include #include #include +#include namespace synth { class CgStr { public: CgStr(CXString&& s) - : m_data(s) + : m_data(std::move(s)) { } CgStr(CgStr&& other) From e09a208f76782420811e9e22b8e7567125d6f3ef Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Sat, 9 Apr 2016 01:35:27 +0200 Subject: [PATCH 05/12] Mark CgStr destructor and move special member functions noexcept --- src/CgStr.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CgStr.hpp b/src/CgStr.hpp index 65ec961..f282246 100644 --- a/src/CgStr.hpp +++ b/src/CgStr.hpp @@ -16,13 +16,13 @@ class CgStr { : m_data(std::move(s)) { } - CgStr(CgStr&& other) + CgStr(CgStr&& other) noexcept : m_data(std::move(other.m_data)) { other.m_data.data = nullptr; } - CgStr& operator=(CgStr&& other) { + CgStr& operator=(CgStr&& other) noexcept { destroy(); m_data = std::move(other.m_data); other.m_data.data = nullptr; // HACK Undocumented behavior. @@ -30,7 +30,7 @@ class CgStr { return *this; } - ~CgStr() { + ~CgStr() noexcept { destroy(); } From a04684d612758cfd4f247375090fb057df2eeab8 Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Sat, 9 Apr 2016 01:36:12 +0200 Subject: [PATCH 06/12] CgStr does not provide a virtual destructor, mark it final --- src/CgStr.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CgStr.hpp b/src/CgStr.hpp index f282246..ec31d8f 100644 --- a/src/CgStr.hpp +++ b/src/CgStr.hpp @@ -10,7 +10,7 @@ namespace synth { -class CgStr { +class CgStr final { public: CgStr(CXString&& s) : m_data(std::move(s)) From 9b8d3c31de9a52c2094b1fe930b5fd4d8c773740 Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Sat, 9 Apr 2016 01:38:22 +0200 Subject: [PATCH 07/12] Use size-checking equal in equal_to implementation --- src/FileIdSupport.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/FileIdSupport.hpp b/src/FileIdSupport.hpp index c06b6c7..26bcce8 100644 --- a/src/FileIdSupport.hpp +++ b/src/FileIdSupport.hpp @@ -3,6 +3,7 @@ #include #include +#include #include namespace std { @@ -31,7 +32,8 @@ namespace std { return std::equal( std::begin(lhs.data), std::end(lhs.data), - std::begin(rhs.data)); + std::begin(rhs.data), + std::end(rhs.data)); } }; } From 0b78dc4ac505078eeba082047da456cbef47b32b Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Sat, 9 Apr 2016 01:40:45 +0200 Subject: [PATCH 08/12] Mutex is already thread-safe, mark mutable --- src/MultiTuProcessor.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MultiTuProcessor.hpp b/src/MultiTuProcessor.hpp index b3d1d34..9801e4e 100644 --- a/src/MultiTuProcessor.hpp +++ b/src/MultiTuProcessor.hpp @@ -84,7 +84,7 @@ class MultiTuProcessor { // Common prefix of all keys in m_dirs fs::path m_rootInDir; - std::mutex m_mut; + mutable std::mutex m_mut; }; } // namespace synth From d27a43b42c55cecad2b01d961993821f1155c0d4 Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Sat, 9 Apr 2016 01:49:17 +0200 Subject: [PATCH 09/12] CgTokensHandle final, noexcept --- src/cgWrappers.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cgWrappers.hpp b/src/cgWrappers.hpp index 9e99eda..808cccb 100644 --- a/src/cgWrappers.hpp +++ b/src/cgWrappers.hpp @@ -12,15 +12,15 @@ namespace synth { -class CgTokensHandle { +class CgTokensHandle final { public: CgTokensHandle(CXToken* data, unsigned ntokens, CXTranslationUnit tu_) : m_data(data), m_ntokens(ntokens), m_tu(tu_) {} - ~CgTokensHandle() { destroy(); } + ~CgTokensHandle() noexcept { destroy(); } - CgTokensHandle(CgTokensHandle&& other) + CgTokensHandle(CgTokensHandle&& other) noexcept : m_data(other.m_data) , m_ntokens(other.m_ntokens) , m_tu(other.m_tu) @@ -28,7 +28,7 @@ class CgTokensHandle { other.release(); } - CgTokensHandle& operator= (CgTokensHandle&& other) + CgTokensHandle& operator= (CgTokensHandle&& other) noexcept { destroy(); m_data = other.m_data; From c323352a96c771759f71bc526ab7e4a740817e3e Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Sat, 9 Apr 2016 01:49:40 +0200 Subject: [PATCH 10/12] Mark tokens member function const --- src/cgWrappers.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cgWrappers.hpp b/src/cgWrappers.hpp index 808cccb..387c566 100644 --- a/src/cgWrappers.hpp +++ b/src/cgWrappers.hpp @@ -40,7 +40,7 @@ class CgTokensHandle final { CXTranslationUnit tu() const { return m_tu; } unsigned size() const { return m_ntokens; } - CXToken* tokens() { return m_data; } + CXToken* tokens() const { return m_data; } private: void destroy() From d4eadc8165417b78c6aa4c6d289b0b4a8c128f28 Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Sat, 9 Apr 2016 01:55:11 +0200 Subject: [PATCH 11/12] hardware_concurrency() is allowed to return zero --- src/cmdline.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cmdline.cpp b/src/cmdline.cpp index 70039fc..80c4677 100644 --- a/src/cmdline.cpp +++ b/src/cmdline.cpp @@ -3,6 +3,7 @@ #include #include #include +#include using namespace synth; @@ -77,7 +78,7 @@ CmdLineArgs CmdLineArgs::parse(int argc, char const* const* argv) throw std::runtime_error("Superfluous commandline arguments."); if (r.nThreads == 0) - r.nThreads = std::thread::hardware_concurrency(); + r.nThreads = std::max(std::thread::hardware_concurrency(), 1u); for (auto& dir : r.inOutDirs) { if (!dir.second) dir.second = "."; From 3d93904ac6baf5cab1d551efc53a95e2d1c81dea Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Sat, 9 Apr 2016 02:00:44 +0200 Subject: [PATCH 12/12] Make kMaxRefRecursion TU local --- src/highlight.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/highlight.cpp b/src/highlight.cpp index eb7c0c2..7c7ac6e 100644 --- a/src/highlight.cpp +++ b/src/highlight.cpp @@ -10,7 +10,7 @@ using namespace synth; -unsigned const kMaxRefRecursion = 16; +static unsigned const kMaxRefRecursion = 16; static bool isTypeKind(CXCursorKind k) {