diff --git a/cpp/ql/lib/semmle/code/cpp/Specifier.qll b/cpp/ql/lib/semmle/code/cpp/Specifier.qll index 2f1976d220c..28ba2195656 100644 --- a/cpp/ql/lib/semmle/code/cpp/Specifier.qll +++ b/cpp/ql/lib/semmle/code/cpp/Specifier.qll @@ -97,6 +97,18 @@ class AccessSpecifier extends Specifier { override string getAPrimaryQlClass() { result = "AccessSpecifier" } } +/** + * A C/C++ calling convention specifier: `cdecl`, `fastcall`, `stdcall`, `thiscall`, + * `vectorcall`, or `clrcall`. + */ +class CallingConventionSpecifier extends Specifier { + CallingConventionSpecifier() { + this.hasName(["cdecl", "fastcall", "stdcall", "thiscall", "vectorcall", "clrcall"]) + } + + override string getAPrimaryQlClass() { result = "CallingConventionSpecifier" } +} + /** * An attribute introduced by GNU's `__attribute__((name))` syntax, * Microsoft's `__declspec(name)` syntax, Microsoft's `[name]` syntax, the diff --git a/cpp/ql/test/library-tests/calling-convention/calling-convention.ql b/cpp/ql/test/library-tests/calling-convention/calling-convention.ql new file mode 100644 index 00000000000..02e3b3af5ce --- /dev/null +++ b/cpp/ql/test/library-tests/calling-convention/calling-convention.ql @@ -0,0 +1,5 @@ +import cpp + +from FunctionDeclarationEntry func, CallingConventionSpecifier ccs +where ccs.hasName(func.getASpecifier()) +select func, func.getASpecifier()