[clang] [clang][Sema] Unwrap reference types in HeuristicResolverImpl::resolveTypeToRecordDecl() (PR #124451)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 26 19:24:53 PST 2025


================
@@ -133,8 +133,8 @@ TemplateName getReferencedTemplateName(const Type *T) {
 CXXRecordDecl *HeuristicResolverImpl::resolveTypeToRecordDecl(const Type *T) {
   assert(T);
 
-  // Unwrap type sugar such as type aliases.
-  T = T->getCanonicalTypeInternal().getTypePtr();
+  // Unwrap references and type sugar such as type aliases.
+  T = T->getCanonicalTypeInternal().getNonReferenceType().getTypePtr();
----------------
HighCommander4 wrote:

No, the pointer case is a bit more involved because we bail [here](https://searchfox.org/llvm/rev/8035d38daab028b8da3cf2b01090b5f0ceacd695/clang/lib/Sema/HeuristicResolver.cpp#236) after failing to unwrap the pointee type [here](https://searchfox.org/llvm/rev/8035d38daab028b8da3cf2b01090b5f0ceacd695/clang/lib/Sema/HeuristicResolver.cpp#233).

To handle it we will need to do something like:

 1. Check for pointer type and unwrap it if found
 2. Resolve `BuiltinType::Dependent` 
 3. If a pointer type was not unwrapped at step (1), check for it again after step (2) and unwrap it if found

I was going to do this in a follow-up patch but it might make more sense to do it in the same patch; I will revise.

https://github.com/llvm/llvm-project/pull/124451


More information about the cfe-commits mailing list