Skip to content

Commit 54488eb

Browse files
committed
C++: fix global vars accesses in global vars
1 parent a3f1d61 commit 54488eb

File tree

8 files changed

+5
-10
lines changed

8 files changed

+5
-10
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ private Element getRealParent(Expr expr) {
2525
result.(Destructor).getADestruction() = expr
2626
}
2727

28-
IRUserVariable getIRUserVariable(Function func, Variable var) {
28+
IRUserVariable getIRUserVariable(Declaration decl, Variable var) {
2929
result.getVariable() = var and
30-
result.getEnclosingFunction() = func
30+
result.getEnclosingFunction() = decl
3131
}
3232

3333
IRTempVariable getIRTempVariable(Locatable ast, TempVariableTag tag) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ class TranslatedNonFieldVariableAccess extends TranslatedVariableAccess {
841841

842842
override IRVariable getInstructionVariable(InstructionTag tag) {
843843
tag = OnlyInstructionTag() and
844-
result = getIRUserVariable(expr.getEnclosingFunction(), expr.getTarget())
844+
result = getIRUserVariable(expr.getEnclosingDeclaration(), expr.getTarget())
845845
}
846846
}
847847

cpp/ql/test/library-tests/ir/ir/aliased_ssa_consistency.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ nonUniqueEnclosingIRFunction
2424
fieldAddressOnNonPointer
2525
thisArgumentIsNonPointer
2626
nonUniqueIRVariable
27-
| ir.cpp:1831:16:1831:23 | VariableAddress: global_2 | Variable address instruction 'VariableAddress: global_2' has no associated variable, in function '$@'. | ir.cpp:1831:5:1831:12 | int global_6 | int global_6 |
2827
missingCanonicalLanguageType
2928
multipleCanonicalLanguageTypes
3029
missingIRType

cpp/ql/test/library-tests/ir/ir/aliased_ssa_consistency_unsound.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ nonUniqueEnclosingIRFunction
2424
fieldAddressOnNonPointer
2525
thisArgumentIsNonPointer
2626
nonUniqueIRVariable
27-
| ir.cpp:1831:16:1831:23 | VariableAddress: global_2 | Variable address instruction 'VariableAddress: global_2' has no associated variable, in function '$@'. | ir.cpp:1831:5:1831:12 | int global_6 | int global_6 |
2827
missingCanonicalLanguageType
2928
multipleCanonicalLanguageTypes
3029
missingIRType

cpp/ql/test/library-tests/ir/ir/raw_consistency.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ nonUniqueEnclosingIRFunction
2828
fieldAddressOnNonPointer
2929
thisArgumentIsNonPointer
3030
nonUniqueIRVariable
31-
| ir.cpp:1831:16:1831:23 | VariableAddress: global_2 | Variable address instruction 'VariableAddress: global_2' has no associated variable, in function '$@'. | ir.cpp:1831:5:1831:12 | int global_6 | int global_6 |
3231
missingCanonicalLanguageType
3332
multipleCanonicalLanguageTypes
3433
missingIRType

cpp/ql/test/library-tests/ir/ir/raw_ir.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9801,8 +9801,8 @@ ir.cpp:
98019801
# 1831| v1831_1(void) = EnterFunction :
98029802
# 1831| mu1831_2(unknown) = AliasedDefinition :
98039803
# 1831| r1831_3(glval<int>) = VariableAddress[global_6] :
9804-
# 1831| r1831_4(glval<int>) = VariableAddress :
9805-
# 1831| r1831_5(int) = Load[?] : &:r1831_4, ~m?
9804+
# 1831| r1831_4(glval<int>) = VariableAddress[global_2] :
9805+
# 1831| r1831_5(int) = Load[global_2] : &:r1831_4, ~m?
98069806
# 1831| mu1831_6(int) = Store[global_6] : &:r1831_3, r1831_5
98079807
# 1831| v1831_7(void) = ReturnVoid :
98089808
# 1831| v1831_8(void) = AliasedUse : ~m?

cpp/ql/test/library-tests/ir/ir/unaliased_ssa_consistency.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ nonUniqueEnclosingIRFunction
2424
fieldAddressOnNonPointer
2525
thisArgumentIsNonPointer
2626
nonUniqueIRVariable
27-
| ir.cpp:1831:16:1831:23 | VariableAddress: global_2 | Variable address instruction 'VariableAddress: global_2' has no associated variable, in function '$@'. | ir.cpp:1831:5:1831:12 | int global_6 | int global_6 |
2827
missingCanonicalLanguageType
2928
multipleCanonicalLanguageTypes
3029
missingIRType

cpp/ql/test/library-tests/ir/ir/unaliased_ssa_consistency_unsound.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ nonUniqueEnclosingIRFunction
2424
fieldAddressOnNonPointer
2525
thisArgumentIsNonPointer
2626
nonUniqueIRVariable
27-
| ir.cpp:1831:16:1831:23 | VariableAddress: global_2 | Variable address instruction 'VariableAddress: global_2' has no associated variable, in function '$@'. | ir.cpp:1831:5:1831:12 | int global_6 | int global_6 |
2827
missingCanonicalLanguageType
2928
multipleCanonicalLanguageTypes
3029
missingIRType

0 commit comments

Comments
 (0)