diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2013-01-26 00:35:08 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2013-01-26 00:35:08 +0000 |
commit | 8334af8c2a88e59860e7aef2ec44a64df402cae1 (patch) | |
tree | d91e9f6c046ceeb6e8867ac147bc69fe1b862791 /clang/lib/Serialization | |
parent | 9a8ff813f34b39438b8042a6d784a4f2305b9fcc (diff) | |
download | bcm5719-llvm-8334af8c2a88e59860e7aef2ec44a64df402cae1.tar.gz bcm5719-llvm-8334af8c2a88e59860e7aef2ec44a64df402cae1.zip |
Preserve Sema::UndefinedInternals across PCH boundaries. Fixes
-Wundefined-internal warnings with PCH.
llvm-svn: 173538
Diffstat (limited to 'clang/lib/Serialization')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 30 | ||||
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 17 |
2 files changed, 45 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index fd1b8966ee2..0261ad8f483 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -2461,7 +2461,24 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) { for (unsigned I = 0, N = Record.size(); I != N; ++I) KnownNamespaces.push_back(getGlobalDeclID(F, Record[I])); break; - + + case UNDEFINED_INTERNALS: + if (UndefinedInternals.size() % 2 != 0) { + Error("Invalid existing UndefinedInternals"); + return true; + } + + if (Record.size() % 2 != 0) { + Error("invalid undefined internals record"); + return true; + } + for (unsigned I = 0, N = Record.size(); I != N; /* in loop */) { + UndefinedInternals.push_back(getGlobalDeclID(F, Record[I++])); + UndefinedInternals.push_back( + ReadSourceLocation(F, Record, I).getRawEncoding()); + } + break; + case IMPORTED_MODULES: { if (F.Kind != MK_Module) { // If we aren't loading a module (which has its own exports), make @@ -5934,6 +5951,17 @@ void ASTReader::ReadKnownNamespaces( } } +void ASTReader::ReadUndefinedInternals( + llvm::MapVector<NamedDecl*, SourceLocation> &Undefined) { + for (unsigned Idx = 0, N = UndefinedInternals.size(); Idx != N;) { + NamedDecl *D = cast<NamedDecl>(GetDecl(UndefinedInternals[Idx++])); + SourceLocation Loc = + SourceLocation::getFromRawEncoding(UndefinedInternals[Idx++]); + Undefined.insert(std::make_pair(D, Loc)); + } +} + + void ASTReader::ReadTentativeDefinitions( SmallVectorImpl<VarDecl *> &TentativeDefs) { for (unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) { diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 5a690b3ded8..d3981533245 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -824,6 +824,7 @@ void ASTWriter::WriteBlockInfoBlock() { RECORD(OPENCL_EXTENSIONS); RECORD(DELEGATING_CTORS); RECORD(KNOWN_NAMESPACES); + RECORD(UNDEFINED_INTERNALS); RECORD(MODULE_OFFSET_MAP); RECORD(SOURCE_MANAGER_LINE_TABLE); RECORD(OBJC_CATEGORIES_MAP); @@ -3581,7 +3582,7 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, // Build a record containing all of the known namespaces. RecordData KnownNamespaces; - for (llvm::DenseMap<NamespaceDecl*, bool>::iterator + for (llvm::MapVector<NamespaceDecl*, bool>::iterator I = SemaRef.KnownNamespaces.begin(), IEnd = SemaRef.KnownNamespaces.end(); I != IEnd; ++I) { @@ -3589,6 +3590,16 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, AddDeclRef(I->first, KnownNamespaces); } + // Build a record of all used, undefined objects with internal linkage. + RecordData UndefinedInternals; + for (llvm::MapVector<NamedDecl*, SourceLocation>::iterator + I = SemaRef.UndefinedInternals.begin(), + IEnd = SemaRef.UndefinedInternals.end(); + I != IEnd; ++I) { + AddDeclRef(I->first, UndefinedInternals); + AddSourceLocation(I->second, UndefinedInternals); + } + // Write the control block WriteControlBlock(PP, Context, isysroot, OutputFile); @@ -3803,6 +3814,10 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, // Write the known namespaces. if (!KnownNamespaces.empty()) Stream.EmitRecord(KNOWN_NAMESPACES, KnownNamespaces); + + // Write the undefined internal functions and variables. + if (!UndefinedInternals.empty()) + Stream.EmitRecord(UNDEFINED_INTERNALS, UndefinedInternals); // Write the visible updates to DeclContexts. for (llvm::SmallPtrSet<const DeclContext *, 16>::iterator |