Suggested implementation for rule 8.2#3169
Conversation
|
|
||
| # Zero arguments should be in form ( void ) | ||
| if (len(func.argument) == 0): | ||
| zeroCallTokens = getFollowingRawTokens(rawTokens, func.tokenDef, 3) |
There was a problem hiding this comment.
I think it's a mistake to remove the "void". I wonder if we can just remove the Tokenizer::simplifyParameterVoid. Could you check if that would confuse the symboldatabase for some C/C++ code?
There was a problem hiding this comment.
I removed Tokenizer::simplifyParameterVoid in my latest commit and updated the tests accordingly. This made it possible to check this case without using the raw tokens.
| if len(rawTokensFollowingPtr) != 3: | ||
| continue | ||
|
|
||
| # Compliant: returnType (*ptrName) ( ArgType ) |
There was a problem hiding this comment.
I have the feeling that the long term goal would be that the tokenlist has all this information.. but maybe for now it will be easier that you check the rawtokens like this..
danmar
left a comment
There was a problem hiding this comment.
yes looks pretty good. however as a long term goal I would prefer if you didn't have to go to the raw tokens..
There was a problem hiding this comment.
all other test cases seem good to me.. I just wonder what happened here.
There was a problem hiding this comment.
I updated the expected text output here now.
There was a problem hiding this comment.
do you know why we get such strange warning. I have not debugged it but I don't spontanously see where *) comes from.
There was a problem hiding this comment.
I think that in CheckSizeof::sizeofVoid (line 407) we could check not only for Token::simpleMatch(tok, "sizeof ( )" but also Token::simpleMatch(tok, "sizeof (void)". Then it will report issue as sizeofVoidError instead of sizeofDereferencedVoidPointerError.
There was a problem hiding this comment.
I have pushed a fix for this now. Verified it locally.
|
|
||
| for (const Token *tok = mTokenizer->tokens(); tok; tok = tok->next()) { | ||
| if (Token::simpleMatch(tok, "sizeof ( )")) { // "sizeof(void)" gets simplified to sizeof ( ) | ||
| if (Token::simpleMatch(tok, "sizeof ( )") || Token::simpleMatch(tok, "sizeof ( void )")) { |
There was a problem hiding this comment.
Thanks.. now I guess we should skip the first test.. if (Token::simpleMatch(tok, "sizeof ( void )")) {
There was a problem hiding this comment.
Yes you are correct. This is now fixed in my latest commit.
|
@danmar : will you be able to merge this PR or do I need to rebase from main first? |
Would like some early feedback on a strategy for supporting rule 8.2.