[PATCH] D52771: [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP)

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 5 07:27:35 PDT 2018


JonasToth added a comment.

C.131 seems to imply a minimal amount of trivial getters/setters before
diagnosing.

I feel that the CPPCG just want to force the programmer to think twice
instead of forbidding it totally.
It might be worth to have a more chatty/specific check for the CPPCG and
a strict "Don't do it" for HICPP.

>From my experience with asking the CPPCG authors it takes a while for a
response and that in the end is
not necessarily telling which way to go. Experience might differ
depending on topic though.

> Hmm, I don't know that it would help with code like this:
> 
>   class Base {
>     int f; // Suggested by C.133/C.9
>   
>   protected:
>   //  int f; // Disallowed by C.133
>   
>     int getF() const { return f; } // Suggested by C.133, disallowed by C.131
>     void setF(int NewF) { f = NewF; }  // Suggested by C.133, disallowed by C.131
>   };
> 
>> Still worth asking the authors.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52771





More information about the cfe-commits mailing list