aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/TemplateBase.cpp
diff options
context:
space:
mode:
authorYounan Zhang <zyn7109@gmail.com>2024-05-29 12:58:44 +0800
committerGitHub <noreply@github.com>2024-05-29 12:58:44 +0800
commitbb42511f64fd44f2ff1beb0dd38a653a8f2c20df (patch)
treeb79a9f4c471c739f03d9b88d305554eca4841026 /clang/lib/AST/TemplateBase.cpp
parentcbf6e93ceee7b9de2b7c3e7e8cea3a972eda0e75 (diff)
downloadllvm-bb42511f64fd44f2ff1beb0dd38a653a8f2c20df.zip
llvm-bb42511f64fd44f2ff1beb0dd38a653a8f2c20df.tar.gz
llvm-bb42511f64fd44f2ff1beb0dd38a653a8f2c20df.tar.bz2
[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
Diffstat (limited to 'clang/lib/AST/TemplateBase.cpp')
-rw-r--r--clang/lib/AST/TemplateBase.cpp7
1 files changed, 6 insertions, 1 deletions
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.