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

Richard via cfe-dev cfe-dev at lists.llvm.org
Wed Dec 26 16:39:10 PST 2018


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?

Thanks.
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
             The Terminals Wiki <http://terminals-wiki.org>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>


More information about the cfe-dev mailing list