Skip to content

Commit 18f1b73

Browse files
[llvm-cfi-verify] Avoid creating temporary instances of std::string (NFC) (llvm#142524)
symbolizeInlinedCode and symbolizeCode take StringRef as the first parameter. We don't need to create temporary instances of std::string only to be converted back to StringRef.
1 parent d77c995 commit 18f1b73

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,7 @@ Expected<DIInliningInfo>
278278
FileAnalysis::symbolizeInlinedCode(object::SectionedAddress Address) {
279279
assert(Symbolizer != nullptr && "Symbolizer is invalid.");
280280

281-
return Symbolizer->symbolizeInlinedCode(std::string(Object->getFileName()),
282-
Address);
281+
return Symbolizer->symbolizeInlinedCode(Object->getFileName(), Address);
283282
}
284283

285284
CFIProtectionStatus
@@ -523,9 +522,8 @@ void FileAnalysis::parseSectionContents(ArrayRef<uint8_t> SectionBytes,
523522

524523
// Check if this instruction exists in the range of the DWARF metadata.
525524
if (!IgnoreDWARFFlag) {
526-
auto LineInfo =
527-
Symbolizer->symbolizeCode(std::string(Object->getFileName()),
528-
{VMAddress, Address.SectionIndex});
525+
auto LineInfo = Symbolizer->symbolizeCode(
526+
Object->getFileName(), {VMAddress, Address.SectionIndex});
529527
if (!LineInfo) {
530528
handleAllErrors(LineInfo.takeError(), [](const ErrorInfoBase &E) {
531529
errs() << "Symbolizer failed to get line: " << E.message() << "\n";

0 commit comments

Comments
 (0)