diff options
| -rw-r--r-- | clang/include/clang/AST/ASTContext.h | 2 | ||||
| -rw-r--r-- | clang/include/clang/AST/DeclCXX.h | 1 | ||||
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/AST/DeclCXX.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Frontend/PCHReaderDecl.cpp | 19 | ||||
| -rw-r--r-- | clang/lib/Frontend/PCHWriterDecl.cpp | 9 | 
6 files changed, 45 insertions, 0 deletions
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 0c36ad7b939..816d59512c3 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -362,6 +362,8 @@ public:    overridden_cxx_method_iterator    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    /// Overridden method.    void addOverriddenMethod(const CXXMethodDecl *Method,  diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 98ab83c6a69..1b7958a5fdf 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -1114,6 +1114,7 @@ public:    method_iterator begin_overridden_methods() const;    method_iterator end_overridden_methods() const; +  unsigned size_overridden_methods() const;    /// getParent - Returns the parent of this method declaration, which    /// is the class in which this method is defined. diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 24ddb127bda..4fb9d369de3 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -478,6 +478,16 @@ ASTContext::overridden_methods_end(const CXXMethodDecl *Method) const {    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,                                        const CXXMethodDecl *Overridden) {    OverriddenMethods[Method].push_back(Overridden); diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 7ce9c64de03..19c3ac10119 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -716,6 +716,10 @@ CXXMethodDecl::method_iterator CXXMethodDecl::end_overridden_methods() const {    return getASTContext().overridden_methods_end(this);  } +unsigned CXXMethodDecl::size_overridden_methods() const { +  return getASTContext().overridden_methods_size(this); +} +  QualType CXXMethodDecl::getThisType(ASTContext &C) const {    // 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*, diff --git a/clang/lib/Frontend/PCHReaderDecl.cpp b/clang/lib/Frontend/PCHReaderDecl.cpp index c9bf4470eb1..be4f72ec3b7 100644 --- a/clang/lib/Frontend/PCHReaderDecl.cpp +++ b/clang/lib/Frontend/PCHReaderDecl.cpp @@ -507,6 +507,11 @@ void PCHDeclReader::VisitFieldDecl(FieldDecl *FD) {    FD->setMutable(Record[Idx++]);    if (Record[Idx++])      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) { @@ -603,12 +608,19 @@ void PCHDeclReader::VisitUsingDecl(UsingDecl *D) {      D->addShadowDecl(cast<UsingShadowDecl>(Reader.GetDecl(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) {    VisitNamedDecl(D);    D->setTargetDecl(cast<NamedDecl>(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) { @@ -715,6 +727,13 @@ void PCHDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {  void PCHDeclReader::VisitCXXMethodDecl(CXXMethodDecl *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) { diff --git a/clang/lib/Frontend/PCHWriterDecl.cpp b/clang/lib/Frontend/PCHWriterDecl.cpp index 24777966b13..deca4b22ec6 100644 --- a/clang/lib/Frontend/PCHWriterDecl.cpp +++ b/clang/lib/Frontend/PCHWriterDecl.cpp @@ -476,6 +476,8 @@ void PCHDeclWriter::VisitFieldDecl(FieldDecl *D) {    Record.push_back(D->getBitWidth()? 1 : 0);    if (D->getBitWidth())      Writer.AddStmt(D->getBitWidth()); +  if (!D->getDeclName()) +    Writer.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D), Record);    Code = pch::DECL_FIELD;  } @@ -609,6 +611,7 @@ void PCHDeclWriter::VisitUsingDecl(UsingDecl *D) {         PEnd = D->shadow_end(); P != PEnd; ++P)      Writer.AddDeclRef(*P, Record);    Record.push_back(D->isTypeName()); +  Writer.AddDeclRef(Context.getInstantiatedFromUsingDecl(D), Record);    Code = pch::DECL_USING;  } @@ -616,6 +619,7 @@ void PCHDeclWriter::VisitUsingShadowDecl(UsingShadowDecl *D) {    VisitNamedDecl(D);    Writer.AddDeclRef(D->getTargetDecl(), Record);    Writer.AddDeclRef(D->getUsingDecl(), Record); +  Writer.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D), Record);    Code = pch::DECL_USING_SHADOW;  } @@ -714,6 +718,11 @@ void PCHDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {  void PCHDeclWriter::VisitCXXMethodDecl(CXXMethodDecl *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;  }  | 

