HighCommander4 wrote:
> for some odd reason explicit instantiations are treated as implicit ones, so
> I feel like here is some clean up to do too (see [this
> call](https://searchfox.org/llvm/source/clang/lib/Index/IndexDecl.cpp#784)
> returning true on
> [this](https://searchfox.org/llvm/source/clang/lib/Index/IndexingContext.cpp#189)),
> which ties again into, what even is the desired behaviour?
A note on terminology: an **explicit instantiation** is when you ask the
compiler to explicitly instantiate a primary template for a particular set of
arguments. For example:
```c++
// Primary template definition
template <typename T> void foo() {
...
}
// Explicitly ask for foo<int> to be instantiated
template void foo<int>();
```
(You can also forward-declare an explicit instantiation with `extern template
void foo<int>();`, which amounts to telling the compiler that another
translation unit will explicitly instantiate `foo<int>` and so the current
translation unit should not, it should just emit references to a symbol that
will be found at link time.)
By contrast, an **explicit specialization** is when you provide an alternative
definition (different from the primary template definition) for a particular
set of template arguments:
```c++
template <typename T> void foo() {
// primary template definition
}
template <> void foo<int>() {
// different definition for foo<int>
}
```
With this terminology in mind, I think having libIndex's
`IndexImplicitInstantiations` flag also enable indexing of explicit
instantiations is probably fine, even if it means the flag name is not fully
precise.
> I am pondering why when turning on the
> `IndexingOptions::IndexImplicitInstantiation` only explicit instantiations
> get Symbols and if that is desired behaviour. Not sure if this matters at all
> but for now it leads to a test failure
I'd need some more details to comment on this (e.g. what test, where are you
looking to see what gets Symbols).
https://github.com/llvm/llvm-project/pull/177273
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits