-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Token: do not return non-const pointer from const methods - part 1
#4761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6ba11ad
28ed027
3f86b8f
ba3dc16
467bae4
be70749
1d33abc
52e001d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1345,7 +1345,7 @@ static void valueFlowArray(TokenList *tokenlist) | |
| // const array decl | ||
| else if (tok->variable() && tok->variable()->isArray() && tok->variable()->isConst() && | ||
| tok->variable()->nameToken() == tok && Token::Match(tok, "%var% [ %num%| ] = {")) { | ||
| const Token* rhstok = tok->next()->link()->tokAt(2); | ||
| Token* rhstok = tok->next()->link()->tokAt(2); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these can stay
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These changes are all based straight on compiler errors when the signature has been fixed - so no, they cannot. Also from looking at the code it is used to get a new value for |
||
| constantArrays[tok->varId()] = rhstok; | ||
| tok = rhstok->link(); | ||
| } | ||
|
|
@@ -1365,16 +1365,16 @@ static void valueFlowArray(TokenList *tokenlist) | |
| } | ||
|
|
||
| if (Token::Match(tok, "const %type% %var% [ %num%| ] = {")) { | ||
| const Token *vartok = tok->tokAt(2); | ||
| const Token *rhstok = vartok->next()->link()->tokAt(2); | ||
| Token *vartok = tok->tokAt(2); | ||
| Token *rhstok = vartok->next()->link()->tokAt(2); | ||
| constantArrays[vartok->varId()] = rhstok; | ||
| tok = rhstok->link(); | ||
| continue; | ||
| } | ||
|
|
||
| else if (Token::Match(tok, "const char %var% [ %num%| ] = %str% ;")) { | ||
| const Token *vartok = tok->tokAt(2); | ||
| const Token *strtok = vartok->next()->link()->tokAt(2); | ||
| Token *vartok = tok->tokAt(2); | ||
| Token *strtok = vartok->next()->link()->tokAt(2); | ||
| constantArrays[vartok->varId()] = strtok; | ||
| tok = strtok->next(); | ||
| continue; | ||
|
|
@@ -4903,7 +4903,7 @@ static bool isStdMoveOrStdForwarded(Token * tok, ValueFlow::Value::MoveKind * mo | |
| variableToken = tok->tokAt(4); | ||
| kind = ValueFlow::Value::MoveKind::MovedVariable; | ||
| } else if (Token::simpleMatch(tok, "std :: forward <")) { | ||
| const Token * const leftAngle = tok->tokAt(3); | ||
| Token * const leftAngle = tok->tokAt(3); | ||
| Token * rightAngle = leftAngle->link(); | ||
| if (Token::Match(rightAngle, "> ( %var% )")) { | ||
| variableToken = rightAngle->tokAt(2); | ||
|
|
@@ -5098,7 +5098,7 @@ static void valueFlowConditionExpressions(TokenList *tokenlist, SymbolDatabase* | |
| for (const Token* tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) { | ||
| if (!Token::simpleMatch(tok, "if (")) | ||
| continue; | ||
| Token * parenTok = tok->next(); | ||
| const Token * parenTok = tok->next(); | ||
| if (!Token::simpleMatch(parenTok->link(), ") {")) | ||
| continue; | ||
| Token * blockTok = parenTok->link()->tokAt(1); | ||
|
|
@@ -6824,7 +6824,7 @@ static void valueFlowForLoopSimplify(Token* const bodyStart, | |
| if ((tok2->str() == "&&" && !conditionIsTrue(tok2->astOperand1(), programMemory)) || | ||
| (tok2->str() == "||" && !conditionIsFalse(tok2->astOperand1(), programMemory))) { | ||
| // Skip second expression.. | ||
| const Token *parent = tok2; | ||
| Token *parent = tok2; | ||
| while (parent && parent->str() == tok2->str()) | ||
| parent = parent->astParent(); | ||
| // Jump to end of condition | ||
|
|
@@ -7233,7 +7233,7 @@ static void valueFlowSwitchVariable(TokenList *tokenlist, SymbolDatabase* symbol | |
| continue; | ||
| } | ||
|
|
||
| for (Token *tok = scope.bodyStart->next(); tok != scope.bodyEnd; tok = tok->next()) { | ||
| for (const Token *tok = scope.bodyStart->next(); tok != scope.bodyEnd; tok = tok->next()) { | ||
| if (tok->str() == "{") { | ||
| tok = tok->link(); | ||
| continue; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.