in my company we are writing python checkers, which are using cppcheck dump files as an input. Unfortunatelly we found couple of situations, in which there is a lack of consistency between source code and dump file, e.g.:
when such code is cppcheck'ed, no token with str=="unsigned" is visible in the .dump file. As far as i remember, we found at least 5 keyword which cannot be parsed into dump file. My question is, is that made on purpose or this is a bug, and can be reported on Trac?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I see the problem and that is a mistake.. I want it to be consistent with cppcheck internals, so I think we should add isUnsigned and isSigned for tokens.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for your response, I appreciate that you fixed the problem so quickly.
Unfortunatelly this won't work in our case. The perfect situation for us, is when dump file genereted by cppcheck, contains ALL the tokens from the source code. After your change, we can get the information that variable is signed/unsigned (that's good), but there is still no token with str=="signed/unsigned".
I will explaing my concerns on the example. We are implementing some checkers for rules, and one of them is telling:
Function style cast does not allow more than one type specifier.
The use of other cast styles is recommended.
Example:
void foo ()
{
unsigned int ui1 = unsigned int(-1); // WARNING
unsigned int ui2 = (unsigned int)(-1); // OK
unsigned int ui3 = static_cast<unsigned int>(-1); // BETTER
}
You can see, that because we don't see "unsigned" token, in the dump file, we cannot find the deviation in the mentioned code. Because dump file, contains only one type specifier. Our checker is checking correct code format, rather then logic.
Like i said, there are couple of problems with dumping, e.g. please look at the comma operator, there are no brackets in the dump file. In this case it totally changes the logic of the code.
according to the dump "b = 0, 1, a" - so at the end b equals 0 instead of a.
I don't know if this is moral, to ask you for resolving our issues :) but maybe i will gather all problems with dumping, and we will submit them via Trac.
Cheers!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Like i said, there are couple of problems with dumping, e.g. please look at the comma operator, there are no brackets in the dump file. In this case it totally changes the logic of the code.
That is clearly a bug.
We have a "normal" and a "simplified" token list. In the "normal" token list I don't want that any parentheses are removed even if they are redundant. In the "simplified" token list they could be removed if they are redundant.
I am not sure which token list we use for dump. But I would hope the "normal".
Last edit: Daniel Marjamäki 2016-12-14
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
in my company we are writing python checkers, which are using cppcheck dump files as an input. Unfortunatelly we found couple of situations, in which there is a lack of consistency between source code and dump file, e.g.:
when such code is cppcheck'ed, no token with str=="unsigned" is visible in the .dump file. As far as i remember, we found at least 5 keyword which cannot be parsed into dump file. My question is, is that made on purpose or this is a bug, and can be reported on Trac?
I see the problem and that is a mistake.. I want it to be consistent with cppcheck internals, so I think we should add isUnsigned and isSigned for tokens.
It's very nice to hear that you are using this feature. Let me know if you think it can be made more convenient.
Information added. An "unsigned int" will now generate this token:
Pushed with https://github.com/danmar/cppcheck/commit/2ca85a1c40b760cce9537519657b0bc0d636e1d6
Last edit: Daniel Marjamäki 2016-12-09
Hi Daniel,
Thanks for your response, I appreciate that you fixed the problem so quickly.
Unfortunatelly this won't work in our case. The perfect situation for us, is when dump file genereted by cppcheck, contains ALL the tokens from the source code. After your change, we can get the information that variable is signed/unsigned (that's good), but there is still no token with str=="signed/unsigned".
I will explaing my concerns on the example. We are implementing some checkers for rules, and one of them is telling:
You can see, that because we don't see "unsigned" token, in the dump file, we cannot find the deviation in the mentioned code. Because dump file, contains only one type specifier. Our checker is checking correct code format, rather then logic.
Like i said, there are couple of problems with dumping, e.g. please look at the comma operator, there are no brackets in the dump file. In this case it totally changes the logic of the code.
according to the dump "b = 0, 1, a" - so at the end b equals 0 instead of a.
I don't know if this is moral, to ask you for resolving our issues :) but maybe i will gather all problems with dumping, and we will submit them via Trac.
Cheers!
This is because there is no token "signed" or "unsigned" in our token list.
I think you misunderstand. What is the --dump output?
All the "int" tokens are unsigned according to isUnsigned.
Last edit: Daniel Marjamäki 2016-12-14
That is clearly a bug.
We have a "normal" and a "simplified" token list. In the "normal" token list I don't want that any parentheses are removed even if they are redundant. In the "simplified" token list they could be removed if they are redundant.
I am not sure which token list we use for dump. But I would hope the "normal".
Last edit: Daniel Marjamäki 2016-12-14