[PATCH] D24444: [clang-tidy] modernize-use-default default constructor bugfix
Malcolm Parsons via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 11 04:21:26 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283869: [clang-tidy] modernize-use-default default constructor bugfix (authored by malcolm.parsons).
Changed prior to commit:
https://reviews.llvm.org/D24444?vs=70966&id=74232#toc
Repository:
rL LLVM
https://reviews.llvm.org/D24444
Files:
clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default.cpp
@@ -43,6 +43,24 @@
int Field;
};
+// Default member initializer
+class DMI {
+public:
+ DMI() {}
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
+ // CHECK-FIXES: DMI() = default;
+ int Field = 5;
+};
+
+// Class member
+class CM {
+public:
+ CM() {}
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
+ // CHECK-FIXES: CM() = default;
+ OL o;
+};
+
// Private constructor/destructor.
class Priv {
Priv() {}
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseDefaultCheck.cpp
@@ -238,7 +238,7 @@
isDefinition(),
anyOf(
// Default constructor.
- allOf(unless(hasAnyConstructorInitializer(anything())),
+ allOf(unless(hasAnyConstructorInitializer(isWritten())),
parameterCountIs(0)),
// Copy constructor.
allOf(isCopyConstructor(),
@@ -296,12 +296,12 @@
if (!isCopyConstructorAndCanBeDefaulted(Result.Context, Ctor))
return;
SpecialFunctionName = "copy constructor";
- }
- // If there are constructor initializers, they must be removed.
- if (Ctor->getNumCtorInitializers() != 0) {
- StartLoc = getColonLoc(Result.Context, Ctor);
- if (!StartLoc.isValid())
- return;
+ // If there are constructor initializers, they must be removed.
+ if (Ctor->getNumCtorInitializers() != 0) {
+ StartLoc = getColonLoc(Result.Context, Ctor);
+ if (!StartLoc.isValid())
+ return;
+ }
}
} else if (isa<CXXDestructorDecl>(SpecialFunctionDecl)) {
SpecialFunctionName = "destructor";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24444.74232.patch
Type: text/x-patch
Size: 2126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161011/1c8b917d/attachment.bin>
More information about the cfe-commits
mailing list