diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-02-15 20:57:03 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-02-15 20:57:03 +0000 |
commit | d49cb20288b2dbc222aaf5673c1a4738c151b7bf (patch) | |
tree | cb9671a267826548d4a2d95930657ce7043d5bda /lib/Basic/DiagnosticIDs.cpp | |
parent | ceb15656fbab9ee1da319afa4934b8f6a5964758 (diff) |
Store the warning option corresponding to a diagnostics as an index into the option table instead of storing the name.
Another 8 bytes + relocation removed from every diagnostic on x86_64.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150615 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/DiagnosticIDs.cpp')
-rw-r--r-- | lib/Basic/DiagnosticIDs.cpp | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/lib/Basic/DiagnosticIDs.cpp b/lib/Basic/DiagnosticIDs.cpp index 754d7c0322..2f28c5dbf7 100644 --- a/lib/Basic/DiagnosticIDs.cpp +++ b/lib/Basic/DiagnosticIDs.cpp @@ -52,16 +52,13 @@ struct StaticDiagInfoRec { unsigned WarnShowInSystemHeader : 1; unsigned Category : 5; - uint8_t OptionGroupLen; + uint16_t OptionGroupIndex; uint16_t DescriptionLen; - - const char *OptionGroupStr; - const char *DescriptionStr; - StringRef getOptionGroup() const { - return StringRef(OptionGroupStr, OptionGroupLen); + unsigned getOptionGroupIndex() const { + return OptionGroupIndex; } StringRef getDescription() const { @@ -89,10 +86,8 @@ static const StaticDiagInfoRec StaticDiagInfo[] = { SFINAE,ACCESS,NOWERROR,SHOWINSYSHEADER, \ CATEGORY) \ { diag::ENUM, DEFAULT_MAPPING, CLASS, SFINAE, ACCESS, \ - NOWERROR, SHOWINSYSHEADER, CATEGORY, \ - STR_SIZE(GROUP, uint8_t), \ - STR_SIZE(DESC, uint16_t), \ - GROUP, DESC }, + NOWERROR, SHOWINSYSHEADER, CATEGORY, GROUP, \ + STR_SIZE(DESC, uint16_t), DESC }, #include "clang/Basic/DiagnosticCommonKinds.inc" #include "clang/Basic/DiagnosticDriverKinds.inc" #include "clang/Basic/DiagnosticFrontendKinds.inc" @@ -103,7 +98,7 @@ static const StaticDiagInfoRec StaticDiagInfo[] = { #include "clang/Basic/DiagnosticSemaKinds.inc" #include "clang/Basic/DiagnosticAnalysisKinds.inc" #undef DIAG - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; static const unsigned StaticDiagInfoSize = @@ -130,7 +125,7 @@ static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) { // Search the diagnostic table with a binary search. StaticDiagInfoRec Find = { static_cast<unsigned short>(DiagID), - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; const StaticDiagInfoRec *Found = std::lower_bound(StaticDiagInfo, StaticDiagInfo + StaticDiagInfoSize, Find); @@ -164,15 +159,6 @@ static DiagnosticMappingInfo GetDefaultDiagMappingInfo(unsigned DiagID) { return Info; } -/// getWarningOptionForDiag - Return the lowest-level warning option that -/// enables the specified diagnostic. If there is no -Wfoo flag that controls -/// the diagnostic, this returns null. -StringRef DiagnosticIDs::getWarningOptionForDiag(unsigned DiagID) { - if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID)) - return Info->getOptionGroup(); - return StringRef(); -} - /// getCategoryNumberForDiag - Return the category number that a specified /// DiagID belongs to, or 0 if no category. unsigned DiagnosticIDs::getCategoryNumberForDiag(unsigned DiagID) { @@ -531,6 +517,15 @@ static bool WarningOptionCompare(const WarningOption &LHS, return LHS.getName() < RHS.getName(); } +/// getWarningOptionForDiag - Return the lowest-level warning option that +/// enables the specified diagnostic. If there is no -Wfoo flag that controls +/// the diagnostic, this returns null. +StringRef DiagnosticIDs::getWarningOptionForDiag(unsigned DiagID) { + if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID)) + return OptionTable[Info->getOptionGroupIndex()].getName(); + return StringRef(); +} + void DiagnosticIDs::getDiagnosticsInGroup( const WarningOption *Group, llvm::SmallVectorImpl<diag::kind> &Diags) const |