Problem
clang-dumper currently serializes TemplateArgument::StructuralValue using only the value's type. Clava stores that type in TemplateArgumentStructuralValue, but loses the evaluated APValue.
For example:
template <double D>
struct FloatArg {
int values[D > 1.0 ? 2 : 1];
};
FloatArg<1.25> first;
FloatArg<0.5> second;
The source-facing TemplateSpecializationType keeps each written expression. The canonical ClassTemplateSpecializationDecl arguments, however, both reach Clava as StructuralValue(type = double) with no value. This loses the information that identifies each specialization.
The specialization declarations are still useful because Clang puts substituted members on them. In this example, the two values fields have types int[2] and int[1].
Suggested direction
- Keep written argument expressions on
TemplateSpecializationType.
- Serialize the useful evaluated value for
StructuralValue as typed data, not as an ID with no resolvable Clava node.
- Cover the APValue kinds that structural template arguments need. Do not dump every cached
ConstantExpr APValue.
- Keep implicit specialization declarations for analysis, but do not emit them as separately written source.
- Update clang-dumper and Clava together because the line protocol has no record version.
- Add focused floating-point and class-valued template argument tests.
Related discussion: #241 (comment)
Problem
clang-dumper currently serializes
TemplateArgument::StructuralValueusing only the value's type. Clava stores that type inTemplateArgumentStructuralValue, but loses the evaluatedAPValue.For example:
The source-facing
TemplateSpecializationTypekeeps each written expression. The canonicalClassTemplateSpecializationDeclarguments, however, both reach Clava asStructuralValue(type = double)with no value. This loses the information that identifies each specialization.The specialization declarations are still useful because Clang puts substituted members on them. In this example, the two
valuesfields have typesint[2]andint[1].Suggested direction
TemplateSpecializationType.StructuralValueas typed data, not as an ID with no resolvable Clava node.ConstantExprAPValue.Related discussion: #241 (comment)