From e5a934d3c840872d58724383a83443ed38f1d831 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Sat, 13 Oct 2012 05:05:20 +0000 Subject: [PATCH] [analyzer] Remove the "direct bindings only" Environment lookup. This was only used by OSAtomicChecker and makes it more difficult to update values for expressions that the environment may look through instead (it's not the same as IgnoreParens). With this gone, we can have bindExpr bind to the inner expression that getSVal will find. Groundwork for git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165866 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../StaticAnalyzer/Core/PathSensitive/Environment.h | 4 +--- .../StaticAnalyzer/Core/PathSensitive/ProgramState.h | 10 ++++------ lib/StaticAnalyzer/Core/Environment.cpp | 12 +----------- 3 files changed, 6 insertions(+), 20 deletions(-) diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h b/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h index b80213e249..54fce6530b 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h @@ -76,9 +76,7 @@ public: /// Fetches the current binding of the expression in the /// Environment. - SVal getSVal(const EnvironmentEntry &E, - SValBuilder &svalBuilder, - bool useOnlyDirectBindings = false) const; + SVal getSVal(const EnvironmentEntry &E, SValBuilder &svalBuilder) const; /// Profile - Profile the contents of an Environment object for use /// in a FoldingSet. diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h index 541078cc89..86c94deab5 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -252,8 +252,7 @@ public: SVal getLValue(QualType ElementType, SVal Idx, SVal Base) const; /// Returns the SVal bound to the statement 'S' in the state's environment. - SVal getSVal(const Stmt *S, const LocationContext *LCtx, - bool useOnlyDirectBindings = false) const; + SVal getSVal(const Stmt *S, const LocationContext *LCtx) const; SVal getSValAsScalarOrLoc(const Stmt *Ex, const LocationContext *LCtx) const; @@ -666,11 +665,10 @@ inline SVal ProgramState::getLValue(QualType ElementType, SVal Idx, SVal Base) c return UnknownVal(); } -inline SVal ProgramState::getSVal(const Stmt *Ex, const LocationContext *LCtx, - bool useOnlyDirectBindings) const{ +inline SVal ProgramState::getSVal(const Stmt *Ex, + const LocationContext *LCtx) const{ return Env.getSVal(EnvironmentEntry(Ex, LCtx), - *getStateManager().svalBuilder, - useOnlyDirectBindings); + *getStateManager().svalBuilder); } inline SVal diff --git a/lib/StaticAnalyzer/Core/Environment.cpp b/lib/StaticAnalyzer/Core/Environment.cpp index a8c2da7642..07659cb601 100644 --- a/lib/StaticAnalyzer/Core/Environment.cpp +++ b/lib/StaticAnalyzer/Core/Environment.cpp @@ -30,17 +30,7 @@ SVal Environment::lookupExpr(const EnvironmentEntry &E) const { } SVal Environment::getSVal(const EnvironmentEntry &Entry, - SValBuilder& svalBuilder, - bool useOnlyDirectBindings) const { - - if (useOnlyDirectBindings) { - // This branch is rarely taken, but can be exercised by - // checkers that explicitly bind values to arbitrary - // expressions. It is crucial that we do not ignore any - // expression here, and do a direct lookup. - return lookupExpr(Entry); - } - + SValBuilder& svalBuilder) const { const Stmt *E = Entry.getStmt(); const LocationContext *LCtx = Entry.getLocationContext(); -- 2.40.0