From: Fariborz Jahanian Date: Mon, 13 May 2013 17:27:00 +0000 (+0000) Subject: Objective-C error recovery. This patch makes a quick X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fbff0c4510c7f0e0f30a005960e434b973f5bd21;p=clang Objective-C error recovery. This patch makes a quick 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 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 49e3639e93..21a16a6d98 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -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(); diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index f33e7bcb16..07610585c5 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -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 diff --git a/test/Sema/warn-documentation.m b/test/Sema/warn-documentation.m index 14e0c347e3..2720480509 100644 --- a/test/Sema/warn-documentation.m +++ b/test/Sema/warn-documentation.m @@ -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