aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Analysis/ReachableCode.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/Analysis/ReachableCode.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/Analysis/ReachableCode.cpp')
-rw-r--r--clang/lib/Analysis/ReachableCode.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/Analysis/ReachableCode.cpp b/clang/lib/Analysis/ReachableCode.cpp
index acbe147..dd81c8e 100644
--- a/clang/lib/Analysis/ReachableCode.cpp
+++ b/clang/lib/Analysis/ReachableCode.cpp
@@ -13,11 +13,11 @@
#include "clang/Analysis/Analyses/ReachableCode.h"
#include "clang/AST/Attr.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/ParentMap.h"
-#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/StmtCXX.h"
#include "clang/Analysis/AnalysisDeclContext.h"
#include "clang/Analysis/CFG.h"
@@ -476,17 +476,19 @@ static bool isInCoroutineStmt(const Stmt *DeadStmt, const CFGBlock *Block) {
}
if (!CoroStmt)
return false;
- struct Checker : RecursiveASTVisitor<Checker> {
+ struct Checker : DynamicRecursiveASTVisitor {
const Stmt *DeadStmt;
bool CoroutineSubStmt = false;
- Checker(const Stmt *S) : DeadStmt(S) {}
- bool VisitStmt(const Stmt *S) {
+ Checker(const Stmt *S) : DeadStmt(S) {
+ // Statements captured in the CFG can be implicit.
+ ShouldVisitImplicitCode = true;
+ }
+
+ bool VisitStmt(Stmt *S) override {
if (S == DeadStmt)
CoroutineSubStmt = true;
return true;
}
- // Statements captured in the CFG can be implicit.
- bool shouldVisitImplicitCode() const { return true; }
};
Checker checker(DeadStmt);
checker.TraverseStmt(const_cast<Stmt *>(CoroStmt));