[cfe-commits] r101972 - in /cfe/trunk: include/clang/AST/ include/clang/Checker/BugReporter/ lib/AST/ lib/Checker/ lib/CodeGen/ lib/Frontend/ lib/Index/ lib/Sema/ tools/CIndex/

Douglas Gregor dgregor at apple.com
Wed Apr 21 10:13:01 PDT 2010


On Apr 21, 2010, at 10:07 AM, Fariborz Jahanian wrote:

> 
> On Apr 20, 2010, at 5:45 PM, Douglas Gregor wrote:
> 
>> Author: dgregor
>> Date: Tue Apr 20 19:45:42 2010
>> New Revision: 101972
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=101972&view=rev
>> Log:
>> Overhaul the AST representation of Objective-C message send
>> expressions, to improve source-location information, clarify the
>> actual receiver of the message, and pave the way for proper C++
>> support. The ObjCMessageExpr node represents four different kinds of
>> message sends in a single AST node:
>> 
>> 1) Send to a object instance described by an expression (e.g., [x method:5])
>> 2) Send to a class described by the class name (e.g., [NSString method:5])
>> 3) Send to a superclass class (e.g, [super method:5] in class method)
>> 4) Send to a superclass instance (e.g., [super method:5] in instance method)
>> 
>> Previously these four cases where tangled together. Now, they have
>> more distinct representations. Specific changes:
>> 
>> ed Size = sizeof(ObjCMessageExpr) + sizeof(void *) +
>> +    NumArgs * sizeof(Expr *);
> 
> This is really nice work. One minor comment. Isn't it more expressive if you use
> llvm's anonymous union to represent selector/method prototype. I am not
> sure what the overhead would be though.

You mean llvm::PointerUnion? Unfortunately, I can't use it because Selector already uses the low bits of its pointer, so llvm::PointerUnion does not have any space for the discriminating bit.

>  The other comment
> that I have is how does 'Class' or  'id' receivers are represented in the AST (they
> must have or tests would have failed).

Well, you can't message 'Class' or 'id' directly. If we have an expression of type 'Class' or type 'id', then we represent that as an instance message sending to that object. (This is the same representation we had before my refactoring). 

	- Doug



More information about the cfe-commits mailing list