Skip to content

C++: Make 'getChildCount' more robust by counting indices instead of elements#21280

Merged
MathiasVP merged 1 commit intogithub:mainfrom
MathiasVP:make-getChildCount-more-robust
Feb 6, 2026
Merged

C++: Make 'getChildCount' more robust by counting indices instead of elements#21280
MathiasVP merged 1 commit intogithub:mainfrom
MathiasVP:make-getChildCount-more-robust

Conversation

@MathiasVP
Copy link
Contributor

In an ideal world counting elements should give the same as counting how many indices returns an element. However I noticed today that, on inconsistent databases, it is possible that a single index can return duplicated getDeclarationEntrys.

This meant that getChildCount() returned 2 (because there were two getDeclarationEntrys for index 0). However, only getDeclarationEntry(0) had a result (in fact it had 2 results), and getDeclarationEntry(1) returned no results. This caused the control-flow graph abruptly stop.

By changing getChildCount to count indices instead we avoid a dead-end in the control-flow graph since getChildCount() now returns 1.

@MathiasVP MathiasVP requested a review from a team as a code owner February 5, 2026 20:28
Copilot AI review requested due to automatic review settings February 5, 2026 20:28
@MathiasVP MathiasVP added the no-change-note-required This PR does not need a change note label Feb 5, 2026
@github-actions github-actions bot added the C++ label Feb 5, 2026
Copy link
Contributor

Copilot AI left a comment

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 fixes a robustness issue in the C++ IR (Intermediate Representation) implementation where inconsistent databases could cause the control-flow graph to abruptly stop. The fix changes how getChildCount() calculates the number of children in declaration statements.

Changes:

  • Modified TranslatedDeclStmt.getChildCount() to count distinct indices instead of counting elements, preventing issues when duplicate elements exist for a single index on inconsistent databases.

Copy link
Contributor

@IdrissRio IdrissRio left a comment

Choose a reason for hiding this comment

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

LGTM 👍

DCA looks good as well except for one project failing with: fatal error occurred: Injecting Windows tracer failed which is completely unrelated.

@MathiasVP
Copy link
Contributor Author

Thanks, Idriss! DCA looks fantastic. A not insignificant reduction in dead ends in the CFG across all projects.

image

@MathiasVP MathiasVP merged commit 2c05624 into github:main Feb 6, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C++ no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants