Skip to content

Commit be08b97

Browse files
authored
Merge pull request github#12999 from kaspersv/kaspersv/cpp-explicit-this-receiver
C++: Make implicit this receivers explicit
2 parents a92a55f + c9fba18 commit be08b97

File tree

3 files changed

+309
-290
lines changed

3 files changed

+309
-290
lines changed

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ abstract class TranslatedElement extends TTranslatedElement {
821821
abstract Locatable getAst();
822822

823823
/** DEPRECATED: Alias for getAst */
824-
deprecated Locatable getAST() { result = getAst() }
824+
deprecated Locatable getAST() { result = this.getAst() }
825825

826826
/**
827827
* Get the first instruction to be executed in the evaluation of this element.
@@ -831,7 +831,7 @@ abstract class TranslatedElement extends TTranslatedElement {
831831
/**
832832
* Get the immediate child elements of this element.
833833
*/
834-
final TranslatedElement getAChild() { result = getChild(_) }
834+
final TranslatedElement getAChild() { result = this.getChild(_) }
835835

836836
/**
837837
* Gets the immediate child element of this element. The `id` is unique
@@ -844,25 +844,29 @@ abstract class TranslatedElement extends TTranslatedElement {
844844
* Gets the an identifier string for the element. This id is unique within
845845
* the scope of the element's function.
846846
*/
847-
final int getId() { result = getUniqueId() }
847+
final int getId() { result = this.getUniqueId() }
848848

849849
private TranslatedElement getChildByRank(int rankIndex) {
850850
result =
851-
rank[rankIndex + 1](TranslatedElement child, int id | child = getChild(id) | child order by id)
851+
rank[rankIndex + 1](TranslatedElement child, int id |
852+
child = this.getChild(id)
853+
|
854+
child order by id
855+
)
852856
}
853857

854858
language[monotonicAggregates]
855859
private int getDescendantCount() {
856860
result =
857-
1 + sum(TranslatedElement child | child = getChildByRank(_) | child.getDescendantCount())
861+
1 + sum(TranslatedElement child | child = this.getChildByRank(_) | child.getDescendantCount())
858862
}
859863

860864
private int getUniqueId() {
861-
if not exists(getParent())
865+
if not exists(this.getParent())
862866
then result = 0
863867
else
864868
exists(TranslatedElement parent |
865-
parent = getParent() and
869+
parent = this.getParent() and
866870
if this = parent.getChildByRank(0)
867871
then result = 1 + parent.getUniqueId()
868872
else
@@ -908,7 +912,7 @@ abstract class TranslatedElement extends TTranslatedElement {
908912
* there is no enclosing `try`.
909913
*/
910914
Instruction getExceptionSuccessorInstruction() {
911-
result = getParent().getExceptionSuccessorInstruction()
915+
result = this.getParent().getExceptionSuccessorInstruction()
912916
}
913917

914918
/**
@@ -1022,14 +1026,14 @@ abstract class TranslatedElement extends TTranslatedElement {
10221026
exists(Locatable ast |
10231027
result.getAst() = ast and
10241028
result.getTag() = tag and
1025-
hasTempVariableAndAst(tag, ast)
1029+
this.hasTempVariableAndAst(tag, ast)
10261030
)
10271031
}
10281032

10291033
pragma[noinline]
10301034
private predicate hasTempVariableAndAst(TempVariableTag tag, Locatable ast) {
1031-
hasTempVariable(tag, _) and
1032-
ast = getAst()
1035+
this.hasTempVariable(tag, _) and
1036+
ast = this.getAst()
10331037
}
10341038

10351039
/**

0 commit comments

Comments
 (0)