C.clear();
}
+/// Provide wrappers to std::for_each which take ranges instead of having to\r
+/// pass begin/end explicitly.\r
+template <typename R, typename UnaryPredicate>\r
+UnaryPredicate for_each(R &&Range, UnaryPredicate P) {\r
+ return std::for_each(std::begin(Range), std::end(Range), P);\r
+}\r
+
/// Provide wrappers to std::all_of which take ranges instead of having to pass
/// begin/end explicitly.
template <typename R, typename UnaryPredicate>
if (I == ExternalSymbols.end())
return;
- GV.setLinkage(I->second);
- };
-
- std::for_each(MergedModule->begin(), MergedModule->end(), externalize);
- std::for_each(MergedModule->global_begin(), MergedModule->global_end(),
- externalize);
- std::for_each(MergedModule->alias_begin(), MergedModule->alias_end(),
- externalize);
-}
-
-void LTOCodeGenerator::verifyMergedModuleOnce() {
+ GV.setLinkage(I->second);\r
+ };\r
+\r
+ llvm::for_each(MergedModule->functions(), externalize);\r
+ llvm::for_each(MergedModule->globals(), externalize);\r
+ llvm::for_each(MergedModule->aliases(), externalize);\r
+}\r
+\r
+void LTOCodeGenerator::verifyMergedModuleOnce() {\r
// Only run on the first call.
if (HasVerifiedInput)
return;
findValueToReuse();
if (ReuseCandidate.isDefined()) {
reuseValue();
- Changed = true;
- Continue = true;
- }
- std::for_each(Dependences.begin(), Dependences.end(),
- std::default_delete<DepChain>());
- } while (Continue);
- return Changed;
-}
+ Changed = true;\r
+ Continue = true;\r
+ }\r
+ llvm::for_each(Dependences, std::default_delete<DepChain>());\r
+ } while (Continue);\r
+ return Changed;\r
+}\r
void HexagonVectorLoopCarriedReuse::findDepChainFromPHI(Instruction *I,
DepChain &D) {
}
if (GV.hasLocalLinkage())
- addAllGlobalValueUsers(GVtoClusterMap, &GV, &GV);
- };
-
- std::for_each(M->begin(), M->end(), recordGVSet);
- std::for_each(M->global_begin(), M->global_end(), recordGVSet);
- std::for_each(M->alias_begin(), M->alias_end(), recordGVSet);
-
- // Assigned all GVs to merged clusters while balancing number of objects in
- // each.
+ addAllGlobalValueUsers(GVtoClusterMap, &GV, &GV);\r
+ };\r
+\r
+ llvm::for_each(M->functions(), recordGVSet);\r
+ llvm::for_each(M->globals(), recordGVSet);\r
+ llvm::for_each(M->aliases(), recordGVSet);\r
+\r
+ // Assigned all GVs to merged clusters while balancing number of objects in\r
+ // each.\r
auto CompareClusters = [](const std::pair<unsigned, unsigned> &a,
const std::pair<unsigned, unsigned> &b) {
if (a.second || b.second)
cl::ParseCommandLineOptions(argc, argv, "LLVM C++ ABI Data Dumper\n");
// Default to stdin if no filename is specified.
- if (opts::InputFilenames.size() == 0)
- opts::InputFilenames.push_back("-");
-
- std::for_each(opts::InputFilenames.begin(), opts::InputFilenames.end(),
- dumpInput);
-
- return EXIT_SUCCESS;
-}
+ if (opts::InputFilenames.size() == 0)\r
+ opts::InputFilenames.push_back("-");\r
+\r
+ llvm::for_each(opts::InputFilenames, dumpInput);\r
+\r
+ return EXIT_SUCCESS;\r
+}\r
ToolName = argv[0];
// If no input files specified, read from stdin.
- if (InputFilenames.size() == 0)
- InputFilenames.push_back("-");
-
- std::for_each(InputFilenames.begin(), InputFilenames.end(),
- parseMCMarkup);
- return 0;
-}
+ if (InputFilenames.size() == 0)\r
+ InputFilenames.push_back("-");\r
+\r
+ llvm::for_each(InputFilenames, parseMCMarkup);\r
+ return 0;\r
+}\r
if (NoDyldInfo && (AddDyldInfo || DyldInfoOnly))
error("-no-dyldinfo can't be used with -add-dyldinfo or -dyldinfo-only");
- std::for_each(InputFilenames.begin(), InputFilenames.end(),
- dumpSymbolNamesFromFile);
+ llvm::for_each(InputFilenames, dumpSymbolNamesFromFile);
if (HadError)
return 1;
&& !PrintFaultMaps
&& DwarfDumpType == DIDT_Null) {
cl::PrintHelpMessage();
- return 2;
- }
-
- std::for_each(InputFilenames.begin(), InputFilenames.end(),
- DumpInput);
-
- return EXIT_SUCCESS;
-}
+ return 2;\r
+ }\r
+\r
+ llvm::for_each(InputFilenames, DumpInput);\r
+\r
+ return EXIT_SUCCESS;\r
+}\r
opts::pretty::ExcludeCompilands.push_back(
"f:\\\\binaries\\\\Intermediate\\\\vctools\\\\crt_bld");
opts::pretty::ExcludeCompilands.push_back("f:\\\\dd\\\\vctools\\\\crt");
- opts::pretty::ExcludeCompilands.push_back(
- "d:\\\\th.obj.x86fre\\\\minkernel");
- }
- std::for_each(opts::pretty::InputFilenames.begin(),
- opts::pretty::InputFilenames.end(), dumpPretty);
- } else if (opts::DumpSubcommand) {
- std::for_each(opts::dump::InputFilenames.begin(),
- opts::dump::InputFilenames.end(), dumpRaw);
- } else if (opts::BytesSubcommand) {
- std::for_each(opts::bytes::InputFilenames.begin(),
- opts::bytes::InputFilenames.end(), dumpBytes);
- } else if (opts::DiffSubcommand) {
- for (StringRef S : opts::diff::RawModiEquivalences) {
- StringRef Left;
+ opts::pretty::ExcludeCompilands.push_back(\r
+ "d:\\\\th.obj.x86fre\\\\minkernel");\r
+ }\r
+ llvm::for_each(opts::pretty::InputFilenames, dumpPretty);\r
+ } else if (opts::DumpSubcommand) {\r
+ llvm::for_each(opts::dump::InputFilenames, dumpRaw);\r
+ } else if (opts::BytesSubcommand) {\r
+ llvm::for_each(opts::bytes::InputFilenames, dumpBytes);\r
+ } else if (opts::DiffSubcommand) {\r
+ for (StringRef S : opts::diff::RawModiEquivalences) {\r
+ StringRef Left;\r
StringRef Right;
std::tie(Left, Right) = S.split(',');
uint32_t X, Y;
cl::ParseCommandLineOptions(argc, argv, "LLVM Object Reader\n");
// Default to stdin if no filename is specified.
- if (opts::InputFilenames.size() == 0)
- opts::InputFilenames.push_back("-");
-
- std::for_each(opts::InputFilenames.begin(), opts::InputFilenames.end(),
- dumpInput);
-
- if (opts::CodeViewMergedTypes) {
- ScopedPrinter W(outs());
+ if (opts::InputFilenames.size() == 0)\r
+ opts::InputFilenames.push_back("-");\r
+\r
+ llvm::for_each(opts::InputFilenames, dumpInput);\r
+\r
+ if (opts::CodeViewMergedTypes) {\r
+ ScopedPrinter W(outs());\r
dumpCodeViewMergedTypes(W, CVTypes.IDTable, CVTypes.TypeTable);
}
}
if (InputFilenames.size() == 0)
- InputFilenames.push_back("a.out");
-
- MoreThanOneFile = InputFilenames.size() > 1;
- std::for_each(InputFilenames.begin(), InputFilenames.end(),
- printFileSectionSizes);
- if (OutputFormat == berkeley && TotalSizes)
- printBerkelyTotals();
-
+ InputFilenames.push_back("a.out");\r
+\r
+ MoreThanOneFile = InputFilenames.size() > 1;\r
+ llvm::for_each(InputFilenames, printFileSectionSizes);\r
+ if (OutputFormat == berkeley && TotalSizes)\r
+ printBerkelyTotals();\r
+\r
if (HadError)
return 1;
}
EXPECT_EQ(3, count(v, 1));
EXPECT_EQ(2, count(v, 2));
EXPECT_EQ(1, count(v, 3));
- EXPECT_EQ(1, count(v, 4));
-}
-
-TEST(STLExtrasTest, ToVector) {
- std::vector<char> v = {'a', 'b', 'c'};
- auto Enumerated = to_vector<4>(enumerate(v));
+ EXPECT_EQ(1, count(v, 4));\r
+}\r
+\r
+TEST(STLExtrasTest, for_each) {\r
+ std::vector<int> v{ 0, 1, 2, 3, 4 };\r
+ int count = 0;\r
+\r
+ llvm::for_each(v, [&count](int) { ++count; });\r
+ EXPECT_EQ(5, count);\r
+}\r
+\r
+TEST(STLExtrasTest, ToVector) {\r
+ std::vector<char> v = {'a', 'b', 'c'};\r
+ auto Enumerated = to_vector<4>(enumerate(v));\r
ASSERT_EQ(3u, Enumerated.size());
for (size_t I = 0; I < v.size(); ++I) {
EXPECT_EQ(I, Enumerated[I].index());