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(SpecialFunctionDecl)) { SpecialFunctionName = "destructor"; 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() {}