Skip to content

Commit 8c13680

Browse files
committed
PR18733: Remove -Wweak-template-vtables
It isn't really pulling its weight and I think splitting it out from -Wweak-vtables was the wrong call: I think it was just a bug in the original warning, which was trying to not diagnose template instantiations, implicit or explicit.
1 parent 516884f commit 8c13680

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,10 +1643,6 @@ def warn_weak_vtable : Warning<
16431643
"%0 has no out-of-line virtual method definitions; its vtable will be "
16441644
"emitted in every translation unit">,
16451645
InGroup<DiagGroup<"weak-vtables">>, DefaultIgnore;
1646-
def warn_weak_template_vtable : Warning<
1647-
"explicit template instantiation %0 will emit a vtable in every "
1648-
"translation unit">,
1649-
InGroup<DiagGroup<"weak-template-vtables">>, DefaultIgnore;
16501646

16511647
def ext_using_undefined_std : ExtWarn<
16521648
"using directive refers to implicitly-defined namespace 'std'">;

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "clang/AST/TypeOrdering.h"
2727
#include "clang/Basic/AttributeCommonInfo.h"
2828
#include "clang/Basic/PartialDiagnostic.h"
29+
#include "clang/Basic/Specifiers.h"
2930
#include "clang/Basic/TargetInfo.h"
3031
#include "clang/Lex/LiteralSupport.h"
3132
#include "clang/Lex/Preprocessor.h"
@@ -17647,16 +17648,12 @@ bool Sema::DefineUsedVTables() {
1764717648
// no key function or the key function is inlined. Don't warn in C++ ABIs
1764817649
// that lack key functions, since the user won't be able to make one.
1764917650
if (Context.getTargetInfo().getCXXABI().hasKeyFunctions() &&
17650-
Class->isExternallyVisible() && ClassTSK != TSK_ImplicitInstantiation) {
17651+
Class->isExternallyVisible() && ClassTSK != TSK_ImplicitInstantiation &&
17652+
ClassTSK != TSK_ExplicitInstantiationDefinition) {
1765117653
const FunctionDecl *KeyFunctionDef = nullptr;
1765217654
if (!KeyFunction || (KeyFunction->hasBody(KeyFunctionDef) &&
17653-
KeyFunctionDef->isInlined())) {
17654-
Diag(Class->getLocation(),
17655-
ClassTSK == TSK_ExplicitInstantiationDefinition
17656-
? diag::warn_weak_template_vtable
17657-
: diag::warn_weak_vtable)
17658-
<< Class;
17659-
}
17655+
KeyFunctionDef->isInlined()))
17656+
Diag(Class->getLocation(), diag::warn_weak_vtable) << Class;
1766017657
}
1766117658
}
1766217659
VTableUses.clear();

clang/test/SemaCXX/warn-weak-vtables.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// RUN: %clang_cc1 %s -fsyntax-only -verify -triple %itanium_abi_triple -Wweak-vtables -Wweak-template-vtables
1+
// RUN: %clang_cc1 %s -fsyntax-only -verify -triple %itanium_abi_triple -Wweak-vtables
22
//
33
// Check that this warning is disabled on MS ABI targets which don't have key
44
// functions.
5-
// RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror -Wweak-vtables -Wweak-template-vtables
5+
// RUN: %clang_cc1 %s -fsyntax-only -triple %ms_abi_triple -Werror -Wweak-vtables
66

77
struct A { // expected-warning {{'A' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}
88
virtual void f() { }
@@ -63,7 +63,7 @@ template<typename T> struct TemplVirt {
6363
virtual void f();
6464
};
6565

66-
template class TemplVirt<float>; // expected-warning{{explicit template instantiation 'TemplVirt<float>' will emit a vtable in every translation unit}}
66+
template class TemplVirt<float>;
6767

6868
template<> struct TemplVirt<bool> {
6969
virtual void f();

0 commit comments

Comments
 (0)