-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for hierarchy when
.ql
files are separate from .cpp
…
… files
- Loading branch information
Showing
22 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
doStmt/doStmtTest.ql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: codeql-code-test | ||
dependencies: | ||
codeql-queries-test: "*" | ||
extractor: cpp | ||
tests: . |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rangeBasedForStmt/rangeBasedForStmtTest.ql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
lockVersion: 1.0.0 | ||
dependencies: {} | ||
compiled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
int get_square(int number = 0) { | ||
return number * number; | ||
} | ||
|
||
int foo1() { | ||
int a = 0; | ||
int b = 100; | ||
do { | ||
do { | ||
a++; | ||
} while (get_square(5) < a); | ||
b--; | ||
} while (get_square(a) > b); | ||
return a; | ||
} | ||
|
||
int foo2() { | ||
int a = 0; | ||
do { | ||
a++; | ||
} while (get_square() != 0); | ||
return a; | ||
} | ||
|
||
int foo3() { | ||
int a = 0; | ||
bool flag = get_square(5) != 25; | ||
do { | ||
a++; | ||
} while (flag); | ||
return a; | ||
} | ||
|
||
int foo4(int a) { | ||
bool flag = get_square(a) != 0; | ||
do { | ||
a++; | ||
} while (flag && get_square(a) > 10); | ||
return a; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
| doStmtCode.cpp:8:5:13:32 | do (...) ... | This is 'do' statement. | | ||
| doStmtCode.cpp:9:9:11:36 | do (...) ... | This is 'do' statement. | | ||
| doStmtCode.cpp:19:5:21:32 | do (...) ... | This is 'do' statement. | | ||
| doStmtCode.cpp:28:5:30:19 | do (...) ... | This is 'do' statement. | | ||
| doStmtCode.cpp:36:5:38:41 | do (...) ... | This is 'do' statement. | |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: codeql-code-with-queries-test | ||
dependencies: | ||
codeql/cpp-all: "*" | ||
extractor: cpp | ||
tests: . |
17 changes: 17 additions & 0 deletions
17
codeWithQueries/cpp/rangeBasedForStmt/rangeBasedForStmtCode.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
int foo1() { | ||
int a = 100; | ||
int array1[] = {-6, 3, 10}; | ||
for (int i: array1) { | ||
a -= i; | ||
} | ||
return a; | ||
} | ||
|
||
int foo2() { | ||
int a = 0; | ||
int array2[] = {-9, 5, 15}; | ||
for (int j: array2) { | ||
a += j; | ||
} | ||
return a; | ||
} |
2 changes: 2 additions & 0 deletions
2
codeWithQueries/cpp/rangeBasedForStmt/rangeBasedForStmtTest.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
| rangeBasedForStmtCode.cpp:4:5:6:5 | for(...:...) ... | This is range based 'for' statement. | | ||
| rangeBasedForStmtCode.cpp:13:5:15:5 | for(...:...) ... | This is range based 'for' statement. | |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
lockVersion: 1.0.0 | ||
dependencies: {} | ||
compiled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* @name Test 'do' statement | ||
* @kind problem | ||
* @id cpp/doStmtTest | ||
*/ | ||
|
||
import cpp | ||
|
||
from DoStmt doStmt | ||
select doStmt, "This is 'do' statement." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: codeql-test-examples | ||
name: codeql-queries-test | ||
dependencies: | ||
codeql/cpp-all: "*" | ||
extractor: cpp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* @name Test range based 'for' statement | ||
* @kind problem | ||
* @id cpp/rangeBasedForStmtTest | ||
*/ | ||
|
||
import cpp | ||
|
||
from RangeBasedForStmt rangeBasedForStmt | ||
select rangeBasedForStmt, "This is range based 'for' statement." |