[llvm] r283043 - Use StringRef for MemoryBuffer identifier API (NFC)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 1 09:38:31 PDT 2016
Author: mehdi_amini
Date: Sat Oct 1 11:38:28 2016
New Revision: 283043
URL: http://llvm.org/viewvc/llvm-project?rev=283043&view=rev
Log:
Use StringRef for MemoryBuffer identifier API (NFC)
Modified:
llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h
llvm/trunk/include/llvm/Support/MemoryBuffer.h
llvm/trunk/lib/Support/MemoryBuffer.cpp
llvm/trunk/lib/Support/SourceMgr.cpp
llvm/trunk/utils/TableGen/CTagsEmitter.cpp
Modified: llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h?rev=283043&r1=283042&r2=283043&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/ObjectMemoryBuffer.h Sat Oct 1 11:38:28 2016
@@ -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; }
Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MemoryBuffer.h?rev=283043&r1=283042&r2=283043&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MemoryBuffer.h (original)
+++ llvm/trunk/include/llvm/Support/MemoryBuffer.h Sat Oct 1 11:38:28 2016
@@ -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
Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=283043&r1=283042&r2=283043&view=diff
==============================================================================
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Sat Oct 1 11:38:28 2016
@@ -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 {
Modified: llvm/trunk/lib/Support/SourceMgr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/SourceMgr.cpp?rev=283043&r1=283042&r2=283043&view=diff
==============================================================================
--- llvm/trunk/lib/Support/SourceMgr.cpp (original)
+++ llvm/trunk/lib/Support/SourceMgr.cpp Sat Oct 1 11:38:28 2016
@@ -142,7 +142,7 @@ SMDiagnostic SourceMgr::GetMessage(SMLoc
// 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()) {
Modified: llvm/trunk/utils/TableGen/CTagsEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CTagsEmitter.cpp?rev=283043&r1=283042&r2=283043&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CTagsEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/CTagsEmitter.cpp Sat Oct 1 11:38:28 2016
@@ -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";
}
More information about the llvm-commits
mailing list