[PATCH] D49356: [clang-tidy: modernize] Fix modernize-use-equals-default with {} brackets list initialization: patch
IdrissRio created this revision. IdrissRio added reviewers: aaron.ballman, hokein, alexfh. Herald added a subscriber: cfe-commits. Hello, i would like to suggest a fix for one of the checks in clang-tidy. The bug was reported in https://bugs.llvm.org/show_bug.cgi?id=38039 where you can find more information Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49356 Files: clang-tidy/modernize/UseEqualsDefaultCheck.cpp test/clang-tidy/modernize-use-equals-default-copy.cpp Index: test/clang-tidy/modernize-use-equals-default-copy.cpp === --- test/clang-tidy/modernize-use-equals-default-copy.cpp +++ test/clang-tidy/modernize-use-equals-default-copy.cpp @@ -497,3 +497,11 @@ STRUCT_WITH_COPY_ASSIGN(unsigned char, Hex8CopyAssign) // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy-assignment operator // CHECK-MESSAGES: :[[@LINE-9]]:40: note: + +// Use of braces +struct UOB{ + UOB(const UOB &Other):j{Other.j}{} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default] + // CHECK-FIXES: UOB(const UOB &Other)= default; + int j; +}; Index: clang-tidy/modernize/UseEqualsDefaultCheck.cpp === --- clang-tidy/modernize/UseEqualsDefaultCheck.cpp +++ clang-tidy/modernize/UseEqualsDefaultCheck.cpp @@ -97,6 +97,7 @@ isMemberInitializer(), forField(equalsNode(Field)), withInitializer(anyOf( AccessToFieldInParam, + initListExpr(has(AccessToFieldInParam)), cxxConstructExpr(allOf( hasDeclaration(cxxConstructorDecl(isCopyConstructor())), argumentCountIs(1), Index: test/clang-tidy/modernize-use-equals-default-copy.cpp === --- test/clang-tidy/modernize-use-equals-default-copy.cpp +++ test/clang-tidy/modernize-use-equals-default-copy.cpp @@ -497,3 +497,11 @@ STRUCT_WITH_COPY_ASSIGN(unsigned char, Hex8CopyAssign) // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy-assignment operator // CHECK-MESSAGES: :[[@LINE-9]]:40: note: + +// Use of braces +struct UOB{ + UOB(const UOB &Other):j{Other.j}{} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default] + // CHECK-FIXES: UOB(const UOB &Other)= default; + int j; +}; Index: clang-tidy/modernize/UseEqualsDefaultCheck.cpp === --- clang-tidy/modernize/UseEqualsDefaultCheck.cpp +++ clang-tidy/modernize/UseEqualsDefaultCheck.cpp @@ -97,6 +97,7 @@ isMemberInitializer(), forField(equalsNode(Field)), withInitializer(anyOf( AccessToFieldInParam, + initListExpr(has(AccessToFieldInParam)), cxxConstructExpr(allOf( hasDeclaration(cxxConstructorDecl(isCopyConstructor())), argumentCountIs(1), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49356: [clang-tidy: modernize] Fix modernize-use-equals-default with {} brackets list initialization: patch
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM with a formatting nit. Comment at: clang-tidy/modernize/UseEqualsDefaultCheck.cpp:100 AccessToFieldInParam, + initListExpr(has(AccessToFieldInParam)), cxxConstructExpr(allOf( Did clang-format produce this formatting? If not, can you clang-format this patch? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49356 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49356: [clang-tidy: modernize] Fix modernize-use-equals-default with {} brackets list initialization: patch
IdrissRio updated this revision to Diff 155715. IdrissRio added a comment. Fixed the formatting error with clang-format Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49356 Files: clang-tidy/modernize/UseEqualsDefaultCheck.cpp test/clang-tidy/modernize-use-equals-default-copy.cpp Index: test/clang-tidy/modernize-use-equals-default-copy.cpp === --- test/clang-tidy/modernize-use-equals-default-copy.cpp +++ test/clang-tidy/modernize-use-equals-default-copy.cpp @@ -497,3 +497,11 @@ STRUCT_WITH_COPY_ASSIGN(unsigned char, Hex8CopyAssign) // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy-assignment operator // CHECK-MESSAGES: :[[@LINE-9]]:40: note: + +// Use of braces +struct UOB{ + UOB(const UOB &Other):j{Other.j}{} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default] + // CHECK-FIXES: UOB(const UOB &Other)= default; + int j; +}; Index: clang-tidy/modernize/UseEqualsDefaultCheck.cpp === --- clang-tidy/modernize/UseEqualsDefaultCheck.cpp +++ clang-tidy/modernize/UseEqualsDefaultCheck.cpp @@ -97,6 +97,7 @@ isMemberInitializer(), forField(equalsNode(Field)), withInitializer(anyOf( AccessToFieldInParam, +initListExpr(has(AccessToFieldInParam)), cxxConstructExpr(allOf( hasDeclaration(cxxConstructorDecl(isCopyConstructor())), argumentCountIs(1), Index: test/clang-tidy/modernize-use-equals-default-copy.cpp === --- test/clang-tidy/modernize-use-equals-default-copy.cpp +++ test/clang-tidy/modernize-use-equals-default-copy.cpp @@ -497,3 +497,11 @@ STRUCT_WITH_COPY_ASSIGN(unsigned char, Hex8CopyAssign) // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy-assignment operator // CHECK-MESSAGES: :[[@LINE-9]]:40: note: + +// Use of braces +struct UOB{ + UOB(const UOB &Other):j{Other.j}{} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default] + // CHECK-FIXES: UOB(const UOB &Other)= default; + int j; +}; Index: clang-tidy/modernize/UseEqualsDefaultCheck.cpp === --- clang-tidy/modernize/UseEqualsDefaultCheck.cpp +++ clang-tidy/modernize/UseEqualsDefaultCheck.cpp @@ -97,6 +97,7 @@ isMemberInitializer(), forField(equalsNode(Field)), withInitializer(anyOf( AccessToFieldInParam, +initListExpr(has(AccessToFieldInParam)), cxxConstructExpr(allOf( hasDeclaration(cxxConstructorDecl(isCopyConstructor())), argumentCountIs(1), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D49356: [clang-tidy: modernize] Fix modernize-use-equals-default with {} brackets list initialization: patch
This revision was automatically updated to reflect the committed changes. IdrissRio marked an inline comment as done. Closed by commit rCTE337286: [clang-tidy: modernize] Fix modernize-use-equals-default with {} brackets list… (authored by IdrissRio, committed by ). Changed prior to commit: https://reviews.llvm.org/D49356?vs=155715&id=155887#toc Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D49356 Files: clang-tidy/modernize/UseEqualsDefaultCheck.cpp test/clang-tidy/modernize-use-equals-default-copy.cpp Index: test/clang-tidy/modernize-use-equals-default-copy.cpp === --- test/clang-tidy/modernize-use-equals-default-copy.cpp +++ test/clang-tidy/modernize-use-equals-default-copy.cpp @@ -497,3 +497,11 @@ STRUCT_WITH_COPY_ASSIGN(unsigned char, Hex8CopyAssign) // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy-assignment operator // CHECK-MESSAGES: :[[@LINE-9]]:40: note: + +// Use of braces +struct UOB{ + UOB(const UOB &Other):j{Other.j}{} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default] + // CHECK-FIXES: UOB(const UOB &Other)= default; + int j; +}; Index: clang-tidy/modernize/UseEqualsDefaultCheck.cpp === --- clang-tidy/modernize/UseEqualsDefaultCheck.cpp +++ clang-tidy/modernize/UseEqualsDefaultCheck.cpp @@ -97,6 +97,7 @@ isMemberInitializer(), forField(equalsNode(Field)), withInitializer(anyOf( AccessToFieldInParam, +initListExpr(has(AccessToFieldInParam)), cxxConstructExpr(allOf( hasDeclaration(cxxConstructorDecl(isCopyConstructor())), argumentCountIs(1), Index: test/clang-tidy/modernize-use-equals-default-copy.cpp === --- test/clang-tidy/modernize-use-equals-default-copy.cpp +++ test/clang-tidy/modernize-use-equals-default-copy.cpp @@ -497,3 +497,11 @@ STRUCT_WITH_COPY_ASSIGN(unsigned char, Hex8CopyAssign) // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy-assignment operator // CHECK-MESSAGES: :[[@LINE-9]]:40: note: + +// Use of braces +struct UOB{ + UOB(const UOB &Other):j{Other.j}{} + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default] + // CHECK-FIXES: UOB(const UOB &Other)= default; + int j; +}; Index: clang-tidy/modernize/UseEqualsDefaultCheck.cpp === --- clang-tidy/modernize/UseEqualsDefaultCheck.cpp +++ clang-tidy/modernize/UseEqualsDefaultCheck.cpp @@ -97,6 +97,7 @@ isMemberInitializer(), forField(equalsNode(Field)), withInitializer(anyOf( AccessToFieldInParam, +initListExpr(has(AccessToFieldInParam)), cxxConstructExpr(allOf( hasDeclaration(cxxConstructorDecl(isCopyConstructor())), argumentCountIs(1), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits