This commit fixes http://llvm.org/PR26274 in a simpler and more correct way than
4736d63f752f8d13f4c6a9afd558565c32119718 did. See
https://reviews.llvm.org/D69855#1767089 for details.
Details
- Reviewers
gribozavr aaron.ballman gribozavr2 - Commits
- rGfac4e3c5f8a0: [clang-tidy] Fix PR26274
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Build result: pass - 60438 tests passed, 0 failed and 726 were skipped.
Log files: console-log.txt, CMakeCache.txt
I'm not convinced this feature is worth implementing at all, because there's a good alternative to a macro here -- a namespace alias. What is the reason to use a macro instead of a namespace alias?
While I think that's a superior solution to using macros, some users have macros instead. This fixes a bug reported in https://bugs.llvm.org/show_bug.cgi?id=26274 and I agree that the behavior described in that bug is not what I would expect it to be.
I mean, it is possible to break pretty much any ClangTidy check with sneaky code. But there's a limit to which we should try to make things work in tricky corner cases. For example, the fix in this patch does not handle function-like macros (namespace MY_LIBRARY_NAMESPACE_FOR_VERSION(42) {).
LGTM if we must... but I don't think we should.
- Added support for inline namespaces and namespace attributes, fixed a typo, added tests.
Build result: pass - 60438 tests passed, 0 failed and 726 were skipped.
Log files: console-log.txt, CMakeCache.txt
Apart from preprocessor-related stuff, this patch improves support for nested inline namespace declarations (namespace a::inline b::c), attributes on namespaces and comments inside namespace declarations. And also reduces the number of special cases. It should be a net positive effect ;)
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp | ||
---|---|---|
54 | s/begin/beginning/ |
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp | ||
---|---|---|
79 | How well do these test cases work? namespace [[]] { } namespace frobble::inline bar { } I'm not certain what we want the comment to be for the second example, and I'm not certain the first example will parse properly here. |
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp | ||
---|---|---|
79 | Both work correctly, in the second case the inline is dropped (why would we want it not to?). See clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments.cpp:66 and clang-tools-extra/test/clang-tidy/checkers/google-readability-namespace-comments-c++17.cpp:4 for tests covering very similar cases. Just in case, I've added a test with an empty attribute list. |
Build result: pass - 60438 tests passed, 0 failed and 726 were skipped.
Log files: console-log.txt, CMakeCache.txt
s/begin/beginning/