[clang] [Clang][Sema] Use StructuralValues to model dependent NTTP arguments (PR #93556)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Tue May 28 07:50:14 PDT 2024
================
@@ -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;
----------------
zyn0217 wrote:
The only caller of `getAsSimpleValueDeclRef` is `TemplateArgument`'s constructor (for an NTTP establishment), where we basically try the following things in order, IIUC:
1) integral type
2) nullptrs
3) declarations (this is where we called `getAsSimpleValueDeclRef` and built up a `TemplateParamObjectDecl` if the function does return a value)
otherwise, a structural type.
https://github.com/llvm/llvm-project/blob/74ed79f7f123788d95f1552800e1af9ceaee4a08/clang/lib/AST/TemplateBase.cpp#L237-L249
https://github.com/llvm/llvm-project/pull/93556
More information about the cfe-commits
mailing list