llvm.org GIT mirror llvm / b397ac4
Avoid some copies by using const references. clang-tidy's performance-unnecessary-copy-initialization with some manual fixes. No functional changes intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270988 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 3 years ago
13 changed file(s) with 22 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
4949 SpecialCaseList::create(const std::vector &Paths,
5050 std::string &Error) {
5151 std::unique_ptr SCL(new SpecialCaseList());
52 for (auto Path : Paths) {
52 for (const auto &Path : Paths) {
5353 ErrorOr> FileOrErr =
5454 MemoryBuffer::getFile(Path);
5555 if (std::error_code EC = FileOrErr.getError()) {
189189 MCAsmBackend *llvm::createAMDGPUAsmBackend(const Target &T,
190190 const MCRegisterInfo &MRI,
191191 const Triple &TT, StringRef CPU) {
192 Triple TargetTriple(TT);
193
194192 // Use 64-bit ELF for amdgcn
195 return new ELFAMDGPUAsmBackend(T, TargetTriple.getArch() == Triple::amdgcn);
193 return new ELFAMDGPUAsmBackend(T, TT.getArch() == Triple::amdgcn);
196194 }
641641 static_cast(TM);
642642 const ARMSubtarget STI(TT, CPU, ArchFS, ATM, ATM.isLittleEndian());
643643
644 std::string CPUString = STI.getCPUString();
644 const std::string &CPUString = STI.getCPUString();
645645
646646 if (CPUString.find("generic") != 0) { //CPUString doesn't start with "generic"
647647 // FIXME: remove krait check when GNU tools support krait cpu
14001400 AsmToken const &Token = Parser.getTok();
14011401 if (Token.is(AsmToken::Identifier)) {
14021402 StringRef String = Token.getString();
1403 AsmToken IDToken = Token;
14041403 if (String.lower() == "hi") {
14051404 HiOnly = true;
14061405 } else if (String.lower() == "lo") {
437437 IsCpRestoreSet = false;
438438 CpRestoreOffset = -1;
439439
440 Triple TheTriple(sti.getTargetTriple());
440 const Triple &TheTriple = sti.getTargetTriple();
441441 if ((TheTriple.getArch() == Triple::mips) ||
442442 (TheTriple.getArch() == Triple::mips64))
443443 IsLittleEndian = false;
116116 if (ignoreLoc(MI))
117117 return;
118118
119 DebugLoc curLoc = MI.getDebugLoc();
119 const DebugLoc &curLoc = MI.getDebugLoc();
120120
121121 if (!prevDebugLoc && !curLoc)
122122 return;
291291 const MCInstrInfo &MII, const MCTargetOptions &Options)
292292 : MCTargetAsmParser(Options, STI), MII(MII) {
293293 // Check for 64-bit vs. 32-bit pointer mode.
294 Triple TheTriple(STI.getTargetTriple());
294 const Triple &TheTriple = STI.getTargetTriple();
295295 IsPPC64 = (TheTriple.getArch() == Triple::ppc64 ||
296296 TheTriple.getArch() == Triple::ppc64le);
297297 IsDarwin = TheTriple.isMacOSX();
444444 /// \returns the weight of \p Inst.
445445 ErrorOr
446446 SampleProfileLoader::getInstWeight(const Instruction &Inst) const {
447 DebugLoc DLoc = Inst.getDebugLoc();
447 const DebugLoc &DLoc = Inst.getDebugLoc();
448448 if (!DLoc)
449449 return std::error_code();
450450
7676
7777 // Loop over the blocks, adding them to our set-vector, and aborting with an
7878 // empty set if we encounter invalid blocks.
79 for (IteratorT I = BBBegin, E = BBEnd; I != E; ++I) {
80 if (!Result.insert(*I))
79 do {
80 if (!Result.insert(*BBBegin))
8181 llvm_unreachable("Repeated basic blocks in extraction input");
8282
83 if (!isBlockValidForExtraction(**I)) {
83 if (!isBlockValidForExtraction(**BBBegin)) {
8484 Result.clear();
8585 return Result;
8686 }
87 }
87 } while (++BBBegin != BBEnd);
8888
8989 #ifndef NDEBUG
9090 for (SetVector::iterator I = std::next(Result.begin()),
157157
158158 // Expand any .dSYM bundles to the individual object files contained therein.
159159 std::vector Objects;
160 for (auto F : InputFilenames) {
160 for (const auto &F : InputFilenames) {
161161 auto Objs = expandBundle(F);
162162 Objects.insert(Objects.end(), Objs.begin(), Objs.end());
163163 }
893893 OS << "\n"; "; \n";
894894 OS << "
FileCoverage %
895895 OS << "Hit (Total) Fns
896 for (auto FileName : Files) {
896 for (const auto &FileName : Files) {
897897 std::pair FC = FileCoverage[FileName];
898898 if (FC.first == 0) {
899899 NotCoveredFilesCount++;
914914 if (NotCoveredFilesCount) {
915915 OS << "
Not Touched Files\n";
916916 OS << "\n"; \n";
917 for (auto FileName : Files) {
917 for (const auto &FileName : Files) {
918918 std::pair FC = FileCoverage[FileName];
919919 if (FC.first == 0)
920920 OS << "
" << stripPathPrefix(FileName) << "
926926 }
927927
928928 // Source
929 for (auto FileName : Files) {
929 for (const auto &FileName : Files) {
930930 std::pair FC = FileCoverage[FileName];
931931 if (FC.first == 0)
932932 continue;
968968 FileLoc Loc = FileLoc{FileName, Line};
969969 auto It = AllFnsByLoc.find(Loc);
970970 if (It != AllFnsByLoc.end()) {
971 for (std::string Fn : It->second) {
971 for (const std::string &Fn : It->second) {
972972 OS << "
973973 << "\">";
974974 };
10681068 std::vector> MergedCoverage;
10691069 for (const auto &Pair : CoverageByObjFile) {
10701070 if (findSanitizerCovFunctions(Pair.first).empty()) {
1071 for (auto FileName : Pair.second) {
1071 for (const auto &FileName : Pair.second) {
10721072 CovFiles.erase(FileName);
10731073 }
10741074
11581158 // About
11591159 OS << "
About\n";
11601160 OS << "Coverage files:
    ";
1161 for (auto InputFile : CoverageFiles) {
1161 for (const auto &InputFile : CoverageFiles) {
11621162 llvm::sys::fs::file_status Status;
11631163 llvm::sys::fs::status(InputFile, Status);
11641164 OS << "
  • " << stripPathPrefix(InputFile) << " ("
  • 12081208 return 0;
    12091209 } else if (Action == PrintCovPointsAction) {
    12101210 // -print-coverage-points doesn't need coverage files.
    1211 for (std::string ObjFile : ClInputFiles) {
    1211 for (const std::string &ObjFile : ClInputFiles) {
    12121212 printCovPoints(ObjFile, outs());
    12131213 }
    12141214 return 0;
    115115 size_t writeLoadCommandData(MachOYAML::LoadCommand &LC,
    116116 raw_ostream &OS) {
    117117 size_t BytesWritten = 0;
    118 for (auto Sec : LC.Sections) {
    118 for (const auto &Sec : LC.Sections) {
    119119 auto TempSec = constructSection(Sec);
    120120 OS.write(reinterpret_cast(&(TempSec)),
    121121 sizeof(MachO::section));
    129129 writeLoadCommandData(MachOYAML::LoadCommand &LC,
    130130 raw_ostream &OS) {
    131131 size_t BytesWritten = 0;
    132 for (auto Sec : LC.Sections) {
    132 for (const auto &Sec : LC.Sections) {
    133133 auto TempSec = constructSection(Sec);
    134134 TempSec.reserved3 = Sec.reserved3;
    135135 OS.write(reinterpret_cast(&(TempSec)),
    989989 ArrayRef Order = RC.getOrder();
    990990
    991991 // Give the register class a legal C name if it's anonymous.
    992 std::string Name = RC.getName();
    992 const std::string &Name = RC.getName();
    993993
    994994 RegClassStrings.add(Name);
    995995