<div dir="ltr">This looks like <a href="http://llvm.org/PR22385">http://llvm.org/PR22385</a>, and it looks like we need to store absolute path in ClangTidyError and tooling:Replacement (or maybe both relative and absolute path, as I suspect that we need the former too).<div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 20, 2015 at 11:31 AM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><a href="mailto:alexfh@google.com" target="_blank">+Alexander Kornienko</a> <br><div><div class="h5"><br><div class="gmail_quote">On Fri Feb 20 2015 at 12:18:49 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">+Sam who's been doing a fair bit with clang-tidy recently (Sam, feel free to add Manuel, Daniel, whomever else might be more appropriate if you prefer)<div class="gmail_extra"><br><div class="gmail_quote"></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Feb 19, 2015 at 2:57 PM, Johann Klähn <span dir="ltr"><<a href="mailto:kljohann@gmail.com" target="_blank">kljohann@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">clang-tidy seems to have problems with relative paths in command lines<br>
in compile_commands.json.<br>
<br>
Consider the following case:<br>
<br>
$ cat > test.cpp<br>
int main(int argc, char* argv[]) {<br>
    return 0;<br>
}<br>
$ cat > compile_commands.json<br>
[<br>
{<br>
  "directory": "/home/kljohann/test/build",<br>
  "command": "/usr/bin/clang++ -Wunused-parameter -o test.cpp.o -c ../test.cpp",<br>
  "file": "/home/kljohann/test/test.cpp"<br>
}<br>
]<br>
$ mkdir build<br>
$ clang-tidy test.cpp<br>
2 warnings generated.<br>
clang-tidy: ../tools/clang/lib/Basic/SourceManager.cpp:422: const<br>
clang::SrcMgr::ContentCache*<br>
clang::SourceManager::getOrCreateContentCache(const clang::FileEntry*,<br>
bool): Assertion `FileEnt && "Didn't specify a file entry to use?"'<br>
failed.<br>
[1]    23129 abort      clang-tidy test.cpp<br>
<br>
My guess is the following: In ClangTool::run we chdir() into the<br>
"directory" that is specified in compile_commands.json. Then, the<br>
relative file name is stored in ClangTidyMessage (I checked that this<br>
is the case using gdb). Eventually handleErrors() is called, but by<br>
then we already chdired back and thus in ErrorReporter::getLocation<br>
  const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);<br>
is a null pointer (checked using gdb).<br>
On the other hand this is my first venture into the clang source code,<br>
so I may very well be wrong. I hope you can reproduce this bug.<br></blockquote></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br>Yeah, I can reproduce this. I know little about clang-tidy and what the expected behavior is here - certainly crashing isn't ideal, but even beyond that I'm not sure if the assumption is taht all the paths in the compile commands database will be absolute, or relative to some specific place, etc.<br><br>The CMake compilation database support seems to create databases with all absolute paths so I imagine this doesn't come up there.</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br><br>- David<br> </div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
All the best,<br>
Johann<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">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>
</blockquote></div></div></div>
______________________________<u></u>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">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/<u></u>mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div></div></div>
</blockquote></div><br>
</div></div>