Skip to content

Commit 1d2fdba

Browse files
committed
Revert FallthroughMapper to use CRTP
1 parent ad00026 commit 1d2fdba

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

clang/lib/Sema/AnalysisBasedWarnings.cpp

+12-7
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
#include "clang/AST/Decl.h"
1717
#include "clang/AST/DeclCXX.h"
1818
#include "clang/AST/DeclObjC.h"
19+
#include "clang/AST/DynamicRecursiveASTVisitor.h"
1920
#include "clang/AST/EvaluatedExprVisitor.h"
2021
#include "clang/AST/Expr.h"
2122
#include "clang/AST/ExprCXX.h"
2223
#include "clang/AST/ExprObjC.h"
2324
#include "clang/AST/OperationKinds.h"
2425
#include "clang/AST/ParentMap.h"
25-
#include "clang/AST/DynamicRecursiveASTVisitor.h"
26+
#include "clang/AST/RecursiveASTVisitor.h"
2627
#include "clang/AST/StmtCXX.h"
2728
#include "clang/AST/StmtObjC.h"
2829
#include "clang/AST/StmtVisitor.h"
@@ -1067,14 +1068,18 @@ static bool DiagnoseUninitializedUse(Sema &S, const VarDecl *VD,
10671068
}
10681069

10691070
namespace {
1070-
class FallthroughMapper final : public DynamicRecursiveASTVisitor {
1071+
// This is not a dynamic visitor because it ends up traversing an
1072+
// order of magnitude more statements than every other visitor combined.
1073+
class FallthroughMapper final
1074+
: public RecursiveASTVisitor<FallthroughMapper> {
10711075
public:
10721076
FallthroughMapper(Sema &S)
10731077
: FoundSwitchStatements(false),
10741078
S(S) {
1075-
ShouldWalkTypesOfTypeLocs = false;
10761079
}
10771080

1081+
bool shouldWalkTypesOfTypeLocs() const { return false; }
1082+
10781083
bool foundSwitchStatements() const { return FoundSwitchStatements; }
10791084

10801085
void markFallthroughVisited(const AttributedStmt *Stmt) {
@@ -1187,23 +1192,23 @@ namespace {
11871192
return !!UnannotatedCnt;
11881193
}
11891194

1190-
bool VisitAttributedStmt(AttributedStmt *S) override {
1195+
bool VisitAttributedStmt(AttributedStmt *S) {
11911196
if (asFallThroughAttr(S))
11921197
FallthroughStmts.insert(S);
11931198
return true;
11941199
}
11951200

1196-
bool VisitSwitchStmt(SwitchStmt *S) override {
1201+
bool VisitSwitchStmt(SwitchStmt *S) {
11971202
FoundSwitchStatements = true;
11981203
return true;
11991204
}
12001205

12011206
// We don't want to traverse local type declarations. We analyze their
12021207
// methods separately.
1203-
bool TraverseDecl(Decl *D) override { return true; }
1208+
bool TraverseDecl(Decl *D) { return true; }
12041209

12051210
// We analyze lambda bodies separately. Skip them here.
1206-
bool TraverseLambdaExpr(LambdaExpr *LE) override {
1211+
bool TraverseLambdaExpr(LambdaExpr *LE) {
12071212
// Traverse the captures, but not the body.
12081213
for (const auto C : zip(LE->captures(), LE->capture_inits()))
12091214
TraverseLambdaCapture(LE, &std::get<0>(C), std::get<1>(C));

0 commit comments

Comments
 (0)