================
@@ -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:
Higher bits still represent the module file index here, right?
Could you clarify why it's correct to compare with `NUM_PREDEF_TYPE_IDS`
without first extracting those bits?
Are the higher bits of predefined types always `0`?
(If this was done on top of results `translateTypeIDToIndex`, it would be very
clear that the code is correct, not sure if there are reasons to postpone this
call).
https://github.com/llvm/llvm-project/pull/92511
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits