How do clang tools handle input like '/path/to/files/*.c'?

Hi,

I am studying Clang for an academic project. I am using Clang from Windows. I was able to build it with MSVS 2013. I am using MinGW and msys shell to run the Clang tools from the command line.

As a trial, I gave a path input to clang-tidy tool -

clang-tidy …//*.cpp -checks=“readability-braces-around-statements” –

It is interesting that the tool was able to handle this without compilation database (Note --).

To see how this input is handled by ‘CommonOptionsParser’, I gave the same input through Visual Studio debugger in my clang build. However, the tool throws an error for the argument ‘/path/*.cpp’.

In general, how do clang tools handle such ‘SourcePath’ input?

Is it possible to run a clang tool on all files in a directory by using FixedCompilationDatabase? (It returns nullptr for getAllFiles())

In Windows, I have to manually write the compile_commands.json file, which is an additional task for huge source code.

Any suggestions / guidance is appreciated.

Thanks,

Pradnya

Hi,

I am studying Clang for an academic project. I am using Clang from
Windows. I was able to build it with MSVS 2013. I am using MinGW and msys
shell to run the Clang tools from the command line.

As a trial, I gave a path input to clang-tidy tool -

clang-tidy ../<path>/*.cpp -checks="readability-braces-around-statements"
--

It is interesting that the tool was able to handle this without
compilation database (Note --).

To see how this input is handled by 'CommonOptionsParser', I gave the same
input through Visual Studio debugger in my clang build. However, the tool
throws an error for the argument '/path/*.cpp'.

In general, how do clang tools handle such 'SourcePath' input?

The difference between the above two scenarios is probably the msys shell
-- when a unix-like shell processes a command with wildcards in an
argument, it performs path expansion on that argument (looking up files
matching the pattern and converting the argument into a sequence of
filenames). When you give the same wildcard pattern directly to the tool's
argv, this will not typically happen.

Answering multiple people inline :slight_smile:

Yep.

No.

Which build system are you using? The Visual Studio one? I think it has xml files, which you could parse with python to generate the compile_commands.json?

Richard,

Thank you for your prompt reply!

Manuel,

Thank you for the confirmation!

Yes, I am using the Visual Studio build. Can you please elaborate on the the compilation database generation with Python? Are you referring to the xml files in ‘llvm\Utils’?

Regards,

Pradnya

Richard,

Thank you for your prompt reply!

Manuel,

Thank you for the confirmation!

Yes, I am using the Visual Studio build. Can you please elaborate on the the compilation database generation with Python? Are you referring to the xml files in ‘llvm\Utils’?

No, I mean parsing the Visual Studio project description files…