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

Jonas Toth via cfe-dev cfe-dev at lists.llvm.org
Fri Dec 28 08:15:46 PST 2018


Hi,

did you try something similar to `// RUN: clang-tidy -checks='-*,
abseil-no-namespace' -header-filter='.*' %s -- -I %S/Inputs 2>&1 |
FileCheck %s`?

This pattern occurs multiple times in the test-framework: `git grep "|
FileCheck" *.cpp` shows quite a view places, maybe there are other
places that are more specific to your requirement?


Best, Jonas

Am 27.12.18 um 01:39 schrieb Richard via cfe-dev:
> 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.



More information about the cfe-dev mailing list