File tree 3 files changed +42
-1
lines changed
3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ package Clang.Extensions is
45
45
function Get_Var_Init_Expr (C : Cursor_T) return Cursor_T
46
46
with Import, Convention => C, External_Name => " clang_getVarInitExpr" ;
47
47
48
+ function Get_For_Range_Expr (C : Cursor_T) return Cursor_T
49
+ with Import, Convention => C, External_Name => " clang_getForRangeExpr" ;
50
+
48
51
function Get_Then (C : Cursor_T) return Cursor_T
49
52
with Import, Convention => C, External_Name => " clang_getThen" ;
50
53
Original file line number Diff line number Diff line change @@ -169,12 +169,31 @@ clang_getForInit (CXCursor C)
169
169
{
170
170
case Stmt::ForStmtClass:
171
171
return MakeCXCursorWithNull (cast<ForStmt> (S)->getInit (), C);
172
+ case Stmt::CXXForRangeStmtClass:
173
+ return MakeCXCursorWithNull (cast<CXXForRangeStmt> (S)->getInit (),
174
+ C);
172
175
default :
173
176
return clang_getNullCursor ();
174
177
}
175
178
return clang_getNullCursor ();
176
179
}
177
180
181
+ extern " C" CXCursor
182
+ clang_getForRangeExpr (CXCursor C)
183
+ {
184
+ const Stmt *stmt;
185
+ const CXXForRangeStmt *for_stmt;
186
+
187
+ if (clang_isStatement (C.kind )
188
+ && (stmt = cxcursor::getCursorStmt (C))
189
+ && stmt->getStmtClass () == Stmt::CXXForRangeStmtClass)
190
+ {
191
+ for_stmt = cast<CXXForRangeStmt> (stmt);
192
+ return MakeCXCursorWithNull (for_stmt->getRangeInit (), C);
193
+ }
194
+ return clang_getNullCursor ();
195
+ }
196
+
178
197
extern " C" CXCursor
179
198
clang_getForInc (CXCursor C)
180
199
{
Original file line number Diff line number Diff line change @@ -1999,9 +1999,28 @@ package body Instrument.C is
1999
1999
2000
2000
when Cursor_CXX_For_Range_Stmt =>
2001
2001
declare
2002
- For_Body : constant Cursor_T := Get_Body (N);
2002
+ For_Init_Stmt : constant Cursor_T := Get_For_Init (N);
2003
+ For_Range_Decl : constant Cursor_T := Get_For_Range_Expr (N);
2004
+ For_Body : constant Cursor_T := Get_Body (N);
2003
2005
begin
2006
+ -- Generate SCO statements for both the init statement and
2007
+ -- the range declaration initialization expression. Like all
2008
+ -- statements, they can contain nested decisions.
2009
+
2010
+ Extend_Statement_Sequence
2011
+ (For_Init_Stmt, ' ' , Insertion_N => N);
2012
+ Process_Decisions_Defer (For_Init_Stmt, ' X' );
2013
+
2014
+ Extend_Statement_Sequence
2015
+ (For_Range_Decl, ' ' ,
2016
+ Insertion_N => For_Range_Decl,
2017
+ Instr_Scheme => Instr_Expr);
2018
+ Process_Decisions_Defer (For_Range_Decl, ' X' );
2019
+
2004
2020
Set_Statement_Entry;
2021
+
2022
+ -- Generate obligations for body statements
2023
+
2005
2024
UIC.Pass.Curlify (N => For_Body, Rew => UIC.Rewriter);
2006
2025
Traverse_Statements
2007
2026
(IC, UIC,
You can’t perform that action at this time.
0 commit comments