summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/AST/DeclObjC.cpp10
-rw-r--r--clang/test/Modules/Inputs/objc-method-redecl.h4
-rw-r--r--clang/test/Modules/objc-method-redecl.m8
3 files changed, 19 insertions, 3 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 47e032a2e54..fdbac00fc94 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -897,9 +897,13 @@ ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() {
return MD;
}
- if (isRedeclaration())
- return cast<ObjCContainerDecl>(CtxD)->getMethod(getSelector(),
- isInstanceMethod());
+ if (isRedeclaration()) {
+ // It is possible that we have not done deserializing the ObjCMethod yet.
+ ObjCMethodDecl *MD =
+ cast<ObjCContainerDecl>(CtxD)->getMethod(getSelector(),
+ isInstanceMethod());
+ return MD ? MD : this;
+ }
return this;
}
diff --git a/clang/test/Modules/Inputs/objc-method-redecl.h b/clang/test/Modules/Inputs/objc-method-redecl.h
new file mode 100644
index 00000000000..95c6533fad9
--- /dev/null
+++ b/clang/test/Modules/Inputs/objc-method-redecl.h
@@ -0,0 +1,4 @@
+@interface T
+- (void)test;
+- (void)test;
+@end
diff --git a/clang/test/Modules/objc-method-redecl.m b/clang/test/Modules/objc-method-redecl.m
new file mode 100644
index 00000000000..f7acda5450d
--- /dev/null
+++ b/clang/test/Modules/objc-method-redecl.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c-header -emit-pch %S/Inputs/objc-method-redecl.h -o %t.pch -Wno-objc-root-class
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x objective-c -include-pch %t.pch %s -verify -Wno-objc-root-class
+// expected-no-diagnostics
+
+@implementation T
+- (void)test {
+}
+@end
OpenPOWER on IntegriCloud