[PATCH] D37652: Remove unneccessary string copies from method invocations.
Mitch Phillips via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 11 15:37:57 PDT 2017
hctim updated this revision to Diff 114721.
hctim added a comment.
Made a mistake in last diff, SourcePrinter() is now correctly default-member initialised.
Repository:
rL LLVM
https://reviews.llvm.org/D37652
Files:
tools/llvm-objdump/llvm-objdump.cpp
Index: tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- tools/llvm-objdump/llvm-objdump.cpp
+++ tools/llvm-objdump/llvm-objdump.cpp
@@ -418,7 +418,7 @@
class SourcePrinter {
protected:
DILineInfo OldLineInfo;
- const ObjectFile *Obj;
+ const ObjectFile *Obj = nullptr;
std::unique_ptr<symbolize::LLVMSymbolizer> Symbolizer;
// File name to file contents of source
std::unordered_map<std::string, std::unique_ptr<MemoryBuffer>> SourceCache;
@@ -426,11 +426,10 @@
std::unordered_map<std::string, std::vector<StringRef>> LineCache;
private:
- bool cacheSource(std::string File);
+ bool cacheSource(const std::string& File);
public:
- virtual ~SourcePrinter() {}
- SourcePrinter() : Obj(nullptr), Symbolizer(nullptr) {}
+ SourcePrinter() = default;
SourcePrinter(const ObjectFile *Obj, StringRef DefaultArch) : Obj(Obj) {
symbolize::LLVMSymbolizer::Options SymbolizerOpts(
DILineInfoSpecifier::FunctionNameKind::None, true, false, false,
@@ -437,11 +436,12 @@
DefaultArch);
Symbolizer.reset(new symbolize::LLVMSymbolizer(SymbolizerOpts));
}
+ virtual ~SourcePrinter() = default;
virtual void printSourceLine(raw_ostream &OS, uint64_t Address,
StringRef Delimiter = "; ");
};
-bool SourcePrinter::cacheSource(std::string File) {
+bool SourcePrinter::cacheSource(const std::string& File) {
auto BufferOrError = MemoryBuffer::getFile(File);
if (!BufferOrError)
return false;
@@ -509,7 +509,7 @@
class PrettyPrinter {
public:
- virtual ~PrettyPrinter(){}
+ virtual ~PrettyPrinter() = default;
virtual void printInst(MCInstPrinter &IP, const MCInst *MI,
ArrayRef<uint8_t> Bytes, uint64_t Address,
raw_ostream &OS, StringRef Annot,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37652.114721.patch
Type: text/x-patch
Size: 1856 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170911/11bf887a/attachment.bin>
More information about the llvm-commits
mailing list