[clang-tools-extra] r342388 - [Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains about variable cast to void
Author: idrissrio Date: Mon Sep 17 05:29:29 2018 New Revision: 342388 URL: http://llvm.org/viewvc/llvm-project?rev=342388&view=rev Log: [Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains about variable cast to void Summary: 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=32575 where you can find more information. For example: ``` template struct S { template void g() const { int a; (void)a; } }; void f() { S().g(); } ``` this piece of code should not trigger any warning by the check modernize-redundant-void-arg but when we execute the following command ``` clang_tidy -checks=-*,modernize-redundant-void-arg test.cpp -- -std=c++11 ``` we obtain the following warning: /Users/eco419/Desktop/clang-tidy.project/void-redundand_2/test.cpp:6:6: warning: redundant void argument list in function declaration [modernize-redundant-void-arg] (void)a; ^~~~ Reviewers: aaron.ballman, hokein, alexfh, JonasToth Reviewed By: aaron.ballman, JonasToth Subscribers: JonasToth, lebedev.ri, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D52135 Modified: clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp Modified: clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp?rev=342388&r1=342387&r2=342388&view=diff == --- clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp Mon Sep 17 05:29:29 2018 @@ -49,7 +49,7 @@ void RedundantVoidArgCheck::registerMatc return; Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()), - unless(isExternC())) + unless(isInstantiated()), unless(isExternC())) .bind(FunctionId), this); Finder->addMatcher(typedefNameDecl().bind(TypedefId), this); Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp?rev=342388&r1=342387&r2=342388&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp Mon Sep 17 05:29:29 2018 @@ -488,3 +488,64 @@ void lambda_expression_with_macro_test() // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg] // CHECK-FIXES: []() BODY; } + +struct S_1 { + void g_1(void) const { +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg] +// CHECK-FIXES: void g_1() const { +int a; +(void)a; + } + + void g_2() const { +int a; +(void)a; + } +}; + +template +struct S_2 { + void g_1(void) const { +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg] +// CHECK-FIXES: void g_1() const { +int a; +(void)a; + } + + void g_2() const { +int a; +(void)a; + } +}; + +template +struct S_3 { + template + void g_1(void) const { +// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg] +// CHECK-FIXES: void g_1() const { +int a; +(void)a; + } + template + void g_2() const { +int a; +(void)a; + } +}; + +template +void g_3(void) { + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant void argument list in function definition [modernize-redundant-void-arg] + // CHECK-FIXES: void g_3(){ + int a; + (void)a; +} + +//Template instantiation +void f_testTemplate() { + S_1(); + S_2(); + S_3(); + g_3(); +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r342389 - Fix
Author: idrissrio Date: Mon Sep 17 05:58:19 2018 New Revision: 342389 URL: http://llvm.org/viewvc/llvm-project?rev=342389&view=rev Log: Fix Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp?rev=342389&r1=342388&r2=342389&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp Mon Sep 17 05:58:19 2018 @@ -491,7 +491,7 @@ void lambda_expression_with_macro_test() struct S_1 { void g_1(void) const { -// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg] +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant void argument list in function definition [modernize-redundant-void-arg] // CHECK-FIXES: void g_1() const { int a; (void)a; @@ -506,7 +506,7 @@ struct S_1 { template struct S_2 { void g_1(void) const { -// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg] +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant void argument list in function definition [modernize-redundant-void-arg] // CHECK-FIXES: void g_1() const { int a; (void)a; @@ -522,7 +522,7 @@ template struct S_3 { template void g_1(void) const { -// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg] +// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant void argument list in function definition [modernize-redundant-void-arg] // CHECK-FIXES: void g_1() const { int a; (void)a; @@ -537,7 +537,7 @@ struct S_3 { template void g_3(void) { // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant void argument list in function definition [modernize-redundant-void-arg] - // CHECK-FIXES: void g_3(){ + // CHECK-FIXES: void g_3() { int a; (void)a; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r337286 - [clang-tidy: modernize] Fix modernize-use-equals-default with {} brackets list initialization: patch
Author: idrissrio Date: Tue Jul 17 07:35:15 2018 New Revision: 337286 URL: http://llvm.org/viewvc/llvm-project?rev=337286&view=rev Log: [clang-tidy: modernize] Fix modernize-use-equals-default with {} brackets list initialization: patch Summary: 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. ``` struct UOB{ UOB(const UOB &Other):j{Other.j}{} int j; }; ``` In this case the check modernize-use-equals-default does not detect copy constructors that can be defaulted; that should be: ``` struct UOB{ UOB(const UOB &Other) = default; int j; }; ``` Reviewers: aaron.ballman, hokein, alexfh Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49356 Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp?rev=337286&r1=337285&r2=337286&view=diff == --- clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/modernize/UseEqualsDefaultCheck.cpp Tue Jul 17 07:35:15 2018 @@ -97,6 +97,7 @@ static bool isCopyConstructorAndCanBeDef isMemberInitializer(), forField(equalsNode(Field)), withInitializer(anyOf( AccessToFieldInParam, +initListExpr(has(AccessToFieldInParam)), cxxConstructExpr(allOf( hasDeclaration(cxxConstructorDecl(isCopyConstructor())), argumentCountIs(1), Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp?rev=337286&r1=337285&r2=337286&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp Tue Jul 17 07:35:15 2018 @@ -497,3 +497,11 @@ STRUCT_WITH_COPY_CONSTRUCT(unsigned char 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; +}; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[Clang-Tidy]: modernize-avoid-bind erroneous scope resolution.
Hello, i would like to suggest a fix for one of the checks in clang-tidy and i should hope this one is the correct mailing list.The check is modernize-avoid-bind.Consider the following:void bar(int x, int y);namespace N{ void bar(int x, int y);}void foo(){ auto Test = std::bind(N::bar,1,1);}clang-tidy’s modernize-avoid-bind check suggests writing:void foo(){ auto Test =[] {return bar(1,1);};}instead of:void foo(){ auto Test = [] {return N::bar(1,1);};}So clang-tidy has proposed an incorrect Fix.This is my proposal patch: AvoidBindCheck.patch Description: Binary data And this is my proposal testcase: modernize-avoid-bind.patch Description: Binary data Should I have to open a report on BugZilla? Idriss Riouakidriss.rio...@studenti.unipr.itCorso di Laurea in scienze informatica.Dipartimento di Matematica e Informatica. smime.p7s Description: S/MIME cryptographic signature ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[Clang-tools-extra][Clang-Tidy]: Fix modernize-avoid-bind erroneous scope resolution. [ping]
Hello, i would like to suggest a fix for one of the checks in clang-tidy and i should hope this one is the correct mailing list.The check is modernize-avoid-bind.Consider the following:void bar(int x, int y);namespace N{ void bar(int x, int y);}void foo(){ auto Test = std::bind(N::bar,1,1);}clang-tidy’s modernize-avoid-bind check suggests writing:void foo(){ auto Test =[] {return bar(1,1);};}instead of:void foo(){ auto Test = [] {return N::bar(1,1);};}So clang-tidy has proposed an incorrect Fix.This is my proposal patch: AvoidBindCheck.patch Description: Binary data And this is my proposal testcase: modernize-avoid-bind.patch Description: Binary data Should I have to open a report on BugZilla? Idriss Riouakidriss.rio...@studenti.unipr.itCorso di Laurea in scienze informatica.Dipartimento di Matematica e Informatica. smime.p7s Description: S/MIME cryptographic signature ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits