]> granicus.if.org Git - clang/commitdiff
Objective-C error recovery. This patch makes a quick
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 13 May 2013 17:27:00 +0000 (17:27 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 13 May 2013 17:27:00 +0000 (17:27 +0000)
recovery form duplicate method definition error thus
preventing doc parsing to loop trying to find comment
for the invalid redefinition in a previous declaration.
// rdar://13836387

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181710 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
lib/Sema/SemaDeclObjC.cpp
test/Sema/warn-documentation.m

index 49e3639e939878a34e6608ce7913b32eeb45279e..21a16a6d98267ec112979783f4ffcabb9a4cf824 100644 (file)
@@ -409,6 +409,8 @@ comments::FullComment *ASTContext::cloneFullComment(comments::FullComment *FC,
 comments::FullComment *ASTContext::getCommentForDecl(
                                               const Decl *D,
                                               const Preprocessor *PP) const {
+  if (D->isInvalidDecl())
+    return NULL;
   D = adjustDeclToTemplate(D);
   
   const Decl *Canonical = D->getCanonicalDecl();
index f33e7bcb1671cc08db3dd56e1e06adf5cfc16c38..07610585c5101374ed6150186bb79db0d6312448 100644 (file)
@@ -3052,6 +3052,8 @@ Decl *Sema::ActOnMethodDeclaration(
     Diag(ObjCMethod->getLocation(), diag::err_duplicate_method_decl)
       << ObjCMethod->getDeclName();
     Diag(PrevMethod->getLocation(), diag::note_previous_declaration);
+    ObjCMethod->setInvalidDecl();
+    return ObjCMethod;
   }
 
   // If this Objective-C method does not have a related result type, but we
index 14e0c347e3f9b118b6258087b5056036b2e0207b..272048050966e4f5e1aa613261e73d644aedf48b 100644 (file)
@@ -176,3 +176,24 @@ struct S;
 // expected-warning@+1 {{unknown command tag name}}
 /// \t bbb IS_DOXYGEN_END
 int FooBar();
+
+// rdar://13836387
+/** \brief Module handling the incoming notifications from the system.
+ *
+ * This includes:
+ * - Network Reachability
+ * - Power State
+ * - Low Disk
+ */
+@interface BRC : NSObject
+- (void)removeReach:(NSObject*)observer;
+@end
+
+@implementation BRC : NSObject
+- (void)removeReach:(NSObject*)observer // expected-note {{previous declaration is here}}
+{
+}
+- (void)removeReach:(NSObject*)observer // expected-error {{duplicate declaration of method 'removeReach:'}}
+{
+}
+@end