Skip to content

Commit 55c86c5

Browse files
authored
[clang-tidy][NFC] fix formatting of namespace-comment-check (#143305)
Fixed formatting and codestyle issues in `namespace-comment-check` Follow up to #124265.
1 parent 102dfa8 commit 55c86c5

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ NamespaceCommentCheck::NamespaceCommentCheck(StringRef Name,
2828
llvm::Regex::IgnoreCase),
2929
ShortNamespaceLines(Options.get("ShortNamespaceLines", 1U)),
3030
SpacesBeforeComments(Options.get("SpacesBeforeComments", 1U)),
31-
AllowOmittingNamespaceComments(Options.get("AllowOmittingNamespaceComments", false)) {}
31+
AllowOmittingNamespaceComments(
32+
Options.get("AllowOmittingNamespaceComments", false)) {}
3233

3334
void NamespaceCommentCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
3435
Options.store(Opts, "ShortNamespaceLines", ShortNamespaceLines);
3536
Options.store(Opts, "SpacesBeforeComments", SpacesBeforeComments);
36-
Options.store(Opts, "AllowOmittingNamespaceComments", AllowOmittingNamespaceComments);
37+
Options.store(Opts, "AllowOmittingNamespaceComments",
38+
AllowOmittingNamespaceComments);
3739
}
3840

3941
void NamespaceCommentCheck::registerMatchers(MatchFinder *Finder) {
@@ -108,7 +110,7 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
108110
// Currently for nested namespace (n1::n2::...) the AST matcher will match foo
109111
// then bar instead of a single match. So if we got a nested namespace we have
110112
// to skip the next ones.
111-
for (const auto &EndOfNameLocation : Ends) {
113+
for (const SourceLocation &EndOfNameLocation : Ends) {
112114
if (Sources.isBeforeInTranslationUnit(ND->getLocation(), EndOfNameLocation))
113115
return;
114116
}
@@ -142,7 +144,7 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
142144

143145
SourceRange OldCommentRange(AfterRBrace, AfterRBrace);
144146
std::string Message = "%0 not terminated with a closing comment";
145-
bool hasComment = false;
147+
bool HasComment = false;
146148

147149
// Try to find existing namespace closing comment on the same line.
148150
if (Tok.is(tok::comment) && NextTokenIsOnSameLine) {
@@ -161,7 +163,7 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
161163
return;
162164
}
163165

164-
hasComment = true;
166+
HasComment = true;
165167

166168
// Otherwise we need to fix the comment.
167169
NeedLineBreak = Comment.starts_with("/*");
@@ -185,13 +187,13 @@ void NamespaceCommentCheck::check(const MatchFinder::MatchResult &Result) {
185187
}
186188

187189
std::string NamespaceNameForDiag =
188-
ND->isAnonymousNamespace() ? "anonymous namespace"
189-
: ("namespace '" + *NamespaceNameAsWritten + "'");
190+
ND->isAnonymousNamespace()
191+
? "anonymous namespace"
192+
: ("namespace '" + *NamespaceNameAsWritten + "'");
190193

191194
// If no namespace comment is allowed
192-
if(!hasComment && AllowOmittingNamespaceComments) {
195+
if (!HasComment && AllowOmittingNamespaceComments)
193196
return;
194-
}
195197

196198
std::string Fix(SpacesBeforeComments, ' ');
197199
Fix.append("// namespace");

0 commit comments

Comments
 (0)