[cfe-commits] r110262 - in /cfe/trunk: lib/Frontend/PCHWriter.cpp test/PCH/Inputs/chain-selectors1.h test/PCH/Inputs/chain-selectors2.h test/PCH/chain-selectors.m

Sebastian Redl sebastian.redl at getdesigned.at
Wed Aug 4 15:21:29 PDT 2010


Author: cornedbee
Date: Wed Aug  4 17:21:29 2010
New Revision: 110262

URL: http://llvm.org/viewvc/llvm-project?rev=110262&view=rev
Log:
Activate selectors in chained PCH. Chained PCH now works for Objective-C.

Added:
    cfe/trunk/test/PCH/Inputs/chain-selectors1.h
    cfe/trunk/test/PCH/Inputs/chain-selectors2.h
    cfe/trunk/test/PCH/chain-selectors.m
Modified:
    cfe/trunk/lib/Frontend/PCHWriter.cpp

Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=110262&r1=110261&r2=110262&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Wed Aug  4 17:21:29 2010
@@ -1752,6 +1752,9 @@
 
   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 @@
   Stream.ExitBlock();
 
   WritePreprocessor(PP);
-  // FIXME: Method pool
+  WriteSelectors(SemaRef);
+  WriteReferencedSelectorsPool(SemaRef);
   WriteIdentifierTable(PP);
   WriteTypeDeclOffsets();
 

Added: cfe/trunk/test/PCH/Inputs/chain-selectors1.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/chain-selectors1.h?rev=110262&view=auto
==============================================================================
--- cfe/trunk/test/PCH/Inputs/chain-selectors1.h (added)
+++ cfe/trunk/test/PCH/Inputs/chain-selectors1.h Wed Aug  4 17:21:29 2010
@@ -0,0 +1,12 @@
+ at interface X
+  -(void)f;
+  -(void)f2;
+  -(void)g:(int)p;
+  -(void)h:(int)p1 foo:(int)p2;
+ at end
+
+void foo1() {
+  // FIXME: Can't verify warnings in headers
+  //(void)@selector(x);
+  (void)@selector(f);
+}

Added: cfe/trunk/test/PCH/Inputs/chain-selectors2.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/chain-selectors2.h?rev=110262&view=auto
==============================================================================
--- cfe/trunk/test/PCH/Inputs/chain-selectors2.h (added)
+++ cfe/trunk/test/PCH/Inputs/chain-selectors2.h Wed Aug  4 17:21:29 2010
@@ -0,0 +1,11 @@
+ at interface Y
+  -(void)f;
+  -(double)f2;
+  -(void)e;
+ at end
+
+void foo2() {
+  // FIXME: Can't verify warnings in headers
+  //(void)@selector(y);
+  //(void)@selector(e);
+}

Added: cfe/trunk/test/PCH/chain-selectors.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/chain-selectors.m?rev=110262&view=auto
==============================================================================
--- cfe/trunk/test/PCH/chain-selectors.m (added)
+++ cfe/trunk/test/PCH/chain-selectors.m Wed Aug  4 17:21:29 2010
@@ -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
+
+ at implementation X
+-(void)f {}
+-(void)f2 {}
+-(void)g: (int)p {}
+-(void)h: (int)p1 foo: (int)p2 {}
+ at 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}}
+}





More information about the cfe-commits mailing list