-
Notifications
You must be signed in to change notification settings - Fork 9
Fixes some minor code issues #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
f176678
a8a1680
97b527a
2a3abbc
e09a208
a04684d
9b8d3c3
0b78dc4
d27a43b
c323352
d4eadc8
3d93904
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| *.kdev4 | ||
| build | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,30 +6,31 @@ | |
| #include <cassert> | ||
| #include <ostream> | ||
| #include <string> | ||
| #include <utility> | ||
|
|
||
| namespace synth { | ||
|
|
||
| class CgStr { | ||
| class CgStr final { | ||
| public: | ||
| CgStr(CXString&& s) | ||
| : m_data(s) | ||
| : m_data(std::move(s)) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since CXString comes from a C library, it is a POD. But nonetheless moving is OK as documentation. 👍 |
||
| { } | ||
|
|
||
| CgStr(CgStr&& other) | ||
| CgStr(CgStr&& other) noexcept | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very good point! 👍 |
||
| : 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. | ||
| assert(!other.valid()); | ||
| return *this; | ||
| } | ||
|
|
||
| ~CgStr() { | ||
| ~CgStr() noexcept { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer to rely on C++11's default |
||
| destroy(); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ | |
|
|
||
| #include <clang-c/Index.h> | ||
| #include <algorithm> | ||
| #include <iterator> | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| #include <functional> | ||
|
|
||
| namespace std { | ||
| template <> | ||
|
|
@@ -30,7 +32,8 @@ namespace std { | |
| return std::equal( | ||
| std::begin(lhs.data), | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? Both are fixed size C arrays. |
||
| std::end(lhs.data), | ||
| std::begin(rhs.data)); | ||
| std::begin(rhs.data), | ||
| std::end(rhs.data)); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 <boost/filesystem/path.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; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I never thought about that, good point! 👍 |
||
| }; | ||
|
|
||
| } // namespace synth | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,23 +12,23 @@ | |
|
|
||
| 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(); } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As before: I do not like explicit noexcept for destructors. |
||
|
|
||
| CgTokensHandle(CgTokensHandle&& other) | ||
| CgTokensHandle(CgTokensHandle&& other) noexcept | ||
| : m_data(other.m_data) | ||
| , m_ntokens(other.m_ntokens) | ||
| , m_tu(other.m_tu) | ||
| { | ||
| 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; } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leaving out But thinking about it, libclang provides no way to modify a |
||
|
|
||
| private: | ||
| void destroy() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ | |
| using namespace synth; | ||
|
|
||
|
|
||
| unsigned const kMaxRefRecursion = 16; | ||
| static unsigned const kMaxRefRecursion = 16; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| static bool isTypeKind(CXCursorKind k) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually use out-of-source builds (i.e. I make the build directory a sibling not a child of the project directory), but why not.