================ @@ -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); ---------------- jansvoboda11 wrote:
This seems a bit tautological. https://github.com/llvm/llvm-project/pull/86912 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits