[cfe-dev] Weak function pointers (was "SymbolRef and SVal confusion")

Jordan Rose jordan_rose at apple.com
Mon Jan 21 09:48:11 PST 2013


On Jan 20, 2013, at 9:00 , Richard <tarka.t.otter at googlemail.com> wrote:

>>> +
>>> +  void setWeakSymbol(const SymbolExtent *S) {
>>> +    // Only weak functions can have symbols.
>>> +    assert(cast<ValueDecl>(FD)->isWeak());
>>> +    WeakSym = S;
>>> +  }
>> 
>> MemRegions need to be immutable, so the setWeakSymbol() is not going to work.  Can we just have the symbol associated with the FunctionTextRegion when it gets created?
> 
> I would like to do this, but I don't see how it is possible easily. The SymbolExtent requires the FunctionTextRegion in its constructor, and I don't see a nice way to get hold of the SymbolManager in the FunctionTextRegions constructor to create it. Any suggestions here?

My new thought on this is that this should just be created lazily by SValBuilder and that it doesn't even need to live on the region. SValBuilder::getWeakSymbolForRegion, or something like that. 

I'll talk to Anna and Ted about what to rename SymbolExtent and SymbolMetadata to properly include this new usage; if you have any opinions, I'd love to hear them!

SymbolExtent:
- based on the region itself
- does not get invalidated
- live as long as the region is live (in theory)

SymbolMetadata:
- based on the region contents
- is invalidated along with region contents
- live as long as the region is live and some checker is interested

Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130121/68d0e2ee/attachment.html>


More information about the cfe-dev mailing list