[cfe-dev] Help with Sema code

Mario Voorsluys via cfe-dev cfe-dev at lists.llvm.org
Tue Oct 1 00:59:35 PDT 2019


Hi all,

I'm new to the clang code base. I decided to take a look at bug
https://bugs.llvm.org/show_bug.cgi?id=23029, as it is affecting one of my
daily projects.

I came up with two different solutions for it, but I have no idea which one
is the best.

The problem:
If I have a template declaration like:

template <typename... T>
void f(int i = 0, T ...args) {}

I cannot instantiate with `f(1, 1);` as clang will complain that there is
no default value for `args`.

The first solution is to avoid calling the function
`CheckCXXDefaultArguments(NewFD)` in file `SemaDecl.cpp`, in the function
`Sema::CheckFunctionDeclaration()` when it is a template instantiation,
assuming the check was already done in the template definition.

The second one is to modify the check in `Sema::CheckCXXDefaultArguments()`
in file `SemaDeclCXX.cpp`, to check if a parameter is a template
substitution, and if so, check if the original parameter is a parameter
pack.

Can someone with more knowledge about this part of the code give me some
advice? Is the assumption for solution one always valid? And which solution
would be preferred?

Regards,
Mario
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20191001/da36bbf7/attachment.html>


More information about the cfe-dev mailing list