[PATCH] D69779: -fmodules-codegen should not emit extern templates
David Blaikie via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 2 12:12:41 PST 2020
dblaikie added a comment.
Hey - thanks for this! Does look like it reproduces in modules:
foo.h:
#pragma once
template <typename T>
struct outer {
static void func() {
}
};
template<typename T>
void func() {
}
extern template struct outer<int>;
extern template void func<int>();
inline void caller() {
outer<int>::func();
func<int>();
}
foo.modulemap:
module foo { header "foo.h" }
use.cpp:
#include "foo.h"
template struct outer<int>;
template void func<int>();
int main() {
}
Commands:
clang-tot -cc1 -fmodules-codegen -fmodules -emit-module -fmodule-name=foo foo.modulemap -x c++ -o foo.pcm
clang-tot -cc1 -fmodules -fmodule-file=foo.pcm use.cpp -emit-obj
clang-tot -c foo.pcm
clang-tot foo.o use.o
This test case exercises both a member function of a class template, and a standalone function template. I'd like to better understand why this shows up for function templates but not member functions of class templates - perhaps there's somewhere the solution to both cases can be unified.
Ah, if I mark the standalone function template 'inline' (the implicit linkage of member functions) then I get the same failure for both. Haven't tested whether the fix is the same fix for both yet.
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69779/new/
https://reviews.llvm.org/D69779
More information about the cfe-commits
mailing list