clang API Documentation

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
clang::BinaryOperator Class Reference

A builtin binary operation expression such as "x + y" or "x <= y". More...

#include <Expr.h>

Inheritance diagram for clang::BinaryOperator:
Inheritance graph
[legend]
Collaboration diagram for clang::BinaryOperator:
Collaboration graph
[legend]

List of all members.

Public Types

typedef BinaryOperatorKind Opcode

Public Member Functions

 BinaryOperator (Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, bool fpContractable)
 BinaryOperator (EmptyShell Empty)
 Construct an empty binary operator.
SourceLocation getExprLoc () const LLVM_READONLY
SourceLocation getOperatorLoc () const
void setOperatorLoc (SourceLocation L)
Opcode getOpcode () const
void setOpcode (Opcode O)
ExprgetLHS () const
void setLHS (Expr *E)
ExprgetRHS () const
void setRHS (Expr *E)
SourceLocation getLocStart () const LLVM_READONLY
SourceLocation getLocEnd () const LLVM_READONLY
StringRef getOpcodeStr () const
bool isPtrMemOp () const
 predicates to categorize the respective opcodes.
bool isMultiplicativeOp () const
bool isAdditiveOp () const
bool isShiftOp () const
bool isBitwiseOp () const
bool isRelationalOp () const
bool isEqualityOp () const
bool isComparisonOp () const
bool isLogicalOp () const
bool isAssignmentOp () const
bool isCompoundAssignmentOp () const
bool isShiftAssignOp () const
child_range children ()
void setFPContractable (bool FPC)
bool isFPContractable () const

Static Public Member Functions

static StringRef getOpcodeStr (Opcode Op)
static Opcode getOverloadedOpcode (OverloadedOperatorKind OO)
 Retrieve the binary opcode that corresponds to the given overloaded operator.
static OverloadedOperatorKind getOverloadedOperator (Opcode Opc)
 Retrieve the overloaded operator kind that corresponds to the given binary opcode.
static bool isAdditiveOp (Opcode Opc)
static bool isShiftOp (Opcode Opc)
static bool isBitwiseOp (Opcode Opc)
static bool isRelationalOp (Opcode Opc)
static bool isEqualityOp (Opcode Opc)
static bool isComparisonOp (Opcode Opc)
static Opcode negateComparisonOp (Opcode Opc)
static Opcode reverseComparisonOp (Opcode Opc)
static bool isLogicalOp (Opcode Opc)
static bool isAssignmentOp (Opcode Opc)
static bool isCompoundAssignmentOp (Opcode Opc)
static Opcode getOpForCompoundAssignment (Opcode Opc)
static bool isShiftAssignOp (Opcode Opc)
static bool classof (const Stmt *S)

Protected Member Functions

 BinaryOperator (Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, bool fpContractable, bool dead2)
 BinaryOperator (StmtClass SC, EmptyShell Empty)

Detailed Description

A builtin binary operation expression such as "x + y" or "x <= y".

This expression node kind describes a builtin binary operation, such as "x + y" for integer values "x" and "y". The operands will already have been converted to appropriate types (e.g., by performing promotions or conversions).

In C++, where operators may be overloaded, a different kind of expression node (CXXOperatorCallExpr) is used to express the invocation of an overloaded operator with operator syntax. Within a C++ template, whether BinaryOperator or CXXOperatorCallExpr is used to store an expression "x + y" depends on the subexpressions for x and y. If neither x or y is type-dependent, and the "+" operator resolves to a built-in operation, BinaryOperator will be used to express the computation (x and y may still be value-dependent). If either x or y is type-dependent, or if the "+" resolves to an overloaded operator, CXXOperatorCallExpr will be used to express the computation.

Definition at line 2917 of file Expr.h.


Member Typedef Documentation

Definition at line 2919 of file Expr.h.


Constructor & Destructor Documentation

clang::BinaryOperator::BinaryOperator ( Expr lhs,
Expr rhs,
Opcode  opc,
QualType  ResTy,
ExprValueKind  VK,
ExprObjectKind  OK,
SourceLocation  opLoc,
bool  fpContractable 
) [inline]

