Skip to content

Conversation

@vbvictor
Copy link
Contributor

@vbvictor vbvictor commented Jun 8, 2025

For ease of future developing, I make a series of clang-format patches on all clang-tidy code.
Typically, all new contributors should follow the existing style, so making it consistent will give a benefit in it.

After landing all commits, I will add them to .git-blame-ignore-revs.

@llvmbot
Copy link
Member

llvmbot commented Jun 8, 2025

@llvm/pr-subscribers-clang-tidy

@llvm/pr-subscribers-clang-tools-extra

Author: Baranov Victor (vbvictor)

Changes

For ease of future developing, I make a series of clang-format patches on all clang-tidy code.
Typically, all new contributors should follow the existing style, so making it consistent will give a benefit in it.

After landing all commits, I will add them to .git-blame-ignore-revs.


Full diff: https://github.com/llvm/llvm-project/pull/143314.diff

14 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp (+2-4)
  • (modified) clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.h (+1-1)
  • (modified) clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp (+2-1)
  • (modified) clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.h (+1-1)
  • (modified) clang-tools-extra/clang-tidy/abseil/NoNamespaceCheck.cpp (+3-4)
  • (modified) clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp (+16-16)
  • (modified) clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.h (+2-2)
  • (modified) clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp (+4-4)
  • (modified) clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.h (+1-1)
  • (modified) clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.h (+1-1)
  • (modified) clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.h (+2-1)
  • (modified) clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp (+1-1)
  • (modified) clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.h (+1-1)
  • (modified) clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp (+2-2)
