diff options
| author | Scott Douglass <sdouglass@arm.com> | 2015-06-10 13:53:15 +0000 |
|---|---|---|
| committer | Scott Douglass <sdouglass@arm.com> | 2015-06-10 13:53:15 +0000 |
| commit | 503fc39d1f86c1ea39ae33c7b6752a9d3e2fcbca (patch) | |
| tree | 953ea747aebeafddc11278de9b0f7e8f98ef9bc2 /clang/lib | |
| parent | 965bf6a3cebe04300f9826017e1258c12dc21222 (diff) | |
| download | bcm5719-llvm-503fc39d1f86c1ea39ae33c7b6752a9d3e2fcbca.tar.gz bcm5719-llvm-503fc39d1f86c1ea39ae33c7b6752a9d3e2fcbca.zip | |
add ConstEvaluatedExprVisitor
Differential Revision: http://reviews.llvm.org/D10210
llvm-svn: 239474
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/Expr.cpp | 28 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGClass.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/Sema/AnalysisBasedWarnings.cpp | 17 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 1 |
4 files changed, 28 insertions, 28 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 7cc84111469..99c72436b44 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -1238,7 +1238,7 @@ unsigned CallExpr::getBuiltinCallee() const { return FDecl->getBuiltinID(); } -bool CallExpr::isUnevaluatedBuiltinCall(ASTContext &Ctx) const { +bool CallExpr::isUnevaluatedBuiltinCall(const ASTContext &Ctx) const { if (unsigned BI = getBuiltinCallee()) return Ctx.BuiltinInfo.isUnevaluated(BI); return false; @@ -3136,21 +3136,21 @@ bool Expr::HasSideEffects(const ASTContext &Ctx, namespace { /// \brief Look for a call to a non-trivial function within an expression. - class NonTrivialCallFinder : public EvaluatedExprVisitor<NonTrivialCallFinder> + class NonTrivialCallFinder : public ConstEvaluatedExprVisitor<NonTrivialCallFinder> { - typedef EvaluatedExprVisitor<NonTrivialCallFinder> Inherited; - + typedef ConstEvaluatedExprVisitor<NonTrivialCallFinder> Inherited; + bool NonTrivial; public: - explicit NonTrivialCallFinder(ASTContext &Context) + explicit NonTrivialCallFinder(const ASTContext &Context) : Inherited(Context), NonTrivial(false) { } bool hasNonTrivialCall() const { return NonTrivial; } - - void VisitCallExpr(CallExpr *E) { - if (CXXMethodDecl *Method - = dyn_cast_or_null<CXXMethodDecl>(E->getCalleeDecl())) { + + void VisitCallExpr(const CallExpr *E) { + if (const CXXMethodDecl *Method + = dyn_cast_or_null<const CXXMethodDecl>(E->getCalleeDecl())) { if (Method->isTrivial()) { // Recurse to children of the call. Inherited::VisitStmt(E); @@ -3160,8 +3160,8 @@ namespace { NonTrivial = true; } - - void VisitCXXConstructExpr(CXXConstructExpr *E) { + + void VisitCXXConstructExpr(const CXXConstructExpr *E) { if (E->getConstructor()->isTrivial()) { // Recurse to children of the call. Inherited::VisitStmt(E); @@ -3170,8 +3170,8 @@ namespace { NonTrivial = true; } - - void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { + + void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E) { if (E->getTemporary()->getDestructor()->isTrivial()) { Inherited::VisitStmt(E); return; @@ -3182,7 +3182,7 @@ namespace { }; } -bool Expr::hasNonTrivialCall(ASTContext &Ctx) { +bool Expr::hasNonTrivialCall(const ASTContext &Ctx) const { NonTrivialCallFinder Finder(Ctx); Finder.Visit(this); return Finder.hasNonTrivialCall(); diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index cd75da27628..1320cd3c89a 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -370,25 +370,25 @@ namespace { /// A visitor which checks whether an initializer uses 'this' in a /// way which requires the vtable to be properly set. - struct DynamicThisUseChecker : EvaluatedExprVisitor<DynamicThisUseChecker> { - typedef EvaluatedExprVisitor<DynamicThisUseChecker> super; + struct DynamicThisUseChecker : ConstEvaluatedExprVisitor<DynamicThisUseChecker> { + typedef ConstEvaluatedExprVisitor<DynamicThisUseChecker> super; bool UsesThis; - DynamicThisUseChecker(ASTContext &C) : super(C), UsesThis(false) {} + DynamicThisUseChecker(const ASTContext &C) : super(C), UsesThis(false) {} // Black-list all explicit and implicit references to 'this'. // // Do we need to worry about external references to 'this' derived // from arbitrary code? If so, then anything which runs arbitrary // external code might potentially access the vtable. - void VisitCXXThisExpr(CXXThisExpr *E) { UsesThis = true; } + void VisitCXXThisExpr(const CXXThisExpr *E) { UsesThis = true; } }; } static bool BaseInitializerUsesThis(ASTContext &C, const Expr *Init) { DynamicThisUseChecker Checker(C); - Checker.Visit(const_cast<Expr*>(Init)); + Checker.Visit(Init); return Checker.UsesThis; } diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp index 97f4a8def8c..36030b99a30 100644 --- a/clang/lib/Sema/AnalysisBasedWarnings.cpp +++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -574,28 +574,29 @@ namespace { /// ContainsReference - A visitor class to search for references to /// a particular declaration (the needle) within any evaluated component of an /// expression (recursively). -class ContainsReference : public EvaluatedExprVisitor<ContainsReference> { +class ContainsReference : public ConstEvaluatedExprVisitor<ContainsReference> { bool FoundReference; const DeclRefExpr *Needle; public: + typedef ConstEvaluatedExprVisitor<ContainsReference> Inherited; + ContainsReference(ASTContext &Context, const DeclRefExpr *Needle) - : EvaluatedExprVisitor<ContainsReference>(Context), - FoundReference(false), Needle(Needle) {} + : Inherited(Context), FoundReference(false), Needle(Needle) {} - void VisitExpr(Expr *E) { + void VisitExpr(const Expr *E) { // Stop evaluating if we already have a reference. if (FoundReference) return; - EvaluatedExprVisitor<ContainsReference>::VisitExpr(E); + Inherited::VisitExpr(E); } - void VisitDeclRefExpr(DeclRefExpr *E) { + void VisitDeclRefExpr(const DeclRefExpr *E) { if (E == Needle) FoundReference = true; else - EvaluatedExprVisitor<ContainsReference>::VisitDeclRefExpr(E); + Inherited::VisitDeclRefExpr(E); } bool doesContainReference() const { return FoundReference; } @@ -854,7 +855,7 @@ static bool DiagnoseUninitializedUse(Sema &S, const VarDecl *VD, return false; ContainsReference CR(S.Context, DRE); - CR.Visit(const_cast<Expr*>(Initializer)); + CR.Visit(Initializer); if (CR.doesContainReference()) { S.Diag(DRE->getLocStart(), diag::warn_uninit_self_reference_in_init) diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 7e305ffa8ed..ef72097e935 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -20,7 +20,6 @@ #include "clang/AST/CXXInheritance.h" #include "clang/AST/CharUnits.h" #include "clang/AST/DeclObjC.h" -#include "clang/AST/EvaluatedExprVisitor.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" #include "clang/AST/RecursiveASTVisitor.h" |

