Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
C++: Make IRVariable non-abstract
  • Loading branch information
dave-bartolomeo committed Aug 14, 2019
commit d40e9f02cea9b3128527f53cf104aecdeaaaeb2c
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,35 @@ IRUserVariable getIRUserVariable(Language::Function func, Language::Variable var
* be a user-declared variable (`IRUserVariable`) or a temporary variable
* generated by the AST-to-IR translation (`IRTempVariable`).
*/
abstract class IRVariable extends TIRVariable {
class IRVariable extends TIRVariable {
Language::Function func;

abstract string toString();
string toString() {
none()
}

/**
* Gets the type of the variable.
*/
abstract Language::Type getType();
Language::Type getType() {
none()
}

/**
* Gets the AST node that declared this variable, or that introduced this
* variable as part of the AST-to-IR translation.
*/
abstract Language::AST getAST();
Language::AST getAST() {
none()
}

/**
* Gets an identifier string for the variable. This identifier is unique
* within the function.
*/
abstract string getUniqueId();
string getUniqueId() {
none()
}

/**
* Gets the source location of this variable.
Expand Down Expand Up @@ -100,10 +108,14 @@ class IRUserVariable extends IRVariable, TIRUserVariable {
* stack. This includes all parameters, non-static local variables, and
* temporary variables.
*/
abstract class IRAutomaticVariable extends IRVariable {
class IRAutomaticVariable extends IRVariable {
IRAutomaticVariable() {
this instanceof IRAutomaticUserVariable or
this instanceof IRTempVariable
}
}

class IRAutomaticUserVariable extends IRUserVariable, IRAutomaticVariable {
class IRAutomaticUserVariable extends IRUserVariable {
override Language::AutomaticVariable var;

IRAutomaticUserVariable() {
Expand Down Expand Up @@ -132,7 +144,7 @@ IRTempVariable getIRTempVariable(Language::AST ast, TempVariableTag tag) {
result.getTag() = tag
}

class IRTempVariable extends IRVariable, IRAutomaticVariable, TIRTempVariable {
class IRTempVariable extends IRVariable, TIRTempVariable {
Language::AST ast;
TempVariableTag tag;
Language::Type type;
Expand Down
28 changes: 20 additions & 8 deletions cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRVariable.qll
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,35 @@ IRUserVariable getIRUserVariable(Language::Function func, Language::Variable var
* be a user-declared variable (`IRUserVariable`) or a temporary variable
* generated by the AST-to-IR translation (`IRTempVariable`).
*/
abstract class IRVariable extends TIRVariable {
class IRVariable extends TIRVariable {
Language::Function func;

abstract string toString();
string toString() {
none()
}

/**
* Gets the type of the variable.
*/
abstract Language::Type getType();
Language::Type getType() {
none()
}

/**
* Gets the AST node that declared this variable, or that introduced this
* variable as part of the AST-to-IR translation.
*/
abstract Language::AST getAST();
Language::AST getAST() {
none()
}

/**
* Gets an identifier string for the variable. This identifier is unique
* within the function.
*/
abstract string getUniqueId();
string getUniqueId() {
none()
}

/**
* Gets the source location of this variable.
Expand Down Expand Up @@ -100,10 +108,14 @@ class IRUserVariable extends IRVariable, TIRUserVariable {
* stack. This includes all parameters, non-static local variables, and
* temporary variables.
*/
abstract class IRAutomaticVariable extends IRVariable {
class IRAutomaticVariable extends IRVariable {
IRAutomaticVariable() {
this instanceof IRAutomaticUserVariable or
this instanceof IRTempVariable
}
}

class IRAutomaticUserVariable extends IRUserVariable, IRAutomaticVariable {
class IRAutomaticUserVariable extends IRUserVariable {
override Language::AutomaticVariable var;

IRAutomaticUserVariable() {
Expand Down Expand Up @@ -132,7 +144,7 @@ IRTempVariable getIRTempVariable(Language::AST ast, TempVariableTag tag) {
result.getTag() = tag
}

class IRTempVariable extends IRVariable, IRAutomaticVariable, TIRTempVariable {
class IRTempVariable extends IRVariable, TIRTempVariable {
Language::AST ast;
TempVariableTag tag;
Language::Type type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,35 @@ IRUserVariable getIRUserVariable(Language::Function func, Language::Variable var
* be a user-declared variable (`IRUserVariable`) or a temporary variable
* generated by the AST-to-IR translation (`IRTempVariable`).
*/
abstract class IRVariable extends TIRVariable {
class IRVariable extends TIRVariable {
Language::Function func;

abstract string toString();
string toString() {
none()
}

/**
* Gets the type of the variable.
*/
abstract Language::Type getType();
Language::Type getType() {
none()
}

/**
* Gets the AST node that declared this variable, or that introduced this
* variable as part of the AST-to-IR translation.
*/
abstract Language::AST getAST();
Language::AST getAST() {
none()
}

/**
* Gets an identifier string for the variable. This identifier is unique
* within the function.
*/
abstract string getUniqueId();
string getUniqueId() {
none()
}

/**
* Gets the source location of this variable.
Expand Down Expand Up @@ -100,10 +108,14 @@ class IRUserVariable extends IRVariable, TIRUserVariable {
* stack. This includes all parameters, non-static local variables, and
* temporary variables.
*/
abstract class IRAutomaticVariable extends IRVariable {
class IRAutomaticVariable extends IRVariable {
IRAutomaticVariable() {
this instanceof IRAutomaticUserVariable or
this instanceof IRTempVariable
}
}

class IRAutomaticUserVariable extends IRUserVariable, IRAutomaticVariable {
class IRAutomaticUserVariable extends IRUserVariable {
override Language::AutomaticVariable var;

IRAutomaticUserVariable() {
Expand Down Expand Up @@ -132,7 +144,7 @@ IRTempVariable getIRTempVariable(Language::AST ast, TempVariableTag tag) {
result.getTag() = tag
}

class IRTempVariable extends IRVariable, IRAutomaticVariable, TIRTempVariable {
class IRTempVariable extends IRVariable, TIRTempVariable {
Language::AST ast;
TempVariableTag tag;
Language::Type type;
Expand Down