Skip to content

Commit 16e9d76

Browse files
committed
Merge branch 'master' into python-keyword-only-args
2 parents c5e14f5 + a0800ce commit 16e9d76

File tree

170 files changed

+6431
-630
lines changed

Some content is hidden

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

170 files changed

+6431
-630
lines changed

CODEOWNERS

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
/cpp/ @Semmle/cpp-analysis
2-
/csharp/ @Semmle/cs
3-
/java/ @Semmle/java
4-
/javascript/ @Semmle/js
5-
/python/ @Semmle/python
1+
/cpp/ @github/codeql-c-analysis
2+
/csharp/ @github/codeql-csharp
3+
/java/ @github/codeql-java
4+
/javascript/ @github/codeql-javascript
5+
/python/ @github/codeql-python
66
/cpp/**/*.qhelp @hubwriter
77
/csharp/**/*.qhelp @jf205
88
/java/**/*.qhelp @felicitymay

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ If you have an idea for a query that you would like to share with other CodeQL u
2020
* Python: `python/ql/src`
2121

2222
Each language-specific directory contains further subdirectories that group queries based on their `@tags` or purpose.
23-
- Experimental queries and libraries are stored in the `experimental` subdirectory within each language-specific directory in the [CodeQL repository](https://github.com/Semmle/ql). For example, experimental Java queries and libraries are stored in `java/ql/src/experimental` and any corresponding tests in `java/ql/test/experimental`.
23+
- Experimental queries and libraries are stored in the `experimental` subdirectory within each language-specific directory in the [CodeQL repository](https://github.com/github/codeql). For example, experimental Java queries and libraries are stored in `java/ql/src/experimental` and any corresponding tests in `java/ql/test/experimental`.
2424
- The structure of an `experimental` subdirectory mirrors the structure of its parent directory.
2525
- Select or create an appropriate directory in `experimental` based on the existing directory structure of `experimental` or its parent directory.
2626

@@ -36,7 +36,7 @@ If you have an idea for a query that you would like to share with other CodeQL u
3636

3737
3. **Formatting**
3838

39-
- The queries and libraries must be [autoformatted](https://help.semmle.com/codeql/codeql-for-vscode/reference/editor.html#autoformatting).
39+
- The queries and libraries must be autoformatted, for example using the "Format Document" command in [CodeQL for Visual Studio Code](https://help.semmle.com/codeql/codeql-for-vscode/procedures/about-codeql-for-vscode.html).
4040

4141
4. **Compilation**
4242

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You can use the [interactive query console](https://lgtm.com/help/lgtm/using-que
99

1010
## Contributing
1111

12-
We welcome contributions to our standard library and standard checks. Do you have an idea for a new check, or how to improve an existing query? Then please go ahead and open a pull request! Before you do, though, please take the time to read our [contributing guidelines](CONTRIBUTING.md). You can also consult our [style guides](https://github.com/Semmle/ql/tree/master/docs) to learn how to format your code for consistency and clarity, how to write query metadata, and how to write query help documentation for your query.
12+
We welcome contributions to our standard library and standard checks. Do you have an idea for a new check, or how to improve an existing query? Then please go ahead and open a pull request! Before you do, though, please take the time to read our [contributing guidelines](CONTRIBUTING.md). You can also consult our [style guides](https://github.com/github/codeql/tree/master/docs) to learn how to format your code for consistency and clarity, how to write query metadata, and how to write query help documentation for your query.
1313

1414
## License
1515

cpp/ql/src/Likely Bugs/Underspecified Functions/MistypedFunctionArguments.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import cpp
88

9+
pragma[inline]
910
private predicate arithTypesMatch(Type arg, Type parm) {
1011
arg = parm
1112
or

cpp/ql/src/Security/CWE/CWE-468/IncorrectPointerScaling.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ where
2121
destBase = baseType(destType) and
2222
destBase.getSize() != sourceBase.getSize() and
2323
not dest.isInMacroExpansion() and
24-
// If the source type is a char* or void* then don't
24+
// If the source type is a `char*` or `void*` then don't
2525
// produce a result, because it is likely to be a false
2626
// positive.
2727
not sourceBase instanceof CharType and

cpp/ql/src/Security/CWE/CWE-468/IncorrectPointerScalingChar.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ where
2121
destBase = baseType(destType) and
2222
destBase.getSize() != sourceBase.getSize() and
2323
not dest.isInMacroExpansion() and
24-
// If the source type is a char* or void* then don't
24+
// If the source type is a `char*` or `void*` then don't
2525
// produce a result, because it is likely to be a false
2626
// positive.
2727
not sourceBase instanceof CharType and

cpp/ql/src/Security/CWE/CWE-468/SuspiciousAddWithSizeof.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ private predicate isCharSzPtrExpr(Expr e) {
2424
from Expr sizeofExpr, Expr e
2525
where
2626
// If we see an addWithSizeof then we expect the type of
27-
// the pointer expression to be char* or void*. Otherwise it
27+
// the pointer expression to be `char*` or `void*`. Otherwise it
2828
// is probably a mistake.
2929
addWithSizeof(e, sizeofExpr, _) and not isCharSzPtrExpr(e)
3030
select sizeofExpr,
31-
"Suspicious sizeof offset in a pointer arithmetic expression. " + "The type of the pointer is " +
32-
e.getFullyConverted().getType().toString() + "."
31+
"Suspicious sizeof offset in a pointer arithmetic expression. The type of the pointer is $@.",
32+
e.getFullyConverted().getType() as t, t.toString()

cpp/ql/src/semmle/code/cpp/Declaration.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private import semmle.code.cpp.internal.QualifiedName as Q
2525
* `DeclarationEntry`, because they always have a unique source location.
2626
* `EnumConstant` and `FriendDecl` are both examples of this.
2727
*/
28-
abstract class Declaration extends Locatable, @declaration {
28+
class Declaration extends Locatable, @declaration {
2929
/**
3030
* Gets the innermost namespace which contains this declaration.
3131
*

cpp/ql/src/semmle/code/cpp/Function.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
103103

104104
/**
105105
* Holds if this function is declared to be `constexpr`.
106+
*
107+
* Note that this does not hold if the function has been declared
108+
* `consteval`.
106109
*/
107110
predicate isDeclaredConstexpr() { this.hasSpecifier("declared_constexpr") }
108111

@@ -115,9 +118,16 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
115118
* template <typename T> constexpr int g(T x) { return f(x); }
116119
* ```
117120
* `g<int>` is declared constexpr, but is not constexpr.
121+
*
122+
* Will also hold if this function is `consteval`.
118123
*/
119124
predicate isConstexpr() { this.hasSpecifier("is_constexpr") }
120125

126+
/**
127+
* Holds if this function is declared to be `consteval`.
128+
*/
129+
predicate isConsteval() { this.hasSpecifier("is_consteval") }
130+
121131
/**
122132
* Holds if this function is declared with `__attribute__((naked))` or
123133
* `__declspec(naked)`.

cpp/ql/src/semmle/code/cpp/Type.qll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ private predicate isIntegralType(@builtintype type, int kind) {
376376
kind = 43
377377
or
378378
kind = 44
379+
or
380+
kind = 51
379381
)
380382
}
381383

@@ -463,6 +465,8 @@ private predicate integralTypeMapping(int original, int canonical, int unsigned,
463465
original = 43 and canonical = 43 and unsigned = -1 and signed = -1 // char16_t
464466
or
465467
original = 44 and canonical = 44 and unsigned = -1 and signed = -1 // char32_t
468+
or
469+
original = 51 and canonical = 51 and unsigned = -1 and signed = -1 // char8_t
466470
}
467471

468472
/**
@@ -993,6 +997,18 @@ class WideCharType extends IntegralType {
993997
override string getCanonicalQLClass() { result = "WideCharType" }
994998
}
995999

1000+
/**
1001+
* The C/C++ `char8_t` type. This is available starting with C++20.
1002+
* ```
1003+
* char8_t c8;
1004+
* ```
1005+
*/
1006+
class Char8Type extends IntegralType {
1007+
Char8Type() { builtintypes(underlyingElement(this), _, 51, _, _, _) }
1008+
1009+
override string getCanonicalQLClass() { result = "Char8Type" }
1010+
}
1011+
9961012
/**
9971013
* The C/C++ `char16_t` type. This is available starting with C11 and C++11.
9981014
* ```

0 commit comments

Comments
 (0)