Closed Bug 529382 Opened 15 years ago Closed 4 years ago

Warn when side-effecty-looking expressions are buried in NS_ASSERTION()/NS_ABORT_IF_FALSE() et al.

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: cjones, Unassigned)

References

Details

I just found a stupid bug in some of my code where I wrote Var importantValue; NS_ABORT_IF_FALSE(!GetImportValue(&importantValue)); It'd be cool if I could get a warning when I do stupid things like this. There are a couple of complications: (1) Definition of "side-effecty." Some debug checks, like NS_ASSERT(!!ptr), end up making method calls to smart pointers, which look side-effecty but should be ignored. These would probably need to be special-cased. (2) SanityCheck()-type methods, e.g. NS_ASSERT(SanityCheck()). Personally I prefer a conditionally-compiled |AssertSanity()|-type method instead, so I would be perfectly happy with a warning for this case. Not sure how prevalent this pattern is though.
yeah we need a similar check for other macros too. I think what we want is a must_be_pure() marker on code and pure annotations on various methods that are pure enough
Product: Core → Firefox Build System

Our current static-analysis infra has a check for this.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WORKSFORME
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.