Skip to content

Commit 68bcd6b

Browse files
committed
Validator: Define virtual destructor in .cpp file
This fixes compiler warnings from clang: src/training/validator.h:72:7: warning: 'Validator' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit [-Wweak-vtables] Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 0d211f9 commit 68bcd6b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/training/validator.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ const char32 Validator::kLeftToRightMark = 0x200E;
2424
const char32 Validator::kRightToLeftMark = 0x200F;
2525
const char32 Validator::kInvalid = 0xfffd;
2626

27+
// Destructor.
28+
// It is defined here, so the compiler can create a single vtable
29+
// instead of weak vtables in every compilation unit.
30+
Validator::~Validator() = default;
31+
2732
// Validates and cleans the src vector of unicodes to the *dest, according to
2833
// g_mode. In the case of kSingleString, a single vector containing the whole
2934
// result is added to *dest. With kCombined, multiple vectors are added to
@@ -175,7 +180,7 @@ ViramaScript Validator::MostFrequentViramaScript(
175180
bool Validator::IsVirama(char32 unicode) {
176181
return (kMinIndicUnicode <= unicode && unicode <= kMaxSinhalaUnicode &&
177182
(unicode & 0x7f) == 0x4d) ||
178-
unicode == kSinhalaVirama ||
183+
unicode == kSinhalaVirama ||
179184
unicode == kJavaneseVirama ||
180185
unicode == kMyanmarVirama ||
181186
unicode == kKhmerVirama;
@@ -193,8 +198,8 @@ bool Validator::IsVedicAccent(char32 unicode) {
193198
bool Validator::IsSubscriptScript() const {
194199
return script_ == ViramaScript::kTelugu ||
195200
script_ == ViramaScript::kKannada ||
196-
script_ == ViramaScript::kJavanese ||
197-
script_ == ViramaScript::kMyanmar ||
201+
script_ == ViramaScript::kJavanese ||
202+
script_ == ViramaScript::kMyanmar ||
198203
script_ == ViramaScript::kKhmer;
199204
}
200205

src/training/validator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Validator {
8989
return ch == kZeroWidthSpace || ch == kLeftToRightMark ||
9090
ch == kRightToLeftMark || ch == kInvalid;
9191
}
92-
virtual ~Validator() {}
92+
virtual ~Validator();
9393

9494
// Some specific but universally useful unicodes.
9595
static const char32 kZeroWidthSpace;

0 commit comments

Comments
 (0)