diff options
| author | Craig Topper <craig.topper@gmail.com> | 2017-05-31 19:01:11 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@gmail.com> | 2017-05-31 19:01:11 +0000 |
| commit | 2b8419a22d0fdb9b204ef0a0262a6ca22137b9a5 (patch) | |
| tree | d7801abd33c2973d4a9f375e9519e55b3745d375 /llvm/lib/TableGen | |
| parent | fa5dc09292ad2310a378a82a05a6449f2bd3a113 (diff) | |
| download | bcm5719-llvm-2b8419a22d0fdb9b204ef0a0262a6ca22137b9a5.tar.gz bcm5719-llvm-2b8419a22d0fdb9b204ef0a0262a6ca22137b9a5.zip | |
[TableGen] Make Record::getValueAsString and getValueAsListOfStrings return StringRefs instead of std::string
Internally both these methods just return the result of getValue on either a StringInit or a CodeInit object. In both cases this returns a StringRef pointing to a string allocated in the BumpPtrAllocator so its not going anywhere. So we can just pass that StringRef along.
This is a fairly naive patch that targets just the build failures caused by this change. There's additional work that can be done to avoid creating std::string at call sites that still think getValueAsString returns a std::string. I'll try to clean those up in future patches.
Differential Revision: https://reviews.llvm.org/D33710
llvm-svn: 304325
Diffstat (limited to 'llvm/lib/TableGen')
| -rw-r--r-- | llvm/lib/TableGen/Record.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index 06129c59095..b7432d5314c 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -1708,7 +1708,7 @@ Init *Record::getValueInit(StringRef FieldName) const { return R->getValue(); } -std::string Record::getValueAsString(StringRef FieldName) const { +StringRef Record::getValueAsString(StringRef FieldName) const { const RecordVal *R = getValue(FieldName); if (!R || !R->getValue()) PrintFatalError(getLoc(), "Record `" + getName() + @@ -1787,10 +1787,10 @@ Record::getValueAsListOfInts(StringRef FieldName) const { return Ints; } -std::vector<std::string> +std::vector<StringRef> Record::getValueAsListOfStrings(StringRef FieldName) const { ListInit *List = getValueAsListInit(FieldName); - std::vector<std::string> Strings; + std::vector<StringRef> Strings; for (Init *I : List->getValues()) { if (StringInit *SI = dyn_cast<StringInit>(I)) Strings.push_back(SI->getValue()); |

