Skip to content

Fix #14863 (tokenizer: add token flag when braces are inserted during simplifications and publish in dumpfile)#8664

Open
danmar wants to merge 1 commit into
cppcheck-opensource:mainfrom
cppchecksolutions:fix-14863
Open

Fix #14863 (tokenizer: add token flag when braces are inserted during simplifications and publish in dumpfile)#8664
danmar wants to merge 1 commit into
cppcheck-opensource:mainfrom
cppchecksolutions:fix-14863

Conversation

@danmar

@danmar danmar commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@danmar danmar changed the title Fix #14863 (dumpfile: flag isSimplifiedScope when compound scope is missing) Fix #14863 (tokenizer: add token flag when braces are inserted during simplifications and publish in dumpfile) Jun 19, 2026
@danmar danmar requested a review from Copilot June 19, 2026 10:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses #14863 by tracking braces that are inserted by tokenizer simplifications via a new Token flag and exposing that information in the tokenizer dump output.

Changes:

  • Add Token::isInsertedBrace flag and emit it as isInsertedBrace="true" in Tokenizer::dump().
  • Mark braces as inserted when adding braces during simplification (e.g., simplifyAddBracesPair(), elseif()).
  • Add a unit test that validates the dump contains the inserted-brace marker after while(a); is simplified.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
test/testtokenize.cpp Adds a regression test ensuring the dump output includes isInsertedBrace="true" after brace insertion.
lib/tokenize.cpp Emits the new dump attribute and sets the inserted-brace flag during relevant simplifications.
lib/token.h Introduces the new token flag and repurposes the prior simplified-scope flag into an if/switch/for-init-statement flag.
lib/checkother.cpp Updates logic to use the new flags (isInsertedBrace, isSimplifiedIfInitStmt) instead of the removed isSimplifiedScope.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/token.h
Comment thread lib/token.h
Comment thread lib/tokenize.cpp Outdated
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