diff options
author | Luboš Luňák <l.lunak@centrum.cz> | 2019-11-03 20:47:40 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@centrum.cz> | 2020-01-14 23:39:50 +0100 |
commit | 729530f68fe135ad41d470fbed019cc5e31ac8a5 (patch) | |
tree | 84ec84a0ee7baa437932dd9cef1c723bd67c80e8 /clang/lib/Serialization/ASTWriterDecl.cpp | |
parent | f52d71736b10e87b1aa1880b777dc9462a0085ce (diff) | |
download | bcm5719-llvm-729530f68fe135ad41d470fbed019cc5e31ac8a5.tar.gz bcm5719-llvm-729530f68fe135ad41d470fbed019cc5e31ac8a5.zip |
-fmodules-codegen should not emit extern templates
If a header contains 'extern template', then the template should be provided
somewhere by an explicit instantiation, so it is not necessary to generate
a copy. Worse, this can lead to an unresolved symbol, because the codegen's
object file will not actually contain functions from such a template
because of the GVA_AvailableExternally, but the object file for the explicit
instantiation will not contain them either because it will be blocked
by the information provided by the module.
Differential Revision: https://reviews.llvm.org/D69779
Diffstat (limited to 'clang/lib/Serialization/ASTWriterDecl.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriterDecl.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp index a553936570b..74a49fa813a 100644 --- a/clang/lib/Serialization/ASTWriterDecl.cpp +++ b/clang/lib/Serialization/ASTWriterDecl.cpp @@ -2437,11 +2437,12 @@ void ASTRecordWriter::AddFunctionDefinition(const FunctionDecl *FD) { } if (Writer->Context->getLangOpts().ModulesCodegen) { // Under -fmodules-codegen, codegen is performed for all non-internal, - // non-always_inline functions. + // non-always_inline functions, unless they are available elsewhere. if (!FD->hasAttr<AlwaysInlineAttr>()) { if (!Linkage) Linkage = Writer->Context->GetGVALinkageForFunction(FD); - ModulesCodegen = *Linkage != GVA_Internal; + ModulesCodegen = + *Linkage != GVA_Internal && *Linkage != GVA_AvailableExternally; } } } |