diff options
28 files changed, 58 insertions, 1 deletions
diff --git a/src/analysis/analysis.cpp b/src/analysis/analysis.cpp index 6da4af3..6300992 100644 --- a/src/analysis/analysis.cpp +++ b/src/analysis/analysis.cpp @@ -51,6 +51,17 @@ void walkTree(Node *node, WalkItem wi) } } +int findBackLocation(Node *node) +{ + location_t loc = 0; + while(node && !loc) + { + loc = node->location; + node = node->parent; + } + return loc; +} + WalkItem analyseNode(Node *node, WalkItem wi) { // searching function declaration diff --git a/src/analysis/analysis.h b/src/analysis/analysis.h index 641ada9..b7da6bd 100644 --- a/src/analysis/analysis.h +++ b/src/analysis/analysis.h @@ -32,6 +32,8 @@ namespace Analysis void walkTree(Node *node, WalkItem wi); WalkItem analyseNode(Node *node, WalkItem wi); + + int findBackLocation(Node *node); } #endif // ANALYSIS_ANALYSIS_H diff --git a/src/analysis/expression.cpp b/src/analysis/expression.cpp index 12af495..d18a38f 100644 --- a/src/analysis/expression.cpp +++ b/src/analysis/expression.cpp @@ -53,7 +53,8 @@ WalkItem analyseModifyExpr(ModifyExprNode *node, WalkItem wi) { if (wi.checkNullVars.find(arg->label) != wi.checkNullVars.end()) { - Log::warn(arg->location, "Using variable without check for NULL"); + Log::warn(findBackLocation(node), + "Using variable without check for NULL"); } } } diff --git a/src/parsers/base/expr.cpp b/src/parsers/base/expr.cpp index 3432ec3..e458366 100644 --- a/src/parsers/base/expr.cpp +++ b/src/parsers/base/expr.cpp @@ -30,6 +30,23 @@ namespace Generic { +void fillExprLocation(Node *node) +{ + if (!node || node->gccNode == NULL_TREE) + { + return; + } + + if (EXPR_HAS_LOCATION(node->gccNode)) + { + location_t loc = EXPR_LOCATION(node->gccNode); + node->location = loc; + node->file = LOCATION_FILE(loc); + node->line = LOCATION_LINE(loc); + node->column = LOCATION_COLUMN(loc); + } +} + void fillExprOperands(ExprNode *node) { if (!node || node->gccNode == NULL_TREE) diff --git a/src/parsers/base/expr.h b/src/parsers/base/expr.h index 6f1b124..9067133 100644 --- a/src/parsers/base/expr.h +++ b/src/parsers/base/expr.h @@ -21,9 +21,12 @@ #define PARSERS_BASE_EXPR_H struct ExprNode; +struct Node; namespace Generic { + void fillExprLocation(Node *node); + void fillExprOperands(ExprNode *node); } diff --git a/src/parsers/expr/addr_expr.cpp b/src/parsers/expr/addr_expr.cpp index e1c2583..f831e4e 100644 --- a/src/parsers/expr/addr_expr.cpp +++ b/src/parsers/expr/addr_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseAddrExprNode(AddrExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/bind_expr.cpp b/src/parsers/expr/bind_expr.cpp index 0c0e0ea..1157163 100644 --- a/src/parsers/expr/bind_expr.cpp +++ b/src/parsers/expr/bind_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseBindExprNode(BindExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/call_expr.cpp b/src/parsers/expr/call_expr.cpp index 265da1a..f3072bf 100644 --- a/src/parsers/expr/call_expr.cpp +++ b/src/parsers/expr/call_expr.cpp @@ -33,6 +33,7 @@ namespace Generic void parseCallExprNode(CallExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); // not recommended diff --git a/src/parsers/expr/cleanuppoint_expr.cpp b/src/parsers/expr/cleanuppoint_expr.cpp index 19d3686..b08b9e1 100644 --- a/src/parsers/expr/cleanuppoint_expr.cpp +++ b/src/parsers/expr/cleanuppoint_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseCleanupPointExprNode(CleanupPointExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/cond_expr.cpp b/src/parsers/expr/cond_expr.cpp index a334a84..2129059 100644 --- a/src/parsers/expr/cond_expr.cpp +++ b/src/parsers/expr/cond_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseCondExprNode(CondExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/convert_expr.cpp b/src/parsers/expr/convert_expr.cpp index 7680da0..bb74e24 100644 --- a/src/parsers/expr/convert_expr.cpp +++ b/src/parsers/expr/convert_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseConvertExprNode(ConvertExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/decl_expr.cpp b/src/parsers/expr/decl_expr.cpp index b65226d..7a333f3 100644 --- a/src/parsers/expr/decl_expr.cpp +++ b/src/parsers/expr/decl_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseDeclExprNode(DeclExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/eq_expr.cpp b/src/parsers/expr/eq_expr.cpp index 66668f1..7cf458c 100644 --- a/src/parsers/expr/eq_expr.cpp +++ b/src/parsers/expr/eq_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseEqExprNode(EqExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/ge_expr.cpp b/src/parsers/expr/ge_expr.cpp index 39589af..96d536e 100644 --- a/src/parsers/expr/ge_expr.cpp +++ b/src/parsers/expr/ge_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseGeExprNode(GeExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/gt_expr.cpp b/src/parsers/expr/gt_expr.cpp index 511f184..d0ef3bf 100644 --- a/src/parsers/expr/gt_expr.cpp +++ b/src/parsers/expr/gt_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseGtExprNode(GtExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/indirect_ref.cpp b/src/parsers/expr/indirect_ref.cpp index 2f935b5..961050b 100644 --- a/src/parsers/expr/indirect_ref.cpp +++ b/src/parsers/expr/indirect_ref.cpp @@ -31,6 +31,7 @@ namespace Generic void parseIndirectRefNode(IndirectRefNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/init_expr.cpp b/src/parsers/expr/init_expr.cpp index a35b7bc..44baf51 100644 --- a/src/parsers/expr/init_expr.cpp +++ b/src/parsers/expr/init_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseInitExprNode(InitExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/le_expr.cpp b/src/parsers/expr/le_expr.cpp index f3619f5..15e90a8 100644 --- a/src/parsers/expr/le_expr.cpp +++ b/src/parsers/expr/le_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseLeExprNode(LeExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/loop_expr.cpp b/src/parsers/expr/loop_expr.cpp index e8558a5..78846f0 100644 --- a/src/parsers/expr/loop_expr.cpp +++ b/src/parsers/expr/loop_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseLoopExprNode(LoopExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); // fillExprOperands(node); diff --git a/src/parsers/expr/lt_expr.cpp b/src/parsers/expr/lt_expr.cpp index b0c833e..bf3f330 100644 --- a/src/parsers/expr/lt_expr.cpp +++ b/src/parsers/expr/lt_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseLtExprNode(LtExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/minus_expr.cpp b/src/parsers/expr/minus_expr.cpp index 19a18c7..9922b8e 100644 --- a/src/parsers/expr/minus_expr.cpp +++ b/src/parsers/expr/minus_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseMinusExprNode(MinusExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/modify_expr.cpp b/src/parsers/expr/modify_expr.cpp index 07552fa..af225e7 100644 --- a/src/parsers/expr/modify_expr.cpp +++ b/src/parsers/expr/modify_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseModifyExprNode(ModifyExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/mult_expr.cpp b/src/parsers/expr/mult_expr.cpp index 4950737..e67b40c 100644 --- a/src/parsers/expr/mult_expr.cpp +++ b/src/parsers/expr/mult_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseMultExprNode(MultExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/ne_expr.cpp b/src/parsers/expr/ne_expr.cpp index 22e9cc5..ba20614 100644 --- a/src/parsers/expr/ne_expr.cpp +++ b/src/parsers/expr/ne_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseNeExprNode(NeExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/nop_expr.cpp b/src/parsers/expr/nop_expr.cpp index 8eba0c2..1efecc5 100644 --- a/src/parsers/expr/nop_expr.cpp +++ b/src/parsers/expr/nop_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseNopExprNode(NopExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/plus_expr.cpp b/src/parsers/expr/plus_expr.cpp index 211a516..41dceaa 100644 --- a/src/parsers/expr/plus_expr.cpp +++ b/src/parsers/expr/plus_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parsePlusExprNode(PlusExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/pointerplus_expr.cpp b/src/parsers/expr/pointerplus_expr.cpp index 3dce95b..13963d7 100644 --- a/src/parsers/expr/pointerplus_expr.cpp +++ b/src/parsers/expr/pointerplus_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parsePointerPlusExprNode(PointerPlusExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); diff --git a/src/parsers/expr/return_expr.cpp b/src/parsers/expr/return_expr.cpp index 76e36d0..b36993a 100644 --- a/src/parsers/expr/return_expr.cpp +++ b/src/parsers/expr/return_expr.cpp @@ -31,6 +31,7 @@ namespace Generic void parseReturnExprNode(ReturnExprNode *node) { fillType(node); + fillExprLocation(node); Log::dump(node); fillExprOperands(node); |