Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent clang-tidy warnings for extern libraries used #89

Open
ClausKlein opened this issue Mar 2, 2021 · 4 comments
Open

prevent clang-tidy warnings for extern libraries used #89

ClausKlein opened this issue Mar 2, 2021 · 4 comments

Comments

@ClausKlein
Copy link
Contributor

i.e. the example use cxxopts which was fetched with CPM.cmake:

builddriver executing: 'run-clang-tidy.py -p build/standalone -checks=-*,modernize-*,misc-*,hicpp-*,cert-*,readability-*,portability-*,performance-*,google-* standalone'
Compilation SUCCEED in 8.628576 seconds
Number of warnings: 238
WarningErrorEntry(path='/Users/clausklein/.cache/CPM/cxxopts/d5c328043c71a6a5670c290d8646b093756db962/include/cxxopts.hpp', lineno='51', severity='warning', message="declaration uses identifier 'CXXOPTS__VERSION_MAJOR', which is a reserved identifier [cert-dcl37-c,cert-dcl51-cpp]", column='9')
WarningErrorEntry(path='/Users/clausklein/.cache/CPM/cxxopts/d5c328043c71a6a5670c290d8646b093756db962/include/cxxopts.hpp', lineno='52', severity='warning', message="declaration uses identifier 'CXXOPTS__VERSION_MINOR', which is a reserved identifier [cert-dcl37-c,cert-dcl51-cpp]", column='9')
WarningErrorEntry(path='/Users/clausklein/.cache/CPM/cxxopts/d5c328043c71a6a5670c290d8646b093756db962/include/cxxopts.hpp', lineno='53', severity='warning', message="declaration uses identifier 'CXXOPTS__VERSION_PATCH', which is a reserved identifier [cert-dcl37-c,cert-dcl51-cpp]", column='9')
WarningErrorEntry(path='/Users/clausklein/.cache/CPM/cxxopts/d5c328043c71a6a5670c290d8646b093756db962/include/cxxopts.hpp', lineno='212', severity='warning', message="use 'using' instead of 'typedef' [modernize-use-using]", column='3')
WarningErrorEntry(path='/Users/clausklein/.cache/CPM/cxxopts/d5c328043c71a6a5670c290d8646b093756db962/include/cxxopts.hpp', lineno='216', severity='warning', message='use a trailing return type for this function [modernize-use-trailing-return-type]', column='3')
WarningErrorEntry(path='/Users/clausklein/.cache/CPM/cxxopts/d5c328043c71a6a5670c290d8646b093756db962/include/cxxopts.hpp', lineno='223', severity='warning', message='use a trailing return type for this function [modernize-use-trailing-return-type]', column='3')
WarningErrorEntry(path='/Users/clausklein/.cache/CPM/cxxopts/d5c328043c71a6a5670c290d8646b093756db962/include/cxxopts.hpp', lineno='230', severity='warning', message='use a trailing return type for this function [modernize-use-trailing-return-type]', column='3')
WarningErrorEntry(path='/Users/clausklein/.cache/CPM/cxxopts/d5c328043c71a6a5670c290d8646b093756db962/include/cxxopts.hpp', lineno='230', severity='warning', message="non-const reference parameter 's', make it const or use a pointer [google-runtime-references]", column='23')
WarningErrorEntry(path='/Users/clausklein/.cache/CPM/cxxopts/d5c328043c71a6a5670c290d8646b093756db962/include/cxxopts.hpp', lineno='230', severity='warning', message="the parameter 'a' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]", column='33')
WarningErrorEntry(path='/Users/clausklein/.cache/CPM/cxxopts/d5c328043c71a6a5670c290d8646b093756db962/include/cxxopts.hpp', lineno='232', severity='warning', message='passing result of std::move() as a const reference argument; no move will actually happen [hicpp-move-const-arg,performance-move-const-arg]', column='21')
# . . .
@ClausKlein
Copy link
Contributor Author

ClausKlein commented Mar 2, 2021

Hint: all headers included with #include<...> and found with -isystem are suppressed by default (at least by gcc and clang compilers)

@ClausKlein
Copy link
Contributor Author

When I change the generated compile_commands.json to:

[
{
  "directory": "/Users/clausklein/Workspace/cpp/ModernCppStarter/build/standalone",
  "command": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DFMT_HEADER_ONLY=1 
-I/Users/clausklein/Workspace/cpp/ModernCppStarter/include -I_deps/greeter-build/PackageProjectInclude 
-I/Users/clausklein/.cache/CPM/fmt/9dd47b889fbf7c876d24be56ca097a884004b789/include 
-isystem /Users/clausklein/.cache/CPM/cxxopts/d5c328043c71a6a5670c290d8646b093756db962/include
-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/include 
-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include 
-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include  
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk 
-std=c++17 -o CMakeFiles/GreeterStandalone.dir/source/main.cpp.o 
-c /Users/clausklein/Workspace/cpp/ModernCppStarter/standalone/source/main.cpp",
  "file": "/Users/clausklein/Workspace/cpp/ModernCppStarter/standalone/source/main.cpp"
}
]

there are no waring about cxxopts code 🥇

@ClausKlein
Copy link
Contributor Author

This fix it temporarily:

perl -i.bak -pe 's#$CPM_SOURCE_CACHE-I#-isystem $1#g' build/install/compile_commands.json
run-clang-tidy.py -p build/install source
# . . .
# no warnings

@ClausKlein
Copy link
Contributor Author

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

No branches or pull requests

1 participant