]> granicus.if.org Git - clang/commit
[analyzer] Be less pessimistic about invalidation of global variables
authorAnna Zaks <ganna@apple.com>
Wed, 4 Jan 2012 23:54:01 +0000 (23:54 +0000)
committerAnna Zaks <ganna@apple.com>
Wed, 4 Jan 2012 23:54:01 +0000 (23:54 +0000)
commiteb31a76d1cdaaf8874c549dc6bd964ff270d3822
tree2431945856d47f0454cf15617fe52bd33e15b095
parentf063a3b783e22effa7972d05830cee942b2499ce
[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)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147569 91177308-0d34-0410-b5e6-96231b3b80d8
16 files changed:
include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
include/clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h
include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
lib/StaticAnalyzer/Checkers/MallocChecker.cpp
lib/StaticAnalyzer/Core/ExprEngine.cpp
lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
lib/StaticAnalyzer/Core/MemRegion.cpp
lib/StaticAnalyzer/Core/ProgramState.cpp
lib/StaticAnalyzer/Core/RegionStore.cpp
lib/StaticAnalyzer/Core/Store.cpp
test/Analysis/global-region-invalidation.c [new file with mode: 0644]
test/Analysis/misc-ps.c
test/Analysis/system-header-simulator.h [new file with mode: 0644]