[PATCH] D7375: [clang-tidy] Assert related checkers

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 13 05:47:23 PST 2017

lebedev.ri added inline comments.
Herald added a subscriber: mgorny.

Comment at: test/clang-tidy/misc-static-assert.cpp:71
+  assert(ZERO_MACRO && "Report me!");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
Hmm. Are you sure about this?
I'm having false-positives (as far i'm concerned at least) due to this.

In particular with `<sanitizer/asan_interface.h>`. If the build is with asan,
then i can include the header and use e.g. `__asan_region_is_poisoned()`
But if it is not, i can't do that. So i need to wrap it into a macro, which expands
to `__asan_region_is_poisoned()` if the build is with asan, and to some constant
(e.g. `0`) otherwise. And the check, naturally, does not like this.

As a minimal reproducer:
#ifndef MYDEFINE
#define mycheck(x) 0
#define notmycheck(x) 1
int __mycheck(int x);
int __notmycheck(int x);
#define mycheck(x) __mycheck(x)
#define notmycheck(x) __notmycheck(x)

void f(int x) {
I'd expect the check to not warn regardless of `MYDEFINE` presence.


More information about the cfe-commits mailing list