[cfe-dev] Getting information from MemRegion
Rui Paulo
rpaulo at apple.com
Tue Jun 7 17:11:16 PDT 2011
On Jun 7, 2011, at 1:37 PM, Jordy Rose wrote:
> Unfortunately, the analyzer runs well after the preprocessor does, so while you could probably reconstruct some of this information, it's probably more trouble than it's worth. You also won't necessarily be able to handle cases like
>
> lock(*foo);
>
> which the static analyzer can track (at least in theory). On the other hand, the simple example you gave *should* work anyway; unless lockR is already NULL, it should be a VarRegion whether or not it passes through a macro.
Yes, I guess my example was bad.
> As a debugging aid, you can use MemRegion::dump() to print a description of the region. If you're printing for diagnostics, there are a few examples of "SummarizeRegion" methods among the checkers (which should probably be unified in the general CheckerHelpers.h file at some point). And to actually track data, you probably want to look at the existing PthreadLockChecker, which just associates 'locked' or 'unlocked' states with regions. (Think about 'locks[3]' or 'criticalData->lock', which would have other types of MemRegions.)
I'm actually working on the PthreadLockChecker. I need to write code to print useful warning messages. I'll look at SummarizeRegion.
Thanks,
--
Rui Paulo
More information about the cfe-dev
mailing list