Skip to content

Commit e899120

Browse files
author
Robert Marsh
committed
C++: replace getType().getUnspecifiedType()
1 parent a72fff7 commit e899120

File tree

55 files changed

+177
-177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+177
-177
lines changed

cpp/ql/src/Likely Bugs/AmbiguouslySignedBitField.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
import cpp
1818

1919
from BitField bf
20-
where not bf.getType().getUnspecifiedType().(IntegralType).isExplicitlySigned()
21-
and not bf.getType().getUnspecifiedType().(IntegralType).isExplicitlyUnsigned()
22-
and not bf.getType().getUnspecifiedType() instanceof Enum
23-
and not bf.getType().getUnspecifiedType() instanceof BoolType
20+
where not bf.getUnspecifiedType().(IntegralType).isExplicitlySigned()
21+
and not bf.getUnspecifiedType().(IntegralType).isExplicitlyUnsigned()
22+
and not bf.getUnspecifiedType() instanceof Enum
23+
and not bf.getUnspecifiedType() instanceof BoolType
2424
// At least for C programs on Windows, BOOL is a common typedef for a type
2525
// representing BoolType.
2626
and not bf.getType().hasName("BOOL")

cpp/ql/src/Likely Bugs/Arithmetic/BadCheckOdd.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import cpp
1515
from EqualityOperation t, RemExpr lhs, Literal rhs
1616
where t.getLeftOperand() = lhs and
1717
t.getRightOperand() = rhs and
18-
lhs.getLeftOperand().getType().getUnspecifiedType().(IntegralType).isSigned() and
18+
lhs.getLeftOperand().getUnspecifiedType().(IntegralType).isSigned() and
1919
lhs.getRightOperand().getValue() = "2" and
2020
rhs.getValue() = "1"
2121
select t, "Possibly invalid test for oddness. This will fail for negative numbers."

