diff options
author | Anna Zaks <ganna@apple.com> | 2012-02-16 03:40:57 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-02-16 03:40:57 +0000 |
commit | d32ead82d93f38ec11ba78a6c95bc41db377c99e (patch) | |
tree | dd4a7cc03e45313820405242604f58a44b31205d /clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp | |
parent | 17100bad0ac1b25e9f4f2dd8ef6d5629ad1364d6 (diff) | |
download | bcm5719-llvm-d32ead82d93f38ec11ba78a6c95bc41db377c99e.tar.gz bcm5719-llvm-d32ead82d93f38ec11ba78a6c95bc41db377c99e.zip |
[analyzer] Malloc Checker: Give up when a pointer escapes into a struct.
We are not properly handling the memory regions that escape into struct
fields, which led to a bunch of false positives. Be conservative here
and give up when a pointer escapes into a struct.
llvm-svn: 150658
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp index 88a0613a78f..a14057980fe 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -924,6 +924,12 @@ void MallocChecker::checkBind(SVal loc, SVal val, const Stmt *S, // the binding). escapes = (state == (state->bindLoc(*regionLoc, val))); } + if (!escapes) { + // Case 4: We do not currently model what happens when a symbol is + // assigned to a struct field, so be conservative here and let the symbol + // go. TODO: This could definitely be improved upon. + escapes = !isa<VarRegion>(regionLoc->getRegion()); + } } // If our store can represent the binding and we aren't storing to something |