[cfe-dev] Adding template default parameter with as typed explicit parameter
Philippe Canal
pcanal at fnal.gov
Wed Sep 26 06:10:17 PDT 2012
Hi,
With the class template:
template <typename T> class Coord;
template <typename T, typename U = Coord<T> > class Point;
If the user code contains:
typedef long size_t;
Point<size_t> p;
when traversing the AST, reaching 'p', I have access to a clang::Type
named 'Point<size_t>' which directs the CXXRecordDecl named
'Point<long, Coord<long> >.
Is there a way to create (from Point<size_t>) a type which would be
named 'Point<size_t, Coord<size_t> >'. I.e. which preserves the
typedef when expanding/adding the template default parameters?
If there is not, what would you recommend to start from to
implement support for this?
Thanks,
Philippe.
PS.
clang::TemplateArgumentLoc ArgType = S.SubstDefaultTemplateArgumentIfAvailable(
Template,
TemplateLoc,
RAngleLoc,
TTP,
Converted);
with Converted containing the argument passed by the user as is (i.e. non-canonical)
**seems** to work as I need it .... but only if a few asserts (requiring the canonicality
of the element of Converted) are removed and if I avoid the call to:
} else if (Context.hasSameUnqualifiedType(Arg, Context.OverloadTy)) {
return Diag(SR.getBegin(), diag::err_template_arg_overload_type) << SR;
in Sema::CheckTemplateArgument which only works properly with canonical types.
More information about the cfe-dev
mailing list