The following code triggers an error: "AST broken, binary operator '>' doesn't have two operands." This is obviously because the expression has been parsed incorrectly.
So cppcheck removes the template keyword which makes it harder to know what brackets should be linked. We should add a template flag in the token when its removed so we can later find templates.
Alternatively, I wonder if we can try to link the brackets after the AST is built. Since we know there is no AST for the < it must mean it could be a template bracket.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think the 'template' keyword here is absolutely necessary for disambiguation and you can't parse this correctly if it was removed (i. e. without taking this keyword into account).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, actually we dont remove the template keyword in the snippet above. However, we still dont check for a template keyword before ahead anyways. So I fixed this here:
The following code triggers an error: "AST broken, binary operator '>' doesn't have two operands." This is obviously because the expression has been parsed incorrectly.
So cppcheck removes the template keyword which makes it harder to know what brackets should be linked. We should add a template flag in the token when its removed so we can later find templates.
Alternatively, I wonder if we can try to link the brackets after the AST is built. Since we know there is no AST for the
<
it must mean it could be a template bracket.I think the 'template' keyword here is absolutely necessary for disambiguation and you can't parse this correctly if it was removed (i. e. without taking this keyword into account).
Well, actually we dont remove the
template
keyword in the snippet above. However, we still dont check for a template keyword before ahead anyways. So I fixed this here:https://github.com/danmar/cppcheck/pull/3399
It will remove the template keyword and then set the
isTemplate
flag on the name that follows, and then linking the brackets will use this flag.