[PATCH] D40170: [llvm-tblgen] - Stop using std::string in RecordKeeper.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 20 06:04:11 PST 2017
grimar updated this revision to Diff 123572.
grimar retitled this revision from "[llvm-tblgen] - Stop using std:string in RecordKeeper." to "[llvm-tblgen] - Stop using std::string in RecordKeeper.".
grimar added a comment.
- Use StringRef in `Tag` instead of `std::string*'. (`Tag` remembers ID of Classes/Defs from `Record` and since patch changes type of map key from `std::string` to `StringRef`, this place should be updated.)
https://reviews.llvm.org/D40170
Files:
include/llvm/TableGen/Record.h
utils/TableGen/CTagsEmitter.cpp
Index: utils/TableGen/CTagsEmitter.cpp
===================================================================
--- utils/TableGen/CTagsEmitter.cpp
+++ utils/TableGen/CTagsEmitter.cpp
@@ -28,18 +28,17 @@
class Tag {
private:
- const std::string *Id;
+ StringRef Id;
SMLoc Loc;
public:
- Tag(const std::string &Name, const SMLoc Location)
- : Id(&Name), Loc(Location) {}
- int operator<(const Tag &B) const { return *Id < *B.Id; }
+ Tag(StringRef Name, const SMLoc Location) : Id(Name), Loc(Location) {}
+ int operator<(const Tag &B) const { return Id < B.Id; }
void emit(raw_ostream &OS) const {
const MemoryBuffer *CurMB =
SrcMgr.getMemoryBuffer(SrcMgr.FindBufferContainingLoc(Loc));
auto BufferName = CurMB->getBufferIdentifier();
std::pair<unsigned, unsigned> LineAndColumn = SrcMgr.getLineAndColumn(Loc);
- OS << *Id << "\t" << BufferName << "\t" << LineAndColumn.first << "\n";
+ OS << Id << "\t" << BufferName << "\t" << LineAndColumn.first << "\n";
}
};
Index: include/llvm/TableGen/Record.h
===================================================================
--- include/llvm/TableGen/Record.h
+++ include/llvm/TableGen/Record.h
@@ -1525,7 +1525,7 @@
};
class RecordKeeper {
- using RecordMap = std::map<std::string, std::unique_ptr<Record>>;
+ using RecordMap = std::map<StringRef, std::unique_ptr<Record>>;
RecordMap Classes, Defs;
public:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40170.123572.patch
Type: text/x-patch
Size: 1415 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171120/94e9c66d/attachment.bin>
More information about the llvm-commits
mailing list