<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Mar 26, 2012, at 7:39 AM, Manuel Klimek <<a href="mailto:klimek@google.com">klimek@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">On Mon, Mar 26, 2012 at 4:26 PM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">
<div style="word-wrap:break-word"><br><div><div><div class="h5"><div>On Mar 26, 2012, at 7:21 AM, Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:</div><br><blockquote type="cite">
<div class="gmail_quote">On Mon, Mar 26, 2012 at 3:56 PM, 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-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">

<div><br>
On Mar 26, 2012, at 4:08 AM, Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:</div></blockquote></div></blockquote></div></div></div><div><div class="im"><blockquote type="cite"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div><br>
>> Then again, when you say "CompilationDatabase", I think of something that I can extract a set { commands, arguments, source file } tuples to be executed.<br>
>> Maybe that's where we are are talking past each other.<br>
><br>
> When I say CompilationDatabase I think of a map<filename, { command,<br>
> arguments, path}>. Does that make sense?<br>
<br>
<br>
</div>Makes sense to me, although of course this could end up being a multimap.<br></blockquote><div><br></div><div>Which is also an interesting design question - at least for refactorings we'll probably want to run over all different command lines the file was compiled with (think: different configurations with different macros enabled). This would lead to a slightly different interface for CompilationDatabase though (returning a list of compile command lines for each target).</div>

</div></blockquote><br></div></div><div>I think it's important for us to support this case in the interface.</div></div></blockquote><div><br></div>Agreed. So something like:<br><br>/// \brief Specifies the working directory and command of a compilation.<br>
struct CompileCommand {<br>  /// \brief The working directory the command was executed from.<br>  std::string Directory;<br><br>  /// \brief The command line that was executed.<br>  std::vector<std::string> CommandLine;<br>
};</div><div class="gmail_quote"><br></div><div class="gmail_quote">class CompilationDatabase {</div><div class="gmail_quote">public:</div><div class="gmail_quote">  /// \brief Returns all compile commands in which the specified file was compiled.</div>
<div class="gmail_quote">  ///</div><div class="gmail_quote">  /// This includes compile commands that span multiple source files.</div><div class="gmail_quote">  /// For example, for a compile command line</div><div class="gmail_quote">
  /// $ clang++ -o test a.cc b.cc t.cc</div><div class="gmail_quote">  /// $ clang++ -o production a.cc b.cc -DPRODUCTION</div><div class="gmail_quote">  /// A compilation database representing the project would return both command lines </div>
<div class="gmail_quote">  /// for a.cc and b.cc and only the first command line for t.cc.</div><div class="gmail_quote">  virtual vector<CompileCommand> getCompileCommands(StringRef FilePath) = 0;</div><div class="gmail_quote">
};</div></blockquote><div><br></div>Sure. Returning vectors is cheap now! ;)</div><div><br><blockquote type="cite"><div class="gmail_quote">Also, I'd like to pull CompilationDatabase into its own header file if that is fine with you.<br></div></blockquote><br></div><div>Yes, please.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">  </span>- Doug</div><br></body></html>