[cfe-dev] Return type of statement

steve naroff snaroff at apple.com
Tue Jan 6 13:50:24 PST 2009


On Jan 6, 2009, at 3:36 PM, Alexei Svitkine wrote:

> Thanks for info.
>
> I'm now getting a crash in getAsString() on the Expr's type:
>
> if (clang::Expr *E = dyn_cast<clang::Expr>(S)) {
>  std::cout << "Type: '" << E->getType().getAsString() << "'\n";
> }
>
> GDB prints:
>
> Program received signal EXC_BAD_ACCESS, Could not access memory.
> Reason: KERN_INVALID_ADDRESS at address: 0xc000000f
> 0x00072d8a in clang::QualType::getAsStringInternal (this=0xbffff758,
> S=@0xbffff754) at Type.cpp:894
> 894	  getTypePtr()->getAsStringInternal(S);
> (gdb) bt
> #0  0x00072d8a in clang::QualType::getAsStringInternal
> (this=0xbffff758, S=@0xbffff754) at Type.cpp:894
> #1  0x000050a8 in clang::QualType::getAsString (this=0xbffff758) at  
> Type.h:168
>
> Am I doing something wrong, or is this a bug I stumbled upon?
>

Hi Alexei,

It's hard to say without seeing the code being analyzed.

The ObjC rewriter uses the "getAsString()" API fairly extensively (so  
if there's a bug, it's not easy to diagnose without seeing the source).

> Also, is there some better way to ask questions I encounter, rather
> than emailing each one? Like some kind of irc chat? (I joined #llvm
> but there didn't seem to be any clang discussion going on there...)
>

I'm not aware of any public IRC chat for clang. I believe the llvm IRC  
is fine for clang related stuff. In this case, however, email works  
fine. You could also submit a bugzilla.

snaroff

> Or is bombarding this list with questions the way to go? :P


> -Alexei
>
> On Mon, Jan 5, 2009 at 11:21 PM, Chris Lattner <clattner at apple.com>  
> wrote:
>>
>> On Jan 5, 2009, at 6:31 PM, Alexei Svitkine wrote:
>>
>>> Thanks for the pointers.
>>>
>>> What's the best way to map from a location in the source to the
>>> corresponding Stmt (and hence Expr if it is exists)?
>>
>> There isn't an efficient way to do it.  You'd have to walk the whole
>> function body and look at the source ranges that each stmt covers,  
>> stopping
>> at the smallest one that covers the point of interest.  You could  
>> do this
>> once and build a location -> stmt mapping of course.  This would be  
>> useful
>> if you do repeated queries (such as having a mouse float over code  
>> etc).
>>
>> -Chris
>>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list