From 36b302947673020003b1665707ac4f06428dc584 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 4 Aug 2015 23:03:20 +0300 Subject: Add more checks for attribute nonnullpointer. --- src/analysis/expression.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/analysis/expression.cpp b/src/analysis/expression.cpp index 235aa84..dded718 100644 --- a/src/analysis/expression.cpp +++ b/src/analysis/expression.cpp @@ -177,6 +177,12 @@ VarItem getComponentRefVariable(Node *node) VarDeclNode *varDecl = static_cast(ref); if (varDecl->varType != POINTER_TYPE) return str; + if (findTreeListPurpose(static_cast( + skipNop(varDecl->attribute)), + "nonnullpointer")) + { + str.isNonNull = true; + } } if (ref == PARM_DECL || ref == VAR_DECL) { @@ -227,14 +233,21 @@ std::vector getComponentRefParts(Node *node) if (skipNop(parmDecl->declType) == nullptr || skipNop(parmDecl->declType) == POINTER_TYPE) { - str.push_back(VarItem(ref->label, isNonNull)); + str.push_back(VarItem(ref->label, false)); } } if (ref == VAR_DECL) { VarDeclNode *varDecl = static_cast(ref); + bool isNonNull2(false); + if (findTreeListPurpose(static_cast( + skipNop(varDecl->attribute)), + "nonnullpointer")) + { + isNonNull2 = true; + } if (varDecl->varType == POINTER_TYPE) - str.push_back(VarItem(ref->label, isNonNull)); + str.push_back(VarItem(ref->label, isNonNull2)); } if (ref == PARM_DECL || ref == VAR_DECL) { @@ -272,16 +285,20 @@ std::vector getComponentRefLeftParts(Node *node) bool isNonNull(false); // if (fieldDecl->fieldType != POINTER_TYPE) // return str; - if (findTreeListPurpose(static_cast( - skipNop(fieldDecl->attribute)), - "nonnullpointer")) - { - isNonNull = true; - } IndirectRefNode *indirect = static_cast(object); Node *ref = skipNop(indirect->ref); if (ref && !isValidVar(ref->label)) return str; + if (ref == VAR_DECL) + { + VarDeclNode *varDecl = static_cast(ref); + if (findTreeListPurpose(static_cast( + skipNop(varDecl->attribute)), + "nonnullpointer")) + { + isNonNull = true; + } + } if (ref == PARM_DECL || ref == VAR_DECL) { str.push_back(VarItem(ref->label, isNonNull)); -- cgit v1.2.3-60-g2f50