Author: dcoughlin Date: Mon Apr 11 19:53:26 2016 New Revision: 266031 URL: http://llvm.org/viewvc/llvm-project?rev=266031&view=rev Log: [analyzer] Fix assertion in ReturnVisitor for body-farm synthesized getters Don't emit a path note marking the return site if the return statement does not have a valid location. This fixes an assertion failure I introduced in r265839.
Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp cfe/trunk/test/Analysis/inlining/false-positive-suppression.m Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=266031&r1=266030&r2=266031&view=diff ============================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Mon Apr 11 19:53:26 2016 @@ -324,6 +324,9 @@ public: } PathDiagnosticLocation L(Ret, BRC.getSourceManager(), StackFrame); + if (!L.isValid() || !L.asLocation().isValid()) + return nullptr; + return new PathDiagnosticEventPiece(L, Out.str()); } Modified: cfe/trunk/test/Analysis/inlining/false-positive-suppression.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/false-positive-suppression.m?rev=266031&r1=266030&r2=266031&view=diff ============================================================================== --- cfe/trunk/test/Analysis/inlining/false-positive-suppression.m (original) +++ cfe/trunk/test/Analysis/inlining/false-positive-suppression.m Mon Apr 11 19:53:26 2016 @@ -45,6 +45,8 @@ __attribute__((objc_root_class)) @property(readonly) int *propertyReturningNull; +@property(readonly) int *synthesizedProperty; + @end @implementation SomeClass @@ -70,5 +72,16 @@ void testPropertyReturningNull(SomeClass *result = 1; #ifndef SUPPRESSED // expected-warning@-2 {{Dereference of null pointer}} +#endif +} + +void testSynthesizedPropertyReturningNull(SomeClass *sc) { + if (sc.synthesizedProperty) + return; + + int *result = sc.synthesizedProperty; + *result = 1; +#ifndef SUPPRESSED + // expected-warning@-2 {{Dereference of null pointer}} #endif } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits