summaryrefslogtreecommitdiff
path: root/lib/TableGen
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-05-31 19:01:11 +0000
committerCraig Topper <craig.topper@gmail.com>2017-05-31 19:01:11 +0000
commitc469be384cbd573c05d7456be95eb9ddbfc3c1b4 (patch)
treea12a21da130dafafa280a190e0d37438d01bc089 /lib/TableGen
parent923e8566d0569f360711fcf7115c9c8b463f7a0e (diff)
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304325 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/TableGen')
-rw-r--r--lib/TableGen/Record.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/TableGen/Record.cpp b/lib/TableGen/Record.cpp
index 06129c59095..b7432d5314c 100644
--- a/lib/TableGen/Record.cpp
+++ b/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());