diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-09-22 12:41:24 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-09-22 12:41:24 +0000 |
| commit | a92b80f8a099280c9d6f475eb31a6e71bb1e9bc3 (patch) | |
| tree | f4b4f46eb4fd7f782de923d8ed301b76e73ca4c5 /clang/lib | |
| parent | 56262595061846b618f239111120cfba4529ccb7 (diff) | |
| download | bcm5719-llvm-a92b80f8a099280c9d6f475eb31a6e71bb1e9bc3.tar.gz bcm5719-llvm-a92b80f8a099280c9d6f475eb31a6e71bb1e9bc3.zip | |
Rewrite a cold use of std::sort to array_pod_sort.
No functionality change.
llvm-svn: 191173
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp b/clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp index c374d0da0e8..337770a05ce 100644 --- a/clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp @@ -154,25 +154,29 @@ void ento::registerCallGraphDumper(CheckerManager &mgr) { namespace { class ConfigDumper : public Checker< check::EndOfTranslationUnit > { + typedef AnalyzerOptions::ConfigTable Table; + + static int compareEntry(const void *LHS, const void *RHS) { + return ((const Table::MapEntryTy *)LHS)->getKey().compare( + ((const Table::MapEntryTy *)RHS)->getKey()); + } + public: void checkEndOfTranslationUnit(const TranslationUnitDecl *TU, AnalysisManager& mgr, BugReporter &BR) const { + const Table &Config = mgr.options.Config; - const AnalyzerOptions::ConfigTable &Config = mgr.options.Config; - AnalyzerOptions::ConfigTable::const_iterator I = - Config.begin(), E = Config.end(); + SmallVector<const Table::MapEntryTy *, 32> Keys; + for (Table::const_iterator I = Config.begin(), E = Config.end(); I != E; + ++I) + Keys.push_back(&*I); + llvm::array_pod_sort(Keys.begin(), Keys.end(), compareEntry); - std::vector<StringRef> Keys; - for (; I != E ; ++I) { Keys.push_back(I->getKey()); } - sort(Keys.begin(), Keys.end()); - llvm::errs() << "[config]\n"; - for (unsigned i = 0, n = Keys.size(); i < n ; ++i) { - StringRef Key = Keys[i]; - I = Config.find(Key); - llvm::errs() << Key << " = " << I->second << '\n'; - } + for (unsigned I = 0, E = Keys.size(); I != E; ++I) + llvm::errs() << Keys[I]->getKey() << " = " << Keys[I]->second << '\n'; + llvm::errs() << "[stats]\n" << "num-entries = " << Keys.size() << '\n'; } }; |

