diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h | 2 | ||||
-rw-r--r-- | llvm/include/llvm/Support/MemoryBuffer.h | 4 | ||||
-rw-r--r-- | llvm/lib/Support/MemoryBuffer.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/Support/SourceMgr.cpp | 2 | ||||
-rw-r--r-- | llvm/utils/TableGen/CTagsEmitter.cpp | 2 |
5 files changed, 9 insertions, 11 deletions
diff --git a/llvm/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h b/llvm/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h index b07561152ec..0f00ad006a7 100644 --- a/llvm/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h +++ b/llvm/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h @@ -49,7 +49,7 @@ public: init(this->SV.begin(), this->SV.end(), false); } - const char* getBufferIdentifier() const override { return BufferName.c_str(); } + StringRef getBufferIdentifier() const override { return BufferName; } BufferKind getBufferKind() const override { return MemoryBuffer_Malloc; } diff --git a/llvm/include/llvm/Support/MemoryBuffer.h b/llvm/include/llvm/Support/MemoryBuffer.h index 73d643537a6..70d91bdc26a 100644 --- a/llvm/include/llvm/Support/MemoryBuffer.h +++ b/llvm/include/llvm/Support/MemoryBuffer.h @@ -56,9 +56,7 @@ public: /// Return an identifier for this buffer, typically the filename it was read /// from. - virtual const char *getBufferIdentifier() const { - return "Unknown buffer"; - } + virtual StringRef getBufferIdentifier() const { return "Unknown buffer"; } /// Open the specified file as a MemoryBuffer, returning a new MemoryBuffer /// if successful, otherwise returning null. If FileSize is specified, this diff --git a/llvm/lib/Support/MemoryBuffer.cpp b/llvm/lib/Support/MemoryBuffer.cpp index b935cbf1ae7..689343206c5 100644 --- a/llvm/lib/Support/MemoryBuffer.cpp +++ b/llvm/lib/Support/MemoryBuffer.cpp @@ -90,9 +90,9 @@ public: /// tail-allocated data. void operator delete(void *p) { ::operator delete(p); } - const char *getBufferIdentifier() const override { - // The name is stored after the class itself. - return reinterpret_cast<const char*>(this + 1); + StringRef getBufferIdentifier() const override { + // The name is stored after the class itself. + return StringRef(reinterpret_cast<const char *>(this + 1)); } BufferKind getBufferKind() const override { @@ -221,9 +221,9 @@ public: /// tail-allocated data. void operator delete(void *p) { ::operator delete(p); } - const char *getBufferIdentifier() const override { + StringRef getBufferIdentifier() const override { // The name is stored after the class itself. - return reinterpret_cast<const char *>(this + 1); + return StringRef(reinterpret_cast<const char *>(this + 1)); } BufferKind getBufferKind() const override { diff --git a/llvm/lib/Support/SourceMgr.cpp b/llvm/lib/Support/SourceMgr.cpp index b2f87d64845..4cb9b2ff2cd 100644 --- a/llvm/lib/Support/SourceMgr.cpp +++ b/llvm/lib/Support/SourceMgr.cpp @@ -142,7 +142,7 @@ SMDiagnostic SourceMgr::GetMessage(SMLoc Loc, SourceMgr::DiagKind Kind, // location to pull out the source line. SmallVector<std::pair<unsigned, unsigned>, 4> ColRanges; std::pair<unsigned, unsigned> LineAndCol; - const char *BufferID = "<unknown>"; + StringRef BufferID = "<unknown>"; std::string LineStr; if (Loc.isValid()) { diff --git a/llvm/utils/TableGen/CTagsEmitter.cpp b/llvm/utils/TableGen/CTagsEmitter.cpp index 35f4ad6dd5b..5213cd90446 100644 --- a/llvm/utils/TableGen/CTagsEmitter.cpp +++ b/llvm/utils/TableGen/CTagsEmitter.cpp @@ -37,7 +37,7 @@ public: void emit(raw_ostream &OS) const { const MemoryBuffer *CurMB = SrcMgr.getMemoryBuffer(SrcMgr.FindBufferContainingLoc(Loc)); - const char *BufferName = CurMB->getBufferIdentifier(); + auto BufferName = CurMB->getBufferIdentifier(); std::pair<unsigned, unsigned> LineAndColumn = SrcMgr.getLineAndColumn(Loc); OS << *Id << "\t" << BufferName << "\t" << LineAndColumn.first << "\n"; } |