From 8158ef0dec7e940c4e8dbe59ee688d1a044c7b95 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Wed, 4 Jan 2012 23:54:01 +0000 Subject: [analyzer] Be less pessimistic about invalidation of global variables as a result of a call. Problem: Global variables, which come in from system libraries should not be invalidated by all calls. Also, non-system globals should not be invalidated by system calls. Solution: The following solution to invalidation of globals seems flexible enough for taint (does not invalidate stdin) and should not lead to too many false positives. We split globals into 3 classes: * immutable - values are preserved by calls (unless the specific global is passed in as a parameter): A : Most system globals and const scalars * invalidated by functions defined in system headers: B: errno * invalidated by all other functions (note, these functions may in turn contain system calls): B: errno C: all other globals (which are not in A nor B) llvm-svn: 147569 --- clang/lib/StaticAnalyzer/Core/ProgramState.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'clang/lib/StaticAnalyzer/Core/ProgramState.cpp') diff --git a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp index eac9c1c99c1..4b98ce8b0f7 100644 --- a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp +++ b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -136,20 +136,20 @@ const ProgramState * ProgramState::invalidateRegions(ArrayRef Regions, const Expr *E, unsigned Count, StoreManager::InvalidatedSymbols *IS, - bool invalidateGlobals) const { + const CallOrObjCMessage *Call) const { if (!IS) { StoreManager::InvalidatedSymbols invalidated; return invalidateRegionsImpl(Regions, E, Count, - invalidated, invalidateGlobals); + invalidated, Call); } - return invalidateRegionsImpl(Regions, E, Count, *IS, invalidateGlobals); + return invalidateRegionsImpl(Regions, E, Count, *IS, Call); } const ProgramState * ProgramState::invalidateRegionsImpl(ArrayRef Regions, const Expr *E, unsigned Count, StoreManager::InvalidatedSymbols &IS, - bool invalidateGlobals) const { + const CallOrObjCMessage *Call) const { ProgramStateManager &Mgr = getStateManager(); SubEngine* Eng = Mgr.getOwningEngine(); @@ -157,14 +157,14 @@ ProgramState::invalidateRegionsImpl(ArrayRef Regions, StoreManager::InvalidatedRegions Invalidated; const StoreRef &newStore = Mgr.StoreMgr->invalidateRegions(getStore(), Regions, E, Count, IS, - invalidateGlobals, &Invalidated); + Call, &Invalidated); const ProgramState *newState = makeWithStore(newStore); return Eng->processRegionChanges(newState, &IS, Regions, Invalidated); } const StoreRef &newStore = Mgr.StoreMgr->invalidateRegions(getStore(), Regions, E, Count, IS, - invalidateGlobals, NULL); + Call, NULL); return makeWithStore(newStore); } -- cgit v1.2.3