<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi,<br>
Is there a way to find the parent expression given an expression? Say I
have an instance of ObjCMessageExpr and<br>
want to find out if it's part of a declaration (DeclStmt) or an
statement by itself. Is there any facility to do that?<br>
<br>
<br>
Thanks.<br>
<br>
rajesh<br>
<br>
<br>
Ted Kremenek wrote:
<blockquote cite="mid:0621FB8D-421D-4501-8A46-29D65B7E00F5@apple.com"
type="cite">
<pre wrap="">On Jul 29, 2008, at 8:11 AM, Rajesh Karmani wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,
I have just started looking at Clang and found it to be a great tool.
I also came across the RewriteObjc module and wanted to play around
with
how the Objective-C messages are "rewritten".
I have not been able to figure out how an assignment statement like:
c = [obj execute];
is parsed in Clang (what functions are called?). I would like to
rewrite
such statements differently from
[obj execute];
where nothing is being returned. Could someone please guide me which
parts of code should I be looking at?
</pre>
</blockquote>
<pre wrap=""><!---->
Hi Rajesh,
In general, an excellent way to figure out the structure of the ASTs
is to use the --ast-dump option:
clang --ast-dump myfile.m
For example:
void f(NSObject *m) {
NSObject* c = [m execute];
}
becomes:
void f(NSObject *m)
(CompoundStmt 0x2372060 <<stdin>:3:21, line:5:1>
(DeclStmt 0x2371ff0 <line:4:3>
0x2371fa0 "NSObject *c =
(ImplicitCastExpr 0x236c030 <col:17, col:27> 'NSObject *'
(ObjCMessageExpr 0x2372010 <col:17, col:27> 'id':'struct
objc_object *' selector=execute
(DeclRefExpr 0x2371fd0 <col:18> 'NSObject *' ParmVar='m'
0x23712b0)))")
Note that assignments and variable declarations are different.
Assignments are represented using BinaryOperator, while variable
declarations are represented using DeclStmt.
Ted
</pre>
</blockquote>
</body>
</html>