Skip to content

Commit 656466e

Browse files
committed
Fix dangling StringRefs found by clang-tidy misc-dangling-handle check.
llvm-svn: 307085
1 parent a66a98c commit 656466e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

llvm/tools/llvm-lto/llvm-lto.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ loadAllFilesForIndex(const ModuleSummaryIndex &Index) {
383383

384384
for (auto &ModPath : Index.modulePaths()) {
385385
const auto &Filename = ModPath.first();
386-
auto CurrentActivity = "loading file '" + Filename + "'";
386+
std::string CurrentActivity = ("loading file '" + Filename + "'").str();
387387
auto InputOrErr = MemoryBuffer::getFile(Filename);
388388
error(InputOrErr, "error " + CurrentActivity);
389389
InputBuffers.push_back(std::move(*InputOrErr));
@@ -475,7 +475,7 @@ class ThinLTOProcessing {
475475
std::vector<std::unique_ptr<MemoryBuffer>> InputBuffers;
476476
for (unsigned i = 0; i < InputFilenames.size(); ++i) {
477477
auto &Filename = InputFilenames[i];
478-
StringRef CurrentActivity = "loading file '" + Filename + "'";
478+
std::string CurrentActivity = "loading file '" + Filename + "'";
479479
auto InputOrErr = MemoryBuffer::getFile(Filename);
480480
error(InputOrErr, "error " + CurrentActivity);
481481
InputBuffers.push_back(std::move(*InputOrErr));
@@ -710,7 +710,7 @@ class ThinLTOProcessing {
710710
std::vector<std::unique_ptr<MemoryBuffer>> InputBuffers;
711711
for (unsigned i = 0; i < InputFilenames.size(); ++i) {
712712
auto &Filename = InputFilenames[i];
713-
StringRef CurrentActivity = "loading file '" + Filename + "'";
713+
std::string CurrentActivity = "loading file '" + Filename + "'";
714714
auto InputOrErr = MemoryBuffer::getFile(Filename);
715715
error(InputOrErr, "error " + CurrentActivity);
716716
InputBuffers.push_back(std::move(*InputOrErr));

llvm/tools/llvm-readobj/COFFDumper.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,11 @@ static StringRef getBaseRelocTypeName(uint8_t Type) {
16371637
case COFF::IMAGE_REL_BASED_HIGHADJ: return "HIGHADJ";
16381638
case COFF::IMAGE_REL_BASED_ARM_MOV32T: return "ARM_MOV32(T)";
16391639
case COFF::IMAGE_REL_BASED_DIR64: return "DIR64";
1640-
default: return "unknown (" + llvm::utostr(Type) + ")";
1640+
default: {
1641+
static std::string Result;
1642+
Result = "unknown (" + llvm::utostr(Type) + ")";
1643+
return Result;
1644+
}
16411645
}
16421646
}
16431647

0 commit comments

Comments
 (0)