Closed Bug 1802540 Opened 3 years ago Closed 3 years ago

Clang-tidy bogusly claims that "this expression can be simplified using De Morgan's law"

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1804160

People

(Reporter: jseward, Unassigned)

Details

Phabricator URL: https://phabricator.services.mozilla.com/D163112

Quite a lot. I think these claims are all bogus. They are certainly
distracting. Eg:

 MOZ_ASSERT(elemSize >= 1 && elemSize <= 16);
 Lint: clang-tidy
 WARNING: boolean expression can be simplified by DeMorgan's theorem

Looking at this more, all of the complaints occur inside uses of MOZ_ASSERT.
I guess this is because, starting with, eg

MOZ_ASSERT(x == 4 || x == 37)

and given

#define MOZ_ASSERT(_cond) \
    if (!(_cond)) crash(); \

the analyser sees the text after macro-expansion, viz

  if (!(x == 4 || x == 37)) crash();

and I suppose it is right to claim that it could, per de Morgan, be
converted into

  if (x != 4 && x != 37) crash();

even though the complaint is un-actionable.

Maybe tell clang-tidy to not do this analysis inside MOZ_ASSERT et al?
Or just turn this warning off entirely?

Status: NEW → RESOLVED
Closed: 3 years ago
Duplicate of bug: 1804160
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.