<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Apr 22, 2014 at 2:35 AM, Alastair Rankine <span dir="ltr"><<a href="mailto:alastair@girtby.net" target="_blank">alastair@girtby.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div class="">On Apr 17, 2014, at 8:25 PM, Michael Bolin <<a href="mailto:bolinfest@gmail.com" target="_blank">bolinfest@gmail.com</a>> wrote:<br>
<div><br><blockquote type="cite"><div dir="ltr">I am looking at the docs for the CompilationDatabase (<a href="http://clang.llvm.org/doxygen/group__COMPILATIONDB.html" target="_blank">http://clang.llvm.org/doxygen/group__COMPILATIONDB.html</a>), which I am creating via a compile_commands.json file.<div>

<br></div><div>It looks like I can dump all of the entries via clang_CompilationDatabase_getAllCompileCommands(), and for each entry, I can get its directory and its command, but not the file itself? Is this deliberate, or just something that has not been implemented yet?</div>

</div></blockquote><br></div></div><div>I'm not an expert but the comments for getCompileCommands look relevant:</div><div><br></div><div><div>  /// \brief Returns all compile commands in which the specified file was</div>
<div>  /// compiled.</div><div>  ///</div><div>  /// This includes compile comamnds that span multiple source files.</div><div>  /// For example, consider a project with the following compilations:</div><div>  /// $ clang++ -o test <a href="http://a.cc" target="_blank">a.cc</a> <a href="http://b.cc" target="_blank">b.cc</a> <a href="http://t.cc" target="_blank">t.cc</a></div>
<div>  /// $ clang++ -o production <a href="http://a.cc" target="_blank">a.cc</a> <a href="http://b.cc" target="_blank">b.cc</a> -DPRODUCTION</div><div>  /// A compilation database representing the project would return both command</div>
<div>  /// lines for <a href="http://a.cc" target="_blank">a.cc</a> and <a href="http://b.cc" target="_blank">b.cc</a> and only the first command line for <a href="http://t.cc" target="_blank">t.cc</a>.</div><div>  virtual std::vector<CompileCommand> getCompileCommands(</div>
<div>    StringRef FilePath) const = 0;</div><div><br></div></div><div>In other words, it seems that what you want is not possible, by design.</div><div><br></div><div>As an alternative you could iterate through all of the source files returned by getAllFiles(), and for each one call getCompileCommands(). Note that this should be relatively efficient due to the use of a string map in the JSONCompilationDatabase.</div>
</div></blockquote><div><br></div><div>+1. Problem is that getAllFiles seems to be missing from the libclang interface...</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><br></div><div>HTH,</div></div><br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>