diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2017-04-12 03:45:32 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2017-04-12 03:45:32 +0000 |
commit | a351c10df3b843acaa2ecb48a1bdb61afd10ff01 (patch) | |
tree | 16ba79129b6e624657a41fe3ad75f8dc495c1ac2 /clang/lib/Serialization/ASTReader.cpp | |
parent | acb089e12ae48b82c0b05c42326196a030df9b82 (diff) | |
download | bcm5719-llvm-a351c10df3b843acaa2ecb48a1bdb61afd10ff01.tar.gz bcm5719-llvm-a351c10df3b843acaa2ecb48a1bdb61afd10ff01.zip |
Serialization: Emit the final diagnostic state last, almost NFC
Emit the final diagnostic state last to match source order. This also
prepares for a follow-up commit for implicit modules.
There's no real functionaliy change, just a slightly different AST file
format.
llvm-svn: 300024
Diffstat (limited to 'clang/lib/Serialization/ASTReader.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index da29f69c7a1..e09af28059b 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -5533,27 +5533,16 @@ void ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag) { return NewState; }; + // Read the first state. auto *FirstState = ReadDiagState( F.isModule() ? DiagState() : *Diag.DiagStatesByLoc.CurDiagState, SourceLocation(), F.isModule()); - SourceLocation CurStateLoc = - ReadSourceLocation(F, F.PragmaDiagMappings[Idx++]); - auto *CurState = ReadDiagState(*FirstState, CurStateLoc, false); - if (!F.isModule()) { - Diag.DiagStatesByLoc.CurDiagState = CurState; - Diag.DiagStatesByLoc.CurDiagStateLoc = CurStateLoc; - - // Preserve the property that the imaginary root file describes the - // current state. - auto &T = Diag.DiagStatesByLoc.Files[FileID()].StateTransitions; - if (T.empty()) - T.push_back({CurState, 0}); - else - T[0].State = CurState; - } - - while (Idx < Record.size()) { + // Read the state transitions. + unsigned NumLocations = Record[Idx++]; + while (NumLocations--) { + assert(Idx < Record.size() && + "Invalid data, missing pragma diagnostic states"); SourceLocation Loc = ReadSourceLocation(F, Record[Idx++]); auto IDAndOffset = SourceMgr.getDecomposedLoc(Loc); assert(IDAndOffset.second == 0 && "not a start location for a FileID"); @@ -5573,6 +5562,26 @@ void ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag) { } } + // Read the final state. + assert(Idx < Record.size() && + "Invalid data, missing final pragma diagnostic state"); + SourceLocation CurStateLoc = + ReadSourceLocation(F, F.PragmaDiagMappings[Idx++]); + auto *CurState = ReadDiagState(*FirstState, CurStateLoc, false); + + if (!F.isModule()) { + Diag.DiagStatesByLoc.CurDiagState = CurState; + Diag.DiagStatesByLoc.CurDiagStateLoc = CurStateLoc; + + // Preserve the property that the imaginary root file describes the + // current state. + auto &T = Diag.DiagStatesByLoc.Files[FileID()].StateTransitions; + if (T.empty()) + T.push_back({CurState, 0}); + else + T[0].State = CurState; + } + // Don't try to read these mappings again. Record.clear(); } |