[PATCH] D23343: [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 16 15:47:40 PDT 2016
aaron.ballman added inline comments.
================
Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:35
@@ +34,3 @@
+ auto CanCallCtor = unless(has(ignoringImpCasts(cxxConstructExpr(
+ hasDeclaration(decl(anyOf(isPrivate(), isProtected())))))));
+
----------------
Prazek wrote:
> aaron.ballman wrote:
> > Perhaps: `unless(isPublic())` instead of `anyOf(isPrivate(), isProtected())`?
> POD types doesn't have public constructors so it will fail :)
Don't they have an implicit one for the purposes of a CXXConstructExpr? Looking at an AST dump for:
```
struct S {
int i;
};
```
yields:
```
|-CXXRecordDecl 0x26d74ae5348 <line:25:1, line:27:1> line:25:8 referenced struct S definition
| |-CXXRecordDecl 0x26d74ae5460 <col:1, col:8> col:8 implicit struct S
| |-FieldDecl 0x26d74ae7880 <line:26:3, col:7> col:7 i 'int'
| |-CXXConstructorDecl 0x26d74ae87b8 <line:25:8> col:8 implicit used S 'void (void) noexcept' inline
| | `-CompoundStmt 0x26d74ae3850 <col:8>
| |-CXXConstructorDecl 0x26d74ae34a8 <col:8> col:8 implicit constexpr S 'void (const struct S &)' inline noexcept-unevaluated 0x26d74ae34a8
| | `-ParmVarDecl 0x26d74ae35e0 <col:8> col:8 'const struct S &'
| `-CXXConstructorDecl 0x26d74ae3678 <col:8> col:8 implicit constexpr S 'void (struct S &&)' inline noexcept-unevaluated 0x26d74ae3678
| `-ParmVarDecl 0x26d74ae37b0 <col:8> col:8 'struct S &&'
```
https://reviews.llvm.org/D23343
More information about the cfe-commits
mailing list