Merge changes Ie6c300e1,I391f1e69

* changes:
  header-checker: Remove protobuf parser for Python
  header-checker: Reorder command line option checks
This commit is contained in:
Logan Chien
2018-10-18 09:36:51 +00:00
committed by Gerrit Code Review
3 changed files with 15 additions and 1583 deletions

View File

@@ -81,29 +81,35 @@ int main(int argc, const char **argv) {
FixedArgvRegistry::Apply(fixed_argv);
// Create compilation database from command line arguments after "--".
std::string cmdline_error_msg;
std::unique_ptr<clang::tooling::CompilationDatabase> compilations;
{
// loadFromCommandLine() may alter argc and argv, thus access fixed_argv
// through FixedArgvAccess.
FixedArgvAccess raw(fixed_argv);
std::string cmdline_error_msg;
compilations =
clang::tooling::FixedCompilationDatabase::loadFromCommandLine(
raw.argc_, raw.argv_, cmdline_error_msg);
// Check whether we can create compilation database and deduce compiler
// options from command line options.
if (!compilations) {
llvm::errs() << "ERROR: " << cmdline_error_msg << "\n";
::exit(1);
}
}
// Parse the command line options.
// Parse the command line options
llvm::cl::ParseCommandLineOptions(
fixed_argv.GetArgc(), fixed_argv.GetArgv(), "header-checker");
// Print an error message if we failed to create the compilation database
// from the command line arguments. This check is intentionally performed
// after `llvm::cl::ParseCommandLineOptions()` so that `-help` can work
// without `--`.
if (!compilations) {
if (cmdline_error_msg.empty()) {
llvm::errs() << "ERROR: Failed to parse clang command line options\n";
} else {
llvm::errs() << "ERROR: " << cmdline_error_msg << "\n";
}
::exit(1);
}
// Input header file existential check.
if (!llvm::sys::fs::exists(header_file)) {
llvm::errs() << "ERROR: Header file \"" << header_file << "\" not found\n";

File diff suppressed because one or more lines are too long