[all-commits] [llvm/llvm-project] 637af4: Add -Wbitwise-conditional-parentheses to warn on m...
llvm-git-migration via All-commits
all-commits at lists.llvm.org
Fri Oct 18 18:46:34 PDT 2019
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 637af4cc37802a25564aa96c4d4eb3facbcff9b8
https://github.com/llvm/llvm-project/commit/637af4cc37802a25564aa96c4d4eb3facbcff9b8
Author: Richard Trieu <rtrieu at google.com>
Date: 2019-10-19 (Sat, 19 Oct 2019)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/include/clang/Basic/DiagnosticGroups.td
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/lib/Sema/SemaExpr.cpp
M clang/test/Sema/parentheses.c
Log Message:
-----------
Add -Wbitwise-conditional-parentheses to warn on mixing '|' and '&' with "?:"
Extend -Wparentheses to cover mixing bitwise-and and bitwise-or with the
conditional operator. There's two main cases seen with this:
unsigned bits1 = 0xf0 | cond ? 0x4 : 0x1;
unsigned bits2 = cond1 ? 0xf0 : 0x10 | cond2 ? 0x5 : 0x2;
// Intended order of evaluation:
unsigned bits1 = 0xf0 | (cond ? 0x4 : 0x1);
unsigned bits2 = (cond1 ? 0xf0 : 0x10) | (cond2 ? 0x5 : 0x2);
// Actual order of evaluation:
unsigned bits1 = (0xf0 | cond) ? 0x4 : 0x1;
unsigned bits2 = cond1 ? 0xf0 : ((0x10 | cond2) ? 0x5 : 0x2);
Differential Revision: https://reviews.llvm.org/D66043
llvm-svn: 375326
More information about the All-commits
mailing list