diff options
author | Stephan Tolksdorf <st@quanttec.com> | 2014-03-27 19:22:19 +0000 |
---|---|---|
committer | Stephan Tolksdorf <st@quanttec.com> | 2014-03-27 19:22:19 +0000 |
commit | a6a0863470796a0e01fed0273811192cb1a6a455 (patch) | |
tree | 6279b2c6af084a5f6d9fa04229a6e1b05172acfb /clang/lib/Serialization | |
parent | 1f9d80ac666e3e96540871070fbe20758a73c708 (diff) | |
download | bcm5719-llvm-a6a0863470796a0e01fed0273811192cb1a6a455.tar.gz bcm5719-llvm-a6a0863470796a0e01fed0273811192cb1a6a455.zip |
Fix PR18307: Properly (de)serialize inherited constructors and their using declarations
Reviewed in http://llvm-reviews.chandlerc.com/D3102
llvm-svn: 204951
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 32 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTWriterDecl.cpp | 1 |
3 files changed, 29 insertions, 8 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index f266ebaa98e..7d950729304 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -1348,7 +1348,9 @@ void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) { void ASTDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) { VisitCXXMethodDecl(D); - + + if (auto *CD = ReadDeclAs<CXXConstructorDecl>(Record, Idx)) + D->setInheritedConstructor(CD); D->IsExplicitSpecified = Record[Idx++]; std::tie(D->CtorInitializers, D->NumCtorInitializers) = Reader.ReadCXXCtorInitializers(F, Record, Idx); diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 33f7e56805e..30eaa3a4316 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -3411,7 +3411,9 @@ ASTWriter::GenerateNameLookupTable(const DeclContext *DC, ASTDeclContextNameLookupTrait Trait(*this); // Create the on-disk hash table representation. + DeclarationName ConstructorName; DeclarationName ConversionName; + SmallVector<NamedDecl *, 8> ConstructorDecls; SmallVector<NamedDecl *, 4> ConversionDecls; auto AddLookupResult = [&](DeclarationName Name, @@ -3419,16 +3421,25 @@ ASTWriter::GenerateNameLookupTable(const DeclContext *DC, if (Result.empty()) return; - if (Name.getNameKind() == DeclarationName::CXXConversionFunctionName) { - // Hash all conversion function names to the same name. The actual - // type information in conversion function name is not used in the - // key (since such type information is not stable across different - // modules), so the intended effect is to coalesce all of the conversion - // functions under a single key. + // Different DeclarationName values of certain kinds are mapped to + // identical serialized keys, because we don't want to use type + // identifiers in the keys (since type ids are local to the module). + switch (Name.getNameKind()) { + case DeclarationName::CXXConstructorName: + // There may be different CXXConstructorName DeclarationName values + // in a DeclContext because a UsingDecl that inherits constructors + // has the DeclarationName of the inherited constructors. + if (!ConstructorName) + ConstructorName = Name; + ConstructorDecls.append(Result.begin(), Result.end()); + return; + case DeclarationName::CXXConversionFunctionName: if (!ConversionName) ConversionName = Name; ConversionDecls.append(Result.begin(), Result.end()); return; + default: + break; } Generator.insert(Name, Result, Trait); @@ -3458,7 +3469,14 @@ ASTWriter::GenerateNameLookupTable(const DeclContext *DC, // FIXME: const_cast since OnDiskHashTable wants a non-const lookup result. AddLookupResult(Name, const_cast<DeclContext*>(DC)->lookup(Name)); - // Add the conversion functions + // Add the constructors. + if (!ConstructorDecls.empty()) { + Generator.insert(ConstructorName, + DeclContext::lookup_result(ConstructorDecls.begin(), + ConstructorDecls.end()), + Trait); + } + // Add the conversion functions. if (!ConversionDecls.empty()) { Generator.insert(ConversionName, DeclContext::lookup_result(ConversionDecls.begin(), diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index f0b03128346..14304ab6e1a 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -1030,6 +1030,7 @@ void ASTDeclWriter::VisitCXXMethodDecl(CXXMethodDecl *D) { void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) { VisitCXXMethodDecl(D); + Writer.AddDeclRef(D->getInheritedConstructor(), Record); Record.push_back(D->IsExplicitSpecified); Writer.AddCXXCtorInitializers(D->CtorInitializers, D->NumCtorInitializers, Record); |