[llvm-branch-commits] [clang] [serialization] No transitive type change (PR #92511)
Chuanqi Xu via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jun 19 19:21:50 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;
----------------
ChuanqiXu9 wrote:
> Are the higher bits of predefined types always 0?
Yes. Technically, the predefined ones (including decls, identifiers and types) doesn't belong to any modules. So their module file index is always 0.
I will try to update a comment for this.
> (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).
The `Index` in `translateTypeIDToIndex` means index in the `ASTReader::TypesLoaded` array. And these predefined ones, they are predefined, not loaded, shouldn't be in `ASTReader::TypesLoaded`. Then I call `translateTypeIDToIndex` after dealing with the predefined ones.
https://github.com/llvm/llvm-project/pull/92511
More information about the llvm-branch-commits
mailing list