<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/73389>73389</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [question] How to figure out if template argument is being passed to "Visit" callback?
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          harsszegi
      </td>
    </tr>
</table>

<pre>
    Hello,

I have a strange issue. I have something like this:

```
template<typename T, int S>
class Test
{
public:
  Test(T t) : t_{t} {}
private:
  T t_;
};

static Test<int,2> aa{4};
static Test<double,3> bb{6.0};

void functionX(Test<int,2> a = aa, Test<double,3> b = bb);
void functionZ(Test<int,2> a, Test<double,3> b);

```

I am using libclang to parse the AST and using visitors obviously the use the AST.
I have issue with the "Test<int,2> a = aa".
It does the following (when I visit):

* calls VisitVarDecl
* calls VisitTemplateSpecializationTypeLoc, which calls VisitTemplateName, this will call back to my visitor code with the "Test"
template ref. so far so good
* Then it wants to visit the template arguments, which is understandable
* It calls VisitTemplateArgumentLoc to visit the template arguments, first it calls VisitBuiltinTypeLoc (because of "int"),
but that doesn't visit because type filtering in VisitBuiltinTypeLoc
* The second argument will be passed as TemplateArgument::Expression, which will be an integral literal (2).

So my "visitor" code first received a templateref, then an integer literal ("2")

How can I figure out that the literal "2" is actually "belonging" to the previously received templateref, e.g. it's not a "default argument", but the argument of the template.

Thanks,
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVc2OqzgTfRpnU7qImNAkiyzy09Ft6erbdNT6NJuRMQV42rEZ2yST-_SjMuRvOnc0UgvoUHVO1anjQnivGoO4ZPma5duJ6ENr3bIVzvuf2KhJaavz8jtqbRnfsHTL0tVwfYNWHBEE-OCEaRCU9z0mMP7u7QFDq0wDWn0ihFZ5lq3uAdhLOv7FfwMeOi0CsmwTzh0acUDYM74BZQK8s-x1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