[cfe-commits] r73949 - /cfe/trunk/lib/Analysis/RegionStore.cpp

Ted Kremenek kremenek at apple.com
Tue Jun 23 11:33:54 PDT 2009


Similar comment to my comment for r73946.  Was there a particular  
motivation for this change?  While there is certainly more complexity  
in mass assigning fields to 0, algorithmically it seems like a more  
scalable approach. If the original implementation was too complicated,  
perhaps we just need to find an alternate implementation that is  
easier to reason about.

On Jun 22, 2009, at 10:43 PM, Zhongxing Xu wrote:

> Author: zhongxingxu
> Date: Tue Jun 23 00:43:16 2009
> New Revision: 73949
>
> URL: http://llvm.org/viewvc/llvm-project?rev=73949&view=rev
> Log:
> If the init list is fewer than the struct fields, bind the rest  
> fields to 0
> explicitly. Make 0 value with the field type.
>
> Modified:
>    cfe/trunk/lib/Analysis/RegionStore.cpp
>
> Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=73949&r1=73948&r2=73949&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
> +++ cfe/trunk/lib/Analysis/RegionStore.cpp Tue Jun 23 00:43:16 2009
> @@ -1165,20 +1165,14 @@
>
>   nonloc::CompoundVal& CV = cast<nonloc::CompoundVal>(V);
>   nonloc::CompoundVal::iterator VI = CV.begin(), VE = CV.end();
> -
> -  for (RecordDecl::field_iterator FI = RD->field_begin(getContext()),
> -                                  FE = RD->field_end(getContext());
> +
> +  RecordDecl::field_iterator FI, FE;
> +
> +  for (FI = RD->field_begin(getContext()), FE = RD->field_end 
> (getContext());
>        FI != FE; ++FI, ++VI) {
>
> -    // There may be fewer values than fields only when we are  
> initializing a
> -    // struct decl. In this case, mark the region as having default  
> value.
> -    if (VI == VE) {
> -      // FIXME: We should bind signed/unsigned 0 according to the  
> sign of the
> -      // field type.
> -      const NonLoc& Idx = NonLoc::MakeIntVal(getBasicVals(), 0,  
> false);
> -      state = state->set<RegionDefaultValue>(R, Idx);
> +    if (VI == VE)
>       break;
> -    }
>
>     QualType FTy = (*FI)->getType();
>     FieldRegion* FR = MRMgr.getFieldRegion(*FI, R);
> @@ -1191,6 +1185,17 @@
>       state = BindStruct(state, FR, *VI);
>   }
>
> +  // There may be fewer values in the initialize list than the  
> fields of struct.
> +  while (FI != FE) {
> +    QualType FTy = (*FI)->getType();
> +    if (FTy->isIntegerType()) {
> +      FieldRegion* FR = MRMgr.getFieldRegion(*FI, R);
> +      state = Bind(state, Loc::MakeVal(FR), ValMgr.makeZeroVal(FTy));
> +    }
> +
> +    ++FI;
> +  }
> +
>   return state;
> }
>
>
>
> _______________________________________________
> 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