Fix dangling StringRefs found by clang-tidy misc-dangling-handle check.

llvm-svn: 307085
This commit is contained in:
Alexander Kornienko 2017-07-04 15:13:02 +00:00
parent a66a98cc74
commit 656466ed0b
2 changed files with 8 additions and 4 deletions

View File

@ -383,7 +383,7 @@ loadAllFilesForIndex(const ModuleSummaryIndex &Index) {
for (auto &ModPath : Index.modulePaths()) {
const auto &Filename = ModPath.first();
auto CurrentActivity = "loading file '" + Filename + "'";
std::string CurrentActivity = ("loading file '" + Filename + "'").str();
auto InputOrErr = MemoryBuffer::getFile(Filename);
error(InputOrErr, "error " + CurrentActivity);
InputBuffers.push_back(std::move(*InputOrErr));
@ -475,7 +475,7 @@ private:
std::vector<std::unique_ptr<MemoryBuffer>> InputBuffers;
for (unsigned i = 0; i < InputFilenames.size(); ++i) {
auto &Filename = InputFilenames[i];
StringRef CurrentActivity = "loading file '" + Filename + "'";
std::string CurrentActivity = "loading file '" + Filename + "'";
auto InputOrErr = MemoryBuffer::getFile(Filename);
error(InputOrErr, "error " + CurrentActivity);
InputBuffers.push_back(std::move(*InputOrErr));
@ -710,7 +710,7 @@ private:
std::vector<std::unique_ptr<MemoryBuffer>> InputBuffers;
for (unsigned i = 0; i < InputFilenames.size(); ++i) {
auto &Filename = InputFilenames[i];
StringRef CurrentActivity = "loading file '" + Filename + "'";
std::string CurrentActivity = "loading file '" + Filename + "'";
auto InputOrErr = MemoryBuffer::getFile(Filename);
error(InputOrErr, "error " + CurrentActivity);
InputBuffers.push_back(std::move(*InputOrErr));

View File

@ -1637,7 +1637,11 @@ static StringRef getBaseRelocTypeName(uint8_t Type) {
case COFF::IMAGE_REL_BASED_HIGHADJ: return "HIGHADJ";
case COFF::IMAGE_REL_BASED_ARM_MOV32T: return "ARM_MOV32(T)";
case COFF::IMAGE_REL_BASED_DIR64: return "DIR64";
default: return "unknown (" + llvm::utostr(Type) + ")";
default: {
static std::string Result;
Result = "unknown (" + llvm::utostr(Type) + ")";
return Result;
}
}
}