r179395 - [analyzer]Print field region even when the base region is not printable

Jordan Rose jordan_rose at apple.com
Fri Apr 12 14:57:42 PDT 2013


>> Oh shoot, CXXBaseObjectRegion is such a region. Here is the test case:
>> 
>> struct Base { int *x; };
>> struct Derived : public Base {};
>> 
>> void test(Derived d) {
>>   d.x = 0;
>>   *d.x = 1;
>> }
>> 
> I don't follow. What is this example demonstrating?

Oops. It was supposed to demonstrate that we can print a CXXBaseObjectRegion by printing nothing, but that's not true; it should print its super-region. Guess it's not related.

>> struct Outer {
>>   struct Inner {
>>     int *p;
>>   } inner;
>> };
>> 
>> void test(Outer *wrapperPtr) {
>>   wrapperPtr->inner.p = 0;
>>   *wrapperPtr->inner.p = 1;
>> }
>> 
> 
> What do we want to print in this case? Options:
> A: "nothing"
> B: "field 'inner' of field 'p'"
> 
> B looks OK, but might get a bit too complex with a lot of nesting.

I think it's simplest to give up and just say "field 'p'" (notice that your example was actually backwards), but I'm not sure if that's easier or harder to implement. More than two fields in a chain will look pretty nasty, though, so it'd be better to stop somewhere…and then 1 is usually an easy number.

Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130412/7d4df049/attachment.html>


More information about the cfe-commits mailing list