summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-07-23 19:27:33 +0300
committerAndrei Karas <akaras@inbox.ru>2015-07-23 19:27:33 +0300
commitc504e9e4af6120d5467c803ac24f05a8bb1fbaa3 (patch)
tree06e995681dd01fd228d18d908c5211e8db7652c9 /src
parentbba5ead2aa0900fb25a59913a708f240b6af00ab (diff)
downloadparanucker-c504e9e4af6120d5467c803ac24f05a8bb1fbaa3.tar.gz
paranucker-c504e9e4af6120d5467c803ac24f05a8bb1fbaa3.tar.bz2
paranucker-c504e9e4af6120d5467c803ac24f05a8bb1fbaa3.tar.xz
paranucker-c504e9e4af6120d5467c803ac24f05a8bb1fbaa3.zip
Do not check for null pointers variables with vptr.
Diffstat (limited to 'src')
-rw-r--r--src/analysis/expression.cpp17
-rw-r--r--src/analysis/expression.h2
2 files changed, 19 insertions, 0 deletions
diff --git a/src/analysis/expression.cpp b/src/analysis/expression.cpp
index 4c7fa5e..f51a432 100644
--- a/src/analysis/expression.cpp
+++ b/src/analysis/expression.cpp
@@ -154,6 +154,8 @@ std::string getComponentRefVariable(Node *node)
return str;
IndirectRefNode *indirect = static_cast<IndirectRefNode*>(object);
Node *ref = skipNop(indirect->ref);
+ if (ref && !isValidVar(ref->label))
+ return str;
if (ref == PARM_DECL)
{
ParmDeclNode *decl = static_cast<ParmDeclNode*>(ref);
@@ -171,6 +173,8 @@ std::string getComponentRefVariable(Node *node)
}
if (ref == PARM_DECL || ref == VAR_DECL)
{
+ if (!isValidVar(field->label))
+ return str;
str.append(ref->label).append("->").append(field->label);
}
}
@@ -178,6 +182,13 @@ std::string getComponentRefVariable(Node *node)
return str;
}
+bool isValidVar(const std::string &str)
+{
+ if (str.size() > 6 && str.substr(0, 6) == "_vptr.")
+ return false;
+ return true;
+}
+
std::vector<std::string> getComponentRefParts(Node *node)
{
std::vector<std::string> str;
@@ -194,6 +205,8 @@ std::vector<std::string> getComponentRefParts(Node *node)
FieldDeclNode *fieldDecl = static_cast<FieldDeclNode*>(field);
IndirectRefNode *indirect = static_cast<IndirectRefNode*>(object);
Node *ref = skipNop(indirect->ref);
+ if (ref && !isValidVar(ref->label))
+ return str;
if (ref == PARM_DECL)
{
ParmDeclNode *parmDecl = static_cast<ParmDeclNode*>(ref);
@@ -219,6 +232,8 @@ std::vector<std::string> getComponentRefParts(Node *node)
if (arr->elementType != POINTER_TYPE)
return str;
}
+ if (!isValidVar(field->label))
+ return str;
str.push_back(std::string(ref->label).append("->").append(field->label));
}
}
@@ -244,6 +259,8 @@ std::vector<std::string> getComponentRefLeftParts(Node *node)
// return str;
IndirectRefNode *indirect = static_cast<IndirectRefNode*>(object);
Node *ref = skipNop(indirect->ref);
+ if (ref && !isValidVar(ref->label))
+ return str;
if (ref == PARM_DECL || ref == VAR_DECL)
{
str.push_back(ref->label);
diff --git a/src/analysis/expression.h b/src/analysis/expression.h
index 602a9ae..b07f296 100644
--- a/src/analysis/expression.h
+++ b/src/analysis/expression.h
@@ -105,6 +105,8 @@ namespace Analysis
Node *node1,
Node *node2,
WalkItem &wo);
+
+ bool isValidVar(const std::string &str);
}
#endif // ANALYSIS_EXPRESSION_H