llvm.org GIT mirror llvm / d7a50cf
implement support for C-style string literal concatenation in td files. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66663 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
2 changed file(s) with 17 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
11
22 class Y {
33 string T = !strconcat(S, "foo");
4
5 // String values concatenate lexically, as in C.
6 string S = "foo" "bar";
47 }
58
69 def Z : Y<"fu">;
504504 ///
505505 /// SimpleValue ::= IDValue
506506 /// SimpleValue ::= INTVAL
507 /// SimpleValue ::= STRVAL
507 /// SimpleValue ::= STRVAL+
508508 /// SimpleValue ::= CODEFRAGMENT
509509 /// SimpleValue ::= '?'
510510 /// SimpleValue ::= '{' ValueList '}'
522522 switch (Lex.getCode()) {
523523 default: TokError("Unknown token when parsing a value"); break;
524524 case tgtok::IntVal: R = new IntInit(Lex.getCurIntVal()); Lex.Lex(); break;
525 case tgtok::StrVal: R = new StringInit(Lex.getCurStrVal()); Lex.Lex(); break;
525 case tgtok::StrVal: {
526 std::string Val = Lex.getCurStrVal();
527 Lex.Lex();
528
529 // Handle multiple consequtive concatenated strings.
530 while (Lex.getCode() == tgtok::StrVal) {
531 Val += Lex.getCurStrVal();
532 Lex.Lex();
533 }
534
535 R = new StringInit(Val);
536 break;
537 }
526538 case tgtok::CodeFragment:
527539 R = new CodeInit(Lex.getCurStrVal()); Lex.Lex(); break;
528540 case tgtok::question: R = new UnsetInit(); Lex.Lex(); break;