This revision was automatically updated to reflect the committed changes. Closed by commit rL282293: [analyzer] Fix crash in RetainCountChecker::checkEndFunction (authored by alexshap).
Changed prior to commit: https://reviews.llvm.org/D24792?vs=72206&id=72354#toc Repository: rL LLVM https://reviews.llvm.org/D24792 Files: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp cfe/trunk/test/Analysis/NSString.m Index: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -652,15 +652,19 @@ 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) { unsigned CFGSize = DeclCFG->size(); MaxCFGSize = MaxCFGSize < CFGSize ? CFGSize : MaxCFGSize; } - // Clear the AnalysisManager of old AnalysisDeclContexts. - Mgr->ClearContexts(); BugReporter BR(*Mgr); if (Mode & AM_Syntax) Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -3863,7 +3863,7 @@ // Don't process anything within synthesized bodies. const LocationContext *LCtx = Pred->getLocationContext(); if (LCtx->getAnalysisDeclContext()->isBodyAutosynthesized()) { - assert(LCtx->getParent()); + assert(!LCtx->inTopFrame()); return; } Index: cfe/trunk/test/Analysis/NSString.m =================================================================== --- cfe/trunk/test/Analysis/NSString.m +++ cfe/trunk/test/Analysis/NSString.m @@ -289,7 +289,11 @@ _Bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue ) { return opaque_OSAtomicCompareAndSwapPtr(__oldValue, __newValue, __theValue); } - +// Test that the analyzer doesn't crash when the farm model is used. +// The analyzer ignores the autosynthesized code. +_Bool OSAtomicCompareAndSwapEmptyFunction( void *__oldValue, void *__newValue, void * volatile *__theValue ) { + return 0; +} extern BOOL opaque_objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation); extern BOOL objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation) { return opaque_objc_atomicCompareAndSwapPtr(predicate, replacement, objectLocation); @@ -441,4 +445,4 @@ - (void)callValue { [self _value]; } -@end \ No newline at end of file +@end
Index: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -652,15 +652,19 @@ 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) { unsigned CFGSize = DeclCFG->size(); MaxCFGSize = MaxCFGSize < CFGSize ? CFGSize : MaxCFGSize; } - // Clear the AnalysisManager of old AnalysisDeclContexts. - Mgr->ClearContexts(); BugReporter BR(*Mgr); if (Mode & AM_Syntax) Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp =================================================================== --- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -3863,7 +3863,7 @@ // Don't process anything within synthesized bodies. const LocationContext *LCtx = Pred->getLocationContext(); if (LCtx->getAnalysisDeclContext()->isBodyAutosynthesized()) { - assert(LCtx->getParent()); + assert(!LCtx->inTopFrame()); return; } Index: cfe/trunk/test/Analysis/NSString.m =================================================================== --- cfe/trunk/test/Analysis/NSString.m +++ cfe/trunk/test/Analysis/NSString.m @@ -289,7 +289,11 @@ _Bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue ) { return opaque_OSAtomicCompareAndSwapPtr(__oldValue, __newValue, __theValue); } - +// Test that the analyzer doesn't crash when the farm model is used. +// The analyzer ignores the autosynthesized code. +_Bool OSAtomicCompareAndSwapEmptyFunction( void *__oldValue, void *__newValue, void * volatile *__theValue ) { + return 0; +} extern BOOL opaque_objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation); extern BOOL objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation) { return opaque_objc_atomicCompareAndSwapPtr(predicate, replacement, objectLocation); @@ -441,4 +445,4 @@ - (void)callValue { [self _value]; } -@end \ No newline at end of file +@end
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits