llvm.org GIT mirror llvm / 793d2a4
Use StringRef for MemoryBuffer identifier API (NFC) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283043 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 3 years ago
5 changed file(s) with 9 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
4848 init(this->SV.begin(), this->SV.end(), false);
4949 }
5050
51 const char* getBufferIdentifier() const override { return BufferName.c_str(); }
51 StringRef getBufferIdentifier() const override { return BufferName; }
5252
5353 BufferKind getBufferKind() const override { return MemoryBuffer_Malloc; }
5454
5555
5656 /// Return an identifier for this buffer, typically the filename it was read
5757 /// from.
58 virtual const char *getBufferIdentifier() const {
59 return "Unknown buffer";
60 }
58 virtual StringRef getBufferIdentifier() const { return "Unknown buffer"; }
6159
6260 /// Open the specified file as a MemoryBuffer, returning a new MemoryBuffer
6361 /// if successful, otherwise returning null. If FileSize is specified, this
8989 /// tail-allocated data.
9090 void operator delete(void *p) { ::operator delete(p); }
9191
92 const char *getBufferIdentifier() const override {
93 // The name is stored after the class itself.
94 return reinterpret_cast(this + 1);
92 StringRef getBufferIdentifier() const override {
93 // The name is stored after the class itself.
94 return StringRef(reinterpret_cast(this + 1));
9595 }
9696
9797 BufferKind getBufferKind() const override {
220220 /// tail-allocated data.
221221 void operator delete(void *p) { ::operator delete(p); }
222222
223 const char *getBufferIdentifier() const override {
223 StringRef getBufferIdentifier() const override {
224224 // The name is stored after the class itself.
225 return reinterpret_cast(this + 1);
225 return StringRef(reinterpret_cast(this + 1));
226226 }
227227
228228 BufferKind getBufferKind() const override {
141141 // location to pull out the source line.
142142 SmallVector, 4> ColRanges;
143143 std::pair LineAndCol;
144 const char *BufferID = "";
144 StringRef BufferID = "";
145145 std::string LineStr;
146146
147147 if (Loc.isValid()) {
3636 void emit(raw_ostream &OS) const {
3737 const MemoryBuffer *CurMB =
3838 SrcMgr.getMemoryBuffer(SrcMgr.FindBufferContainingLoc(Loc));
39 const char *BufferName = CurMB->getBufferIdentifier();
39 auto BufferName = CurMB->getBufferIdentifier();
4040 std::pair LineAndColumn = SrcMgr.getLineAndColumn(Loc);
4141 OS << *Id << "\t" << BufferName << "\t" << LineAndColumn.first << "\n";
4242 }