Skip to content

Commit c8b0224

Browse files
committed
Merge branch 'main' into redsun82/go
2 parents 146d84b + e44d4c4 commit c8b0224

351 files changed

Lines changed: 1521 additions & 470 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/buildifier.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check bazel formatting
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "**.bazel"
7+
- "**.bzl"
8+
branches:
9+
- main
10+
- "rc/*"
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
check:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
- name: Check bazel formatting
22+
uses: pre-commit/action@646c83fcd040023954eafda54b4db0192ce70507
23+
with:
24+
extra_args: >
25+
buildifier --all-files 2>&1 ||
26+
(
27+
echo -e "In order to format all bazel files, please run:\n bazel run //:buildifier"; exit 1
28+
)

.pre-commit-config.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ repos:
2020
- id: autopep8
2121
files: ^misc/codegen/.*\.py
2222

23-
- repo: https://github.com/warchant/pre-commit-buildifier
24-
rev: 0.0.2
23+
- repo: local
2524
hooks:
2625
- id: buildifier
26+
name: Format bazel files
27+
files: \.(bazel|bzl)
28+
language: system
29+
entry: bazel run //:buildifier
30+
pass_filenames: false
2731

28-
- repo: local
29-
hooks:
3032
- id: go-gen
3133
name: Check checked in generated files in go
3234
files: go/.*

BUILD.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@buildifier_prebuilt//:rules.bzl", "buildifier")
2+
3+
buildifier(
4+
name = "buildifier",
5+
exclude_patterns = [
6+
"./.git/*",
7+
],
8+
lint_mode = "fix",
9+
)

MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json")
2525
bazel_dep(name = "fmt", version = "10.0.0")
2626
bazel_dep(name = "gazelle", version = "0.36.0")
2727

28+
bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
29+
2830
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
2931
pip.parse(
3032
hub_name = "codegen_deps",

config/identical-files.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@
362362
"java/ql/lib/semmle/code/java/security/internal/EncryptionKeySizes.qll"
363363
],
364364
"Python model summaries test extension": [
365-
"python/ql/test/experimental/dataflow/model-summaries/InlineTaintTest.ext.yml",
366-
"python/ql/test/experimental/dataflow/model-summaries/NormalDataflowTest.ext.yml"
365+
"python/ql/test/library-tests/dataflow/model-summaries/InlineTaintTest.ext.yml",
366+
"python/ql/test/library-tests/dataflow/model-summaries/NormalDataflowTest.ext.yml"
367367
]
368-
}
368+
}

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,25 @@ class StmtNode extends AstNode {
463463
}
464464
}
465465

