<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi,<br>
<br>
On 03/18/2014 03:01 PM, Bo Zhao wrote:<br>
</div>
<blockquote cite="mid:BAY172-W7DF22A6B529D5AAF874FFB57C0@phx.gbl"
type="cite">
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style>
<div dir="ltr"><span class="Apple-style-span" style="font-family:
Verdana, Geneva, Helvetica, Arial, sans-serif; font-size:
13px; ">Hi, <br>
I'm new with clang. I want to know how to get loop boundary
form ForStmt. For example, for(int i = 0; i!=10;++i) , I want
to get the value 0 and 10. Then I can use those value in other
template such as intel TBB parallel_for. <br>
<br>
I already know that getCond(),getInit() method, but how to get
the value? <br>
</span></div>
</blockquote>
<br>
I'm not an expert but I'd say that you have to make sure you have
this very type of init and cond in your ForStmt's, <u>as well as
your inc</u>. Then you can try and get the VarDecl's nodes, get
their child, get the BinaryOperator nodes and get their RHS.<br>
<br>
With this code:<br>
int main() {<br>
for(int i = 0; i < 10; ++i) {<br>
}<br>
}<br>
<br>
See an AST-dump like this to help you:<br>
<br>
clang -cc1 -fsyntax-only -ast-dump forstmt.c <br>
TranslationUnitDecl 0x47880c0 <<invalid sloc>><br>
|-TypedefDecl 0x47885c0 <<invalid sloc>> __int128_t
'__int128'<br>
|-TypedefDecl 0x4788620 <<invalid sloc>> __uint128_t
'unsigned __int128'<br>
|-TypedefDecl 0x4788970 <<invalid sloc>>
__builtin_va_list '__va_list_tag [1]'<br>
`-FunctionDecl 0x4788a10 <forstmt.c:1:1, line:4:1> main 'int
()'<br>
`-CompoundStmt 0x4788c78 <line:1:12, line:4:1><br>
`-<b>ForStmt </b>0x4788c38 <line:2:5, line:3:5><br>
|-DeclStmt 0x4788b38 <line:2:9, col:18><br>
| `-<b>VarDecl</b> 0x4788ac0 <col:9, col:17> <b>i</b>
'int'<br>
| `-<b>IntegerLiteral</b> 0x4788b18 <col:17> 'int' <b>0</b><br>
|-<<<NULL>>><br>
|-<b>BinaryOperator</b> 0x4788bb0 <col:20, col:24> 'int'
'<'<br>
| |-ImplicitCastExpr 0x4788b98 <col:20> 'int'
<LValueToRValue><br>
| | `-DeclRefExpr 0x4788b50 <col:20> 'int' lvalue Var
0x4788ac0 'i' 'int'<br>
| `-<b>IntegerLiteral</b> 0x4788b78 <col:24> 'int' <b>10</b><br>
|-UnaryOperator 0x4788c00 <col:28, col:30> 'int' prefix
'++'<br>
| `-DeclRefExpr 0x4788bd8 <col:30> 'int' lvalue Var
0x4788ac0 'i' 'int'<br>
`-CompoundStmt 0x4788c20 <col:33, line:3:5><br>
<br>
<blockquote cite="mid:BAY172-W7DF22A6B529D5AAF874FFB57C0@phx.gbl"
type="cite">
<div dir="ltr"><span class="Apple-style-span" style="font-family:
Verdana, Geneva, Helvetica, Arial, sans-serif; font-size:
13px; "><br>
Thanks.</span> </div>
<pre wrap="">_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Hugues de Lassus Saint-Geniès</pre>
</body>
</html>