]> granicus.if.org Git - clang/commitdiff
Activate selectors in chained PCH. Chained PCH now works for Objective-C.
authorSebastian Redl <sebastian.redl@getdesigned.at>
Wed, 4 Aug 2010 22:21:29 +0000 (22:21 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Wed, 4 Aug 2010 22:21:29 +0000 (22:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110262 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/PCHWriter.cpp
test/PCH/Inputs/chain-selectors1.h [new file with mode: 0644]
test/PCH/Inputs/chain-selectors2.h [new file with mode: 0644]
test/PCH/chain-selectors.m [new file with mode: 0644]

index 53c05c8fdf212b5029b67d75ea99ad48006e474b..d5750a1f5049af6270592ee73e424e8386d2399f 100644 (file)
@@ -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<Selector, SourceLocation>::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 (file)
index 0000000..37c1c00
--- /dev/null
@@ -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 (file)
index 0000000..4d6b556
--- /dev/null
@@ -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 (file)
index 0000000..60db3f9
--- /dev/null
@@ -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}}
+}