summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2013-08-29 05:18:04 +0000
committerCraig Topper <craig.topper@gmail.com>2013-08-29 05:18:04 +0000
commitda7cf8ab2b22ec96c8d334d65daad1deba872381 (patch)
treee4b6ede84732648910c9910940cbe5affe8a0b67 /clang/lib
parent3e1d5da901a060bec0f023d5df6716244b4e7b60 (diff)
downloadbcm5719-llvm-da7cf8ab2b22ec96c8d334d65daad1deba872381.tar.gz
bcm5719-llvm-da7cf8ab2b22ec96c8d334d65daad1deba872381.zip
Move individual group name strings from the OptionTable into one big char array. Then only store offsets into it in the OptionTable. Saves about 4K from the clang binary and removes 400 relocation entries from DiagnosticIDs.o.
llvm-svn: 189568
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Basic/DiagnosticIDs.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp
index cccf418f65f..71752bb38f6 100644
--- a/clang/lib/Basic/DiagnosticIDs.cpp
+++ b/clang/lib/Basic/DiagnosticIDs.cpp
@@ -501,21 +501,22 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass,
return Result;
}
+#define GET_DIAG_ARRAYS
+#include "clang/Basic/DiagnosticGroups.inc"
+#undef GET_DIAG_ARRAYS
+
struct clang::WarningOption {
- const char *NameStr;
- uint16_t NameLen;
+ uint16_t NameOffset;
uint16_t Members;
uint16_t SubGroups;
+ // String is stored with a pascal-style length byte.
StringRef getName() const {
- return StringRef(NameStr, NameLen);
+ return StringRef(DiagGroupNames + NameOffset + 1,
+ DiagGroupNames[NameOffset]);
}
};
-#define GET_DIAG_ARRAYS
-#include "clang/Basic/DiagnosticGroups.inc"
-#undef GET_DIAG_ARRAYS
-
// Second the table of options, sorted by name for fast binary lookup.
static const WarningOption OptionTable[] = {
#define GET_DIAG_TABLE
@@ -524,9 +525,8 @@ static const WarningOption OptionTable[] = {
};
static const size_t OptionTableSize = llvm::array_lengthof(OptionTable);
-static bool WarningOptionCompare(const WarningOption &LHS,
- const WarningOption &RHS) {
- return LHS.getName() < RHS.getName();
+static bool WarningOptionCompare(const WarningOption &LHS, StringRef RHS) {
+ return LHS.getName() < RHS;
}
/// getWarningOptionForDiag - Return the lowest-level warning option that
@@ -555,11 +555,8 @@ void DiagnosticIDs::getDiagnosticsInGroup(
bool DiagnosticIDs::getDiagnosticsInGroup(
StringRef Group,
SmallVectorImpl<diag::kind> &Diags) const {
- if (Group.size() > UINT16_MAX)
- return true; // Option is too long to be one in the table.
- WarningOption Key = { Group.data(), (uint16_t)Group.size(), 0, 0 };
const WarningOption *Found =
- std::lower_bound(OptionTable, OptionTable + OptionTableSize, Key,
+ std::lower_bound(OptionTable, OptionTable + OptionTableSize, Group,
WarningOptionCompare);
if (Found == OptionTable + OptionTableSize ||
Found->getName() != Group)
OpenPOWER on IntegriCloud