|
16 | 16 | #include "clang/AST/Decl.h"
|
17 | 17 | #include "clang/AST/DeclCXX.h"
|
18 | 18 | #include "clang/AST/DeclObjC.h"
|
| 19 | +#include "clang/AST/DynamicRecursiveASTVisitor.h" |
19 | 20 | #include "clang/AST/EvaluatedExprVisitor.h"
|
20 | 21 | #include "clang/AST/Expr.h"
|
21 | 22 | #include "clang/AST/ExprCXX.h"
|
22 | 23 | #include "clang/AST/ExprObjC.h"
|
23 | 24 | #include "clang/AST/OperationKinds.h"
|
24 | 25 | #include "clang/AST/ParentMap.h"
|
25 |
| -#include "clang/AST/DynamicRecursiveASTVisitor.h" |
| 26 | +#include "clang/AST/RecursiveASTVisitor.h" |
26 | 27 | #include "clang/AST/StmtCXX.h"
|
27 | 28 | #include "clang/AST/StmtObjC.h"
|
28 | 29 | #include "clang/AST/StmtVisitor.h"
|
@@ -1067,14 +1068,18 @@ static bool DiagnoseUninitializedUse(Sema &S, const VarDecl *VD,
|
1067 | 1068 | }
|
1068 | 1069 |
|
1069 | 1070 | 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> { |
1071 | 1075 | public:
|
1072 | 1076 | FallthroughMapper(Sema &S)
|
1073 | 1077 | : FoundSwitchStatements(false),
|
1074 | 1078 | S(S) {
|
1075 |
| - ShouldWalkTypesOfTypeLocs = false; |
1076 | 1079 | }
|
1077 | 1080 |
|
| 1081 | + bool shouldWalkTypesOfTypeLocs() const { return false; } |
| 1082 | + |
1078 | 1083 | bool foundSwitchStatements() const { return FoundSwitchStatements; }
|
1079 | 1084 |
|
1080 | 1085 | void markFallthroughVisited(const AttributedStmt *Stmt) {
|
@@ -1187,23 +1192,23 @@ namespace {
|
1187 | 1192 | return !!UnannotatedCnt;
|
1188 | 1193 | }
|
1189 | 1194 |
|
1190 |
| - bool VisitAttributedStmt(AttributedStmt *S) override { |
| 1195 | + bool VisitAttributedStmt(AttributedStmt *S) { |
1191 | 1196 | if (asFallThroughAttr(S))
|
1192 | 1197 | FallthroughStmts.insert(S);
|
1193 | 1198 | return true;
|
1194 | 1199 | }
|
1195 | 1200 |
|
1196 |
| - bool VisitSwitchStmt(SwitchStmt *S) override { |
| 1201 | + bool VisitSwitchStmt(SwitchStmt *S) { |
1197 | 1202 | FoundSwitchStatements = true;
|
1198 | 1203 | return true;
|
1199 | 1204 | }
|
1200 | 1205 |
|
1201 | 1206 | // We don't want to traverse local type declarations. We analyze their
|
1202 | 1207 | // methods separately.
|
1203 |
| - bool TraverseDecl(Decl *D) override { return true; } |
| 1208 | + bool TraverseDecl(Decl *D) { return true; } |
1204 | 1209 |
|
1205 | 1210 | // We analyze lambda bodies separately. Skip them here.
|
1206 |
| - bool TraverseLambdaExpr(LambdaExpr *LE) override { |
| 1211 | + bool TraverseLambdaExpr(LambdaExpr *LE) { |
1207 | 1212 | // Traverse the captures, but not the body.
|
1208 | 1213 | for (const auto C : zip(LE->captures(), LE->capture_inits()))
|
1209 | 1214 | TraverseLambdaCapture(LE, &std::get<0>(C), std::get<1>(C));
|
|
0 commit comments