[PATCH] D24965: [clang-tidy] Fix cppcoreguidelines-pro-type-member-init false negatives

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 3 13:25:21 PDT 2016


aaron.ballman added inline comments.


> ProTypeMemberInitCheck.cpp:307
> +                 Result.Nodes.getNodeAs<CXXRecordDecl>("record")) {
> +    assert(Record->hasDefaultConstructor());
> +    checkMissingMemberInitializer(*Result.Context, Record, nullptr);

Please add an explanatory string literal to the assert (that way, if it triggers, some more information is immediately available).

> ProTypeMemberInitCheck.cpp:372
>    // Do not propose fixes in macros since we cannot place them correctly.
> -  if (Ctor->getLocStart().isMacroID())
> +  if (Ctor && Ctor->getLocStart().isMacroID())
>      return;

Should also update the comment.

> cppcoreguidelines-pro-type-member-init.cpp:401
> +  // CHECK-FIXES: int F{};
> +};

Can you also add a test like:

  template <typename T>
  struct S {
    T Val;
    virtual ~S() = default;
  };
  
  template struct S<int>;

https://reviews.llvm.org/D24965





More information about the cfe-commits mailing list