[cfe-commits] r46109 - in /cfe/trunk: AST/Decl.cpp Sema/SemaExpr.cpp include/clang/AST/DeclObjC.h

Fariborz Jahanian fjahanian at apple.com
Thu Jan 17 09:06:05 PST 2008


On Jan 17, 2008, at 6:54 AM, Steve Naroff wrote:

>
> On Jan 16, 2008, at 5:36 PM, Fariborz Jahanian wrote:
>
>> Author: fjahanian
>> Date: Wed Jan 16 19:36:09 2008
>> New Revision: 46109
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=46109&view=rev
>> Log:
>> Computed length of a __func__ identifier used in an objective-c  
>> method correctly,
>> when creating its type.
>>
>> Modified:
>>   cfe/trunk/AST/Decl.cpp
>>   cfe/trunk/Sema/SemaExpr.cpp
>>   cfe/trunk/include/clang/AST/DeclObjC.h
>>
>> Modified: cfe/trunk/AST/Decl.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Decl.cpp?rev=46109&r1=46108&r2=46109&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- cfe/trunk/AST/Decl.cpp (original)
>> +++ cfe/trunk/AST/Decl.cpp Wed Jan 16 19:36:09 2008
>> @@ -549,6 +549,15 @@
>>  return NULL;
>> }
>>
>> +int ObjCMethodDecl::getSynthesizedSelectorSize() const {
>> +  // syntesized method name is a concatenation of -/+[class-name  
>> selector]
>> +  // Get length of this name.
>> +  int length = 4;  // for '+' or '-', '[', space in between and ']'
>> +  length += getSelector().getName().size(); // for selector name.
>> +  length += strlen(getMethodContext()->getName()); // for its  
>> class name
>> +  return length;
>> +}
>> +
>
> Naming nit...
>
> I think a better name for this routine is getSynthesizedMethodSize  
> (since it encodes much more info than a selector).

Good name, I will use it. BTW, I did something stupid. I computed size  
of gcc's encoding of the method name and *not* clang's rewriter :) :).

Patch will be coming up shortly.

- Fariborz

>
>
> snaroff
>
>>
>> ObjCInterfaceDecl *const ObjCMethodDecl::getClassInterface() const {
>>  if (ObjCInterfaceDecl *ID =  
>> dyn_cast<ObjCInterfaceDecl>(MethodContext))
>>    return ID;
>>
>> Modified: cfe/trunk/Sema/SemaExpr.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=46109&r1=46108&r2=46109&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- cfe/trunk/Sema/SemaExpr.cpp (original)
>> +++ cfe/trunk/Sema/SemaExpr.cpp Wed Jan 16 19:36:09 2008
>> @@ -131,7 +131,7 @@
>>  if (CurFunctionDecl)
>>    Length = CurFunctionDecl->getIdentifier()->getLength();
>>  else
>> -    Length = CurMethodDecl->getSelector().getName().size();
>> +    Length = CurMethodDecl->getSynthesizedSelectorSize();
>>
>>  llvm::APInt LengthI(32, Length + 1);
>>  QualType ResTy = Context.CharTy.getQualifiedType(QualType::Const);
>>
>> Modified: cfe/trunk/include/clang/AST/DeclObjC.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=46109&r1=46108&r2=46109&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- cfe/trunk/include/clang/AST/DeclObjC.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Jan 16 19:36:09 2008
>> @@ -116,6 +116,7 @@
>>  ObjCInterfaceDecl *const getClassInterface() const;
>>
>>  Selector getSelector() const { return SelName; }
>> +  int getSynthesizedSelectorSize() const;
>>  QualType getResultType() const { return MethodDeclType; }
>>
>>  // Iterator access to formal parameters.
>>
>>
>> _______________________________________________
>> 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