[llvm-commits] [llvm] r66663 - in /llvm/trunk: test/TableGen/strconcat.td utils/TableGen/TGParser.cpp
Chris Lattner
sabre at nondot.org
Wed Mar 11 10:08:14 PDT 2009
Author: lattner
Date: Wed Mar 11 12:08:13 2009
New Revision: 66663
URL: http://llvm.org/viewvc/llvm-project?rev=66663&view=rev
Log:
implement support for C-style string literal concatenation in td files.
Modified:
llvm/trunk/test/TableGen/strconcat.td
llvm/trunk/utils/TableGen/TGParser.cpp
Modified: llvm/trunk/test/TableGen/strconcat.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/strconcat.td?rev=66663&r1=66662&r2=66663&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/strconcat.td (original)
+++ llvm/trunk/test/TableGen/strconcat.td Wed Mar 11 12:08:13 2009
@@ -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">;
Modified: llvm/trunk/utils/TableGen/TGParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.cpp?rev=66663&r1=66662&r2=66663&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/TGParser.cpp (original)
+++ llvm/trunk/utils/TableGen/TGParser.cpp Wed Mar 11 12:08:13 2009
@@ -505,7 +505,7 @@
///
/// SimpleValue ::= IDValue
/// SimpleValue ::= INTVAL
-/// SimpleValue ::= STRVAL
+/// SimpleValue ::= STRVAL+
/// SimpleValue ::= CODEFRAGMENT
/// SimpleValue ::= '?'
/// SimpleValue ::= '{' ValueList '}'
@@ -523,7 +523,19 @@
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;
More information about the llvm-commits
mailing list