Skip to content

Commit f6667e1

Browse files
npmillerdwoodwor-intel
authored andcommitted
[SYCL] Fix filename string data going out of scope
`getInputFilename` returns a `std::string` so just taking the `c_str` without keeping track of the string object doesn't work.
1 parent 2c217cf commit f6667e1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ const char *SYCL::Linker::constructLLVMLinkCommand(
168168
if (HostTC->getTriple().isWindowsMSVCEnvironment() &&
169169
C.getDriver().IsCLMode())
170170
LibPostfix = ".obj";
171-
StringRef InputFilename = llvm::sys::path::filename(
172-
StringRef(this->getToolChain().getInputFilename(II)));
171+
std::string FileName = this->getToolChain().getInputFilename(II);
172+
StringRef InputFilename = llvm::sys::path::filename(FileName);
173173
StringRef LibSyclPrefix("libsycl-");
174174
if (!InputFilename.startswith(LibSyclPrefix) ||
175175
!InputFilename.endswith(LibPostfix) || (InputFilename.count('-') < 2))

0 commit comments

Comments
 (0)