Skip to content

Conversation

steakhal
Copy link
Contributor

@steakhal steakhal commented Mar 6, 2024

Fixes #73764

With this patch, now all the callbacks are demonstrated here.

Fixes #73764

With this patch, now all the callbacks are demonstrated here.
@steakhal steakhal requested a review from NagyDonat March 6, 2024 12:08
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Mar 6, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 6, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-static-analyzer-1

Author: Balazs Benics (steakhal)

Changes

Fixes #73764

With this patch, now all the callbacks are demonstrated here.


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

1 Files Affected:

  • (modified) clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp (+34-24)
diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp b/clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
index 01e0bed54cc6ed..ba66a2254cc777 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp
@@ -33,30 +33,33 @@ namespace ento {
 /// checking.
 ///
 /// \sa CheckerContext
-class CheckerDocumentation : public Checker< check::PreStmt<ReturnStmt>,
-                                       check::PostStmt<DeclStmt>,
-                                       check::PreObjCMessage,
-                                       check::PostObjCMessage,
-                                       check::ObjCMessageNil,
-                                       check::PreCall,
-                                       check::PostCall,
-                                       check::BranchCondition,
-                                       check::NewAllocator,
-                                       check::Location,
-                                       check::Bind,
-                                       check::DeadSymbols,
-                                       check::BeginFunction,
-                                       check::EndFunction,
-                                       check::EndAnalysis,
-                                       check::EndOfTranslationUnit,
-                                       eval::Call,
-                                       eval::Assume,
-                                       check::LiveSymbols,
-                                       check::RegionChanges,
-                                       check::PointerEscape,
-                                       check::ConstPointerEscape,
-                                       check::Event<ImplicitNullDerefEvent>,
-                                       check::ASTDecl<FunctionDecl> > {
+class CheckerDocumentation : public Checker<                           //
+                                 check::ASTCodeBody,                   //
+                                 check::ASTDecl<FunctionDecl>,         //
+                                 check::BeginFunction,                 //
+                                 check::Bind,                          //
+                                 check::BranchCondition,               //
+                                 check::ConstPointerEscape,            //
+                                 check::DeadSymbols,                   //
+                                 check::EndAnalysis,                   //
+                                 check::EndFunction,                   //
+                                 check::EndOfTranslationUnit,          //
+                                 check::Event<ImplicitNullDerefEvent>, //
+                                 check::LiveSymbols,                   //
+                                 check::Location,                      //
+                                 check::NewAllocator,                  //
+                                 check::ObjCMessageNil,                //
+                                 check::PointerEscape,                 //
+                                 check::PostCall,                      //
+                                 check::PostObjCMessage,               //
+                                 check::PostStmt<DeclStmt>,            //
+                                 check::PreCall,                       //
+                                 check::PreObjCMessage,                //
+                                 check::PreStmt<ReturnStmt>,           //
+                                 check::RegionChanges,                 //
+                                 eval::Assume,                         //
+                                 eval::Call                            //
+                                 > {
 public:
   /// Pre-visit the Statement.
   ///
@@ -321,6 +324,13 @@ class CheckerDocumentation : public Checker< check::PreStmt<ReturnStmt>,
   void checkASTDecl(const FunctionDecl *D,
                     AnalysisManager &Mgr,
                     BugReporter &BR) const {}
+
+  /// Check every declaration that has a statement body in the AST.
+  ///
+  /// As AST traversal callback, which should only be used when the checker is
+  /// not path sensitive. It will be called for every Declaration in the AST.
+  void checkASTCodeBody(const Decl *D, AnalysisManager &Mgr,
+                        BugReporter &BR) const {}
 };
 
 void CheckerDocumentation::checkPostStmt(const DeclStmt *DS,

@steakhal steakhal requested a review from NagyDonat March 6, 2024 12:59
Copy link
Contributor

@NagyDonat NagyDonat left a comment

Choose a reason for hiding this comment

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

LGTM, I also like that the indentation is not so deep now.

@steakhal steakhal merged commit c486d90 into llvm:main Mar 6, 2024
@steakhal steakhal deleted the csa-document-ASTCodeBody-callback branch March 6, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:static analyzer clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incompatible function declarations in CheckerDocumentation.cpp
3 participants