aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
diff options
context:
space:
mode:
authorSirraide <aeternalmail@gmail.com>2024-11-15 08:04:08 +0100
committerGitHub <noreply@github.com>2024-11-15 08:04:08 +0100
commitdde802b153d5cb41505bf4d377be753576991297 (patch)
treefcdf5cdb4010cfc65bf821de6936f1e6904b2803 /clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
parent3d57c79728968e291df4929b377b3580d16af7b9 (diff)
downloadllvm-dde802b153d5cb41505bf4d377be753576991297.zip
llvm-dde802b153d5cb41505bf4d377be753576991297.tar.gz
llvm-dde802b153d5cb41505bf4d377be753576991297.tar.bz2
[Clang] [NFC] Refactor AST visitors in Sema and the static analyser to use DynamicRecursiveASTVisitor (#115144)
This pr refactors all recursive AST visitors in `Sema`, `Analyze`, and `StaticAnalysis` to inherit from DRAV instead. This is over half of the visitors that inherit from RAV directly. See also #115132, #110040, #93462 LLVM Compile-Time Tracker link for this branch: https://llvm-compile-time-tracker.com/compare.php?from=5adb5c05a2e9f31385fbba8b0436cbc07d91a44d&to=b58e589a86c06ba28d4d90613864d10be29aa5ba&stat=instructions%3Au
Diffstat (limited to 'clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
index 03bc4080..91c9b08 100644
--- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -15,7 +15,7 @@
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
-#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/Analysis/Analyses/LiveVariables.h"
#include "clang/Analysis/CFG.h"
#include "clang/Analysis/CallGraph.h"
@@ -68,7 +68,7 @@ STATISTIC(MaxCFGSize, "The maximum number of basic blocks in a function.");
namespace {
class AnalysisConsumer : public AnalysisASTConsumer,
- public RecursiveASTVisitor<AnalysisConsumer> {
+ public DynamicRecursiveASTVisitor {
enum {
AM_None = 0,
AM_Syntax = 0x1,
@@ -147,6 +147,9 @@ public:
if (Opts.ShouldDisplayMacroExpansions)
MacroExpansions.registerForPreprocessor(PP);
+
+ // Visitor options.
+ ShouldWalkTypesOfTypeLocs = false;
}
~AnalysisConsumer() override {
@@ -261,11 +264,8 @@ public:
ExprEngine::InliningModes IMode,
SetOfConstDecls *VisitedCallees);
- /// Visitors for the RecursiveASTVisitor.
- bool shouldWalkTypesOfTypeLocs() const { return false; }
-
/// Handle callbacks for arbitrary Decls.
- bool VisitDecl(Decl *D) {
+ bool VisitDecl(Decl *D) override {
AnalysisMode Mode = getModeForDecl(D, RecVisitorMode);
if (Mode & AM_Syntax) {
if (SyntaxCheckTimer)
@@ -277,7 +277,7 @@ public:
return true;
}
- bool VisitVarDecl(VarDecl *VD) {
+ bool VisitVarDecl(VarDecl *VD) override {
if (!Opts.IsNaiveCTUEnabled)
return true;
@@ -306,7 +306,7 @@ public:
return true;
}
- bool VisitFunctionDecl(FunctionDecl *FD) {
+ bool VisitFunctionDecl(FunctionDecl *FD) override {
IdentifierInfo *II = FD->getIdentifier();
if (II && II->getName().starts_with("__inline"))
return true;
@@ -321,7 +321,7 @@ public:
return true;
}
- bool VisitObjCMethodDecl(ObjCMethodDecl *MD) {
+ bool VisitObjCMethodDecl(ObjCMethodDecl *MD) override {
if (MD->isThisDeclarationADefinition()) {
assert(RecVisitorMode == AM_Syntax || Mgr->shouldInlineCall() == false);
HandleCode(MD, RecVisitorMode);
@@ -329,7 +329,7 @@ public:
return true;
}
- bool VisitBlockDecl(BlockDecl *BD) {
+ bool VisitBlockDecl(BlockDecl *BD) override {
if (BD->hasBody()) {
assert(RecVisitorMode == AM_Syntax || Mgr->shouldInlineCall() == false);
// Since we skip function template definitions, we should skip blocks