From: Sebastian Redl Date: Wed, 4 Aug 2010 22:21:29 +0000 (+0000) Subject: Activate selectors in chained PCH. Chained PCH now works for Objective-C. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a68340fd55e177a5849cb3adbf66aedce1f6e91b;p=clang Activate selectors in chained PCH. Chained PCH now works for Objective-C. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110262 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index 53c05c8fdf..d5750a1f50 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -1752,6 +1752,9 @@ void PCHWriter::WriteReferencedSelectorsPool(Sema &SemaRef) { RecordData Record; + // Note: this writes out all references even for a dependent PCH. But it is + // very tricky to fix, and given that @selector shouldn't really appear in + // headers, probably not worth it. It's not a correctness issue. for (DenseMap::iterator S = SemaRef.ReferencedSelectors.begin(), E = SemaRef.ReferencedSelectors.end(); S != E; ++S) { @@ -2435,7 +2438,8 @@ void PCHWriter::WritePCHChain(Sema &SemaRef, MemorizeStatCalls *StatCalls, Stream.ExitBlock(); WritePreprocessor(PP); - // FIXME: Method pool + WriteSelectors(SemaRef); + WriteReferencedSelectorsPool(SemaRef); WriteIdentifierTable(PP); WriteTypeDeclOffsets(); diff --git a/test/PCH/Inputs/chain-selectors1.h b/test/PCH/Inputs/chain-selectors1.h new file mode 100644 index 0000000000..37c1c00b57 --- /dev/null +++ b/test/PCH/Inputs/chain-selectors1.h @@ -0,0 +1,12 @@ +@interface X + -(void)f; + -(void)f2; + -(void)g:(int)p; + -(void)h:(int)p1 foo:(int)p2; +@end + +void foo1() { + // FIXME: Can't verify warnings in headers + //(void)@selector(x); + (void)@selector(f); +} diff --git a/test/PCH/Inputs/chain-selectors2.h b/test/PCH/Inputs/chain-selectors2.h new file mode 100644 index 0000000000..4d6b556630 --- /dev/null +++ b/test/PCH/Inputs/chain-selectors2.h @@ -0,0 +1,11 @@ +@interface Y + -(void)f; + -(double)f2; + -(void)e; +@end + +void foo2() { + // FIXME: Can't verify warnings in headers + //(void)@selector(y); + //(void)@selector(e); +} diff --git a/test/PCH/chain-selectors.m b/test/PCH/chain-selectors.m new file mode 100644 index 0000000000..60db3f994b --- /dev/null +++ b/test/PCH/chain-selectors.m @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -Wselector -include %S/Inputs/chain-selectors1.h -include %S/Inputs/chain-selectors2.h + +// RUN: %clang_cc1 -x objective-c -emit-pch -o %t1 %S/Inputs/chain-selectors1.h +// RUN: %clang_cc1 -x objective-c -emit-pch -o %t2 %S/Inputs/chain-selectors2.h -include-pch %t1 -chained-pch +// RUN: %clang_cc1 -fsyntax-only -verify %s -Wselector -include-pch %t2 + +@implementation X +-(void)f {} +-(void)f2 {} +-(void)g: (int)p {} +-(void)h: (int)p1 foo: (int)p2 {} +@end + +void bar() { + id a = 0; + [a nothing]; // expected-warning {{method '-nothing' not found}} + [a f]; + // FIXME: Can't verify notes in headers + //[a f2]; + + (void)@selector(x); // expected-warning {{unimplemented selector}} + (void)@selector(y); // expected-warning {{unimplemented selector}} + (void)@selector(e); // expected-warning {{unimplemented selector}} +}