[cfe-commits] r109871 - in /cfe/trunk: lib/Sema/IdentifierResolver.cpp test/PCH/Inputs/chain-decls1.h test/PCH/Inputs/chain-decls2.h test/PCH/Inputs/chain-function1.h test/PCH/Inputs/chain-function2.h test/PCH/chain-decls.c test/PCH/chain-function.c
Sebastian Redl
sebastian.redl at getdesigned.at
Fri Jul 30 10:25:10 PDT 2010
Author: cornedbee
Date: Fri Jul 30 12:25:10 2010
New Revision: 109871
URL: http://llvm.org/viewvc/llvm-project?rev=109871&view=rev
Log:
Correctly deal with using names for both functions and structs in chained PCH.
Added:
cfe/trunk/test/PCH/Inputs/chain-decls1.h
- copied, changed from r109864, cfe/trunk/test/PCH/Inputs/chain-function1.h
cfe/trunk/test/PCH/Inputs/chain-decls2.h
- copied, changed from r109864, cfe/trunk/test/PCH/Inputs/chain-function2.h
cfe/trunk/test/PCH/chain-decls.c
- copied, changed from r109864, cfe/trunk/test/PCH/chain-function.c
Removed:
cfe/trunk/test/PCH/Inputs/chain-function1.h
cfe/trunk/test/PCH/Inputs/chain-function2.h
cfe/trunk/test/PCH/chain-function.c
Modified:
cfe/trunk/lib/Sema/IdentifierResolver.cpp
Modified: cfe/trunk/lib/Sema/IdentifierResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/IdentifierResolver.cpp?rev=109871&r1=109870&r2=109871&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/trunk/lib/Sema/IdentifierResolver.cpp Fri Jul 30 12:25:10 2010
@@ -139,6 +139,9 @@
/// 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::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 @@
"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 @@
void IdentifierResolver::AddDeclToIdentifierChain(IdentifierInfo *II,
NamedDecl *D) {
+ II->setIsFromPCH(false);
void *Ptr = II->getFETokenInfo<void>();
if (!Ptr) {
Copied: cfe/trunk/test/PCH/Inputs/chain-decls1.h (from r109864, cfe/trunk/test/PCH/Inputs/chain-function1.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/chain-decls1.h?p2=cfe/trunk/test/PCH/Inputs/chain-decls1.h&p1=cfe/trunk/test/PCH/Inputs/chain-function1.h&r1=109864&r2=109871&rev=109871&view=diff
==============================================================================
--- cfe/trunk/test/PCH/Inputs/chain-function1.h (original)
+++ cfe/trunk/test/PCH/Inputs/chain-decls1.h Fri Jul 30 12:25:10 2010
@@ -1 +1,4 @@
void f();
+
+struct one {};
+void two();
Copied: cfe/trunk/test/PCH/Inputs/chain-decls2.h (from r109864, cfe/trunk/test/PCH/Inputs/chain-function2.h)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/chain-decls2.h?p2=cfe/trunk/test/PCH/Inputs/chain-decls2.h&p1=cfe/trunk/test/PCH/Inputs/chain-function2.h&r1=109864&r2=109871&rev=109871&view=diff
==============================================================================
--- cfe/trunk/test/PCH/Inputs/chain-function2.h (original)
+++ cfe/trunk/test/PCH/Inputs/chain-decls2.h Fri Jul 30 12:25:10 2010
@@ -1 +1,5 @@
void g();
+
+struct two {};
+void one();
+struct three {}; // for verification
Removed: cfe/trunk/test/PCH/Inputs/chain-function1.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/chain-function1.h?rev=109870&view=auto
==============================================================================
--- cfe/trunk/test/PCH/Inputs/chain-function1.h (original)
+++ cfe/trunk/test/PCH/Inputs/chain-function1.h (removed)
@@ -1 +0,0 @@
-void f();
Removed: cfe/trunk/test/PCH/Inputs/chain-function2.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/chain-function2.h?rev=109870&view=auto
==============================================================================
--- cfe/trunk/test/PCH/Inputs/chain-function2.h (original)
+++ cfe/trunk/test/PCH/Inputs/chain-function2.h (removed)
@@ -1 +0,0 @@
-void g();
Copied: cfe/trunk/test/PCH/chain-decls.c (from r109864, cfe/trunk/test/PCH/chain-function.c)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/chain-decls.c?p2=cfe/trunk/test/PCH/chain-decls.c&p1=cfe/trunk/test/PCH/chain-function.c&r1=109864&r2=109871&rev=109871&view=diff
==============================================================================
--- cfe/trunk/test/PCH/chain-function.c (original)
+++ cfe/trunk/test/PCH/chain-decls.c Fri Jul 30 12:25:10 2010
@@ -1,6 +1,10 @@
-// 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
+// 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();
@@ -9,4 +13,10 @@
void h() {
f();
g();
+
+ struct one x;
+ one();
+ struct two y;
+ two();
+ struct three z;
}
Removed: cfe/trunk/test/PCH/chain-function.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/chain-function.c?rev=109870&view=auto
==============================================================================
--- cfe/trunk/test/PCH/chain-function.c (original)
+++ cfe/trunk/test/PCH/chain-function.c (removed)
@@ -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();
-}
More information about the cfe-commits
mailing list