-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang-tidy][NFC] fix formatting of namespace-comment-check
#143305
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
[clang-tidy][NFC] fix formatting of namespace-comment-check
#143305
Conversation
@llvm/pr-subscribers-clang-tidy Author: Baranov Victor (vbvictor) ChangesFixed formatting and codestyle issues in Follow up to #124265. Full diff: https://github.com/llvm/llvm-project/pull/143305.diff 1 Files Affected:
diff --git a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
index 12e52d6afad56..c04bf361c40ca 100644
--- a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -28,12 +28,14 @@ NamespaceCommentCheck::NamespaceCommentCheck(StringRef Name,
llvm::Regex::IgnoreCase),
ShortNamespaceLines(Options.get("ShortNamespaceLines", 1U)),
SpacesBeforeComments(Options.get("SpacesBeforeComments", 1U)),
- AllowOmittingNamespaceComments(Options.get("AllowOmittingNamespaceComments", false)) {}
+ AllowOmittingNamespaceComments(
+ Options.get("AllowOmittingNamespaceComments", false)) {}
void NamespaceCommentCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "ShortNamespaceLines", ShortNamespaceLines);
Options.store(Opts, "SpacesBeforeComments", SpacesBeforeComments);
- Options.store(Opts, "AllowOmittingNamespaceComments", AllowOmittingNamespaceComments);
+ Options.store(Opts, "AllowOmittingNamespaceComments",
+ AllowOmittingNamespaceComments);
}
void NamespaceCommentCheck::registerMatchers(MatchFinder *Finder) {
@@ -108,7 +110,7 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
// Currently for nested namespace (n1::n2::...) the AST matcher will match foo
// then bar instead of a single match. So if we got a nested namespace we have
// to skip the next ones.
- for (const auto &EndOfNameLocation : Ends) {
+ for (const SourceLocation &EndOfNameLocation : Ends) {
if (Sources.isBeforeInTranslationUnit(ND->getLocation(), EndOfNameLocation))
return;
}
@@ -142,7 +144,7 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
SourceRange OldCommentRange(AfterRBrace, AfterRBrace);
std::string Message = "%0 not terminated with a closing comment";
- bool hasComment = false;
+ bool HasComment = false;
// Try to find existing namespace closing comment on the same line.
if (Tok.is(tok::comment) && NextTokenIsOnSameLine) {
@@ -161,7 +163,7 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
return;
}
- hasComment = true;
+ HasComment = true;
// Otherwise we need to fix the comment.
NeedLineBreak = Comment.starts_with("/*");
@@ -185,13 +187,13 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
}
std::string NamespaceNameForDiag =
- ND->isAnonymousNamespace() ? "anonymous namespace"
- : ("namespace '" + *NamespaceNameAsWritten + "'");
+ ND->isAnonymousNamespace()
+ ? "anonymous namespace"
+ : ("namespace '" + *NamespaceNameAsWritten + "'");
// If no namespace comment is allowed
- if(!hasComment && AllowOmittingNamespaceComments) {
+ if (!HasComment && AllowOmittingNamespaceComments)
return;
- }
std::string Fix(SpacesBeforeComments, ' ');
Fix.append("// namespace");
|
@llvm/pr-subscribers-clang-tools-extra Author: Baranov Victor (vbvictor) ChangesFixed formatting and codestyle issues in Follow up to #124265. Full diff: https://github.com/llvm/llvm-project/pull/143305.diff 1 Files Affected:
diff --git a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
index 12e52d6afad56..c04bf361c40ca 100644
--- a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -28,12 +28,14 @@ NamespaceCommentCheck::NamespaceCommentCheck(StringRef Name,
llvm::Regex::IgnoreCase),
ShortNamespaceLines(Options.get("ShortNamespaceLines", 1U)),
SpacesBeforeComments(Options.get("SpacesBeforeComments", 1U)),
- AllowOmittingNamespaceComments(Options.get("AllowOmittingNamespaceComments", false)) {}
+ AllowOmittingNamespaceComments(
+ Options.get("AllowOmittingNamespaceComments", false)) {}
void NamespaceCommentCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "ShortNamespaceLines", ShortNamespaceLines);
Options.store(Opts, "SpacesBeforeComments", SpacesBeforeComments);
- Options.store(Opts, "AllowOmittingNamespaceComments", AllowOmittingNamespaceComments);
+ Options.store(Opts, "AllowOmittingNamespaceComments",
+ AllowOmittingNamespaceComments);
}
void NamespaceCommentCheck::registerMatchers(MatchFinder *Finder) {
@@ -108,7 +110,7 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
// Currently for nested namespace (n1::n2::...) the AST matcher will match foo
// then bar instead of a single match. So if we got a nested namespace we have
// to skip the next ones.
- for (const auto &EndOfNameLocation : Ends) {
+ for (const SourceLocation &EndOfNameLocation : Ends) {
if (Sources.isBeforeInTranslationUnit(ND->getLocation(), EndOfNameLocation))
return;
}
@@ -142,7 +144,7 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
SourceRange OldCommentRange(AfterRBrace, AfterRBrace);
std::string Message = "%0 not terminated with a closing comment";
- bool hasComment = false;
+ bool HasComment = false;
// Try to find existing namespace closing comment on the same line.
if (Tok.is(tok::comment) && NextTokenIsOnSameLine) {
@@ -161,7 +163,7 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
return;
}
- hasComment = true;
+ HasComment = true;
// Otherwise we need to fix the comment.
NeedLineBreak = Comment.starts_with("/*");
@@ -185,13 +187,13 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
}
std::string NamespaceNameForDiag =
- ND->isAnonymousNamespace() ? "anonymous namespace"
- : ("namespace '" + *NamespaceNameAsWritten + "'");
+ ND->isAnonymousNamespace()
+ ? "anonymous namespace"
+ : ("namespace '" + *NamespaceNameAsWritten + "'");
// If no namespace comment is allowed
- if(!hasComment && AllowOmittingNamespaceComments) {
+ if (!HasComment && AllowOmittingNamespaceComments)
return;
- }
std::string Fix(SpacesBeforeComments, ' ');
Fix.append("// namespace");
|
…43305) Fixed formatting and codestyle issues in `namespace-comment-check` Follow up to llvm#124265.
…43305) Fixed formatting and codestyle issues in `namespace-comment-check` Follow up to llvm#124265.
…43305) Fixed formatting and codestyle issues in `namespace-comment-check` Follow up to llvm#124265.
…43305) Fixed formatting and codestyle issues in `namespace-comment-check` Follow up to llvm#124265.
…43305) Fixed formatting and codestyle issues in `namespace-comment-check` Follow up to llvm#124265.
Fixed formatting and codestyle issues in
namespace-comment-check
Follow up to #124265.