From b94c6646b23174099602e18206d4a846a04db8a8 Mon Sep 17 00:00:00 2001 From: Robin Eklind Date: Sun, 8 Mar 2020 05:59:05 +0100 Subject: [PATCH] ast: handle optional part_of_explicit_cast of ImplicitCastExpr node Fixes #839. --- ast/implicit_cast_expr.go | 29 ++++++++++++++++------------- ast/implicit_cast_expr_test.go | 8 ++++++++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/ast/implicit_cast_expr.go b/ast/implicit_cast_expr.go index a744d3484..4cc7f2026 100644 --- a/ast/implicit_cast_expr.go +++ b/ast/implicit_cast_expr.go @@ -2,12 +2,13 @@ package ast // ImplicitCastExpr is expression. type ImplicitCastExpr struct { - Addr Address - Pos Position - Type string - Type2 string - Kind string - ChildNodes []Node + Addr Address + Pos Position + Type string + Type2 string + Kind string + PartOfExplicitCast bool + ChildNodes []Node } // ImplicitCastExprArrayToPointerDecay - constant @@ -18,17 +19,19 @@ func parseImplicitCastExpr(line string) *ImplicitCastExpr { `<(?P.*)> '(?P.*?)' (:'(?P.*?)')? - <(?P.*)>`, + <(?P.*)> + (?P part_of_explicit_cast)?`, line, ) return &ImplicitCastExpr{ - Addr: ParseAddress(groups["address"]), - Pos: NewPositionFromString(groups["position"]), - Type: groups["type"], - Type2: groups["type2"], - Kind: groups["kind"], - ChildNodes: []Node{}, + Addr: ParseAddress(groups["address"]), + Pos: NewPositionFromString(groups["position"]), + Type: groups["type"], + Type2: groups["type2"], + Kind: groups["kind"], + PartOfExplicitCast: len(groups["part_of_explicit_cast"]) > 0, + ChildNodes: []Node{}, } } diff --git a/ast/implicit_cast_expr_test.go b/ast/implicit_cast_expr_test.go index b19bab0aa..a6370ab19 100644 --- a/ast/implicit_cast_expr_test.go +++ b/ast/implicit_cast_expr_test.go @@ -36,6 +36,14 @@ func TestImplicitCastExpr(t *testing.T) { Kind: "LValueToRValue", ChildNodes: []Node{}, }, + `0x5600a8148b10 'unsigned int' part_of_explicit_cast`: &ImplicitCastExpr{ + Addr: 0x5600a8148b10, + Pos: NewPositionFromString("col:16"), + Type: "unsigned int", + Kind: "LValueToRValue", + PartOfExplicitCast: true, + ChildNodes: []Node{}, + }, } runNodeTests(t, nodes)