[cfe-dev] Continuing Adventures with Objective-C

David Chisnall theraven at sucs.org
Fri May 16 10:44:05 PDT 2008


On 16 May 2008, at 18:30, Devang Patel wrote:

> I guess this is moved somewhere else ?

I've moved the Objective-C-specific stuff into CGObjC.cpp.  This  
should make future ObjC-related diffs a bit easier to read.

> Please include these with VLA patch so that it is possible to review  
> VLA support.

Sorry - copy-and-paste error.

>>
>> @@ -908,6 +883,11 @@
>>                                   LHS, RHS, "cmp");
>>     } else {
>>       // Signed integers and pointers.
>> +      const llvm::Type *LHSTy = LHS->getType();
>> +      // Are we comparing pointers to different types?
>> +      if (RHS->getType() != LHSTy) {
>> +        RHS = Builder.CreateBitCast(RHS, LHSTy);
>
> createPointerCast ?

Makes sense.

>> @@ -629,9 +637,11 @@
>
>>
>>   // Handle struct-return functions by passing a pointer to the  
>> location that
>>   // we would like to return into.
>> +  int RealArgStart = 0;
>>   if (hasAggregateLLVMType(ResultType)) {
>>     // Create a temporary alloca to hold the result of the call. :(
>>     Args.push_back(CreateTempAlloca(ConvertType(ResultType)));
>> +    RealArgStart++;
>>     // FIXME: set the stret attribute on the argument.
>>   }
>>
>> @@ -640,7 +650,16 @@
>>
>>     if (!hasAggregateLLVMType(ArgTy)) {
>>       // Scalar argument is passed by-value.
>> -      Args.push_back(EmitScalarExpr(ArgExprs[i]));
>> +      llvm::Value *ArgVal = EmitScalarExpr(ArgExprs[i]);
>> +      const llvm::FunctionType *CalleeTy = cast<llvm::FunctionType>(
>> +          cast<llvm::PointerType>(Callee->getType())- 
>> >getElementType());
>> +      if (i < CalleeTy->getNumParams()) {
>
> use assert instead of this check. Otherwise this part is OK.

I don't believe this should be an assert - i can be greater than the  
number of parameters in a variadic function and this is not an error.   
Variadic parameters do not been implicit casting because they are not  
type-checked.

>> +        const llvm::Type *ArgTy = CalleeTy->getParamType(i +  
>> RealArgStart);
>> +        if (ArgTy && (ArgVal->getType() != ArgTy)) {
>> +          ArgVal = Builder.CreateBitCast(ArgVal, ArgTy);
>> +        }
>> +      }
>> +      Args.push_back(ArgVal);
>>     } else if (ArgTy->isAnyComplexType()) {
>>       // Make a temporary alloca to pass the argument.
>>       llvm::Value *DestMem = CreateTempAlloca(ConvertType(ArgTy));
>
> LLVM and clangs development style prefers small and incremental  
> changes. We are able to introduce big features and huge improvements  
> using this style. If you adhere to this style then it'll be easier  
> for you to make progress faster.

Sorry - I lost track of how big my out-of-tree changes were getting.

David



More information about the cfe-dev mailing list