[clang] [serialization] No transitive type change (PR #92511)
Ilya Biryukov via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 20 04:59:11 PDT 2024
================
@@ -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
More information about the cfe-commits
mailing list