================ @@ -7100,14 +7084,25 @@ TypeSourceInfo *ASTRecordReader::readTypeSourceInfo() { return TInfo; } +std::pair<ModuleFile *, unsigned> +ASTReader::translateTypeIDToIndex(serialization::TypeID ID) const { + unsigned Index = + (ID & llvm::maskTrailingOnes<TypeID>(32)) >> Qualifiers::FastWidth; + + ModuleFile *OwningModuleFile = getOwningModuleFile(ID); + assert(OwningModuleFile && + "untranslated type ID or local type ID shouldn't be in TypesLoaded"); + return {OwningModuleFile, OwningModuleFile->BaseTypeIndex + Index}; +} + QualType ASTReader::GetType(TypeID ID) { assert(ContextObj && "reading type with no AST context"); ASTContext &Context = *ContextObj; unsigned FastQuals = ID & Qualifiers::FastMask; - unsigned Index = ID >> Qualifiers::FastWidth; - if (Index < NUM_PREDEF_TYPE_IDS) { + if (uint64_t Index = ID >> Qualifiers::FastWidth; ---------------- ilya-biryukov wrote:
Makes sense, thanks! Now that we use the helper function here it's 100% clear we're doing the right thing. (and `translateTypeIDToIndex` has an assert too, so that's nice!) https://github.com/llvm/llvm-project/pull/92511 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits