Skip to content

Commit f61c135

Browse files
committed
[clang][modules] NFCI: Pragma diagnostic mappings: write/read FileID instead of SourceLocation
For pragma diagnostic mappings, we always write/read `SourceLocation` with offset 0. This is equivalent to just writing a `FileID`, which is exactly what this patch starts doing. Depends on D137211. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D137213
1 parent fdbc55a commit f61c135

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

clang/include/clang/Serialization/ASTBitCodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace serialization {
4141
/// Version 4 of AST files also requires that the version control branch and
4242
/// revision match exactly, since there is no backward compatibility of
4343
/// AST files at this time.
44-
const unsigned VERSION_MAJOR = 23;
44+
const unsigned VERSION_MAJOR = 24;
4545

4646
/// AST file minor version number supported by this version of
4747
/// Clang.

clang/lib/Serialization/ASTReader.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6340,17 +6340,15 @@ void ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag) {
63406340
while (NumLocations--) {
63416341
assert(Idx < Record.size() &&
63426342
"Invalid data, missing pragma diagnostic states");
6343-
SourceLocation Loc = ReadSourceLocation(F, Record[Idx++]);
6344-
auto IDAndOffset = SourceMgr.getDecomposedLoc(Loc);
6345-
assert(IDAndOffset.first.isValid() && "invalid FileID for transition");
6346-
assert(IDAndOffset.second == 0 && "not a start location for a FileID");
6343+
FileID FID = ReadFileID(F, Record, Idx);
6344+
assert(FID.isValid() && "invalid FileID for transition");
63476345
unsigned Transitions = Record[Idx++];
63486346

63496347
// Note that we don't need to set up Parent/ParentOffset here, because
63506348
// we won't be changing the diagnostic state within imported FileIDs
63516349
// (other than perhaps appending to the main source file, which has no
63526350
// parent).
6353-
auto &F = Diag.DiagStatesByLoc.Files[IDAndOffset.first];
6351+
auto &F = Diag.DiagStatesByLoc.Files[FID];
63546352
F.StateTransitions.reserve(F.StateTransitions.size() + Transitions);
63556353
for (unsigned I = 0; I != Transitions; ++I) {
63566354
unsigned Offset = Record[Idx++];

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,9 +3010,7 @@ void ASTWriter::WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
30103010
continue;
30113011
++NumLocations;
30123012

3013-
SourceLocation Loc = Diag.SourceMgr->getComposedLoc(FileIDAndFile.first, 0);
3014-
assert(!Loc.isInvalid() && "start loc for valid FileID is invalid");
3015-
AddSourceLocation(Loc, Record);
3013+
AddFileID(FileIDAndFile.first, Record);
30163014

30173015
Record.push_back(FileIDAndFile.second.StateTransitions.size());
30183016
for (auto &StatePoint : FileIDAndFile.second.StateTransitions) {

0 commit comments

Comments
 (0)