Skip to content

Commit 439afd9

Browse files
committed
C++: Small performance optimization.
1 parent 132bb9f commit 439afd9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cpp/ql/src/Critical/GlobalUseBeforeInit.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ predicate useFunc(GlobalVariable v, Function f) {
3131
}
3232

3333
predicate uninitialisedBefore(GlobalVariable v, Function f) {
34-
f.hasGlobalName("main")
34+
f.hasGlobalName("main") and
35+
not initialisedAtDeclaration(v) and
36+
not isStdlibVariable(v)
3537
or
3638
exists(Call call, Function g |
3739
uninitialisedBefore(v, g) and
@@ -107,9 +109,7 @@ predicate isStdlibVariable(GlobalVariable v) { v.hasGlobalName(["stdin", "stdout
107109
from GlobalVariable v, Function f
108110
where
109111
uninitialisedBefore(v, f) and
110-
useFunc(v, f) and
111-
not initialisedAtDeclaration(v) and
112-
not isStdlibVariable(v)
112+
useFunc(v, f)
113113
select f,
114114
"The variable '" + v.getName() +
115115
" is used in this function but may not be initialized when it is called."

0 commit comments

Comments
 (0)