summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp3
-rw-r--r--clang/test/Analysis/inlining/false-positive-suppression.m13
2 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index e0f014714f7..657d33fa7a3 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -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());
}
diff --git a/clang/test/Analysis/inlining/false-positive-suppression.m b/clang/test/Analysis/inlining/false-positive-suppression.m
index 7be1cb8472f..d9678206c7c 100644
--- a/clang/test/Analysis/inlining/false-positive-suppression.m
+++ b/clang/test/Analysis/inlining/false-positive-suppression.m
@@ -45,6 +45,8 @@ __attribute__((objc_root_class))
@property(readonly) int *propertyReturningNull;
+@property(readonly) int *synthesizedProperty;
+
@end
@implementation SomeClass
@@ -72,3 +74,14 @@ void testPropertyReturningNull(SomeClass *sc) {
// 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
+}
OpenPOWER on IntegriCloud