Skip to content

Commit 483f4c3

Browse files
authored
Merge pull request #14921 from jketema/kr-style-function-parameters
C++: Expose whether a function was prototyped or not
2 parents 4df25f4 + 28ac46a commit 483f4c3

File tree

10 files changed

+9653
-713
lines changed

10 files changed

+9653
-713
lines changed

cpp/downgrades/0a9eb01d3650642e013eb86be45d952289537f91/old.dbscheme

Lines changed: 2233 additions & 0 deletions
Large diffs are not rendered by default.

cpp/downgrades/0a9eb01d3650642e013eb86be45d952289537f91/semmlecode.cpp.dbscheme

Lines changed: 2231 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
description: Expose whether a function was prototyped or not
2+
compatibility: backwards
3+
function_prototyped.rel: delete
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: feature
3+
---
4+
* Added an `isPrototyped` predicate to `Function` that holds when the function has a prototype.

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
112112
*/
113113
predicate isDeleted() { function_deleted(underlyingElement(this)) }
114114

115+
/**
116+
* Holds if this function has a prototyped interface.
117+
*
118+
* Functions generally have a prototyped interface, unless they are
119+
* K&R-style functions either without any forward function declaration,
120+
* or with all the forward declarations omitting the parameters of the
121+
* function.
122+
*/
123+
predicate isPrototyped() { function_prototyped(underlyingElement(this)) }
124+
115125
/**
116126
* Holds if this function is explicitly defaulted with the `= default`
117127
* specifier.

cpp/ql/lib/semmlecode.cpp.dbscheme

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@ function_deleted(unique int id: @function ref);
405405

406406
function_defaulted(unique int id: @function ref);
407407

408+
function_prototyped(unique int id: @function ref)
409+
408410
member_function_this_type(
409411
unique int id: @function ref,
410412
int this_type: @type ref

0 commit comments

Comments
 (0)