GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — simplify expressions that could be type-casts · github/codeql@4e8e3a7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • cpp/ql
    • lib/semmle/code/cpp
      • Class.qll
      • Specifier.qll
      • XML.qll
      • controlflow
        • IRGuards.qll
      • dataflow/internal
        • DataFlowPrivate.qll
      • exprs
        • Access.qll
        • Call.qll
        • Cast.qll
      • metrics
        • MetricClass.qll
      • padding
        • Padding.qll
      • pointsto
        • PointsTo.qll
      • security
        • TaintTrackingImpl.qll
      • stmts
        • Stmt.qll
    • src
      • Critical
        • DeadCodeGoto.ql
      • Likely Bugs/Leap Year
        • LeapYear.qll
      • Security/CWE/CWE-732
        • UnsafeDaclSecurityDescriptor.ql
      • experimental/Security/CWE
        • CWE-1041
          • FindWrapperFunctions.ql
        • CWE-675
          • DoubleRelease.ql
      • jsf/4.10 Classes
        • AV Rule 97.1.ql
  • csharp/ql
    • lib
      • Linq
        • Helpers.qll
      • semmle/code/csharp
        • XML.qll
        • dispatch
          • Dispatch.qll
    • src
      • Likely Bugs/Statements
        • UseBraces.ql
      • experimental/ir/internal
        • IRGuards.qll
  • docs/codeql/writing-codeql-queries
    • river-crossing.ql
  • javascript/ql
    • lib/semmle/javascript
      • XML.qll
      • frameworks
        • Files.qll
    • src/experimental/Security/CWE-020
      • PostMessageNoOriginCheck.ql
    • test/testUtilities
      • ConsistencyChecking.qll
  • java/ql
    • lib/semmle/code
      • java
        • Expr.qll
        • Generics.qll
        • Statement.qll
        • controlflow
          • UnreachableBlocks.qll
        • dataflow
          • FlowSources.qll
        • deadcode
          • DeadEnumConstant.qll
          • frameworks
            • CamelEntryPoints.qll
        • frameworks
          • Mockito.qll
          • spring
            • SpringBean.qll
            • SpringBeanFile.qll
            • SpringXMLElement.qll
        • metrics
          • MetricElement.qll
          • MetricStmt.qll
        • security
          • UnsafeDeserializationQuery.qll
      • xml
        • XML.qll
    • src
      • Architecture/Dependencies
        • UnusedMavenDependencyBinary.ql
      • DeadCode
        • DeadField.ql
      • Frameworks/Spring/Violations of Best Practice
        • UseSetterInjection.ql
        • UseShortcutForms.ql
      • Likely Bugs
        • Cloning
          • MissingMethodClone.ql
        • Concurrency
          • WaitOutsideLoop.ql
        • Serialization
          • IncorrectSerialVersionUID.ql
          • NonSerializableInnerClass.ql
      • Violations of Best Practice/Implementation Hiding
        • StaticArray.ql
      • experimental/Security/CWE
        • CWE-094
          • SpringImplicitViewManipulation.ql
        • CWE-200
          • AndroidFileIntentSource.qll
        • CWE-326
          • InsufficientKeySize.ql
  • python/ql
    • lib/semmle/python
      • Comment.qll
      • Function.qll
      • Variables.qll
      • dataflow/new/internal
        • PrintNode.qll
      • pointsto
        • PointsTo.qll
      • types
        • Exceptions.qll
      • xml
        • XML.qll
    • src
      • Statements
        • MismatchInMultipleAssignment.ql
      • Variables
        • UndefinedExport.ql
        • UndefinedGlobal.ql
      • analysis
        • Efficiency.ql
  • ruby/ql
    • lib/codeql/ruby/frameworks
      • ActiveRecord.qll
      • http_clients
        • Httparty.qll
    • src/queries/security/cwe-732
      • WeakFilePermissions.ql

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/Class.qll
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ class Class extends UserType {
206206
* it is callable by a particular caller. For C++11, there's also a question
207207
* of whether to include members that are defaulted or deleted.
208208
*/
209-
deprecated predicate hasCopyConstructor() {
210-
exists(CopyConstructor cc | cc = this.getAMemberFunction())
211-
}
209+
deprecated predicate hasCopyConstructor() { this.getAMemberFunction() instanceof CopyConstructor }
212210

213211
/**
214212
* Holds if this class has a copy assignment operator that is either
@@ -224,7 +222,7 @@ class Class extends UserType {
224222
* or deleted.
225223
*/
226224
deprecated predicate hasCopyAssignmentOperator() {
227-
exists(CopyAssignmentOperator coa | coa = this.getAMemberFunction())
225+
this.getAMemberFunction() instanceof CopyAssignmentOperator
228226
}
229227

230228
/**
@@ -887,7 +885,7 @@ class NestedClass extends Class {
887885
* pure virtual function.
888886
*/
889887
class AbstractClass extends Class {
890-
AbstractClass() { exists(PureVirtualFunction f | this.getAMemberFunction() = f) }
888+
AbstractClass() { this.getAMemberFunction() instanceof PureVirtualFunction }
891889

892890
override string getAPrimaryQlClass() { result = "AbstractClass" }
893891
}
Collapse file

‎cpp/ql/lib/semmle/code/cpp/Specifier.qll‎

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/Specifier.qll
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,13 @@ class AttributeArgument extends Element, @attribute_arg {
286286
override Location getLocation() { attribute_args(underlyingElement(this), _, _, _, result) }
287287

288288
override string toString() {
289-
if exists(@attribute_arg_empty self | self = underlyingElement(this))
289+
if underlyingElement(this) instanceof @attribute_arg_empty
290290
then result = "empty argument"
291291
else
292292
exists(string prefix, string tail |
293293
(if exists(this.getName()) then prefix = this.getName() + "=" else prefix = "") and
294294
(
295-
if exists(@attribute_arg_type self | self = underlyingElement(this))
295+
if underlyingElement(this) instanceof @attribute_arg_type
296296
then tail = this.getValueType().getName()
297297
else tail = this.getValueText()
298298
) and
Collapse file

‎cpp/ql/lib/semmle/code/cpp/XML.qll‎

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/XML.qll
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class XMLElement extends @xmlelement, XMLParent, XMLLocatable {
233233
XMLAttribute getAttribute(string name) { result.getElement() = this and result.getName() = name }
234234

235235
/** Holds if this XML element has an attribute with the specified `name`. */
236-
predicate hasAttribute(string name) { exists(XMLAttribute a | a = this.getAttribute(name)) }
236+
predicate hasAttribute(string name) { exists(this.getAttribute(name)) }
237237

238238
/** Gets the value of the attribute with the specified `name`, if any. */
239239
string getAttributeValue(string name) { result = this.getAttribute(name).getValue() }
Collapse file

‎cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll‎

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/controlflow/IRGuards.qll
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class GuardCondition extends Expr {
2929
exists(IRGuardCondition ir | this = ir.getUnconvertedResultExpression())
3030
or
3131
// no binary operators in the IR
32-
exists(GuardCondition gc | this.(BinaryLogicalOperation).getAnOperand() = gc)
32+
this.(BinaryLogicalOperation).getAnOperand() instanceof GuardCondition
3333
or
3434
// the IR short-circuits if(!x)
3535
// don't produce a guard condition for `y = !x` and other non-short-circuited cases
@@ -98,7 +98,7 @@ class GuardCondition extends Expr {
9898
*/
9999
private class GuardConditionFromBinaryLogicalOperator extends GuardCondition {
100100
GuardConditionFromBinaryLogicalOperator() {
101-
exists(GuardCondition gc | this.(BinaryLogicalOperation).getAnOperand() = gc)
101+
this.(BinaryLogicalOperation).getAnOperand() instanceof GuardCondition
102102
}
103103

104104
override predicate controls(BasicBlock controlled, boolean testIsTrue) {
Collapse file

‎cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowPrivate.qll‎

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowPrivate.qll
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private class Argument extends Expr {
4848
*/
4949
class ArgumentNode extends Node {
5050
ArgumentNode() {
51-
exists(Argument arg | this.asExpr() = arg) or
51+
this.asExpr() instanceof Argument or
5252
this = getInstanceArgument(_)
5353
}
5454

Collapse file

‎cpp/ql/lib/semmle/code/cpp/exprs/Access.qll‎

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/exprs/Access.qll
+5-7Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ class VariableAccess extends Access, @varaccess {
8484
exists(Assignment a | a.getLValue() = this) or
8585
exists(CrementOperation c | c.getOperand() = this) or
8686
exists(AddressOfExpr addof | addof.getOperand() = this) or
87-
exists(ReferenceToExpr rte | this.getConversion() = rte) or
88-
exists(ArrayToPointerConversion atpc | this.getConversion() = atpc)
87+
this.getConversion() instanceof ReferenceToExpr or
88+
this.getConversion() instanceof ArrayToPointerConversion
8989
}
9090

9191
/**
@@ -104,8 +104,8 @@ class VariableAccess extends Access, @varaccess {
104104
predicate isRValue() {
105105
not exists(AssignExpr ae | ae.getLValue() = this) and
106106
not exists(AddressOfExpr addof | addof.getOperand() = this) and
107-
not exists(ReferenceToExpr rte | this.getConversion() = rte) and
108-
not exists(ArrayToPointerConversion atpc | this.getConversion() = atpc)
107+
not this.getConversion() instanceof ReferenceToExpr and
108+
not this.getConversion() instanceof ArrayToPointerConversion
109109
}
110110

111111
/**
@@ -218,9 +218,7 @@ class PointerFieldAccess extends FieldAccess {
218218
class DotFieldAccess extends FieldAccess {
219219
override string getAPrimaryQlClass() { result = "DotFieldAccess" }
220220

221-
DotFieldAccess() {
222-
exists(Class c | c = this.getQualifier().getFullyConverted().getUnspecifiedType())
223-
}
221+
DotFieldAccess() { this.getQualifier().getFullyConverted().getUnspecifiedType() instanceof Class }
224222
}
225223

226224
/**
Collapse file

‎cpp/ql/lib/semmle/code/cpp/exprs/Call.qll‎

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/exprs/Call.qll
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Call extends Expr, NameQualifiableElement, TCall {
3535
*
3636
* For example, `ptr->f()` has a qualifier, whereas plain `f()` does not.
3737
*/
38-
predicate hasQualifier() { exists(Expr e | this.getChild(-1) = e) }
38+
predicate hasQualifier() { exists(this.getChild(-1)) }
3939

4040
/**
4141
* Gets the expression to the left of the function name or function pointer variable name.
Collapse file

‎cpp/ql/lib/semmle/code/cpp/exprs/Cast.qll‎

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/exprs/Cast.qll
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ class SizeofOperator extends Expr, @runtime_sizeof {
724724
* ```
725725
*/
726726
class SizeofExprOperator extends SizeofOperator {
727-
SizeofExprOperator() { exists(Expr e | this.getChild(0) = e) }
727+
SizeofExprOperator() { exists(this.getChild(0)) }
728728

729729
override string getAPrimaryQlClass() { result = "SizeofExprOperator" }
730730

@@ -787,7 +787,7 @@ class AlignofOperator extends Expr, @runtime_alignof {
787787
* ```
788788
*/
789789
class AlignofExprOperator extends AlignofOperator {
790-
AlignofExprOperator() { exists(Expr e | this.getChild(0) = e) }
790+
AlignofExprOperator() { exists(this.getChild(0)) }
791791

792792
/**
793793
* Gets the contained expression.
Collapse file

‎cpp/ql/lib/semmle/code/cpp/metrics/MetricClass.qll‎

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/metrics/MetricClass.qll
+20-20Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -308,45 +308,45 @@ class MetricClass extends Class {
308308
}
309309

310310
private string getAUsedHalsteadN1Operator() {
311-
exists(CommaExpr e | e = this.getAnEnclosedExpression()) and result = "comma"
311+
this.getAnEnclosedExpression() instanceof CommaExpr and result = "comma"
312312
or
313-
exists(ReferenceToExpr e | e = this.getAnEnclosedExpression()) and result = "refTo"
313+
this.getAnEnclosedExpression() instanceof ReferenceToExpr and result = "refTo"
314314
or
315-
exists(PointerDereferenceExpr e | e = this.getAnEnclosedExpression()) and result = "dereference"
315+
this.getAnEnclosedExpression() instanceof PointerDereferenceExpr and result = "dereference"
316316
or
317-
exists(CStyleCast e | e = this.getAnEnclosedExpression()) and result = "cCast"
317+
this.getAnEnclosedExpression() instanceof CStyleCast and result = "cCast"
318318
or
319-
exists(StaticCast e | e = this.getAnEnclosedExpression()) and result = "staticCast"
319+
this.getAnEnclosedExpression() instanceof StaticCast and result = "staticCast"
320320
or
321-
exists(ConstCast e | e = this.getAnEnclosedExpression()) and result = "constCast"
321+
this.getAnEnclosedExpression() instanceof ConstCast and result = "constCast"
322322
or
323-
exists(ReinterpretCast e | e = this.getAnEnclosedExpression()) and result = "reinterpretCast"
323+
this.getAnEnclosedExpression() instanceof ReinterpretCast and result = "reinterpretCast"
324324
or
325-
exists(DynamicCast e | e = this.getAnEnclosedExpression()) and result = "dynamicCast"
325+
this.getAnEnclosedExpression() instanceof DynamicCast and result = "dynamicCast"
326326
or
327-
exists(SizeofExprOperator e | e = this.getAnEnclosedExpression()) and result = "sizeofExpr"
327+
this.getAnEnclosedExpression() instanceof SizeofExprOperator and result = "sizeofExpr"
328328
or
329-
exists(SizeofTypeOperator e | e = this.getAnEnclosedExpression()) and result = "sizeofType"
329+
this.getAnEnclosedExpression() instanceof SizeofTypeOperator and result = "sizeofType"
330330
or
331-
exists(IfStmt e | e = this.getAnEnclosedStmt()) and result = "ifVal"
331+
this.getAnEnclosedStmt() instanceof IfStmt and result = "ifVal"
332332
or
333-
exists(SwitchStmt e | e = this.getAnEnclosedStmt()) and result = "switchVal"
333+
this.getAnEnclosedStmt() instanceof SwitchStmt and result = "switchVal"
334334
or
335-
exists(ForStmt e | e = this.getAnEnclosedStmt()) and result = "forVal"
335+
this.getAnEnclosedStmt() instanceof ForStmt and result = "forVal"
336336
or
337-
exists(DoStmt e | e = this.getAnEnclosedStmt()) and result = "doVal"
337+
this.getAnEnclosedStmt() instanceof DoStmt and result = "doVal"
338338
or
339-
exists(WhileStmt e | e = this.getAnEnclosedStmt()) and result = "whileVal"
339+
this.getAnEnclosedStmt() instanceof WhileStmt and result = "whileVal"
340340
or
341-
exists(GotoStmt e | e = this.getAnEnclosedStmt()) and result = "gotoVal"
341+
this.getAnEnclosedStmt() instanceof GotoStmt and result = "gotoVal"
342342
or
343-
exists(ContinueStmt e | e = this.getAnEnclosedStmt()) and result = "continueVal"
343+
this.getAnEnclosedStmt() instanceof ContinueStmt and result = "continueVal"
344344
or
345-
exists(BreakStmt e | e = this.getAnEnclosedStmt()) and result = "breakVal"
345+
this.getAnEnclosedStmt() instanceof BreakStmt and result = "breakVal"
346346
or
347-
exists(ReturnStmt e | e = this.getAnEnclosedStmt()) and result = "returnVal"
347+
this.getAnEnclosedStmt() instanceof ReturnStmt and result = "returnVal"
348348
or
349-
exists(SwitchCase e | e = this.getAnEnclosedStmt()) and result = "caseVal"
349+
this.getAnEnclosedStmt() instanceof SwitchCase and result = "caseVal"
350350
or
351351
exists(IfStmt s | s = this.getAnEnclosedStmt() and s.hasElse()) and
352352
result = "elseVal"
Collapse file

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

Copy file name to clipboardExpand all lines: cpp/ql/lib/semmle/code/cpp/padding/Padding.qll
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ class PaddedType extends Class {
397397
// Support only single inheritance for now. If multiple inheritance is
398398
// supported, be sure to fix up the calls to getABaseClass*() to correctly
399399
// handle the presence of multiple base class subojects with the same type.
400-
not exists(ClassDerivation cd | cd = this.getDerivation(1))
400+
not exists(this.getDerivation(1))
401401
}
402402

403403
/**

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.