https://bugs.llvm.org/show_bug.cgi?id=38934
Bug ID: 38934
Summary: Failing to dllexport class template member w/ explicit
instantiation and PCH
Product: new-bugs
Version: 7.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedb...@nondot.org
Reporter: h...@chromium.org
CC: llvm-bugs@lists.llvm.org
For example:
#ifndef IN_HEADER
#define IN_HEADER
template <typename T> struct S { };
extern template struct S<int>;
inline void use(S<int> *s, S<int> *t) {
*s = *t;
}
#else
template struct __declspec(dllexport) S<int>;
#endif
$ clang -cc1 -triple i686-pc-win32 -fms-extensions -emit-pch
-building-pch-with-obj -o x.pch /tmp/x.cc
$ clang -cc1 -triple i686-pc-win32 -fms-extensions -emit-obj -emit-llvm
-DUSE_PCH -include-pch x.pch -o - /tmp/x.cc
In the second invocation, S<int>::operator=(S<int>&) is supposed to get
emitted, but it's not because it appears as if its definition comes from the
PCH file and so would be emitted in the .obj file corresponding to the PCH.
However, it's just the declaration that's in the PCH, not the definition.
The code in ASTContext::DeclMustBeEmitted() is supposed to catch exactly this:
bool IsExpInstDef =
isa<FunctionDecl>(D) &&
cast<FunctionDecl>(D)->getTemplateSpecializationKind() ==
TSK_ExplicitInstantiationDefinition;
if (getExternalSource()->DeclIsFromPCHWithObjectFile(D) && !IsExpInstDef)
return false;
However it doesn't work here because getTemplateSpecializationKind() returns 0,
as the function itself is not a template. At least that's what I think is
happening. It's seems I'm not understanding the AST right.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs