[clang] e1dbe09 - [clang] build UnresolvedUsingType for constructor initializers (#154592)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 20 12:24:45 PDT 2025
Author: Matheus Izvekov
Date: 2025-08-20T16:24:41-03:00
New Revision: e1dbe093c4b79ef5086a755ea28c2326d1658f9e
URL: https://github.com/llvm/llvm-project/commit/e1dbe093c4b79ef5086a755ea28c2326d1658f9e
DIFF: https://github.com/llvm/llvm-project/commit/e1dbe093c4b79ef5086a755ea28c2326d1658f9e.diff
LOG: [clang] build UnresolvedUsingType for constructor initializers (#154592)
When building the base type for constructor initializer, the case of an
UnresolvedUsingType was not being handled.
For the non-dependent case, we are also skipping adding the UsingType,
but this is just missing information in the AST. A FIXME for this is
added.
This fixes a regression introduced in #147835, which was never released,
so there are no release notes.
Fixes #154436
Added:
Modified:
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaTemplate/class-template-ctor-initializer.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index ea8519c71a398..bb57968830a65 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -4568,6 +4568,7 @@ Sema::BuildMemInitializer(Decl *ConstructorD,
MarkAnyDeclReferenced(TyD->getLocation(), TyD, /*OdrUse=*/false);
TypeLocBuilder TLB;
+ // FIXME: This is missing building the UsingType for TyD, if any.
if (const auto *TD = dyn_cast<TagDecl>(TyD)) {
BaseType = Context.getTagType(ElaboratedTypeKeyword::None,
SS.getScopeRep(), TD, /*OwnsTag=*/false);
@@ -4581,6 +4582,12 @@ Sema::BuildMemInitializer(Decl *ConstructorD,
TLB.push<TypedefTypeLoc>(BaseType).set(
/*ElaboratedKeywordLoc=*/SourceLocation(),
SS.getWithLocInContext(Context), IdLoc);
+ } else if (auto *UD = dyn_cast<UnresolvedUsingTypenameDecl>(TyD)) {
+ BaseType = Context.getUnresolvedUsingType(ElaboratedTypeKeyword::None,
+ SS.getScopeRep(), UD);
+ TLB.push<UnresolvedUsingTypeLoc>(BaseType).set(
+ /*ElaboratedKeywordLoc=*/SourceLocation(),
+ SS.getWithLocInContext(Context), IdLoc);
} else {
// FIXME: What else can appear here?
assert(SS.isEmpty());
diff --git a/clang/test/SemaTemplate/class-template-ctor-initializer.cpp b/clang/test/SemaTemplate/class-template-ctor-initializer.cpp
index 6dae20774585e..43a3986fea845 100644
--- a/clang/test/SemaTemplate/class-template-ctor-initializer.cpp
+++ b/clang/test/SemaTemplate/class-template-ctor-initializer.cpp
@@ -4,8 +4,8 @@
template<class X> struct A {};
-template<class X> struct B : A<X> {
- B() : A<X>() {}
+template<class X> struct B : A<X> {
+ B() : A<X>() {}
};
B<int> x;
@@ -76,3 +76,12 @@ namespace NonDependentError {
Derived1<void> d1;
Derived2<void> d2;
}
+
+namespace UnresolvedUsing {
+ template <class T> class A {
+ using typename T::B;
+ struct C : B {
+ C() : B() {}
+ };
+ };
+} // namespace UnresolvedUsing
More information about the cfe-commits
mailing list