cpp/ql/src/Likely Bugs/Arithmetic/PointlessSelfComparison.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ predicate pointlessSelfComparison(ComparisonOperation cmp) {
4545
predicate nanTest(EqualityOperation cmp) {
4646
pointlessSelfComparison(cmp) and
4747
exists (Type t
48-
| t = cmp.getLeftOperand().getType().getUnspecifiedType()
48+
| t = cmp.getLeftOperand().getUnspecifiedType()
4949
| t instanceof FloatingPointType or
5050
t instanceof TemplateParameter)
5151
}

cpp/ql/src/Likely Bugs/Conversion/CastArrayPointerArithmetic.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ predicate introducesNewField(Class derived, Class base) {
5555

5656
from DataFlow::PathNode source, DataFlow::PathNode sink, CastToPointerArithFlow cfg
5757
where cfg.hasFlowPath(source, sink)
58-
and source.getNode().asExpr().getFullyConverted().getType().getUnspecifiedType() = sink.getNode().asExpr().getFullyConverted().getType().getUnspecifiedType()
58+
and source.getNode().asExpr().getFullyConverted().getUnspecifiedType() = sink.getNode().asExpr().getFullyConverted().getUnspecifiedType()
5959
select sink, source, sink, "Pointer arithmetic here may be done with the wrong type because of the cast $@.", source, "here"

cpp/ql/src/Likely Bugs/Format/NonConstantFormat.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ predicate gettextFunction(Function f, int arg) {
4848

4949
predicate stringArray(Variable arr, AggregateLiteral init) {
5050
arr.getInitializer().getExpr() = init and
51-
stringType(arr.getType().getUnspecifiedType().(ArrayType).getBaseType(), _)
51+
stringType(arr.getUnspecifiedType().(ArrayType).getBaseType(), _)
5252
// Ideally, this predicate should also check that no item of `arr` is ever
5353
// reassigned, but such an analysis could get fairly complicated. Instead, we
5454
// just hope that nobody would initialize an array of constants and then

cpp/ql/src/Likely Bugs/Memory Management/AllocaInLoop.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class LoopWithAlloca extends Stmt {
7575
conditionRequires(eq, truth) and
7676
eq.getAnOperand().getValue().toInt() = 1 and
7777
e = eq.getAnOperand() and
78-
e.getType().getUnspecifiedType() instanceof BoolType and
78+
e.getUnspecifiedType() instanceof BoolType and
7979
not exists(e.getValue())
8080
)
8181
or
@@ -84,7 +84,7 @@ class LoopWithAlloca extends Stmt {
8484
conditionRequires(eq, truth.booleanNot()) and
8585
eq.getAnOperand().getValue().toInt() = 1 and
8686
e = eq.getAnOperand() and
87-
e.getType().getUnspecifiedType() instanceof BoolType and
87+
e.getUnspecifiedType() instanceof BoolType and
8888
not exists(e.getValue())
8989
)
9090
or

cpp/ql/src/Likely Bugs/Memory Management/ReturnStackAllocatedMemory.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ predicate hasNontrivialConversion(Expr e) {
4545
from LocalScopeVariable var, VariableAccess va, ReturnStmt r
4646
where
4747
not var.isStatic() and
48-
not var.getType().getUnspecifiedType() instanceof ReferenceType and
48+
not var.getUnspecifiedType() instanceof ReferenceType and
4949
not r.isFromUninstantiatedTemplate(_) and
5050
va = var.getAnAccess() and
5151
(

cpp/ql/src/Likely Bugs/Memory Management/StrncpyFlippedArgs.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ string nthString (int num) {
8484
* with a fixed size array.
8585
*/
8686
int arrayExprFixedSize(Expr e) {
87-
result = e.getType().getUnspecifiedType().(ArrayType).getSize()
87+
result = e.getUnspecifiedType().(ArrayType).getSize()
8888
or
8989
result = e.(NewArrayExpr).getAllocatedType().(ArrayType).getSize()
9090
or
9191
exists (SsaDefinition def, LocalVariable v
92-
| not (e.getType().getUnspecifiedType() instanceof ArrayType) and
92+
| not (e.getUnspecifiedType() instanceof ArrayType) and
9393
e = def.getAUse(v) and
9494
result = arrayExprFixedSize(def.getDefiningValue(v)))
9595
}
@@ -103,7 +103,7 @@ where
103103
copySource = fc.getArgument(argSrc) and
104104
// Some of the functions operate on a larger char type, like `wchar_t`, so we
105105
// need to take this into account in the fixed size case.
106-
charSize = f.getParameter(argDest).getType().getUnspecifiedType().(PointerType).getBaseType().getSize() and
106+
charSize = f.getParameter(argDest).getUnspecifiedType().(PointerType).getBaseType().getSize() and
107107
if exists(fc.getArgument(argLimit).getValue().toInt()) then (
108108
// Fixed sized case
109109
exists(int size |

cpp/ql/src/Likely Bugs/Memory Management/SuspiciousSizeof.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ import cpp
1717
class CandidateParameter extends Parameter {
1818
CandidateParameter() {
1919
// an array parameter
20-
getType().getUnspecifiedType() instanceof ArrayType
20+
getUnspecifiedType() instanceof ArrayType
2121
or
2222
(
2323
// a pointer parameter
24-
getType().getUnspecifiedType() instanceof PointerType and
24+
getUnspecifiedType() instanceof PointerType and
2525

2626
// whose address is never taken (rules out common
2727
// false positive patterns)

cpp/ql/src/Likely Bugs/OO/ThrowInDestructor.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ predicate bindThrownType(ThrowExpr te, Type thrown)
3434

3535
// For rethrows, we use the unqualified version of the type caught by the enclosing catch block.
3636
// Note that this is not precise, but is a reasonable first approximation.
37-
or exists(CatchBlock cb | bindEnclosingCatch(te, cb) and bindStrippedReferenceType(cb.getParameter().getType().getUnspecifiedType(), thrown))
37+
or exists(CatchBlock cb | bindEnclosingCatch(te, cb) and bindStrippedReferenceType(cb.getParameter().getUnspecifiedType(), thrown))
3838
}
3939

4040
// This predicate determines the catch blocks that can catch the exceptions thrown by each throw expression.
@@ -43,7 +43,7 @@ predicate canCatch(ThrowExpr te, CatchBlock cb)
4343
{
4444
exists(Type thrown, Type caught |
4545
bindThrownType(te, thrown)
46-
and caught = cb.getParameter().getType().getUnspecifiedType()
46+
and caught = cb.getParameter().getUnspecifiedType()
4747
and not bindEnclosingCatch(te, cb)
4848

4949
and

0 commit comments

Comments
 (0)