llvm.org GIT mirror llvm / 4c12732
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285832 91177308-0d34-0410-b5e6-96231b3b80d8 Malcolm Parsons 2 years ago
13 changed file(s) with 22 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
253253 llvm::Constant *initWith = 0) {
254254 llvm::BasicBlock &block = function.getEntryBlock();
255255 llvm::IRBuilder<> tmp(&block, block.begin());
256 llvm::AllocaInst *ret = tmp.CreateAlloca(type, 0, varName.c_str());
256 llvm::AllocaInst *ret = tmp.CreateAlloca(type, 0, varName);
257257
258258 if (initWith)
259259 tmp.CreateStore(initWith, ret);
10461046 const Constant *&C) {
10471047 auto Source = StringValue.str(); // The source has to be null terminated.
10481048 SMDiagnostic Err;
1049 C = parseConstantValue(Source.c_str(), Err, *MF.getFunction()->getParent(),
1049 C = parseConstantValue(Source, Err, *MF.getFunction()->getParent(),
10501050 &PFS.IRSlots);
10511051 if (!C)
10521052 return error(Loc + Err.getColumnNo(), Err.getMessage());
613613 TAA, TAAParsed, StubSize);
614614
615615 if (!ErrorStr.empty())
616 return Error(Loc, ErrorStr.c_str());
616 return Error(Loc, ErrorStr);
617617
618618 // Issue a warning if the target is not powerpc and Section is a *coal* section.
619619 Triple TT = getParser().getContext().getObjectFileInfo()->getTargetTriple();
421421 uint64_t BytesWritten = sizeof(MachO::linker_option_command);
422422 for (const std::string &Option : Options) {
423423 // Write each string, including the null byte.
424 writeBytes(Option.c_str(), Option.size() + 1);
424 writeBytes(Option, Option.size() + 1);
425425 BytesWritten += Option.size() + 1;
426426 }
427427
5050 else
5151 IO.setError(
5252 llvm::Twine("YAML Object File unsupported document type tag '") +
53 llvm::Twine(Tag.c_str()) + llvm::Twine("'!"));
53 llvm::Twine(Tag) + llvm::Twine("'!"));
5454 }
5555 }
5656 }
15031503 ES << "0-" << Max;
15041504 else
15051505 ES << Max << "-" << (-Max - 1);
1506 return Parser.printError(IDLoc, ES.str().c_str());
1506 return Parser.printError(IDLoc, ES.str());
15071507 }
15081508
15091509 int HexagonAsmParser::processInstruction(MCInst &Inst,
7979 MachineFunction &Fn) {
8080
8181 std::string VDescStr = ".long 0x1dffe0" + getStringReg(Reg);
82 const char *cstr = Fn.createExternalSymbolName(VDescStr.c_str());
82 const char *cstr = Fn.createExternalSymbolName(VDescStr);
8383 unsigned ExtraInfo = InlineAsm::Extra_HasSideEffects;
8484 BuildMI(*MBB, I, DL, QII->get(TargetOpcode::INLINEASM))
8585 .addExternalSymbol(cstr)
223223 const char *Sym = MFI->getImageHandleSymbol(Index);
224224 std::string *SymNamePtr =
225225 nvTM.getManagedStrPool()->getManagedString(Sym);
226 MCOp = GetSymbolRef(OutContext.getOrCreateSymbol(
227 StringRef(SymNamePtr->c_str())));
226 MCOp = GetSymbolRef(OutContext.getOrCreateSymbol(StringRef(*SymNamePtr)));
228227 }
229228
230229 void NVPTXAsmPrinter::lowerToMCInst(const MachineInstr *MI, MCInst &OutMI) {
270270 return nullptr;
271271 // Load the object from the cache filename
272272 ErrorOr> IRObjectBuffer =
273 MemoryBuffer::getFile(CacheName.c_str(), -1, false);
273 MemoryBuffer::getFile(CacheName, -1, false);
274274 // If the file isn't there, that's OK.
275275 if (!IRObjectBuffer)
276276 return nullptr;
822822 for (unsigned i = BaseArg; i < InputFilenames.size(); ++i) {
823823 CurrentActivity = "loading file '" + InputFilenames[i] + "'";
824824 ErrorOr> ModuleOrErr =
825 LTOModule::createFromFile(Context, InputFilenames[i].c_str(), Options);
825 LTOModule::createFromFile(Context, InputFilenames[i], Options);
826826 std::unique_ptr &Module = *ModuleOrErr;
827827 CurrentActivity = "";
828828
850850
851851 // Add all the exported symbols to the table of symbols to preserve.
852852 for (unsigned i = 0; i < ExportedSymbols.size(); ++i)
853 CodeGen.addMustPreserveSymbol(ExportedSymbols[i].c_str());
853 CodeGen.addMustPreserveSymbol(ExportedSymbols[i]);
854854
855855 // Add all the dso symbols to the table of symbols to expose.
856856 for (unsigned i = 0; i < KeptDSOSyms.size(); ++i)
857 CodeGen.addMustPreserveSymbol(KeptDSOSyms[i].c_str());
857 CodeGen.addMustPreserveSymbol(KeptDSOSyms[i]);
858858
859859 // Set cpu and attrs strings for the default target/subtarget.
860860 CodeGen.setCpu(MCPU.c_str());
869869 }
870870
871871 if (!attrs.empty())
872 CodeGen.setAttr(attrs.c_str());
872 CodeGen.setAttr(attrs);
873873
874874 if (FileType.getNumOccurrences())
875875 CodeGen.setFileType(FileType);
886886 ModuleFilename += ".merged.bc";
887887 std::string ErrMsg;
888888
889 if (!CodeGen.writeMergedModules(ModuleFilename.c_str()))
889 if (!CodeGen.writeMergedModules(ModuleFilename))
890890 error("writing merged module failed.");
891891 }
892892
152152 attrs.append(MAttrs[i]);
153153 }
154154
155 CG->setAttr(attrs.c_str());
155 CG->setAttr(attrs);
156156 }
157157
158158 if (OptLevel < '0' || OptLevel > '3')
4545 return false;
4646 }
4747
48 StringRef getPassName() const override { return PassName.c_str(); }
48 StringRef getPassName() const override { return PassName; }
4949
5050 void getAnalysisUsage(AnalysisUsage &AU) const override {
5151 AU.addRequiredID(PassToPrint->getTypeInfo());
8282 return false;
8383 }
8484
85 StringRef getPassName() const override { return PassName.c_str(); }
85 StringRef getPassName() const override { return PassName; }
8686
8787 void getAnalysisUsage(AnalysisUsage &AU) const override {
8888 AU.addRequiredID(PassToPrint->getTypeInfo());
114114 return false;
115115 }
116116
117 StringRef getPassName() const override { return PassName.c_str(); }
117 StringRef getPassName() const override { return PassName; }
118118
119119 void getAnalysisUsage(AnalysisUsage &AU) const override {
120120 AU.addRequiredID(PassToPrint->getTypeInfo());
147147 return false;
148148 }
149149
150 StringRef getPassName() const override { return PassName.c_str(); }
150 StringRef getPassName() const override { return PassName; }
151151
152152 void getAnalysisUsage(AnalysisUsage &AU) const override {
153153 AU.addRequiredID(PassToPrint->getTypeInfo());
182182 return false;
183183 }
184184
185 StringRef getPassName() const override { return PassName.c_str(); }
185 StringRef getPassName() const override { return PassName; }
186186
187187 void getAnalysisUsage(AnalysisUsage &AU) const override {
188188 AU.addRequiredID(PassToPrint->getTypeInfo());
216216 return false;
217217 }
218218
219 StringRef getPassName() const override { return PassName.c_str(); }
219 StringRef getPassName() const override { return PassName; }
220220
221221 void getAnalysisUsage(AnalysisUsage &AU) const override {
222222 AU.addRequiredID(PassToPrint->getTypeInfo());
6666 // If ARCH has sub-arch support, find it
6767 SmallVectorImpl::const_iterator I = SupportedSubArchs.begin();
6868 for(; I != SupportedSubArchs.end(); ++I)
69 if (Host.getArchName().startswith(I->c_str()))
69 if (Host.getArchName().startswith(*I))
7070 return true;
7171
7272 return false;