Skip to content

Commit

Permalink
only NULL is a nullpointer, not null
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldietsch committed Nov 28, 2017
1 parent 73a7c9a commit 27ef92c
Showing 1 changed file with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ public Result visit(final Dispatcher main, final IASTIdExpression node) {
final String cId = node.getName().toString();

// deal with builtin constants
if ("NULL".equalsIgnoreCase(cId)) {
if ("NULL".equals(cId)) {
return new ExpressionResult(new RValue(mExpressionTranslation.constructNullPointer(loc),
new CPointer(new CPrimitive(CPrimitives.VOID))));

Expand Down Expand Up @@ -1593,8 +1593,8 @@ public Result visit(final Dispatcher main, final IASTReturnStatement node) {
* The declarations themselves of the local variables (and f.i. typedefs) are stored in the symbolTable and inserted
* into the Boogie code at the next endScope()
* <p>
* Declarations of static variables are added to
* mDeclarationsGlobalInBoogie such that they can be declared and initialized globally.
* Declarations of static variables are added to mDeclarationsGlobalInBoogie such that they can be declared and
* initialized globally.
* <p>
* Variables/types that are global in Boogie but not in C are stored in the Symboltable to keep the association of
* BoogieId and CId.
Expand Down Expand Up @@ -2079,10 +2079,9 @@ BinaryExpression.Operator.COMPEQ, new IdentifierExpression(loc, funcId), mExpres
(TypeHandler) mTypeHandler, mTypeHandler.getUndefinedTypes(), mDeclarationsGlobalInBoogie,
mExpressionTranslation));


/*
* this must come after the post processor because the post processor might add declarations when dispatching
* initializers of static variables
* initializers of static variables
*/
decl.addAll(getStaticObjectsHandler().getGlobalDeclarations());

Expand Down Expand Up @@ -2546,9 +2545,9 @@ public ExpressionResult makeAssignment(final Dispatcher main, final ILocation lo
Expression rhsWithBitfieldTreatment;
if (hlv.getBitfieldInformation() != null) {
final int bitfieldWidth = hlv.getBitfieldInformation().getNumberOfBits();
rhsWithBitfieldTreatment = mExpressionTranslation.erazeBits(loc,
rightHandSideWithConversionsApplied.getValue(),
(CPrimitive) hlv.getCType().getUnderlyingType(), bitfieldWidth);
rhsWithBitfieldTreatment =
mExpressionTranslation.erazeBits(loc, rightHandSideWithConversionsApplied.getValue(),
(CPrimitive) hlv.getCType().getUnderlyingType(), bitfieldWidth);
} else {
rhsWithBitfieldTreatment = rightHandSideWithConversionsApplied.getValue();
}
Expand Down Expand Up @@ -3109,8 +3108,8 @@ private void convertToPointer(final ILocation loc, final ExpressionResult rexp,
} else if (oldType instanceof CArray) {
if (rexp instanceof StringLiteralResult) {
/*
* a string literal's char-array decays to a pointer
* the stringLiteralResult already has the correct RValue, we just need to change the type
* a string literal's char-array decays to a pointer the stringLiteralResult already has the correct
* RValue, we just need to change the type
*/
rexp.mLrVal = new RValue(rexp.mLrVal.getValue(), new CPointer(new CPrimitive(CPrimitives.CHAR)));
} else {
Expand Down Expand Up @@ -3170,8 +3169,8 @@ private Result handleIndirectionOperator(final Dispatcher main, final Expression
throw new IncorrectSyntaxException(loc, "Pointer dereference of incomplete type");
}

return new ExpressionResult(rop.mStmt, new HeapLValue(rValue.getValue(), pointedType, null), rop.mDecl, rop.mAuxVars,
rop.mOverappr);
return new ExpressionResult(rop.mStmt, new HeapLValue(rValue.getValue(), pointedType, null), rop.mDecl,
rop.mAuxVars, rop.mOverappr);
}

/**
Expand Down Expand Up @@ -3594,7 +3593,6 @@ ExpressionResult handleAdditiveOperation(final Dispatcher main, final ILocation
CType lType = left.mLrVal.getCType().getUnderlyingType();
final CType rType = right.mLrVal.getCType().getUnderlyingType();


if (lType instanceof CArray && rType.isArithmeticType()) {
// arrays decay to pointers in this case
assert ((CArray) lType).getDimensions().length == 1 : "TODO: think about this case";
Expand Down Expand Up @@ -3675,9 +3673,8 @@ ExpressionResult handleAdditiveOperation(final Dispatcher main, final ILocation
if (left instanceof StringLiteralResult) {
assert lhs == null : "unforseen case";

result = new StringLiteralResult(result.getStatements(), null,
result.getDeclarations(), result.getAuxVars(), result.getOverapprs(),
((StringLiteralResult) left).getAuxVarName(),
result = new StringLiteralResult(result.getStatements(), null, result.getDeclarations(),
result.getAuxVars(), result.getOverapprs(), ((StringLiteralResult) left).getAuxVarName(),
((StringLiteralResult) left).getLiteralString(),
((StringLiteralResult) left).overApproximatesLongStringLiteral());
}
Expand Down

0 comments on commit 27ef92c

Please sign in to comment.