From 33894b619b89e0ab686bcc5701364ddaf47435d6 Mon Sep 17 00:00:00 2001 From: George Rimar Date: Thu, 23 Nov 2017 06:52:44 +0000 Subject: [PATCH] Revert r318822 "[llvm-tblgen] - Stop using std::string in RecordKeeper." It reported to have problems with memory sanitizers and DBUILD_SHARED_LIBS=ON. llvm-svn: 318899 --- llvm/include/llvm/TableGen/Record.h | 2 +- llvm/utils/TableGen/CTagsEmitter.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h index d0e6ddb..55b4dfe 100644 --- a/llvm/include/llvm/TableGen/Record.h +++ b/llvm/include/llvm/TableGen/Record.h @@ -1525,7 +1525,7 @@ struct MultiClass { }; class RecordKeeper { - using RecordMap = std::map>; + using RecordMap = std::map>; RecordMap Classes, Defs; public: diff --git a/llvm/utils/TableGen/CTagsEmitter.cpp b/llvm/utils/TableGen/CTagsEmitter.cpp index e724300..5213cd9 100644 --- a/llvm/utils/TableGen/CTagsEmitter.cpp +++ b/llvm/utils/TableGen/CTagsEmitter.cpp @@ -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 LineAndColumn = SrcMgr.getLineAndColumn(Loc); - OS << Id << "\t" << BufferName << "\t" << LineAndColumn.first << "\n"; + OS << *Id << "\t" << BufferName << "\t" << LineAndColumn.first << "\n"; } }; -- 2.7.4