Avoid some copies by using const references.
clang-tidy's performance-unnecessary-copy-initialization with some manual fixes. No functional changes intended. llvm-svn: 270988
This commit is contained in:
@@ -50,7 +50,7 @@ std::unique_ptr<SpecialCaseList>
|
|||||||
SpecialCaseList::create(const std::vector<std::string> &Paths,
|
SpecialCaseList::create(const std::vector<std::string> &Paths,
|
||||||
std::string &Error) {
|
std::string &Error) {
|
||||||
std::unique_ptr<SpecialCaseList> SCL(new SpecialCaseList());
|
std::unique_ptr<SpecialCaseList> SCL(new SpecialCaseList());
|
||||||
for (auto Path : Paths) {
|
for (const auto &Path : Paths) {
|
||||||
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr =
|
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr =
|
||||||
MemoryBuffer::getFile(Path);
|
MemoryBuffer::getFile(Path);
|
||||||
if (std::error_code EC = FileOrErr.getError()) {
|
if (std::error_code EC = FileOrErr.getError()) {
|
||||||
|
|||||||
@@ -190,8 +190,6 @@ public:
|
|||||||
MCAsmBackend *llvm::createAMDGPUAsmBackend(const Target &T,
|
MCAsmBackend *llvm::createAMDGPUAsmBackend(const Target &T,
|
||||||
const MCRegisterInfo &MRI,
|
const MCRegisterInfo &MRI,
|
||||||
const Triple &TT, StringRef CPU) {
|
const Triple &TT, StringRef CPU) {
|
||||||
Triple TargetTriple(TT);
|
|
||||||
|
|
||||||
// Use 64-bit ELF for amdgcn
|
// Use 64-bit ELF for amdgcn
|
||||||
return new ELFAMDGPUAsmBackend(T, TargetTriple.getArch() == Triple::amdgcn);
|
return new ELFAMDGPUAsmBackend(T, TT.getArch() == Triple::amdgcn);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -642,7 +642,7 @@ void ARMAsmPrinter::emitAttributes() {
|
|||||||
static_cast<const ARMBaseTargetMachine &>(TM);
|
static_cast<const ARMBaseTargetMachine &>(TM);
|
||||||
const ARMSubtarget STI(TT, CPU, ArchFS, ATM, ATM.isLittleEndian());
|
const ARMSubtarget STI(TT, CPU, ArchFS, ATM, ATM.isLittleEndian());
|
||||||
|
|
||||||
std::string CPUString = STI.getCPUString();
|
const std::string &CPUString = STI.getCPUString();
|
||||||
|
|
||||||
if (CPUString.find("generic") != 0) { //CPUString doesn't start with "generic"
|
if (CPUString.find("generic") != 0) { //CPUString doesn't start with "generic"
|
||||||
// FIXME: remove krait check when GNU tools support krait cpu
|
// FIXME: remove krait check when GNU tools support krait cpu
|
||||||
|
|||||||
@@ -1401,7 +1401,6 @@ bool HexagonAsmParser::parseInstruction(OperandVector &Operands) {
|
|||||||
AsmToken const &Token = Parser.getTok();
|
AsmToken const &Token = Parser.getTok();
|
||||||
if (Token.is(AsmToken::Identifier)) {
|
if (Token.is(AsmToken::Identifier)) {
|
||||||
StringRef String = Token.getString();
|
StringRef String = Token.getString();
|
||||||
AsmToken IDToken = Token;
|
|
||||||
if (String.lower() == "hi") {
|
if (String.lower() == "hi") {
|
||||||
HiOnly = true;
|
HiOnly = true;
|
||||||
} else if (String.lower() == "lo") {
|
} else if (String.lower() == "lo") {
|
||||||
|
|||||||
@@ -438,7 +438,7 @@ public:
|
|||||||
IsCpRestoreSet = false;
|
IsCpRestoreSet = false;
|
||||||
CpRestoreOffset = -1;
|
CpRestoreOffset = -1;
|
||||||
|
|
||||||
Triple TheTriple(sti.getTargetTriple());
|
const Triple &TheTriple = sti.getTargetTriple();
|
||||||
if ((TheTriple.getArch() == Triple::mips) ||
|
if ((TheTriple.getArch() == Triple::mips) ||
|
||||||
(TheTriple.getArch() == Triple::mips64))
|
(TheTriple.getArch() == Triple::mips64))
|
||||||
IsLittleEndian = false;
|
IsLittleEndian = false;
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ void NVPTXAsmPrinter::emitLineNumberAsDotLoc(const MachineInstr &MI) {
|
|||||||
if (ignoreLoc(MI))
|
if (ignoreLoc(MI))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DebugLoc curLoc = MI.getDebugLoc();
|
const DebugLoc &curLoc = MI.getDebugLoc();
|
||||||
|
|
||||||
if (!prevDebugLoc && !curLoc)
|
if (!prevDebugLoc && !curLoc)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ public:
|
|||||||
const MCInstrInfo &MII, const MCTargetOptions &Options)
|
const MCInstrInfo &MII, const MCTargetOptions &Options)
|
||||||
: MCTargetAsmParser(Options, STI), MII(MII) {
|
: MCTargetAsmParser(Options, STI), MII(MII) {
|
||||||
// Check for 64-bit vs. 32-bit pointer mode.
|
// Check for 64-bit vs. 32-bit pointer mode.
|
||||||
Triple TheTriple(STI.getTargetTriple());
|
const Triple &TheTriple = STI.getTargetTriple();
|
||||||
IsPPC64 = (TheTriple.getArch() == Triple::ppc64 ||
|
IsPPC64 = (TheTriple.getArch() == Triple::ppc64 ||
|
||||||
TheTriple.getArch() == Triple::ppc64le);
|
TheTriple.getArch() == Triple::ppc64le);
|
||||||
IsDarwin = TheTriple.isMacOSX();
|
IsDarwin = TheTriple.isMacOSX();
|
||||||
|
|||||||
@@ -445,7 +445,7 @@ void SampleProfileLoader::printBlockWeight(raw_ostream &OS,
|
|||||||
/// \returns the weight of \p Inst.
|
/// \returns the weight of \p Inst.
|
||||||
ErrorOr<uint64_t>
|
ErrorOr<uint64_t>
|
||||||
SampleProfileLoader::getInstWeight(const Instruction &Inst) const {
|
SampleProfileLoader::getInstWeight(const Instruction &Inst) const {
|
||||||
DebugLoc DLoc = Inst.getDebugLoc();
|
const DebugLoc &DLoc = Inst.getDebugLoc();
|
||||||
if (!DLoc)
|
if (!DLoc)
|
||||||
return std::error_code();
|
return std::error_code();
|
||||||
|
|
||||||
|
|||||||
@@ -77,15 +77,15 @@ static SetVector<BasicBlock *> buildExtractionBlockSet(IteratorT BBBegin,
|
|||||||
|
|
||||||
// Loop over the blocks, adding them to our set-vector, and aborting with an
|
// Loop over the blocks, adding them to our set-vector, and aborting with an
|
||||||
// empty set if we encounter invalid blocks.
|
// empty set if we encounter invalid blocks.
|
||||||
for (IteratorT I = BBBegin, E = BBEnd; I != E; ++I) {
|
do {
|
||||||
if (!Result.insert(*I))
|
if (!Result.insert(*BBBegin))
|
||||||
llvm_unreachable("Repeated basic blocks in extraction input");
|
llvm_unreachable("Repeated basic blocks in extraction input");
|
||||||
|
|
||||||
if (!isBlockValidForExtraction(**I)) {
|
if (!isBlockValidForExtraction(**BBBegin)) {
|
||||||
Result.clear();
|
Result.clear();
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
}
|
} while (++BBBegin != BBEnd);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
for (SetVector<BasicBlock *>::iterator I = std::next(Result.begin()),
|
for (SetVector<BasicBlock *>::iterator I = std::next(Result.begin()),
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
// Expand any .dSYM bundles to the individual object files contained therein.
|
// Expand any .dSYM bundles to the individual object files contained therein.
|
||||||
std::vector<std::string> Objects;
|
std::vector<std::string> Objects;
|
||||||
for (auto F : InputFilenames) {
|
for (const auto &F : InputFilenames) {
|
||||||
auto Objs = expandBundle(F);
|
auto Objs = expandBundle(F);
|
||||||
Objects.insert(Objects.end(), Objs.begin(), Objs.end());
|
Objects.insert(Objects.end(), Objs.begin(), Objs.end());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -894,7 +894,7 @@ public:
|
|||||||
OS << "<table>\n";
|
OS << "<table>\n";
|
||||||
OS << "<tr><th>File</th><th>Coverage %</th>";
|
OS << "<tr><th>File</th><th>Coverage %</th>";
|
||||||
OS << "<th>Hit (Total) Fns</th></tr>\n";
|
OS << "<th>Hit (Total) Fns</th></tr>\n";
|
||||||
for (auto FileName : Files) {
|
for (const auto &FileName : Files) {
|
||||||
std::pair<size_t, size_t> FC = FileCoverage[FileName];
|
std::pair<size_t, size_t> FC = FileCoverage[FileName];
|
||||||
if (FC.first == 0) {
|
if (FC.first == 0) {
|
||||||
NotCoveredFilesCount++;
|
NotCoveredFilesCount++;
|
||||||
@@ -915,7 +915,7 @@ public:
|
|||||||
if (NotCoveredFilesCount) {
|
if (NotCoveredFilesCount) {
|
||||||
OS << "<details><summary>Not Touched Files</summary>\n";
|
OS << "<details><summary>Not Touched Files</summary>\n";
|
||||||
OS << "<table>\n";
|
OS << "<table>\n";
|
||||||
for (auto FileName : Files) {
|
for (const auto &FileName : Files) {
|
||||||
std::pair<size_t, size_t> FC = FileCoverage[FileName];
|
std::pair<size_t, size_t> FC = FileCoverage[FileName];
|
||||||
if (FC.first == 0)
|
if (FC.first == 0)
|
||||||
OS << "<tr><td>" << stripPathPrefix(FileName) << "</td>\n";
|
OS << "<tr><td>" << stripPathPrefix(FileName) << "</td>\n";
|
||||||
@@ -927,7 +927,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Source
|
// Source
|
||||||
for (auto FileName : Files) {
|
for (const auto &FileName : Files) {
|
||||||
std::pair<size_t, size_t> FC = FileCoverage[FileName];
|
std::pair<size_t, size_t> FC = FileCoverage[FileName];
|
||||||
if (FC.first == 0)
|
if (FC.first == 0)
|
||||||
continue;
|
continue;
|
||||||
@@ -969,7 +969,7 @@ public:
|
|||||||
FileLoc Loc = FileLoc{FileName, Line};
|
FileLoc Loc = FileLoc{FileName, Line};
|
||||||
auto It = AllFnsByLoc.find(Loc);
|
auto It = AllFnsByLoc.find(Loc);
|
||||||
if (It != AllFnsByLoc.end()) {
|
if (It != AllFnsByLoc.end()) {
|
||||||
for (std::string Fn : It->second) {
|
for (const std::string &Fn : It->second) {
|
||||||
OS << "<a name=\"" << anchorName(FileName + "::" + Fn)
|
OS << "<a name=\"" << anchorName(FileName + "::" + Fn)
|
||||||
<< "\"></a>";
|
<< "\"></a>";
|
||||||
};
|
};
|
||||||
@@ -1069,7 +1069,7 @@ public:
|
|||||||
std::vector<std::unique_ptr<CoverageDataWithObjectFile>> MergedCoverage;
|
std::vector<std::unique_ptr<CoverageDataWithObjectFile>> MergedCoverage;
|
||||||
for (const auto &Pair : CoverageByObjFile) {
|
for (const auto &Pair : CoverageByObjFile) {
|
||||||
if (findSanitizerCovFunctions(Pair.first).empty()) {
|
if (findSanitizerCovFunctions(Pair.first).empty()) {
|
||||||
for (auto FileName : Pair.second) {
|
for (const auto &FileName : Pair.second) {
|
||||||
CovFiles.erase(FileName);
|
CovFiles.erase(FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1159,7 +1159,7 @@ public:
|
|||||||
// About
|
// About
|
||||||
OS << "<details><summary>About</summary>\n";
|
OS << "<details><summary>About</summary>\n";
|
||||||
OS << "Coverage files:<ul>";
|
OS << "Coverage files:<ul>";
|
||||||
for (auto InputFile : CoverageFiles) {
|
for (const auto &InputFile : CoverageFiles) {
|
||||||
llvm::sys::fs::file_status Status;
|
llvm::sys::fs::file_status Status;
|
||||||
llvm::sys::fs::status(InputFile, Status);
|
llvm::sys::fs::status(InputFile, Status);
|
||||||
OS << "<li>" << stripPathPrefix(InputFile) << " ("
|
OS << "<li>" << stripPathPrefix(InputFile) << " ("
|
||||||
@@ -1209,7 +1209,7 @@ int main(int argc, char **argv) {
|
|||||||
return 0;
|
return 0;
|
||||||
} else if (Action == PrintCovPointsAction) {
|
} else if (Action == PrintCovPointsAction) {
|
||||||
// -print-coverage-points doesn't need coverage files.
|
// -print-coverage-points doesn't need coverage files.
|
||||||
for (std::string ObjFile : ClInputFiles) {
|
for (const std::string &ObjFile : ClInputFiles) {
|
||||||
printCovPoints(ObjFile, outs());
|
printCovPoints(ObjFile, outs());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ template <>
|
|||||||
size_t writeLoadCommandData<MachO::segment_command>(MachOYAML::LoadCommand &LC,
|
size_t writeLoadCommandData<MachO::segment_command>(MachOYAML::LoadCommand &LC,
|
||||||
raw_ostream &OS) {
|
raw_ostream &OS) {
|
||||||
size_t BytesWritten = 0;
|
size_t BytesWritten = 0;
|
||||||
for (auto Sec : LC.Sections) {
|
for (const auto &Sec : LC.Sections) {
|
||||||
auto TempSec = constructSection<MachO::section>(Sec);
|
auto TempSec = constructSection<MachO::section>(Sec);
|
||||||
OS.write(reinterpret_cast<const char *>(&(TempSec)),
|
OS.write(reinterpret_cast<const char *>(&(TempSec)),
|
||||||
sizeof(MachO::section));
|
sizeof(MachO::section));
|
||||||
@@ -130,7 +130,7 @@ size_t
|
|||||||
writeLoadCommandData<MachO::segment_command_64>(MachOYAML::LoadCommand &LC,
|
writeLoadCommandData<MachO::segment_command_64>(MachOYAML::LoadCommand &LC,
|
||||||
raw_ostream &OS) {
|
raw_ostream &OS) {
|
||||||
size_t BytesWritten = 0;
|
size_t BytesWritten = 0;
|
||||||
for (auto Sec : LC.Sections) {
|
for (const auto &Sec : LC.Sections) {
|
||||||
auto TempSec = constructSection<MachO::section_64>(Sec);
|
auto TempSec = constructSection<MachO::section_64>(Sec);
|
||||||
TempSec.reserved3 = Sec.reserved3;
|
TempSec.reserved3 = Sec.reserved3;
|
||||||
OS.write(reinterpret_cast<const char *>(&(TempSec)),
|
OS.write(reinterpret_cast<const char *>(&(TempSec)),
|
||||||
|
|||||||
@@ -990,7 +990,7 @@ RegisterInfoEmitter::runMCDesc(raw_ostream &OS, CodeGenTarget &Target,
|
|||||||
ArrayRef<Record*> Order = RC.getOrder();
|
ArrayRef<Record*> Order = RC.getOrder();
|
||||||
|
|
||||||
// Give the register class a legal C name if it's anonymous.
|
// Give the register class a legal C name if it's anonymous.
|
||||||
std::string Name = RC.getName();
|
const std::string &Name = RC.getName();
|
||||||
|
|
||||||
RegClassStrings.add(Name);
|
RegClassStrings.add(Name);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user