Bail when an unrecoverable error has been detected.
If for example an include file is not found, iwyu should not continue to run because it would be working with a garbage ast.
This commit is contained in:
parent
9945e543d8
commit
4909f206b4
13
iwyu.cc
13
iwyu.cc
|
@ -3596,7 +3596,18 @@ class IwyuAstConsumer
|
|||
ParseFunctionTemplates(context.getTranslationUnitDecl());
|
||||
|
||||
TraverseDecl(context.getTranslationUnitDecl());
|
||||
|
||||
|
||||
// Check if any unrecoverable errors have occurred.
|
||||
// There is no point in continuing when the AST is in a bad state.
|
||||
//
|
||||
// EXIT_INVALIDARGS is not a great choice for the return status
|
||||
// because a compile error will not have a strong connection to the
|
||||
// command line arguments, but there are only 2 error codes and
|
||||
// this is the least bad choice.
|
||||
// TODO : Readdress when error codes are reworked.
|
||||
if (compiler()->getDiagnostics().hasUnrecoverableErrorOccurred())
|
||||
exit(EXIT_INVALIDARGS);
|
||||
|
||||
const set<const FileEntry*>* const files_to_report_iwyu_violations_for
|
||||
= preprocessor_info().files_to_report_iwyu_violations_for();
|
||||
|
||||
|
|
Loading…
Reference in New Issue