-
Notifications
You must be signed in to change notification settings - Fork 14.3k
added option google-readability-namespace-comments.AllowNoNamespaceComments
#124265
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
Merged
vbvictor
merged 1 commit into
llvm:main
from
thorsten-klein:google-readability-namespace-comments-allow-empty
Jun 8, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...t/clang-tidy/checkers/google/readability-namespace-comments-missing-nested-namespaces.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// RUN: %check_clang_tidy %s google-readability-namespace-comments %t -std=c++20 \ | ||
// RUN: '-config={CheckOptions: { \ | ||
// RUN: google-readability-namespace-comments.AllowOmittingNamespaceComments: true, \ | ||
// RUN: google-readability-namespace-comments.ShortNamespaceLines: 0, \ | ||
// RUN: }}' | ||
thorsten-klein marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// accept if namespace comments are fully omitted | ||
namespace n1::n2 { | ||
namespace /*comment1*/n3/*comment2*/::/*comment3*/inline/*comment4*/n4/*comment5*/ { | ||
void f(); | ||
}} | ||
|
||
namespace n5::inline n6 { | ||
void f(); | ||
} | ||
|
||
namespace n7::inline n8 { | ||
void f(); | ||
} | ||
|
||
// accept if namespace comments are partly omitted (e.g. only for nested namespace) | ||
namespace n1::n2 { | ||
namespace n3::n4 { | ||
void f(); | ||
} | ||
} // namespace n1::n2 | ||
|
||
// fail if namespace comment is different than expected | ||
namespace n9::inline n10 { | ||
void f(); | ||
} // namespace n9::n10 | ||
// CHECK-MESSAGES: :[[@LINE-1]]:2: warning: namespace 'n9::inline n10' ends with a comment that refers to a wrong namespace 'n9::n10' [google-readability-namespace-comments] |
40 changes: 40 additions & 0 deletions
40
clang-tools-extra/test/clang-tidy/checkers/google/readability-namespace-comments-missing.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// RUN: %check_clang_tidy %s google-readability-namespace-comments %t \ | ||
// RUN: -config='{CheckOptions: { \ | ||
// RUN: google-readability-namespace-comments.AllowOmittingNamespaceComments: true, \ | ||
// RUN: google-readability-namespace-comments.ShortNamespaceLines: 0, \ | ||
// RUN: }}' | ||
|
||
// accept if namespace comments are fully omitted | ||
namespace n1 { | ||
namespace /* a comment */ n2 /* another comment */ { | ||
void f(); | ||
}} | ||
|
||
#define MACRO macro_expansion | ||
namespace MACRO { | ||
void f(); | ||
} | ||
|
||
namespace [[deprecated("foo")]] namespace_with_attr { | ||
inline namespace inline_namespace { | ||
void f(); | ||
} | ||
} | ||
|
||
namespace [[]] { | ||
void f(); | ||
} | ||
|
||
// accept if namespace comments are partly omitted (e.g. only for nested namespace) | ||
namespace n3 { | ||
namespace n4 { | ||
void f(); | ||
} // n4 | ||
} | ||
|
||
// fail if namespace comment is different than expected | ||
namespace n1 { | ||
void f(); | ||
} // namespace n2 | ||
// CHECK-MESSAGES: :[[@LINE-1]]:2: warning: namespace 'n1' ends with a comment that refers to a wrong namespace 'n2' [google-readability-namespace-comments] | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.