summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/VTableBuilder.cpp9
-rw-r--r--clang/lib/Analysis/LiveVariables.cpp22
-rw-r--r--clang/lib/Analysis/ReachableCode.cpp17
-rw-r--r--clang/lib/Frontend/PrintPreprocessedOutput.cpp11
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp11
5 files changed, 29 insertions, 41 deletions
diff --git a/clang/lib/AST/VTableBuilder.cpp b/clang/lib/AST/VTableBuilder.cpp
index d975dbe3639..eb5fa328559 100644
--- a/clang/lib/AST/VTableBuilder.cpp
+++ b/clang/lib/AST/VTableBuilder.cpp
@@ -3244,10 +3244,6 @@ void MicrosoftVTableContext::computeVTablePaths(bool ForVBTables,
Changed = rebucketPaths(Paths);
}
-static bool pathCompare(const VPtrInfo *LHS, const VPtrInfo *RHS) {
- return LHS->MangledPath < RHS->MangledPath;
-}
-
static bool extendPath(VPtrInfo *P) {
if (P->NextBaseToMangle) {
P->MangledPath.push_back(P->NextBaseToMangle);
@@ -3265,7 +3261,10 @@ static bool rebucketPaths(VPtrInfoVector &Paths) {
// ordering is based on pointers, but it doesn't change our output order. The
// current algorithm is designed to match MSVC 2012's names.
VPtrInfoVector PathsSorted(Paths);
- std::sort(PathsSorted.begin(), PathsSorted.end(), pathCompare);
+ std::sort(PathsSorted.begin(), PathsSorted.end(),
+ [](const VPtrInfo *LHS, const VPtrInfo *RHS) {
+ return LHS->MangledPath < RHS->MangledPath;
+ });
bool Changed = false;
for (size_t I = 0, E = PathsSorted.size(); I != E;) {
// Scan forward to find the end of the bucket.
diff --git a/clang/lib/Analysis/LiveVariables.cpp b/clang/lib/Analysis/LiveVariables.cpp
index f13f90324cb..799799c5426 100644
--- a/clang/lib/Analysis/LiveVariables.cpp
+++ b/clang/lib/Analysis/LiveVariables.cpp
@@ -581,16 +581,6 @@ LiveVariables::computeLiveness(AnalysisDeclContext &AC,
return new LiveVariables(LV);
}
-static bool compare_entries(const CFGBlock *A, const CFGBlock *B) {
- return A->getBlockID() < B->getBlockID();
-}
-
-static bool compare_vd_entries(const Decl *A, const Decl *B) {
- SourceLocation ALoc = A->getLocStart();
- SourceLocation BLoc = B->getLocStart();
- return ALoc.getRawEncoding() < BLoc.getRawEncoding();
-}
-
void LiveVariables::dumpBlockLiveness(const SourceManager &M) {
getImpl(impl).dumpBlockLiveness(M);
}
@@ -602,7 +592,9 @@ void LiveVariablesImpl::dumpBlockLiveness(const SourceManager &M) {
it != ei; ++it) {
vec.push_back(it->first);
}
- std::sort(vec.begin(), vec.end(), compare_entries);
+ std::sort(vec.begin(), vec.end(), [](const CFGBlock *A, const CFGBlock *B) {
+ return A->getBlockID() < B->getBlockID();
+ });
std::vector<const VarDecl*> declVec;
@@ -619,9 +611,11 @@ void LiveVariablesImpl::dumpBlockLiveness(const SourceManager &M) {
se = vals.liveDecls.end(); si != se; ++si) {
declVec.push_back(*si);
}
-
- std::sort(declVec.begin(), declVec.end(), compare_vd_entries);
-
+
+ std::sort(declVec.begin(), declVec.end(), [](const Decl *A, const Decl *B) {
+ return A->getLocStart() < B->getLocStart();
+ });
+
for (std::vector<const VarDecl*>::iterator di = declVec.begin(),
de = declVec.end(); di != de; ++di) {
llvm::errs() << " " << (*di)->getDeclName().getAsString()
diff --git a/clang/lib/Analysis/ReachableCode.cpp b/clang/lib/Analysis/ReachableCode.cpp
index 47f8f2b90cd..1e5aa1224ba 100644
--- a/clang/lib/Analysis/ReachableCode.cpp
+++ b/clang/lib/Analysis/ReachableCode.cpp
@@ -400,15 +400,6 @@ const Stmt *DeadCodeScan::findDeadCode(const clang::CFGBlock *Block) {
return 0;
}
-static int SrcCmp(const std::pair<const CFGBlock *, const Stmt *> *p1,
- const std::pair<const CFGBlock *, const Stmt *> *p2) {
- if (p1->second->getLocStart() < p2->second->getLocStart())
- return -1;
- if (p2->second->getLocStart() < p1->second->getLocStart())
- return 1;
- return 0;
-}
-
unsigned DeadCodeScan::scanBackwards(const clang::CFGBlock *Start,
clang::reachable_code::Callback &CB) {
@@ -457,7 +448,13 @@ unsigned DeadCodeScan::scanBackwards(const clang::CFGBlock *Start,
// If we didn't find a dead root, then report the dead code with the
// earliest location.
if (!DeferredLocs.empty()) {
- llvm::array_pod_sort(DeferredLocs.begin(), DeferredLocs.end(), SrcCmp);
+ llvm::array_pod_sort(DeferredLocs.begin(), DeferredLocs.end(),
+ [](const DeferredLocsTy::value_type *p1,
+ const DeferredLocsTy::value_type *p2) {
+ if (p1->second->getLocStart() != p2->second->getLocStart())
+ return p1->second->getLocStart() < p2->second->getLocStart() ? -1 : 1;
+ return 0;
+ });
for (DeferredLocsTy::iterator I = DeferredLocs.begin(),
E = DeferredLocs.end(); I != E; ++I) {
const CFGBlock *Block = I->first;
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index 20d7cd3a8c0..88e3b2212ab 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -678,11 +678,6 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
}
}
-typedef std::pair<const IdentifierInfo *, MacroInfo *> id_macro_pair;
-static int MacroIDCompare(const id_macro_pair *LHS, const id_macro_pair *RHS) {
- return LHS->first->getName().compare(RHS->first->getName());
-}
-
static void DoPrintMacros(Preprocessor &PP, raw_ostream *OS) {
// Ignore unknown pragmas.
PP.AddPragmaHandler(new EmptyPragmaHandler());
@@ -695,13 +690,17 @@ static void DoPrintMacros(Preprocessor &PP, raw_ostream *OS) {
do PP.Lex(Tok);
while (Tok.isNot(tok::eof));
+ typedef std::pair<const IdentifierInfo *, MacroInfo *> id_macro_pair;
SmallVector<id_macro_pair, 128> MacrosByID;
for (Preprocessor::macro_iterator I = PP.macro_begin(), E = PP.macro_end();
I != E; ++I) {
if (I->first->hasMacroDefinition())
MacrosByID.push_back(id_macro_pair(I->first, I->second->getMacroInfo()));
}
- llvm::array_pod_sort(MacrosByID.begin(), MacrosByID.end(), MacroIDCompare);
+ llvm::array_pod_sort(MacrosByID.begin(), MacrosByID.end(),
+ [](const id_macro_pair *LHS, const id_macro_pair *RHS) {
+ return LHS->first->getName().compare(RHS->first->getName());
+ });
for (unsigned i = 0, e = MacrosByID.size(); i != e; ++i) {
MacroInfo &MI = *MacrosByID[i].second;
diff --git a/clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp b/clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
index 51e7a3d3ce3..fbb130bc176 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
@@ -161,11 +161,6 @@ namespace {
class ConfigDumper : public Checker< check::EndOfTranslationUnit > {
typedef AnalyzerOptions::ConfigTable Table;
- static int compareEntry(const Table::MapEntryTy *const *LHS,
- const Table::MapEntryTy *const *RHS) {
- return (*LHS)->getKey().compare((*RHS)->getKey());
- }
-
public:
void checkEndOfTranslationUnit(const TranslationUnitDecl *TU,
AnalysisManager& mgr,
@@ -176,7 +171,11 @@ public:
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);
+ llvm::array_pod_sort(Keys.begin(), Keys.end(),
+ [](const Table::MapEntryTy *const *LHS,
+ const Table::MapEntryTy *const *RHS) {
+ return (*LHS)->getKey().compare((*RHS)->getKey());
+ });
llvm::errs() << "[config]\n";
for (unsigned I = 0, E = Keys.size(); I != E; ++I)
OpenPOWER on IntegriCloud