[cfe-commits] r74408 - in /cfe/trunk: lib/Analysis/CFRefCount.cpp test/Analysis/array-struct.c
Zhongxing Xu
xuzhongxing at gmail.com
Tue Jun 30 19:31:28 PDT 2009
On Wed, Jul 1, 2009 at 3:59 AM, Ted Kremenek<kremenek at apple.com> wrote:
> Hi Zhongxing,
>
> First, I think all of this logic for region invalidation is great.
>
> Second, I think we should start considering placing (some or all of) this
> logic elsewhere, e.g., in StoreManager. This will allow us to separate
> "policy" (when to invalidate) from "action" (invalidation). This seems
> natural as value invalidation seems like the task of StoreManager, and much
> of the control-logic here hopefully won't stay in CFRefCounts.cpp.
That's exactly what I thought.
>
> What do you think? As a part of invalidating regions, checker-specific
> logic may wish to know when a region gets invalidated, e.g., so it can stop
> tracking an object's reference counts, etc. This can probably be done via
> callbacks.
Yes, this should accompany the refactoring of the TransferFuncs and
SValuators. I planned to do this as we do the refactoring.
>
> On Jun 28, 2009, at 6:59 AM, Zhongxing Xu wrote:
>
>> Author: zhongxingxu
>> Date: Sun Jun 28 08:59:24 2009
>> New Revision: 74408
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=74408&view=rev
>> Log:
>> Invalidate a field of struct type by setting its default value to conjured
>> symbol.
>>
>> Modified:
>> cfe/trunk/lib/Analysis/CFRefCount.cpp
>> cfe/trunk/test/Analysis/array-struct.c
>>
>> Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=74408&r1=74407&r2=74408&view=diff
>>
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
>> +++ cfe/trunk/lib/Analysis/CFRefCount.cpp Sun Jun 28 08:59:24 2009
>> @@ -2863,14 +2863,25 @@
>> // For now just handle scalar fields.
>> FieldDecl *FD = *FI;
>> QualType FT = FD->getType();
>> -
>> + const FieldRegion* FR = MRMgr.getFieldRegion(FD, R);
>> +
>> if (Loc::IsLocType(FT) ||
>> (FT->isIntegerType() && FT->isScalarType())) {
>> - const FieldRegion* FR = MRMgr.getFieldRegion(FD, R);
>> -
>> SVal V = ValMgr.getConjuredSymbolVal(*I, FT, Count);
>> state = state->bindLoc(ValMgr.makeLoc(FR), V);
>> - }
>> + }
>> + else if (FT->isStructureType()) {
>> + // set the default value of the struct field to
>> conjured
>> + // symbol. Note that the type of the symbol is
>> irrelavant.
>> + // We cannot use the type of the struct otherwise
>> ValMgr won't
>> + // give us the conjured symbol.
>> + StoreManager& StoreMgr =
>> + Eng.getStateManager().getStoreManager();
>> + SVal V = ValMgr.getConjuredSymbolVal(*I,
>> +
>> Eng.getContext().IntTy,
>> + Count);
>> + state = StoreMgr.setDefaultValue(state, FR, V);
>> + }
>> }
>> } else if (const ArrayType *AT = Ctx.getAsArrayType(T)) {
>> // Set the default value of the array to conjured symbol.
>>
>> Modified: cfe/trunk/test/Analysis/array-struct.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/array-struct.c?rev=74408&r1=74407&r2=74408&view=diff
>>
>>
>> ==============================================================================
>> --- cfe/trunk/test/Analysis/array-struct.c (original)
>> +++ cfe/trunk/test/Analysis/array-struct.c Sun Jun 28 08:59:24 2009
>> @@ -157,3 +157,14 @@
>> void f16(struct s3 *p) {
>> struct s3 a = *((struct s3*) ((char*) &p[0]));
>> }
>> +
>> +void inv(struct s1 *);
>> +
>> +// Invalidate the struct field.
>> +void f17() {
>> + struct s1 t;
>> + int x;
>> + inv(&t);
>> + if (t.e.d)
>> + x = 1;
>> +}
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
More information about the cfe-commits
mailing list