[llvm] r285832 - Fix Clang-tidy readability-redundant-string-cstr warnings
Malcolm Parsons via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 2 09:43:50 PDT 2016
Author: malcolm.parsons
Date: Wed Nov 2 11:43:50 2016
New Revision: 285832
URL: http://llvm.org/viewvc/llvm-project?rev=285832&view=rev
Log:
Fix Clang-tidy readability-redundant-string-cstr warnings
Reviewers: beanz, lattner, jlebar
Subscribers: jholewinski, llvm-commits, mehdi_amini
Differential Revision: https://reviews.llvm.org/D26235
Modified:
llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp
llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp
llvm/trunk/lib/MC/MachObjectWriter.cpp
llvm/trunk/lib/ObjectYAML/ObjectYAML.cpp
llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
llvm/trunk/lib/Target/Hexagon/HexagonVectorPrint.cpp
llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
llvm/trunk/tools/lli/lli.cpp
llvm/trunk/tools/llvm-lto/llvm-lto.cpp
llvm/trunk/tools/lto/lto.cpp
llvm/trunk/tools/opt/PassPrinters.cpp
llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h
Modified: llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp?rev=285832&r1=285831&r2=285832&view=diff
==============================================================================
--- llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp (original)
+++ llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp Wed Nov 2 11:43:50 2016
@@ -254,7 +254,7 @@ static llvm::AllocaInst *createEntryBloc
llvm::Constant *initWith = 0) {
llvm::BasicBlock &block = function.getEntryBlock();
llvm::IRBuilder<> tmp(&block, block.begin());
- llvm::AllocaInst *ret = tmp.CreateAlloca(type, 0, varName.c_str());
+ llvm::AllocaInst *ret = tmp.CreateAlloca(type, 0, varName);
if (initWith)
tmp.CreateStore(initWith, ret);
Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=285832&r1=285831&r2=285832&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Wed Nov 2 11:43:50 2016
@@ -1047,7 +1047,7 @@ bool MIParser::parseIRConstant(StringRef
const Constant *&C) {
auto Source = StringValue.str(); // The source has to be null terminated.
SMDiagnostic Err;
- C = parseConstantValue(Source.c_str(), Err, *MF.getFunction()->getParent(),
+ C = parseConstantValue(Source, Err, *MF.getFunction()->getParent(),
&PFS.IRSlots);
if (!C)
return error(Loc + Err.getColumnNo(), Err.getMessage());
Modified: llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp?rev=285832&r1=285831&r2=285832&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/DarwinAsmParser.cpp Wed Nov 2 11:43:50 2016
@@ -614,7 +614,7 @@ bool DarwinAsmParser::parseDirectiveSect
TAA, TAAParsed, StubSize);
if (!ErrorStr.empty())
- return Error(Loc, ErrorStr.c_str());
+ return Error(Loc, ErrorStr);
// Issue a warning if the target is not powerpc and Section is a *coal* section.
Triple TT = getParser().getContext().getObjectFileInfo()->getTargetTriple();
Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=285832&r1=285831&r2=285832&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MachObjectWriter.cpp Wed Nov 2 11:43:50 2016
@@ -422,7 +422,7 @@ void MachObjectWriter::writeLinkerOption
uint64_t BytesWritten = sizeof(MachO::linker_option_command);
for (const std::string &Option : Options) {
// Write each string, including the null byte.
- writeBytes(Option.c_str(), Option.size() + 1);
+ writeBytes(Option, Option.size() + 1);
BytesWritten += Option.size() + 1;
}
Modified: llvm/trunk/lib/ObjectYAML/ObjectYAML.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ObjectYAML/ObjectYAML.cpp?rev=285832&r1=285831&r2=285832&view=diff
==============================================================================
--- llvm/trunk/lib/ObjectYAML/ObjectYAML.cpp (original)
+++ llvm/trunk/lib/ObjectYAML/ObjectYAML.cpp Wed Nov 2 11:43:50 2016
@@ -51,7 +51,7 @@ void MappingTraits<YamlObjectFile>::mapp
else
IO.setError(
llvm::Twine("YAML Object File unsupported document type tag '") +
- llvm::Twine(Tag.c_str()) + llvm::Twine("'!"));
+ llvm::Twine(Tag) + llvm::Twine("'!"));
}
}
}
Modified: llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp?rev=285832&r1=285831&r2=285832&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp Wed Nov 2 11:43:50 2016
@@ -1504,7 +1504,7 @@ bool HexagonAsmParser::OutOfRange(SMLoc
ES << "0-" << Max;
else
ES << Max << "-" << (-Max - 1);
- return Parser.printError(IDLoc, ES.str().c_str());
+ return Parser.printError(IDLoc, ES.str());
}
int HexagonAsmParser::processInstruction(MCInst &Inst,
Modified: llvm/trunk/lib/Target/Hexagon/HexagonVectorPrint.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonVectorPrint.cpp?rev=285832&r1=285831&r2=285832&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonVectorPrint.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonVectorPrint.cpp Wed Nov 2 11:43:50 2016
@@ -80,7 +80,7 @@ static void addAsmInstr(MachineBasicBloc
MachineFunction &Fn) {
std::string VDescStr = ".long 0x1dffe0" + getStringReg(Reg);
- const char *cstr = Fn.createExternalSymbolName(VDescStr.c_str());
+ const char *cstr = Fn.createExternalSymbolName(VDescStr);
unsigned ExtraInfo = InlineAsm::Extra_HasSideEffects;
BuildMI(*MBB, I, DL, QII->get(TargetOpcode::INLINEASM))
.addExternalSymbol(cstr)
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp?rev=285832&r1=285831&r2=285832&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp Wed Nov 2 11:43:50 2016
@@ -224,8 +224,7 @@ void NVPTXAsmPrinter::lowerImageHandleSy
const char *Sym = MFI->getImageHandleSymbol(Index);
std::string *SymNamePtr =
nvTM.getManagedStrPool()->getManagedString(Sym);
- MCOp = GetSymbolRef(OutContext.getOrCreateSymbol(
- StringRef(SymNamePtr->c_str())));
+ MCOp = GetSymbolRef(OutContext.getOrCreateSymbol(StringRef(*SymNamePtr)));
}
void NVPTXAsmPrinter::lowerToMCInst(const MachineInstr *MI, MCInst &OutMI) {
Modified: llvm/trunk/tools/lli/lli.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=285832&r1=285831&r2=285832&view=diff
==============================================================================
--- llvm/trunk/tools/lli/lli.cpp (original)
+++ llvm/trunk/tools/lli/lli.cpp Wed Nov 2 11:43:50 2016
@@ -271,7 +271,7 @@ public:
return nullptr;
// Load the object from the cache filename
ErrorOr<std::unique_ptr<MemoryBuffer>> IRObjectBuffer =
- MemoryBuffer::getFile(CacheName.c_str(), -1, false);
+ MemoryBuffer::getFile(CacheName, -1, false);
// If the file isn't there, that's OK.
if (!IRObjectBuffer)
return nullptr;
Modified: llvm/trunk/tools/llvm-lto/llvm-lto.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-lto/llvm-lto.cpp?rev=285832&r1=285831&r2=285832&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-lto/llvm-lto.cpp (original)
+++ llvm/trunk/tools/llvm-lto/llvm-lto.cpp Wed Nov 2 11:43:50 2016
@@ -823,7 +823,7 @@ int main(int argc, char **argv) {
for (unsigned i = BaseArg; i < InputFilenames.size(); ++i) {
CurrentActivity = "loading file '" + InputFilenames[i] + "'";
ErrorOr<std::unique_ptr<LTOModule>> ModuleOrErr =
- LTOModule::createFromFile(Context, InputFilenames[i].c_str(), Options);
+ LTOModule::createFromFile(Context, InputFilenames[i], Options);
std::unique_ptr<LTOModule> &Module = *ModuleOrErr;
CurrentActivity = "";
@@ -851,11 +851,11 @@ int main(int argc, char **argv) {
// Add all the exported symbols to the table of symbols to preserve.
for (unsigned i = 0; i < ExportedSymbols.size(); ++i)
- CodeGen.addMustPreserveSymbol(ExportedSymbols[i].c_str());
+ CodeGen.addMustPreserveSymbol(ExportedSymbols[i]);
// Add all the dso symbols to the table of symbols to expose.
for (unsigned i = 0; i < KeptDSOSyms.size(); ++i)
- CodeGen.addMustPreserveSymbol(KeptDSOSyms[i].c_str());
+ CodeGen.addMustPreserveSymbol(KeptDSOSyms[i]);
// Set cpu and attrs strings for the default target/subtarget.
CodeGen.setCpu(MCPU.c_str());
@@ -870,7 +870,7 @@ int main(int argc, char **argv) {
}
if (!attrs.empty())
- CodeGen.setAttr(attrs.c_str());
+ CodeGen.setAttr(attrs);
if (FileType.getNumOccurrences())
CodeGen.setFileType(FileType);
@@ -887,7 +887,7 @@ int main(int argc, char **argv) {
ModuleFilename += ".merged.bc";
std::string ErrMsg;
- if (!CodeGen.writeMergedModules(ModuleFilename.c_str()))
+ if (!CodeGen.writeMergedModules(ModuleFilename))
error("writing merged module failed.");
}
Modified: llvm/trunk/tools/lto/lto.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=285832&r1=285831&r2=285832&view=diff
==============================================================================
--- llvm/trunk/tools/lto/lto.cpp (original)
+++ llvm/trunk/tools/lto/lto.cpp Wed Nov 2 11:43:50 2016
@@ -153,7 +153,7 @@ static void lto_add_attrs(lto_code_gen_t
attrs.append(MAttrs[i]);
}
- CG->setAttr(attrs.c_str());
+ CG->setAttr(attrs);
}
if (OptLevel < '0' || OptLevel > '3')
Modified: llvm/trunk/tools/opt/PassPrinters.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/PassPrinters.cpp?rev=285832&r1=285831&r2=285832&view=diff
==============================================================================
--- llvm/trunk/tools/opt/PassPrinters.cpp (original)
+++ llvm/trunk/tools/opt/PassPrinters.cpp Wed Nov 2 11:43:50 2016
@@ -46,7 +46,7 @@ struct FunctionPassPrinter : public Func
return false;
}
- StringRef getPassName() const override { return PassName.c_str(); }
+ StringRef getPassName() const override { return PassName; }
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequiredID(PassToPrint->getTypeInfo());
@@ -83,7 +83,7 @@ struct CallGraphSCCPassPrinter : public
return false;
}
- StringRef getPassName() const override { return PassName.c_str(); }
+ StringRef getPassName() const override { return PassName; }
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequiredID(PassToPrint->getTypeInfo());
@@ -115,7 +115,7 @@ struct ModulePassPrinter : public Module
return false;
}
- StringRef getPassName() const override { return PassName.c_str(); }
+ StringRef getPassName() const override { return PassName; }
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequiredID(PassToPrint->getTypeInfo());
@@ -148,7 +148,7 @@ struct LoopPassPrinter : public LoopPass
return false;
}
- StringRef getPassName() const override { return PassName.c_str(); }
+ StringRef getPassName() const override { return PassName; }
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequiredID(PassToPrint->getTypeInfo());
@@ -183,7 +183,7 @@ struct RegionPassPrinter : public Region
return false;
}
- StringRef getPassName() const override { return PassName.c_str(); }
+ StringRef getPassName() const override { return PassName; }
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequiredID(PassToPrint->getTypeInfo());
@@ -217,7 +217,7 @@ struct BasicBlockPassPrinter : public Ba
return false;
}
- StringRef getPassName() const override { return PassName.c_str(); }
+ StringRef getPassName() const override { return PassName; }
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequiredID(PassToPrint->getTypeInfo());
Modified: llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h?rev=285832&r1=285831&r2=285832&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h (original)
+++ llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITTestAPICommon.h Wed Nov 2 11:43:50 2016
@@ -67,7 +67,7 @@ protected:
// If ARCH has sub-arch support, find it
SmallVectorImpl<std::string>::const_iterator I = SupportedSubArchs.begin();
for(; I != SupportedSubArchs.end(); ++I)
- if (Host.getArchName().startswith(I->c_str()))
+ if (Host.getArchName().startswith(*I))
return true;
return false;
More information about the llvm-commits
mailing list