summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-03-26 14:05:40 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-03-26 14:05:40 +0000
commit40b099b0680e8a6b99167fba6e1e6b228e8935bd (patch)
tree19abe52df22b753421b3ac26de7661c3d53fecb9
parentc0f6380464525285fe165cae60a41b146e09d48a (diff)
downloadbcm5719-llvm-40b099b0680e8a6b99167fba6e1e6b228e8935bd.tar.gz
bcm5719-llvm-40b099b0680e8a6b99167fba6e1e6b228e8935bd.zip
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. llvm-svn: 153437
-rw-r--r--clang/lib/Sema/AnalysisBasedWarnings.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 13ab5428b85..a8e679132c7 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/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);
OpenPOWER on IntegriCloud