From: Manuel Klimek Date: Thu, 3 Dec 2015 10:38:53 +0000 (+0000) Subject: Add fall-back mode for clang tools. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0267370b16cd972a4d4fe96b3309daa9f4109ea0;p=clang Add fall-back mode for clang tools. Run without flags if we cannot load a compilation database. This matches the behavior of clang itself when simply called with a source file. Based on a patch by Russell Wallace. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254599 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Tooling/CommonOptionsParser.cpp b/lib/Tooling/CommonOptionsParser.cpp index e6b986709a..82f5601400 100644 --- a/lib/Tooling/CommonOptionsParser.cpp +++ b/lib/Tooling/CommonOptionsParser.cpp @@ -116,8 +116,7 @@ CommonOptionsParser::CommonOptionsParser( cl::HideUnrelatedOptions(Category); - Compilations.reset(FixedCompilationDatabase::loadFromCommandLine(argc, - argv)); + Compilations.reset(FixedCompilationDatabase::loadFromCommandLine(argc, argv)); cl::ParseCommandLineOptions(argc, argv, Overview); SourcePathList = SourcePaths; if ((OccurrencesFlag == cl::ZeroOrMore || OccurrencesFlag == cl::Optional) && @@ -132,8 +131,12 @@ CommonOptionsParser::CommonOptionsParser( Compilations = CompilationDatabase::autoDetectFromSource(SourcePaths[0], ErrorMessage); } - if (!Compilations) - llvm::report_fatal_error(ErrorMessage); + if (!Compilations) { + llvm::errs() << "Error while trying to load a compilation database:\n" + << ErrorMessage << "Running without flags.\n"; + Compilations.reset( + new FixedCompilationDatabase(".", std::vector())); + } } auto AdjustingCompilations = llvm::make_unique(