Hello Alexey Serbin, Kudu Jenkins, Andrew Wong,

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/15004

to look at the new patch set (#2).

Change subject: clang-tidy: silence pragma-once-outside-header false positives
......................................................................

clang-tidy: silence pragma-once-outside-header false positives

This turned out to be quite the rabbit hole.

The false positives that have been plaguing us since the LLVM 9 upgrade
appear to be due to the '-x c++' flag provided via compile_flags.py. That
causes clang-tidy to treat every file as a C++ source rather than .cpp files
as C++ sources and .h files as C++ headers.

So, how do we convince clang-tidy to properly handle our headers? Removing
'-x c++' and letting Clang's auto-detection go to town doesn't work, as
Clang expects C++ headers to be suffixed with .H, .hh, or .hpp; .h files are
interpreted as C headers, causing issues with C++ includes like <cstdint>.
Passing '-x c++-header' for headers doesn't work as it causes some kind of
issue when Clang loads a compilation database that borks clang-tidy.

Speaking of compilation databases, on a lark I tried using -p (-path in
clang-tidy-diff) to provide a path to the actual compilation database, and
that seems to have done the trick. To get it to work properly I had to
replace the use of -- with -extra-arg in order to pass -DCLANG_TIDY; not
sure why clang-tidy cares about this.

Using the compilation database allows us to fix another long-standing wart:
the static compile_flags.py which is stale with respect to Kudu's actual
preprocessor definitions. The only remaining usage was YouCompleteMe, which
used the static flags if the compilation database didn't exist, but that
seems like a corner case not worth supporting.

Change-Id: If316344dc3c120ff278c9835b8a10aac49fab9b1
---
M .ycm_extra_conf.py
M build-support/clang_tidy_gerrit.py
D build-support/compile_flags.py
3 files changed, 15 insertions(+), 94 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/04/15004/2
--
To view, visit http://gerrit.cloudera.org:8080/15004
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If316344dc3c120ff278c9835b8a10aac49fab9b1
Gerrit-Change-Number: 15004
Gerrit-PatchSet: 2
Gerrit-Owner: Adar Dembo <[email protected]>
Gerrit-Reviewer: Alexey Serbin <[email protected]>
Gerrit-Reviewer: Andrew Wong <[email protected]>
Gerrit-Reviewer: Kudu Jenkins (120)

Reply via email to