Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Linter issues when including headers in subdirectories #205

Open
diegoferigo opened this issue Apr 4, 2017 · 8 comments
Open

Linter issues when including headers in subdirectories #205

diegoferigo opened this issue Apr 4, 2017 · 8 comments

Comments

@diegoferigo
Copy link

diegoferigo commented Apr 4, 2017

Considering the following directory structure:

.
|-- CMakeLists.txt
|-- Main.cpp
|-- compile_commands.json
|-- FooLib
|   |-- CMakeLists.txt
|   |-- FooLib.h
|   `-- FooLib.cpp
|-- BarLib
|   |-- CMakeLists.txt
|   |-- BarLib.h
|   `-- BarLib.cpp

If BarLib.h contains #include "FooLib.h", and the flag -I/absolute/path/to/FooLib is present in its target entry in compile_commands.json, this atom Atom package generates an error in the BarLib.h file, not finding the FooLib.h header.

Main.cpp instead works as expected, only the subfolders suffer from this problem.

@diegoferigo diegoferigo changed the title Linter issues when including source in subdirectories Linter issues when including headers in subdirectories Apr 4, 2017
@Arcanemagus
Copy link
Member

It should work if you rename build_commands.json to compile_commands.json as stated in the readme.

@diegoferigo
Copy link
Author

diegoferigo commented Apr 4, 2017

Sorry, it was a typo. Its name is already compile_commands.json, I mixed its name and the folder it was inside (build), pardon. I edited the first message accordingly.

@Arcanemagus
Copy link
Member

Okay, attempting to reproduce locally.

@Arcanemagus
Copy link
Member

Hmmm, looks like clang-flags isn't finding anything for that file, could you possibly upload an archive or create a gist of this to make sure I haven't screwed up setting this up?

@diegoferigo
Copy link
Author

diegoferigo commented Apr 5, 2017

I uploaded here an archive with a minimal example. You'll also find the compile_commands.json that was generated by CMake.

Commands:

mkdir build
cd build
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1
cp compile_commands.json ..
make

@diegoferigo
Copy link
Author

diegoferigo commented Jul 13, 2017

@Arcanemagus I updated my setup to clang4, and the problem still persists. I didn't dig much into your code, but so far my limited knowledge about all the clang features didn't allow me to get a working static analyzer in the tarball I uploaded with compile_commands.json support if not executing clang-check or clang-tidy. These two tools provide the -p option, clang --analyze doesn't.

@Jazzz42
Copy link

Jazzz42 commented Sep 30, 2018

I have the same issue. Has anyone resolved it?

@nick-prat
Copy link

compile_commands.json only provides information on the compiler flags/options for source files, not headers as headers aren't processed into translation units, only the source files that include them. This method doesn't make sense to work with header files. I would recommend using the .clang-complete option for global includes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants