[cfe-commits] r153437 - /cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
Benjamin Kramer
benny.kra at googlemail.com
Mon Mar 26 07:05:40 PDT 2012
Author: d0k
Date: Mon Mar 26 09:05:40 2012
New Revision: 153437
URL: http://llvm.org/viewvc/llvm-project?rev=153437&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=153437&r1=153436&r2=153437&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Mon Mar 26 09:05:40 2012
@@ -621,17 +621,16 @@
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 @@
/// 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);
More information about the cfe-commits
mailing list