mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
QL: Fix FP in 'ql/missing-noinline'.
This commit is contained in:
@@ -18,7 +18,9 @@ where
|
||||
not decl.getAnAnnotation() instanceof NoMagic and
|
||||
not decl.getAnAnnotation() instanceof NoOpt and
|
||||
not decl.getAnAnnotation().getName() = "cached" and
|
||||
// If it's marked as inline it's probably because the QLDoc says something like
|
||||
// "this predicate is inlined because it gives a better join-order".
|
||||
not decl.getAnAnnotation() instanceof Inline
|
||||
// If it's marked as inline (or has at least one bindingset annotation)
|
||||
// it's probably because the QLDoc says something like "this predicate
|
||||
// is inlined because it gives a better join-order".
|
||||
not decl.getAnAnnotation() instanceof Inline and
|
||||
not decl.getAnAnnotation() instanceof BindingSet
|
||||
select decl, "This predicate might be inlined."
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
queries/performance/MissingNoinline.ql
|
||||
73
ql/ql/test/queries/performance/MissingNoInline/Test.qll
Normal file
73
ql/ql/test/queries/performance/MissingNoInline/Test.qll
Normal file
@@ -0,0 +1,73 @@
|
||||
import ql
|
||||
|
||||
/**
|
||||
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
|
||||
*
|
||||
* This predicate exists to fix a join order.
|
||||
*/
|
||||
predicate missingNoInline(AddExpr add, Expr e1, Expr e2) {
|
||||
// BAD
|
||||
add.getLeftOperand() = e1 and
|
||||
add.getRightOperand() = e2
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
|
||||
*
|
||||
* This predicate exists to fix a join order.
|
||||
*/
|
||||
pragma[noinline]
|
||||
predicate noInlined(AddExpr add, Expr e1, Expr e2) {
|
||||
// GOOD
|
||||
add.getLeftOperand() = e1 and
|
||||
add.getRightOperand() = e2
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
|
||||
*
|
||||
* This predicate exists to fix a join order.
|
||||
*/
|
||||
pragma[nomagic]
|
||||
predicate nomagicd(AddExpr add, Expr e1, Expr e2) {
|
||||
// GOOD
|
||||
add.getLeftOperand() = e1 and
|
||||
add.getRightOperand() = e2
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
|
||||
*
|
||||
* This predicate exists to fix a join order.
|
||||
*/
|
||||
pragma[inline]
|
||||
predicate inlined(AddExpr add, Expr e1, Expr e2) {
|
||||
// GOOD
|
||||
add.getLeftOperand() = e1 and
|
||||
add.getRightOperand() = e2
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
|
||||
*
|
||||
* This predicate exists to fix a join order.
|
||||
*/
|
||||
bindingset[add]
|
||||
predicate hasBindingset(AddExpr add, Expr e1, Expr e2) {
|
||||
// GOOD
|
||||
add.getLeftOperand() = e1 and
|
||||
add.getRightOperand() = e2
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `add.getLeftOperand() = e1` and `add.getRightOperand() = e2`.
|
||||
*
|
||||
* This predicate exists to fix a join order.
|
||||
*/
|
||||
pragma[noopt]
|
||||
predicate noOpted(AddExpr add, Expr e1, Expr e2) {
|
||||
// GOOD
|
||||
add instanceof AddExpr and
|
||||
add.getLeftOperand() = e1 and
|
||||
add.getRightOperand() = e2
|
||||
}
|
||||
Reference in New Issue
Block a user