[clang] [Modules] No transitive source location change (PR #86912)
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 15 01:05:13 PDT 2024
================
@@ -5574,10 +5577,34 @@ void ASTWriter::AddFileID(FileID FID, RecordDataImpl &Record) {
Record.push_back(getAdjustedFileID(FID).getOpaqueValue());
}
+SourceLocationEncoding::RawLocEncoding
+ASTWriter::getRawSourceLocationEncoding(SourceLocation Loc, LocSeq *Seq) {
+ unsigned BaseOffset = 0;
+ unsigned ModuleFileIndex = 0;
+
+ // See SourceLocationEncoding.h for the encoding details.
+ if (Context->getSourceManager().isLoadedSourceLocation(Loc) &&
+ Loc.isValid()) {
+ assert(getChain());
+ auto SLocMapI = getChain()->GlobalSLocOffsetMap.find(
+ SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
+ assert(SLocMapI != getChain()->GlobalSLocOffsetMap.end() &&
+ "Corrupted global sloc offset map");
+ ModuleFile *F = SLocMapI->second;
+ BaseOffset = F->SLocEntryBaseOffset - 2;
+ // 0 means the location is not loaded. So we need to add 1 to the index to
+ // make it clear.
+ ModuleFileIndex = F->Index + 1;
+ assert(&getChain()->getModuleManager()[F->Index] == F);
----------------
ChuanqiXu9 wrote:
Yes but I'd like to remain it. The assertions make me feel better.
https://github.com/llvm/llvm-project/pull/86912
More information about the cfe-commits
mailing list