[cfe-dev] Lazy bindings

Ted Kremenek kremenek at apple.com
Wed Dec 17 17:53:51 PST 2008


On Dec 17, 2008, at 4:22 AM, Zhongxing Xu wrote:

> Hi Ted,
>
> This is the patch for lazy binding.

Hi Zhongxing,

This is a huge patch, so I'm going to make a few passes over it.   
Overall it looks very good.  I'm wondering if we can break out the  
changes to SymbolManager.[h,cpp] into a separate patch without  
compromising the current functionality of BasicStore.  It would also  
make your changes to RegionStore more isolated.

> * failed C test cases are due to bugs in RemoveDeadBindings(),
> which removes constraints that is still alive. I plan to fix this
> in a later patch. This patch is already messy enough.

Okay.

> * I wish you could help fix failed ObjC test cases, since I have
> no access to the Mac development platform. It'll take some time for me
> to learn basic things.

Sure thing.

> * default value of array and struct regions are not implemented
> yet, because the GDM of the same type of ImmutableMap<const
> Region*, SVal> is already used for region extents.

You can have multiple GDM entries of the same type.  Just use a  
different GDM index and create a different "tag" type.  For example, I  
*believe* that the following should do the trick (this shows two GDM  
entries with the same map type):

typedef llvm::ImmutableMap<SymbolRef, unsigned> MapTy;

// TypeA.
class TypeA {};
static int TypeAIndex = 0;

namespace clang {
   template<>
   struct GRStateTrait<TypeA> : public GRStatePartialTrait< MapTy > {
     static inline void* GDMIndex() { return &TypeAIndex; }
   };
}

// TypeB.
static int TypeBIndex = 0;

namespace clang {
   template<>
   struct GRStateTrait<TypeB> : public GRStatePartialTrait< MapTy > {
     static inline void* GDMIndex() { return &TypeBIndex; }
   };
}

I think this should work.  Basically the type used for GRStateTrait  
used for indexing into the GDM table, and we can subclass  
GRStatePartialTrait to create the rest of the methods.

All of the other uses of the GDM should probably be modified to follow  
this style to avoid any accidental re-uses of the same GDM entries.

>
>
> * Now Bind() methods take and return GRState* because binding could
>   also alter GDM.

Makes sense.

>
>
> * No variables are initialized except those declared with initial
>   values.


Great.



More information about the cfe-dev mailing list