-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 #12658 Remove constructor initialize also with checkHeaders = false #6375
base: main
Are you sure you want to change the base?
Changes from 3 commits
b30aa4c
b8d036f
b9b2f02
f5b88ef
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 |
---|---|---|
|
@@ -6225,6 +6225,29 @@ void Tokenizer::simplifyHeadersAndUnusedTemplates() | |
for (Token *tok = list.front(); tok; tok = tok->next()) { | ||
const bool isIncluded = (tok->fileIndex() != 0); | ||
|
||
// Remove constructor initializer | ||
if (isIncluded && !mSettings.checkHeaders && Token::Match(tok, "%name% (")) { | ||
Token *start = tok->next()->link(); | ||
if (start) { | ||
start = start->next(); | ||
} | ||
if (start && start->str() == ":") { | ||
const Token *next = start; | ||
while (Token::Match(next, "[,:]")) { | ||
// Skip to ( or { | ||
while (next && !next->link()) | ||
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 don't want to skip any random tokens. something more like:
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. Looking better at it, If after the previous change 'Token::Match(next, "[,:] %name%")' The symbol after %name% should always be a link in a constructor initializer list. If not is is something else. %name% should always be a member or delegate constructor. Only thing now failing is a parameter pack expansion in an initializer list template<class... Mixins> |
||
next = next->next(); | ||
if (next) { | ||
next = next->link(); | ||
next = next->next(); // Go to next, either ',' or '{' | ||
} | ||
} | ||
if (next && next->str() == "{") { | ||
Token::eraseTokens(start->previous(), next); | ||
} | ||
} | ||
} | ||
|
||
// Remove executable code | ||
if (isIncluded && !mSettings.checkHeaders && tok->str() == "{") { | ||
// TODO: We probably need to keep the executable code if this function is called from the source file. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we expect that there is a name token after next right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in my opinion it wouldn't hurt to add that more explicit check.