466+
/**
467+
* A node representing a child of a `Stmt` that is itself a `Stmt`.
468+
*/
469+
class ChildStmtNode extends StmtNode {
470+
Stmt childStmt;
471+
472+
ChildStmtNode() { exists(Stmt parent | parent.getAChild() = childStmt and childStmt = ast) }
473+
474+
override BaseAstNode getChildInternal(int childIndex) {
475+
result = super.getChildInternal(childIndex)
476+
or
477+
exists(int destructorIndex |
478+
result.getAst() = childStmt.getImplicitDestructorCall(destructorIndex) and
479+
childIndex =
480+
destructorIndex + max(int index | exists(childStmt.getChild(index)) or index = 0) + 1
481+
)
482+
}
483+
}
484+
466485
/**
467486
* A node representing a `DeclStmt`.
468487
*/
@@ -674,6 +693,13 @@ class FunctionNode extends FunctionOrGlobalOrNamespaceVariableNode {
674693
private string getChildAccessorWithoutConversions(Locatable parent, Element child) {
675694
shouldPrintDeclaration(getAnEnclosingDeclaration(parent)) and
676695
(
696+
exists(Stmt s, int i | s.getChild(i) = parent |
697+
exists(int n |
698+
s.getChild(i).(Stmt).getImplicitDestructorCall(n) = child and
699+
result = "getImplicitDestructorCall(" + n + ")"
700+
)
701+
)
702+
or
677703
exists(Stmt s | s = parent |
678704
namedStmtChildPredicates(s, child, result)
679705
or

cpp/ql/src/experimental/Security/CWE/CWE-125/DangerousWorksWithMultibyteOrWideCharacters.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ predicate exprMayBeString(Expr exp) {
2424
fctmp.getAnArgument().(VariableAccess).getTarget() = exp.(VariableAccess).getTarget() or
2525
globalValueNumber(fctmp.getAnArgument()) = globalValueNumber(exp)
2626
) and
27-
fctmp.getTarget().hasName(["strlen", "strcat", "strncat", "strcpy", "sptintf", "printf"])
27+
fctmp.getTarget().hasName(["strlen", "strcat", "strncat", "strcpy", "sprintf", "printf"])
2828
)
2929
or
3030
exists(AssignExpr astmp |

cpp/ql/test/library-tests/ir/ir/PrintAST.expected

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22334,6 +22334,114 @@ ir.cpp:
2233422334
# 2480| Type = [Struct] B
2233522335
# 2480| ValueCategory = xvalue
2233622336
# 2481| getStmt(1): [ReturnStmt] return ...
22337+
# 2484| [TopLevelFunction] void destructor_without_block(bool)
22338+
# 2484| <params>:
22339+
# 2484| getParameter(0): [Parameter] b
22340+
# 2484| Type = [BoolType] bool
22341+
# 2485| getEntryPoint(): [BlockStmt] { ... }
22342+
# 2486| getStmt(0): [IfStmt] if (...) ...
22343+
# 2486| getCondition(): [VariableAccess] b
22344+
# 2486| Type = [BoolType] bool
22345+
# 2486| ValueCategory = prvalue(load)
22346+
# 2487| getThen(): [DeclStmt] declaration
22347+
# 2487| getDeclarationEntry(0): [VariableDeclarationEntry] definition of c
22348+
# 2487| Type = [Class] ClassWithDestructor
22349+
# 2487| getVariable().getInitializer(): [Initializer] initializer for c
22350+
# 2487| getExpr(): [ConstructorCall] call to ClassWithDestructor
22351+
# 2487| Type = [VoidType] void
22352+
# 2487| ValueCategory = prvalue
22353+
#-----| getImplicitDestructorCall(0): [DestructorCall] call to ~ClassWithDestructor
22354+
#-----| Type = [VoidType] void
22355+
#-----| ValueCategory = prvalue
22356+
#-----| getQualifier(): [VariableAccess] c
22357+
#-----| Type = [Class] ClassWithDestructor
22358+
#-----| ValueCategory = lvalue
22359+
# 2489| getStmt(1): [IfStmt] if (...) ...
22360+
# 2489| getCondition(): [VariableAccess] b
22361+
# 2489| Type = [BoolType] bool
22362+
# 2489| ValueCategory = prvalue(load)
22363+
# 2490| getThen(): [DeclStmt] declaration
22364+
# 2490| getDeclarationEntry(0): [VariableDeclarationEntry] definition of d
22365+
# 2490| Type = [Class] ClassWithDestructor
22366+
# 2490| getVariable().getInitializer(): [Initializer] initializer for d
22367+
# 2490| getExpr(): [ConstructorCall] call to ClassWithDestructor
22368+
# 2490| Type = [VoidType] void
22369+
# 2490| ValueCategory = prvalue
22370+
#-----| getImplicitDestructorCall(0): [DestructorCall] call to ~ClassWithDestructor
22371+
#-----| Type = [VoidType] void
22372+
#-----| ValueCategory = prvalue
22373+
#-----| getQualifier(): [VariableAccess] d
22374+
#-----| Type = [Class] ClassWithDestructor
22375+
#-----| ValueCategory = lvalue
22376+
# 2492| getElse(): [DeclStmt] declaration
22377+
# 2492| getDeclarationEntry(0): [VariableDeclarationEntry] definition of e
22378+
# 2492| Type = [Class] ClassWithDestructor
22379+
# 2492| getVariable().getInitializer(): [Initializer] initializer for e
22380+
# 2492| getExpr(): [ConstructorCall] call to ClassWithDestructor
22381+
# 2492| Type = [VoidType] void
22382+
# 2492| ValueCategory = prvalue
22383+
#-----| getImplicitDestructorCall(0): [DestructorCall] call to ~ClassWithDestructor
22384+
#-----| Type = [VoidType] void
22385+
#-----| ValueCategory = prvalue
22386+
#-----| getQualifier(): [VariableAccess] e
22387+
#-----| Type = [Class] ClassWithDestructor
22388+
#-----| ValueCategory = lvalue
22389+
# 2494| getStmt(2): [WhileStmt] while (...) ...
22390+
# 2494| getCondition(): [VariableAccess] b
22391+
# 2494| Type = [BoolType] bool
22392+
# 2494| ValueCategory = prvalue(load)
22393+
# 2495| getStmt(): [DeclStmt] declaration
22394+
# 2495| getDeclarationEntry(0): [VariableDeclarationEntry] definition of f
22395+
# 2495| Type = [Class] ClassWithDestructor
22396+
# 2495| getVariable().getInitializer(): [Initializer] initializer for f
22397+
# 2495| getExpr(): [ConstructorCall] call to ClassWithDestructor
22398+
# 2495| Type = [VoidType] void
22399+
# 2495| ValueCategory = prvalue
22400+
#-----| getImplicitDestructorCall(0): [DestructorCall] call to ~ClassWithDestructor
22401+
#-----| Type = [VoidType] void
22402+
#-----| ValueCategory = prvalue
22403+
#-----| getQualifier(): [VariableAccess] f
22404+
#-----| Type = [Class] ClassWithDestructor
22405+
#-----| ValueCategory = lvalue
22406+
# 2497| getStmt(3): [ForStmt] for(...;...;...) ...
22407+
# 2497| getInitialization(): [DeclStmt] declaration
22408+
# 2497| getDeclarationEntry(0): [VariableDeclarationEntry] definition of i
22409+
# 2497| Type = [IntType] int
22410+
# 2497| getVariable().getInitializer(): [Initializer] initializer for i
22411+
# 2497| getExpr(): [Literal] 0
22412+
# 2497| Type = [IntType] int
22413+
# 2497| Value = [Literal] 0
22414+
# 2497| ValueCategory = prvalue
22415+
# 2497| getCondition(): [LTExpr] ... < ...
22416+
# 2497| Type = [BoolType] bool
22417+
# 2497| ValueCategory = prvalue
22418+
# 2497| getLesserOperand(): [VariableAccess] i
22419+
# 2497| Type = [IntType] int
22420+
# 2497| ValueCategory = prvalue(load)
22421+
# 2497| getGreaterOperand(): [Literal] 42
22422+
# 2497| Type = [IntType] int
22423+
# 2497| Value = [Literal] 42
22424+
# 2497| ValueCategory = prvalue
22425+
# 2497| getUpdate(): [PrefixIncrExpr] ++ ...
22426+
# 2497| Type = [IntType] int
22427+
# 2497| ValueCategory = lvalue
22428+
# 2497| getOperand(): [VariableAccess] i
22429+
# 2497| Type = [IntType] int
22430+
# 2497| ValueCategory = lvalue
22431+
# 2498| getStmt(): [DeclStmt] declaration
22432+
# 2498| getDeclarationEntry(0): [VariableDeclarationEntry] definition of g
22433+
# 2498| Type = [Class] ClassWithDestructor
22434+
# 2498| getVariable().getInitializer(): [Initializer] initializer for g
22435+
# 2498| getExpr(): [ConstructorCall] call to ClassWithDestructor
22436+
# 2498| Type = [VoidType] void
22437+
# 2498| ValueCategory = prvalue
22438+
#-----| getImplicitDestructorCall(0): [DestructorCall] call to ~ClassWithDestructor
22439+
#-----| Type = [VoidType] void
22440+
#-----| ValueCategory = prvalue
22441+
#-----| getQualifier(): [VariableAccess] g
22442+
#-----| Type = [Class] ClassWithDestructor
22443+
#-----| ValueCategory = lvalue
22444+
# 2499| getStmt(4): [ReturnStmt] return ...
2233722445
perf-regression.cpp:
2233822446
# 4| [CopyAssignmentOperator] Big& Big::operator=(Big const&)
2233922447
# 4| <params>:

0 commit comments

Comments
 (0)