aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--test/TableGen/subst2.td15
-rw-r--r--utils/TableGen/Record.cpp4
2 files changed, 18 insertions, 1 deletions
diff --git a/test/TableGen/subst2.td b/test/TableGen/subst2.td
new file mode 100644
index 0000000..3366c9d
--- /dev/null
+++ b/test/TableGen/subst2.td
@@ -0,0 +1,15 @@
+// RUN: tblgen %s | FileCheck %s
+// CHECK: No subst
+// CHECK: No foo
+// CHECK: RECURSE foo
+
+class Recurse<string t> {
+ string Text = t;
+}
+
+class Text<string text> :
+ Recurse<!subst("RECURSE", "RECURSE", !subst("NORECURSE", "foo", text))>;
+
+def Ok1 : Text<"No subst">;
+def Ok2 : Text<"No NORECURSE">;
+def Trouble : Text<"RECURSE NORECURSE">;
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index 53f9014..542735e 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -945,11 +945,13 @@ Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) {
std::string Val = RHSs->getValue();
std::string::size_type found;
+ std::string::size_type idx = 0;
do {
- found = Val.find(LHSs->getValue());
+ found = Val.find(LHSs->getValue(), idx);
if (found != std::string::npos) {
Val.replace(found, LHSs->getValue().size(), MHSs->getValue());
}
+ idx = found + MHSs->getValue().size();
} while (found != std::string::npos);
return new StringInit(Val);