[cfe-dev] How to verify clang-tidy checks applied to headers?

Stephen Kelly via cfe-dev cfe-dev at lists.llvm.org
Thu Dec 27 07:07:02 PST 2018

On 27/12/2018 00:39, Richard via cfe-dev wrote:
> Hi,
> I'm trying to write a test for this bug:
> <https://bugs.llvm.org/show_bug.cgi?id=26332>
> Namely, that clang-tidy check readability-simplify-boolean-expr
> doesn't apply to the user's header files correctly.
> So I wrote a cpp file like this:
> ====
> // RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t
> #include "readability-simplify-bool-expr.h"
> ====
> and I copied readability-simplify-bool-expr.cpp to
> readability-simplify-bool-expr.h to cover all the same cases in a
> header as are covered in a source file.
> However, I encounter two problems.  First, I encounter the complaint
> from %check_clang_tidy that my source file contains no CHECK lines.
> If I add a bogus CHECK-MESSAGES comment to my source file, then I can
> continue, but the check still fails to report messages from the
> included header.
> I tried changing the run line to invoke clang-tidy directly so I could
> specify -header-filter, but that also failed to work.
> I can run clang-tidy manually with -header-filter and get the
> necessary diagnostics, but I need to run this under the test framework
> to verify that the diagnostic described in the bug is missing.
> How can I achieve this?

You probably need to extend the test framework to accept
the -header-filter command line and pass it through.



More information about the cfe-dev mailing list