summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAlexander Shaposhnikov <shal1t712@gmail.com>2016-09-23 20:49:01 +0000
committerAlexander Shaposhnikov <shal1t712@gmail.com>2016-09-23 20:49:01 +0000
commita1fead293fa6fd3296318290248cea04d860ad47 (patch)
tree2c1e24267ae9cf4d11a3a3f0a20ceb172ee517bc /clang/lib
parent2d1d944f7e79e113e5c3b93980ff3de51337ba91 (diff)
downloadbcm5719-llvm-a1fead293fa6fd3296318290248cea04d860ad47.tar.gz
bcm5719-llvm-a1fead293fa6fd3296318290248cea04d860ad47.zip
[analyzer] Fix crash in RetainCountChecker::checkEndFunction
The class BodyFarm creates bodies for OSAtomicCompareAndSwap*, objc_atomicCompareAndSwap*, dispatch_sync*, dispatch_once* and for them the flag isBodyAutosynthesized is set to true. This diff 1. makes AnalysisConsumer::HandleCode skip the autosynthesized code 2. replaces assert(LCtx->getParent()) in RetainCountChecker::checkEndFunction by assert(!LCtx->inTopFrame()) (minor cleanup) Test plan: make -j8 check-clang-analysis Differential revision: https://reviews.llvm.org/D24792 llvm-svn: 282293
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp8
2 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
index d445e91b0d6..13a4f87bd9d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -3863,7 +3863,7 @@ void RetainCountChecker::checkEndFunction(CheckerContext &Ctx) const {
// Don't process anything within synthesized bodies.
const LocationContext *LCtx = Pred->getLocationContext();
if (LCtx->getAnalysisDeclContext()->isBodyAutosynthesized()) {
- assert(LCtx->getParent());
+ assert(!LCtx->inTopFrame());
return;
}
diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
index 2faf62e3fcc..1dc490e1c70 100644
--- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -652,6 +652,12 @@ void AnalysisConsumer::HandleCode(Decl *D, AnalysisMode Mode,
if (Mode == AM_None)
return;
+ // Clear the AnalysisManager of old AnalysisDeclContexts.
+ Mgr->ClearContexts();
+ // Ignore autosynthesized code.
+ if (Mgr->getAnalysisDeclContext(D)->isBodyAutosynthesized())
+ return;
+
DisplayFunction(D, Mode, IMode);
CFG *DeclCFG = Mgr->getCFG(D);
if (DeclCFG) {
@@ -659,8 +665,6 @@ void AnalysisConsumer::HandleCode(Decl *D, AnalysisMode Mode,
MaxCFGSize = MaxCFGSize < CFGSize ? CFGSize : MaxCFGSize;
}
- // Clear the AnalysisManager of old AnalysisDeclContexts.
- Mgr->ClearContexts();
BugReporter BR(*Mgr);
if (Mode & AM_Syntax)
OpenPOWER on IntegriCloud