mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
C++: Fix FP by not generating a global def entry node for variable 'v' in the 'IRfunction' for 'v' itself.
This commit is contained in:
@@ -153,6 +153,10 @@ private predicate isGlobalDefImpl(
|
||||
GlobalLikeVariable v, IRFunction f, int indirection, int indirectionIndex
|
||||
) {
|
||||
exists(VariableAddressInstruction vai |
|
||||
// The right-hand side of an initialization of a global variable
|
||||
// creates its own `IRFunction`. We don't want flow into that `IRFunction`
|
||||
// since the variable is only initialized once.
|
||||
not vai.getEnclosingFunction() = v and
|
||||
vai.getEnclosingIRFunction() = f and
|
||||
vai.getAstVariable() = v and
|
||||
isUse(_, _, vai, indirection, indirectionIndex) and
|
||||
|
||||
@@ -327,7 +327,6 @@ irFlow
|
||||
| test.cpp:1117:27:1117:34 | call to source | test.cpp:1117:27:1117:34 | call to source |
|
||||
| test.cpp:1132:11:1132:16 | call to source | test.cpp:1121:8:1121:8 | x |
|
||||
| test.cpp:1138:17:1138:22 | call to source | test.cpp:1140:8:1140:18 | * ... |
|
||||
| test.cpp:1158:18:1158:42 | ... , ... | test.cpp:1158:23:1158:31 | recursion |
|
||||
| true_upon_entry.cpp:9:11:9:16 | call to source | true_upon_entry.cpp:13:8:13:8 | x |
|
||||
| true_upon_entry.cpp:17:11:17:16 | call to source | true_upon_entry.cpp:21:8:21:8 | x |
|
||||
| true_upon_entry.cpp:27:9:27:14 | call to source | true_upon_entry.cpp:29:8:29:8 | x |
|
||||
|
||||
@@ -1155,4 +1155,4 @@ namespace conflation_regression {
|
||||
}
|
||||
}
|
||||
|
||||
int recursion = (sink(recursion), source()); // $ SPURIOUS: ir
|
||||
int recursion = (sink(recursion), source()); // clean
|
||||
Reference in New Issue
Block a user