From 0e28a257727f092fbb2d544fd9aaf3b20a323456 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 28 Aug 2013 06:01:10 +0000 Subject: Reorder and shrink size of NameLen field in diagnostic group table. Shaves ~4K from clang binary. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189445 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/diagtool/DiagnosticNames.h | 5 +---- tools/diagtool/TreeView.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'tools/diagtool') diff --git a/tools/diagtool/DiagnosticNames.h b/tools/diagtool/DiagnosticNames.h index dd5381f028..957a1818e8 100644 --- a/tools/diagtool/DiagnosticNames.h +++ b/tools/diagtool/DiagnosticNames.h @@ -35,11 +35,8 @@ namespace diagtool { struct GroupRecord { - // Be safe with the size of 'NameLen' because we don't statically check if - // the size will fit in the field; the struct size won't decrease with a - // shorter type anyway. - size_t NameLen; const char *NameStr; + uint16_t NameLen; uint16_t Members; uint16_t SubGroups; diff --git a/tools/diagtool/TreeView.cpp b/tools/diagtool/TreeView.cpp index 6298179030..10809c1d8d 100644 --- a/tools/diagtool/TreeView.cpp +++ b/tools/diagtool/TreeView.cpp @@ -94,7 +94,12 @@ static int showGroup(llvm::raw_ostream &out, StringRef RootGroup, bool FlagsOnly) { ArrayRef AllGroups = getDiagnosticGroups(); - GroupRecord Key = { RootGroup.size(), RootGroup.data(), 0, 0 }; + if (RootGroup.size() > UINT16_MAX) { + llvm::errs() << "No such diagnostic group exists\n"; + return 1; + } + + GroupRecord Key = { RootGroup.data(), (uint16_t)RootGroup.size(), 0, 0 }; const GroupRecord *Found = std::lower_bound(AllGroups.begin(), AllGroups.end(), Key); -- cgit v1.2.3