MaskRay created this revision. MaskRay added reviewers: akyrtzi, jyknight, rtrieu, rsmith. Herald added subscribers: cfe-commits, dexonsmith. Herald added a project: clang.
The -Wparentheses warnings are enabled by default in clang but they are under -Wall in gcc (gcc/c-family/c.opt). Many of the operator precedence warnings are oftentimes criticized as noise (clang: default; gcc: -Wall). If a warning is very controversial, it is probably not a good idea to enable it by default. This patch disables the rather annoying ones: -Wbitwise-op-parentheses, e.g. i & i | i -Wlogical-op-parentheses, e.g. i && i || i -Wshift-op-parentheses (and -Woverloaded-shift-op-parentheses), e.g. i+i << i After this change: * = enabled by default -Wall -Wmost -Wparentheses -Wlogical-op-parentheses -Wlogical-not-parentheses* -Wbitwise-op-parentheses -Wshift-op-parentheses -Woverloaded-shift-op-parentheses -Wparentheses-equality* -Wdangling-else* Repository: rC Clang https://reviews.llvm.org/D65192 Files: include/clang/Basic/DiagnosticSemaKinds.td test/Misc/warning-flags-enabled.c test/Parser/cxx2a-spaceship.cpp test/SemaCXX/parentheses.cpp Index: test/SemaCXX/parentheses.cpp =================================================================== --- test/SemaCXX/parentheses.cpp +++ test/SemaCXX/parentheses.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -verify -Wlogical-op-parentheses %s // PR16930, PR16727: template<class Foo> Index: test/Parser/cxx2a-spaceship.cpp =================================================================== --- test/Parser/cxx2a-spaceship.cpp +++ test/Parser/cxx2a-spaceship.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++2a -verify %s +// RUN: %clang_cc1 -std=c++2a -verify -Wparentheses %s template<int> struct X {}; Index: test/Misc/warning-flags-enabled.c =================================================================== --- test/Misc/warning-flags-enabled.c +++ test/Misc/warning-flags-enabled.c @@ -36,7 +36,7 @@ // Test if -Wshift-op-parentheses is a subgroup of -Wparentheses // RUN: diagtool show-enabled --no-levels -Wno-parentheses -Wshift-op-parentheses %s | FileCheck --check-prefix CHECK-SHIFT-OP-PARENTHESES %s -// RUN: diagtool show-enabled --no-levels %s | FileCheck --check-prefix CHECK-SHIFT-OP-PARENTHESES %s +// RUN: diagtool show-enabled --no-levels %s | FileCheck --check-prefix CHECK-NO-SHIFT-OP-PARENTHESES %s // RUN: diagtool show-enabled --no-levels -Wno-parentheses %s | FileCheck --check-prefix CHECK-NO-SHIFT-OP-PARENTHESES %s // // CHECK-SHIFT-OP-PARENTHESES: -Wshift-op-parentheses Index: include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -5639,21 +5639,21 @@ "remove constant to silence this warning">; def warn_bitwise_op_in_bitwise_op : Warning< - "'%0' within '%1'">, InGroup<BitwiseOpParentheses>; + "'%0' within '%1'">, InGroup<BitwiseOpParentheses>, DefaultIgnore; def warn_logical_and_in_logical_or : Warning< - "'&&' within '||'">, InGroup<LogicalOpParentheses>; + "'&&' within '||'">, InGroup<LogicalOpParentheses>, DefaultIgnore; def warn_overloaded_shift_in_comparison :Warning< "overloaded operator %select{>>|<<}0 has higher precedence than " "comparison operator">, - InGroup<OverloadedShiftOpParentheses>; + InGroup<OverloadedShiftOpParentheses>, DefaultIgnore; def note_evaluate_comparison_first :Note< "place parentheses around comparison expression to evaluate it first">; def warn_addition_in_bitshift : Warning< "operator '%0' has lower precedence than '%1'; " - "'%1' will be evaluated first">, InGroup<ShiftOpParentheses>; + "'%1' will be evaluated first">, InGroup<ShiftOpParentheses>, DefaultIgnore; def warn_self_assignment_builtin : Warning< "explicitly assigning value of variable of type %0 to itself">,
Index: test/SemaCXX/parentheses.cpp =================================================================== --- test/SemaCXX/parentheses.cpp +++ test/SemaCXX/parentheses.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -verify -Wlogical-op-parentheses %s // PR16930, PR16727: template<class Foo> Index: test/Parser/cxx2a-spaceship.cpp =================================================================== --- test/Parser/cxx2a-spaceship.cpp +++ test/Parser/cxx2a-spaceship.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++2a -verify %s +// RUN: %clang_cc1 -std=c++2a -verify -Wparentheses %s template<int> struct X {}; Index: test/Misc/warning-flags-enabled.c =================================================================== --- test/Misc/warning-flags-enabled.c +++ test/Misc/warning-flags-enabled.c @@ -36,7 +36,7 @@ // Test if -Wshift-op-parentheses is a subgroup of -Wparentheses // RUN: diagtool show-enabled --no-levels -Wno-parentheses -Wshift-op-parentheses %s | FileCheck --check-prefix CHECK-SHIFT-OP-PARENTHESES %s -// RUN: diagtool show-enabled --no-levels %s | FileCheck --check-prefix CHECK-SHIFT-OP-PARENTHESES %s +// RUN: diagtool show-enabled --no-levels %s | FileCheck --check-prefix CHECK-NO-SHIFT-OP-PARENTHESES %s // RUN: diagtool show-enabled --no-levels -Wno-parentheses %s | FileCheck --check-prefix CHECK-NO-SHIFT-OP-PARENTHESES %s // // CHECK-SHIFT-OP-PARENTHESES: -Wshift-op-parentheses Index: include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -5639,21 +5639,21 @@ "remove constant to silence this warning">; def warn_bitwise_op_in_bitwise_op : Warning< - "'%0' within '%1'">, InGroup<BitwiseOpParentheses>; + "'%0' within '%1'">, InGroup<BitwiseOpParentheses>, DefaultIgnore; def warn_logical_and_in_logical_or : Warning< - "'&&' within '||'">, InGroup<LogicalOpParentheses>; + "'&&' within '||'">, InGroup<LogicalOpParentheses>, DefaultIgnore; def warn_overloaded_shift_in_comparison :Warning< "overloaded operator %select{>>|<<}0 has higher precedence than " "comparison operator">, - InGroup<OverloadedShiftOpParentheses>; + InGroup<OverloadedShiftOpParentheses>, DefaultIgnore; def note_evaluate_comparison_first :Note< "place parentheses around comparison expression to evaluate it first">; def warn_addition_in_bitshift : Warning< "operator '%0' has lower precedence than '%1'; " - "'%1' will be evaluated first">, InGroup<ShiftOpParentheses>; + "'%1' will be evaluated first">, InGroup<ShiftOpParentheses>, DefaultIgnore; def warn_self_assignment_builtin : Warning< "explicitly assigning value of variable of type %0 to itself">,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits