]> granicus.if.org Git - clang/commitdiff
Correctly deal with using names for both functions and structs in chained PCH.
authorSebastian Redl <sebastian.redl@getdesigned.at>
Fri, 30 Jul 2010 17:25:10 +0000 (17:25 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Fri, 30 Jul 2010 17:25:10 +0000 (17:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109871 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/IdentifierResolver.cpp
test/PCH/Inputs/chain-decls1.h [new file with mode: 0644]
test/PCH/Inputs/chain-decls2.h [new file with mode: 0644]
test/PCH/Inputs/chain-function1.h [deleted file]
test/PCH/Inputs/chain-function2.h [deleted file]
test/PCH/chain-decls.c [new file with mode: 0644]
test/PCH/chain-function.c [deleted file]

index b09526e097b603911607559c7cdca1e64a4627da..62df1a7c2c5b20b3ae31a49b54a4cf7ad21b00f8 100644 (file)
@@ -139,6 +139,9 @@ bool IdentifierResolver::isDeclInScope(Decl *D, DeclContext *Ctx,
 /// AddDecl - Link the decl to its shadowed decl chain.
 void IdentifierResolver::AddDecl(NamedDecl *D) {
   DeclarationName Name = D->getDeclName();
+  if (IdentifierInfo *II = Name.getAsIdentifierInfo())
+    II->setIsFromPCH(false);
+
   void *Ptr = Name.getFETokenInfo<void>();
 
   if (!Ptr) {
@@ -164,6 +167,9 @@ void IdentifierResolver::AddDecl(NamedDecl *D) {
 void IdentifierResolver::RemoveDecl(NamedDecl *D) {
   assert(D && "null param passed");
   DeclarationName Name = D->getDeclName();
+  if (IdentifierInfo *II = Name.getAsIdentifierInfo())
+    II->setIsFromPCH(false);
+
   void *Ptr = Name.getFETokenInfo<void>();
 
   assert(Ptr && "Didn't find this decl on its identifier's chain!");
@@ -182,6 +188,9 @@ bool IdentifierResolver::ReplaceDecl(NamedDecl *Old, NamedDecl *New) {
          "Cannot replace a decl with another decl of a different name");
 
   DeclarationName Name = Old->getDeclName();
+  if (IdentifierInfo *II = Name.getAsIdentifierInfo())
+    II->setIsFromPCH(false);
+
   void *Ptr = Name.getFETokenInfo<void>();
 
   if (!Ptr)
@@ -218,6 +227,7 @@ IdentifierResolver::begin(DeclarationName Name) {
 
 void IdentifierResolver::AddDeclToIdentifierChain(IdentifierInfo *II,
                                                   NamedDecl *D) {
+  II->setIsFromPCH(false);
   void *Ptr = II->getFETokenInfo<void>();
 
   if (!Ptr) {
diff --git a/test/PCH/Inputs/chain-decls1.h b/test/PCH/Inputs/chain-decls1.h
new file mode 100644 (file)
index 0000000..79586ce
--- /dev/null
@@ -0,0 +1,4 @@
+void f();
+
+struct one {};
+void two();
diff --git a/test/PCH/Inputs/chain-decls2.h b/test/PCH/Inputs/chain-decls2.h
new file mode 100644 (file)
index 0000000..1826da9
--- /dev/null
@@ -0,0 +1,5 @@
+void g();
+
+struct two {};
+void one();
+struct three {}; // for verification
diff --git a/test/PCH/Inputs/chain-function1.h b/test/PCH/Inputs/chain-function1.h
deleted file mode 100644 (file)
index 789447c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-void f();
diff --git a/test/PCH/Inputs/chain-function2.h b/test/PCH/Inputs/chain-function2.h
deleted file mode 100644 (file)
index e8fc965..0000000
+++ /dev/null
@@ -1 +0,0 @@
-void g();
diff --git a/test/PCH/chain-decls.c b/test/PCH/chain-decls.c
new file mode 100644 (file)
index 0000000..f790a29
--- /dev/null
@@ -0,0 +1,22 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/chain-decls1.h -include %S/Inputs/chain-decls2.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-decls1.h
+// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-decls2.h -include-pch %t1 -chained-pch
+// RUN: %clang_cc1 -include-pch %t2 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -ast-print -include-pch %t2 %s | FileCheck %s
+
+// CHECK: void f();
+// CHECK: void g();
+
+void h() {
+  f();
+  g();
+
+  struct one x;
+  one();
+  struct two y;
+  two();
+  struct three z;
+}
diff --git a/test/PCH/chain-function.c b/test/PCH/chain-function.c
deleted file mode 100644 (file)
index 0d766fb..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -emit-pch -o %t1 %S/Inputs/chain-function1.h
-// RUN: %clang_cc1 -emit-pch -o %t2 %S/Inputs/chain-function2.h -include-pch %t1 -chained-pch
-// RUN: %clang_cc1 -fsyntax-only -verify -include-pch %t2 %s
-// RUN: %clang_cc1 -ast-print -include-pch %t2 %s | FileCheck %s
-
-// CHECK: void f();
-// CHECK: void g();
-
-void h() {
-  f();
-  g();
-}