From: Argyrios Kyrtzidis Date: Thu, 3 May 2012 02:26:32 +0000 (+0000) Subject: [PCH] Clear switch case IDs when deserializing a objc method body. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67835c1a7ebaffd8613892e6bedfdb045eaf823f;p=clang [PCH] Clear switch case IDs when deserializing a objc method body. Fixes rdar://11353109 & http://llvm.org/bugs/show_bug.cgi?id=12689 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156056 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 8dd53ee7d2..15aa90b351 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -629,6 +629,8 @@ void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) { if (Record[Idx++]) { // In practice, this won't be executed (since method definitions // don't occur in header files). + // Switch case IDs are per method body. + Reader.ClearSwitchCaseIDs(); MD->setBody(Reader.ReadStmt(F)); MD->setSelfDecl(ReadDeclAs(Record, Idx)); MD->setCmdDecl(ReadDeclAs(Record, Idx)); diff --git a/test/PCH/objc_methods.h b/test/PCH/objc_methods.h index c9b1ad4342..7b9e22decb 100644 --- a/test/PCH/objc_methods.h +++ b/test/PCH/objc_methods.h @@ -9,3 +9,19 @@ // FIXME: @compatibility_alias AliasForTestPCH TestPCH; +// http://llvm.org/PR12689 +@interface PR12689 +@end + +@implementation PR12689 +-(void)mugi:(int)x { + switch(x) { + case 23: {} + } +} +-(void)bonk:(int)x { + switch(x) { + case 42: {} + } +} +@end