Skip to content

Conversation

@blazie2004
Copy link

No description provided.

@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Apr 23, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 23, 2025

@llvm/pr-subscribers-clang

Author: None (blazie2004)

Changes

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

1 Files Affected:

  • (modified) clang/lib/AST/ASTConsumer.cpp (+52-8)
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     

Copy link
Contributor

@frederick-vs-ja frederick-vs-ja left a comment

Choose a reason for hiding this comment

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

IIUC the changes should go to some test file, not clang/lib/AST/ASTConsumer.cpp.

@blazie2004 blazie2004 closed this Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants