Allow tools to work without compilation database

2015-12-02 Thread Russell Wallace via cfe-commits
Per discussion at
http://lists.llvm.org/pipermail/cfe-dev/2015-December/046321.html allow
tools to work in the absence of a compilation database, but warn the user
about the absence.
Index: lib/Tooling/CommonOptionsParser.cpp
===
--- lib/Tooling/CommonOptionsParser.cpp (revision 254518)
+++ lib/Tooling/CommonOptionsParser.cpp (working copy)
@@ -116,8 +116,7 @@
 
   cl::HideUnrelatedOptions(Category);
 
-  Compilations.reset(FixedCompilationDatabase::loadFromCommandLine(argc,
-   argv));
+  Compilations.reset(FixedCompilationDatabase::loadFromCommandLine(argc, 
argv));
   cl::ParseCommandLineOptions(argc, argv, Overview);
   SourcePathList = SourcePaths;
   if (!Compilations) {
@@ -129,8 +128,13 @@
   Compilations = CompilationDatabase::autoDetectFromSource(SourcePaths[0],
ErrorMessage);
 }
-if (!Compilations)
-  llvm::report_fatal_error(ErrorMessage);
+if (!Compilations) {
+  errs() << "Compilation database not found - using default options\n";
+  int argc = 1;
+  const char *argv[] = {"--"};
+  Compilations.reset(
+  FixedCompilationDatabase::loadFromCommandLine(argc, argv));
+}
   }
   auto AdjustingCompilations =
   llvm::make_unique(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: Allow tools to work without compilation database

2015-12-03 Thread Russell Wallace via cfe-commits
Okay - I don't understand how the class works well enough to be certain
that will do the same thing, but if you do, I've no problem taking your
word for it. Should I resend the patch with that change?

On Thu, Dec 3, 2015 at 9:56 AM, Manuel Klimek  wrote:

> -if (!Compilations)
> -  llvm::report_fatal_error(ErrorMessage);
> +if (!Compilations) {
> +  errs() << "Compilation database not found - using default options\n";
> +  int argc = 1;
> +  const char *argv[] = {"--"};
> +  Compilations.reset(
> +  FixedCompilationDatabase::loadFromCommandLine(argc, argv));
>
>
> Just Compilations.reset(new FixedCompilationDatabase(".",
> std::vector()))?
>
> On Thu, Dec 3, 2015 at 8:51 AM Russell Wallace via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Per discussion at
>> http://lists.llvm.org/pipermail/cfe-dev/2015-December/046321.html allow
>> tools to work in the absence of a compilation database, but warn the user
>> about the absence.
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits