As for this patch: I had discussions with Manuel Klimek and Chandler about it before submitting but I failed including cfe-commits in these discussions. Our approach was to get this in first (not changing the behavior for anyone that does not specifically add the -D option) and then turn it into a plugin system (as I tried to formulate in the FIXME) later. I'll start looking into this now and send a plugin design proposal to cfe-dev and cfe-commits.<div>
<br></div><div>As for r160369: I'll have Alex back it out again. A proper design discussion would have prevented this. We'll do better next time!</div><div><br></div><div>Cheers,<br>Daniel</div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Wed, Jul 18, 2012 at 12:30 AM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com" target="_blank">dgregor@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
On Jul 11, 2012, at 12:13 PM, Daniel Jasper <<a href="mailto:djasper@google.com">djasper@google.com</a>> wrote:<br>
<br>
> Author: djasper<br>
> Date: Wed Jul 11 14:13:13 2012<br>
> New Revision: 160061<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=160061&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=160061&view=rev</a><br>
> Log:<br>
> Add a hook to supply a custom CompilationDatabase. To add a custom CompilationDatabase, make it implement findCompilationDatabaseForDirectory in CustomCompilationDatabase.h and set USE_COSTUM_COMPILATION_DATABASE.<br>

<br>
</div>I have the same concerns/complaints about this change as I did for r160369: using -D options as part of the Clang build to drop in new functionality is without precedent in LLVM/Clang (unless I missed something!) and needs to be discussed first. It's a new and *very* different direction from the library-centric approach Clang takes.<br>

<br>
        - Doug<br>
<div class="HOEnZb"><div class="h5"><br>
> Differential Revision: <a href="http://llvm-reviews.chandlerc.com/D4" target="_blank">http://llvm-reviews.chandlerc.com/D4</a><br>
><br>
> Added:<br>
>    cfe/trunk/lib/Tooling/CustomCompilationDatabase.h<br>
> Modified:<br>
>    cfe/trunk/lib/Tooling/CompilationDatabase.cpp<br>
><br>
> Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=160061&r1=160060&r2=160061&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=160061&r1=160060&r2=160061&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)<br>
> +++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Wed Jul 11 14:13:13 2012<br>
> @@ -18,6 +18,10 @@<br>
> #include "llvm/Support/Path.h"<br>
> #include "llvm/Support/system_error.h"<br>
><br>
> +#ifdef USE_CUSTOM_COMPILATION_DATABASE<br>
> +#include "CustomCompilationDatabase.h"<br>
> +#endif<br>
> +<br>
> namespace clang {<br>
> namespace tooling {<br>
><br>
> @@ -124,6 +128,11 @@<br>
><br>
> static CompilationDatabase *<br>
> findCompilationDatabaseFromDirectory(StringRef Directory) {<br>
> +#ifdef USE_CUSTOM_COMPILATION_DATABASE<br>
> +  if (CompilationDatabase *DB =<br>
> +      ::findCompilationDatabaseForDirectory(Directory))<br>
> +    return DB;<br>
> +#endif<br>
>   while (!Directory.empty()) {<br>
>     std::string LoadErrorMessage;<br>
><br>
><br>
> Added: cfe/trunk/lib/Tooling/CustomCompilationDatabase.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CustomCompilationDatabase.h?rev=160061&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CustomCompilationDatabase.h?rev=160061&view=auto</a><br>

> ==============================================================================<br>
> --- cfe/trunk/lib/Tooling/CustomCompilationDatabase.h (added)<br>
> +++ cfe/trunk/lib/Tooling/CustomCompilationDatabase.h Wed Jul 11 14:13:13 2012<br>
> @@ -0,0 +1,37 @@<br>
> +//===--- CustomCompilationDatabase.h --------------------------------------===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +//<br>
> +//  This file contains a hook to supply a custom \c CompilationDatabase<br>
> +//  implementation.<br>
> +//<br>
> +//  The mechanism can be used by IDEs or non-public code bases to integrate with<br>
> +//  their build system. Currently we support statically linking in an<br>
> +//  implementation of \c findCompilationDatabaseForDirectory and enabling it<br>
> +//  with -DUSE_CUSTOM_COMPILATION_DATABASE when compiling the Tooling library.<br>
> +//<br>
> +//  FIXME: The strategy forward is to provide a plugin system that can load<br>
> +//  custom compilation databases and make enabling that a build option.<br>
> +//<br>
> +//===----------------------------------------------------------------------===//<br>
> +<br>
> +#include "llvm/ADT/StringRef.h"<br>
> +<br>
> +namespace clang {<br>
> +namespace tooling {<br>
> +class CompilationDatabase;<br>
> +}<br>
> +}<br>
> +<br>
> +/// \brief Returns a CompilationDatabase for the given \c Directory.<br>
> +///<br>
> +/// \c Directory can be any directory within a project. This methods will<br>
> +/// then try to find compilation database files in \c Directory or any of its<br>
> +/// parents. If a compilation database cannot be found or loaded, returns NULL.<br>
> +clang::tooling::CompilationDatabase *findCompilationDatabaseForDirectory(<br>
> +  llvm::StringRef Directory);<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br>
</div></div></blockquote></div><br></div>