Skip to content

Commit 65d6662

Browse files
authored
[clang-tidy][NFC] run clang-format over abseil and altera checks. (llvm#143314)
1 parent 366f488 commit 65d6662

14 files changed

+39
-40
lines changed

clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,12 @@ class AbseilModule : public ClangTidyModule {
5959
CheckFactories.registerCheck<NoNamespaceCheck>("abseil-no-namespace");
6060
CheckFactories.registerCheck<RedundantStrcatCallsCheck>(
6161
"abseil-redundant-strcat-calls");
62-
CheckFactories.registerCheck<StrCatAppendCheck>(
63-
"abseil-str-cat-append");
62+
CheckFactories.registerCheck<StrCatAppendCheck>("abseil-str-cat-append");
6463
CheckFactories.registerCheck<StringFindStartswithCheck>(
6564
"abseil-string-find-startswith");
6665
CheckFactories.registerCheck<StringFindStrContainsCheck>(
6766
"abseil-string-find-str-contains");
68-
CheckFactories.registerCheck<TimeComparisonCheck>(
69-
"abseil-time-comparison");
67+
CheckFactories.registerCheck<TimeComparisonCheck>("abseil-time-comparison");
7068
CheckFactories.registerCheck<TimeSubtractionCheck>(
7169
"abseil-time-subtraction");
7270
CheckFactories.registerCheck<UpgradeDurationConversionsCheck>(

clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace clang::tidy::abseil {
1515

1616
// Find potential incorrect uses of integer division of absl::Duration objects.
1717
//
18-
// For the user-facing documentation see:
18+
// For the user-facing documentation see:
1919
// http://clang.llvm.org/extra/clang-tidy/checks/abseil/duration-division.html
2020

2121
class DurationDivisionCheck : public ClangTidyCheck {

clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ void NoInternalDependenciesCheck::registerMatchers(MatchFinder *Finder) {
2727
this);
2828
}
2929

30-
void NoInternalDependenciesCheck::check(const MatchFinder::MatchResult &Result) {
30+
void NoInternalDependenciesCheck::check(
31+
const MatchFinder::MatchResult &Result) {
3132
const auto *InternalDependency =
3233
Result.Nodes.getNodeAs<NestedNameSpecifierLoc>("InternalDep");
3334

clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- NoInternalDependenciesCheck.h - clang-tidy----------------------*- C++ -*-===//
1+
//===--- NoInternalDependenciesCheck.h - clang-tidy--------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

clang-tools-extra/clang-tidy/abseil/NoNamespaceCheck.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ using namespace clang::ast_matchers;
1515
namespace clang::tidy::abseil {
1616

1717
void NoNamespaceCheck::registerMatchers(MatchFinder *Finder) {
18-
Finder->addMatcher(
19-
namespaceDecl(hasName("::absl"), unless(isInAbseilFile()))
20-
.bind("abslNamespace"),
21-
this);
18+
Finder->addMatcher(namespaceDecl(hasName("::absl"), unless(isInAbseilFile()))
19+
.bind("abslNamespace"),
20+
this);
2221
}
2322

2423
void NoNamespaceCheck::check(const MatchFinder::MatchResult &Result) {

clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace clang::tidy::abseil {
2323
// - Make it work in macros if the outer and inner StrCats are both in the
2424
// argument.
2525

26-
void RedundantStrcatCallsCheck::registerMatchers(MatchFinder* Finder) {
26+
void RedundantStrcatCallsCheck::registerMatchers(MatchFinder *Finder) {
2727
const auto CallToStrcat =
2828
callExpr(callee(functionDecl(hasName("::absl::StrCat"))));
2929
const auto CallToStrappend =
@@ -62,7 +62,7 @@ const clang::CallExpr *processArgument(const Expr *Arg,
6262
const MatchFinder::MatchResult &Result,
6363
StrCatCheckResult *CheckResult) {
6464
const auto IsAlphanum = hasDeclaration(cxxMethodDecl(hasName("AlphaNum")));
65-
static const auto* const Strcat = new auto(hasName("::absl::StrCat"));
65+
static const auto *const Strcat = new auto(hasName("::absl::StrCat"));
6666
const auto IsStrcat = cxxBindTemporaryExpr(
6767
has(callExpr(callee(functionDecl(*Strcat))).bind("StrCat")));
6868
if (const auto *SubStrcatCall = selectFirst<const CallExpr>(
@@ -81,18 +81,18 @@ const clang::CallExpr *processArgument(const Expr *Arg,
8181
StrCatCheckResult processCall(const CallExpr *RootCall, bool IsAppend,
8282
const MatchFinder::MatchResult &Result) {
8383
StrCatCheckResult CheckResult;
84-
std::deque<const CallExpr*> CallsToProcess = {RootCall};
84+
std::deque<const CallExpr *> CallsToProcess = {RootCall};
8585

8686
while (!CallsToProcess.empty()) {
8787
++CheckResult.NumCalls;
8888

89-
const CallExpr* CallExpr = CallsToProcess.front();
89+
const CallExpr *CallExpr = CallsToProcess.front();
9090
CallsToProcess.pop_front();
9191

9292
int StartArg = CallExpr == RootCall && IsAppend;
9393
for (const auto *Arg : CallExpr->arguments()) {
94-
if (StartArg-- > 0)
95-
continue;
94+
if (StartArg-- > 0)
95+
continue;
9696
if (const clang::CallExpr *Sub =
9797
processArgument(Arg, Result, &CheckResult)) {
9898
CallsToProcess.push_back(Sub);
@@ -101,18 +101,18 @@ StrCatCheckResult processCall(const CallExpr *RootCall, bool IsAppend,
101101
}
102102
return CheckResult;
103103
}
104-
} // namespace
104+
} // namespace
105105

106-
void RedundantStrcatCallsCheck::check(const MatchFinder::MatchResult& Result) {
106+
void RedundantStrcatCallsCheck::check(const MatchFinder::MatchResult &Result) {
107107
bool IsAppend = false;
108108

109109
const CallExpr *RootCall = nullptr;
110-
if ((RootCall = Result.Nodes.getNodeAs<CallExpr>("StrCat")))
111-
IsAppend = false;
112-
else if ((RootCall = Result.Nodes.getNodeAs<CallExpr>("StrAppend")))
113-
IsAppend = true;
114-
else
115-
return;
110+
if ((RootCall = Result.Nodes.getNodeAs<CallExpr>("StrCat")))
111+
IsAppend = false;
112+
else if ((RootCall = Result.Nodes.getNodeAs<CallExpr>("StrAppend")))
113+
IsAppend = true;
114+
else
115+
return;
116116

117117
if (RootCall->getBeginLoc().isMacroID()) {
118118
// Ignore calls within macros.
@@ -128,8 +128,8 @@ void RedundantStrcatCallsCheck::check(const MatchFinder::MatchResult& Result) {
128128
return;
129129
}
130130

131-
diag(RootCall->getBeginLoc(),
132-
"multiple calls to 'absl::StrCat' can be flattened into a single call")
131+
diag(RootCall->getBeginLoc(),
132+
"multiple calls to 'absl::StrCat' can be flattened into a single call")
133133
<< CheckResult.Hints;
134134
}
135135

clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
namespace clang::tidy::abseil {
1515

16-
/// Flags redundant calls to absl::StrCat when the result is being passed to
17-
/// another call of absl::StrCat/absl::StrAppend. Also suggests a fix to
16+
/// Flags redundant calls to absl::StrCat when the result is being passed to
17+
/// another call of absl::StrCat/absl::StrAppend. Also suggests a fix to
1818
/// collapse the calls.
1919
/// Example:
2020
/// StrCat(1, StrCat(2, 3)) ==> StrCat(1, 2, 3)

clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ AST_MATCHER_P(Stmt, IgnoringTemporaries, ast_matchers::internal::Matcher<Stmt>,
3434
return InnerMatcher.matches(*E, Finder, Builder);
3535
}
3636

37-
} // namespace
37+
} // namespace
3838

3939
// TODO: str += StrCat(...)
4040
// str.append(StrCat(...))
4141

4242
void StrCatAppendCheck::registerMatchers(MatchFinder *Finder) {
4343
const auto StrCat = functionDecl(hasName("::absl::StrCat"));
44-
// The arguments of absl::StrCat are implicitly converted to AlphaNum. This
45-
// matches to the arguments because of that behavior.
44+
// The arguments of absl::StrCat are implicitly converted to AlphaNum. This
45+
// matches to the arguments because of that behavior.
4646
const auto AlphaNum = IgnoringTemporaries(cxxConstructExpr(
4747
argumentCountIs(1), hasType(cxxRecordDecl(hasName("::absl::AlphaNum"))),
4848
hasArgument(0, ignoringImpCasts(declRefExpr(to(equalsBoundNode("LHS")),
@@ -73,7 +73,7 @@ void StrCatAppendCheck::registerMatchers(MatchFinder *Finder) {
7373
void StrCatAppendCheck::check(const MatchFinder::MatchResult &Result) {
7474
const auto *Op = Result.Nodes.getNodeAs<CXXOperatorCallExpr>("Op");
7575
const auto *Call = Result.Nodes.getNodeAs<CallExpr>("Call");
76-
assert(Op != nullptr && Call != nullptr && "Matcher does not work as expected");
76+
assert(Op && Call && "Matcher does not work as expected");
7777

7878
// Handles the case 'x = absl::StrCat(x)', which has no effect.
7979
if (Call->getNumArgs() == 1) {

clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace clang::tidy::abseil {
1515

1616
/// Flags uses of absl::StrCat to append to a string. Suggests absl::StrAppend
17-
/// should be used instead.
17+
/// should be used instead.
1818
///
1919
/// For the user-facing documentation see:
2020
/// http://clang.llvm.org/extra/clang-tidy/checks/abseil/str-cat-append.html

clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class TimeSubtractionCheck : public ClangTidyCheck {
2626
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
2727

2828
private:
29-
void emitDiagnostic(const Expr* Node, llvm::StringRef Replacement);
29+
void emitDiagnostic(const Expr *Node, llvm::StringRef Replacement);
3030
};
3131

3232
} // namespace clang::tidy::abseil

0 commit comments

Comments
 (0)