Definition at line 2935 of file Expr.h.

References isCompoundAssignmentOp().

clang::BinaryOperator::BinaryOperator ( EmptyShell  Empty) [inline, explicit]

Construct an empty binary operator.

Definition at line 2953 of file Expr.h.

clang::BinaryOperator::BinaryOperator ( Expr lhs,
Expr rhs,
Opcode  opc,
QualType  ResTy,
ExprValueKind  VK,
ExprObjectKind  OK,
SourceLocation  opLoc,
bool  fpContractable,
bool  dead2 
) [inline, protected]

Definition at line 3084 of file Expr.h.

clang::BinaryOperator::BinaryOperator ( StmtClass  SC,
EmptyShell  Empty 
) [inline, protected]

Definition at line 3099 of file Expr.h.


Member Function Documentation

Reimplemented from clang::Stmt.

Definition at line 3071 of file Expr.h.

static bool clang::BinaryOperator::classof ( const Stmt S) [inline, static]

Reimplemented from clang::Expr.

Reimplemented in clang::CompoundAssignOperator.

Definition at line 3065 of file Expr.h.

References clang::Stmt::getStmtClass().

getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic expression.

Reimplemented from clang::Expr.

Definition at line 2956 of file Expr.h.

Referenced by LogicalErrorHandler::compareAlwaysTrue(), and LogicalErrorHandler::compareBitwiseEquality().

Expr* clang::BinaryOperator::getLHS ( ) const [inline]

Reimplemented from clang::Stmt.

Definition at line 2971 of file Expr.h.

References clang::Stmt::getLocEnd(), and getRHS().

Reimplemented from clang::Stmt.

Definition at line 2968 of file Expr.h.

References getLHS(), and clang::Stmt::getLocStart().

Referenced by DiagUninitUse().

Definition at line 2960 of file Expr.h.

Referenced by CheckICE(), ClassifyBinaryOp(), DiagUninitUse(), clang::CodeGen::CodeGenFunction::EmitBinaryOperatorLValue(), clang::CodeGen::CodeGenFunction::EmitComplexAssignmentLValue(), clang::CodeGen::CodeGenFunction::EmitComplexCompoundAssignmentLValue(), clang::CodeGen::CodeGenFunction::EmitCompoundAssignmentLValue(), clang::CodeGen::CodeGenFunction::EmitCXXMemberPointerCallExpr(), EmitDiagnosticForBitwiseAndInBitwiseOr(), EmitDiagnosticForLogicalAndInLogicalOr(), clang::CodeGen::CodeGenFunction::EmitPointerToDataMemberBinaryExpr(), clang::CodeGen::CodeGenFunction::EmitScalarCompooundAssignWithComplex(), EvalAddr(), GenerateMinimalPathDiagnostic(), getOpcodeStr(), HandleMemberPointerAccess(), isAdditiveOp(), isAssignmentOp(), isBitwiseOp(), isComparisonOp(), isCompoundAssignmentOp(), clang::ParentMap::isConsumedExpr(), isEqualityOp(), isIdenticalStmt(), isLogicalOp(), clang::arcmt::trans::isPlusOneAssign(), isRelationalOp(), isShiftAssignOp(), isShiftOp(), clang::Expr::isUnusedResultAWarning(), LookThroughTransitiveAssignmentsAndCommaOperators(), print_elem(), clang::ento::ExprEngine::Visit(), clang::ASTNodeImporter::VisitBinaryOperator(), clang::ento::ExprEngine::VisitBinaryOperator(), clang::consumed::ConsumedStmtVisitor::VisitBinaryOperator(), clang::threadSafety::VarMapBuilder::VisitBinaryOperator(), clang::ASTNodeImporter::VisitCompoundAssignOperator(), clang::ento::ExprEngine::VisitLogicalExpr(), and clang::ento::ConditionBRVisitor::VisitTrueTest().

StringRef BinaryOperator::getOpcodeStr ( Opcode  Op) [static]
StringRef clang::BinaryOperator::getOpcodeStr ( ) const [inline]

Retrieve the overloaded operator kind that corresponds to the given binary opcode.

Definition at line 1845 of file Expr.cpp.

