aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/TableGen/strconcat.td3
-rw-r--r--utils/TableGen/TGParser.cpp16
2 files changed, 17 insertions, 2 deletions
diff --git a/test/TableGen/strconcat.td b/test/TableGen/strconcat.td
index cdf3928f04..fc0d80596c 100644
--- a/test/TableGen/strconcat.td
+++ b/test/TableGen/strconcat.td
@@ -2,6 +2,9 @@
class Y<string S> {
string T = !strconcat(S, "foo");
+
+ // String values concatenate lexically, as in C.
+ string S = "foo" "bar";
}
def Z : Y<"fu">;
diff --git a/utils/TableGen/TGParser.cpp b/utils/TableGen/TGParser.cpp
index 1ea6b9816f..d31e2a50ee 100644
--- a/utils/TableGen/TGParser.cpp
+++ b/utils/TableGen/TGParser.cpp
@@ -505,7 +505,7 @@ Init *TGParser::ParseIDValue(Record *CurRec,
///
/// SimpleValue ::= IDValue
/// SimpleValue ::= INTVAL
-/// SimpleValue ::= STRVAL
+/// SimpleValue ::= STRVAL+
/// SimpleValue ::= CODEFRAGMENT
/// SimpleValue ::= '?'
/// SimpleValue ::= '{' ValueList '}'
@@ -523,7 +523,19 @@ Init *TGParser::ParseSimpleValue(Record *CurRec) {
switch (Lex.getCode()) {
default: TokError("Unknown token when parsing a value"); break;
case tgtok::IntVal: R = new IntInit(Lex.getCurIntVal()); Lex.Lex(); break;
- case tgtok::StrVal: R = new StringInit(Lex.getCurStrVal()); Lex.Lex(); break;
+ case tgtok::StrVal: {
+ std::string Val = Lex.getCurStrVal();
+ Lex.Lex();
+
+ // Handle multiple consequtive concatenated strings.
+ while (Lex.getCode() == tgtok::StrVal) {
+ Val += Lex.getCurStrVal();
+ Lex.Lex();
+ }
+
+ R = new StringInit(Val);
+ break;
+ }
case tgtok::CodeFragment:
R = new CodeInit(Lex.getCurStrVal()); Lex.Lex(); break;
case tgtok::question: R = new UnsetInit(); Lex.Lex(); break;