[PATCH] D19993: Fixed cppcoreguidelines-pro-type-member-init when checking records with indirect fields

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu May 5 17:05:44 PDT 2016


On Thu, May 5, 2016 at 4:44 PM, Michael Miller via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> michael_miller added inline comments.
>
> ================
> Comment at: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp:31
> @@ +30,3 @@
> +// Convenience utility to get a RecordDecl from a QualType.
> +const RecordDecl *getCanonicalRecordDecl(const QualType &Type) {
> +  if (const auto *RT = Type.getCanonicalType()->getAs<RecordType>())
> ----------------
> alexfh wrote:
> > Is `getCanonicalType()` important here? Did you try using
> `QualType::getAsCXXRecordDecl()`?
> Probably not but I didn't try it. I just moved the previous function up to
> the top so I didn't have to forward declare it.
>
> One thing I'm simply unsure of is whether it's possible to get a
> RecordDecl that's not a CXXRecordDecl in C++ code. It seems like the answer
> is no but that might be another reason to keep it as is if I'm wrong about
> that...


It's fine to assume that all RecordDecls will be CXXRecordDecls in C++
code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160505/253d2219/attachment.html>


More information about the cfe-commits mailing list