[PATCH] Sema: Propagate the mangling number into instantiations
Richard Smith
richard at metafoo.co.uk
Mon Nov 18 18:43:41 PST 2013
LGTM
Sorry for the broken example before; a fixed one would look like this:
template<typename ...T> int g(T...);
struct S {
template<typename ...T> static void f(int f = g([]{ static T t; return ++t; }()...)) {}
};
void h() { S::f<int, int, int>(); }
Here, we cannot inherit the mangling number from the lambda in the template into the lambdas in the expansions. I think your approach will work fine for this, because the mangling numbers are within the parent context, which will be the lambda in the problematic case. Some testcases for this would be useful, though. Things like this:
template<typename ...T> void g(T...);
template<typename ...T> void f() {
g([]{ static T t; return ++t; }()...); // or a struct inside the lambda
}
template void f<int, int, int>();
================
Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:1706-1708
@@ -1695,1 +1705,5 @@
+ // Forward the mangling number from the template to the instantiated decl.
+ SemaRef.Context.setManglingNumber(Method,
+ SemaRef.Context.getManglingNumber(D));
+
----------------
Instead of doing this in both `VisitFunctionDecl` and `VisitCXXMethodDecl`, can you put this in `InitFunctionInstantiation`?
http://llvm-reviews.chandlerc.com/D2203
ARCANIST PROJECT
clang
More information about the cfe-commits
mailing list