diff --git a/.gitignore b/.gitignore index 3159f7f..823af82 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.kdev4 +build diff --git a/src/CgStr.hpp b/src/CgStr.hpp index 19b7cb9..ec31d8f 100644 --- a/src/CgStr.hpp +++ b/src/CgStr.hpp @@ -6,22 +6,23 @@ #include #include #include +#include namespace synth { -class CgStr { +class CgStr final { public: CgStr(CXString&& s) - : m_data(s) + : 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. @@ -29,7 +30,7 @@ class CgStr { return *this; } - ~CgStr() { + ~CgStr() noexcept { destroy(); } diff --git a/src/FileIdSupport.hpp b/src/FileIdSupport.hpp index d0dd52f..26bcce8 100644 --- a/src/FileIdSupport.hpp +++ b/src/FileIdSupport.hpp @@ -3,6 +3,8 @@ #include #include +#include +#include namespace std { template <> @@ -30,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)); } }; } diff --git a/src/MultiTuProcessor.hpp b/src/MultiTuProcessor.hpp index 47ebd23..9801e4e 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 @@ -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 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" diff --git a/src/cgWrappers.hpp b/src/cgWrappers.hpp index 9e99eda..387c566 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; @@ -40,7 +40,7 @@ class CgTokensHandle { 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() 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 = "."; 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) {