[cfe-dev] Getting source files into the CompilationDatabase interfaces
Aaron Ballman
aaron at aaronballman.com
Wed Nov 6 09:50:27 PST 2013
On Wed, Nov 6, 2013 at 12:34 PM, Manuel Klimek <klimek at google.com> wrote:
> Hi,
>
> as we've seen more use of the compilation database (for example through the
> YCM vim plugin), we noticed that for networked build systems and server
> applications the information we currently expose in the interfaces (path,
> file-name, command line arguments) is not enough - we also need to be able
> to get all source code, which we then can put into clang's VFS to get a
> fully build-system independent clang run over a translation unit.
>
> We think that getting the source information (perhaps optionally) as part of
> a getCompileCommands run is a good fit - a build system always must know how
> to provide the required sources, and as such it seems to be a natural fit.
I think the premise is sound; it's information that's useful, and
something the compilation database can definitely provide.
> I'd propose to change the CompilationDatabase interface
> (tools/clang/include/clang/Tooling/CompilationDatabase.h) to that end, and
> see two possible solutions, which both have different pros and cons:
> 1. Add a map from std::string (file-name) -> std::string (source content) to
> the CompileCommand class (in
> tools/clang/include/clang/Tooling/CompilationDatabase.h); let specific
> CompilationDatabases optionally fill in that information
> 2. Do not modify CompileCommand - instead, add a
> getCompileCommandsAndSources(StringRef FilePath) method that returns a
> vector<pair<CompileCommand, map<string, string>>> which also includes the
> sources; I'm reluctant to split the call into two, as the compile command
> and the sources are tightly coupled (if a user syncs in the background, both
> tend to change at the same time)
Can we have a bit more information about these two options? I think I
may be a bit confused. Option #1 sounds like it maps a file name to
the file contents. But I can't seem to make heads or tails of what
the input and outputs are for Option #2.
Thanks!
~Aaron
More information about the cfe-dev
mailing list