Index: clang/lib/Analysis/BodyFarm.cpp
===================================================================
--- clang/lib/Analysis/BodyFarm.cpp
+++ clang/lib/Analysis/BodyFarm.cpp
@@ -780,7 +780,11 @@
// return self->_ivar;
ASTMaker M(Ctx);
- const VarDecl *selfVar = Prop->getGetterMethodDecl()->getSelfDecl();
+ const ObjCMethodDecl *MD = Prop->getGetterMethodDecl();
+ assert(MD == MD->getCanonicalDecl() &&
+ "The declaration of 'self' must belong to the method we're farming!");
+
+ const VarDecl *selfVar = MD->getSelfDecl();
if (!selfVar)
return nullptr;
Index: clang/lib/StaticAnalyzer/Core/CallEvent.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -1309,6 +1309,8 @@
}
const ObjCMethodDecl *MD = Val.getValue();
+ if (MD && !MD->hasBody())
+ MD = MD->getCanonicalDecl();
if (CanBeSubClassed)
return RuntimeDefinition(MD, Receiver);
else
Index: clang/test/Analysis/Inputs/expected-plists/nullability-notes.m.plist
===================================================================
--- clang/test/Analysis/Inputs/expected-plists/nullability-notes.m.plist
+++ clang/test/Analysis/Inputs/expected-plists/nullability-notes.m.plist
@@ -16,12 +16,46 @@
start
- line16
+ line31
col3
file0
- line16
+ line31
+ col33
+ file0
+
+
+ end
+
+
+ line33
+ col3
+ file0
+
+
+ line33
+ col10
+ file0
+
+
+
+
+
+
+ kindcontrol
+ edges
+
+
+ start
+
+
+ line33
+ col3
+ file0
+
+
+ line33
col10
file0
@@ -29,12 +63,12 @@
end
- line16
+ line33
col22
file0
- line16
+ line33
col22
file0
@@ -46,7 +80,7 @@
kindevent
location
- line16
+ line33
col22
file0
@@ -54,12 +88,12 @@
- line16
+ line33
col22
file0
- line16
+ line33
col22
file0
@@ -79,12 +113,12 @@
start
- line16
+ line33
col22
file0
- line16
+ line33
col22
file0
@@ -92,12 +126,12 @@
end
- line16
+ line33
col3
file0
- line16
+ line33
col10
file0
@@ -113,12 +147,12 @@
start
- line16
+ line33
col3
file0
- line16
+ line33
col10
file0
@@ -126,12 +160,12 @@
end
- line17
+ line36
col3
file0
- line17
+ line36
col14
file0
@@ -143,7 +177,7 @@
kindevent
location
- line17
+ line36
col3
file0
@@ -151,12 +185,12 @@
- line17
+ line36
col16
file0
- line17
+ line36
col16
file0
@@ -177,10 +211,10 @@
issue_hash_content_of_line_in_contextff735bea0eb12d4d172b139143c32365
issue_context_kindObjective-C method
issue_contextmethod
- issue_hash_function_offset3
+ issue_hash_function_offset6
location
- line17
+ line36
col3
file0
@@ -188,9 +222,11 @@
0
- 14
- 16
- 17
+ 26
+ 30
+ 31
+ 33
+ 36
Index: clang/test/Analysis/nullability-notes.m
===================================================================
--- clang/test/Analysis/nullability-notes.m
+++ clang/test/Analysis/nullability-notes.m
@@ -1,6 +1,22 @@
-// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced -analyzer-output=text -verify %s
-// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullableDereferenced -analyzer-output=plist -o %t.plist %s
-// RUN: %normalize_plist <%t.plist | diff -ub %S/Inputs/expected-plists/nullability-notes.m.plist -
+// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core \
+// RUN: -analyzer-checker=nullability.NullPassedToNonnull \
+// RUN: -analyzer-checker=nullability.NullReturnedFromNonnull \
+// RUN: -analyzer-checker=nullability.NullablePassedToNonnull \
+// RUN: -analyzer-checker=nullability.NullableReturnedFromNonnull \
+// RUN: -analyzer-checker=nullability.NullableDereferenced \
+// RUN: -analyzer-checker=debug.ExprInspection \
+// RUN: -analyzer-output=text -verify %s
+// RUN: %clang_analyze_cc1 -fblocks -analyzer-checker=core \
+// RUN: -analyzer-checker=nullability.NullPassedToNonnull \
+// RUN: -analyzer-checker=nullability.NullReturnedFromNonnull \
+// RUN: -analyzer-checker=nullability.NullablePassedToNonnull \
+// RUN: -analyzer-checker=nullability.NullableReturnedFromNonnull \
+// RUN: -analyzer-checker=nullability.NullableDereferenced \
+// RUN: -analyzer-output=plist -o %t.plist %s
+// RUN: %normalize_plist <%t.plist \
+// RUN: | diff -ub %S/Inputs/expected-plists/nullability-notes.m.plist -
+
+void clang_analyzer_warnOnDeadSymbol(id);
#include "Inputs/system-header-simulator-for-nullability.h"
@@ -12,8 +28,11 @@
@end;
@implementation ClassWithProperties
-(void) method {
+ clang_analyzer_warnOnDeadSymbol(self);
// no-crash
NSObject *x = self.x; // expected-note{{Nullability 'nullable' is inferred}}
+ // expected-warning@-1{{SYMBOL DEAD}}
+ // expected-note@-2 {{SYMBOL DEAD}}
takesNonnull(x); // expected-warning{{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
// expected-note@-1{{Nullable pointer is passed to a callee that requires a non-null 1st parameter}}
}