Fix #13847 (simplifyTypedef should not simplify all using statements)#7527
Conversation
|
Do we handle this code? FYI accepted by clang and gcc, rejected by msvc. |
I thought it would.. do I understand it correctly that the |
Yes, at least two compilers interpret |
|
After And then after this the |
|
I feel I would rather not update But if I move the variable a little then clang suddenly seems to reject the code: so it seems if we make some exception in simplifyUsing it should only be for the variables in local scope |
There was a problem hiding this comment.
Pull Request Overview
This PR addresses issue #13847 by preventing the simplifyTypedef pass from converting all using statements into typedefs in C++ code.
- Added a new tokenizer test (
tokenize41) to cover the no-simplify-using scenario. - Introduced
typedefInfo3to verify thatdumpTypedefInfoignoresusingstatements. - Removed the old
simplifyUsingToTypedefmethod and inlined minimalusing→typedeflogic intosimplifyTypedefCpp.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/testtokenize.cpp | Added tokenize41 test for using statements (#13847). |
| test/testsimplifytypedef.cpp | Registered new typedefInfo3 test; removed typedefInfo2 registration. |
| lib/tokenize.h | Dropped simplifyUsingToTypedef declaration. |
| lib/tokenize.cpp | Removed simplifyUsingToTypedef implementation; inlined simple using→typedef pattern. |
Comments suppressed due to low confidence (3)
test/testtokenize.cpp:873
- The test currently discards
errout_str(). Add an assertion likeASSERT_EQUALS("", errout_str());to ensure no unexpected errors are emitted during tokenization.
(void)errout_str();
test/testsimplifytypedef.cpp:253
- The original TEST_CASE(typedefInfo2) registration was removed, so its test will no longer run. Either restore TEST_CASE(typedefInfo2) or remove its function definition to keep the suite consistent.
TEST_CASE(typedefInfo3);
lib/tokenize.cpp:1951
- This pattern only matches single-level
using X::Y;and misses global-namespace or nested qualifiers (e.g.,using ::X::Y;). Consider extending the match to also coverusing :: %name% ::|;or refactor using logic to handle all valid cases.
if (cpp && Token::Match(tok2->previous(), "using %name% ::|;")) {
|
This PR is about making |
|
I created https://trac.cppcheck.net/ticket/13872 about your issue |
No description provided.