[cfe-dev] Fwd: Running Clang-Tidy on a Large Project

Ahmad Nouralizadeh via cfe-dev cfe-dev at lists.llvm.org
Fri Jul 20 10:56:25 PDT 2018


I revised the compile commands database. But there is still problem with
header files. Their path is relative in yaml file. I will try to change
clang-tidy source code in order to fix the problem.

On Fri, Jul 20, 2018 at 7:59 PM, Ahmad Nouralizadeh <
ahmadnouralizadeh at gmail.com> wrote:

> Many Thanks! You helped me pinpoint the problem.
> The problem is with the compile commands database. In fact, clang-tidy
> expects the database format to be a little bit restricted (which is the
> real cause of the problem). The input paths to build commands in MPlayer
> are all relative (determined by the Makefile) as can be seen here:
> ...
>             "-I/usr/local/lib/clang/3.9.0/include/",
>             "-fpie",
>             "-DPIC",
>             "-D_REENTRANT",
>             "-DZLIB_CONST",
>             "-o",
>             "libavformat/cafdec.o",
>             "libavformat/cafdec.c"
>         ],
>         "directory": "/home/ahmad/Programs/MPlayer-1.3.0/ffmpeg",
>         "file": "/home/ahmad/Programs/MPlayer-1.3.0/ffmpeg/libavformat/
> cafdec.c"
> ...
> This is part of the commands database generated using Bear with the file
> entry revised to be absolute (I did that). The problem is still there.
> Because the last two lines of the compile command arguments are relative
> paths:
> "libavformat/cafdec.o"
> "libavformat/cafdec.c"
> which should be changed to:
> "/home/ahmad/Programs/MPlayer-1.3.0/ffmpeg/libavformat/cafdec.o"
> "/home/ahmad/Programs/MPlayer-1.3.0/ffmpeg/libavformat/cafdec.c"
> It seems that the fastest way to fix the problem is to postprocess the
> commands database and make all paths absolute.
>
>
> On Fri, Jul 20, 2018 at 11:53 AM, Miklos Vajna <vmiklos at vmiklos.hu> wrote:
>
>> Hi,
>>
>> On Thu, Jul 19, 2018 at 11:04:21PM +0430, Ahmad Nouralizadeh <
>> ahmadnouralizadeh at gmail.com> wrote:
>> > path is recreated in that case. It can be seen at
>> "clang-extra-tools-source/
>> > clang-tidy/ClangTidy.cpp:line131" (clang-extra-tools-6.0.0):
>> > ...
>> >
>> > SmallString<128> FixAbsoluteFilePath = Repl.getFilePath();
>> >
>> > Files.makeAbsolutePath(FixAbsoluteFilePath);
>> > ...
>> > But the same operation is not performed when the information is
>> exported to
>> > yaml, which is done when I run "run-clang-tidy" script with "-fix"
>> option.
>>
>> Sounds like if you submit a patch to fix this, it would makes sense. (I
>> haven't tried run-clang-tidy with -fix myself; what I usually do is
>> invoking clang-tidy directly with -export-fixes=, then
>> clang-apply-replacements, but in theory this is the same.)
>>
>> Perhaps the reason why nobody hit this before is the usage of relative
>> paths; I think cmake just writes absolute paths in the compile commands
>> db, so you don't hit the codepath where making the paths absolute
>> matters.
>>
>> Regards,
>>
>> Miklos
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180720/8f6b662e/attachment.html>


More information about the cfe-dev mailing list