mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C++: Handle C11 _Noreturn in DefaultOptions
This commit is contained in:
@@ -54,11 +54,13 @@ class Options extends string {
|
||||
*
|
||||
* By default, this holds for `exit`, `_exit`, `abort`, `__assert_fail`,
|
||||
* `longjmp`, `__builtin_unreachable` and any function with a
|
||||
* `noreturn` attribute.
|
||||
* `noreturn` attribute or specifier.
|
||||
*/
|
||||
predicate exits(Function f) {
|
||||
f.getAnAttribute().hasName("noreturn")
|
||||
or
|
||||
f.getASpecifier().hasName("noreturn")
|
||||
or
|
||||
f.hasGlobalOrStdName([
|
||||
"exit", "_exit", "abort", "__assert_fail", "longjmp", "__builtin_unreachable"
|
||||
])
|
||||
|
||||
@@ -39,7 +39,7 @@ class CustomOptions extends Options {
|
||||
*
|
||||
* By default, this holds for `exit`, `_exit`, `abort`, `__assert_fail`,
|
||||
* `longjmp`, `error`, `__builtin_unreachable` and any function with a
|
||||
* `noreturn` attribute.
|
||||
* `noreturn` attribute or specifier.
|
||||
*/
|
||||
override predicate exits(Function f) { Options.super.exits(f) }
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class FunctionSpecifier extends Specifier {
|
||||
|
||||
/**
|
||||
* A C/C++ storage class specifier: `auto`, `register`, `static`, `extern`,
|
||||
* or `mutable".
|
||||
* or `mutable`.
|
||||
*/
|
||||
class StorageClassSpecifier extends Specifier {
|
||||
StorageClassSpecifier() { this.hasName(["auto", "register", "static", "extern", "mutable"]) }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
// semmle-extractor-options: -std=c11
|
||||
int f1(void) {
|
||||
int x = 1;
|
||||
return 2;
|
||||
@@ -99,3 +99,9 @@ int f14()
|
||||
{
|
||||
__asm__("rdtsc"); // GOOD
|
||||
}
|
||||
|
||||
_Noreturn void f15();
|
||||
|
||||
int f16() {
|
||||
f15(); // GOOD
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
// semmle-extractor-options: -std=c++11
|
||||
class MyValue {
|
||||
public:
|
||||
MyValue(int _val) : val(_val) {};
|
||||
@@ -164,3 +164,9 @@ int g19(int x)
|
||||
|
||||
return x; // GOOD
|
||||
}
|
||||
|
||||
[[noreturn]] void g20();
|
||||
|
||||
int g21() {
|
||||
g20(); // GOOD
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user