1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

implement support for C-style string literal concatenation in td files.

llvm-svn: 66663
This commit is contained in:
Chris Lattner 2009-03-11 17:08:13 +00:00
parent 5bf3e7dc27
commit 8fdb9ac396
2 changed files with 17 additions and 2 deletions

View File

@ -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">;

View File

@ -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;