[Clang] -gtemplate-alias assertion failure '!isValueDependent() && "Expression evaluator can't be called on a dependent expression."' · Issue #89774 · llvm/llvm-project (original) (raw)
#87623 adds an option -gtemplate-alias
which tells Clang to emit type metadata that can be used to build DW_TAG_template_alias
DWARF DIEs instead of DW_TAG_typedefs
for template aliases. In order to do this we need to create DIType *
s for all the template arguments.
This case causes an assertion:
template using A = int;
template struct S { using AA = A; AA aa; };
S<0> s;
clang/lib/AST/ExprConstant.cpp:15722: bool clang::Expr::EvaluateAsRValue(clang::Expr::EvalResult&, const clang::ASTContext&, bool) const: Assertion '!isValueDependent() && "Expression evaluator can't be called on a dependent expression."' failed
Remove -Xclang -dump-ast
from this Godbolt example to see the assertion:
https://godbolt.org/z/dPEcbneba
The TemplateSpecializationType
passed to CGDebugInfo::CreateType
for S<0>::AA
's underlying type A<I>
looks like this:
TemplateSpecializationType 0x55911729f2a0 'A' sugar instantiation_dependent alias A
|-TemplateArgument expr
| -DeclRefExpr 0x55911729f280 'int' NonTypeTemplateParm 0x55911729ee18 'I' 'int'
-BuiltinType 0x55911724ea30 'int'
I'm trying to fix the issue, but I'm not particularly familiar with the front end or Clang AST.
Is it possible to resolve the dependent expression I
in A<I>
to 0
? S
has been instantiated, so it feels like we should have that information available, but I'm not sure where it exists in the AST.
If anyone is able to point me in the right direction or at some documentation that would be greatly appreciated.