[cfe-dev] [Possible regression?] Canonical decl of friend template decls in dependent contexts

slycelote via cfe-dev cfe-dev at lists.llvm.org
Thu Oct 12 15:17:44 PDT 2017


Consider the following:


template<typename T>
struct C; // d1

template<typename T>
class D {
    static void f() {}

    template<typename>
    friend struct C; // d2
};

template<typename T>
struct C { }; // d3

int main() { }


Here there are 3 declarations corresponding to class template C (marked
as d1, d2 and d3).

In clang 3.9 getCanonicalDecl() for all 3 of them returns d1. Starting
from clang 4.0, d2->getCanonicalDecl() == d2. As far as I can tell, this
is caused by commit 291753 [1].

Is this intended? It looks to me, that, for example,
clang::declaresSameEntity(d1, d2) [2] will return a wrong result.


[1] https://llvm.org/viewvc/llvm-project?view=revision&revision=291753
[2]
https://clang.llvm.org/doxygen/namespaceclang.html#ad9d926b16adbdbc93705737b69d47cae


-- 
Sly.



More information about the cfe-dev mailing list