diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-06-23 19:47:08 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-06-23 19:47:08 +0300 |
commit | 69e9e905de9dd9fb5c28abb5013945bba03e9dbb (patch) | |
tree | 6897b769af7fd15d041192cda25d47820fcb2f57 /src/analysis/expression.cpp | |
parent | 8aa42b625d7fd34d22df6690e5b305b5be525eea (diff) | |
download | paranucker-69e9e905de9dd9fb5c28abb5013945bba03e9dbb.tar.gz paranucker-69e9e905de9dd9fb5c28abb5013945bba03e9dbb.tar.bz2 paranucker-69e9e905de9dd9fb5c28abb5013945bba03e9dbb.tar.xz paranucker-69e9e905de9dd9fb5c28abb5013945bba03e9dbb.zip |
Fix false positive for ADDR_EXPR node.
Ignored example: arr.push_back(ptr);
Diffstat (limited to 'src/analysis/expression.cpp')
-rw-r--r-- | src/analysis/expression.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/analysis/expression.cpp b/src/analysis/expression.cpp index c3fb050..a31f78f 100644 --- a/src/analysis/expression.cpp +++ b/src/analysis/expression.cpp @@ -28,6 +28,7 @@ #include "nodes/expr/addr_expr.h" #include "nodes/expr/bind_expr.h" +#include "nodes/expr/call_expr.h" #include "nodes/expr/compound_expr.h" #include "nodes/expr/cond_expr.h" #include "nodes/expr/decl_expr.h" @@ -83,6 +84,21 @@ void analyseAddrExpr(AddrExprNode *node, const WalkItem &wi, WalkItem &wo) if (node->args.empty() || command == FindArgs) return; + // do not report code like func1(ptr) or push_back(ptr) + Node *node2 = skipBackNop(node->parent); + if (node2) + { + while (node2 && node2->nodeType == ADDR_EXPR) + { + node2 = skipBackNop(node2->parent); + } + // found what some parent is function or method call + if (node2 && node2->nodeType == CALL_EXPR) + { + return; + } + } + reportParmDeclNullPointer(node, node->args[0], wi); } |