diff --git a/clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp b/clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp
index 09a09e6c599b0..c5c42908d0c59 100644
--- a/clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp
@@ -59,14 +59,12 @@ class AbseilModule : public ClangTidyModule {
     CheckFactories.registerCheck<NoNamespaceCheck>("abseil-no-namespace");
     CheckFactories.registerCheck<RedundantStrcatCallsCheck>(
         "abseil-redundant-strcat-calls");
-    CheckFactories.registerCheck<StrCatAppendCheck>(
-        "abseil-str-cat-append");
+    CheckFactories.registerCheck<StrCatAppendCheck>("abseil-str-cat-append");
     CheckFactories.registerCheck<StringFindStartswithCheck>(
         "abseil-string-find-startswith");
     CheckFactories.registerCheck<StringFindStrContainsCheck>(
         "abseil-string-find-str-contains");
-    CheckFactories.registerCheck<TimeComparisonCheck>(
-        "abseil-time-comparison");
+    CheckFactories.registerCheck<TimeComparisonCheck>("abseil-time-comparison");
     CheckFactories.registerCheck<TimeSubtractionCheck>(
         "abseil-time-subtraction");
     CheckFactories.registerCheck<UpgradeDurationConversionsCheck>(
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.h b/clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.h
index 6b194e3d2664a..c8f259521b648 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.h
+++ b/clang-tools-extra/clang-tidy/abseil/DurationDivisionCheck.h
@@ -15,7 +15,7 @@ namespace clang::tidy::abseil {
 
 // Find potential incorrect uses of integer division of absl::Duration objects.
 //
-// For the user-facing documentation see: 
+// For the user-facing documentation see:
 // http://clang.llvm.org/extra/clang-tidy/checks/abseil/duration-division.html
 
 class DurationDivisionCheck : public ClangTidyCheck {
diff --git a/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp b/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
index edaa584a4d8ef..19409d0616f06 100644
--- a/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.cpp
@@ -27,7 +27,8 @@ void NoInternalDependenciesCheck::registerMatchers(MatchFinder *Finder) {
       this);
 }
 
-void NoInternalDependenciesCheck::check(const MatchFinder::MatchResult &Result) {
+void NoInternalDependenciesCheck::check(
+    const MatchFinder::MatchResult &Result) {
   const auto *InternalDependency =
       Result.Nodes.getNodeAs<NestedNameSpecifierLoc>("InternalDep");
 
diff --git a/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.h b/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.h
index dfaa2cbf8f900..9c16524ff6b59 100644
--- a/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.h
+++ b/clang-tools-extra/clang-tidy/abseil/NoInternalDependenciesCheck.h
@@ -1,4 +1,4 @@
-//===--- NoInternalDependenciesCheck.h - clang-tidy----------------------*- C++ -*-===//
+//===--- NoInternalDependenciesCheck.h - clang-tidy--------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/clang-tools-extra/clang-tidy/abseil/NoNamespaceCheck.cpp b/clang-tools-extra/clang-tidy/abseil/NoNamespaceCheck.cpp
index b45a9c99d780d..6c2baa4c41412 100644
--- a/clang-tools-extra/clang-tidy/abseil/NoNamespaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/NoNamespaceCheck.cpp
@@ -15,10 +15,9 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::abseil {
 
 void NoNamespaceCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-      namespaceDecl(hasName("::absl"), unless(isInAbseilFile()))
-          .bind("abslNamespace"),
-      this);
+  Finder->addMatcher(namespaceDecl(hasName("::absl"), unless(isInAbseilFile()))
+                         .bind("abslNamespace"),
+                     this);
 }
 
 void NoNamespaceCheck::check(const MatchFinder::MatchResult &Result) {
diff --git a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp b/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
index 04ca006143503..ef26a8a76cb37 100644
--- a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
@@ -23,7 +23,7 @@ namespace clang::tidy::abseil {
 //  - Make it work in macros if the outer and inner StrCats are both in the
 //    argument.
 
-void RedundantStrcatCallsCheck::registerMatchers(MatchFinder* Finder) {
+void RedundantStrcatCallsCheck::registerMatchers(MatchFinder *Finder) {
   const auto CallToStrcat =
       callExpr(callee(functionDecl(hasName("::absl::StrCat"))));
   const auto CallToStrappend =
@@ -62,7 +62,7 @@ const clang::CallExpr *processArgument(const Expr *Arg,
                                        const MatchFinder::MatchResult &Result,
                                        StrCatCheckResult *CheckResult) {
   const auto IsAlphanum = hasDeclaration(cxxMethodDecl(hasName("AlphaNum")));
-  static const auto* const Strcat = new auto(hasName("::absl::StrCat"));
+  static const auto *const Strcat = new auto(hasName("::absl::StrCat"));
   const auto IsStrcat = cxxBindTemporaryExpr(
       has(callExpr(callee(functionDecl(*Strcat))).bind("StrCat")));
   if (const auto *SubStrcatCall = selectFirst<const CallExpr>(
@@ -81,18 +81,18 @@ const clang::CallExpr *processArgument(const Expr *Arg,
 StrCatCheckResult processCall(const CallExpr *RootCall, bool IsAppend,
                               const MatchFinder::MatchResult &Result) {
   StrCatCheckResult CheckResult;
-  std::deque<const CallExpr*> CallsToProcess = {RootCall};
+  std::deque<const CallExpr *> CallsToProcess = {RootCall};
 
   while (!CallsToProcess.empty()) {
     ++CheckResult.NumCalls;
 
-    const CallExpr* CallExpr = CallsToProcess.front();
+    const CallExpr *CallExpr = CallsToProcess.front();
     CallsToProcess.pop_front();
 
     int StartArg = CallExpr == RootCall && IsAppend;
     for (const auto *Arg : CallExpr->arguments()) {
-      if (StartArg-- > 0) 
-      	continue;
+      if (StartArg-- > 0)
+        continue;
       if (const clang::CallExpr *Sub =
               processArgument(Arg, Result, &CheckResult)) {
         CallsToProcess.push_back(Sub);
@@ -101,18 +101,18 @@ StrCatCheckResult processCall(const CallExpr *RootCall, bool IsAppend,
   }
   return CheckResult;
 }
-}  // namespace
+} // namespace
 
-void RedundantStrcatCallsCheck::check(const MatchFinder::MatchResult& Result) {
+void RedundantStrcatCallsCheck::check(const MatchFinder::MatchResult &Result) {
   bool IsAppend = false;
 
   const CallExpr *RootCall = nullptr;
-  if ((RootCall = Result.Nodes.getNodeAs<CallExpr>("StrCat"))) 
-  	IsAppend = false;
-  else if ((RootCall = Result.Nodes.getNodeAs<CallExpr>("StrAppend"))) 
-  	IsAppend = true;
-  else 
-  	return;
+  if ((RootCall = Result.Nodes.getNodeAs<CallExpr>("StrCat")))
+    IsAppend = false;
+  else if ((RootCall = Result.Nodes.getNodeAs<CallExpr>("StrAppend")))
+    IsAppend = true;
+  else
+    return;
 
   if (RootCall->getBeginLoc().isMacroID()) {
     // Ignore calls within macros.
@@ -128,8 +128,8 @@ void RedundantStrcatCallsCheck::check(const MatchFinder::MatchResult& Result) {
     return;
   }
 
-  diag(RootCall->getBeginLoc(), 
-  	   "multiple calls to 'absl::StrCat' can be flattened into a single call")
+  diag(RootCall->getBeginLoc(),
+       "multiple calls to 'absl::StrCat' can be flattened into a single call")
       << CheckResult.Hints;
 }
 
diff --git a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.h b/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.h
index 04c7c9cb4b783..a27899d3e821a 100644
--- a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.h
+++ b/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.h
@@ -13,8 +13,8 @@
 
 namespace clang::tidy::abseil {
 
-/// Flags redundant calls to absl::StrCat when the result is being passed to 
-///	another call of absl::StrCat/absl::StrAppend. Also suggests a fix to 
+/// Flags redundant calls to absl::StrCat when the result is being passed to
+///	another call of absl::StrCat/absl::StrAppend. Also suggests a fix to
 ///	collapse the calls.
 /// Example:
 ///   StrCat(1, StrCat(2, 3))  ==>  StrCat(1, 2, 3)
diff --git a/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp b/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
index ab6ed701e59fe..6025d3d66675a 100644
--- a/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
@@ -34,15 +34,15 @@ AST_MATCHER_P(Stmt, IgnoringTemporaries, ast_matchers::internal::Matcher<Stmt>,
   return InnerMatcher.matches(*E, Finder, Builder);
 }
 
-}  // namespace
+} // namespace
 
 // TODO: str += StrCat(...)
 //       str.append(StrCat(...))
 
 void StrCatAppendCheck::registerMatchers(MatchFinder *Finder) {
   const auto StrCat = functionDecl(hasName("::absl::StrCat"));
-  // The arguments of absl::StrCat are implicitly converted to AlphaNum. This 
-  // matches to the arguments because of that behavior. 
+  // The arguments of absl::StrCat are implicitly converted to AlphaNum. This
+  // matches to the arguments because of that behavior.
   const auto AlphaNum = IgnoringTemporaries(cxxConstructExpr(
       argumentCountIs(1), hasType(cxxRecordDecl(hasName("::absl::AlphaNum"))),
       hasArgument(0, ignoringImpCasts(declRefExpr(to(equalsBoundNode("LHS")),
@@ -73,7 +73,7 @@ void StrCatAppendCheck::registerMatchers(MatchFinder *Finder) {
 void StrCatAppendCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *Op = Result.Nodes.getNodeAs<CXXOperatorCallExpr>("Op");
   const auto *Call = Result.Nodes.getNodeAs<CallExpr>("Call");
-  assert(Op != nullptr && Call != nullptr && "Matcher does not work as expected");
+  assert(Op && Call && "Matcher does not work as expected");
 
   // Handles the case 'x = absl::StrCat(x)', which has no effect.
   if (Call->getNumArgs() == 1) {
diff --git a/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.h b/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.h
index 22b55abfd83be..fcd9d4b6e1885 100644
--- a/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.h
+++ b/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.h
@@ -14,7 +14,7 @@
 namespace clang::tidy::abseil {
 
 /// Flags uses of absl::StrCat to append to a string. Suggests absl::StrAppend
-/// should be used instead. 
+/// should be used instead.
 ///
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/abseil/str-cat-append.html
diff --git a/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.h b/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.h
index 7e7dc73511812..c947f6bca7f31 100644
--- a/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.h
+++ b/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.h
@@ -26,7 +26,7 @@ class TimeSubtractionCheck : public ClangTidyCheck {
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 
 private:
-  void emitDiagnostic(const Expr* Node, llvm::StringRef Replacement);
+  void emitDiagnostic(const Expr *Node, llvm::StringRef Replacement);
 };
 
 } // namespace clang::tidy::abseil
diff --git a/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.h b/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.h
index beb5479aa6aae..8e7d9829533d4 100644
--- a/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.h
+++ b/clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.h
@@ -16,7 +16,8 @@
 
 namespace clang::tidy::abseil {
 
-/// Finds deprecated uses of `absl::Duration` arithmetic operators and factories.
+/// Finds deprecated uses of `absl::Duration` arithmetic operators and
+/// factories.
 ///
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/abseil/upgrade-duration-conversions.html
diff --git a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
index cdaedd440959c..789327b196ab6 100644
--- a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
@@ -47,7 +47,7 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {
   // Do not trigger on templated struct declarations because the packing and
   // alignment requirements are unknown.
   if (Struct->isTemplated())
-     return;
+    return;
 
   // Packing and alignment requirements for invalid decls are meaningless.
   if (Struct->isInvalidDecl())
diff --git a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.h b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.h
index 5edfd40ef77bc..f360bcef4f14e 100644
--- a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.h
+++ b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.h
@@ -22,7 +22,7 @@ class StructPackAlignCheck : public ClangTidyCheck {
 public:
   StructPackAlignCheck(StringRef Name, ClangTidyContext *Context)
       : ClangTidyCheck(Name, Context),
-    MaxConfiguredAlignment(Options.get("MaxConfiguredAlignment", 128)) {}
+        MaxConfiguredAlignment(Options.get("MaxConfiguredAlignment", 128)) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
diff --git a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
index 532a43bad7412..0bb9d6e4a7cee 100644
--- a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -247,8 +247,8 @@ bool UnrollLoopsCheck::extractValue(int &Value, const BinaryOperator *Op,
   return true;
 }
 
-bool UnrollLoopsCheck::exprHasLargeNumIterations(const Expr *Expression,
-                                                 const ASTContext *Context) const {
+bool UnrollLoopsCheck::exprHasLargeNumIterations(
+    const Expr *Expression, const ASTContext *Context) const {
   Expr::EvalResult Result;
   if (Expression->EvaluateAsRValue(Result, *Context)) {
     if (!Result.Val.isInt())

Copy link
Contributor

@carlosgalvezp carlosgalvezp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Personally I think it would have been fine to do it all in one patch, less commits to add to the git-blame-ignore later. But it's ok!

@vbvictor
Copy link
Contributor Author

vbvictor commented Jun 8, 2025

It appeared relatively easy to review, I'll make next slightly bigger. But don't feel confident making just one huge commit

@vbvictor vbvictor merged commit 65d6662 into llvm:main Jun 8, 2025
10 checks passed
tomtor pushed a commit to tomtor/llvm-project that referenced this pull request Jun 14, 2025
@vbvictor vbvictor deleted the clang-format-tidy1 branch June 22, 2025 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants