[cfe-commits] r85117 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/Sema/parentheses.c
Chris Lattner
clattner at apple.com
Mon Oct 26 14:30:06 PDT 2009
On Oct 26, 2009, at 8:24 AM, Sebastian Redl wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=85117&view=rev
> Log:
> Implement a warning for mixing bitwise logical with comparison ops.
> Fixes PR5297.
Nice, thanks Sebasian!
>
> +static inline bool IsBitwise(int Opc) {
> + return Opc >= BinaryOperator::And && Opc <= BinaryOperator::Or;
> +}
> +static inline bool IsEqOrRel(int Opc) {
> + return Opc >= BinaryOperator::LT && Opc <= BinaryOperator::NE;
> +}
Please make these be static methods on the BinaryOperator class. On
the LLVM IR side of things we usually have something like this:
class BinOp {
...
static bool isBitwise(unsigned Opcode) { ... }
bool isBitwise() const { return isBitwise(getOpcode()); }
}
which is a nice pattern.
> +
> +static void DiagnoseBitwisePrecedence(Sema &Self,
> BinaryOperator::Opcode Opc,
> + SourceLocation OpLoc,Expr
> *lhs,Expr *rhs){
Please add a doxygen comment. Thanks for adding this!
-Chris
More information about the cfe-commits
mailing list