[cfe-commits] r77351 - in /cfe/trunk: lib/CodeGen/CGCXX.cpp lib/CodeGen/CGExpr.cpp test/CodeGenCXX/constructor-init.cpp

Fariborz Jahanian fjahanian at apple.com
Tue Jul 28 15:53:13 PDT 2009


On Jul 28, 2009, at 3:47 PM, Chris Lattner wrote:

>
> On Jul 28, 2009, at 3:46 PM, Fariborz Jahanian wrote:
>
>>>>
>>>> +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Tue Jul 28 13:54:57 2009
>>>> @@ -168,16 +168,23 @@
>>>> getContext().getASTRecordLayout(ClassDecl);
>>>> llvm::Type *I8Ptr =  
>>>> VMContext.getPointerTypeUnqual(llvm::Type::Int8Ty);
>>>> unsigned Idx = 0;
>>>> +  bool DerivedToBaseConversion = false;
>>>> for (CXXRecordDecl::base_class_const_iterator i =
>>>>       ClassDecl->bases_begin(),
>>>>       e = ClassDecl->bases_end(); i != e; ++i, ++Idx) {
>>>>  if (!i->isVirtual()) {
>>>>      const CXXRecordDecl *Base =
>>>>      cast<CXXRecordDecl>(i->getType()->getAsRecordType()- 
>>>> >getDecl());
>>>> -        if (Base == BaseClassDecl)
>>>> -          break;
>>>> +      if (Base == BaseClassDecl) {
>>>> +        DerivedToBaseConversion = true;
>>>> +        break;
>>>> +      }
>>>>  }
>>>> }
>>>
>>> Can you convert this loop to be a static function instead?   
>>> Justification here:
>>> http://llvm.org/docs/CodingStandards.html#hl_predicateloops
>>
>> This code will all likelihood change when Anders has the type  
>> layout change done.
>> Base class offset calculation is based on the current layout and  
>> will be replaced soon.
>
> This code seems like a generally useful predicate.  Isn't there  
> other places in the compiler that compute the same thing?
I don;t know at this time. Note that loop also computes index into the  
Offset table for a given base class. So, it does other things.
In any case, I will make sure that this loop, in whatever form it will  
be, will go into a static function.

- fariborz

>
>
> -Chris




More information about the cfe-commits mailing list