Read/write more information of ASTContext for PCH. Overriden methods and instantiated-from information.
llvm-svn: 107597
This commit is contained in:
@@ -362,6 +362,8 @@ public:
|
|||||||
overridden_cxx_method_iterator
|
overridden_cxx_method_iterator
|
||||||
overridden_methods_end(const CXXMethodDecl *Method) const;
|
overridden_methods_end(const CXXMethodDecl *Method) const;
|
||||||
|
|
||||||
|
unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
|
||||||
|
|
||||||
/// \brief Note that the given C++ \p Method overrides the given \p
|
/// \brief Note that the given C++ \p Method overrides the given \p
|
||||||
/// Overridden method.
|
/// Overridden method.
|
||||||
void addOverriddenMethod(const CXXMethodDecl *Method,
|
void addOverriddenMethod(const CXXMethodDecl *Method,
|
||||||
|
|||||||
@@ -1114,6 +1114,7 @@ public:
|
|||||||
|
|
||||||
method_iterator begin_overridden_methods() const;
|
method_iterator begin_overridden_methods() const;
|
||||||
method_iterator end_overridden_methods() const;
|
method_iterator end_overridden_methods() const;
|
||||||
|
unsigned size_overridden_methods() const;
|
||||||
|
|
||||||
/// getParent - Returns the parent of this method declaration, which
|
/// getParent - Returns the parent of this method declaration, which
|
||||||
/// is the class in which this method is defined.
|
/// is the class in which this method is defined.
|
||||||
|
|||||||
@@ -478,6 +478,16 @@ ASTContext::overridden_methods_end(const CXXMethodDecl *Method) const {
|
|||||||
return Pos->second.end();
|
return Pos->second.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned
|
||||||
|
ASTContext::overridden_methods_size(const CXXMethodDecl *Method) const {
|
||||||
|
llvm::DenseMap<const CXXMethodDecl *, CXXMethodVector>::const_iterator Pos
|
||||||
|
= OverriddenMethods.find(Method);
|
||||||
|
if (Pos == OverriddenMethods.end())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return Pos->second.size();
|
||||||
|
}
|
||||||
|
|
||||||
void ASTContext::addOverriddenMethod(const CXXMethodDecl *Method,
|
void ASTContext::addOverriddenMethod(const CXXMethodDecl *Method,
|
||||||
const CXXMethodDecl *Overridden) {
|
const CXXMethodDecl *Overridden) {
|
||||||
OverriddenMethods[Method].push_back(Overridden);
|
OverriddenMethods[Method].push_back(Overridden);
|
||||||
|
|||||||
@@ -716,6 +716,10 @@ CXXMethodDecl::method_iterator CXXMethodDecl::end_overridden_methods() const {
|
|||||||
return getASTContext().overridden_methods_end(this);
|
return getASTContext().overridden_methods_end(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned CXXMethodDecl::size_overridden_methods() const {
|
||||||
|
return getASTContext().overridden_methods_size(this);
|
||||||
|
}
|
||||||
|
|
||||||
QualType CXXMethodDecl::getThisType(ASTContext &C) const {
|
QualType CXXMethodDecl::getThisType(ASTContext &C) const {
|
||||||
// C++ 9.3.2p1: The type of this in a member function of a class X is X*.
|
// C++ 9.3.2p1: The type of this in a member function of a class X is X*.
|
||||||
// If the member function is declared const, the type of this is const X*,
|
// If the member function is declared const, the type of this is const X*,
|
||||||
|
|||||||
@@ -507,6 +507,11 @@ void PCHDeclReader::VisitFieldDecl(FieldDecl *FD) {
|
|||||||
FD->setMutable(Record[Idx++]);
|
FD->setMutable(Record[Idx++]);
|
||||||
if (Record[Idx++])
|
if (Record[Idx++])
|
||||||
FD->setBitWidth(Reader.ReadExpr());
|
FD->setBitWidth(Reader.ReadExpr());
|
||||||
|
if (!FD->getDeclName()) {
|
||||||
|
FieldDecl *Tmpl = cast_or_null<FieldDecl>(Reader.GetDecl(Record[Idx++]));
|
||||||
|
if (Tmpl)
|
||||||
|
Reader.getContext()->setInstantiatedFromUnnamedFieldDecl(FD, Tmpl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCHDeclReader::VisitVarDecl(VarDecl *VD) {
|
void PCHDeclReader::VisitVarDecl(VarDecl *VD) {
|
||||||
@@ -603,12 +608,19 @@ void PCHDeclReader::VisitUsingDecl(UsingDecl *D) {
|
|||||||
D->addShadowDecl(cast<UsingShadowDecl>(Reader.GetDecl(Record[Idx++])));
|
D->addShadowDecl(cast<UsingShadowDecl>(Reader.GetDecl(Record[Idx++])));
|
||||||
}
|
}
|
||||||
D->setTypeName(Record[Idx++]);
|
D->setTypeName(Record[Idx++]);
|
||||||
|
NamedDecl *Pattern = cast_or_null<NamedDecl>(Reader.GetDecl(Record[Idx++]));
|
||||||
|
if (Pattern)
|
||||||
|
Reader.getContext()->setInstantiatedFromUsingDecl(D, Pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCHDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) {
|
void PCHDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) {
|
||||||
VisitNamedDecl(D);
|
VisitNamedDecl(D);
|
||||||
D->setTargetDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++])));
|
D->setTargetDecl(cast<NamedDecl>(Reader.GetDecl(Record[Idx++])));
|
||||||
D->setUsingDecl(cast<UsingDecl>(Reader.GetDecl(Record[Idx++])));
|
D->setUsingDecl(cast<UsingDecl>(Reader.GetDecl(Record[Idx++])));
|
||||||
|
UsingShadowDecl *Pattern
|
||||||
|
= cast_or_null<UsingShadowDecl>(Reader.GetDecl(Record[Idx++]));
|
||||||
|
if (Pattern)
|
||||||
|
Reader.getContext()->setInstantiatedFromUsingShadowDecl(D, Pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCHDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
|
void PCHDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
|
||||||
@@ -715,6 +727,13 @@ void PCHDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {
|
|||||||
|
|
||||||
void PCHDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) {
|
void PCHDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) {
|
||||||
VisitFunctionDecl(D);
|
VisitFunctionDecl(D);
|
||||||
|
unsigned NumOverridenMethods = Record[Idx++];
|
||||||
|
while (NumOverridenMethods--) {
|
||||||
|
CXXMethodDecl *MD = cast<CXXMethodDecl>(Reader.GetDecl(Record[Idx++]));
|
||||||
|
// Avoid invariant checking of CXXMethodDecl::addOverriddenMethod,
|
||||||
|
// MD may be initializing.
|
||||||
|
Reader.getContext()->addOverriddenMethod(D, MD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PCHDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
|
void PCHDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
|
||||||
|
|||||||
@@ -476,6 +476,8 @@ void PCHDeclWriter::VisitFieldDecl(FieldDecl *D) {
|
|||||||
Record.push_back(D->getBitWidth()? 1 : 0);
|
Record.push_back(D->getBitWidth()? 1 : 0);
|
||||||
if (D->getBitWidth())
|
if (D->getBitWidth())
|
||||||
Writer.AddStmt(D->getBitWidth());
|
Writer.AddStmt(D->getBitWidth());
|
||||||
|
if (!D->getDeclName())
|
||||||
|
Writer.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D), Record);
|
||||||
Code = pch::DECL_FIELD;
|
Code = pch::DECL_FIELD;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,6 +611,7 @@ void PCHDeclWriter::VisitUsingDecl(UsingDecl *D) {
|
|||||||
PEnd = D->shadow_end(); P != PEnd; ++P)
|
PEnd = D->shadow_end(); P != PEnd; ++P)
|
||||||
Writer.AddDeclRef(*P, Record);
|
Writer.AddDeclRef(*P, Record);
|
||||||
Record.push_back(D->isTypeName());
|
Record.push_back(D->isTypeName());
|
||||||
|
Writer.AddDeclRef(Context.getInstantiatedFromUsingDecl(D), Record);
|
||||||
Code = pch::DECL_USING;
|
Code = pch::DECL_USING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,6 +619,7 @@ void PCHDeclWriter::VisitUsingShadowDecl(UsingShadowDecl *D) {
|
|||||||
VisitNamedDecl(D);
|
VisitNamedDecl(D);
|
||||||
Writer.AddDeclRef(D->getTargetDecl(), Record);
|
Writer.AddDeclRef(D->getTargetDecl(), Record);
|
||||||
Writer.AddDeclRef(D->getUsingDecl(), Record);
|
Writer.AddDeclRef(D->getUsingDecl(), Record);
|
||||||
|
Writer.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D), Record);
|
||||||
Code = pch::DECL_USING_SHADOW;
|
Code = pch::DECL_USING_SHADOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -714,6 +718,11 @@ void PCHDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
|
|||||||
|
|
||||||
void PCHDeclWriter::VisitCXXMethodDecl(CXXMethodDecl *D) {
|
void PCHDeclWriter::VisitCXXMethodDecl(CXXMethodDecl *D) {
|
||||||
VisitFunctionDecl(D);
|
VisitFunctionDecl(D);
|
||||||
|
Record.push_back(D->size_overridden_methods());
|
||||||
|
for (CXXMethodDecl::method_iterator
|
||||||
|
I = D->begin_overridden_methods(), E = D->end_overridden_methods();
|
||||||
|
I != E; ++I)
|
||||||
|
Writer.AddDeclRef(*I, Record);
|
||||||
Code = pch::DECL_CXX_METHOD;
|
Code = pch::DECL_CXX_METHOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user