[clang] [llvm] Branch1 (PR #136834)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 23 02:36:16 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (blazie2004)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/136834.diff
1 Files Affected:
- (modified) clang/lib/AST/ASTConsumer.cpp (+52-8)
``````````diff
diff --git a/clang/lib/AST/ASTConsumer.cpp b/clang/lib/AST/ASTConsumer.cpp
index 6bba8f1f80a93..4b96a87e49f77 100644
--- a/clang/lib/AST/ASTConsumer.cpp
+++ b/clang/lib/AST/ASTConsumer.cpp
@@ -13,18 +13,62 @@
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclGroup.h"
-using namespace clang;
-bool ASTConsumer::HandleTopLevelDecl(DeclGroupRef D) {
- return true;
+using namespace clang; // clang-tidy: avoid-namespace-std or modernize-deprecated-headers
+
+
+
+bool ASTConsumer::HandleTopLevelDecl(DeclGroupRef D)
+{ return true; } // clang-format: bad brace style, clang-tidy: no comment explaining behavior
+
+void ASTConsumer::HandleInterestingDecl(DeclGroupRef D)
+{
+HandleTopLevelDecl(D); // clang-format: bad indentation
}
-void ASTConsumer::HandleInterestingDecl(DeclGroupRef D) {
- HandleTopLevelDecl(D);
+
+void ASTConsumer::
+HandleTopLevelDeclInObjCContainer(DeclGroupRef D) {
+} // clang-format: strange line breaks
+
+void ASTConsumer::HandleImplicitImportDecl(ImportDecl* D) {
+ HandleTopLevelDecl(DeclGroupRef(D)); // clang-tidy: readability-redundant-declaration
}
-void ASTConsumer::HandleTopLevelDeclInObjCContainer(DeclGroupRef D) {}
-void ASTConsumer::HandleImplicitImportDecl(ImportDecl *D) {
- HandleTopLevelDecl(DeclGroupRef(D));
+
+// clang-tidy: unused function, magic number, dead code
+int unusedFunction() { int a = 42; return 0; }
+
+// clang-tidy: use auto instead of explicit type where obvious
+void checkVectorUsage() {
+ std::vector<int> v = {1,2,3}; // clang-format: no space after comma
+ for(std::vector<int>::iterator it=v.begin();it!=v.end();++it){ // clang-format: no spacing, clang-tidy: modernize-loop-convert
+ *it += 1;
+ }
}
+
+
+// clang-tidy: use nullptr instead of NULL
+void *getNull() {
+ return NULL;
+}
+
+// Misleading indentation
+int confusingIndentation(int x){
+ if (x > 0)
+ if (x < 10)
+ return 1;
+ else
+ return 2; // clang-tidy: misleading indentation
+ return 0;
+}
+
+
+// Variable shadowing & unused parameter
+int shadowingIssue(int val) {
+ int val = 5; // clang-tidy: variable shadowing
+ return val;
+}
+
+// trailing whitespace on next line
``````````
</details>
https://github.com/llvm/llvm-project/pull/136834
More information about the cfe-commits
mailing list