Skip to content

Commit 0b74d56

Browse files
authored
Merge pull request github#2959 from jbj/getCanonicalQLClass-Variable
C++: Add getCanonicalQLClass overrides in Variable
2 parents 46a645c + 76066af commit 0b74d56

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import semmle.code.cpp.exprs.Access
1919
class Field extends MemberVariable {
2020
Field() { fieldoffsets(underlyingElement(this), _, _) }
2121

22+
override string getCanonicalQLClass() { result = "Field" }
23+
2224
/**
2325
* Gets the offset of this field in bytes from the start of its declaring
2426
* type (on the machine where facts were extracted).
@@ -84,6 +86,8 @@ class Field extends MemberVariable {
8486
class BitField extends Field {
8587
BitField() { bitfield(underlyingElement(this), _, _) }
8688

89+
override string getCanonicalQLClass() { result = "BitField" }
90+
8791
/**
8892
* Gets the size of this bitfield in bits (on the machine where facts
8993
* were extracted).

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ private import semmle.code.cpp.internal.ResolveClass
2828
* can have multiple declarations.
2929
*/
3030
class Variable extends Declaration, @variable {
31+
override string getCanonicalQLClass() { result = "Variable" }
32+
3133
/** Gets the initializer of this variable, if any. */
3234
Initializer getInitializer() { result.getDeclaration() = this }
3335

@@ -351,6 +353,8 @@ class StackVariable extends LocalScopeVariable {
351353
* A local variable can be declared by a `DeclStmt` or a `ConditionDeclExpr`.
352354
*/
353355
class LocalVariable extends LocalScopeVariable, @localvariable {
356+
override string getCanonicalQLClass() { result = "LocalVariable" }
357+
354358
override string getName() { localvariables(underlyingElement(this), _, result) }
355359

356360
override Type getType() { localvariables(underlyingElement(this), unresolveElement(result), _) }
@@ -396,6 +400,8 @@ class NamespaceVariable extends GlobalOrNamespaceVariable {
396400
NamespaceVariable() {
397401
exists(Namespace n | namespacembrs(unresolveElement(n), underlyingElement(this)))
398402
}
403+
404+
override string getCanonicalQLClass() { result = "NamespaceVariable" }
399405
}
400406

401407
/**
@@ -415,6 +421,8 @@ class NamespaceVariable extends GlobalOrNamespaceVariable {
415421
*/
416422
class GlobalVariable extends GlobalOrNamespaceVariable {
417423
GlobalVariable() { not this instanceof NamespaceVariable }
424+
425+
override string getCanonicalQLClass() { result = "GlobalVariable" }
418426
}
419427

420428
/**
@@ -434,6 +442,8 @@ class GlobalVariable extends GlobalOrNamespaceVariable {
434442
class MemberVariable extends Variable, @membervariable {
435443
MemberVariable() { this.isMember() }
436444

445+
override string getCanonicalQLClass() { result = "MemberVariable" }
446+
437447
/** Holds if this member is private. */
438448
predicate isPrivate() { this.hasSpecifier("private") }
439449

0 commit comments

Comments
 (0)