summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2017-04-12 03:45:32 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2017-04-12 03:45:32 +0000
commita351c10df3b843acaa2ecb48a1bdb61afd10ff01 (patch)
tree16ba79129b6e624657a41fe3ad75f8dc495c1ac2 /clang/lib/Serialization/ASTWriter.cpp
parentacb089e12ae48b82c0b05c42326196a030df9b82 (diff)
downloadbcm5719-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/ASTWriter.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index be1945d5715..ffcad78f295 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -2888,13 +2888,18 @@ void ASTWriter::WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
};
AddDiagState(Diag.DiagStatesByLoc.FirstDiagState, isModule);
- AddSourceLocation(Diag.DiagStatesByLoc.CurDiagStateLoc, Record);
- AddDiagState(Diag.DiagStatesByLoc.CurDiagState, false);
+ // Reserve a spot for the number of locations with state transitions.
+ auto NumLocationsIdx = Record.size();
+ Record.emplace_back();
+
+ // Emit the state transitions.
+ unsigned NumLocations = 0;
for (auto &FileIDAndFile : Diag.DiagStatesByLoc.Files) {
if (!FileIDAndFile.first.isValid() ||
!FileIDAndFile.second.HasLocalTransitions)
continue;
+ ++NumLocations;
AddSourceLocation(Diag.SourceMgr->getLocForStartOfFile(FileIDAndFile.first),
Record);
Record.push_back(FileIDAndFile.second.StateTransitions.size());
@@ -2904,6 +2909,13 @@ void ASTWriter::WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
}
}
+ // Backpatch the number of locations.
+ Record[NumLocationsIdx] = NumLocations;
+
+ // Emit CurDiagStateLoc. Do it last in order to match source order.
+ AddSourceLocation(Diag.DiagStatesByLoc.CurDiagStateLoc, Record);
+ AddDiagState(Diag.DiagStatesByLoc.CurDiagState, false);
+
Stream.EmitRecord(DIAG_PRAGMA_MAPPINGS, Record);
}
OpenPOWER on IntegriCloud