summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/Diagnostic.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2012-03-13 18:21:17 +0000
committerDaniel Dunbar <daniel@zuster.org>2012-03-13 18:21:17 +0000
commit007b9dc5936296ae65db926611d7204b865f92da (patch)
treec0242c8d903b23e0cc73c2bf52d7140d47f9d54d /clang/lib/Basic/Diagnostic.cpp
parent87fa77bd8a53d338df10f37718d4e7bcc9b74550 (diff)
downloadbcm5719-llvm-007b9dc5936296ae65db926611d7204b865f92da.tar.gz
bcm5719-llvm-007b9dc5936296ae65db926611d7204b865f92da.zip
[Basic] Stop using a SmallVector<> for Diagnostic. This drops Clang binary size
by ~%.3/~100k in my build -- simply by eliminating the horrible code bloat coming from the .clear() of the SmallVector<FixItHint>, which does a std::~string, etc. - My understanding is we don't ever emit arbitrary numbers of fixits, so I just moved us to using a statically sized array like we do for arguments and ranges. llvm-svn: 152639
Diffstat (limited to 'clang/lib/Basic/Diagnostic.cpp')
-rw-r--r--clang/lib/Basic/Diagnostic.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index 4a63d979335..a36f3ce38a1 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -357,7 +357,7 @@ void DiagnosticsEngine::Report(const StoredDiagnostic &storedDiag) {
NumDiagArgs = 0;
NumDiagRanges = storedDiag.range_size();
- assert(NumDiagRanges < sizeof(DiagRanges)/sizeof(DiagRanges[0]) &&
+ assert(NumDiagRanges < DiagnosticsEngine::MaxRanges &&
"Too many arguments to diagnostic!");
unsigned i = 0;
for (StoredDiagnostic::range_iterator
@@ -365,11 +365,13 @@ void DiagnosticsEngine::Report(const StoredDiagnostic &storedDiag) {
RE = storedDiag.range_end(); RI != RE; ++RI)
DiagRanges[i++] = *RI;
- FixItHints.clear();
+ assert(NumDiagRanges < DiagnosticsEngine::MaxFixItHints &&
+ "Too many arguments to diagnostic!");
+ NumDiagFixItHints = 0;
for (StoredDiagnostic::fixit_iterator
FI = storedDiag.fixit_begin(),
FE = storedDiag.fixit_end(); FI != FE; ++FI)
- FixItHints.push_back(*FI);
+ DiagFixItHints[NumDiagFixItHints++] = *FI;
assert(Client && "DiagnosticConsumer not set!");
Level DiagLevel = storedDiag.getLevel();
@@ -386,6 +388,7 @@ void DiagnosticsEngine::Report(const StoredDiagnostic &storedDiag) {
void DiagnosticBuilder::FlushCounts() {
DiagObj->NumDiagArgs = NumArgs;
DiagObj->NumDiagRanges = NumRanges;
+ DiagObj->NumDiagFixItHints = NumFixits;
}
bool DiagnosticBuilder::Emit() {
OpenPOWER on IntegriCloud