forked from OSchip/llvm-project
Correctly deal with using names for both functions and structs in chained PCH.
llvm-svn: 109871
This commit is contained in:
parent
7957c73f0b
commit
671eee9e68
|
@ -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) {
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
void f();
|
||||
|
||||
struct one {};
|
||||
void two();
|
|
@ -0,0 +1,5 @@
|
|||
void g();
|
||||
|
||||
struct two {};
|
||||
void one();
|
||||
struct three {}; // for verification
|
|
@ -1 +0,0 @@
|
|||
void f();
|
|
@ -1 +0,0 @@
|
|||
void g();
|
|
@ -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;
|
||||
}
|
|
@ -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();
|
||||
}
|
Loading…
Reference in New Issue