Skip to content

Commit 9b5bb95

Browse files
authored
Merge pull request github#5696 from jbj/reapply-inconsistency-workaround
Revert "Revert "C++: Work around extractor issue CPP-383""
2 parents bc8c558 + 6de5b30 commit 9b5bb95

File tree

5 files changed

+43
-5
lines changed

5 files changed

+43
-5
lines changed

cpp/ql/src/semmle/code/cpp/controlflow/internal/CFG.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,8 @@ private predicate conditionJumps(Expr test, boolean truth, Node n2, Pos p2) {
13071307
)
13081308
}
13091309

1310-
// Factored out for performance. See QL-796.
1310+
// Pulled out for performance. See
1311+
// https://github.com/github/codeql-coreql-team/issues/1044.
13111312
private predicate normalGroupMemberBaseCase(Node memberNode, Pos memberPos, Node atNode) {
13121313
memberNode = atNode and
13131314
memberPos.isAt() and

cpp/ql/src/semmle/code/cpp/controlflow/internal/ConstantExprs.qll

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,43 @@ private predicate loopConditionAlwaysUponEntry(ControlFlowNode loop, Expr condit
104104
)
105105
}
106106

107+
/**
108+
* This relation is the same as the `el instanceof Function`, only obfuscated
109+
* so the optimizer will not understand that any `FunctionCall.getTarget()`
110+
* should be in this relation.
111+
*/
112+
pragma[noinline]
113+
private predicate isFunction(Element el) {
114+
el instanceof Function
115+
or
116+
el.(Expr).getParent() = el
117+
}
118+
119+
/**
120+
* Holds if `fc` is a `FunctionCall` with no return value for `getTarget`. This
121+
* can happen in case of rare database inconsistencies.
122+
*/
123+
pragma[noopt]
124+
private predicate callHasNoTarget(@funbindexpr fc) {
125+
exists(Function f |
126+
funbind(fc, f) and
127+
not isFunction(f)
128+
)
129+
}
130+
131+
// Pulled out for performance. See
132+
// https://github.com/github/codeql-coreql-team/issues/1044.
133+
private predicate potentiallyReturningFunctionCall_base(FunctionCall fc) {
134+
fc.isVirtual()
135+
or
136+
callHasNoTarget(fc)
137+
}
138+
107139
/** A function call that *may* return; if in doubt, we assume it may. */
108140
private predicate potentiallyReturningFunctionCall(FunctionCall fc) {
109-
potentiallyReturningFunction(fc.getTarget()) or fc.isVirtual()
141+
potentiallyReturningFunctionCall_base(fc)
142+
or
143+
potentiallyReturningFunction(fc.getTarget())
110144
}
111145

112146
/** A function that *may* return; if in doubt, we assume it may. */

cpp/ql/src/semmle/code/cpp/exprs/Expr.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,8 @@ private predicate convparents(Expr child, int idx, Element parent) {
12711271
)
12721272
}
12731273

1274-
// Pulled out for performance. See QL-796.
1274+
// Pulled out for performance. See
1275+
// https://github.com/github/codeql-coreql-team/issues/1044.
12751276
private predicate hasNoConversions(Expr e) { not e.hasConversion() }
12761277

12771278
/**

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ IRTempVariable getIRTempVariable(Locatable ast, TempVariableTag tag) {
4242
*/
4343
predicate isIRConstant(Expr expr) { exists(expr.getValue()) }
4444

45-
// Pulled out to work around QL-796
45+
// Pulled out for performance. See
46+
// https://github.com/github/codeql-coreql-team/issues/1044.
4647
private predicate isOrphan(Expr expr) { not exists(getRealParent(expr)) }
4748

4849
/**

csharp/ql/src/experimental/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ private Element getRealParent(Expr expr) { result = expr.getParent() }
5757
*/
5858
predicate isIRConstant(Expr expr) { exists(expr.getValue()) }
5959

60-
// Pulled out to work around QL-796
60+
// Pulled out for performance. See
61+
// https://github.com/github/codeql-coreql-team/issues/1044.
6162
private predicate isOrphan(Expr expr) { not exists(getRealParent(expr)) }
6263

6364
/**

0 commit comments

Comments
 (0)