From bb42511f64fd44f2ff1beb0dd38a653a8f2c20df Mon Sep 17 00:00:00 2001 From: Younan Zhang Date: Wed, 29 May 2024 12:58:44 +0800 Subject: [Clang][Sema] Use StructuralValues to model dependent NTTP arguments (#93556) This patch takes Richard's approach of no longer modeling dependent NTTP arguments with TemplateParamObjectDecls. Clang used to do so, which left behind a problem in that we might mess up dependent and non-dependent arguments that boil down to the same canonical type because there's a default argument on the NTTP. The problem of "canonical expression" is still present because this patch doesn't touch the profiling part. Namely, #92292 seems different. Fixes https://github.com/llvm/llvm-project/issues/84052 --- clang/lib/AST/TemplateBase.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'clang/lib/AST/TemplateBase.cpp') diff --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp index a7ee973..b50daf5 100644 --- a/clang/lib/AST/TemplateBase.cpp +++ b/clang/lib/AST/TemplateBase.cpp @@ -221,8 +221,13 @@ static const ValueDecl *getAsSimpleValueDeclRef(const ASTContext &Ctx, // We model class non-type template parameters as their template parameter // object declaration. - if (V.isStruct() || V.isUnion()) + if (V.isStruct() || V.isUnion()) { + // Dependent types are not supposed to be described as + // TemplateParamObjectDecls. + if (T->isDependentType() || T->isInstantiationDependentType()) + return nullptr; return Ctx.getTemplateParamObjectDecl(T, V); + } // Pointers and references with an empty path use the special 'Declaration' // representation. -- cgit v1.1