Skip to content

[engine] Enable cppcoreguidelines-pro-type-member-init clang-tidy check - #194576

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
gaaclarke:enable-pro-type-member-init
Oct 17, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:masterfrom
gaaclarke:enable-pro-type-member-init

Conversation

@gaaclarke

@gaaclarke gaaclarke commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

This PR enables a linter check that flags uninitialized variables. We ran into a problem when #194540 landed which was the result of uninitialized variables. This should catch those kinds of issues earlier. Most of this PR is generated by clang-tidy's fix operation, gemini operated where that failed.

Description from gemini:

#194540 fixed uninitialized counters in DlComplexityPathReceiver that caused a flaky DisplayListComplexity.DrawShadow failure. None of the clang-tidy checks we had enabled flag uninitialized members: modernize-use-default-member-init only rewrites existing constructor initializers, and the static analyzer gives up once the object is passed by reference to an out-of-line call.

This enables cppcoreguidelines-pro-type-member-init (with UseAssignment: true) and fixes the existing violations:

  • Scalar/pointer/enum members get default member initializers (= 0, = nullptr, or an explicit enumerator).
  • Uninitialized locals of trivially-constructible record types (FragInfo, PointerData, struct stat, ...) are value-initialized with {}.
  • Union-based types where the check reports false positives (Vector3/Vector4, HalfVector*, Quaternion, Shear, SaveLayerOptions) are wrapped in NOLINTBEGIN/END with an explanation.

Default member initializers don't change object size or layout. The only runtime cost is a few stores at construction, and most of those are dead stores the optimizer removes.

Verified locally: --lint-all with this check is clean on host_debug_unopt_arm64 (macOS) and android_debug_unopt_arm64, and both build. Linux host and iOS simulator lint variants will be checked by CI.

Pre-launch Checklist

@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems platform-android Android applications specifically engine flutter/engine related. See also e: labels. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) platform-macos Building on or for macOS specifically a: desktop Running on desktop e: impeller Impeller rendering backend issues and features requests team-android Owned by Android platform team flutter-gpu team-macos Owned by the macOS platform team team-fluttergpu Owned by Flutter GPU team labels Oct 16, 2026
@github-project-automation github-project-automation Bot moved this to 🤔 Needs Triage in Flutter GPU Oct 16, 2026
@gaaclarke gaaclarke added the CICD Run CI/CD label Oct 16, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request is not mergeable in its current state, likely because of a merge conflict. Pre-submit CI jobs were not triggered. Pushing a new commit to this branch that resolves the issue will result in pre-submit jobs being scheduled.

@gaaclarke gaaclarke removed this from Flutter GPU Oct 16, 2026
Enables the check that flags uninitialized member variables and locals of
trivially-constructible record types, and fixes all existing violations
found on the host and Android lint variants.

Union-based geometry types (Vector3/4, HalfVector*, Quaternion, Shear) and
SaveLayerOptions are suppressed with NOLINTBEGIN/END since the check doesn't
understand that the union alternatives share storage.
@gaaclarke
gaaclarke force-pushed the enable-pro-type-member-init branch from 5bcf37c to 9bfe677 Compare October 16, 2026 17:22
@github-actions github-actions Bot added platform-linux Building on or for Linux specifically team-linux Owned by the Linux platform team labels Oct 16, 2026
@github-project-automation github-project-automation Bot moved this to 🤔 Needs Triage in Flutter GPU Oct 16, 2026
@gaaclarke
gaaclarke marked this pull request as ready for review October 16, 2026 18:39
@gaaclarke
gaaclarke requested review from a team as code owners October 16, 2026 18:39
@gaaclarke
gaaclarke requested review from gmackall and removed request for a team October 16, 2026 18:39
@gaaclarke gaaclarke removed this from Flutter GPU Oct 16, 2026
@gaaclarke
gaaclarke requested a review from b-luk October 16, 2026 23:14
@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2026
@github-project-automation github-project-automation Bot moved this to 🤔 Needs Triage in Flutter GPU Oct 16, 2026
@auto-submit

auto-submit Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/194576, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2026
@gaaclarke gaaclarke added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 16, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Oct 16, 2026
@gaaclarke

Copy link
Copy Markdown
Member Author

Do not revert if there are integration problems, that is possible with new linter rules

Merged via the queue into flutter:master with commit 9e7c47a Oct 17, 2026
29 checks passed
@github-project-automation github-project-automation Bot moved this from 🤔 Needs Triage to ✅ Done in Flutter GPU Oct 17, 2026
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 17, 2026
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
…ck (flutter#194576)

This PR enables a linter check that flags uninitialized variables. We
ran into a problem when flutter#194540
landed which was the result of uninitialized variables. This should
catch those kinds of issues earlier. Most of this PR is generated by
clang-tidy's fix operation, gemini operated where that failed.

Description from gemini:

> flutter#194540 fixed uninitialized counters in `DlComplexityPathReceiver`
that caused a flaky `DisplayListComplexity.DrawShadow` failure. None of
the clang-tidy checks we had enabled flag uninitialized members:
`modernize-use-default-member-init` only rewrites existing constructor
initializers, and the static analyzer gives up once the object is passed
by reference to an out-of-line call.
> 
> This enables `cppcoreguidelines-pro-type-member-init` (with
`UseAssignment: true`) and fixes the existing violations:
> 
> * Scalar/pointer/enum members get default member initializers (`= 0`,
`= nullptr`, or an explicit enumerator).
> * Uninitialized locals of trivially-constructible record types
(`FragInfo`, `PointerData`, `struct stat`, ...) are value-initialized
with `{}`.
> * Union-based types where the check reports false positives
(`Vector3`/`Vector4`, `HalfVector*`, `Quaternion`, `Shear`,
`SaveLayerOptions`) are wrapped in `NOLINTBEGIN/END` with an
explanation.
> 
> Default member initializers don't change object size or layout. The
only runtime cost is a few stores at construction, and most of those are
dead stores the optimizer removes.
> 
> Verified locally: `--lint-all` with this check is clean on
`host_debug_unopt_arm64` (macOS) and `android_debug_unopt_arm64`, and
both build. Linux host and iOS simulator lint variants will be checked
by CI.
> 

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.

[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/AI-contribution-guidelines.md
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: desktop Running on desktop a: text input Entering text in a text field or keyboard related problems CICD Run CI/CD e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels. flutter-gpu platform-android Android applications specifically platform-ios iOS applications specifically platform-linux Building on or for Linux specifically platform-macos Building on or for macOS specifically team-android Owned by Android platform team team-fluttergpu Owned by Flutter GPU team team-ios Owned by iOS platform team team-linux Owned by the Linux platform team team-macos Owned by the macOS platform team

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants