]> granicus.if.org Git - clang/commitdiff
[clang] Change std::sort to llvm::sort in response to r327219
authorMandeep Singh Grang <mgrang@codeaurora.org>
Tue, 27 Mar 2018 16:50:00 +0000 (16:50 +0000)
committerMandeep Singh Grang <mgrang@codeaurora.org>
Tue, 27 Mar 2018 16:50:00 +0000 (16:50 +0000)
r327219 added wrappers to std::sort which randomly shuffle the container before
sorting.  This will help in uncovering non-determinism caused due to undefined
sorting order of objects having the same key.

To make use of that infrastructure we need to invoke llvm::sort instead of
std::sort.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328636 91177308-0d34-0410-b5e6-96231b3b80d8

37 files changed:
include/clang/Basic/Attr.td
include/clang/Serialization/ContinuousRangeMap.h
lib/AST/ASTContext.cpp
lib/AST/ItaniumMangle.cpp
lib/AST/VTableBuilder.cpp
lib/ASTMatchers/Dynamic/Parser.cpp
lib/Analysis/LiveVariables.cpp
lib/Basic/VirtualFileSystem.cpp
lib/CodeGen/CGVTables.cpp
lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/TargetInfo.cpp
lib/Driver/Driver.cpp
lib/Format/FormatTokenLexer.cpp
lib/Format/WhitespaceManager.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Frontend/DiagnosticRenderer.cpp
lib/Sema/AnalysisBasedWarnings.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclAttr.cpp
lib/Sema/SemaLookup.cpp
lib/Sema/SemaOverload.cpp
lib/Sema/SemaType.cpp
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriter.cpp
lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
lib/StaticAnalyzer/Core/BugReporter.cpp
lib/StaticAnalyzer/Core/CheckerRegistry.cpp
lib/Tooling/ASTDiff/ASTDiff.cpp
lib/Tooling/Core/Replacement.cpp
tools/diagtool/DiagTool.cpp
tools/libclang/CIndex.cpp
unittests/Basic/VirtualFileSystemTest.cpp
utils/TableGen/ClangAttrEmitter.cpp
utils/TableGen/ClangDiagnosticsEmitter.cpp
utils/TableGen/ClangOptionDocEmitter.cpp
utils/TableGen/NeonEmitter.cpp

