Skip to content

Commit 0e3e35f

Browse files
committed
C++: don't dump global vars without initializers
1 parent 3ce7c52 commit 0e3e35f

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

cpp/ql/test/library-tests/ir/ir/PrintConfig.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ predicate locationIsInStandardHeaders(Location loc) {
1212
*
1313
* This predicate excludes functions defined in standard headers.
1414
*/
15-
predicate shouldDumpFunction(Function func) { not locationIsInStandardHeaders(func.getLocation()) }
15+
predicate shouldDumpFunction(Declaration decl) {
16+
not locationIsInStandardHeaders(decl.getLocation()) and
17+
(
18+
not decl instanceof Variable
19+
or
20+
decl.(GlobalOrNamespaceVariable).hasInitializer()
21+
)
22+
}

cpp/ql/test/library-tests/ir/ir/raw_ir.expected

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ bad_asts.cpp:
139139
# 30| v30_6(void) = ExitFunction :
140140

141141
clang.cpp:
142-
# 3| int globalInt
143-
144142
# 5| int* globalIntAddress()
145143
# 5| Block 0
146144
# 5| v5_1(void) = EnterFunction :
@@ -2226,8 +2224,6 @@ ir.cpp:
22262224
# 341| v341_11(void) = AliasedUse : ~m?
22272225
# 341| v341_12(void) = ExitFunction :
22282226

2229-
# 346| int g
2230-
22312227
# 348| int* AddressOf()
22322228
# 348| Block 0
22332229
# 348| v348_1(void) = EnterFunction :
@@ -9016,8 +9012,6 @@ ir.cpp:
90169012
# 1693| v1693_6(void) = AliasedUse : ~m?
90179013
# 1693| v1693_7(void) = ExitFunction :
90189014

9019-
# 1699| int global_1
9020-
90219015
# 1701| int global_2
90229016
# 1701| Block 0
90239017
# 1701| v1701_1(void) = EnterFunction :
@@ -9330,8 +9324,6 @@ struct_init.cpp:
93309324
# 9| v9_9(void) = AliasedUse : ~m?
93319325
# 9| v9_10(void) = ExitFunction :
93329326

9333-
# 14| Info* global_pointer
9334-
93359327
# 16| void let_info_escape(Info*)
93369328
# 16| Block 0
93379329
# 16| v16_1(void) = EnterFunction :

cpp/ql/test/library-tests/ir/ir/raw_ir.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ private import PrintConfig
88

99
private class PrintConfig extends PrintIRConfiguration {
1010
override predicate shouldPrintFunction(Declaration decl) {
11-
shouldDumpFunction(decl) or decl instanceof GlobalOrNamespaceVariable
11+
shouldDumpFunction(decl)
1212
}
1313
}

0 commit comments

Comments
 (0)