Skip to content

Commit d36c66c

Browse files
committed
remove redundant inline casts in arguments where the type is inferred by the call target
1 parent 15c90ad commit d36c66c

File tree

29 files changed

+51
-60
lines changed

29 files changed

+51
-60
lines changed

cpp/ql/lib/semmle/code/cpp/Class.qll

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class Class extends UserType {
237237
exists(ClassDerivation cd | cd.getBaseClass() = base |
238238
result =
239239
this.accessOfBaseMemberMulti(cd.getDerivedClass(),
240-
fieldInBase.accessInDirectDerived(cd.getASpecifier().(AccessSpecifier)))
240+
fieldInBase.accessInDirectDerived(cd.getASpecifier()))
241241
)
242242
}
243243

@@ -261,8 +261,7 @@ class Class extends UserType {
261261
* includes the case of `base` = `this`.
262262
*/
263263
AccessSpecifier accessOfBaseMember(Declaration member) {
264-
result =
265-
this.accessOfBaseMember(member.getDeclaringType(), member.getASpecifier().(AccessSpecifier))
264+
result = this.accessOfBaseMember(member.getDeclaringType(), member.getASpecifier())
266265
}
267266

268267
/**
@@ -319,7 +318,7 @@ class Class extends UserType {
319318
exists(Type t | t = this.getAFieldSubobjectType().getUnspecifiedType() |
320319
// Note: Overload resolution is not implemented -- all copy
321320
// constructors are considered equal.
322-
this.cannotAccessCopyConstructorOnAny(t.(Class))
321+
this.cannotAccessCopyConstructorOnAny(t)
323322
)
324323
or
325324
// - T has direct or virtual base class that cannot be copied (has deleted,
@@ -392,7 +391,7 @@ class Class extends UserType {
392391
exists(Type t | t = this.getAFieldSubobjectType().getUnspecifiedType() |
393392
// Note: Overload resolution is not implemented -- all copy assignment
394393
// operators are considered equal.
395-
this.cannotAccessCopyAssignmentOperatorOnAny(t.(Class))
394+
this.cannotAccessCopyAssignmentOperatorOnAny(t)
396395
)
397396
or
398397
exists(Class c | c = this.getADirectOrVirtualBase() |

cpp/ql/lib/semmle/code/cpp/Declaration.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,7 @@ class AccessHolder extends Declaration, TAccessHolder {
490490
*/
491491
pragma[inline]
492492
predicate canAccessMember(Declaration member, Class derived) {
493-
this.couldAccessMember(member.getDeclaringType(), member.getASpecifier().(AccessSpecifier),
494-
derived)
493+
this.couldAccessMember(member.getDeclaringType(), member.getASpecifier(), derived)
495494
}
496495

497496
/**

cpp/ql/lib/semmle/code/cpp/commons/Dependency.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ private predicate dependsOnFull(DependsSource src, Symbol dest, int category) {
307307
// dependency from a Variable / Function use -> non-visible definition (link time)
308308
dependsOnTransitive(src, mid) and
309309
not mid instanceof EnumConstant and
310-
getDeclarationEntries(mid, dest.(DeclarationEntry)) and
310+
getDeclarationEntries(mid, dest) and
311311
not dest instanceof TypeDeclarationEntry and
312312
// must be definition
313313
dest.(DeclarationEntry).isDefinition() and

cpp/ql/lib/semmle/code/cpp/controlflow/DefinitionsAndUses.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ predicate definitionUsePair(SemanticStackVariable var, Expr def, Expr use) {
2525
* Holds if the definition `def` of some stack variable can reach `node`, which
2626
* is a definition or use, without crossing definitions of the same variable.
2727
*/
28-
predicate definitionReaches(Expr def, Expr node) { def.(Def).reaches(true, _, node.(DefOrUse)) }
28+
predicate definitionReaches(Expr def, Expr node) { def.(Def).reaches(true, _, node) }
2929

3030
private predicate hasAddressOfAccess(SemanticStackVariable var) {
3131
var.getAnAccess().isAddressOfAccessNonConst()

cpp/ql/lib/semmle/code/cpp/controlflow/SSA.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class SsaDefinition extends ControlFlowNodeBase {
6262
BasicBlock getBasicBlock() { result.contains(this.getDefinition()) }
6363

6464
/** Holds if this definition is a phi node for variable `v`. */
65-
predicate isPhiNode(StackVariable v) { exists(StandardSSA x | x.phi_node(v, this.(BasicBlock))) }
65+
predicate isPhiNode(StackVariable v) { exists(StandardSSA x | x.phi_node(v, this)) }
6666

6767
/** Gets the location of this definition. */
6868
Location getLocation() { result = this.(ControlFlowNode).getLocation() }

cpp/ql/lib/semmle/code/cpp/controlflow/SSAUtils.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ library class SSAHelper extends int {
292292
*/
293293
cached
294294
string toString(ControlFlowNode node, StackVariable v) {
295-
if phi_node(v, node.(BasicBlock))
295+
if phi_node(v, node)
296296
then result = "SSA phi(" + v.getName() + ")"
297297
else (
298298
ssa_defn(v, node, _, _) and result = "SSA def(" + v.getName() + ")"

cpp/ql/lib/semmle/code/cpp/controlflow/internal/ConstantExprs.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ library class ExprEvaluator extends int {
484484
this.interestingInternal(e, req, true) and
485485
(
486486
result = req.(CompileTimeConstantInt).getIntValue() or
487-
result = this.getCompoundValue(e, req.(CompileTimeVariableExpr))
487+
result = this.getCompoundValue(e, req)
488488
) and
489489
(
490490
req.getUnderlyingType().(IntegralType).isSigned() or
@@ -611,7 +611,7 @@ library class ExprEvaluator extends int {
611611
or
612612
exists(AssignExpr req | req = val | result = this.getValueInternal(e, req.getRValue()))
613613
or
614-
result = this.getVariableValue(e, val.(VariableAccess))
614+
result = this.getVariableValue(e, val)
615615
or
616616
exists(FunctionCall call | call = val and not callWithMultipleTargets(call) |
617617
result = this.getFunctionValue(call.getTarget())
@@ -663,7 +663,7 @@ library class ExprEvaluator extends int {
663663
this.interestingInternal(_, req, false) and
664664
(
665665
result = req.(CompileTimeConstantInt).getIntValue() or
666-
result = this.getCompoundValueNonSubExpr(req.(CompileTimeVariableExpr))
666+
result = this.getCompoundValueNonSubExpr(req)
667667
) and
668668
(
669669
req.getUnderlyingType().(IntegralType).isSigned() or
@@ -787,7 +787,7 @@ library class ExprEvaluator extends int {
787787
or
788788
exists(AssignExpr req | req = val | result = this.getValueInternalNonSubExpr(req.getRValue()))
789789
or
790-
result = this.getVariableValueNonSubExpr(val.(VariableAccess))
790+
result = this.getVariableValueNonSubExpr(val)
791791
or
792792
exists(FunctionCall call | call = val and not callWithMultipleTargets(call) |
793793
result = this.getFunctionValue(call.getTarget())

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,9 +1305,9 @@ class TranslatedBinaryOperation extends TranslatedSingleInstructionExpr {
13051305
}
13061306

13071307
override Opcode getOpcode() {
1308-
result = binaryArithmeticOpcode(expr.(BinaryArithmeticOperation)) or
1309-
result = binaryBitwiseOpcode(expr.(BinaryBitwiseOperation)) or
1310-
result = comparisonOpcode(expr.(ComparisonOperation))
1308+
result = binaryArithmeticOpcode(expr) or
1309+
result = binaryBitwiseOpcode(expr) or
1310+
result = comparisonOpcode(expr)
13111311
}
13121312

13131313
override int getInstructionElementSize(InstructionTag tag) {

cpp/ql/lib/semmle/code/cpp/padding/Padding.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ abstract class Architecture extends string {
8888
or
8989
t instanceof LongLongType and result = this.longLongSize()
9090
or
91-
result = this.enumBitSize(t.(Enum))
91+
result = this.enumBitSize(t)
9292
or
9393
result = this.integralBitSize(t.(SpecifiedType).getBaseType())
9494
or
@@ -183,7 +183,7 @@ abstract class Architecture extends string {
183183
or
184184
t instanceof ReferenceType and result = this.pointerSize()
185185
or
186-
result = this.enumAlignment(t.(Enum))
186+
result = this.enumAlignment(t)
187187
or
188188
result = this.alignment(t.(SpecifiedType).getBaseType())
189189
or
@@ -232,14 +232,14 @@ private Field getAnInitialField(PaddedType t) {
232232
result = t.getAField()
233233
or
234234
// Initial field of the type of a field of the union
235-
result = getAnInitialField(t.getAField().getUnspecifiedType().(PaddedType))
235+
result = getAnInitialField(t.getAField().getUnspecifiedType())
236236
else
237237
exists(Field firstField | t.fieldIndex(firstField) = 1 |
238238
// The first field of `t`
239239
result = firstField
240240
or
241241
// Initial field of the first field of `t`
242-
result = getAnInitialField(firstField.getUnspecifiedType().(PaddedType))
242+
result = getAnInitialField(firstField.getUnspecifiedType())
243243
)
244244
}
245245

cpp/ql/lib/semmle/code/cpp/rangeanalysis/RangeSSA.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class RangeSsaDefinition extends ControlFlowNodeBase {
9191
BasicBlock getBasicBlock() { result.contains(this.getDefinition()) }
9292

9393
/** Whether this definition is a phi node for variable `v`. */
94-
predicate isPhiNode(StackVariable v) { exists(RangeSSA x | x.phi_node(v, this.(BasicBlock))) }
94+
predicate isPhiNode(StackVariable v) { exists(RangeSSA x | x.phi_node(v, this)) }
9595

9696
/**
9797
* DEPRECATED: Use isGuardPhi/4 instead

0 commit comments

Comments
 (0)