@@ -43,6 +43,7 @@ enum class ActionType {
43
43
FullLexRoundTrip,
44
44
FullParseRoundTrip,
45
45
SerializeRawTree,
46
+ ParseOnly,
46
47
ParserGen,
47
48
EOFPos,
48
49
None
@@ -66,6 +67,9 @@ Action(llvm::cl::desc("Action (required):"),
66
67
" round-trip-parse" ,
67
68
" Parse the source file and print it back out for "
68
69
" comparing against the input" ),
70
+ clEnumValN(ActionType::ParseOnly,
71
+ " parse-only" ,
72
+ " Parse the source file with syntax nodes and exit" ),
69
73
clEnumValN(ActionType::ParserGen,
70
74
" parse-gen" ,
71
75
" Parse the source file and print it back out for "
@@ -233,6 +237,13 @@ int doSerializeRawTree(const char *MainExecutablePath,
233
237
return EXIT_SUCCESS;
234
238
}
235
239
240
+ int doParseOnly (const char *MainExecutablePath,
241
+ const StringRef InputFileName) {
242
+ CompilerInstance Instance;
243
+ SourceFile *SF = getSourceFile (Instance, InputFileName, MainExecutablePath);
244
+ return SF ? EXIT_SUCCESS : EXIT_FAILURE;
245
+ }
246
+
236
247
int dumpParserGen (const char *MainExecutablePath,
237
248
const StringRef InputFileName) {
238
249
CompilerInstance Instance;
@@ -266,7 +277,6 @@ int dumpEOFSourceLoc(const char *MainExecutablePath,
266
277
llvm::outs () << CharSourceRange (SourceMgr, StartLoc, EndLoc).str ();
267
278
return 0 ;
268
279
}
269
-
270
280
}// end of anonymous namespace
271
281
272
282
int main (int argc, char *argv[]) {
@@ -297,6 +307,9 @@ int main(int argc, char *argv[]) {
297
307
case ActionType::SerializeRawTree:
298
308
ExitCode = doSerializeRawTree (argv[0 ], options::InputSourceFilename);
299
309
break ;
310
+ case ActionType::ParseOnly:
311
+ ExitCode = doParseOnly (argv[0 ], options::InputSourceFilename);
312
+ break ;
300
313
case ActionType::ParserGen:
301
314
ExitCode = dumpParserGen (argv[0 ], options::InputSourceFilename);
302
315
break ;
0 commit comments