Skip to content
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

fix #13155: Tokenizer::simplifyTypedef does not set info correctly for typedef in function #6888

Closed
wants to merge 1 commit into from

Conversation

ludviggunne
Copy link
Contributor

No description provided.

Copy link
Owner

@danmar danmar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some unit testing would be good. test/testsimplifytypedef.cpp to start with.

However since you change TokenList::copyTokens I feel there is a danger you change behavior for other simplifications also. So ideally we would check the various copyTokens usages and determine that the result is wanted.

@@ -292,6 +294,9 @@ Token *TokenList::copyTokens(Token *dest, const Token *first, const Token *last,

links.pop();
}

column += tok->next() ? tok->next()->column() - tok->column() : tok->str().length() + 1;
Copy link
Owner

@danmar danmar Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not so sure about this. At least when we replace a token it's better that the column just match the replaced token. imagine MY_INT generates a warning the warning should point at MY_INT not at some other location later..

@@ -267,12 +267,14 @@ Token *TokenList::copyTokens(Token *dest, const Token *first, const Token *last,
std::stack<Token *> links;
Token *tok2 = dest;
int linenr = dest->linenr();
int column = dest->next() ? dest->next()->column() : dest->column() + dest->str().length() + 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the dest->column() + dest->str().length() + 1 is unfortunate. It's an educated guess but could be very wrong.

@@ -267,12 +267,14 @@ Token *TokenList::copyTokens(Token *dest, const Token *first, const Token *last,
std::stack<Token *> links;
Token *tok2 = dest;
int linenr = dest->linenr();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks inconsistent. we read linenr from dest but column from dest->next().
should there be some more option for the location?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants