[clang] [clang] [Serialization] No transitive change for MacroID and PreprocessedEntityID (PR #166346)
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 5 21:48:09 PST 2025
================
@@ -2261,16 +2262,22 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
PreprocessedEntityID
ASTReader::getGlobalPreprocessedEntityID(ModuleFile &M,
- unsigned LocalID) const {
+ PreprocessedEntityID LocalID) const {
if (!M.ModuleOffsetMap.empty())
ReadModuleOffsetMap(M);
- ContinuousRangeMap<uint32_t, int, 2>::const_iterator
- I = M.PreprocessedEntityRemap.find(LocalID - NUM_PREDEF_PP_ENTITY_IDS);
- assert(I != M.PreprocessedEntityRemap.end()
- && "Invalid index into preprocessed entity index remap");
+ unsigned ModuleFileIndex = LocalID >> 32;
+ LocalID &= llvm::maskTrailingOnes<PreprocessedEntityID>(32);
+ ModuleFile *MF =
+ ModuleFileIndex ? M.TransitiveImports[ModuleFileIndex - 1] : &M;
+ assert(MF && "malformed identifier ID encoding?");
- return LocalID + I->second;
+ if (!ModuleFileIndex) {
+ assert(LocalID >= NUM_PREDEF_PP_ENTITY_IDS);
+ LocalID -= NUM_PREDEF_PP_ENTITY_IDS;
+ }
+
+ return ((PreprocessedEntityID)(MF->Index + 1) << 32) | LocalID;
----------------
ChuanqiXu9 wrote:
Done
https://github.com/llvm/llvm-project/pull/166346
More information about the cfe-commits
mailing list