Author: klimek
Date: Thu Dec  3 04:38:53 2015
New Revision: 254599

URL: http://llvm.org/viewvc/llvm-project?rev=254599&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Tooling/CommonOptionsParser.cpp

Modified: cfe/trunk/lib/Tooling/CommonOptionsParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CommonOptionsParser.cpp?rev=254599&r1=254598&r2=254599&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/CommonOptionsParser.cpp (original)
+++ cfe/trunk/lib/Tooling/CommonOptionsParser.cpp Thu Dec  3 04:38:53 2015
@@ -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<std::string>()));
+    }
   }
   auto AdjustingCompilations =
       llvm::make_unique<ArgumentsAdjustingCompilations>(


_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to