diff options
| author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-04-24 16:28:13 +0000 |
|---|---|---|
| committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2011-04-24 16:28:13 +0000 |
| commit | fa1f370b7d208646a324a36ab1c4de324755af5d (patch) | |
| tree | dc2f3fc66786e852eb0046be4b39902ade2b08da /clang/lib | |
| parent | ab238a7d1895201ad3d10fc961ca68105b3844fb (diff) | |
| download | bcm5719-llvm-fa1f370b7d208646a324a36ab1c4de324755af5d.tar.gz bcm5719-llvm-fa1f370b7d208646a324a36ab1c4de324755af5d.zip | |
Fix adding an anonymous namespace in a chained PCH to a namespace from a previous PCH.
Fix anonymous namespaces in PCH.
llvm-svn: 130104
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Serialization/ASTCommon.h | 3 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTReaderDecl.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTWriterDecl.cpp | 14 |
3 files changed, 26 insertions, 1 deletions
diff --git a/clang/lib/Serialization/ASTCommon.h b/clang/lib/Serialization/ASTCommon.h index d4166998d1c..904f8ed6ae4 100644 --- a/clang/lib/Serialization/ASTCommon.h +++ b/clang/lib/Serialization/ASTCommon.h @@ -23,7 +23,8 @@ namespace serialization { enum DeclUpdateKind { UPD_CXX_SET_DEFINITIONDATA, UPD_CXX_ADDED_IMPLICIT_MEMBER, - UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION + UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION, + UPD_CXX_ADDED_ANONYMOUS_NAMESPACE }; TypeIdx TypeIdxFromBuiltin(const BuiltinType *BT); diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 4d2da8decb1..3d4e4cdd002 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -1737,6 +1737,16 @@ void ASTDeclReader::UpdateDecl(Decl *D, const RecordData &Record) { case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION: // It will be added to the template's specializations set when loaded. Reader.GetDecl(Record[Idx++]); + break; + + case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: { + NamespaceDecl *Anon = cast<NamespaceDecl>(Reader.GetDecl(Record[Idx++])); + if (TranslationUnitDecl *TU = dyn_cast<TranslationUnitDecl>(D)) + TU->setAnonymousNamespace(Anon); + else + cast<NamespaceDecl>(D)->OrigOrAnonNamespace.setPointer(Anon); + break; + } } } } diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index b3b55f584ae..db72be3f584 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "clang/Serialization/ASTWriter.h" +#include "ASTCommon.h" #include "clang/AST/DeclVisitor.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclTemplate.h" @@ -21,6 +22,7 @@ #include "llvm/Bitcode/BitstreamWriter.h" #include "llvm/Support/ErrorHandling.h" using namespace clang; +using namespace serialization; //===----------------------------------------------------------------------===// // Declaration serialization @@ -705,6 +707,18 @@ void ASTDeclWriter::VisitNamespaceDecl(NamespaceDecl *D) { } } } + + if (Writer.hasChain() && D->isOriginalNamespace() && + D->isAnonymousNamespace()) { + // This is an original anonymous namespace. If its parent is in a previous + // PCH (or is the TU), mark that parent for update. + Decl *Parent = cast<Decl>(D->getParent()->getPrimaryContext()); + if (Parent->getPCHLevel() > 0) { + ASTWriter::UpdateRecord &Record = Writer.DeclUpdates[Parent]; + Record.push_back(UPD_CXX_ADDED_ANONYMOUS_NAMESPACE); + Writer.AddDeclRef(D, Record); + } + } } void ASTDeclWriter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { |

