diff options
author | Anna Zaks <ganna@apple.com> | 2013-02-07 23:05:43 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2013-02-07 23:05:43 +0000 |
commit | acdc13cb00591e2ab2b168c7924d7eb57fa4808e (patch) | |
tree | 2bb86597344e1dc645c2501fc028214b3f8bdd17 /clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp | |
parent | 7c1f408636d2d2cb2bc5890735d6cac1658dd28e (diff) | |
download | bcm5719-llvm-acdc13cb00591e2ab2b168c7924d7eb57fa4808e.tar.gz bcm5719-llvm-acdc13cb00591e2ab2b168c7924d7eb57fa4808e.zip |
[analyzer] Add pointer escape type param to checkPointerEscape callback
The checkPointerEscape callback previously did not specify how a
pointer escaped. This change includes an enum which describes the
different ways a pointer may escape. This enum is passed to the
checkPointerEscape callback when a pointer escapes. If the escape
is due to a function call, the call is passed. This changes
previous behavior where the call is passed as NULL if the escape
was due to indirectly invalidating the region the pointer referenced.
A patch by Branden Archer!
llvm-svn: 174677
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 33553a1385f..9afd8cff4c7 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -158,7 +158,8 @@ public: ProgramStateRef checkPointerEscape(ProgramStateRef State, const InvalidatedSymbols &Escaped, - const CallEvent *Call) const; + const CallEvent *Call, + PointerEscapeKind Kind) const; void printState(raw_ostream &Out, ProgramStateRef State, const char *NL, const char *Sep) const; @@ -1450,11 +1451,15 @@ bool MallocChecker::doesNotFreeMemory(const CallEvent *Call, ProgramStateRef MallocChecker::checkPointerEscape(ProgramStateRef State, const InvalidatedSymbols &Escaped, - const CallEvent *Call) const { + const CallEvent *Call, + PointerEscapeKind Kind) const { // If we know that the call does not free memory, keep tracking the top // level arguments. - if (Call && doesNotFreeMemory(Call, State)) + if ((Kind == PSK_DirectEscapeOnCall || + Kind == PSK_IndirectEscapeOnCall) && + doesNotFreeMemory(Call, State)) { return State; + } for (InvalidatedSymbols::const_iterator I = Escaped.begin(), E = Escaped.end(); |