forked from OSchip/llvm-project
Support PCH emitting/reading of using declarations.
llvm-svn: 106404
This commit is contained in:
parent
22a544bc82
commit
41d4562da2
|
|
@ -1854,9 +1854,12 @@ class UsingShadowDecl : public NamedDecl {
|
|||
|
||||
UsingShadowDecl(DeclContext *DC, SourceLocation Loc, UsingDecl *Using,
|
||||
NamedDecl *Target)
|
||||
: NamedDecl(UsingShadow, DC, Loc, Target->getDeclName()),
|
||||
: NamedDecl(UsingShadow, DC, Loc, DeclarationName()),
|
||||
Underlying(Target), Using(Using) {
|
||||
IdentifierNamespace = Target->getIdentifierNamespace();
|
||||
if (Target) {
|
||||
setDeclName(Target->getDeclName());
|
||||
IdentifierNamespace = Target->getIdentifierNamespace();
|
||||
}
|
||||
setImplicit();
|
||||
}
|
||||
|
||||
|
|
@ -1873,7 +1876,11 @@ public:
|
|||
|
||||
/// \brief Sets the underlying declaration which has been brought into the
|
||||
/// local scope.
|
||||
void setTargetDecl(NamedDecl* ND) { Underlying = ND; }
|
||||
void setTargetDecl(NamedDecl* ND) {
|
||||
assert(ND && "Target decl is null!");
|
||||
Underlying = ND;
|
||||
IdentifierNamespace = ND->getIdentifierNamespace();
|
||||
}
|
||||
|
||||
/// \brief Gets the using declaration to which this declaration is tied.
|
||||
UsingDecl *getUsingDecl() const { return Using; }
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ namespace {
|
|||
void VisitClassTemplateDecl(ClassTemplateDecl *D);
|
||||
void visitFunctionTemplateDecl(FunctionTemplateDecl *D);
|
||||
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D);
|
||||
void VisitUsing(UsingDecl *D);
|
||||
void VisitUsingShadow(UsingShadowDecl *D);
|
||||
void VisitUsingDecl(UsingDecl *D);
|
||||
void VisitUsingShadowDecl(UsingShadowDecl *D);
|
||||
void VisitLinkageSpecDecl(LinkageSpecDecl *D);
|
||||
void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD);
|
||||
void VisitAccessSpecDecl(AccessSpecDecl *D);
|
||||
|
|
@ -505,7 +505,7 @@ void PCHDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
|
|||
D->setAliasedNamespace(cast<NamedDecl>(Reader.GetDecl(Record[Idx++])));
|
||||
}
|
||||
|
||||
void PCHDeclReader::VisitUsing(UsingDecl *D) {
|
||||
void PCHDeclReader::VisitUsingDecl(UsingDecl *D) {
|
||||
VisitNamedDecl(D);
|
||||
D->setUsingLocation(Reader.ReadSourceLocation(Record, Idx));
|
||||
D->setNestedNameRange(Reader.ReadSourceRange(Record, Idx));
|
||||
|
|
@ -521,7 +521,7 @@ void PCHDeclReader::VisitUsing(UsingDecl *D) {
|
|||
D->setTypeName(Record[Idx++]);
|
||||
}
|
||||
|
||||
void PCHDeclReader::VisitUsingShadow(UsingShadowDecl *D) {
|
||||
void PCHDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) {
|
||||
VisitNamedDecl(D);
|
||||
D->setTargetDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++])));
|
||||
D->setUsingDecl(cast<UsingDecl>(Reader.GetDecl(Record[Idx++])));
|
||||
|
|
|
|||
|
|
@ -77,8 +77,8 @@ namespace {
|
|||
void VisitClassTemplateDecl(ClassTemplateDecl *D);
|
||||
void visitFunctionTemplateDecl(FunctionTemplateDecl *D);
|
||||
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D);
|
||||
void VisitUsing(UsingDecl *D);
|
||||
void VisitUsingShadow(UsingShadowDecl *D);
|
||||
void VisitUsingDecl(UsingDecl *D);
|
||||
void VisitUsingShadowDecl(UsingShadowDecl *D);
|
||||
void VisitLinkageSpecDecl(LinkageSpecDecl *D);
|
||||
void VisitFileScopeAsmDecl(FileScopeAsmDecl *D);
|
||||
void VisitAccessSpecDecl(AccessSpecDecl *D);
|
||||
|
|
@ -521,7 +521,7 @@ void PCHDeclWriter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
|
|||
Code = pch::DECL_NAMESPACE_ALIAS;
|
||||
}
|
||||
|
||||
void PCHDeclWriter::VisitUsing(UsingDecl *D) {
|
||||
void PCHDeclWriter::VisitUsingDecl(UsingDecl *D) {
|
||||
VisitNamedDecl(D);
|
||||
Writer.AddSourceRange(D->getNestedNameRange(), Record);
|
||||
Writer.AddSourceLocation(D->getUsingLocation(), Record);
|
||||
|
|
@ -534,7 +534,7 @@ void PCHDeclWriter::VisitUsing(UsingDecl *D) {
|
|||
Code = pch::DECL_USING;
|
||||
}
|
||||
|
||||
void PCHDeclWriter::VisitUsingShadow(UsingShadowDecl *D) {
|
||||
void PCHDeclWriter::VisitUsingShadowDecl(UsingShadowDecl *D) {
|
||||
VisitNamedDecl(D);
|
||||
Writer.AddDeclRef(D->getTargetDecl(), Record);
|
||||
Writer.AddDeclRef(D->getUsingDecl(), Record);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
// Test this without pch.
|
||||
// RUN: %clang_cc1 -include %S/cxx-using.h -fsyntax-only -verify %s
|
||||
|
||||
// Test with pch.
|
||||
// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-using.h
|
||||
// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
|
||||
|
||||
void m() {
|
||||
D s; // expected-note {{candidate function}}
|
||||
s.f(); // expected-error {{no matching member}}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// expected-note {{candidate function}}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
// Header for PCH test cxx-using.cpp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct B {
|
||||
void f(char c);
|
||||
};
|
||||
|
||||
struct D : B
|
||||
{
|
||||
using B::f;
|
||||
void f(int);
|
||||
};
|
||||
Loading…
Reference in New Issue