Skip to content

Commit

Permalink
Validator: Define virtual destructor in .cpp file
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
stweil committed Sep 4, 2018
1 parent 0d211f9 commit 68bcd6b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/training/validator.cpp
Expand Up @@ -24,6 +24,11 @@ const char32 Validator::kLeftToRightMark = 0x200E;
const char32 Validator::kRightToLeftMark = 0x200F;
const char32 Validator::kInvalid = 0xfffd;

// Destructor.
// It is defined here, so the compiler can create a single vtable
// instead of weak vtables in every compilation unit.
Validator::~Validator() = default;

// Validates and cleans the src vector of unicodes to the *dest, according to
// g_mode. In the case of kSingleString, a single vector containing the whole
// result is added to *dest. With kCombined, multiple vectors are added to
Expand Down Expand Up @@ -175,7 +180,7 @@ ViramaScript Validator::MostFrequentViramaScript(
bool Validator::IsVirama(char32 unicode) {
return (kMinIndicUnicode <= unicode && unicode <= kMaxSinhalaUnicode &&
(unicode & 0x7f) == 0x4d) ||
unicode == kSinhalaVirama ||
unicode == kSinhalaVirama ||
unicode == kJavaneseVirama ||
unicode == kMyanmarVirama ||
unicode == kKhmerVirama;
Expand All @@ -193,8 +198,8 @@ bool Validator::IsVedicAccent(char32 unicode) {
bool Validator::IsSubscriptScript() const {
return script_ == ViramaScript::kTelugu ||
script_ == ViramaScript::kKannada ||
script_ == ViramaScript::kJavanese ||
script_ == ViramaScript::kMyanmar ||
script_ == ViramaScript::kJavanese ||
script_ == ViramaScript::kMyanmar ||
script_ == ViramaScript::kKhmer;
}

Expand Down
2 changes: 1 addition & 1 deletion src/training/validator.h
Expand Up @@ -89,7 +89,7 @@ class Validator {
return ch == kZeroWidthSpace || ch == kLeftToRightMark ||
ch == kRightToLeftMark || ch == kInvalid;
}
virtual ~Validator() {}
virtual ~Validator();

// Some specific but universally useful unicodes.
static const char32 kZeroWidthSpace;
Expand Down

0 comments on commit 68bcd6b

Please sign in to comment.