diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-11-05 22:10:18 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-11-05 22:10:18 +0000 |
commit | f41d3be39980d40849850d3fb90403623cc8459e (patch) | |
tree | 8ddc2c3ae4bad968ffe991f594f7f26e278c678e /lib | |
parent | 2e57494445747c911f48b853015b784e292fefe4 (diff) |
Read/write from/to PCH the diagnostic mappings that the user set so that e.g. #pragma clang diagnostic can be used in a PCH.
Fixes rdar://8435969.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118303 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 23 | ||||
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 17 |
2 files changed, 40 insertions, 0 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index b90203b477..d70546dbbc 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -2130,6 +2130,18 @@ ASTReader::ReadASTBlock(PerFileData &F) { F.CXXBaseSpecifiersOffsets = (const uint32_t *)BlobStart; break; } + + case DIAG_USER_MAPPINGS: + if (Record.size() % 2 != 0) { + Error("invalid DIAG_USER_MAPPINGS block in AST file"); + return Failure; + } + if (UserDiagMappings.empty()) + UserDiagMappings.swap(Record); + else + UserDiagMappings.insert(UserDiagMappings.end(), + Record.begin(), Record.end()); + break; } First = false; } @@ -2457,6 +2469,8 @@ void ASTReader::InitializeContext(ASTContext &Ctx) { if (SpecialTypes[SPECIAL_TYPE_INT128_INSTALLED]) Context->setInt128Installed(); + + ReadUserDiagnosticMappings(Context->getDiagnostics()); } /// \brief Retrieve the name of the original source file name @@ -2623,6 +2637,15 @@ void ASTReader::ReadPreprocessedEntities() { ReadDefinedMacros(); } +void ASTReader::ReadUserDiagnosticMappings(Diagnostic &Diag) { + unsigned Idx = 0; + while (Idx < UserDiagMappings.size()) { + unsigned DiagID = UserDiagMappings[Idx++]; + unsigned Map = UserDiagMappings[Idx++]; + Diag.setDiagnosticMappingInternal(DiagID, Map, /*isUser=*/true); + } +} + /// \brief Get the correct cursor and offset for loading a type. ASTReader::RecordLocation ASTReader::TypeCursorForIndex(unsigned Index) { PerFileData *F = 0; diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 47ef72f7bd..a5977f5cfe 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -1441,6 +1441,19 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP) { } } +void ASTWriter::WriteUserDiagnosticMappings(const Diagnostic &Diag) { + RecordData Record; + for (unsigned i = 0; i != diag::DIAG_UPPER_LIMIT; ++i) { + diag::Mapping Map = Diag.getDiagnosticMappingInfo(i); + if (Map & 0x8) { // user mapping. + Record.push_back(i); + Record.push_back(Map & 0x7); + } + } + + Stream.EmitRecord(DIAG_USER_MAPPINGS, Record); +} + //===----------------------------------------------------------------------===// // Type Serialization //===----------------------------------------------------------------------===// @@ -2402,6 +2415,7 @@ void ASTWriter::WriteASTCore(Sema &SemaRef, MemorizeStatCalls *StatCalls, WriteIdentifierTable(PP); WriteTypeDeclOffsets(); + WriteUserDiagnosticMappings(Context.getDiagnostics()); // Write the C++ base-specifier set offsets. if (!CXXBaseSpecifiersOffsets.empty()) { @@ -2635,6 +2649,9 @@ void ASTWriter::WriteASTChain(Sema &SemaRef, MemorizeStatCalls *StatCalls, WriteReferencedSelectorsPool(SemaRef); WriteIdentifierTable(PP); WriteTypeDeclOffsets(); + // FIXME: For chained PCH only write the new mappings (we currently + // write all of them again). + WriteUserDiagnosticMappings(Context.getDiagnostics()); /// Build a record containing first declarations from a chained PCH and the /// most recent declarations in this AST that they point to. |