From a1fead293fa6fd3296318290248cea04d860ad47 Mon Sep 17 00:00:00 2001 From: Alexander Shaposhnikov Date: Fri, 23 Sep 2016 20:49:01 +0000 Subject: [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 --- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'clang/lib/StaticAnalyzer/Frontend') 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) -- cgit v1.2.3