Skip to content

Commit ad590f3

Browse files
authored
Merge branch 'main' into cpp/mad-barriers
2 parents 656ebab + 075041f commit ad590f3

File tree

38 files changed

+10933
-8579
lines changed

38 files changed

+10933
-8579
lines changed

.github/workflows/ql-for-ql-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
uses: github/codeql-action/init@main
2828
with:
2929
languages: javascript # does not matter
30+
tools: nightly
3031
- uses: ./.github/actions/os-version
3132
id: os_version
3233
### Build the extractor ###

.github/workflows/ql-for-ql-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
uses: github/codeql-action/init@main
3131
with:
3232
languages: javascript # does not matter
33+
tools: nightly
3334
- uses: ./.github/actions/os-version
3435
id: os_version
3536
- uses: actions/cache@v3
@@ -75,6 +76,7 @@ jobs:
7576
uses: github/codeql-action/init@main
7677
with:
7778
languages: javascript # does not matter
79+
tools: nightly
7880
- uses: ./.github/actions/os-version
7981
id: os_version
8082
- uses: actions/cache@v3

cpp/ql/lib/semmle/code/cpp/Element.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,15 @@ class Element extends ElementBase {
192192
*/
193193
predicate isAffectedByMacro() { affectedByMacro(this) }
194194

195+
/**
196+
* INTERNAL: Do not use.
197+
*
198+
* Holds if this element is affected by the expansion of `mi`.
199+
*/
200+
predicate isAffectedByMacro(MacroInvocation mi) {
201+
affectedbymacroexpansion(underlyingElement(this), unresolveElement(mi))
202+
}
203+
195204
private Element getEnclosingElementPref() {
196205
enclosingfunction(underlyingElement(this), unresolveElement(result)) or
197206
result.(Function) = stmtEnclosingElement(this) or

cpp/ql/lib/semmle/code/cpp/Macro.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ class MacroInvocation extends MacroAccess {
239239
macro_argument_unexpanded(underlyingElement(this), i, result)
240240
}
241241

242+
/** Gets the number of arguments for this macro invocation. */
243+
int getNumberOfArguments() { result = count(int i | exists(this.getUnexpandedArgument(i)) | i) }
244+
242245
/**
243246
* Gets the `i`th _expanded_ argument of this macro invocation, where the
244247
* first argument has `i = 0`. The result has been expanded for macros _and_

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Expr extends StmtParent, @expr {
2323
predicate hasChild(Expr e, int n) { e = this.getChild(n) }
2424

2525
/** Gets the enclosing function of this expression, if any. */
26-
Function getEnclosingFunction() { result = exprEnclosingElement(this) }
26+
override Function getEnclosingFunction() { result = exprEnclosingElement(this) }
2727

2828
/** Gets the nearest enclosing set of curly braces around this expression in the source, if any. */
2929
BlockStmt getEnclosingBlock() { result = this.getEnclosingStmt().getEnclosingBlock() }

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaImpl.qll

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,16 @@ module SsaCached {
940940
SsaImpl::phiHasInputFromBlock(phi, inp, bb)
941941
}
942942

943+
cached
944+
predicate uncertainWriteDefinitionInput(Definition uncertain, Definition inp) {
945+
SsaImpl::uncertainWriteDefinitionInput(uncertain, inp)
946+
}
947+
948+
cached
949+
predicate ssaDefReachesEndOfBlock(IRBlock bb, Definition def) {
950+
SsaImpl::ssaDefReachesEndOfBlock(bb, def, _)
951+
}
952+
943953
predicate variableRead = SsaInput::variableRead/4;
944954

945955
predicate variableWrite = SsaInput::variableWrite/4;
@@ -1173,9 +1183,17 @@ class Definition extends SsaImpl::Definition {
11731183
private Definition getAPhiInputOrPriorDefinition() {
11741184
result = this.(PhiNode).getAnInput()
11751185
or
1176-
SsaImpl::uncertainWriteDefinitionInput(this, result)
1186+
uncertainWriteDefinitionInput(this, result)
11771187
}
11781188

1189+
/**
1190+
* Holds if this SSA definition is live at the end of basic block `bb`.
1191+
* That is, this definition reaches the end of basic block `bb`, at which
1192+
* point it is still live, without crossing another SSA definition of the
1193+
* same source variable.
1194+
*/
1195+
predicate isLiveAtEndOfBlock(IRBlock bb) { ssaDefReachesEndOfBlock(bb, this) }
1196+
11791197
/**
11801198
* Gets a definition that ultimately defines this SSA definition and is
11811199
* not itself a phi node.

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/InstructionTag.qll

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ newtype TInstructionTag =
104104
} or
105105
SizeofVlaDimensionTag(int index) {
106106
exists(VlaDeclStmt v | exists(v.getTransitiveVlaDimensionStmt(index)))
107-
}
107+
} or
108+
AssertionVarAddressTag() or
109+
AssertionVarLoadTag() or
110+
AssertionOpTag() or
111+
AssertionBranchTag()
108112

109113
class InstructionTag extends TInstructionTag {
110114
final string toString() { result = getInstructionTagId(this) }
@@ -296,4 +300,12 @@ string getInstructionTagId(TInstructionTag tag) {
296300
tag = CoAwaitBranchTag() and result = "CoAwaitBranch"
297301
or
298302
tag = BoolToIntConversionTag() and result = "BoolToIntConversion"
303+
or
304+
tag = AssertionVarAddressTag() and result = "AssertionVarAddress"
305+
or
306+
tag = AssertionVarLoadTag() and result = "AssertionVarLoad"
307+
or
308+
tag = AssertionOpTag() and result = "AssertionOp"
309+
or
310+
tag = AssertionBranchTag() and result = "AssertionBranch"
299311
}

0 commit comments

Comments
 (0)