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 | a8cafe23e3dfd6fe732c035da51eafa029c49576 (patch) | |
| tree | 50d6d34a89fdc2d137e84eaf94ec0c1a49a34e74 /clang/utils | |
| parent | f9c73f662928e2161a7a1a5e557b66263c03a402 (diff) | |
| download | bcm5719-llvm-a8cafe23e3dfd6fe732c035da51eafa029c49576.tar.gz bcm5719-llvm-a8cafe23e3dfd6fe732c035da51eafa029c49576.zip | |
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.
llvm-svn: 150615
Diffstat (limited to 'clang/utils')
| -rw-r--r-- | clang/utils/TableGen/ClangDiagnosticsEmitter.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp index 4b041fee872..529e7ecd6ac 100644 --- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp +++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp @@ -21,6 +21,7 @@ #include <map> #include <algorithm> #include <functional> +#include <set> using namespace llvm; //===----------------------------------------------------------------------===// @@ -138,7 +139,21 @@ void ClangDiagsDefsEmitter::run(raw_ostream &OS) { const std::vector<Record*> &Diags = Records.getAllDerivedDefinitions("Diagnostic"); - + + // Make a sorted set of all warning opts so we can get the index. + std::set<std::string> WarningOpts; + for (unsigned i = 0, e = Diags.size(); i != e; ++i) { + const Record *R = Diags[i]; + DefInit *DI = dynamic_cast<DefInit*>(R->getValueInit("Group")); + if (DI) + WarningOpts.insert(DI->getDef()->getValueAsString("GroupName")); + } + + std::vector<Record*> DiagGroups + = Records.getAllDerivedDefinitions("DiagGroup"); + for (unsigned i = 0, e = DiagGroups.size(); i != e; ++i) + WarningOpts.insert(DiagGroups[i]->getValueAsString("GroupName")); + DiagCategoryIDMap CategoryIDs(Records); DiagGroupParentMap DGParentMap(Records); @@ -156,12 +171,15 @@ void ClangDiagsDefsEmitter::run(raw_ostream &OS) { OS << ", \""; OS.write_escaped(R.getValueAsString("Text")) << '"'; - // Warning associated with the diagnostic. + // Warning associated with the diagnostic. This is stored as an index into + // the alphabetically sorted warning table. if (DefInit *DI = dynamic_cast<DefInit*>(R.getValueInit("Group"))) { - OS << ", \""; - OS.write_escaped(DI->getDef()->getValueAsString("GroupName")) << '"'; + std::set<std::string>::iterator I = + WarningOpts.find(DI->getDef()->getValueAsString("GroupName")); + assert(I != WarningOpts.end()); + OS << ", " << std::distance(WarningOpts.begin(), I); } else { - OS << ", \"\""; + OS << ", 0"; } // SFINAE bit |

