[clang] [Clang][NFCI] Slightly refactor getTemplateInstantiationArgs() (PR #102922)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 13 19:43:41 PDT 2024


mizvekov wrote:

I think we could instead simplify the function to the following signature:
```C++
MultiLevelTemplateArgumentList Sema::getTemplateInstantiationArgs(
    const Decl *D, bool LexicalParent, bool Final, .....)
```

Ie we take a single decl, which we will assume is a NamedDecl in case Innermost is provided, and in that case continue to either it's semantic or lexical parent, depending on `LexicalParent` parameter.

As an improvement on that, we can basically reuse the logic we already have for deciding which parent to visit next, which is already used in the normal case. Either refactor that, or just add an internal 'bool' parameter that controls if the implementation will add the template parameters, and call that from the 'Innermost' path with adding the arguments disabled.
That way, we can do away with the `LexicalParent` parameter as well.

Does that make sense? Would that work for you?

https://github.com/llvm/llvm-project/pull/102922


More information about the cfe-commits mailing list