Skip to content

C++: Improve alias analysis for indirections #1736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

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
@@ -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.
@@ -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() {
@@ -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;
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
@@ -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.
@@ -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() {
@@ -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;
Original file line number Diff line number Diff line change
@@ -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.
@@ -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() {
@@ -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;