diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-03-26 14:05:40 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-03-26 14:05:40 +0000 |
commit | ecafd309b3ed2ffc6f8ae7eecd1e7eae84b26f81 (patch) | |
tree | 0db2b1fd1f5a07c67c3221669a2d65841bd44833 /lib/Sema/AnalysisBasedWarnings.cpp | |
parent | 38f0df352fadc546c5666079fb22de5ec1819d92 (diff) |
ThreadSafetyReporter: Manage diagnostics in a std::list.
std::list is expensive, but so is std::sorting a SmallVector of SmallVectors of
heavyweight PartialDiagnostics.
Saves ~30k in a i386-linux-Release+Asserts clang build.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153437 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r-- | lib/Sema/AnalysisBasedWarnings.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index 13ab5428b8..a8e679132c 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/lib/Sema/AnalysisBasedWarnings.cpp @@ -621,17 +621,16 @@ namespace clang { namespace thread_safety { typedef llvm::SmallVector<PartialDiagnosticAt, 1> OptionalNotes; typedef std::pair<PartialDiagnosticAt, OptionalNotes> DelayedDiag; -typedef llvm::SmallVector<DelayedDiag, 4> DiagList; +typedef std::list<DelayedDiag> DiagList; struct SortDiagBySourceLocation { - Sema &S; - SortDiagBySourceLocation(Sema &S) : S(S) {} + SourceManager &SM; + SortDiagBySourceLocation(SourceManager &SM) : SM(SM) {} bool operator()(const DelayedDiag &left, const DelayedDiag &right) { // Although this call will be slow, this is only called when outputting // multiple warnings. - return S.getSourceManager().isBeforeInTranslationUnit(left.first.first, - right.first.first); + return SM.isBeforeInTranslationUnit(left.first.first, right.first.first); } }; @@ -660,8 +659,7 @@ class ThreadSafetyReporter : public clang::thread_safety::ThreadSafetyHandler { /// the lockset in deterministic order, so this function orders diagnostics /// and outputs them. void emitDiagnostics() { - SortDiagBySourceLocation SortDiagBySL(S); - sort(Warnings.begin(), Warnings.end(), SortDiagBySL); + Warnings.sort(SortDiagBySourceLocation(S.getSourceManager())); for (DiagList::iterator I = Warnings.begin(), E = Warnings.end(); I != E; ++I) { S.Diag(I->first.first, I->first.second); |