Skip to content

Commit 8a0af0b

Browse files
authored
Merge pull request github#3465 from MathiasVP/remove-abstract-from-access-and-cast
C++: Remove abstract keyword from `Access` and `Cast` classes
2 parents a536069 + 671242c commit 8a0af0b

File tree

7 files changed

+4308
-84
lines changed

7 files changed

+4308
-84
lines changed

cpp/ql/src/semmle/code/cpp/exprs/Access.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ private import semmle.code.cpp.dataflow.EscapesTree
66
/**
77
* A C/C++ access expression. This refers to a function, variable, or enum constant.
88
*/
9-
abstract class Access extends Expr, NameQualifiableElement {
9+
class Access extends Expr, NameQualifiableElement, @access {
10+
// As `@access` is a union type containing `@routineexpr` (which describes function accesses
11+
// that are called), we need to exclude function calls.
12+
Access() { this instanceof @routineexpr implies not iscall(underlyingElement(this), _) }
13+
1014
/** Gets the accessed function, variable, or enum constant. */
11-
abstract Declaration getTarget();
15+
Declaration getTarget() { none() } // overridden in subclasses
1216

1317
override predicate mayBeImpure() { none() }
1418

cpp/ql/src/semmle/code/cpp/exprs/Cast.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ private import semmle.code.cpp.internal.ResolveClass
77
* Instances of this class are not present in the main AST which is navigated by parent/child links. Instead,
88
* instances of this class are attached to nodes in the main AST via special conversion links.
99
*/
10-
abstract class Conversion extends Expr {
10+
class Conversion extends Expr, @conversion {
1111
/** Gets the expression being converted. */
1212
Expr getExpr() { result.getConversion() = this }
1313

cpp/ql/src/semmlecode.cpp.dbscheme

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,13 @@ conversionkinds(
11431143
int kind: int ref
11441144
);
11451145

1146+
@conversion = @cast
1147+
| @array_to_pointer
1148+
| @parexpr
1149+
| @reference_to
1150+
| @ref_indirect
1151+
;
1152+
11461153
/*
11471154
case @funbindexpr.kind of
11481155
0 = @normal_call // a normal call
@@ -1800,6 +1807,8 @@ lambda_capture(
18001807
@addressable = @function | @variable ;
18011808
@accessible = @addressable | @enumconstant ;
18021809

1810+
@access = @varaccess | @routineexpr ;
1811+
18031812
fold(
18041813
int expr: @foldexpr ref,
18051814
string operator: string ref,

0 commit comments

Comments
 (0)