[cfe-dev] A question on initListExpr() matcher
Farzad Sadeghi via cfe-dev
cfe-dev at lists.llvm.org
Tue Nov 22 14:52:08 PST 2016
Given the code provided below, why do i match each inner InitListExpr twice?
Here's the sample code:
void test14 (void)
{
int arr[3][2] = {{2, 3}, {4, 5}, {6, 7}};
}
This is the AST:
`-FunctionDecl 0x59c09b0 <line:792:1, line:806:1> line:792:6 test14
'void (void)'
`-CompoundStmt 0x59c2768 <line:793:1, line:806:1>
|-DeclStmt 0x59c2330 <line:794:2, col:42>
| `-VarDecl 0x59c1f80 <col:2, col:41> col:6 arr 'int [3][2]' cinit
| `-InitListExpr 0x59c21e8 <col:18, col:41> 'int [3][2]'
| |-InitListExpr 0x59c2240 <col:19, col:24> 'int [2]'
| | |-IntegerLiteral 0x59c1fe0 <col:20> 'int' 2
| | `-IntegerLiteral 0x59c2000 <col:23> 'int' 3
| |-InitListExpr 0x59c2290 <col:27, col:32> 'int [2]'
| | |-IntegerLiteral 0x59c2070 <col:28> 'int' 4
| | `-IntegerLiteral 0x59c2090 <col:31> 'int' 5
| `-InitListExpr 0x59c22e0 <col:35, col:40> 'int [2]'
| |-IntegerLiteral 0x59c2100 <col:36> 'int' 6
| `-IntegerLiteral 0x59c2120 <col:39> 'int' 7
This is the matcher im running on clang-query:
match initListExpr()
And this is the result i get:
Match #1:
/home/bloodstalker/devi/hell2/test/testFuncs1.c:794:18: note: "root" binds here
int arr[3][2] = {{2, 3}, {4, 5}, {6, 7}};
^~~~~~~~~~~~~~~~~~~~~~~~
Match #2:
/home/bloodstalker/devi/hell2/test/testFuncs1.c:794:19: note: "root" binds here
int arr[3][2] = {{2, 3}, {4, 5}, {6, 7}};
^~~~~~
Match #3:
/home/bloodstalker/devi/hell2/test/testFuncs1.c:794:27: note: "root" binds here
int arr[3][2] = {{2, 3}, {4, 5}, {6, 7}};
^~~~~~
Match #4:
/home/bloodstalker/devi/hell2/test/testFuncs1.c:794:35: note: "root" binds here
int arr[3][2] = {{2, 3}, {4, 5}, {6, 7}};
^~~~~~
Match #5:
/home/bloodstalker/devi/hell2/test/testFuncs1.c:794:19: note: "root" binds here
int arr[3][2] = {{2, 3}, {4, 5}, {6, 7}};
^~~~~~
Match #6:
/home/bloodstalker/devi/hell2/test/testFuncs1.c:794:27: note: "root" binds here
int arr[3][2] = {{2, 3}, {4, 5}, {6, 7}};
^~~~~~
Match #7:
/home/bloodstalker/devi/hell2/test/testFuncs1.c:794:35: note: "root" binds here
int arr[3][2] = {{2, 3}, {4, 5}, {6, 7}};
^~~~~~
--
Farzad Sadeghi
More information about the cfe-dev
mailing list