This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] fix false-positive for cppcoreguidelines-pro-type-member-init with in-class initializers
ClosedPublic

Authored by mgehre on Sep 22 2016, 2:45 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

mgehre updated this revision to Diff 72217.Sep 22 2016, 2:45 PM
mgehre retitled this revision from to [clang-tidy] fix false-positive for cppcoreguidelines-pro-type-member-init with in-class initializers.
mgehre updated this object.
mgehre added reviewers: alexfh, aaron.ballman.
mgehre added a subscriber: cfe-commits.
test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
372 ↗(On Diff #72217)

There's already this test:

struct NegativeInClassInitialized {
    int F = 0;  
    NegativeInClassInitialized() {}
};

I'd call your test NegativeInClassInitializedImplicit, and also add this:

struct NegativeInClassInitializedDefaulted {
    int F = 0;
    NegativeInClassInitializedDefaulted() = default;
};
aaron.ballman accepted this revision.Sep 26 2016, 9:04 AM
aaron.ballman edited edge metadata.

LGTM with Malcom's test suggestions addressed.

This revision is now accepted and ready to land.Sep 26 2016, 9:04 AM
mgehre updated this revision to Diff 72677.Sep 27 2016, 11:05 AM
mgehre edited edge metadata.

Rename the struct that was introduced in the test. Note that I need to keep the function Bug30487,
because that is where the false-positive warning was emitted.

Rename the struct that was introduced in the test. Note that I need to keep the function Bug30487,
because that is where the false-positive warning was emitted.

D24965 will allow you to write a positive test instead:

struct PositivePartiallyInClassInitialized {
  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: constructor does not initialize these fields: G
  int F = 0;
  int G;
  // CHECK-FIXES: int G{};
};

I would like to close that particular bug report, and thus I would like to have the reproducer of that bug as part of the test case.
The PositivePartiallyInClassInitialized is also a good test, but I fail to see how it is proves that that particular bug is solved.

Are you okay with me committing this as it currently is?

Are you okay with me committing this as it currently is?

Yes.

This revision was automatically updated to reflect the committed changes.