clang-tidy how to exclude header from being preprocessed -- NOLINT not working

Greetings!

How to exclude #include-ed header files while running clang-tidy? Tried ‘// NOLINT’ and ‘// NOLINTNEXTLINE’ but it didn’t help!!!

Sample program:

a.h:

01 #include <inc1.h>

02 #include <inc2.h>

03 #include “inc3.h>

// other code

a.c:

01 #include <a.h> // NOLINT

// other code

With above sample, I want to skip tidy-ing a.h and I tried placing ‘// NOLINT’ but tidy is still parsing a.h.

I also tried with ‘// NOLINTNEXTLINE’ but still tidy is considering a.c:01 line and impacts the overall performance.

Thanks,

Greetings!

How to exclude #include-ed header files while running clang-tidy? Tried ‘//
NOLINT’ and ‘// NOLINTNEXTLINE’ but it didn’t help!!!

Sample program:

a.h:

01 #include <inc1.h>

02 #include <inc2.h>

03 #include “inc3.h>

// other code

a.c:

01 #include <a.h> // NOLINT

// other code

With above sample, I want to skip tidy-ing a.h and I tried placing ‘//
NOLINT’ but tidy is still parsing a.h.

It can't not parse it. Are you asking about not issuing diagnostics from it?

I also tried with ‘// NOLINTNEXTLINE’ but still tidy is considering a.c:01
line and impacts the overall performance.

I would guess as per Clang-Tidy — Extra Clang Tools 16.0.0git documentation
you should try using -header-filter=<string>

Thanks,

Roman.

Hello Roman,

With above sample, I want to skip tidy-ing a.h and I tried placing ‘//
NOLINT’ but tidy is still parsing a.h.

It can't not parse it. Are you asking about not issuing diagnostics from it?

Yes. I don't want any diagnostics from 'a.h'. Simply put tidy should ignore a.h. How to do that with tidy?

I also tried with ‘// NOLINTNEXTLINE’ but still tidy is considering
a.c:01 line and impacts the overall performance.

I would guess as per Clang-Tidy — Extra Clang Tools 16.0.0git documentation
you should try using -header-filter=<string>

Can you suggest example.
$ clag-tidy -checks="*" -header-filter=".*;-a.h", correct?

Hello Roman,

With above sample, I want to skip tidy-ing a.h and I tried placing ‘//
NOLINT’ but tidy is still parsing a.h.

It can't not parse it. Are you asking about not issuing diagnostics from it?

Yes. I don't want any diagnostics from 'a.h'. Simply put tidy should ignore a.h. How to do that with tidy?

I also tried with ‘// NOLINTNEXTLINE’ but still tidy is considering
a.c:01 line and impacts the overall performance.

I would guess as per Clang-Tidy — Extra Clang Tools 16.0.0git documentation
you should try using -header-filter=<string>

Can you suggest example.
$ clag-tidy -checks="*" -header-filter=".*;-a.h", correct?

Not sure, never needed that.
I would guess the other way around, -header-filter=".*/a.h"
Also be aware that -isystem will suppress the warnings as usual.

<

'// NOLINT' or '// NOLINTNEXTLINE' should work even with '#include' line, correct?

Like:
<code1>
#include "a.h" // NOLINT
</code1>
OR
<code2>
// NOLINTNEXTLINE
#include "a.h"
</code2>