References clang::OO_None.

Referenced by BuildOverloadedBinOp(), and clang::Sema::CreateOverloadedBinOp().

Expr* clang::BinaryOperator::getRHS ( ) const [inline]
static bool clang::BinaryOperator::isAdditiveOp ( Opcode  Opc) [inline, static]

Definition at line 2992 of file Expr.h.

References clang::BO_Add, and clang::BO_Sub.

Referenced by ignoreLiteralAdditions(), and clang::ento::ExprEngine::VisitBinaryOperator().

Definition at line 2993 of file Expr.h.

References getOpcode(), and isAdditiveOp().

Referenced by isAdditiveOp().

static bool clang::BinaryOperator::isAssignmentOp ( Opcode  Opc) [inline, static]
static bool clang::BinaryOperator::isBitwiseOp ( Opcode  Opc) [inline, static]

Definition at line 2997 of file Expr.h.

References clang::BO_And, and clang::BO_Or.

Referenced by DiagnoseBitwisePrecedence().

Definition at line 2998 of file Expr.h.

References getOpcode(), and isBitwiseOp().

Referenced by DiagnoseBinOpPrecedence(), and isBitwiseOp().

static bool clang::BinaryOperator::isComparisonOp ( Opcode  Opc) [inline, static]
static bool clang::BinaryOperator::isCompoundAssignmentOp ( Opcode  Opc) [inline, static]

Definition at line 3044 of file Expr.h.

References clang::BO_Assign, and clang::BO_OrAssign.

Referenced by clang::ento::ExprEngine::VisitBinaryOperator().

static bool clang::BinaryOperator::isEqualityOp ( Opcode  Opc) [inline, static]

Definition at line 3003 of file Expr.h.

References clang::BO_EQ, and clang::BO_NE.

Referenced by CheckMemorySizeofForComparison(), and clang::ento::ExprEngine::Visit().

Definition at line 3004 of file Expr.h.

References getOpcode(), and isEqualityOp().

Referenced by diagnoseObjCLiteralComparison(), and isEqualityOp().

static bool clang::BinaryOperator::isLogicalOp ( Opcode  Opc) [inline, static]

Definition at line 3037 of file Expr.h.

References getOpcode(), and isLogicalOp().

Referenced by isLogicalOp().

Definition at line 2991 of file Expr.h.

References clang::BO_Mul, and clang::BO_Rem.

predicates to categorize the respective opcodes.

Definition at line 2990 of file Expr.h.

References clang::BO_PtrMemD, and clang::BO_PtrMemI.

static bool clang::BinaryOperator::isRelationalOp ( Opcode  Opc) [inline, static]

Definition at line 3000 of file Expr.h.

References clang::BO_GE, and clang::BO_LT.

Referenced by clang::ento::ExprEngine::Visit().

Definition at line 3001 of file Expr.h.

References getOpcode(), and isRelationalOp().

Referenced by isRelationalOp().

static bool clang::BinaryOperator::isShiftAssignOp ( Opcode  Opc) [inline, static]

Definition at line 3058 of file Expr.h.

References clang::BO_ShlAssign, and clang::BO_ShrAssign.

Definition at line 3061 of file Expr.h.

References getOpcode().

static bool clang::BinaryOperator::isShiftOp ( Opcode  Opc) [inline, static]

Definition at line 2994 of file Expr.h.

References clang::BO_Shl, and clang::BO_Shr.

Definition at line 2995 of file Expr.h.

References getOpcode(), and isShiftOp().

Referenced by isShiftOp().

static Opcode clang::BinaryOperator::negateComparisonOp ( Opcode  Opc) [inline, static]
static Opcode clang::BinaryOperator::reverseComparisonOp ( Opcode  Opc) [inline, static]

Definition at line 3077 of file Expr.h.

void clang::BinaryOperator::setLHS ( Expr E) [inline]

Definition at line 2964 of file Expr.h.

Definition at line 2961 of file Expr.h.

Definition at line 2958 of file Expr.h.

void clang::BinaryOperator::setRHS ( Expr E) [inline]

Definition at line 2966 of file Expr.h.


The documentation for this class was generated from the following files: