Skip to content

Commit deff282

Browse files
committed
C++: Modernize getAnAssignedValue following PR comments
1 parent 0fb534c commit deff282

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ class Variable extends Declaration, @variable {
115115
else result = this.getADeclarationLocation()
116116
}
117117

118-
/** Pulled out of `getAnAssignedValue` to fix a bad join order */
119-
pragma[noinline]
120-
private predicate aggregateLiteralHasType(AggregateLiteral lit, Class c) { lit.getType() = c }
121-
122118
/**
123119
* Gets an expression that is assigned to this variable somewhere in the
124120
* program.
@@ -130,11 +126,7 @@ class Variable extends Declaration, @variable {
130126
or
131127
exists(AssignExpr ae | ae.getLValue().(Access).getTarget() = this and result = ae.getRValue())
132128
or
133-
exists(AggregateLiteral l, Class c |
134-
this.(Field).getDeclaringType() = c and
135-
aggregateLiteralHasType(l, c) and
136-
result = l.getChild(this.(Field).getInitializationOrder())
137-
)
129+
exists(ClassAggregateLiteral l | result = l.getFieldExpr(this))
138130
}
139131

140132
/**

0 commit comments

Comments
 (0)