Skip to content

Commit b8debab

Browse files
[clang] Remove redundant calls to c_str() (NFC)
Identified with readability-redundant-string-cstr.
1 parent ae206db commit b8debab

File tree

7 files changed

+8
-10
lines changed

7 files changed

+8
-10
lines changed

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,8 +1448,8 @@ llvm::Value *CGOpenMPRuntime::emitUpdateLocation(CodeGenFunction &CGF,
14481448
const char *FileName = PLoc.getFilename();
14491449
unsigned Line = PLoc.getLine();
14501450
unsigned Column = PLoc.getColumn();
1451-
SrcLocStr = OMPBuilder.getOrCreateSrcLocStr(FunctionName.c_str(), FileName,
1452-
Line, Column);
1451+
SrcLocStr =
1452+
OMPBuilder.getOrCreateSrcLocStr(FunctionName, FileName, Line, Column);
14531453
}
14541454
unsigned Reserved2Flags = getDefaultLocationReserved2Flags();
14551455
return OMPBuilder.getOrCreateIdent(SrcLocStr, llvm::omp::IdentFlag(Flags),

clang/lib/Driver/Compilation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ int Compilation::ExecuteCommand(const Command &C,
174174
!getDriver().CCPrintOptionsFilename.empty()) {
175175
std::error_code EC;
176176
OwnedStream.reset(new llvm::raw_fd_ostream(
177-
getDriver().CCPrintOptionsFilename.c_str(), EC,
177+
getDriver().CCPrintOptionsFilename, EC,
178178
llvm::sys::fs::OF_Append | llvm::sys::fs::OF_TextWithCRLF));
179179
if (EC) {
180180
getDriver().Diag(diag::err_drv_cc_print_options_failure)

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4124,7 +4124,7 @@ void Driver::BuildJobs(Compilation &C) const {
41244124
<< '\n';
41254125
Out.flush();
41264126
std::error_code EC;
4127-
llvm::raw_fd_ostream OS(CCPrintStatReportFilename.c_str(), EC,
4127+
llvm::raw_fd_ostream OS(CCPrintStatReportFilename, EC,
41284128
llvm::sys::fs::OF_Append |
41294129
llvm::sys::fs::OF_Text);
41304130
if (EC)

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ AMDGPUToolChain::detectSystemGPUs(const ArgList &Args,
754754

755755
std::string ErrorMessage;
756756
if (int Result = llvm::sys::ExecuteAndWait(
757-
Program.c_str(), {}, {}, Redirects, /* SecondsToWait */ 0,
757+
Program, {}, {}, Redirects, /* SecondsToWait */ 0,
758758
/*MemoryLimit*/ 0, &ErrorMessage)) {
759759
if (Result > 0) {
760760
ErrorMessage = "Exited with error code " + std::to_string(Result);

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ void tools::addArchSpecificRPath(const ToolChain &TC, const ArgList &Args,
661661
std::string CandidateRPath = TC.getArchSpecificLibPath();
662662
if (TC.getVFS().exists(CandidateRPath)) {
663663
CmdArgs.push_back("-rpath");
664-
CmdArgs.push_back(Args.MakeArgString(CandidateRPath.c_str()));
664+
CmdArgs.push_back(Args.MakeArgString(CandidateRPath));
665665
}
666666
}
667667

clang/lib/Driver/ToolChains/NetBSD.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
261261
const SanitizerArgs &SanArgs = ToolChain.getSanitizerArgs();
262262
if (SanArgs.needsSharedRt()) {
263263
CmdArgs.push_back("-rpath");
264-
CmdArgs.push_back(Args.MakeArgString(
265-
ToolChain.getCompilerRTPath().c_str()));
264+
CmdArgs.push_back(Args.MakeArgString(ToolChain.getCompilerRTPath()));
266265
}
267266

268267
unsigned Major, Minor, Micro;

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,8 +2128,7 @@ void CompilerInstance::createModuleFromSource(SourceLocation ImportLoc,
21282128
const FileEntry *ModuleMapFile = Other.getFileManager().getVirtualFile(
21292129
ModuleMapFileName, NullTerminatedSource.size(), 0);
21302130
Other.getSourceManager().overrideFileContents(
2131-
ModuleMapFile,
2132-
llvm::MemoryBuffer::getMemBuffer(NullTerminatedSource.c_str()));
2131+
ModuleMapFile, llvm::MemoryBuffer::getMemBuffer(NullTerminatedSource));
21332132

21342133
Other.BuiltModules = std::move(BuiltModules);
21352134
Other.DeleteBuiltModules = false;

0 commit comments

Comments
 (0)