index ffd60c3c7426bcd79f31aa16c244dad7edd545a0..afbfd04e207546f2b37c7470bb72a7e4e6c23b6d 100644 (file)
@@ -1889,7 +1889,7 @@ def Target : InheritableAttr {
     template<class Compare>
     ParsedTargetAttr parse(Compare cmp) const {
       ParsedTargetAttr Attrs = parse();
-      std::sort(std::begin(Attrs.Features), std::end(Attrs.Features), cmp);
+      llvm::sort(std::begin(Attrs.Features), std::end(Attrs.Features), cmp);
       return Attrs;
     }
 
index 24bfadd0f867716ed8d49ef8ed48ea29d9895cca..5a5093a5c23aaa21a30ccf803cddddf376742c94 100644 (file)
@@ -117,7 +117,7 @@ public:
     Builder &operator=(const Builder&) = delete;
     
     ~Builder() {
-      std::sort(Self.Rep.begin(), Self.Rep.end(), Compare());
+      llvm::sort(Self.Rep.begin(), Self.Rep.end(), Compare());
       std::unique(Self.Rep.begin(), Self.Rep.end(),
                   [](const_reference A, const_reference B) {
         // FIXME: we should not allow any duplicate keys, but there are a lot of
index 1c3495af1fb5d2eb0bf77cb402b3177ad102db02..77c06f21dfbe143426f02e4acb837ebbdbe38c06 100644 (file)
@@ -2186,7 +2186,7 @@ structHasUniqueObjectRepresentations(const ASTContext &Context,
       }
     }
 
-    std::sort(
+    llvm::sort(
         Bases.begin(), Bases.end(), [&](const std::pair<QualType, int64_t> &L,
                                         const std::pair<QualType, int64_t> &R) {
           return Layout.getBaseClassOffset(L.first->getAsCXXRecordDecl()) <
index 3a7b34d271eaff90819615fb931384c58f9e30bf..d42d705d09064270df5466a0cdb2abba37d2ad7c 100644 (file)
@@ -323,7 +323,7 @@ class CXXNameMangler {
                        AdditionalAbiTags->end());
       }
 
-      std::sort(TagList.begin(), TagList.end());
+      llvm::sort(TagList.begin(), TagList.end());
       TagList.erase(std::unique(TagList.begin(), TagList.end()), TagList.end());
 
       writeSortedUniqueAbiTags(Out, TagList);
@@ -339,7 +339,7 @@ class CXXNameMangler {
     }
 
     const AbiTagList &getSortedUniqueUsedAbiTags() {
-      std::sort(UsedAbiTags.begin(), UsedAbiTags.end());
+      llvm::sort(UsedAbiTags.begin(), UsedAbiTags.end());
       UsedAbiTags.erase(std::unique(UsedAbiTags.begin(), UsedAbiTags.end()),
                         UsedAbiTags.end());
       return UsedAbiTags;
index 347c516ef6a5ea1c5bfc5928a2ed3b849b40150f..3e7871e7bd7c9d7a44cbde30a590bf4b3a9d858d 100644 (file)
@@ -2105,8 +2105,8 @@ void ItaniumVTableBuilder::dumpLayout(raw_ostream &Out) {
       const CXXMethodDecl *MD = I.second;
 
       ThunkInfoVectorTy ThunksVector = Thunks[MD];
-      std::sort(ThunksVector.begin(), ThunksVector.end(),
-                [](const ThunkInfo &LHS, const ThunkInfo &RHS) {
+      llvm::sort(ThunksVector.begin(), ThunksVector.end(),
+                 [](const ThunkInfo &LHS, const ThunkInfo &RHS) {
         assert(LHS.Method == nullptr && RHS.Method == nullptr);
         return std::tie(LHS.This, LHS.Return) < std::tie(RHS.This, RHS.Return);
       });
@@ -2206,9 +2206,9 @@ VTableLayout::VTableLayout(ArrayRef<size_t> VTableIndices,
   else
     this->VTableIndices = OwningArrayRef<size_t>(VTableIndices);
 
-  std::sort(this->VTableThunks.begin(), this->VTableThunks.end(),
-            [](const VTableLayout::VTableThunkTy &LHS,
-               const VTableLayout::VTableThunkTy &RHS) {
+  llvm::sort(this->VTableThunks.begin(), this->VTableThunks.end(),
+             [](const VTableLayout::VTableThunkTy &LHS,
+                const VTableLayout::VTableThunkTy &RHS) {
               assert((LHS.first != RHS.first || LHS.second == RHS.second) &&
                      "Different thunks should have unique indices!");
               return LHS.first < RHS.first;
@@ -3344,8 +3344,8 @@ static bool rebucketPaths(VPtrInfoVector &Paths) {
   PathsSorted.reserve(Paths.size());
   for (auto& P : Paths)
     PathsSorted.push_back(*P);
-  std::sort(PathsSorted.begin(), PathsSorted.end(),
-            [](const VPtrInfo &LHS, const VPtrInfo &RHS) {
+  llvm::sort(PathsSorted.begin(), PathsSorted.end(),
+             [](const VPtrInfo &LHS, const VPtrInfo &RHS) {
     return LHS.MangledPath < RHS.MangledPath;
   });
   bool Changed = false;
index 89e1a2695860c7896bca18a5e8b13c712a7fc316..8b7448cbd05aa401e605c046aacf151041bbf7ac 100644 (file)
@@ -619,8 +619,8 @@ Parser::completeExpression(StringRef Code, unsigned CompletionOffset, Sema *S,
   P.parseExpressionImpl(&Dummy);
 
   // Sort by specificity, then by name.
-  std::sort(P.Completions.begin(), P.Completions.end(),
-            [](const MatcherCompletion &A, const MatcherCompletion &B) {
+  llvm::sort(P.Completions.begin(), P.Completions.end(),
+             [](const MatcherCompletion &A, const MatcherCompletion &B) {
     if (A.Specificity != B.Specificity)
       return A.Specificity > B.Specificity;
     return A.TypedText < B.TypedText;
index 4752c2b020aeaab8c57a050ea363bf614c933dfe..f557a74af00c880111cca7b2ebd3828fd2824a13 100644 (file)
@@ -563,7 +563,7 @@ void LiveVariablesImpl::dumpBlockLiveness(const SourceManager &M) {
        it != ei; ++it) {
     vec.push_back(it->first);    
   }
-  std::sort(vec.begin(), vec.end(), [](const CFGBlock *A, const CFGBlock *B) {
+  llvm::sort(vec.begin(), vec.end(), [](const CFGBlock *A, const CFGBlock *B) {
     return A->getBlockID() < B->getBlockID();
   });
 
@@ -583,7 +583,8 @@ void LiveVariablesImpl::dumpBlockLiveness(const SourceManager &M) {
       declVec.push_back(*si);      
     }
 
-    std::sort(declVec.begin(), declVec.end(), [](const Decl *A, const Decl *B) {
+    llvm::sort(declVec.begin(), declVec.end(),
+               [](const Decl *A, const Decl *B) {
       return A->getLocStart() < B->getLocStart();
     });
 
index 9d44597dc3fbb188b87dbff57d0ad19e3ae60907..e95b32a22d7c01221ca291373a18cf07cef6e7ac 100644 (file)
@@ -1812,8 +1812,8 @@ void JSONWriter::write(ArrayRef<YAMLVFSEntry> Entries,
 }
 
 void YAMLVFSWriter::write(llvm::raw_ostream &OS) {
-  std::sort(Mappings.begin(), Mappings.end(),
-            [](const YAMLVFSEntry &LHS, const YAMLVFSEntry &RHS) {
+  llvm::sort(Mappings.begin(), Mappings.end(),
+             [](const YAMLVFSEntry &LHS, const YAMLVFSEntry &RHS) {
     return LHS.VPath < RHS.VPath;
   });
 
index 4fb749fbde5b7d797e8b10d3cd1aa105d291f71f..d898417bd91d66f8158b41e818cc53cf3435b4a6 100644 (file)
@@ -992,8 +992,8 @@ void CodeGenModule::EmitVTableTypeMetadata(llvm::GlobalVariable *VTable,
                            AP.second.AddressPointIndex));
 
   // Sort the bit set entries for determinism.
-  std::sort(BitsetEntries.begin(), BitsetEntries.end(),
-            [this](const BSEntry &E1, const BSEntry &E2) {
+  llvm::sort(BitsetEntries.begin(), BitsetEntries.end(),
+             [this](const BSEntry &E1, const BSEntry &E2) {
     if (&E1 == &E2)
       return false;
 
index 2748dc342269abb80f86fe3b8c38030ba6212b4e..e1cb3242021d6d464fc541e7d1d3701e5834de9f 100644 (file)
@@ -1294,7 +1294,7 @@ bool CodeGenModule::GetCPUAndFeaturesAttributes(const Decl *D,
     AddedAttr = true;
   }
   if (!Features.empty()) {
-    std::sort(Features.begin(), Features.end());
+    llvm::sort(Features.begin(), Features.end());
     Attrs.addAttribute("target-features", llvm::join(Features, ","));
     AddedAttr = true;
   }
index 466253cc2dbdcba1d78e65b691549160dcb10207..45c0ec41e0eb8dafe0f9a875a6fe98f4ffdade72 100644 (file)
@@ -8513,7 +8513,7 @@ static bool appendRecordType(SmallStringEnc &Enc, const RecordType *RT,
     // The ABI requires unions to be sorted but not structures.
     // See FieldEncoding::operator< for sort algorithm.
     if (RT->isUnionType())
-      std::sort(FE.begin(), FE.end());
+      llvm::sort(FE.begin(), FE.end());
     // We can now complete the TypeString.
     unsigned E = FE.size();
     for (unsigned I = 0; I != E; ++I) {
@@ -8557,7 +8557,7 @@ static bool appendEnumType(SmallStringEnc &Enc, const EnumType *ET,
       EnumEnc += '}';
       FE.push_back(FieldEncoding(!I->getName().empty(), EnumEnc));
     }
-    std::sort(FE.begin(), FE.end());
+    llvm::sort(FE.begin(), FE.end());
     unsigned E = FE.size();
     for (unsigned I = 0; I != E; ++I) {
       if (I)
index ad65f6f61e5e3cc0d2332253a7b9285e3eb1a5b7..92fb8f0388a20927fa6e13f2d6eb76d2436c7d57 100644 (file)
@@ -1474,11 +1474,11 @@ void Driver::HandleAutocompletions(StringRef PassedFlags) const {
   // deterministic order. We could sort in any way, but we chose
   // case-insensitive sorting for consistency with the -help option
   // which prints out options in the case-insensitive alphabetical order.
-  std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
-            [](StringRef A, StringRef B) {
-              if (int X = A.compare_lower(B))
-                return X < 0;
-              return A.compare(B) > 0;
+  llvm::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
+             [](StringRef A, StringRef B) {
+               if (int X = A.compare_lower(B))
+                 return X < 0;
+               return A.compare(B) > 0;
             });
 
   llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n';
index 284a3a2b92bb9f5fe382e3f2da388d6cc586a230..e06e26f8bc17c298241f409019ccab7292ed0c58 100644 (file)
@@ -38,7 +38,7 @@ FormatTokenLexer::FormatTokenLexer(const SourceManager &SourceMgr, FileID ID,
 
   for (const std::string &ForEachMacro : Style.ForEachMacros)
     ForEachMacros.push_back(&IdentTable.get(ForEachMacro));
-  std::sort(ForEachMacros.begin(), ForEachMacros.end());
+  llvm::sort(ForEachMacros.begin(), ForEachMacros.end());
 }
 
 ArrayRef<FormatToken *> FormatTokenLexer::lex() {
index a5477a996327b6de01a2335a659dae08572c5a77..5c54080dd0d1fdaba83b248ec0c14a6d1eb2b96c 100644 (file)
@@ -90,7 +90,7 @@ const tooling::Replacements &WhitespaceManager::generateReplacements() {
   if (Changes.empty())
     return Replaces;
 
-  std::sort(Changes.begin(), Changes.end(), Change::IsBeforeInFile(SourceMgr));
+  llvm::sort(Changes.begin(), Changes.end(), Change::IsBeforeInFile(SourceMgr));
   calculateLineBreakInformation();
   alignConsecutiveDeclarations();
   alignConsecutiveAssignments();
index 84ab9239f80bd69fb4e95ae56a89368ad6aa8223..d8bd500cde0f988b1f22bf4e3cd7b8e3b8b0142d 100644 (file)
@@ -1278,7 +1278,7 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
     Success = false;
   }
   else
-    std::sort(Opts.VerifyPrefixes.begin(), Opts.VerifyPrefixes.end());
+    llvm::sort(Opts.VerifyPrefixes.begin(), Opts.VerifyPrefixes.end());
   DiagnosticLevelMask DiagMask = DiagnosticLevelMask::None;
   Success &= parseDiagnosticLevelMask("-verify-ignore-unexpected=",
     Args.getAllArgValues(OPT_verify_ignore_unexpected_EQ),
@@ -2409,7 +2409,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   Opts.CurrentModule = Opts.ModuleName;
   Opts.AppExt = Args.hasArg(OPT_fapplication_extension);
   Opts.ModuleFeatures = Args.getAllArgValues(OPT_fmodule_feature);
-  std::sort(Opts.ModuleFeatures.begin(), Opts.ModuleFeatures.end());
+  llvm::sort(Opts.ModuleFeatures.begin(), Opts.ModuleFeatures.end());
   Opts.NativeHalfType |= Args.hasArg(OPT_fnative_half_type);
   Opts.NativeHalfArgsAndReturns |= Args.hasArg(OPT_fnative_half_arguments_and_returns);
   // Enable HalfArgsAndReturns if present in Args or if NativeHalfArgsAndReturns
index df426af84a4b8b8201146805080e99c7e37a905d..b6c9564f64eaa8922817359455f5c1109afed64b 100644 (file)
@@ -324,8 +324,8 @@ static void computeCommonMacroArgExpansionFileIDs(
   SmallVector<FileID, 4> EndArgExpansions;
   getMacroArgExpansionFileIDs(Begin, BeginArgExpansions, /*IsBegin=*/true, SM);
   getMacroArgExpansionFileIDs(End, EndArgExpansions, /*IsBegin=*/false, SM);
-  std::sort(BeginArgExpansions.begin(), BeginArgExpansions.end());
-  std::sort(EndArgExpansions.begin(), EndArgExpansions.end());
+  llvm::sort(BeginArgExpansions.begin(), BeginArgExpansions.end());
+  llvm::sort(EndArgExpansions.begin(), EndArgExpansions.end());
   std::set_intersection(BeginArgExpansions.begin(), BeginArgExpansions.end(),
                         EndArgExpansions.begin(), EndArgExpansions.end(),
                         std::back_inserter(CommonArgExpansions));
index 4a8540ae582036707f6bd478d9fccf05eb57e6f7..8397a1f936b89b6ba90b9055182a2d58ec21a45f 100644 (file)
@@ -1388,8 +1388,8 @@ static void diagnoseRepeatedUseOfWeak(Sema &S,
 
   // Sort by first use so that we emit the warnings in a deterministic order.
   SourceManager &SM = S.getSourceManager();
-  std::sort(UsesByStmt.begin(), UsesByStmt.end(),
-            [&SM](const StmtUsesPair &LHS, const StmtUsesPair &RHS) {
+  llvm::sort(UsesByStmt.begin(), UsesByStmt.end(),
+             [&SM](const StmtUsesPair &LHS, const StmtUsesPair &RHS) {
     return SM.isBeforeInTranslationUnit(LHS.first->getLocStart(),
                                         RHS.first->getLocStart());
   });
@@ -1527,8 +1527,8 @@ public:
         // Sort the uses by their SourceLocations.  While not strictly
         // guaranteed to produce them in line/column order, this will provide
         // a stable ordering.
-        std::sort(vec->begin(), vec->end(),
-                  [](const UninitUse &a, const UninitUse &b) {
+        llvm::sort(vec->begin(), vec->end(),
+                   [](const UninitUse &a, const UninitUse &b) {
           // Prefer a more confident report over a less confident one.
           if (a.getKind() != b.getKind())
             return a.getKind() > b.getKind();
index 9f1633339601f960a87417e500f42878f10ad8dd..68ad1cd78f5aeae3c474912e292fdf56070cd8c0 100644 (file)
@@ -9375,7 +9375,7 @@ static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD,
 
   TargetAttr::ParsedTargetAttr NewParsed = NewTA->parse();
   // Sort order doesn't matter, it just needs to be consistent.
-  std::sort(NewParsed.Features.begin(), NewParsed.Features.end());
+  llvm::sort(NewParsed.Features.begin(), NewParsed.Features.end());
 
   const auto *OldTA = OldFD->getAttr<TargetAttr>();
   if (!OldFD->isMultiVersion()) {
index 260dfa5b18058a256050de9eb3e64db41f4efcd2..512a3df0744f011c965bb08f70cbff1d60587dfd 100644 (file)
@@ -5051,7 +5051,7 @@ static void handleAbiTagAttr(Sema &S, Decl *D, const AttributeList &AL) {
     return;
 
   // Store tags sorted and without duplicates.
-  std::sort(Tags.begin(), Tags.end());
+  llvm::sort(Tags.begin(), Tags.end());
   Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
 
   D->addAttr(::new (S.Context)
index 692ce111aac3b4ce035dbc755c7790d090b4f695..05bf303c98c774812f3996188ba5505193808da2 100644 (file)
@@ -187,7 +187,7 @@ namespace {
     }
 
     void done() {
-      std::sort(list.begin(), list.end(), UnqualUsingEntry::Comparator());
+      llvm::sort(list.begin(), list.end(), UnqualUsingEntry::Comparator());
     }
 
     typedef ListTy::const_iterator const_iterator;
index ae29e7e20aebe0183dcd4219655a1ecc16a263ea..dea1c2efe9dff9703ced2f51550f56a03a7db2ea 100644 (file)
@@ -10688,8 +10688,8 @@ void TemplateSpecCandidateSet::NoteCandidates(Sema &S, SourceLocation Loc) {
     // in general, want to list every possible builtin candidate.
   }
 
-  std::sort(Cands.begin(), Cands.end(),
-            CompareTemplateSpecCandidatesForDisplay(S));
+  llvm::sort(Cands.begin(), Cands.end(),
+             CompareTemplateSpecCandidatesForDisplay(S));
 
   // FIXME: Perhaps rename OverloadsShown and getShowOverloads()
   // for generalization purposes (?).
index acf22cda0f03abc6609440e4131c1cca9bdc23f9..00bb21ff307fafb7a1c171845e5e8204bc5e386a 100644 (file)
@@ -4861,8 +4861,8 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
         if (Chunk.Fun.TypeQuals & Qualifiers::Restrict)
           RemovalLocs.push_back(Chunk.Fun.getRestrictQualifierLoc());
         if (!RemovalLocs.empty()) {
-          std::sort(RemovalLocs.begin(), RemovalLocs.end(),
-                    BeforeThanCompare<SourceLocation>(S.getSourceManager()));
+          llvm::sort(RemovalLocs.begin(), RemovalLocs.end(),
+                     BeforeThanCompare<SourceLocation>(S.getSourceManager()));
           RemovalRange = SourceRange(RemovalLocs.front(), RemovalLocs.back());
           Loc = RemovalLocs.front();
         }
index 4cc3f9cb86aa2096e50b2d3ad111d5f65e4239c0..d77760dbe80740a44712448b671e600dd369d8f1 100644 (file)
@@ -396,8 +396,8 @@ static bool checkTargetOptions(const TargetOptions &TargetOpts,
                                              ExistingTargetOpts.FeaturesAsWritten.end());
   SmallVector<StringRef, 4> ReadFeatures(TargetOpts.FeaturesAsWritten.begin(),
                                          TargetOpts.FeaturesAsWritten.end());
-  std::sort(ExistingFeatures.begin(), ExistingFeatures.end());
-  std::sort(ReadFeatures.begin(), ReadFeatures.end());
+  llvm::sort(ExistingFeatures.begin(), ExistingFeatures.end());
+  llvm::sort(ReadFeatures.begin(), ReadFeatures.end());
 
   // We compute the set difference in both directions explicitly so that we can
   // diagnose the differences differently.
@@ -9078,8 +9078,8 @@ void ASTReader::ReadComments() {
   NextCursor:
     // De-serialized SourceLocations get negative FileIDs for other modules,
     // potentially invalidating the original order. Sort it again.
-    std::sort(Comments.begin(), Comments.end(),
-              BeforeThanCompare<RawComment>(SourceMgr));
+    llvm::sort(Comments.begin(), Comments.end(),
+               BeforeThanCompare<RawComment>(SourceMgr));
     Context.Comments.addDeserializedComments(Comments);
   }
 }
index 360265b5ad5531cb3ea38ba914938fdba2d91d5a..a90e8657a7d9ea5ba2f3db6e3e4321613aceaa68 100644 (file)
@@ -232,7 +232,7 @@ namespace clang {
 
       if (auto &Old = LazySpecializations) {
         IDs.insert(IDs.end(), Old + 1, Old + 1 + Old[0]);
-        std::sort(IDs.begin(), IDs.end());
+        llvm::sort(IDs.begin(), IDs.end());
         IDs.erase(std::unique(IDs.begin(), IDs.end()), IDs.end());
       }
 
index a6412ed470ad573812b47d79f3578334d701e530..f2d20ddf3a305322d12d27c3f0d64eec0ec90ecc 100644 (file)
@@ -2483,8 +2483,8 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
       MacroIdentifiers.push_back(Id.second);
   // Sort the set of macro definitions that need to be serialized by the
   // name of the macro, to provide a stable ordering.
-  std::sort(MacroIdentifiers.begin(), MacroIdentifiers.end(),
-            llvm::less_ptr<IdentifierInfo>());
+  llvm::sort(MacroIdentifiers.begin(), MacroIdentifiers.end(),
+             llvm::less_ptr<IdentifierInfo>());
 
   // Emit the macro directives as a list and associate the offset with the
   // identifier they belong to.
@@ -3216,8 +3216,8 @@ void ASTWriter::WriteFileDeclIDsMap() {
 
   SmallVector<std::pair<FileID, DeclIDInFileInfo *>, 64> SortedFileDeclIDs(
       FileDeclIDs.begin(), FileDeclIDs.end());
-  std::sort(SortedFileDeclIDs.begin(), SortedFileDeclIDs.end(),
-            llvm::less_first());
+  llvm::sort(SortedFileDeclIDs.begin(), SortedFileDeclIDs.end(),
+             llvm::less_first());
 
   // Join the vectors of DeclIDs from all files.
   SmallVector<DeclID, 256> FileGroupedDeclIDs;
@@ -3721,7 +3721,7 @@ void ASTWriter::WriteIdentifierTable(Preprocessor &PP,
       IIs.push_back(ID.second);
     // Sort the identifiers lexicographically before getting them references so
     // that their order is stable.
-    std::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());
+    llvm::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());
     for (const IdentifierInfo *II : IIs)
       if (Trait.isInterestingNonMacroIdentifier(II))
         getIdentifierRef(II);
@@ -4019,7 +4019,7 @@ ASTWriter::GenerateNameLookupTable(const DeclContext *ConstDC,
   }
 
   // Sort the names into a stable order.
-  std::sort(Names.begin(), Names.end());
+  llvm::sort(Names.begin(), Names.end());
 
   if (auto *D = dyn_cast<CXXRecordDecl>(DC)) {
     // We need to establish an ordering of constructor and conversion function
@@ -4156,7 +4156,7 @@ uint64_t ASTWriter::WriteDeclContextVisibleBlock(ASTContext &Context,
             std::make_pair(Entry.first, Entry.second.getLookupResult()));
     }
 
-    std::sort(LookupResults.begin(), LookupResults.end(), llvm::less_first());
+    llvm::sort(LookupResults.begin(), LookupResults.end(), llvm::less_first());
     for (auto &NameAndResult : LookupResults) {
       DeclarationName Name = NameAndResult.first;
       DeclContext::lookup_result Result = NameAndResult.second;
@@ -4852,7 +4852,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
         IIs.push_back(II);
     }
     // Sort the identifiers to visit based on their name.
-    std::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());
+    llvm::sort(IIs.begin(), IIs.end(), llvm::less_ptr<IdentifierInfo>());
     for (const IdentifierInfo *II : IIs) {
       for (IdentifierResolver::iterator D = SemaRef.IdResolver.begin(II),
                                      DEnd = SemaRef.IdResolver.end();
@@ -5089,7 +5089,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
       };
 
       // Sort and deduplicate module IDs.
-      std::sort(Imports.begin(), Imports.end(), Cmp);
+      llvm::sort(Imports.begin(), Imports.end(), Cmp);
       Imports.erase(std::unique(Imports.begin(), Imports.end(), Eq),
                     Imports.end());
 
index b17cd8d37358414a47472bbd5d802b417ebdf389..295763027ecfb2ffc7454077406896a4259d3774 100644 (file)
@@ -237,7 +237,7 @@ public:
     };\r
     std::transform(RD->field_begin(), RD->field_end(),\r
                    std::back_inserter(Fields), GatherSizesAndAlignments);\r
-    std::sort(Fields.begin(), Fields.end());\r
+    llvm::sort(Fields.begin(), Fields.end());\r
     // This lets us skip over vptrs and non-virtual bases,\r
     // so that we can just worry about the fields in our object.\r
     // Note that this does cause us to miss some cases where we\r
index dc9554a2dbd50668c5dbb442c14367a1b501d35e..376bca8cf1127d093c6fb6ef6f2b0d4ffdd5dfe4 100644 (file)
@@ -2947,8 +2947,8 @@ TrimmedGraph::TrimmedGraph(const ExplodedGraph *OriginalGraph,
   }
 
   // Sort the error paths from longest to shortest.
-  std::sort(ReportNodes.begin(), ReportNodes.end(),
-            PriorityCompare<true>(PriorityMap));
+  llvm::sort(ReportNodes.begin(), ReportNodes.end(),
+             PriorityCompare<true>(PriorityMap));
 }
 
 bool TrimmedGraph::popNextReportGraph(ReportGraph &GraphWrapper) {
index c9cb189a5b7294ad03d851d53532ecf407f799e5..6437f9ca6dbd965ea95cece961464dd20d254bfb 100644 (file)
@@ -97,7 +97,7 @@ void CheckerRegistry::addChecker(InitializationFunction fn, StringRef name,
 void CheckerRegistry::initializeManager(CheckerManager &checkerMgr,
                                   SmallVectorImpl<CheckerOptInfo> &opts) const {
   // Sort checkers for efficient collection.
-  std::sort(Checkers.begin(), Checkers.end(), checkerNameLT);
+  llvm::sort(Checkers.begin(), Checkers.end(), checkerNameLT);
 
   // Collect checkers enabled by the options.
   CheckerInfoSet enabledCheckers;
@@ -141,7 +141,7 @@ void CheckerRegistry::printHelp(raw_ostream &out,
   // FIXME: Alphabetical sort puts 'experimental' in the middle.
   // Would it be better to name it '~experimental' or something else
   // that's ASCIIbetically last?
-  std::sort(Checkers.begin(), Checkers.end(), checkerNameLT);
+  llvm::sort(Checkers.begin(), Checkers.end(), checkerNameLT);
 
   // FIXME: Print available packages.
 
@@ -178,7 +178,7 @@ void CheckerRegistry::printHelp(raw_ostream &out,
 
 void CheckerRegistry::printList(
     raw_ostream &out, SmallVectorImpl<CheckerOptInfo> &opts) const {
-  std::sort(Checkers.begin(), Checkers.end(), checkerNameLT);
+  llvm::sort(Checkers.begin(), Checkers.end(), checkerNameLT);
 
   // Collect checkers enabled by the options.
   CheckerInfoSet enabledCheckers;
index 6da0de7edf9a23d5f8b2c2bf0c21ab046133a11f..a58ac55bd0cdf34d70f98be422f6b10534a95068 100644 (file)
@@ -741,7 +741,7 @@ public:
       List.pop();
     }
     // TODO this is here to get a stable output, not a good heuristic
-    std::sort(Result.begin(), Result.end());
+    llvm::sort(Result.begin(), Result.end());
     return Result;
   }
   int peekMax() const {
index 54b7ca8fafe4941a670bc4030525fad1692f2e05..d13a2765fd77d85b8c0aa658956276853ec3c6dc 100644 (file)
@@ -483,11 +483,11 @@ Replacements Replacements::merge(const Replacements &ReplacesToMerge) const {
 // Returns a set of non-overlapping and sorted ranges that is equivalent to
 // \p Ranges.
 static std::vector<Range> combineAndSortRanges(std::vector<Range> Ranges) {
-  std::sort(Ranges.begin(), Ranges.end(),
-            [](const Range &LHS, const Range &RHS) {
-              if (LHS.getOffset() != RHS.getOffset())
-                return LHS.getOffset() < RHS.getOffset();
-              return LHS.getLength() < RHS.getLength();
+  llvm::sort(Ranges.begin(), Ranges.end(),
+             [](const Range &LHS, const Range &RHS) {
+               if (LHS.getOffset() != RHS.getOffset())
+                 return LHS.getOffset() < RHS.getOffset();
+               return LHS.getLength() < RHS.getLength();
             });
   std::vector<Range> Result;
   for (const auto &R : Ranges) {
index 7582d51ae4f585dee6d5670c6207103aaf5ef520..d9086af8e989327ee1ba5a8e38d5edf768a7cf68 100644 (file)
@@ -48,7 +48,7 @@ void DiagTools::printCommands(llvm::raw_ostream &out) {
     if (len > maxName)
       maxName = len;    
   }
-  std::sort(toolNames.begin(), toolNames.end());
+  llvm::sort(toolNames.begin(), toolNames.end());
 
   for (std::vector<llvm::StringRef>::iterator it = toolNames.begin(),
        ei = toolNames.end(); it != ei; ++it) {
index 791b475975437a42a516e4564aef75f8dcf5344e..d7f27d196cc3b4220058e818891caeaf5fe90bab 100644 (file)
@@ -1039,8 +1039,8 @@ bool CursorVisitor::VisitObjCContainerDecl(ObjCContainerDecl *D) {
   }
 
   // Now sort the Decls so that they appear in lexical order.
-  std::sort(DeclsInContainer.begin(), DeclsInContainer.end(),
-            [&SM](Decl *A, Decl *B) {
+  llvm::sort(DeclsInContainer.begin(), DeclsInContainer.end(),
+             [&SM](Decl *A, Decl *B) {
     SourceLocation L_A = A->getLocStart();
     SourceLocation L_B = B->getLocStart();
     return L_A != L_B ?
@@ -7573,10 +7573,10 @@ static void getCursorPlatformAvailabilityForDecl(
   if (AvailabilityAttrs.empty())
     return;
 
-  std::sort(AvailabilityAttrs.begin(), AvailabilityAttrs.end(),
-            [](AvailabilityAttr *LHS, AvailabilityAttr *RHS) {
-              return LHS->getPlatform()->getName() <
-                     RHS->getPlatform()->getName();
+  llvm::sort(AvailabilityAttrs.begin(), AvailabilityAttrs.end(),
+             [](AvailabilityAttr *LHS, AvailabilityAttr *RHS) {
+               return LHS->getPlatform()->getName() <
+                      RHS->getPlatform()->getName();
             });
   ASTContext &Ctx = D->getASTContext();
   auto It = std::unique(
index f9efbeaee565bd2bb84556c120307101cf970525..13c246ecc53e82e257e550338ff4f2e43d7dd380 100644 (file)
@@ -471,7 +471,7 @@ TEST(VirtualFileSystemTest, BrokenSymlinkRealFSRecursiveIteration) {
   }
 
   // Check sorted contents.
-  std::sort(Contents.begin(), Contents.end());
+  llvm::sort(Contents.begin(), Contents.end());
   EXPECT_EQ(Expected.size(), Contents.size());
   EXPECT_TRUE(std::equal(Contents.begin(), Contents.end(), Expected.begin()));
 }
@@ -488,8 +488,8 @@ static void checkContents(DirIter I, ArrayRef<StringRef> ExpectedOut) {
   for (DirIter E; !EC && I != E; I.increment(EC))
     InputToCheck.push_back(I->getName());
 
-  std::sort(InputToCheck.begin(), InputToCheck.end());
-  std::sort(Expected.begin(), Expected.end());
+  llvm::sort(InputToCheck.begin(), InputToCheck.end());
+  llvm::sort(Expected.begin(), Expected.end());
   EXPECT_EQ(InputToCheck.size(), Expected.size());
 
   unsigned LastElt = std::min(InputToCheck.size(), Expected.size());
index 4f4f94bf3755f6a1de43e88dbc1e6bdf63492d2a..0f8bb18f396a122a5d340b6e6c5a5ba53f85c916 100644 (file)
@@ -3908,9 +3908,9 @@ void EmitClangAttrDocs(RecordKeeper &Records, raw_ostream &OS) {
   for (auto &I : SplitDocs) {
     WriteCategoryHeader(I.first, OS);
 
-    std::sort(I.second.begin(), I.second.end(),
-              [](const DocumentationData &D1, const DocumentationData &D2) {
-                return D1.Heading < D2.Heading;
+    llvm::sort(I.second.begin(), I.second.end(),
+               [](const DocumentationData &D1, const DocumentationData &D2) {
+                 return D1.Heading < D2.Heading;
               });
 
     // Walk over each of the attributes in the category and write out their
index 4a2516ff944bc85f475d5e1581a33b6ce99e51d9..a8a56df75e020ee2b24650d475bc6bb9c4f75541 100644 (file)
@@ -207,9 +207,9 @@ static void groupDiagnostics(const std::vector<Record*> &Diags,
                                               E = SortedGroups.end();
        I != E; ++I) {
     MutableArrayRef<const Record *> GroupDiags = (*I)->DiagsInGroup;
-    std::sort(GroupDiags.begin(), GroupDiags.end(), beforeThanCompare);
+    llvm::sort(GroupDiags.begin(), GroupDiags.end(), beforeThanCompare);
   }
-  std::sort(SortedGroups.begin(), SortedGroups.end(), beforeThanCompareGroups);
+  llvm::sort(SortedGroups.begin(), SortedGroups.end(), beforeThanCompareGroups);
 
   // Warn about the same group being used anonymously in multiple places.
   for (SmallVectorImpl<GroupInfo *>::const_iterator I = SortedGroups.begin(),
@@ -863,9 +863,10 @@ void EmitClangDiagsIndexName(RecordKeeper &Records, raw_ostream &OS) {
     Index.push_back(RecordIndexElement(R));
   }
 
-  std::sort(Index.begin(), Index.end(),
-            [](const RecordIndexElement &Lhs,
-               const RecordIndexElement &Rhs) { return Lhs.Name < Rhs.Name; });
+  llvm::sort(Index.begin(), Index.end(),
+             [](const RecordIndexElement &Lhs, const RecordIndexElement &Rhs) {
+               return Lhs.Name < Rhs.Name;
+            });
 
   for (unsigned i = 0, e = Index.size(); i != e; ++i) {
     const RecordIndexElement &R = Index[i];
@@ -1212,7 +1213,7 @@ void EmitClangDiagDocs(RecordKeeper &Records, raw_ostream &OS) {
       Records.getAllDerivedDefinitions("Diagnostic");
   std::vector<Record*> DiagGroups =
       Records.getAllDerivedDefinitions("DiagGroup");
-  std::sort(DiagGroups.begin(), DiagGroups.end(), diagGroupBeforeByName);
+  llvm::sort(DiagGroups.begin(), DiagGroups.end(), diagGroupBeforeByName);
 
   DiagGroupParentMap DGParentMap(Records);
 
@@ -1231,10 +1232,10 @@ void EmitClangDiagDocs(RecordKeeper &Records, raw_ostream &OS) {
                               DiagsInPedanticSet.end());
     RecordVec GroupsInPedantic(GroupsInPedanticSet.begin(),
                                GroupsInPedanticSet.end());
-    std::sort(DiagsInPedantic.begin(), DiagsInPedantic.end(),
-              beforeThanCompare);
-    std::sort(GroupsInPedantic.begin(), GroupsInPedantic.end(),
-              beforeThanCompare);
+    llvm::sort(DiagsInPedantic.begin(), DiagsInPedantic.end(),
+               beforeThanCompare);
+    llvm::sort(GroupsInPedantic.begin(), GroupsInPedantic.end(),
+               beforeThanCompare);
     PedDiags.DiagsInGroup.insert(PedDiags.DiagsInGroup.end(),
                                  DiagsInPedantic.begin(),
                                  DiagsInPedantic.end());
@@ -1283,7 +1284,7 @@ void EmitClangDiagDocs(RecordKeeper &Records, raw_ostream &OS) {
         OS << "Also controls ";
 
       bool First = true;
-      std::sort(GroupInfo.SubGroups.begin(), GroupInfo.SubGroups.end());
+      llvm::sort(GroupInfo.SubGroups.begin(), GroupInfo.SubGroups.end());
       for (const auto &Name : GroupInfo.SubGroups) {
         if (!First) OS << ", ";
         OS << "`" << (IsRemarkGroup ? "-R" : "-W") << Name << "`_";
index 734ff0bfd8459ccaeff4802b7d98a3bfb833be09..7fe487e546983461123540e75f09eed1d58dc4e6 100644 (file)
@@ -111,7 +111,7 @@ Documentation extractDocumentation(RecordKeeper &Records) {
 
   auto DocumentationForOption = [&](Record *R) -> DocumentedOption {
     auto &A = Aliases[R];
-    std::sort(A.begin(), A.end(), CompareByName);
+    llvm::sort(A.begin(), A.end(), CompareByName);
     return {R, std::move(A)};
   };
 
@@ -120,7 +120,7 @@ Documentation extractDocumentation(RecordKeeper &Records) {
     Documentation D;
 
     auto &Groups = GroupsInGroup[R];
-    std::sort(Groups.begin(), Groups.end(), CompareByLocation);
+    llvm::sort(Groups.begin(), Groups.end(), CompareByLocation);
     for (Record *G : Groups) {
       D.Groups.emplace_back();
       D.Groups.back().Group = G;
@@ -129,7 +129,7 @@ Documentation extractDocumentation(RecordKeeper &Records) {
     }
 
     auto &Options = OptionsInGroup[R];
-    std::sort(Options.begin(), Options.end(), CompareByName);
+    llvm::sort(Options.begin(), Options.end(), CompareByName);
     for (Record *O : Options)
       D.Options.push_back(DocumentationForOption(O));
 
index 1a95ca4c66a3a1987c16c9e9ddb00094548bd948..b9f022492e85bd4440127ea23a78fd96fc181d28 100644 (file)
@@ -2007,7 +2007,7 @@ void NeonEmitter::createIntrinsic(Record *R,
     }
   }
 
-  std::sort(NewTypeSpecs.begin(), NewTypeSpecs.end());
+  llvm::sort(NewTypeSpecs.begin(), NewTypeSpecs.end());
   NewTypeSpecs.erase(std::unique(NewTypeSpecs.begin(), NewTypeSpecs.end()),
                     NewTypeSpecs.end());
   auto &Entry = IntrinsicMap[Name];