Skip to content

Commit 4e1b0f4

Browse files
authored
Merge pull request #37 from nedwardsnae/options_parser_fix
Check if the options parser was created succesfully. If not, log out the error to standard error.
2 parents 43988ca + 01334e4 commit 4e1b0f4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Parsers/ClangLayout/src/Parser.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,18 @@ namespace Parser
385385
ClangParser::g_locationFilter = filter;
386386
}
387387

388-
bool Parse(int argc, const char* argv[])
389-
{
388+
bool Parse(int argc, const char* argv[])
389+
{
390390
llvm::InitializeNativeTarget();
391391
llvm::InitializeNativeTargetAsmParser();
392392

393393
llvm::Expected<clang::tooling::CommonOptionsParser> optionsParser = clang::tooling::CommonOptionsParser::create(argc, argv, CommandLine::g_commandLineCategory);
394+
if (!optionsParser)
395+
{
396+
llvm::errs() << "Failed to create options parser: " << llvm::toString(optionsParser.takeError()) << "\n";
397+
return false;
398+
}
399+
394400
clang::tooling::ClangTool tool(optionsParser->getCompilations(), optionsParser->getSourcePathList());
395401

396402
SetFilter(ClangParser::LocationFilter{ CommandLine::g_locationRow, CommandLine::g_locationCol });
@@ -406,5 +412,5 @@ namespace Parser
406412

407413
ClangParser::Helpers::ClearResult();
408414
return ret;
409-
}
415+
}
410416
}

0 commit comments

Comments
 (0)