summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-08-04 23:03:20 +0300
committerAndrei Karas <akaras@inbox.ru>2015-08-04 23:03:20 +0300
commit36b302947673020003b1665707ac4f06428dc584 (patch)
tree7e04771bf511783297cf9a4d8361c315555b1c45
parentc0cb5d5dc46ac373e4de967d6a3f61b7da5e68cd (diff)
downloadparanucker-36b302947673020003b1665707ac4f06428dc584.tar.gz
paranucker-36b302947673020003b1665707ac4f06428dc584.tar.bz2
paranucker-36b302947673020003b1665707ac4f06428dc584.tar.xz
paranucker-36b302947673020003b1665707ac4f06428dc584.zip
Add more checks for attribute nonnullpointer.
-rw-r--r--src/analysis/expression.cpp33
1 files 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<VarDeclNode*>(ref);
if (varDecl->varType != POINTER_TYPE)
return str;
+ if (findTreeListPurpose(static_cast<TreeListNode*>(
+ skipNop(varDecl->attribute)),
+ "nonnullpointer"))
+ {
+ str.isNonNull = true;
+ }
}
if (ref == PARM_DECL || ref == VAR_DECL)
{
@@ -227,14 +233,21 @@ std::vector<VarItem> 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<VarDeclNode*>(ref);
+ bool isNonNull2(false);
+ if (findTreeListPurpose(static_cast<TreeListNode*>(
+ 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<VarItem> getComponentRefLeftParts(Node *node)
bool isNonNull(false);
// if (fieldDecl->fieldType != POINTER_TYPE)
// return str;
- if (findTreeListPurpose(static_cast<TreeListNode*>(
- skipNop(fieldDecl->attribute)),
- "nonnullpointer"))
- {
- isNonNull = true;
- }
IndirectRefNode *indirect = static_cast<IndirectRefNode*>(object);
Node *ref = skipNop(indirect->ref);
if (ref && !isValidVar(ref->label))
return str;
+ if (ref == VAR_DECL)
+ {
+ VarDeclNode *varDecl = static_cast<VarDeclNode*>(ref);
+ if (findTreeListPurpose(static_cast<TreeListNode*>(
+ skipNop(varDecl->attribute)),
+ "nonnullpointer"))
+ {
+ isNonNull = true;
+ }
+ }
if (ref == PARM_DECL || ref == VAR_DECL)
{
str.push_back(VarItem(ref->label, isNonNull));