================ @@ -55,5 +59,271 @@ TEST_F(FormatTestTableGen, NoSpacesInSquareBracketLists) { verifyFormat("def flag : Flag<[\"-\", \"--\"], \"foo\">;"); } +TEST_F(FormatTestTableGen, LiteralsAndIdentifiers) { + verifyFormat("def LiteralAndIdentifiers {\n" + " let someInteger = -42;\n" + " let 0startID = $TokVarName;\n" + " let 0xstartInteger = 0x42;\n" + " let someIdentifier = $TokVarName;\n" + "}\n"); +} + +TEST_F(FormatTestTableGen, BangOperators) { + verifyFormat("def BangOperators {\n" + " let IfOpe = !if(\n" + " !not(!and(!gt(!add(1, 2), !sub(3, 4)), !isa<Ty>($x))),\n" + " !foldl(0, !listconcat(!range(5, 6), !range(7, 8)),\n" + " total, rec, !add(total, rec.Number)),\n" + " !tail(!range(9, 10)));\n" + " let ForeachOpe = !foreach(\n" + " arg, arglist,\n" + " !if(!isa<SomeType>(arg.Type),\n" + " !add(!cast<SomeOtherType>(arg).Number, x), arg));\n" + " let CondOpe1 = !cond(!eq(size, 1): 1,\n" + " !eq(size, 2): 1,\n" + " !eq(size, 4): 1,\n" + " !eq(size, 8): 1,\n" + " !eq(size, 16): 1,\n" + " true: 0);\n" + " let CondOpe2 = !cond(!lt(x, 0): \"negativenegative\",\n" + " !eq(x, 0): \"zerozero\",\n" + " true: \"positivepositive\");\n" + " let CondOpe2WithComment = !cond(!lt(x, 0): // negative\n" + " \"negativenegative\",\n" + " !eq(x, 0): // zero\n" + " \"zerozero\",\n" + " true: // default\n" + " \"positivepositive\");\n" + "}\n"); +} + +TEST_F(FormatTestTableGen, Include) { + verifyFormat("include \"test/IncludeFile.h\"\n"); +} + +TEST_F(FormatTestTableGen, Types) { + verifyFormat("def Types : list<int>, bits<3>, list<list<string>> {}\n"); +} + +TEST_F(FormatTestTableGen, SimpleValue1_SingleLiterals) { + verifyFormat("def SimpleValue {\n" + " let Integer = 42;\n" + " let String = \"some string\";\n" + "}\n"); +} + +TEST_F(FormatTestTableGen, SimpleValue1_MultilineString) { + // test::messUp does not understand multiline TableGen code-literals. + // We have to give the result and the strings to format manually. + std::string DefWithCode = ---------------- HazardyKnusperkeks wrote:
```suggestion StringRef DefWithCode = ``` No need to allocate. https://github.com/llvm/llvm-project/pull/81611 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits