]> granicus.if.org Git - llvm/commitdiff
Revert r318822 "[llvm-tblgen] - Stop using std::string in RecordKeeper."
authorGeorge Rimar <grimar@accesssoftek.com>
Thu, 23 Nov 2017 06:52:44 +0000 (06:52 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Thu, 23 Nov 2017 06:52:44 +0000 (06:52 +0000)
It reported to have problems with memory sanitizers and DBUILD_SHARED_LIBS=ON.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318899 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/TableGen/Record.h
utils/TableGen/CTagsEmitter.cpp

index d0e6ddbb878fd82781ae3874572f581329f02944..55b4dfe2fa2f6bf4f69df43f280471d2797a368e 100644 (file)
@@ -1525,7 +1525,7 @@ struct MultiClass {
 };
 
 class RecordKeeper {
-  using RecordMap = std::map<StringRef, std::unique_ptr<Record>>;
+  using RecordMap = std::map<std::string, std::unique_ptr<Record>>;
   RecordMap Classes, Defs;
 
 public:
index e72430078baf3dd82f63bcd2c786aa1fe43ce20f..5213cd90446283e3985c784d61f92e3477074d60 100644 (file)
@@ -28,17 +28,18 @@ namespace {
 
 class Tag {
 private:
-  StringRef Id;
+  const std::string *Id;
   SMLoc Loc;
 public:
-  Tag(StringRef Name, const SMLoc Location) : Id(Name), Loc(Location) {}
-  int operator<(const Tag &B) const { return Id < B.Id; }
+  Tag(const std::string &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";
   }
 };