From 2de56d1d0c3a504ad1529de2677628bdfbb95cd4 Mon Sep 17 00:00:00 2001 From: John McCall Date: Wed, 25 Aug 2010 11:45:40 +0000 Subject: [PATCH] GCC didn't care for my attempt at API compatibility, so brute-force everything to the new constants. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112047 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Expr.h | 204 ++------ include/clang/AST/RecursiveASTVisitor.h | 6 +- include/clang/AST/StmtVisitor.h | 104 ++-- .../clang/Analysis/Visitors/CFGStmtVisitor.h | 4 +- include/clang/Frontend/StmtXML.def | 90 ++-- lib/AST/Expr.cpp | 324 ++++++------ lib/AST/ExprClassification.cpp | 18 +- lib/AST/ExprConstant.cpp | 232 ++++----- lib/AST/ParentMap.cpp | 2 +- lib/AST/Stmt.cpp | 2 +- lib/AST/StmtPrinter.cpp | 10 +- lib/AST/StmtProfile.cpp | 90 ++-- lib/Analysis/CFG.cpp | 14 +- lib/Analysis/LiveVariables.cpp | 10 +- lib/Analysis/PseudoConstantAnalysis.cpp | 30 +- lib/Analysis/ReachableCode.cpp | 2 +- lib/Analysis/UninitializedValues.cpp | 4 +- lib/Checker/AggExprVisitor.cpp | 4 +- lib/Checker/BasicValueFactory.cpp | 32 +- lib/Checker/BugReporter.cpp | 8 +- lib/Checker/BugReporterVisitors.cpp | 2 +- lib/Checker/CStringChecker.cpp | 14 +- lib/Checker/CheckDeadStores.cpp | 2 +- lib/Checker/CheckSecuritySyntaxOnly.cpp | 2 +- lib/Checker/DivZeroChecker.cpp | 8 +- lib/Checker/FixedAddressChecker.cpp | 2 +- lib/Checker/GRExprEngine.cpp | 132 ++--- lib/Checker/GRState.cpp | 6 +- lib/Checker/IdempotentOperationChecker.cpp | 142 ++--- lib/Checker/MallocChecker.cpp | 2 +- lib/Checker/PointerArithChecker.cpp | 3 +- lib/Checker/PointerSubChecker.cpp | 2 +- lib/Checker/RegionStore.cpp | 4 +- lib/Checker/SVals.cpp | 4 +- lib/Checker/SValuator.cpp | 4 +- lib/Checker/SimpleConstraintManager.cpp | 46 +- lib/Checker/SimpleSValuator.cpp | 222 ++++---- lib/Checker/SymbolManager.cpp | 32 +- lib/Checker/UnixAPIChecker.cpp | 2 +- lib/Checker/VLASizeChecker.cpp | 2 +- lib/CodeGen/CGBlocks.cpp | 4 +- lib/CodeGen/CGExpr.cpp | 92 ++-- lib/CodeGen/CGExprAgg.cpp | 25 +- lib/CodeGen/CGExprCXX.cpp | 6 +- lib/CodeGen/CGExprComplex.cpp | 4 +- lib/CodeGen/CGExprConstant.cpp | 8 +- lib/CodeGen/CGExprScalar.cpp | 132 ++--- lib/CodeGen/CGObjC.cpp | 6 +- lib/CodeGen/CodeGenFunction.cpp | 6 +- lib/CodeGen/ItaniumCXXABI.cpp | 8 +- lib/Rewrite/RewriteObjC.cpp | 80 +-- lib/Sema/Sema.cpp | 2 +- lib/Sema/SemaCXXCast.cpp | 98 ++-- lib/Sema/SemaChecking.cpp | 78 +-- lib/Sema/SemaDecl.cpp | 6 +- lib/Sema/SemaDeclCXX.cpp | 18 +- lib/Sema/SemaExpr.cpp | 486 +++++++++--------- lib/Sema/SemaExprCXX.cpp | 74 +-- lib/Sema/SemaExprObjC.cpp | 4 +- lib/Sema/SemaInit.cpp | 12 +- lib/Sema/SemaLookup.cpp | 2 +- lib/Sema/SemaObjCProperty.cpp | 2 +- lib/Sema/SemaOverload.cpp | 34 +- lib/Sema/SemaStmt.cpp | 4 +- lib/Sema/SemaTemplate.cpp | 17 +- lib/Sema/TreeTransform.h | 13 +- 66 files changed, 1440 insertions(+), 1604 deletions(-) diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 42db6bd07d..e96a33f503 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -1040,19 +1040,6 @@ public: class UnaryOperator : public Expr { public: typedef UnaryOperatorKind Opcode; - static const Opcode PostInc = UO_PostInc; - static const Opcode PostDec = UO_PostDec; - static const Opcode PreInc = UO_PreInc; - static const Opcode PreDec = UO_PreDec; - static const Opcode AddrOf = UO_AddrOf; - static const Opcode Deref = UO_Deref; - static const Opcode Plus = UO_Plus; - static const Opcode Minus = UO_Minus; - static const Opcode Not = UO_Not; - static const Opcode LNot = UO_LNot; - static const Opcode Real = UO_Real; - static const Opcode Imag = UO_Imag; - static const Opcode Extension = UO_Extension; private: unsigned Opc : 5; @@ -1068,7 +1055,7 @@ public: /// \brief Build an empty unary operator. explicit UnaryOperator(EmptyShell Empty) - : Expr(UnaryOperatorClass, Empty), Opc(AddrOf) { } + : Expr(UnaryOperatorClass, Empty), Opc(UO_AddrOf) { } Opcode getOpcode() const { return static_cast(Opc); } void setOpcode(Opcode O) { Opc = O; } @@ -1082,19 +1069,25 @@ public: /// isPostfix - Return true if this is a postfix operation, like x++. static bool isPostfix(Opcode Op) { - return Op == PostInc || Op == PostDec; + return Op == UO_PostInc || Op == UO_PostDec; } /// isPostfix - Return true if this is a prefix operation, like --x. static bool isPrefix(Opcode Op) { - return Op == PreInc || Op == PreDec; + return Op == UO_PreInc || Op == UO_PreDec; } bool isPrefix() const { return isPrefix(getOpcode()); } bool isPostfix() const { return isPostfix(getOpcode()); } - bool isIncrementOp() const { return Opc == PreInc || getOpcode() == PostInc; } - bool isIncrementDecrementOp() const { return Opc >= PostInc && Opc<=PreDec; } - static bool isArithmeticOp(Opcode Op) { return Op >= Plus && Op <= LNot; } + bool isIncrementOp() const { + return Opc == UO_PreInc || getOpcode() == UO_PostInc; + } + bool isIncrementDecrementOp() const { + return Opc >= UO_PostInc && Opc <= UO_PreDec; + } + static bool isArithmeticOp(Opcode Op) { + return Op >= UO_Plus && Op <= UO_LNot; + } bool isArithmeticOp() const { return isArithmeticOp(getOpcode()); } /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it @@ -1897,116 +1890,6 @@ class CastExpr : public Expr { public: typedef clang::CastKind CastKind; - /// CK_Unknown - Unknown cast kind. - /// FIXME: The goal is to get rid of this and make all casts have a - /// kind so that the AST client doesn't have to try to figure out what's - /// going on. - static const CastKind CK_Unknown = clang::CK_Unknown; - - /// CK_BitCast - Used for reinterpret_cast. - static const CastKind CK_BitCast = clang::CK_BitCast; - - /// CK_LValueBitCast - Used for reinterpret_cast of expressions to - /// a reference type. - static const CastKind CK_LValueBitCast = clang::CK_LValueBitCast; - - /// CK_NoOp - Used for const_cast. - static const CastKind CK_NoOp = clang::CK_NoOp; - - /// CK_BaseToDerived - Base to derived class casts. - static const CastKind CK_BaseToDerived = clang::CK_BaseToDerived; - - /// CK_DerivedToBase - Derived to base class casts. - static const CastKind CK_DerivedToBase = clang::CK_DerivedToBase; - - /// CK_UncheckedDerivedToBase - Derived to base class casts that - /// assume that the derived pointer is not null. - static const CastKind CK_UncheckedDerivedToBase - = clang::CK_UncheckedDerivedToBase; - - /// CK_Dynamic - Dynamic cast. - static const CastKind CK_Dynamic = clang::CK_Dynamic; - - /// CK_ToUnion - Cast to union (GCC extension). - static const CastKind CK_ToUnion = clang::CK_ToUnion; - - /// CK_ArrayToPointerDecay - Array to pointer decay. - static const CastKind CK_ArrayToPointerDecay - = clang::CK_ArrayToPointerDecay; - - // CK_FunctionToPointerDecay - Function to pointer decay. - static const CastKind CK_FunctionToPointerDecay - = clang::CK_FunctionToPointerDecay; - - /// CK_NullToMemberPointer - Null pointer to member pointer. - static const CastKind CK_NullToMemberPointer - = clang::CK_NullToMemberPointer; - - /// CK_BaseToDerivedMemberPointer - Member pointer in base class to - /// member pointer in derived class. - static const CastKind CK_BaseToDerivedMemberPointer - = clang::CK_BaseToDerivedMemberPointer; - - /// CK_DerivedToBaseMemberPointer - Member pointer in derived class to - /// member pointer in base class. - static const CastKind CK_DerivedToBaseMemberPointer - = clang::CK_DerivedToBaseMemberPointer; - - /// CK_UserDefinedConversion - Conversion using a user defined type - /// conversion function. - static const CastKind CK_UserDefinedConversion - = clang::CK_UserDefinedConversion; - - /// CK_ConstructorConversion - Conversion by constructor - static const CastKind CK_ConstructorConversion - = clang::CK_ConstructorConversion; - - /// CK_IntegralToPointer - Integral to pointer - static const CastKind CK_IntegralToPointer = clang::CK_IntegralToPointer; - - /// CK_PointerToIntegral - Pointer to integral - static const CastKind CK_PointerToIntegral = clang::CK_PointerToIntegral; - - /// CK_ToVoid - Cast to void. - static const CastKind CK_ToVoid = clang::CK_ToVoid; - - /// CK_VectorSplat - Casting from an integer/floating type to an extended - /// vector type with the same element type as the src type. Splats the - /// src expression into the destination expression. - static const CastKind CK_VectorSplat = clang::CK_VectorSplat; - - /// CK_IntegralCast - Casting between integral types of different size. - static const CastKind CK_IntegralCast = clang::CK_IntegralCast; - - /// CK_IntegralToFloating - Integral to floating point. - static const CastKind CK_IntegralToFloating = clang::CK_IntegralToFloating; - - /// CK_FloatingToIntegral - Floating point to integral. - static const CastKind CK_FloatingToIntegral = clang::CK_FloatingToIntegral; - - /// CK_FloatingCast - Casting between floating types of different size. - static const CastKind CK_FloatingCast = clang::CK_FloatingCast; - - /// CK_MemberPointerToBoolean - Member pointer to boolean - static const CastKind CK_MemberPointerToBoolean - = clang::CK_MemberPointerToBoolean; - - /// CK_AnyPointerToObjCPointerCast - Casting any pointer to objective-c - /// pointer - static const CastKind CK_AnyPointerToObjCPointerCast - = clang::CK_AnyPointerToObjCPointerCast; - - /// CK_AnyPointerToBlockPointerCast - Casting any pointer to block - /// pointer - static const CastKind CK_AnyPointerToBlockPointerCast - = clang::CK_AnyPointerToBlockPointerCast; - - /// \brief Converting between two Objective-C object types, which - /// can occur when performing reference binding to an Objective-C - /// object. - static const CastKind CK_ObjCObjectLValueCast - = clang::CK_ObjCObjectLValueCast; - private: unsigned Kind : 5; unsigned BasePathSize : BitsRemaining - 5; @@ -2289,39 +2172,6 @@ class BinaryOperator : public Expr { public: typedef BinaryOperatorKind Opcode; - static const Opcode PtrMemD = BO_PtrMemD; - static const Opcode PtrMemI = BO_PtrMemI; - static const Opcode Mul = BO_Mul; - static const Opcode Div = BO_Div; - static const Opcode Rem = BO_Rem; - static const Opcode Add = BO_Add; - static const Opcode Sub = BO_Sub; - static const Opcode Shl = BO_Shl; - static const Opcode Shr = BO_Shr; - static const Opcode LT = BO_LT; - static const Opcode GT = BO_GT; - static const Opcode LE = BO_LE; - static const Opcode GE = BO_GE; - static const Opcode EQ = BO_EQ; - static const Opcode NE = BO_NE; - static const Opcode And = BO_And; - static const Opcode Xor = BO_Xor; - static const Opcode Or = BO_Or; - static const Opcode LAnd = BO_LAnd; - static const Opcode LOr = BO_LOr; - static const Opcode Assign = BO_Assign; - static const Opcode MulAssign = BO_MulAssign; - static const Opcode DivAssign = BO_DivAssign; - static const Opcode RemAssign = BO_RemAssign; - static const Opcode AddAssign = BO_AddAssign; - static const Opcode SubAssign = BO_SubAssign; - static const Opcode ShlAssign = BO_ShlAssign; - static const Opcode ShrAssign = BO_ShrAssign; - static const Opcode AndAssign = BO_AndAssign; - static const Opcode XorAssign = BO_XorAssign; - static const Opcode OrAssign = BO_OrAssign; - static const Opcode Comma = BO_Comma; - private: unsigned Opc : 6; SourceLocation OpLoc; @@ -2344,7 +2194,7 @@ public: /// \brief Construct an empty binary operator. explicit BinaryOperator(EmptyShell Empty) - : Expr(BinaryOperatorClass, Empty), Opc(Comma) { } + : Expr(BinaryOperatorClass, Empty), Opc(BO_Comma) { } SourceLocation getOperatorLoc() const { return OpLoc; } void setOperatorLoc(SourceLocation L) { OpLoc = L; } @@ -2376,30 +2226,34 @@ public: static OverloadedOperatorKind getOverloadedOperator(Opcode Opc); /// predicates to categorize the respective opcodes. - bool isMultiplicativeOp() const { return Opc >= Mul && Opc <= Rem; } - static bool isAdditiveOp(Opcode Opc) { return Opc == Add || Opc == Sub; } + bool isMultiplicativeOp() const { return Opc >= BO_Mul && Opc <= BO_Rem; } + static bool isAdditiveOp(Opcode Opc) { return Opc == BO_Add || Opc==BO_Sub; } bool isAdditiveOp() const { return isAdditiveOp(getOpcode()); } - static bool isShiftOp(Opcode Opc) { return Opc == Shl || Opc == Shr; } + static bool isShiftOp(Opcode Opc) { return Opc == BO_Shl || Opc == BO_Shr; } bool isShiftOp() const { return isShiftOp(getOpcode()); } - static bool isBitwiseOp(Opcode Opc) { return Opc >= And && Opc <= Or; } + static bool isBitwiseOp(Opcode Opc) { return Opc >= BO_And && Opc <= BO_Or; } bool isBitwiseOp() const { return isBitwiseOp(getOpcode()); } - static bool isRelationalOp(Opcode Opc) { return Opc >= LT && Opc <= GE; } + static bool isRelationalOp(Opcode Opc) { return Opc >= BO_LT && Opc<=BO_GE; } bool isRelationalOp() const { return isRelationalOp(getOpcode()); } - static bool isEqualityOp(Opcode Opc) { return Opc == EQ || Opc == NE; } + static bool isEqualityOp(Opcode Opc) { return Opc == BO_EQ || Opc == BO_NE; } bool isEqualityOp() const { return isEqualityOp(getOpcode()); } - static bool isComparisonOp(Opcode Opc) { return Opc >= LT && Opc <= NE; } + static bool isComparisonOp(Opcode Opc) { return Opc >= BO_LT && Opc<=BO_NE; } bool isComparisonOp() const { return isComparisonOp(getOpcode()); } - static bool isLogicalOp(Opcode Opc) { return Opc == LAnd || Opc == LOr; } + static bool isLogicalOp(Opcode Opc) { return Opc == BO_LAnd || Opc==BO_LOr; } bool isLogicalOp() const { return isLogicalOp(getOpcode()); } - bool isAssignmentOp() const { return Opc >= Assign && Opc <= OrAssign; } - bool isCompoundAssignmentOp() const { return Opc > Assign && Opc <= OrAssign;} - bool isShiftAssignOp() const { return Opc == ShlAssign || Opc == ShrAssign; } + bool isAssignmentOp() const { return Opc >= BO_Assign && Opc <= BO_OrAssign; } + bool isCompoundAssignmentOp() const { + return Opc > BO_Assign && Opc <= BO_OrAssign; + } + bool isShiftAssignOp() const { + return Opc == BO_ShlAssign || Opc == BO_ShrAssign; + } static bool classof(const Stmt *S) { return S->getStmtClass() >= firstBinaryOperatorConstant && @@ -2423,7 +2277,7 @@ protected: } BinaryOperator(StmtClass SC, EmptyShell Empty) - : Expr(SC, Empty), Opc(MulAssign) { } + : Expr(SC, Empty), Opc(BO_MulAssign) { } }; /// CompoundAssignOperator - For compound assignments (e.g. +=), we keep diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index ee0bca518f..79ac072fa1 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -376,14 +376,14 @@ bool RecursiveASTVisitor::TraverseStmt(Stmt *S) { if (BinaryOperator *BinOp = dyn_cast(S)) { switch (BinOp->getOpcode()) { #define OPERATOR(NAME) \ - case BinaryOperator::NAME: DISPATCH(Bin##PtrMemD, BinaryOperator, S); + case BO_##NAME: DISPATCH(Bin##PtrMemD, BinaryOperator, S); BINOP_LIST() #undef OPERATOR #undef BINOP_LIST #define OPERATOR(NAME) \ - case BinaryOperator::NAME##Assign: \ + case BO_##NAME##Assign: \ DISPATCH(Bin##NAME##Assign, CompoundAssignOperator, S); CAO_LIST() @@ -393,7 +393,7 @@ bool RecursiveASTVisitor::TraverseStmt(Stmt *S) { } else if (UnaryOperator *UnOp = dyn_cast(S)) { switch (UnOp->getOpcode()) { #define OPERATOR(NAME) \ - case UnaryOperator::NAME: DISPATCH(Unary##NAME, UnaryOperator, S); + case UO_##NAME: DISPATCH(Unary##NAME, UnaryOperator, S); UNARYOP_LIST() #undef OPERATOR diff --git a/include/clang/AST/StmtVisitor.h b/include/clang/AST/StmtVisitor.h index 2c8d3e4654..b8c141d7ef 100644 --- a/include/clang/AST/StmtVisitor.h +++ b/include/clang/AST/StmtVisitor.h @@ -37,67 +37,57 @@ public: if (BinaryOperator *BinOp = dyn_cast(S)) { switch (BinOp->getOpcode()) { default: assert(0 && "Unknown binary operator!"); - case BinaryOperator::PtrMemD: DISPATCH(BinPtrMemD, BinaryOperator); - case BinaryOperator::PtrMemI: DISPATCH(BinPtrMemI, BinaryOperator); - case BinaryOperator::Mul: DISPATCH(BinMul, BinaryOperator); - case BinaryOperator::Div: DISPATCH(BinDiv, BinaryOperator); - case BinaryOperator::Rem: DISPATCH(BinRem, BinaryOperator); - case BinaryOperator::Add: DISPATCH(BinAdd, BinaryOperator); - case BinaryOperator::Sub: DISPATCH(BinSub, BinaryOperator); - case BinaryOperator::Shl: DISPATCH(BinShl, BinaryOperator); - case BinaryOperator::Shr: DISPATCH(BinShr, BinaryOperator); - - case BinaryOperator::LT: DISPATCH(BinLT, BinaryOperator); - case BinaryOperator::GT: DISPATCH(BinGT, BinaryOperator); - case BinaryOperator::LE: DISPATCH(BinLE, BinaryOperator); - case BinaryOperator::GE: DISPATCH(BinGE, BinaryOperator); - case BinaryOperator::EQ: DISPATCH(BinEQ, BinaryOperator); - case BinaryOperator::NE: DISPATCH(BinNE, BinaryOperator); - - case BinaryOperator::And: DISPATCH(BinAnd, BinaryOperator); - case BinaryOperator::Xor: DISPATCH(BinXor, BinaryOperator); - case BinaryOperator::Or : DISPATCH(BinOr, BinaryOperator); - case BinaryOperator::LAnd: DISPATCH(BinLAnd, BinaryOperator); - case BinaryOperator::LOr : DISPATCH(BinLOr, BinaryOperator); - case BinaryOperator::Assign: DISPATCH(BinAssign, BinaryOperator); - case BinaryOperator::MulAssign: - DISPATCH(BinMulAssign, CompoundAssignOperator); - case BinaryOperator::DivAssign: - DISPATCH(BinDivAssign, CompoundAssignOperator); - case BinaryOperator::RemAssign: - DISPATCH(BinRemAssign, CompoundAssignOperator); - case BinaryOperator::AddAssign: - DISPATCH(BinAddAssign, CompoundAssignOperator); - case BinaryOperator::SubAssign: - DISPATCH(BinSubAssign, CompoundAssignOperator); - case BinaryOperator::ShlAssign: - DISPATCH(BinShlAssign, CompoundAssignOperator); - case BinaryOperator::ShrAssign: - DISPATCH(BinShrAssign, CompoundAssignOperator); - case BinaryOperator::AndAssign: - DISPATCH(BinAndAssign, CompoundAssignOperator); - case BinaryOperator::OrAssign: - DISPATCH(BinOrAssign, CompoundAssignOperator); - case BinaryOperator::XorAssign: - DISPATCH(BinXorAssign, CompoundAssignOperator); - case BinaryOperator::Comma: DISPATCH(BinComma, BinaryOperator); + case BO_PtrMemD: DISPATCH(BinPtrMemD, BinaryOperator); + case BO_PtrMemI: DISPATCH(BinPtrMemI, BinaryOperator); + case BO_Mul: DISPATCH(BinMul, BinaryOperator); + case BO_Div: DISPATCH(BinDiv, BinaryOperator); + case BO_Rem: DISPATCH(BinRem, BinaryOperator); + case BO_Add: DISPATCH(BinAdd, BinaryOperator); + case BO_Sub: DISPATCH(BinSub, BinaryOperator); + case BO_Shl: DISPATCH(BinShl, BinaryOperator); + case BO_Shr: DISPATCH(BinShr, BinaryOperator); + + case BO_LT: DISPATCH(BinLT, BinaryOperator); + case BO_GT: DISPATCH(BinGT, BinaryOperator); + case BO_LE: DISPATCH(BinLE, BinaryOperator); + case BO_GE: DISPATCH(BinGE, BinaryOperator); + case BO_EQ: DISPATCH(BinEQ, BinaryOperator); + case BO_NE: DISPATCH(BinNE, BinaryOperator); + + case BO_And: DISPATCH(BinAnd, BinaryOperator); + case BO_Xor: DISPATCH(BinXor, BinaryOperator); + case BO_Or : DISPATCH(BinOr, BinaryOperator); + case BO_LAnd: DISPATCH(BinLAnd, BinaryOperator); + case BO_LOr : DISPATCH(BinLOr, BinaryOperator); + case BO_Assign: DISPATCH(BinAssign, BinaryOperator); + case BO_MulAssign: DISPATCH(BinMulAssign, CompoundAssignOperator); + case BO_DivAssign: DISPATCH(BinDivAssign, CompoundAssignOperator); + case BO_RemAssign: DISPATCH(BinRemAssign, CompoundAssignOperator); + case BO_AddAssign: DISPATCH(BinAddAssign, CompoundAssignOperator); + case BO_SubAssign: DISPATCH(BinSubAssign, CompoundAssignOperator); + case BO_ShlAssign: DISPATCH(BinShlAssign, CompoundAssignOperator); + case BO_ShrAssign: DISPATCH(BinShrAssign, CompoundAssignOperator); + case BO_AndAssign: DISPATCH(BinAndAssign, CompoundAssignOperator); + case BO_OrAssign: DISPATCH(BinOrAssign, CompoundAssignOperator); + case BO_XorAssign: DISPATCH(BinXorAssign, CompoundAssignOperator); + case BO_Comma: DISPATCH(BinComma, BinaryOperator); } } else if (UnaryOperator *UnOp = dyn_cast(S)) { switch (UnOp->getOpcode()) { default: assert(0 && "Unknown unary operator!"); - case UnaryOperator::PostInc: DISPATCH(UnaryPostInc, UnaryOperator); - case UnaryOperator::PostDec: DISPATCH(UnaryPostDec, UnaryOperator); - case UnaryOperator::PreInc: DISPATCH(UnaryPreInc, UnaryOperator); - case UnaryOperator::PreDec: DISPATCH(UnaryPreDec, UnaryOperator); - case UnaryOperator::AddrOf: DISPATCH(UnaryAddrOf, UnaryOperator); - case UnaryOperator::Deref: DISPATCH(UnaryDeref, UnaryOperator); - case UnaryOperator::Plus: DISPATCH(UnaryPlus, UnaryOperator); - case UnaryOperator::Minus: DISPATCH(UnaryMinus, UnaryOperator); - case UnaryOperator::Not: DISPATCH(UnaryNot, UnaryOperator); - case UnaryOperator::LNot: DISPATCH(UnaryLNot, UnaryOperator); - case UnaryOperator::Real: DISPATCH(UnaryReal, UnaryOperator); - case UnaryOperator::Imag: DISPATCH(UnaryImag, UnaryOperator); - case UnaryOperator::Extension: DISPATCH(UnaryExtension, UnaryOperator); + case UO_PostInc: DISPATCH(UnaryPostInc, UnaryOperator); + case UO_PostDec: DISPATCH(UnaryPostDec, UnaryOperator); + case UO_PreInc: DISPATCH(UnaryPreInc, UnaryOperator); + case UO_PreDec: DISPATCH(UnaryPreDec, UnaryOperator); + case UO_AddrOf: DISPATCH(UnaryAddrOf, UnaryOperator); + case UO_Deref: DISPATCH(UnaryDeref, UnaryOperator); + case UO_Plus: DISPATCH(UnaryPlus, UnaryOperator); + case UO_Minus: DISPATCH(UnaryMinus, UnaryOperator); + case UO_Not: DISPATCH(UnaryNot, UnaryOperator); + case UO_LNot: DISPATCH(UnaryLNot, UnaryOperator); + case UO_Real: DISPATCH(UnaryReal, UnaryOperator); + case UO_Imag: DISPATCH(UnaryImag, UnaryOperator); + case UO_Extension: DISPATCH(UnaryExtension, UnaryOperator); } } diff --git a/include/clang/Analysis/Visitors/CFGStmtVisitor.h b/include/clang/Analysis/Visitors/CFGStmtVisitor.h index 8a85ec15cd..6421f185ff 100644 --- a/include/clang/Analysis/Visitors/CFGStmtVisitor.h +++ b/include/clang/Analysis/Visitors/CFGStmtVisitor.h @@ -86,7 +86,7 @@ public: BinaryOperator* B = cast(S); if (B->isLogicalOp()) return static_cast(this)->BlockStmt_VisitLogicalOp(B); - else if (B->getOpcode() == BinaryOperator::Comma) + else if (B->getOpcode() == BO_Comma) return static_cast(this)->BlockStmt_VisitComma(B); // Fall through. } @@ -149,7 +149,7 @@ public: case Stmt::BinaryOperatorClass: { BinaryOperator* B = cast(S); - if (B->getOpcode() != BinaryOperator::Comma) break; + if (B->getOpcode() != BO_Comma) break; static_cast(this)->Visit(B->getRHS()); return; } diff --git a/include/clang/Frontend/StmtXML.def b/include/clang/Frontend/StmtXML.def index 3ee460d1b9..c03a5a8835 100644 --- a/include/clang/Frontend/StmtXML.def +++ b/include/clang/Frontend/StmtXML.def @@ -241,19 +241,19 @@ NODE_XML(UnaryOperator, "UnaryOperator") // op(expr) or (expr)op ATTRIBUTE_FILE_LOCATION_XML TYPE_ATTRIBUTE_XML(getType()) ATTRIBUTE_ENUM_XML(getOpcode(), "kind") - ENUM_XML(UnaryOperator::PostInc, "postinc") - ENUM_XML(UnaryOperator::PostDec, "postdec") - ENUM_XML(UnaryOperator::PreInc, "preinc") - ENUM_XML(UnaryOperator::PreDec, "predec") - ENUM_XML(UnaryOperator::AddrOf, "addrof") - ENUM_XML(UnaryOperator::Deref, "deref") - ENUM_XML(UnaryOperator::Plus, "plus") - ENUM_XML(UnaryOperator::Minus, "minus") - ENUM_XML(UnaryOperator::Not, "not") // bitwise not - ENUM_XML(UnaryOperator::LNot, "lnot") // boolean not - ENUM_XML(UnaryOperator::Real, "__real") - ENUM_XML(UnaryOperator::Imag, "__imag") - ENUM_XML(UnaryOperator::Extension, "__extension__") + ENUM_XML(UO_PostInc, "postinc") + ENUM_XML(UO_PostDec, "postdec") + ENUM_XML(UO_PreInc, "preinc") + ENUM_XML(UO_PreDec, "predec") + ENUM_XML(UO_AddrOf, "addrof") + ENUM_XML(UO_Deref, "deref") + ENUM_XML(UO_Plus, "plus") + ENUM_XML(UO_Minus, "minus") + ENUM_XML(UO_Not, "not") // bitwise not + ENUM_XML(UO_LNot, "lnot") // boolean not + ENUM_XML(UO_Real, "__real") + ENUM_XML(UO_Imag, "__imag") + ENUM_XML(UO_Extension, "__extension__") END_ENUM_XML SUB_NODE_XML(Expr) // expr END_NODE_XML @@ -262,38 +262,38 @@ NODE_XML(BinaryOperator, "BinaryOperator") // (expr1) op (expr2) ATTRIBUTE_FILE_LOCATION_XML TYPE_ATTRIBUTE_XML(getType()) ATTRIBUTE_ENUM_XML(getOpcode(), "kind") - ENUM_XML(BinaryOperator::PtrMemD , "ptrmemd") - ENUM_XML(BinaryOperator::PtrMemI , "ptrmemi") - ENUM_XML(BinaryOperator::Mul , "mul") - ENUM_XML(BinaryOperator::Div , "div") - ENUM_XML(BinaryOperator::Rem , "rem") - ENUM_XML(BinaryOperator::Add , "add") - ENUM_XML(BinaryOperator::Sub , "sub") - ENUM_XML(BinaryOperator::Shl , "shl") - ENUM_XML(BinaryOperator::Shr , "shr") - ENUM_XML(BinaryOperator::LT , "lt") - ENUM_XML(BinaryOperator::GT , "gt") - ENUM_XML(BinaryOperator::LE , "le") - ENUM_XML(BinaryOperator::GE , "ge") - ENUM_XML(BinaryOperator::EQ , "eq") - ENUM_XML(BinaryOperator::NE , "ne") - ENUM_XML(BinaryOperator::And , "and") // bitwise and - ENUM_XML(BinaryOperator::Xor , "xor") - ENUM_XML(BinaryOperator::Or , "or") // bitwise or - ENUM_XML(BinaryOperator::LAnd , "land") // boolean and - ENUM_XML(BinaryOperator::LOr , "lor") // boolean or - ENUM_XML(BinaryOperator::Assign , "assign") - ENUM_XML(BinaryOperator::MulAssign, "mulassign") - ENUM_XML(BinaryOperator::DivAssign, "divassign") - ENUM_XML(BinaryOperator::RemAssign, "remassign") - ENUM_XML(BinaryOperator::AddAssign, "addassign") - ENUM_XML(BinaryOperator::SubAssign, "subassign") - ENUM_XML(BinaryOperator::ShlAssign, "shlassign") - ENUM_XML(BinaryOperator::ShrAssign, "shrassign") - ENUM_XML(BinaryOperator::AndAssign, "andassign") - ENUM_XML(BinaryOperator::XorAssign, "xorassign") - ENUM_XML(BinaryOperator::OrAssign , "orassign") - ENUM_XML(BinaryOperator::Comma , "comma") + ENUM_XML(BO_PtrMemD , "ptrmemd") + ENUM_XML(BO_PtrMemI , "ptrmemi") + ENUM_XML(BO_Mul , "mul") + ENUM_XML(BO_Div , "div") + ENUM_XML(BO_Rem , "rem") + ENUM_XML(BO_Add , "add") + ENUM_XML(BO_Sub , "sub") + ENUM_XML(BO_Shl , "shl") + ENUM_XML(BO_Shr , "shr") + ENUM_XML(BO_LT , "lt") + ENUM_XML(BO_GT , "gt") + ENUM_XML(BO_LE , "le") + ENUM_XML(BO_GE , "ge") + ENUM_XML(BO_EQ , "eq") + ENUM_XML(BO_NE , "ne") + ENUM_XML(BO_And , "and") // bitwise and + ENUM_XML(BO_Xor , "xor") + ENUM_XML(BO_Or , "or") // bitwise or + ENUM_XML(BO_LAnd , "land") // boolean and + ENUM_XML(BO_LOr , "lor") // boolean or + ENUM_XML(BO_Assign , "assign") + ENUM_XML(BO_MulAssign, "mulassign") + ENUM_XML(BO_DivAssign, "divassign") + ENUM_XML(BO_RemAssign, "remassign") + ENUM_XML(BO_AddAssign, "addassign") + ENUM_XML(BO_SubAssign, "subassign") + ENUM_XML(BO_ShlAssign, "shlassign") + ENUM_XML(BO_ShrAssign, "shrassign") + ENUM_XML(BO_AndAssign, "andassign") + ENUM_XML(BO_XorAssign, "xorassign") + ENUM_XML(BO_OrAssign , "orassign") + ENUM_XML(BO_Comma , "comma") END_ENUM_XML SUB_NODE_XML(Expr) // expr1 SUB_NODE_XML(Expr) // expr2 diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 5efc6675f7..d5cf4d67fc 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -44,8 +44,8 @@ bool Expr::isKnownToHaveBooleanValue() const { if (const UnaryOperator *UO = dyn_cast(this)) { switch (UO->getOpcode()) { - case UnaryOperator::Plus: - case UnaryOperator::Extension: + case UO_Plus: + case UO_Extension: return UO->getSubExpr()->isKnownToHaveBooleanValue(); default: return false; @@ -60,25 +60,25 @@ bool Expr::isKnownToHaveBooleanValue() const { if (const BinaryOperator *BO = dyn_cast(this)) { switch (BO->getOpcode()) { default: return false; - case BinaryOperator::LT: // Relational operators. - case BinaryOperator::GT: - case BinaryOperator::LE: - case BinaryOperator::GE: - case BinaryOperator::EQ: // Equality operators. - case BinaryOperator::NE: - case BinaryOperator::LAnd: // AND operator. - case BinaryOperator::LOr: // Logical OR operator. + case BO_LT: // Relational operators. + case BO_GT: + case BO_LE: + case BO_GE: + case BO_EQ: // Equality operators. + case BO_NE: + case BO_LAnd: // AND operator. + case BO_LOr: // Logical OR operator. return true; - case BinaryOperator::And: // Bitwise AND operator. - case BinaryOperator::Xor: // Bitwise XOR operator. - case BinaryOperator::Or: // Bitwise OR operator. + case BO_And: // Bitwise AND operator. + case BO_Xor: // Bitwise XOR operator. + case BO_Or: // Bitwise OR operator. // Handle things like (x==2)|(y==12). return BO->getLHS()->isKnownToHaveBooleanValue() && BO->getRHS()->isKnownToHaveBooleanValue(); - case BinaryOperator::Comma: - case BinaryOperator::Assign: + case BO_Comma: + case BO_Assign: return BO->getRHS()->isKnownToHaveBooleanValue(); } } @@ -434,47 +434,47 @@ void StringLiteral::setString(ASTContext &C, llvm::StringRef Str) { const char *UnaryOperator::getOpcodeStr(Opcode Op) { switch (Op) { default: assert(0 && "Unknown unary operator"); - case PostInc: return "++"; - case PostDec: return "--"; - case PreInc: return "++"; - case PreDec: return "--"; - case AddrOf: return "&"; - case Deref: return "*"; - case Plus: return "+"; - case Minus: return "-"; - case Not: return "~"; - case LNot: return "!"; - case Real: return "__real"; - case Imag: return "__imag"; - case Extension: return "__extension__"; + case UO_PostInc: return "++"; + case UO_PostDec: return "--"; + case UO_PreInc: return "++"; + case UO_PreDec: return "--"; + case UO_AddrOf: return "&"; + case UO_Deref: return "*"; + case UO_Plus: return "+"; + case UO_Minus: return "-"; + case UO_Not: return "~"; + case UO_LNot: return "!"; + case UO_Real: return "__real"; + case UO_Imag: return "__imag"; + case UO_Extension: return "__extension__"; } } -UnaryOperator::Opcode +UnaryOperatorKind UnaryOperator::getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix) { switch (OO) { default: assert(false && "No unary operator for overloaded function"); - case OO_PlusPlus: return Postfix ? PostInc : PreInc; - case OO_MinusMinus: return Postfix ? PostDec : PreDec; - case OO_Amp: return AddrOf; - case OO_Star: return Deref; - case OO_Plus: return Plus; - case OO_Minus: return Minus; - case OO_Tilde: return Not; - case OO_Exclaim: return LNot; + case OO_PlusPlus: return Postfix ? UO_PostInc : UO_PreInc; + case OO_MinusMinus: return Postfix ? UO_PostDec : UO_PreDec; + case OO_Amp: return UO_AddrOf; + case OO_Star: return UO_Deref; + case OO_Plus: return UO_Plus; + case OO_Minus: return UO_Minus; + case OO_Tilde: return UO_Not; + case OO_Exclaim: return UO_LNot; } } OverloadedOperatorKind UnaryOperator::getOverloadedOperator(Opcode Opc) { switch (Opc) { - case PostInc: case PreInc: return OO_PlusPlus; - case PostDec: case PreDec: return OO_MinusMinus; - case AddrOf: return OO_Amp; - case Deref: return OO_Star; - case Plus: return OO_Plus; - case Minus: return OO_Minus; - case Not: return OO_Tilde; - case LNot: return OO_Exclaim; + case UO_PostInc: case UO_PreInc: return OO_PlusPlus; + case UO_PostDec: case UO_PreDec: return OO_MinusMinus; + case UO_AddrOf: return OO_Amp; + case UO_Deref: return OO_Star; + case UO_Plus: return OO_Plus; + case UO_Minus: return OO_Minus; + case UO_Not: return OO_Tilde; + case UO_LNot: return OO_Exclaim; default: return OO_None; } } @@ -694,61 +694,61 @@ MemberExpr *MemberExpr::Create(ASTContext &C, Expr *base, bool isarrow, const char *CastExpr::getCastKindName() const { switch (getCastKind()) { - case CastExpr::CK_Unknown: + case CK_Unknown: return "Unknown"; - case CastExpr::CK_BitCast: + case CK_BitCast: return "BitCast"; - case CastExpr::CK_LValueBitCast: + case CK_LValueBitCast: return "LValueBitCast"; - case CastExpr::CK_NoOp: + case CK_NoOp: return "NoOp"; - case CastExpr::CK_BaseToDerived: + case CK_BaseToDerived: return "BaseToDerived"; - case CastExpr::CK_DerivedToBase: + case CK_DerivedToBase: return "DerivedToBase"; - case CastExpr::CK_UncheckedDerivedToBase: + case CK_UncheckedDerivedToBase: return "UncheckedDerivedToBase"; - case CastExpr::CK_Dynamic: + case CK_Dynamic: return "Dynamic"; - case CastExpr::CK_ToUnion: + case CK_ToUnion: return "ToUnion"; - case CastExpr::CK_ArrayToPointerDecay: + case CK_ArrayToPointerDecay: return "ArrayToPointerDecay"; - case CastExpr::CK_FunctionToPointerDecay: + case CK_FunctionToPointerDecay: return "FunctionToPointerDecay"; - case CastExpr::CK_NullToMemberPointer: + case CK_NullToMemberPointer: return "NullToMemberPointer"; - case CastExpr::CK_BaseToDerivedMemberPointer: + case CK_BaseToDerivedMemberPointer: return "BaseToDerivedMemberPointer"; - case CastExpr::CK_DerivedToBaseMemberPointer: + case CK_DerivedToBaseMemberPointer: return "DerivedToBaseMemberPointer"; - case CastExpr::CK_UserDefinedConversion: + case CK_UserDefinedConversion: return "UserDefinedConversion"; - case CastExpr::CK_ConstructorConversion: + case CK_ConstructorConversion: return "ConstructorConversion"; - case CastExpr::CK_IntegralToPointer: + case CK_IntegralToPointer: return "IntegralToPointer"; - case CastExpr::CK_PointerToIntegral: + case CK_PointerToIntegral: return "PointerToIntegral"; - case CastExpr::CK_ToVoid: + case CK_ToVoid: return "ToVoid"; - case CastExpr::CK_VectorSplat: + case CK_VectorSplat: return "VectorSplat"; - case CastExpr::CK_IntegralCast: + case CK_IntegralCast: return "IntegralCast"; - case CastExpr::CK_IntegralToFloating: + case CK_IntegralToFloating: return "IntegralToFloating"; - case CastExpr::CK_FloatingToIntegral: + case CK_FloatingToIntegral: return "FloatingToIntegral"; - case CastExpr::CK_FloatingCast: + case CK_FloatingCast: return "FloatingCast"; - case CastExpr::CK_MemberPointerToBoolean: + case CK_MemberPointerToBoolean: return "MemberPointerToBoolean"; - case CastExpr::CK_AnyPointerToObjCPointerCast: + case CK_AnyPointerToObjCPointerCast: return "AnyPointerToObjCPointerCast"; - case CastExpr::CK_AnyPointerToBlockPointerCast: + case CK_AnyPointerToBlockPointerCast: return "AnyPointerToBlockPointerCast"; - case CastExpr::CK_ObjCObjectLValueCast: + case CK_ObjCObjectLValueCast: return "ObjCObjectLValueCast"; } @@ -768,9 +768,9 @@ Expr *CastExpr::getSubExprAsWritten() { // Conversions by constructor and conversion functions have a // subexpression describing the call; strip it off. - if (E->getCastKind() == CastExpr::CK_ConstructorConversion) + if (E->getCastKind() == CK_ConstructorConversion) SubExpr = cast(SubExpr)->getArg(0); - else if (E->getCastKind() == CastExpr::CK_UserDefinedConversion) + else if (E->getCastKind() == CK_UserDefinedConversion) SubExpr = cast(SubExpr)->getImplicitObjectArgument(); // If the subexpression we're left with is an implicit cast, look @@ -844,78 +844,78 @@ CStyleCastExpr *CStyleCastExpr::CreateEmpty(ASTContext &C, unsigned PathSize) { /// corresponds to, e.g. "<<=". const char *BinaryOperator::getOpcodeStr(Opcode Op) { switch (Op) { - case PtrMemD: return ".*"; - case PtrMemI: return "->*"; - case Mul: return "*"; - case Div: return "/"; - case Rem: return "%"; - case Add: return "+"; - case Sub: return "-"; - case Shl: return "<<"; - case Shr: return ">>"; - case LT: return "<"; - case GT: return ">"; - case LE: return "<="; - case GE: return ">="; - case EQ: return "=="; - case NE: return "!="; - case And: return "&"; - case Xor: return "^"; - case Or: return "|"; - case LAnd: return "&&"; - case LOr: return "||"; - case Assign: return "="; - case MulAssign: return "*="; - case DivAssign: return "/="; - case RemAssign: return "%="; - case AddAssign: return "+="; - case SubAssign: return "-="; - case ShlAssign: return "<<="; - case ShrAssign: return ">>="; - case AndAssign: return "&="; - case XorAssign: return "^="; - case OrAssign: return "|="; - case Comma: return ","; + case BO_PtrMemD: return ".*"; + case BO_PtrMemI: return "->*"; + case BO_Mul: return "*"; + case BO_Div: return "/"; + case BO_Rem: return "%"; + case BO_Add: return "+"; + case BO_Sub: return "-"; + case BO_Shl: return "<<"; + case BO_Shr: return ">>"; + case BO_LT: return "<"; + case BO_GT: return ">"; + case BO_LE: return "<="; + case BO_GE: return ">="; + case BO_EQ: return "=="; + case BO_NE: return "!="; + case BO_And: return "&"; + case BO_Xor: return "^"; + case BO_Or: return "|"; + case BO_LAnd: return "&&"; + case BO_LOr: return "||"; + case BO_Assign: return "="; + case BO_MulAssign: return "*="; + case BO_DivAssign: return "/="; + case BO_RemAssign: return "%="; + case BO_AddAssign: return "+="; + case BO_SubAssign: return "-="; + case BO_ShlAssign: return "<<="; + case BO_ShrAssign: return ">>="; + case BO_AndAssign: return "&="; + case BO_XorAssign: return "^="; + case BO_OrAssign: return "|="; + case BO_Comma: return ","; } return ""; } -BinaryOperator::Opcode +BinaryOperatorKind BinaryOperator::getOverloadedOpcode(OverloadedOperatorKind OO) { switch (OO) { default: assert(false && "Not an overloadable binary operator"); - case OO_Plus: return Add; - case OO_Minus: return Sub; - case OO_Star: return Mul; - case OO_Slash: return Div; - case OO_Percent: return Rem; - case OO_Caret: return Xor; - case OO_Amp: return And; - case OO_Pipe: return Or; - case OO_Equal: return Assign; - case OO_Less: return LT; - case OO_Greater: return GT; - case OO_PlusEqual: return AddAssign; - case OO_MinusEqual: return SubAssign; - case OO_StarEqual: return MulAssign; - case OO_SlashEqual: return DivAssign; - case OO_PercentEqual: return RemAssign; - case OO_CaretEqual: return XorAssign; - case OO_AmpEqual: return AndAssign; - case OO_PipeEqual: return OrAssign; - case OO_LessLess: return Shl; - case OO_GreaterGreater: return Shr; - case OO_LessLessEqual: return ShlAssign; - case OO_GreaterGreaterEqual: return ShrAssign; - case OO_EqualEqual: return EQ; - case OO_ExclaimEqual: return NE; - case OO_LessEqual: return LE; - case OO_GreaterEqual: return GE; - case OO_AmpAmp: return LAnd; - case OO_PipePipe: return LOr; - case OO_Comma: return Comma; - case OO_ArrowStar: return PtrMemI; + case OO_Plus: return BO_Add; + case OO_Minus: return BO_Sub; + case OO_Star: return BO_Mul; + case OO_Slash: return BO_Div; + case OO_Percent: return BO_Rem; + case OO_Caret: return BO_Xor; + case OO_Amp: return BO_And; + case OO_Pipe: return BO_Or; + case OO_Equal: return BO_Assign; + case OO_Less: return BO_LT; + case OO_Greater: return BO_GT; + case OO_PlusEqual: return BO_AddAssign; + case OO_MinusEqual: return BO_SubAssign; + case OO_StarEqual: return BO_MulAssign; + case OO_SlashEqual: return BO_DivAssign; + case OO_PercentEqual: return BO_RemAssign; + case OO_CaretEqual: return BO_XorAssign; + case OO_AmpEqual: return BO_AndAssign; + case OO_PipeEqual: return BO_OrAssign; + case OO_LessLess: return BO_Shl; + case OO_GreaterGreater: return BO_Shr; + case OO_LessLessEqual: return BO_ShlAssign; + case OO_GreaterGreaterEqual: return BO_ShrAssign; + case OO_EqualEqual: return BO_EQ; + case OO_ExclaimEqual: return BO_NE; + case OO_LessEqual: return BO_LE; + case OO_GreaterEqual: return BO_GE; + case OO_AmpAmp: return BO_LAnd; + case OO_PipePipe: return BO_LOr; + case OO_Comma: return BO_Comma; + case OO_ArrowStar: return BO_PtrMemI; } } @@ -1030,24 +1030,24 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1, switch (UO->getOpcode()) { default: break; - case UnaryOperator::PostInc: - case UnaryOperator::PostDec: - case UnaryOperator::PreInc: - case UnaryOperator::PreDec: // ++/-- + case UO_PostInc: + case UO_PostDec: + case UO_PreInc: + case UO_PreDec: // ++/-- return false; // Not a warning. - case UnaryOperator::Deref: + case UO_Deref: // Dereferencing a volatile pointer is a side-effect. if (Ctx.getCanonicalType(getType()).isVolatileQualified()) return false; break; - case UnaryOperator::Real: - case UnaryOperator::Imag: + case UO_Real: + case UO_Imag: // accessing a piece of a volatile complex is a side-effect. if (Ctx.getCanonicalType(UO->getSubExpr()->getType()) .isVolatileQualified()) return false; break; - case UnaryOperator::Extension: + case UO_Extension: return UO->getSubExpr()->isUnusedResultAWarning(Loc, R1, R2, Ctx); } Loc = UO->getOperatorLoc(); @@ -1061,7 +1061,7 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1, break; // Consider the RHS of comma for side effects. LHS was checked by // Sema::CheckCommaOperands. - case BinaryOperator::Comma: + case BO_Comma: // ((foo = ), 0) is an idiom for hiding the result (and // lvalue-ness) of an assignment written in a macro. if (IntegerLiteral *IE = @@ -1070,8 +1070,8 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1, return false; return BO->getRHS()->isUnusedResultAWarning(Loc, R1, R2, Ctx); // Consider '||', '&&' to have side effects if the LHS or RHS does. - case BinaryOperator::LAnd: - case BinaryOperator::LOr: + case BO_LAnd: + case BO_LOr: if (!BO->getLHS()->isUnusedResultAWarning(Loc, R1, R2, Ctx) || !BO->getRHS()->isUnusedResultAWarning(Loc, R1, R2, Ctx)) return false; @@ -1204,8 +1204,8 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1, // If this is a cast to void or a constructor conversion, check the operand. // Otherwise, the result of the cast is unused. - if (CE->getCastKind() == CastExpr::CK_ToVoid || - CE->getCastKind() == CastExpr::CK_ConstructorConversion) + if (CE->getCastKind() == CK_ToVoid || + CE->getCastKind() == CK_ConstructorConversion) return (cast(this)->getSubExpr() ->isUnusedResultAWarning(Loc, R1, R2, Ctx)); Loc = cast(this)->getTypeBeginLoc(); @@ -1354,7 +1354,7 @@ bool Expr::isDefaultArgument() const { /// expressions. static const Expr *skipTemporaryBindingsAndNoOpCasts(const Expr *E) { while (const ImplicitCastExpr *ICE = dyn_cast(E)) { - if (ICE->getCastKind() == CastExpr::CK_NoOp) + if (ICE->getCastKind() == CK_NoOp) E = ICE->getSubExpr(); else break; @@ -1364,7 +1364,7 @@ static const Expr *skipTemporaryBindingsAndNoOpCasts(const Expr *E) { E = BE->getSubExpr(); while (const ImplicitCastExpr *ICE = dyn_cast(E)) { - if (ICE->getCastKind() == CastExpr::CK_NoOp) + if (ICE->getCastKind() == CK_NoOp) E = ICE->getSubExpr(); else break; @@ -1381,8 +1381,8 @@ const Expr *Expr::getTemporaryObject() const { if (const CastExpr *Cast = dyn_cast(E)) { // Only user-defined and constructor conversions can produce // temporary objects. - if (Cast->getCastKind() != CastExpr::CK_ConstructorConversion && - Cast->getCastKind() != CastExpr::CK_UserDefinedConversion) + if (Cast->getCastKind() != CK_ConstructorConversion && + Cast->getCastKind() != CK_UserDefinedConversion) return 0; // Strip off temporary bindings and no-op casts. @@ -1390,12 +1390,12 @@ const Expr *Expr::getTemporaryObject() const { // If this is a constructor conversion, see if we have an object // construction. - if (Cast->getCastKind() == CastExpr::CK_ConstructorConversion) + if (Cast->getCastKind() == CK_ConstructorConversion) return dyn_cast(Sub); // If this is a user-defined conversion, see if we have a call to // a function that itself returns a temporary object. - if (Cast->getCastKind() == CastExpr::CK_UserDefinedConversion) + if (Cast->getCastKind() == CK_UserDefinedConversion) if (const CallExpr *CE = dyn_cast(Sub)) if (CE->getCallReturnType()->isRecordType()) return CE; @@ -1497,7 +1497,7 @@ bool Expr::isConstantInitializer(ASTContext &Ctx, bool IsForRef) const { ->isConstantInitializer(Ctx, IsForRef); case UnaryOperatorClass: { const UnaryOperator* Exp = cast(this); - if (Exp->getOpcode() == UnaryOperator::Extension) + if (Exp->getOpcode() == UO_Extension) return Exp->getSubExpr()->isConstantInitializer(Ctx, false); break; } @@ -1505,7 +1505,7 @@ bool Expr::isConstantInitializer(ASTContext &Ctx, bool IsForRef) const { // Special case &&foo - &&bar. It would be nice to generalize this somehow // but this handles the common case. const BinaryOperator *Exp = cast(this); - if (Exp->getOpcode() == BinaryOperator::Sub && + if (Exp->getOpcode() == BO_Sub && isa(Exp->getLHS()->IgnoreParenNoopCasts(Ctx)) && isa(Exp->getRHS()->IgnoreParenNoopCasts(Ctx))) return true; @@ -1601,7 +1601,7 @@ FieldDecl *Expr::getBitField() { while (ImplicitCastExpr *ICE = dyn_cast(E)) { if (ICE->getValueKind() != VK_RValue && - ICE->getCastKind() == CastExpr::CK_NoOp) + ICE->getCastKind() == CK_NoOp) E = ICE->getSubExpr()->IgnoreParens(); else break; @@ -1624,7 +1624,7 @@ bool Expr::refersToVectorElement() const { while (const ImplicitCastExpr *ICE = dyn_cast(E)) { if (ICE->getValueKind() != VK_RValue && - ICE->getCastKind() == CastExpr::CK_NoOp) + ICE->getCastKind() == CK_NoOp) E = ICE->getSubExpr()->IgnoreParens(); else break; diff --git a/lib/AST/ExprClassification.cpp b/lib/AST/ExprClassification.cpp index 80e07c5f08..c54dcb60b9 100644 --- a/lib/AST/ExprClassification.cpp +++ b/lib/AST/ExprClassification.cpp @@ -111,20 +111,20 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { // C++ [expr.unary.op]p1: The unary * operator performs indirection: // [...] the result is an lvalue referring to the object or function // to which the expression points. - case UnaryOperator::Deref: + case UO_Deref: return Cl::CL_LValue; // GNU extensions, simply look through them. - case UnaryOperator::Real: - case UnaryOperator::Imag: - case UnaryOperator::Extension: + case UO_Real: + case UO_Imag: + case UO_Extension: return ClassifyInternal(Ctx, cast(E)->getSubExpr()); // C++ [expr.pre.incr]p1: The result is the updated operand; it is an // lvalue, [...] // Not so in C. - case UnaryOperator::PreInc: - case UnaryOperator::PreDec: + case UO_PreInc: + case UO_PreDec: return Lang.CPlusPlus ? Cl::CL_LValue : Cl::CL_PRValue; default: @@ -321,19 +321,19 @@ static Cl::Kinds ClassifyBinaryOp(ASTContext &Ctx, const BinaryOperator *E) { // C++ [expr.comma]p1: the result is of the same value category as its right // operand, [...]. - if (E->getOpcode() == BinaryOperator::Comma) + if (E->getOpcode() == BO_Comma) return ClassifyInternal(Ctx, E->getRHS()); // C++ [expr.mptr.oper]p6: The result of a .* expression whose second operand // is a pointer to a data member is of the same value category as its first // operand. - if (E->getOpcode() == BinaryOperator::PtrMemD) + if (E->getOpcode() == BO_PtrMemD) return E->getType()->isFunctionType() ? Cl::CL_MemberFunction : ClassifyInternal(Ctx, E->getLHS()); // C++ [expr.mptr.oper]p6: The result of an ->* expression is an lvalue if its // second operand is a pointer to data member and a prvalue otherwise. - if (E->getOpcode() == BinaryOperator::PtrMemI) + if (E->getOpcode() == BO_PtrMemI) return E->getType()->isFunctionType() ? Cl::CL_MemberFunction : Cl::CL_LValue; diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 2c8d617f6d..14cbbaf0e8 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -337,7 +337,7 @@ public: default: return false; - case CastExpr::CK_NoOp: + case CK_NoOp: return Visit(E->getSubExpr()); } } @@ -481,8 +481,8 @@ static bool EvaluatePointer(const Expr* E, LValue& Result, EvalInfo &Info) { } bool PointerExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { - if (E->getOpcode() != BinaryOperator::Add && - E->getOpcode() != BinaryOperator::Sub) + if (E->getOpcode() != BO_Add && + E->getOpcode() != BO_Sub) return false; const Expr *PExp = E->getLHS(); @@ -512,7 +512,7 @@ bool PointerExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { else SizeOfPointee = Info.Ctx.getTypeSizeInChars(PointeeType); - if (E->getOpcode() == BinaryOperator::Add) + if (E->getOpcode() == BO_Add) Result.Offset += AdditionalOffset * SizeOfPointee; else Result.Offset -= AdditionalOffset * SizeOfPointee; @@ -532,7 +532,7 @@ bool PointerExprEvaluator::VisitCastExpr(CastExpr* E) { default: break; - case CastExpr::CK_Unknown: { + case CK_Unknown: { // FIXME: The handling for CK_Unknown is ugly/shouldn't be necessary! // Check for pointer->pointer cast @@ -561,14 +561,14 @@ bool PointerExprEvaluator::VisitCastExpr(CastExpr* E) { break; } - case CastExpr::CK_NoOp: - case CastExpr::CK_BitCast: - case CastExpr::CK_LValueBitCast: - case CastExpr::CK_AnyPointerToObjCPointerCast: - case CastExpr::CK_AnyPointerToBlockPointerCast: + case CK_NoOp: + case CK_BitCast: + case CK_LValueBitCast: + case CK_AnyPointerToObjCPointerCast: + case CK_AnyPointerToBlockPointerCast: return Visit(SubExpr); - case CastExpr::CK_IntegralToPointer: { + case CK_IntegralToPointer: { APValue Value; if (!EvaluateIntegerOrLValue(SubExpr, Value, Info)) break; @@ -585,8 +585,8 @@ bool PointerExprEvaluator::VisitCastExpr(CastExpr* E) { return true; } } - case CastExpr::CK_ArrayToPointerDecay: - case CastExpr::CK_FunctionToPointerDecay: + case CK_ArrayToPointerDecay: + case CK_FunctionToPointerDecay: return EvaluateLValue(SubExpr, Result, Info); } @@ -1161,7 +1161,7 @@ bool IntExprEvaluator::VisitCallExpr(CallExpr *E) { } bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { - if (E->getOpcode() == BinaryOperator::Comma) { + if (E->getOpcode() == BO_Comma) { if (!Visit(E->getRHS())) return false; @@ -1181,11 +1181,11 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { if (HandleConversionToBool(E->getLHS(), lhsResult, Info)) { // We were able to evaluate the LHS, see if we can get away with not // evaluating the RHS: 0 && X -> 0, 1 || X -> 1 - if (lhsResult == (E->getOpcode() == BinaryOperator::LOr)) + if (lhsResult == (E->getOpcode() == BO_LOr)) return Success(lhsResult, E); if (HandleConversionToBool(E->getRHS(), rhsResult, Info)) { - if (E->getOpcode() == BinaryOperator::LOr) + if (E->getOpcode() == BO_LOr) return Success(lhsResult || rhsResult, E); else return Success(lhsResult && rhsResult, E); @@ -1194,8 +1194,8 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { if (HandleConversionToBool(E->getRHS(), rhsResult, Info)) { // We can't evaluate the LHS; however, sometimes the result // is determined by the RHS: X && 0 -> 0, X || 1 -> 1. - if (rhsResult == (E->getOpcode() == BinaryOperator::LOr) || - !rhsResult == (E->getOpcode() == BinaryOperator::LAnd)) { + if (rhsResult == (E->getOpcode() == BO_LOr) || + !rhsResult == (E->getOpcode() == BO_LAnd)) { // Since we weren't able to evaluate the left hand side, it // must have had side effects. Info.EvalResult.HasSideEffects = true; @@ -1227,11 +1227,11 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { APFloat::cmpResult CR_i = LHS.getComplexFloatImag().compare(RHS.getComplexFloatImag()); - if (E->getOpcode() == BinaryOperator::EQ) + if (E->getOpcode() == BO_EQ) return Success((CR_r == APFloat::cmpEqual && CR_i == APFloat::cmpEqual), E); else { - assert(E->getOpcode() == BinaryOperator::NE && + assert(E->getOpcode() == BO_NE && "Invalid complex comparison."); return Success(((CR_r == APFloat::cmpGreaterThan || CR_r == APFloat::cmpLessThan || @@ -1241,11 +1241,11 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { CR_i == APFloat::cmpUnordered)), E); } } else { - if (E->getOpcode() == BinaryOperator::EQ) + if (E->getOpcode() == BO_EQ) return Success((LHS.getComplexIntReal() == RHS.getComplexIntReal() && LHS.getComplexIntImag() == RHS.getComplexIntImag()), E); else { - assert(E->getOpcode() == BinaryOperator::NE && + assert(E->getOpcode() == BO_NE && "Invalid compex comparison."); return Success((LHS.getComplexIntReal() != RHS.getComplexIntReal() || LHS.getComplexIntImag() != RHS.getComplexIntImag()), E); @@ -1268,18 +1268,18 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { switch (E->getOpcode()) { default: assert(0 && "Invalid binary operator!"); - case BinaryOperator::LT: + case BO_LT: return Success(CR == APFloat::cmpLessThan, E); - case BinaryOperator::GT: + case BO_GT: return Success(CR == APFloat::cmpGreaterThan, E); - case BinaryOperator::LE: + case BO_LE: return Success(CR == APFloat::cmpLessThan || CR == APFloat::cmpEqual, E); - case BinaryOperator::GE: + case BO_GE: return Success(CR == APFloat::cmpGreaterThan || CR == APFloat::cmpEqual, E); - case BinaryOperator::EQ: + case BO_EQ: return Success(CR == APFloat::cmpEqual, E); - case BinaryOperator::NE: + case BO_NE: return Success(CR == APFloat::cmpGreaterThan || CR == APFloat::cmpLessThan || CR == APFloat::cmpUnordered, E); @@ -1287,7 +1287,7 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { } if (LHSTy->isPointerType() && RHSTy->isPointerType()) { - if (E->getOpcode() == BinaryOperator::Sub || E->isEqualityOp()) { + if (E->getOpcode() == BO_Sub || E->isEqualityOp()) { LValue LHSValue; if (!EvaluatePointer(E->getLHS(), LHSValue, Info)) return false; @@ -1306,7 +1306,7 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { bool bres; if (!EvalPointerValueAsBool(LHSValue, bres)) return false; - return Success(bres ^ (E->getOpcode() == BinaryOperator::EQ), E); + return Success(bres ^ (E->getOpcode() == BO_EQ), E); } else if (RHSValue.getLValueBase()) { if (!E->isEqualityOp()) return false; @@ -1315,10 +1315,10 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { bool bres; if (!EvalPointerValueAsBool(RHSValue, bres)) return false; - return Success(bres ^ (E->getOpcode() == BinaryOperator::EQ), E); + return Success(bres ^ (E->getOpcode() == BO_EQ), E); } - if (E->getOpcode() == BinaryOperator::Sub) { + if (E->getOpcode() == BO_Sub) { QualType Type = E->getLHS()->getType(); QualType ElementType = Type->getAs()->getPointeeType(); @@ -1331,7 +1331,7 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { return Success(Diff / ElementSize, E); } bool Result; - if (E->getOpcode() == BinaryOperator::EQ) { + if (E->getOpcode() == BO_EQ) { Result = LHSValue.getLValueOffset() == RHSValue.getLValueOffset(); } else { Result = LHSValue.getLValueOffset() != RHSValue.getLValueOffset(); @@ -1359,7 +1359,7 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { CharUnits Offset = Result.getLValueOffset(); CharUnits AdditionalOffset = CharUnits::fromQuantity( RHSVal.getInt().getZExtValue()); - if (E->getOpcode() == BinaryOperator::Add) + if (E->getOpcode() == BO_Add) Offset += AdditionalOffset; else Offset -= AdditionalOffset; @@ -1368,7 +1368,7 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { } // Handle cases like 4 + (unsigned long)&a - if (E->getOpcode() == BinaryOperator::Add && + if (E->getOpcode() == BO_Add && RHSVal.isLValue() && Result.isInt()) { CharUnits Offset = RHSVal.getLValueOffset(); Offset += CharUnits::fromQuantity(Result.getInt().getZExtValue()); @@ -1385,38 +1385,38 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { switch (E->getOpcode()) { default: return Error(E->getOperatorLoc(), diag::note_invalid_subexpr_in_ice, E); - case BinaryOperator::Mul: return Success(Result.getInt() * RHS, E); - case BinaryOperator::Add: return Success(Result.getInt() + RHS, E); - case BinaryOperator::Sub: return Success(Result.getInt() - RHS, E); - case BinaryOperator::And: return Success(Result.getInt() & RHS, E); - case BinaryOperator::Xor: return Success(Result.getInt() ^ RHS, E); - case BinaryOperator::Or: return Success(Result.getInt() | RHS, E); - case BinaryOperator::Div: + case BO_Mul: return Success(Result.getInt() * RHS, E); + case BO_Add: return Success(Result.getInt() + RHS, E); + case BO_Sub: return Success(Result.getInt() - RHS, E); + case BO_And: return Success(Result.getInt() & RHS, E); + case BO_Xor: return Success(Result.getInt() ^ RHS, E); + case BO_Or: return Success(Result.getInt() | RHS, E); + case BO_Div: if (RHS == 0) return Error(E->getOperatorLoc(), diag::note_expr_divide_by_zero, E); return Success(Result.getInt() / RHS, E); - case BinaryOperator::Rem: + case BO_Rem: if (RHS == 0) return Error(E->getOperatorLoc(), diag::note_expr_divide_by_zero, E); return Success(Result.getInt() % RHS, E); - case BinaryOperator::Shl: { + case BO_Shl: { // FIXME: Warn about out of range shift amounts! unsigned SA = (unsigned) RHS.getLimitedValue(Result.getInt().getBitWidth()-1); return Success(Result.getInt() << SA, E); } - case BinaryOperator::Shr: { + case BO_Shr: { unsigned SA = (unsigned) RHS.getLimitedValue(Result.getInt().getBitWidth()-1); return Success(Result.getInt() >> SA, E); } - case BinaryOperator::LT: return Success(Result.getInt() < RHS, E); - case BinaryOperator::GT: return Success(Result.getInt() > RHS, E); - case BinaryOperator::LE: return Success(Result.getInt() <= RHS, E); - case BinaryOperator::GE: return Success(Result.getInt() >= RHS, E); - case BinaryOperator::EQ: return Success(Result.getInt() == RHS, E); - case BinaryOperator::NE: return Success(Result.getInt() != RHS, E); + case BO_LT: return Success(Result.getInt() < RHS, E); + case BO_GT: return Success(Result.getInt() > RHS, E); + case BO_LE: return Success(Result.getInt() <= RHS, E); + case BO_GE: return Success(Result.getInt() >= RHS, E); + case BO_EQ: return Success(Result.getInt() == RHS, E); + case BO_NE: return Success(Result.getInt() != RHS, E); } } @@ -1573,7 +1573,7 @@ bool IntExprEvaluator::VisitOffsetOfExpr(const OffsetOfExpr *E) { } bool IntExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) { - if (E->getOpcode() == UnaryOperator::LNot) { + if (E->getOpcode() == UO_LNot) { // LNot's operand isn't necessarily an integer, so we handle it specially. bool bres; if (!HandleConversionToBool(E->getSubExpr(), bres, Info)) @@ -1594,17 +1594,17 @@ bool IntExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) { // Address, indirect, pre/post inc/dec, etc are not valid constant exprs. // See C99 6.6p3. return Error(E->getOperatorLoc(), diag::note_invalid_subexpr_in_ice, E); - case UnaryOperator::Extension: + case UO_Extension: // FIXME: Should extension allow i-c-e extension expressions in its scope? // If so, we could clear the diagnostic ID. return true; - case UnaryOperator::Plus: + case UO_Plus: // The result is always just the subexpr. return true; - case UnaryOperator::Minus: + case UO_Minus: if (!Result.isInt()) return false; return Success(-Result.getInt(), E); - case UnaryOperator::Not: + case UO_Not: if (!Result.isInt()) return false; return Success(~Result.getInt(), E); } @@ -1870,7 +1870,7 @@ bool FloatExprEvaluator::VisitUnaryImag(const UnaryOperator *E) { } bool FloatExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) { - if (E->getOpcode() == UnaryOperator::Deref) + if (E->getOpcode() == UO_Deref) return false; if (!EvaluateFloat(E->getSubExpr(), Result, Info)) @@ -1878,16 +1878,16 @@ bool FloatExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) { switch (E->getOpcode()) { default: return false; - case UnaryOperator::Plus: + case UO_Plus: return true; - case UnaryOperator::Minus: + case UO_Minus: Result.changeSign(); return true; } } bool FloatExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { - if (E->getOpcode() == BinaryOperator::Comma) { + if (E->getOpcode() == BO_Comma) { if (!EvaluateFloat(E->getRHS(), Result, Info)) return false; @@ -1909,16 +1909,16 @@ bool FloatExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { switch (E->getOpcode()) { default: return false; - case BinaryOperator::Mul: + case BO_Mul: Result.multiply(RHS, APFloat::rmNearestTiesToEven); return true; - case BinaryOperator::Add: + case BO_Add: Result.add(RHS, APFloat::rmNearestTiesToEven); return true; - case BinaryOperator::Sub: + case BO_Sub: Result.subtract(RHS, APFloat::rmNearestTiesToEven); return true; - case BinaryOperator::Div: + case BO_Div: Result.divide(RHS, APFloat::rmNearestTiesToEven); return true; } @@ -2139,7 +2139,7 @@ bool ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { "Invalid operands to binary operator."); switch (E->getOpcode()) { default: return false; - case BinaryOperator::Add: + case BO_Add: if (Result.isComplexFloat()) { Result.getComplexFloatReal().add(RHS.getComplexFloatReal(), APFloat::rmNearestTiesToEven); @@ -2150,7 +2150,7 @@ bool ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { Result.getComplexIntImag() += RHS.getComplexIntImag(); } break; - case BinaryOperator::Sub: + case BO_Sub: if (Result.isComplexFloat()) { Result.getComplexFloatReal().subtract(RHS.getComplexFloatReal(), APFloat::rmNearestTiesToEven); @@ -2161,7 +2161,7 @@ bool ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { Result.getComplexIntImag() -= RHS.getComplexIntImag(); } break; - case BinaryOperator::Mul: + case BO_Mul: if (Result.isComplexFloat()) { ComplexValue LHS = Result; APFloat &LHS_r = LHS.getComplexFloatReal(); @@ -2483,20 +2483,20 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { case Expr::UnaryOperatorClass: { const UnaryOperator *Exp = cast(E); switch (Exp->getOpcode()) { - case UnaryOperator::PostInc: - case UnaryOperator::PostDec: - case UnaryOperator::PreInc: - case UnaryOperator::PreDec: - case UnaryOperator::AddrOf: - case UnaryOperator::Deref: + case UO_PostInc: + case UO_PostDec: + case UO_PreInc: + case UO_PreDec: + case UO_AddrOf: + case UO_Deref: return ICEDiag(2, E->getLocStart()); - case UnaryOperator::Extension: - case UnaryOperator::LNot: - case UnaryOperator::Plus: - case UnaryOperator::Minus: - case UnaryOperator::Not: - case UnaryOperator::Real: - case UnaryOperator::Imag: + case UO_Extension: + case UO_LNot: + case UO_Plus: + case UO_Minus: + case UO_Not: + case UO_Real: + case UO_Imag: return CheckICE(Exp->getSubExpr(), Ctx); } @@ -2520,42 +2520,42 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { case Expr::BinaryOperatorClass: { const BinaryOperator *Exp = cast(E); switch (Exp->getOpcode()) { - case BinaryOperator::PtrMemD: - case BinaryOperator::PtrMemI: - case BinaryOperator::Assign: - case BinaryOperator::MulAssign: - case BinaryOperator::DivAssign: - case BinaryOperator::RemAssign: - case BinaryOperator::AddAssign: - case BinaryOperator::SubAssign: - case BinaryOperator::ShlAssign: - case BinaryOperator::ShrAssign: - case BinaryOperator::AndAssign: - case BinaryOperator::XorAssign: - case BinaryOperator::OrAssign: + case BO_PtrMemD: + case BO_PtrMemI: + case BO_Assign: + case BO_MulAssign: + case BO_DivAssign: + case BO_RemAssign: + case BO_AddAssign: + case BO_SubAssign: + case BO_ShlAssign: + case BO_ShrAssign: + case BO_AndAssign: + case BO_XorAssign: + case BO_OrAssign: return ICEDiag(2, E->getLocStart()); - case BinaryOperator::Mul: - case BinaryOperator::Div: - case BinaryOperator::Rem: - case BinaryOperator::Add: - case BinaryOperator::Sub: - case BinaryOperator::Shl: - case BinaryOperator::Shr: - case BinaryOperator::LT: - case BinaryOperator::GT: - case BinaryOperator::LE: - case BinaryOperator::GE: - case BinaryOperator::EQ: - case BinaryOperator::NE: - case BinaryOperator::And: - case BinaryOperator::Xor: - case BinaryOperator::Or: - case BinaryOperator::Comma: { + case BO_Mul: + case BO_Div: + case BO_Rem: + case BO_Add: + case BO_Sub: + case BO_Shl: + case BO_Shr: + case BO_LT: + case BO_GT: + case BO_LE: + case BO_GE: + case BO_EQ: + case BO_NE: + case BO_And: + case BO_Xor: + case BO_Or: + case BO_Comma: { ICEDiag LHSResult = CheckICE(Exp->getLHS(), Ctx); ICEDiag RHSResult = CheckICE(Exp->getRHS(), Ctx); - if (Exp->getOpcode() == BinaryOperator::Div || - Exp->getOpcode() == BinaryOperator::Rem) { + if (Exp->getOpcode() == BO_Div || + Exp->getOpcode() == BO_Rem) { // Evaluate gives an error for undefined Div/Rem, so make sure // we don't evaluate one. if (LHSResult.Val != 2 && RHSResult.Val != 2) { @@ -2569,7 +2569,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { } } } - if (Exp->getOpcode() == BinaryOperator::Comma) { + if (Exp->getOpcode() == BO_Comma) { if (Ctx.getLangOptions().C99) { // C99 6.6p3 introduces a strange edge case: comma can be in an ICE // if it isn't evaluated. @@ -2584,15 +2584,15 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { return LHSResult; return RHSResult; } - case BinaryOperator::LAnd: - case BinaryOperator::LOr: { + case BO_LAnd: + case BO_LOr: { ICEDiag LHSResult = CheckICE(Exp->getLHS(), Ctx); ICEDiag RHSResult = CheckICE(Exp->getRHS(), Ctx); if (LHSResult.Val == 0 && RHSResult.Val == 1) { // Rare case where the RHS has a comma "side-effect"; we need // to actually check the condition to see whether the side // with the comma is evaluated. - if ((Exp->getOpcode() == BinaryOperator::LAnd) != + if ((Exp->getOpcode() == BO_LAnd) != (Exp->getLHS()->EvaluateAsInt(Ctx) == 0)) return RHSResult; return NoDiag(); diff --git a/lib/AST/ParentMap.cpp b/lib/AST/ParentMap.cpp index 48251d52fd..5fe873acf7 100644 --- a/lib/AST/ParentMap.cpp +++ b/lib/AST/ParentMap.cpp @@ -73,7 +73,7 @@ bool ParentMap::isConsumedExpr(Expr* E) const { BinaryOperator *BE = cast(P); // If it is a comma, only the right side is consumed. // If it isn't a comma, both sides are consumed. - return BE->getOpcode()!=BinaryOperator::Comma ||DirectChild==BE->getRHS(); + return BE->getOpcode()!=BO_Comma ||DirectChild==BE->getRHS(); } case Stmt::ForStmtClass: return DirectChild == cast(P)->getCond(); diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp index dba6b08d78..fc8898173f 100644 --- a/lib/AST/Stmt.cpp +++ b/lib/AST/Stmt.cpp @@ -119,7 +119,7 @@ bool Stmt::hasImplicitControlFlow() const { case Stmt::BinaryOperatorClass: { const BinaryOperator* B = cast(this); - if (B->isLogicalOp() || B->getOpcode() == BinaryOperator::Comma) + if (B->isLogicalOp() || B->getOpcode() == BO_Comma) return true; else return false; diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 583a7a95a4..ea528c2dae 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -660,13 +660,13 @@ void StmtPrinter::VisitUnaryOperator(UnaryOperator *Node) { // it might be concatenated incorrectly like '+'. switch (Node->getOpcode()) { default: break; - case UnaryOperator::Real: - case UnaryOperator::Imag: - case UnaryOperator::Extension: + case UO_Real: + case UO_Imag: + case UO_Extension: OS << ' '; break; - case UnaryOperator::Plus: - case UnaryOperator::Minus: + case UO_Plus: + case UO_Minus: if (isa(Node->getSubExpr())) OS << ' '; break; diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp index 4e8fc5fe70..098aec0a19 100644 --- a/lib/AST/StmtProfile.cpp +++ b/lib/AST/StmtProfile.cpp @@ -436,8 +436,8 @@ void StmtProfiler::VisitBlockDeclRefExpr(BlockDeclRefExpr *S) { } static Stmt::StmtClass DecodeOperatorCall(CXXOperatorCallExpr *S, - UnaryOperator::Opcode &UnaryOp, - BinaryOperator::Opcode &BinaryOp) { + UnaryOperatorKind &UnaryOp, + BinaryOperatorKind &BinaryOp) { switch (S->getOperator()) { case OO_None: case OO_New: @@ -453,165 +453,165 @@ static Stmt::StmtClass DecodeOperatorCall(CXXOperatorCallExpr *S, case OO_Plus: if (S->getNumArgs() == 1) { - UnaryOp = UnaryOperator::Plus; + UnaryOp = UO_Plus; return Stmt::UnaryOperatorClass; } - BinaryOp = BinaryOperator::Add; + BinaryOp = BO_Add; return Stmt::BinaryOperatorClass; case OO_Minus: if (S->getNumArgs() == 1) { - UnaryOp = UnaryOperator::Minus; + UnaryOp = UO_Minus; return Stmt::UnaryOperatorClass; } - BinaryOp = BinaryOperator::Sub; + BinaryOp = BO_Sub; return Stmt::BinaryOperatorClass; case OO_Star: if (S->getNumArgs() == 1) { - UnaryOp = UnaryOperator::Minus; + UnaryOp = UO_Minus; return Stmt::UnaryOperatorClass; } - BinaryOp = BinaryOperator::Sub; + BinaryOp = BO_Sub; return Stmt::BinaryOperatorClass; case OO_Slash: - BinaryOp = BinaryOperator::Div; + BinaryOp = BO_Div; return Stmt::BinaryOperatorClass; case OO_Percent: - BinaryOp = BinaryOperator::Rem; + BinaryOp = BO_Rem; return Stmt::BinaryOperatorClass; case OO_Caret: - BinaryOp = BinaryOperator::Xor; + BinaryOp = BO_Xor; return Stmt::BinaryOperatorClass; case OO_Amp: if (S->getNumArgs() == 1) { - UnaryOp = UnaryOperator::AddrOf; + UnaryOp = UO_AddrOf; return Stmt::UnaryOperatorClass; } - BinaryOp = BinaryOperator::And; + BinaryOp = BO_And; return Stmt::BinaryOperatorClass; case OO_Pipe: - BinaryOp = BinaryOperator::Or; + BinaryOp = BO_Or; return Stmt::BinaryOperatorClass; case OO_Tilde: - UnaryOp = UnaryOperator::Not; + UnaryOp = UO_Not; return Stmt::UnaryOperatorClass; case OO_Exclaim: - UnaryOp = UnaryOperator::LNot; + UnaryOp = UO_LNot; return Stmt::UnaryOperatorClass; case OO_Equal: - BinaryOp = BinaryOperator::Assign; + BinaryOp = BO_Assign; return Stmt::BinaryOperatorClass; case OO_Less: - BinaryOp = BinaryOperator::LT; + BinaryOp = BO_LT; return Stmt::BinaryOperatorClass; case OO_Greater: - BinaryOp = BinaryOperator::GT; + BinaryOp = BO_GT; return Stmt::BinaryOperatorClass; case OO_PlusEqual: - BinaryOp = BinaryOperator::AddAssign; + BinaryOp = BO_AddAssign; return Stmt::CompoundAssignOperatorClass; case OO_MinusEqual: - BinaryOp = BinaryOperator::SubAssign; + BinaryOp = BO_SubAssign; return Stmt::CompoundAssignOperatorClass; case OO_StarEqual: - BinaryOp = BinaryOperator::MulAssign; + BinaryOp = BO_MulAssign; return Stmt::CompoundAssignOperatorClass; case OO_SlashEqual: - BinaryOp = BinaryOperator::DivAssign; + BinaryOp = BO_DivAssign; return Stmt::CompoundAssignOperatorClass; case OO_PercentEqual: - BinaryOp = BinaryOperator::RemAssign; + BinaryOp = BO_RemAssign; return Stmt::CompoundAssignOperatorClass; case OO_CaretEqual: - BinaryOp = BinaryOperator::XorAssign; + BinaryOp = BO_XorAssign; return Stmt::CompoundAssignOperatorClass; case OO_AmpEqual: - BinaryOp = BinaryOperator::AndAssign; + BinaryOp = BO_AndAssign; return Stmt::CompoundAssignOperatorClass; case OO_PipeEqual: - BinaryOp = BinaryOperator::OrAssign; + BinaryOp = BO_OrAssign; return Stmt::CompoundAssignOperatorClass; case OO_LessLess: - BinaryOp = BinaryOperator::Shl; + BinaryOp = BO_Shl; return Stmt::BinaryOperatorClass; case OO_GreaterGreater: - BinaryOp = BinaryOperator::Shr; + BinaryOp = BO_Shr; return Stmt::BinaryOperatorClass; case OO_LessLessEqual: - BinaryOp = BinaryOperator::ShlAssign; + BinaryOp = BO_ShlAssign; return Stmt::CompoundAssignOperatorClass; case OO_GreaterGreaterEqual: - BinaryOp = BinaryOperator::ShrAssign; + BinaryOp = BO_ShrAssign; return Stmt::CompoundAssignOperatorClass; case OO_EqualEqual: - BinaryOp = BinaryOperator::EQ; + BinaryOp = BO_EQ; return Stmt::BinaryOperatorClass; case OO_ExclaimEqual: - BinaryOp = BinaryOperator::NE; + BinaryOp = BO_NE; return Stmt::BinaryOperatorClass; case OO_LessEqual: - BinaryOp = BinaryOperator::LE; + BinaryOp = BO_LE; return Stmt::BinaryOperatorClass; case OO_GreaterEqual: - BinaryOp = BinaryOperator::GE; + BinaryOp = BO_GE; return Stmt::BinaryOperatorClass; case OO_AmpAmp: - BinaryOp = BinaryOperator::LAnd; + BinaryOp = BO_LAnd; return Stmt::BinaryOperatorClass; case OO_PipePipe: - BinaryOp = BinaryOperator::LOr; + BinaryOp = BO_LOr; return Stmt::BinaryOperatorClass; case OO_PlusPlus: - UnaryOp = S->getNumArgs() == 1? UnaryOperator::PreInc - : UnaryOperator::PostInc; + UnaryOp = S->getNumArgs() == 1? UO_PreInc + : UO_PostInc; return Stmt::UnaryOperatorClass; case OO_MinusMinus: - UnaryOp = S->getNumArgs() == 1? UnaryOperator::PreDec - : UnaryOperator::PostDec; + UnaryOp = S->getNumArgs() == 1? UO_PreDec + : UO_PostDec; return Stmt::UnaryOperatorClass; case OO_Comma: - BinaryOp = BinaryOperator::Comma; + BinaryOp = BO_Comma; return Stmt::BinaryOperatorClass; case OO_ArrowStar: - BinaryOp = BinaryOperator::PtrMemI; + BinaryOp = BO_PtrMemI; return Stmt::BinaryOperatorClass; case OO_Subscript: @@ -626,8 +626,8 @@ void StmtProfiler::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *S) { if (S->isTypeDependent()) { // Type-dependent operator calls are profiled like their underlying // syntactic operator. - UnaryOperator::Opcode UnaryOp = UnaryOperator::Extension; - BinaryOperator::Opcode BinaryOp = BinaryOperator::Comma; + UnaryOperatorKind UnaryOp = UO_Extension; + BinaryOperatorKind BinaryOp = BO_Comma; Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp); ID.AddInteger(SC); diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp index da7f36a132..3720d20c28 100644 --- a/lib/Analysis/CFG.cpp +++ b/lib/Analysis/CFG.cpp @@ -526,15 +526,15 @@ CFGBlock *CFGBuilder::VisitBinaryOperator(BinaryOperator *B, // See if this is a known constant. TryResult KnownVal = TryEvaluateBool(B->getLHS()); - if (KnownVal.isKnown() && (B->getOpcode() == BinaryOperator::LOr)) + if (KnownVal.isKnown() && (B->getOpcode() == BO_LOr)) KnownVal.negate(); // Now link the LHSBlock with RHSBlock. - if (B->getOpcode() == BinaryOperator::LOr) { + if (B->getOpcode() == BO_LOr) { AddSuccessor(LHSBlock, KnownVal.isTrue() ? NULL : ConfluenceBlock); AddSuccessor(LHSBlock, KnownVal.isFalse() ? NULL : RHSBlock); } else { - assert(B->getOpcode() == BinaryOperator::LAnd); + assert(B->getOpcode() == BO_LAnd); AddSuccessor(LHSBlock, KnownVal.isFalse() ? NULL : RHSBlock); AddSuccessor(LHSBlock, KnownVal.isTrue() ? NULL : ConfluenceBlock); } @@ -543,7 +543,7 @@ CFGBlock *CFGBuilder::VisitBinaryOperator(BinaryOperator *B, Block = LHSBlock; return addStmt(B->getLHS()); } - else if (B->getOpcode() == BinaryOperator::Comma) { // , + else if (B->getOpcode() == BO_Comma) { // , autoCreateBlock(); AppendStmt(Block, B, asc); addStmt(B->getRHS()); @@ -2084,10 +2084,10 @@ public: B->getLHS()->printPretty(OS, Helper, Policy); switch (B->getOpcode()) { - case BinaryOperator::LOr: + case BO_LOr: OS << " || ..."; return; - case BinaryOperator::LAnd: + case BO_LAnd: OS << " && ..."; return; default: @@ -2130,7 +2130,7 @@ static void print_stmt(llvm::raw_ostream &OS, StmtPrinterHelper* Helper, // special printing for comma expressions. if (BinaryOperator* B = dyn_cast(Terminator)) { - if (B->getOpcode() == BinaryOperator::Comma) { + if (B->getOpcode() == BO_Comma) { OS << "... , "; Helper->handledStmt(B->getRHS(),OS); OS << '\n'; diff --git a/lib/Analysis/LiveVariables.cpp b/lib/Analysis/LiveVariables.cpp index 4efe25ea1e..3011fd0dee 100644 --- a/lib/Analysis/LiveVariables.cpp +++ b/lib/Analysis/LiveVariables.cpp @@ -229,10 +229,10 @@ void TransferFuncs::VisitUnaryOperator(UnaryOperator* U) { Expr *E = U->getSubExpr(); switch (U->getOpcode()) { - case UnaryOperator::PostInc: - case UnaryOperator::PostDec: - case UnaryOperator::PreInc: - case UnaryOperator::PreDec: + case UO_PostInc: + case UO_PostDec: + case UO_PreInc: + case UO_PreDec: // Walk through the subexpressions, blasting through ParenExprs // until we either find a DeclRefExpr or some non-DeclRefExpr // expression. @@ -268,7 +268,7 @@ void TransferFuncs::VisitAssign(BinaryOperator* B) { // Handle things like +=, etc., which also generate "uses" // of a variable. Do this just by visiting the subexpression. - if (B->getOpcode() != BinaryOperator::Assign) + if (B->getOpcode() != BO_Assign) VisitDeclRefExpr(DR); } } diff --git a/lib/Analysis/PseudoConstantAnalysis.cpp b/lib/Analysis/PseudoConstantAnalysis.cpp index 5deabacea4..42ebe9c237 100644 --- a/lib/Analysis/PseudoConstantAnalysis.cpp +++ b/lib/Analysis/PseudoConstantAnalysis.cpp @@ -91,7 +91,7 @@ void PseudoConstantAnalysis::RunAnalysis() { // for any of the assignment operators, implying that this Decl is being // written to. switch (BO->getOpcode()) { - case BinaryOperator::Assign: { + case BO_Assign: { const Expr *RHS = BO->getRHS()->IgnoreParenCasts(); if (const DeclRefExpr *RHSDecl = dyn_cast(RHS)) { // Self-assignments don't count as use of a variable @@ -101,15 +101,15 @@ void PseudoConstantAnalysis::RunAnalysis() { } } - case BinaryOperator::AddAssign: - case BinaryOperator::SubAssign: - case BinaryOperator::MulAssign: - case BinaryOperator::DivAssign: - case BinaryOperator::AndAssign: - case BinaryOperator::OrAssign: - case BinaryOperator::XorAssign: - case BinaryOperator::ShlAssign: - case BinaryOperator::ShrAssign: { + case BO_AddAssign: + case BO_SubAssign: + case BO_MulAssign: + case BO_DivAssign: + case BO_AndAssign: + case BO_OrAssign: + case BO_XorAssign: + case BO_ShlAssign: + case BO_ShrAssign: { // The DeclRefExpr is being assigned to - mark it as non-constant const VarDecl *VD = dyn_cast(DR->getDecl()); if (VD) @@ -137,12 +137,12 @@ void PseudoConstantAnalysis::RunAnalysis() { // check for any of the increment/decrement operators, as well as // addressOf. switch (UO->getOpcode()) { - case UnaryOperator::PostDec: - case UnaryOperator::PostInc: - case UnaryOperator::PreDec: - case UnaryOperator::PreInc: + case UO_PostDec: + case UO_PostInc: + case UO_PreDec: + case UO_PreInc: // The DeclRefExpr is being changed - mark it as non-constant - case UnaryOperator::AddrOf: { + case UO_AddrOf: { // If we are taking the address of the DeclRefExpr, assume it is // non-constant. const VarDecl *VD = dyn_cast(DR->getDecl()); diff --git a/lib/Analysis/ReachableCode.cpp b/lib/Analysis/ReachableCode.cpp index f959e5cd43..05439392f9 100644 --- a/lib/Analysis/ReachableCode.cpp +++ b/lib/Analysis/ReachableCode.cpp @@ -41,7 +41,7 @@ top: switch (S->getStmtClass()) { case Expr::BinaryOperatorClass: { const BinaryOperator *BO = cast(S); - if (BO->getOpcode() == BinaryOperator::Comma) { + if (BO->getOpcode() == BO_Comma) { if (sn+1 < b.size()) return b[sn+1].getStmt()->getLocStart(); const CFGBlock *n = &b; diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp index 7a628642dc..0f43efa58c 100644 --- a/lib/Analysis/UninitializedValues.cpp +++ b/lib/Analysis/UninitializedValues.cpp @@ -121,7 +121,7 @@ bool TransferFuncs::VisitBinaryOperator(BinaryOperator* B) { if (VarDecl* VD = FindBlockVarDecl(B->getLHS())) if (B->isAssignmentOp()) { - if (B->getOpcode() == BinaryOperator::Assign) + if (B->getOpcode() == BO_Assign) return V(VD,AD) = Visit(B->getRHS()); else // Handle +=, -=, *=, etc. We do want '&', not '&&'. return V(VD,AD) = Visit(B->getLHS()) & Visit(B->getRHS()); @@ -168,7 +168,7 @@ bool TransferFuncs::VisitCallExpr(CallExpr* C) { bool TransferFuncs::VisitUnaryOperator(UnaryOperator* U) { switch (U->getOpcode()) { - case UnaryOperator::AddrOf: { + case UO_AddrOf: { VarDecl* VD = FindBlockVarDecl(U->getSubExpr()); if (VD && VD->isBlockVarDecl()) return V(VD,AD) = Initialized; diff --git a/lib/Checker/AggExprVisitor.cpp b/lib/Checker/AggExprVisitor.cpp index 343afec18d..e9c0b1e459 100644 --- a/lib/Checker/AggExprVisitor.cpp +++ b/lib/Checker/AggExprVisitor.cpp @@ -38,8 +38,8 @@ void AggExprVisitor::VisitCastExpr(CastExpr *E) { switch (E->getCastKind()) { default: assert(0 && "Unhandled cast kind"); - case CastExpr::CK_NoOp: - case CastExpr::CK_ConstructorConversion: + case CK_NoOp: + case CK_ConstructorConversion: Visit(E->getSubExpr()); break; } diff --git a/lib/Checker/BasicValueFactory.cpp b/lib/Checker/BasicValueFactory.cpp index 246beead12..4c9b109c88 100644 --- a/lib/Checker/BasicValueFactory.cpp +++ b/lib/Checker/BasicValueFactory.cpp @@ -149,22 +149,22 @@ BasicValueFactory::EvaluateAPSInt(BinaryOperator::Opcode Op, default: assert (false && "Invalid Opcode."); - case BinaryOperator::Mul: + case BO_Mul: return &getValue( V1 * V2 ); - case BinaryOperator::Div: + case BO_Div: return &getValue( V1 / V2 ); - case BinaryOperator::Rem: + case BO_Rem: return &getValue( V1 % V2 ); - case BinaryOperator::Add: + case BO_Add: return &getValue( V1 + V2 ); - case BinaryOperator::Sub: + case BO_Sub: return &getValue( V1 - V2 ); - case BinaryOperator::Shl: { + case BO_Shl: { // FIXME: This logic should probably go higher up, where we can // test these conditions symbolically. @@ -182,7 +182,7 @@ BasicValueFactory::EvaluateAPSInt(BinaryOperator::Opcode Op, return &getValue( V1.operator<<( (unsigned) Amt )); } - case BinaryOperator::Shr: { + case BO_Shr: { // FIXME: This logic should probably go higher up, where we can // test these conditions symbolically. @@ -200,33 +200,33 @@ BasicValueFactory::EvaluateAPSInt(BinaryOperator::Opcode Op, return &getValue( V1.operator>>( (unsigned) Amt )); } - case BinaryOperator::LT: + case BO_LT: return &getTruthValue( V1 < V2 ); - case BinaryOperator::GT: + case BO_GT: return &getTruthValue( V1 > V2 ); - case BinaryOperator::LE: + case BO_LE: return &getTruthValue( V1 <= V2 ); - case BinaryOperator::GE: + case BO_GE: return &getTruthValue( V1 >= V2 ); - case BinaryOperator::EQ: + case BO_EQ: return &getTruthValue( V1 == V2 ); - case BinaryOperator::NE: + case BO_NE: return &getTruthValue( V1 != V2 ); // Note: LAnd, LOr, Comma are handled specially by higher-level logic. - case BinaryOperator::And: + case BO_And: return &getValue( V1 & V2 ); - case BinaryOperator::Or: + case BO_Or: return &getValue( V1 | V2 ); - case BinaryOperator::Xor: + case BO_Xor: return &getValue( V1 ^ V2 ); } } diff --git a/lib/Checker/BugReporter.cpp b/lib/Checker/BugReporter.cpp index ca3c4258e1..bffbd52b7d 100644 --- a/lib/Checker/BugReporter.cpp +++ b/lib/Checker/BugReporter.cpp @@ -94,8 +94,8 @@ static const Stmt* GetNextStmt(const ExplodedNode* N) { case Stmt::ChooseExprClass: case Stmt::ConditionalOperatorClass: continue; case Stmt::BinaryOperatorClass: { - BinaryOperator::Opcode Op = cast(S)->getOpcode(); - if (Op == BinaryOperator::LAnd || Op == BinaryOperator::LOr) + BinaryOperatorKind Op = cast(S)->getOpcode(); + if (Op == BO_LAnd || Op == BO_LOr) continue; break; } @@ -664,7 +664,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD, llvm::raw_string_ostream os(sbuf); os << "Left side of '"; - if (B->getOpcode() == BinaryOperator::LAnd) { + if (B->getOpcode() == BO_LAnd) { os << "&&" << "' is "; if (*(Src->succ_begin()+1) == Dst) { @@ -683,7 +683,7 @@ static void GenerateMinimalPathDiagnostic(PathDiagnostic& PD, } } else { - assert(B->getOpcode() == BinaryOperator::LOr); + assert(B->getOpcode() == BO_LOr); os << "||" << "' is "; if (*(Src->succ_begin()+1) == Dst) { diff --git a/lib/Checker/BugReporterVisitors.cpp b/lib/Checker/BugReporterVisitors.cpp index a6ad245bba..cddc86ee9d 100644 --- a/lib/Checker/BugReporterVisitors.cpp +++ b/lib/Checker/BugReporterVisitors.cpp @@ -31,7 +31,7 @@ const Stmt *clang::bugreporter::GetDerefExpr(const ExplodedNode *N) { const Stmt *S = N->getLocationAs()->getStmt(); if (const UnaryOperator *U = dyn_cast(S)) { - if (U->getOpcode() == UnaryOperator::Deref) + if (U->getOpcode() == UO_Deref) return U->getSubExpr()->IgnoreParenCasts(); } else if (const MemberExpr *ME = dyn_cast(S)) { diff --git a/lib/Checker/CStringChecker.cpp b/lib/Checker/CStringChecker.cpp index 583462a00b..9ea572f90d 100644 --- a/lib/Checker/CStringChecker.cpp +++ b/lib/Checker/CStringChecker.cpp @@ -265,13 +265,13 @@ const GRState *CStringChecker::CheckBufferAccess(CheckerContext &C, // Compute the offset of the last element to be accessed: size-1. NonLoc One = cast(VM.makeIntVal(1, SizeTy)); - NonLoc LastOffset = cast(SV.EvalBinOpNN(state, BinaryOperator::Sub, + NonLoc LastOffset = cast(SV.EvalBinOpNN(state, BO_Sub, *Length, One, SizeTy)); // Check that the first buffer is sufficently long. SVal BufStart = SV.EvalCast(BufVal, PtrTy, FirstBuf->getType()); if (Loc *BufLoc = dyn_cast(&BufStart)) { - SVal BufEnd = SV.EvalBinOpLN(state, BinaryOperator::Add, *BufLoc, + SVal BufEnd = SV.EvalBinOpLN(state, BO_Add, *BufLoc, LastOffset, PtrTy); state = CheckLocation(C, state, FirstBuf, BufEnd, FirstIsDestination); @@ -289,7 +289,7 @@ const GRState *CStringChecker::CheckBufferAccess(CheckerContext &C, BufStart = SV.EvalCast(BufVal, PtrTy, SecondBuf->getType()); if (Loc *BufLoc = dyn_cast(&BufStart)) { - SVal BufEnd = SV.EvalBinOpLN(state, BinaryOperator::Add, *BufLoc, + SVal BufEnd = SV.EvalBinOpLN(state, BO_Add, *BufLoc, LastOffset, PtrTy); state = CheckLocation(C, state, SecondBuf, BufEnd); } @@ -345,7 +345,7 @@ const GRState *CStringChecker::CheckOverlap(CheckerContext &C, // Which value comes first? QualType CmpTy = Ctx.IntTy; - SVal Reverse = SV.EvalBinOpLL(state, BinaryOperator::GT, + SVal Reverse = SV.EvalBinOpLL(state, BO_GT, *FirstLoc, *SecondLoc, CmpTy); DefinedOrUnknownSVal *ReverseTest = dyn_cast(&Reverse); if (!ReverseTest) @@ -385,14 +385,14 @@ const GRState *CStringChecker::CheckOverlap(CheckerContext &C, return state; // Compute the end of the first buffer. Bail out if THAT fails. - SVal FirstEnd = SV.EvalBinOpLN(state, BinaryOperator::Add, + SVal FirstEnd = SV.EvalBinOpLN(state, BO_Add, *FirstStartLoc, *Length, CharPtrTy); Loc *FirstEndLoc = dyn_cast(&FirstEnd); if (!FirstEndLoc) return state; // Is the end of the first buffer past the start of the second buffer? - SVal Overlap = SV.EvalBinOpLL(state, BinaryOperator::GT, + SVal Overlap = SV.EvalBinOpLL(state, BO_GT, *FirstEndLoc, *SecondLoc, CmpTy); DefinedOrUnknownSVal *OverlapTest = dyn_cast(&Overlap); if (!OverlapTest) @@ -852,7 +852,7 @@ void CStringChecker::EvalStrcpyCommon(CheckerContext &C, const CallExpr *CE, if (NonLoc *KnownStrLen = dyn_cast(&StrLen)) { SValuator &SV = C.getSValuator(); - SVal LastElement = SV.EvalBinOpLN(state, BinaryOperator::Add, + SVal LastElement = SV.EvalBinOpLN(state, BO_Add, *DstRegVal, *KnownStrLen, Dst->getType()); diff --git a/lib/Checker/CheckDeadStores.cpp b/lib/Checker/CheckDeadStores.cpp index be1cce96ab..38961000d3 100644 --- a/lib/Checker/CheckDeadStores.cpp +++ b/lib/Checker/CheckDeadStores.cpp @@ -268,7 +268,7 @@ public: // Check for '&'. Any VarDecl whose value has its address-taken we // treat as escaped. Expr* E = U->getSubExpr()->IgnoreParenCasts(); - if (U->getOpcode() == UnaryOperator::AddrOf) + if (U->getOpcode() == UO_AddrOf) if (DeclRefExpr* DR = dyn_cast(E)) if (VarDecl* VD = dyn_cast(DR->getDecl())) { Escaped.insert(VD); diff --git a/lib/Checker/CheckSecuritySyntaxOnly.cpp b/lib/Checker/CheckSecuritySyntaxOnly.cpp index 4dc3afe70e..9a2ac45fa2 100644 --- a/lib/Checker/CheckSecuritySyntaxOnly.cpp +++ b/lib/Checker/CheckSecuritySyntaxOnly.cpp @@ -131,7 +131,7 @@ GetIncrementedVar(const Expr *expr, const VarDecl *x, const VarDecl *y) { if (const BinaryOperator *B = dyn_cast(expr)) { if (!(B->isAssignmentOp() || B->isCompoundAssignmentOp() || - B->getOpcode() == BinaryOperator::Comma)) + B->getOpcode() == BO_Comma)) return NULL; if (const DeclRefExpr *lhs = GetIncrementedVar(B->getLHS(), x, y)) diff --git a/lib/Checker/DivZeroChecker.cpp b/lib/Checker/DivZeroChecker.cpp index e09a87149f..32e2a1782d 100644 --- a/lib/Checker/DivZeroChecker.cpp +++ b/lib/Checker/DivZeroChecker.cpp @@ -40,10 +40,10 @@ void *DivZeroChecker::getTag() { void DivZeroChecker::PreVisitBinaryOperator(CheckerContext &C, const BinaryOperator *B) { BinaryOperator::Opcode Op = B->getOpcode(); - if (Op != BinaryOperator::Div && - Op != BinaryOperator::Rem && - Op != BinaryOperator::DivAssign && - Op != BinaryOperator::RemAssign) + if (Op != BO_Div && + Op != BO_Rem && + Op != BO_DivAssign && + Op != BO_RemAssign) return; if (!B->getRHS()->getType()->isIntegerType() || diff --git a/lib/Checker/FixedAddressChecker.cpp b/lib/Checker/FixedAddressChecker.cpp index 4fce45bd35..29a3c3ae35 100644 --- a/lib/Checker/FixedAddressChecker.cpp +++ b/lib/Checker/FixedAddressChecker.cpp @@ -40,7 +40,7 @@ void FixedAddressChecker::PreVisitBinaryOperator(CheckerContext &C, // Using a fixed address is not portable because that address will probably // not be valid in all environments or platforms. - if (B->getOpcode() != BinaryOperator::Assign) + if (B->getOpcode() != BO_Assign) return; QualType T = B->getType(); diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp index 980d83cdab..2c07641b17 100644 --- a/lib/Checker/GRExprEngine.cpp +++ b/lib/Checker/GRExprEngine.cpp @@ -463,7 +463,7 @@ const GRState* GRExprEngine::getInitialState(const LocationContext *InitLoc) { break; SVal V = state->getSVal(loc::MemRegionVal(R)); - SVal Constraint_untested = EvalBinOp(state, BinaryOperator::GT, V, + SVal Constraint_untested = EvalBinOp(state, BO_GT, V, ValMgr.makeZeroVal(T), getContext().IntTy); @@ -867,7 +867,7 @@ void GRExprEngine::Visit(const Stmt* S, ExplodedNode* Pred, VisitLogicalExpr(B, Pred, Dst); break; } - else if (B->getOpcode() == BinaryOperator::Comma) { + else if (B->getOpcode() == BO_Comma) { const GRState* state = GetState(Pred); MakeNode(Dst, B, Pred, state->BindExpr(B, state->getSVal(B->getRHS()))); break; @@ -1046,7 +1046,7 @@ void GRExprEngine::Visit(const Stmt* S, ExplodedNode* Pred, case Stmt::UnaryOperatorClass: { const UnaryOperator *U = cast(S); - if (AMgr.shouldEagerlyAssume()&&(U->getOpcode() == UnaryOperator::LNot)) { + if (AMgr.shouldEagerlyAssume()&&(U->getOpcode() == UO_LNot)) { ExplodedNodeSet Tmp; VisitUnaryOperator(U, Pred, Tmp, false); EvalEagerlyAssume(Dst, Tmp, U); @@ -1242,7 +1242,7 @@ const GRState* GRExprEngine::MarkBranch(const GRState* state, const BinaryOperator* B = cast(Terminator); BinaryOperator::Opcode Op = B->getOpcode(); - assert (Op == BinaryOperator::LAnd || Op == BinaryOperator::LOr); + assert (Op == BO_LAnd || Op == BO_LOr); // For &&, if we take the true branch, then the value of the whole // expression is that of the RHS expression. @@ -1250,8 +1250,8 @@ const GRState* GRExprEngine::MarkBranch(const GRState* state, // For ||, if we take the false branch, then the value of the whole // expression is that of the RHS expression. - const Expr* Ex = (Op == BinaryOperator::LAnd && branchTaken) || - (Op == BinaryOperator::LOr && !branchTaken) + const Expr* Ex = (Op == BO_LAnd && branchTaken) || + (Op == BO_LOr && !branchTaken) ? B->getRHS() : B->getLHS(); return state->BindExpr(B, UndefinedVal(Ex)); @@ -1618,8 +1618,8 @@ void GRExprEngine::ProcessCallExit(GRCallExitNodeBuilder &B) { void GRExprEngine::VisitLogicalExpr(const BinaryOperator* B, ExplodedNode* Pred, ExplodedNodeSet& Dst) { - assert(B->getOpcode() == BinaryOperator::LAnd || - B->getOpcode() == BinaryOperator::LOr); + assert(B->getOpcode() == BO_LAnd || + B->getOpcode() == BO_LOr); assert(B==CurrentStmt && Pred->getLocationContext()->getCFG()->isBlkExpr(B)); @@ -1659,7 +1659,7 @@ void GRExprEngine::VisitLogicalExpr(const BinaryOperator* B, ExplodedNode* Pred, // We took the LHS expression. Depending on whether we are '&&' or // '||' we know what the value of the expression is via properties of // the short-circuiting. - X = ValMgr.makeIntVal(B->getOpcode() == BinaryOperator::LAnd ? 0U : 1U, + X = ValMgr.makeIntVal(B->getOpcode() == BO_LAnd ? 0U : 1U, B->getType()); MakeNode(Dst, B, Pred, state->BindExpr(B, X)); } @@ -2559,14 +2559,14 @@ void GRExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex, } switch (CastE->getCastKind()) { - case CastExpr::CK_ToVoid: + case CK_ToVoid: assert(!asLValue); for (ExplodedNodeSet::iterator I = S2.begin(), E = S2.end(); I != E; ++I) Dst.Add(*I); return; - case CastExpr::CK_NoOp: - case CastExpr::CK_FunctionToPointerDecay: + case CK_NoOp: + case CK_FunctionToPointerDecay: for (ExplodedNodeSet::iterator I = S2.begin(), E = S2.end(); I != E; ++I) { // Copy the SVal of Ex to CastE. ExplodedNode *N = *I; @@ -2577,21 +2577,21 @@ void GRExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex, } return; - case CastExpr::CK_Unknown: - case CastExpr::CK_ArrayToPointerDecay: - case CastExpr::CK_BitCast: - case CastExpr::CK_LValueBitCast: - case CastExpr::CK_IntegralCast: - case CastExpr::CK_IntegralToPointer: - case CastExpr::CK_PointerToIntegral: - case CastExpr::CK_IntegralToFloating: - case CastExpr::CK_FloatingToIntegral: - case CastExpr::CK_FloatingCast: - case CastExpr::CK_AnyPointerToObjCPointerCast: - case CastExpr::CK_AnyPointerToBlockPointerCast: - case CastExpr::CK_DerivedToBase: - case CastExpr::CK_UncheckedDerivedToBase: - case CastExpr::CK_ObjCObjectLValueCast: { + case CK_Unknown: + case CK_ArrayToPointerDecay: + case CK_BitCast: + case CK_LValueBitCast: + case CK_IntegralCast: + case CK_IntegralToPointer: + case CK_PointerToIntegral: + case CK_IntegralToFloating: + case CK_FloatingToIntegral: + case CK_FloatingCast: + case CK_AnyPointerToObjCPointerCast: + case CK_AnyPointerToBlockPointerCast: + case CK_DerivedToBase: + case CK_UncheckedDerivedToBase: + case CK_ObjCObjectLValueCast: { // Delegate to SValuator to process. for (ExplodedNodeSet::iterator I = S2.begin(), E = S2.end(); I != E; ++I) { ExplodedNode* N = *I; @@ -2605,16 +2605,16 @@ void GRExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex, } // Various C++ casts that are not handled yet. - case CastExpr::CK_Dynamic: - case CastExpr::CK_ToUnion: - case CastExpr::CK_BaseToDerived: - case CastExpr::CK_NullToMemberPointer: - case CastExpr::CK_BaseToDerivedMemberPointer: - case CastExpr::CK_DerivedToBaseMemberPointer: - case CastExpr::CK_UserDefinedConversion: - case CastExpr::CK_ConstructorConversion: - case CastExpr::CK_VectorSplat: - case CastExpr::CK_MemberPointerToBoolean: { + case CK_Dynamic: + case CK_ToUnion: + case CK_BaseToDerived: + case CK_NullToMemberPointer: + case CK_BaseToDerivedMemberPointer: + case CK_DerivedToBaseMemberPointer: + case CK_UserDefinedConversion: + case CK_ConstructorConversion: + case CK_VectorSplat: + case CK_MemberPointerToBoolean: { SaveAndRestore OldSink(Builder->BuildSinks); Builder->BuildSinks = true; MakeNode(Dst, CastE, Pred, GetState(Pred)); @@ -2920,7 +2920,7 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U, default: break; - case UnaryOperator::Deref: { + case UO_Deref: { const Expr* Ex = U->getSubExpr()->IgnoreParens(); ExplodedNodeSet Tmp; @@ -2941,7 +2941,7 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U, return; } - case UnaryOperator::Real: { + case UO_Real: { const Expr* Ex = U->getSubExpr()->IgnoreParens(); ExplodedNodeSet Tmp; @@ -2956,7 +2956,7 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U, continue; } - // For all other types, UnaryOperator::Real is an identity operation. + // For all other types, UO_Real is an identity operation. assert (U->getType() == Ex->getType()); const GRState* state = GetState(*I); MakeNode(Dst, U, *I, state->BindExpr(U, state->getSVal(Ex))); @@ -2965,7 +2965,7 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U, return; } - case UnaryOperator::Imag: { + case UO_Imag: { const Expr* Ex = U->getSubExpr()->IgnoreParens(); ExplodedNodeSet Tmp; @@ -2979,7 +2979,7 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U, continue; } - // For all other types, UnaryOperator::Imag returns 0. + // For all other types, UO_Imag returns 0. const GRState* state = GetState(*I); SVal X = ValMgr.makeZeroVal(Ex->getType()); MakeNode(Dst, U, *I, state->BindExpr(U, X)); @@ -2988,8 +2988,8 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U, return; } - case UnaryOperator::Plus: assert(!asLValue); // FALL-THROUGH. - case UnaryOperator::Extension: { + case UO_Plus: assert(!asLValue); // FALL-THROUGH. + case UO_Extension: { // Unary "+" is a no-op, similar to a parentheses. We still have places // where it may be a block-level expression, so we need to @@ -3012,7 +3012,7 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U, return; } - case UnaryOperator::AddrOf: { + case UO_AddrOf: { assert(!asLValue); const Expr* Ex = U->getSubExpr()->IgnoreParens(); @@ -3029,9 +3029,9 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U, return; } - case UnaryOperator::LNot: - case UnaryOperator::Minus: - case UnaryOperator::Not: { + case UO_LNot: + case UO_Minus: + case UO_Not: { assert (!asLValue); const Expr* Ex = U->getSubExpr()->IgnoreParens(); @@ -3065,17 +3065,17 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U, assert(false && "Invalid Opcode."); break; - case UnaryOperator::Not: + case UO_Not: // FIXME: Do we need to handle promotions? state = state->BindExpr(U, EvalComplement(cast(V))); break; - case UnaryOperator::Minus: + case UO_Minus: // FIXME: Do we need to handle promotions? state = state->BindExpr(U, EvalMinus(cast(V))); break; - case UnaryOperator::LNot: + case UO_LNot: // C99 6.5.3.3: "The expression !E is equivalent to (0==E)." // @@ -3085,12 +3085,12 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U, if (isa(V)) { Loc X = ValMgr.makeNull(); - Result = EvalBinOp(state, BinaryOperator::EQ, cast(V), X, + Result = EvalBinOp(state, BO_EQ, cast(V), X, U->getType()); } else { nonloc::ConcreteInt X(getBasicVals().getValue(0, Ex->getType())); - Result = EvalBinOp(state, BinaryOperator::EQ, cast(V), X, + Result = EvalBinOp(state, BO_EQ, cast(V), X, U->getType()); } @@ -3135,8 +3135,8 @@ void GRExprEngine::VisitUnaryOperator(const UnaryOperator* U, DefinedSVal V2 = cast(V2_untested); // Handle all other values. - BinaryOperator::Opcode Op = U->isIncrementOp() ? BinaryOperator::Add - : BinaryOperator::Sub; + BinaryOperator::Opcode Op = U->isIncrementOp() ? BO_Add + : BO_Sub; // If the UnaryOperator has non-location type, use its type to create the // constant value. If the UnaryOperator has location type, create the @@ -3335,7 +3335,7 @@ void GRExprEngine::VisitBinaryOperator(const BinaryOperator* B, BinaryOperator::Opcode Op = B->getOpcode(); - if (Op == BinaryOperator::Assign) { + if (Op == BO_Assign) { // EXPERIMENTAL: "Conjured" symbols. // FIXME: Handle structs. QualType T = RHS->getType(); @@ -3381,16 +3381,16 @@ void GRExprEngine::VisitBinaryOperator(const BinaryOperator* B, switch (Op) { default: assert(0 && "Invalid opcode for compound assignment."); - case BinaryOperator::MulAssign: Op = BinaryOperator::Mul; break; - case BinaryOperator::DivAssign: Op = BinaryOperator::Div; break; - case BinaryOperator::RemAssign: Op = BinaryOperator::Rem; break; - case BinaryOperator::AddAssign: Op = BinaryOperator::Add; break; - case BinaryOperator::SubAssign: Op = BinaryOperator::Sub; break; - case BinaryOperator::ShlAssign: Op = BinaryOperator::Shl; break; - case BinaryOperator::ShrAssign: Op = BinaryOperator::Shr; break; - case BinaryOperator::AndAssign: Op = BinaryOperator::And; break; - case BinaryOperator::XorAssign: Op = BinaryOperator::Xor; break; - case BinaryOperator::OrAssign: Op = BinaryOperator::Or; break; + case BO_MulAssign: Op = BO_Mul; break; + case BO_DivAssign: Op = BO_Div; break; + case BO_RemAssign: Op = BO_Rem; break; + case BO_AddAssign: Op = BO_Add; break; + case BO_SubAssign: Op = BO_Sub; break; + case BO_ShlAssign: Op = BO_Shl; break; + case BO_ShrAssign: Op = BO_Shr; break; + case BO_AndAssign: Op = BO_And; break; + case BO_XorAssign: Op = BO_Xor; break; + case BO_OrAssign: Op = BO_Or; break; } // Perform a load (the LHS). This performs the checks for diff --git a/lib/Checker/GRState.cpp b/lib/Checker/GRState.cpp index 37ff87abec..024237c8cb 100644 --- a/lib/Checker/GRState.cpp +++ b/lib/Checker/GRState.cpp @@ -202,19 +202,19 @@ const GRState *GRState::AssumeInBound(DefinedOrUnknownSVal Idx, nonloc::ConcreteInt Min = BVF.getMinValue(IndexTy); // Adjust the index. - SVal NewIdx = SV.EvalBinOpNN(this, BinaryOperator::Add, + SVal NewIdx = SV.EvalBinOpNN(this, BO_Add, cast(Idx), Min, IndexTy); if (NewIdx.isUnknownOrUndef()) return this; // Adjust the upper bound. - SVal NewBound = SV.EvalBinOpNN(this, BinaryOperator::Add, + SVal NewBound = SV.EvalBinOpNN(this, BO_Add, cast(UpperBound), Min, IndexTy); if (NewBound.isUnknownOrUndef()) return this; // Build the actual comparison. - SVal InBound = SV.EvalBinOpNN(this, BinaryOperator::LT, + SVal InBound = SV.EvalBinOpNN(this, BO_LT, cast(NewIdx), cast(NewBound), Ctx.IntTy); if (InBound.isUnknownOrUndef()) diff --git a/lib/Checker/IdempotentOperationChecker.cpp b/lib/Checker/IdempotentOperationChecker.cpp index d8936203ea..4b26d467b6 100644 --- a/lib/Checker/IdempotentOperationChecker.cpp +++ b/lib/Checker/IdempotentOperationChecker.cpp @@ -156,16 +156,16 @@ void IdempotentOperationChecker::PreVisitBinaryOperator( break; // Fall through intentional - case BinaryOperator::AddAssign: - case BinaryOperator::SubAssign: - case BinaryOperator::MulAssign: - case BinaryOperator::DivAssign: - case BinaryOperator::AndAssign: - case BinaryOperator::OrAssign: - case BinaryOperator::XorAssign: - case BinaryOperator::ShlAssign: - case BinaryOperator::ShrAssign: - case BinaryOperator::Assign: + case BO_AddAssign: + case BO_SubAssign: + case BO_MulAssign: + case BO_DivAssign: + case BO_AndAssign: + case BO_OrAssign: + case BO_XorAssign: + case BO_ShlAssign: + case BO_ShrAssign: + case BO_Assign: // Assign statements have one extra level of indirection if (!isa(LHSVal)) { A = Impossible; @@ -183,7 +183,7 @@ void IdempotentOperationChecker::PreVisitBinaryOperator( break; // We don't care about any other operators. // Fall through intentional - case BinaryOperator::Assign: + case BO_Assign: // x Assign x can be used to silence unused variable warnings intentionally, // and has a slightly different definition for false positives. if (isUnusedSelfAssign(RHS, LHS, AC) @@ -198,18 +198,18 @@ void IdempotentOperationChecker::PreVisitBinaryOperator( UpdateAssumption(A, Equal); return; - case BinaryOperator::SubAssign: - case BinaryOperator::DivAssign: - case BinaryOperator::AndAssign: - case BinaryOperator::OrAssign: - case BinaryOperator::XorAssign: - case BinaryOperator::Sub: - case BinaryOperator::Div: - case BinaryOperator::And: - case BinaryOperator::Or: - case BinaryOperator::Xor: - case BinaryOperator::LOr: - case BinaryOperator::LAnd: + case BO_SubAssign: + case BO_DivAssign: + case BO_AndAssign: + case BO_OrAssign: + case BO_XorAssign: + case BO_Sub: + case BO_Div: + case BO_And: + case BO_Or: + case BO_Xor: + case BO_LOr: + case BO_LAnd: if (LHSVal != RHSVal || LHSContainsFalsePositive || RHSContainsFalsePositive) break; @@ -223,12 +223,12 @@ void IdempotentOperationChecker::PreVisitBinaryOperator( break; // We don't care about any other operators. // Fall through intentional - case BinaryOperator::MulAssign: - case BinaryOperator::DivAssign: - case BinaryOperator::Mul: - case BinaryOperator::Div: - case BinaryOperator::LOr: - case BinaryOperator::LAnd: + case BO_MulAssign: + case BO_DivAssign: + case BO_Mul: + case BO_Div: + case BO_LOr: + case BO_LAnd: if (!RHSVal.isConstant(1) || RHSContainsFalsePositive) break; UpdateAssumption(A, RHSis1); @@ -241,10 +241,10 @@ void IdempotentOperationChecker::PreVisitBinaryOperator( break; // We don't care about any other operators. // Fall through intentional - case BinaryOperator::MulAssign: - case BinaryOperator::Mul: - case BinaryOperator::LOr: - case BinaryOperator::LAnd: + case BO_MulAssign: + case BO_Mul: + case BO_LOr: + case BO_LAnd: if (!LHSVal.isConstant(1) || LHSContainsFalsePositive) break; UpdateAssumption(A, LHSis1); @@ -257,22 +257,22 @@ void IdempotentOperationChecker::PreVisitBinaryOperator( break; // We don't care about any other operators. // Fall through intentional - case BinaryOperator::AddAssign: - case BinaryOperator::SubAssign: - case BinaryOperator::MulAssign: - case BinaryOperator::AndAssign: - case BinaryOperator::OrAssign: - case BinaryOperator::XorAssign: - case BinaryOperator::Add: - case BinaryOperator::Sub: - case BinaryOperator::Mul: - case BinaryOperator::And: - case BinaryOperator::Or: - case BinaryOperator::Xor: - case BinaryOperator::Shl: - case BinaryOperator::Shr: - case BinaryOperator::LOr: - case BinaryOperator::LAnd: + case BO_AddAssign: + case BO_SubAssign: + case BO_MulAssign: + case BO_AndAssign: + case BO_OrAssign: + case BO_XorAssign: + case BO_Add: + case BO_Sub: + case BO_Mul: + case BO_And: + case BO_Or: + case BO_Xor: + case BO_Shl: + case BO_Shr: + case BO_LOr: + case BO_LAnd: if (!RHSVal.isConstant(0) || RHSContainsFalsePositive) break; UpdateAssumption(A, RHSis0); @@ -285,26 +285,26 @@ void IdempotentOperationChecker::PreVisitBinaryOperator( break; // We don't care about any other operators. // Fall through intentional - //case BinaryOperator::AddAssign: // Common false positive - case BinaryOperator::SubAssign: // Check only if unsigned - case BinaryOperator::MulAssign: - case BinaryOperator::DivAssign: - case BinaryOperator::AndAssign: - //case BinaryOperator::OrAssign: // Common false positive - //case BinaryOperator::XorAssign: // Common false positive - case BinaryOperator::ShlAssign: - case BinaryOperator::ShrAssign: - case BinaryOperator::Add: - case BinaryOperator::Sub: - case BinaryOperator::Mul: - case BinaryOperator::Div: - case BinaryOperator::And: - case BinaryOperator::Or: - case BinaryOperator::Xor: - case BinaryOperator::Shl: - case BinaryOperator::Shr: - case BinaryOperator::LOr: - case BinaryOperator::LAnd: + //case BO_AddAssign: // Common false positive + case BO_SubAssign: // Check only if unsigned + case BO_MulAssign: + case BO_DivAssign: + case BO_AndAssign: + //case BO_OrAssign: // Common false positive + //case BO_XorAssign: // Common false positive + case BO_ShlAssign: + case BO_ShrAssign: + case BO_Add: + case BO_Sub: + case BO_Mul: + case BO_Div: + case BO_And: + case BO_Or: + case BO_Xor: + case BO_Shl: + case BO_Shr: + case BO_LOr: + case BO_LAnd: if (!LHSVal.isConstant(0) || LHSContainsFalsePositive) break; UpdateAssumption(A, LHSis0); @@ -351,7 +351,7 @@ void IdempotentOperationChecker::VisitEndAnalysis(ExplodedGraph &G, llvm::raw_svector_ostream os(buf); switch (A) { case Equal: - if (B->getOpcode() == BinaryOperator::Assign) + if (B->getOpcode() == BO_Assign) os << "Assigned value is always the same as the existing value"; else os << "Both operands to '" << B->getOpcodeStr() @@ -577,7 +577,7 @@ bool IdempotentOperationChecker::CanVary(const Expr *Ex, const UnaryOperator *U = cast(Ex); // Handle trivial case first switch (U->getOpcode()) { - case UnaryOperator::Extension: + case UO_Extension: return false; default: return CanVary(U->getSubExpr(), AC); diff --git a/lib/Checker/MallocChecker.cpp b/lib/Checker/MallocChecker.cpp index 6e7faa7c07..3224f7bb2e 100644 --- a/lib/Checker/MallocChecker.cpp +++ b/lib/Checker/MallocChecker.cpp @@ -557,7 +557,7 @@ void MallocChecker::CallocMem(CheckerContext &C, const CallExpr *CE) { SVal Count = state->getSVal(CE->getArg(0)); SVal EleSize = state->getSVal(CE->getArg(1)); - SVal TotalSize = SVator.EvalBinOp(state, BinaryOperator::Mul, Count, EleSize, + SVal TotalSize = SVator.EvalBinOp(state, BO_Mul, Count, EleSize, ValMgr.getContext().getSizeType()); SVal Zero = ValMgr.makeZeroVal(ValMgr.getContext().CharTy); diff --git a/lib/Checker/PointerArithChecker.cpp b/lib/Checker/PointerArithChecker.cpp index ed60c42613..cbac423b46 100644 --- a/lib/Checker/PointerArithChecker.cpp +++ b/lib/Checker/PointerArithChecker.cpp @@ -36,8 +36,7 @@ void *PointerArithChecker::getTag() { void PointerArithChecker::PreVisitBinaryOperator(CheckerContext &C, const BinaryOperator *B) { - if (B->getOpcode() != BinaryOperator::Sub && - B->getOpcode() != BinaryOperator::Add) + if (B->getOpcode() != BO_Sub && B->getOpcode() != BO_Add) return; const GRState *state = C.getState(); diff --git a/lib/Checker/PointerSubChecker.cpp b/lib/Checker/PointerSubChecker.cpp index bc0fd24d19..d64b6ae3fe 100644 --- a/lib/Checker/PointerSubChecker.cpp +++ b/lib/Checker/PointerSubChecker.cpp @@ -39,7 +39,7 @@ void PointerSubChecker::PreVisitBinaryOperator(CheckerContext &C, const BinaryOperator *B) { // When doing pointer subtraction, if the two pointers do not point to the // same memory chunk, emit a warning. - if (B->getOpcode() != BinaryOperator::Sub) + if (B->getOpcode() != BO_Sub) return; const GRState *state = C.getState(); diff --git a/lib/Checker/RegionStore.cpp b/lib/Checker/RegionStore.cpp index e232e03499..595fb6f19b 100644 --- a/lib/Checker/RegionStore.cpp +++ b/lib/Checker/RegionStore.cpp @@ -798,8 +798,8 @@ SVal RegionStoreManager::EvalBinOp(BinaryOperator::Opcode Op, Loc L, NonLoc R, default: // Handle it normally. break; - case BinaryOperator::Add: - case BinaryOperator::Sub: + case BO_Add: + case BO_Sub: // FIXME: does this need to be casted to match resultTy? return L; } diff --git a/lib/Checker/SVals.cpp b/lib/Checker/SVals.cpp index 3248b0fea2..97ba74e948 100644 --- a/lib/Checker/SVals.cpp +++ b/lib/Checker/SVals.cpp @@ -250,8 +250,8 @@ SVal loc::ConcreteInt::EvalBinOp(BasicValueFactory& BasicVals, BinaryOperator::Opcode Op, const loc::ConcreteInt& R) const { - assert (Op == BinaryOperator::Add || Op == BinaryOperator::Sub || - (Op >= BinaryOperator::LT && Op <= BinaryOperator::NE)); + assert (Op == BO_Add || Op == BO_Sub || + (Op >= BO_LT && Op <= BO_NE)); const llvm::APSInt* X = BasicVals.EvaluateAPSInt(Op, getValue(), R.getValue()); diff --git a/lib/Checker/SValuator.cpp b/lib/Checker/SValuator.cpp index a7e15fc3fd..273e5742a8 100644 --- a/lib/Checker/SValuator.cpp +++ b/lib/Checker/SValuator.cpp @@ -37,7 +37,7 @@ SVal SValuator::EvalBinOp(const GRState *ST, BinaryOperator::Opcode Op, if (isa(R)) { // Support pointer arithmetic where the addend is on the left // and the pointer on the right. - assert(Op == BinaryOperator::Add); + assert(Op == BO_Add); // Commute the operands. return EvalBinOpLN(ST, Op, cast(R), cast(L), T); @@ -49,7 +49,7 @@ SVal SValuator::EvalBinOp(const GRState *ST, BinaryOperator::Opcode Op, DefinedOrUnknownSVal SValuator::EvalEQ(const GRState *ST, DefinedOrUnknownSVal L, DefinedOrUnknownSVal R) { - return cast(EvalBinOp(ST, BinaryOperator::EQ, L, R, + return cast(EvalBinOp(ST, BO_EQ, L, R, ValMgr.getContext().IntTy)); } diff --git a/lib/Checker/SimpleConstraintManager.cpp b/lib/Checker/SimpleConstraintManager.cpp index cc26a12ea4..04496e1e33 100644 --- a/lib/Checker/SimpleConstraintManager.cpp +++ b/lib/Checker/SimpleConstraintManager.cpp @@ -31,17 +31,17 @@ bool SimpleConstraintManager::canReasonAbout(SVal X) const { if (const SymIntExpr *SIE = dyn_cast(SE)) { switch (SIE->getOpcode()) { // We don't reason yet about bitwise-constraints on symbolic values. - case BinaryOperator::And: - case BinaryOperator::Or: - case BinaryOperator::Xor: + case BO_And: + case BO_Or: + case BO_Xor: return false; // We don't reason yet about these arithmetic constraints on // symbolic values. - case BinaryOperator::Mul: - case BinaryOperator::Div: - case BinaryOperator::Rem: - case BinaryOperator::Shl: - case BinaryOperator::Shr: + case BO_Mul: + case BO_Div: + case BO_Rem: + case BO_Shl: + case BO_Shr: return false; // All other cases. default: @@ -125,12 +125,12 @@ static BinaryOperator::Opcode NegateComparison(BinaryOperator::Opcode op) { switch (op) { default: assert(false && "Invalid opcode."); - case BinaryOperator::LT: return BinaryOperator::GE; - case BinaryOperator::GT: return BinaryOperator::LE; - case BinaryOperator::LE: return BinaryOperator::GT; - case BinaryOperator::GE: return BinaryOperator::LT; - case BinaryOperator::EQ: return BinaryOperator::NE; - case BinaryOperator::NE: return BinaryOperator::EQ; + case BO_LT: return BO_GE; + case BO_GT: return BO_LE; + case BO_LE: return BO_GT; + case BO_GE: return BO_LT; + case BO_EQ: return BO_NE; + case BO_NE: return BO_EQ; } } @@ -178,7 +178,7 @@ const GRState *SimpleConstraintManager::AssumeAux(const GRState *state, if (!BinaryOperator::isComparisonOp(op)) { QualType T = SymMgr.getType(SE); const llvm::APSInt &zero = BasicVals.getValue(0, T); - op = (Assumption ? BinaryOperator::NE : BinaryOperator::EQ); + op = (Assumption ? BO_NE : BO_EQ); return AssumeSymRel(state, SE, op, zero); } @@ -238,10 +238,10 @@ const GRState *SimpleConstraintManager::AssumeSymRel(const GRState *state, // Get the constant out of the expression "($sym+constant1)". switch (SE->getOpcode()) { - case BinaryOperator::Add: + case BO_Add: Adjustment = SE->getRHS(); break; - case BinaryOperator::Sub: + case BO_Sub: Adjustment = -SE->getRHS(); break; default: @@ -276,22 +276,22 @@ const GRState *SimpleConstraintManager::AssumeSymRel(const GRState *state, // No logic yet for other operators. Assume the constraint is feasible. return state; - case BinaryOperator::EQ: + case BO_EQ: return AssumeSymEQ(state, Sym, ConvertedInt, Adjustment); - case BinaryOperator::NE: + case BO_NE: return AssumeSymNE(state, Sym, ConvertedInt, Adjustment); - case BinaryOperator::GT: + case BO_GT: return AssumeSymGT(state, Sym, ConvertedInt, Adjustment); - case BinaryOperator::GE: + case BO_GE: return AssumeSymGE(state, Sym, ConvertedInt, Adjustment); - case BinaryOperator::LT: + case BO_LT: return AssumeSymLT(state, Sym, ConvertedInt, Adjustment); - case BinaryOperator::LE: + case BO_LE: return AssumeSymLE(state, Sym, ConvertedInt, Adjustment); } // end switch } diff --git a/lib/Checker/SimpleSValuator.cpp b/lib/Checker/SimpleSValuator.cpp index 433c3654fa..7650f09d39 100644 --- a/lib/Checker/SimpleSValuator.cpp +++ b/lib/Checker/SimpleSValuator.cpp @@ -168,12 +168,12 @@ static BinaryOperator::Opcode NegateComparison(BinaryOperator::Opcode op) { switch (op) { default: assert(false && "Invalid opcode."); - case BinaryOperator::LT: return BinaryOperator::GE; - case BinaryOperator::GT: return BinaryOperator::LE; - case BinaryOperator::LE: return BinaryOperator::GT; - case BinaryOperator::GE: return BinaryOperator::LT; - case BinaryOperator::EQ: return BinaryOperator::NE; - case BinaryOperator::NE: return BinaryOperator::EQ; + case BO_LT: return BO_GE; + case BO_GT: return BO_LE; + case BO_LE: return BO_GT; + case BO_GE: return BO_LT; + case BO_EQ: return BO_NE; + case BO_NE: return BO_EQ; } } @@ -181,12 +181,12 @@ static BinaryOperator::Opcode ReverseComparison(BinaryOperator::Opcode op) { switch (op) { default: assert(false && "Invalid opcode."); - case BinaryOperator::LT: return BinaryOperator::GT; - case BinaryOperator::GT: return BinaryOperator::LT; - case BinaryOperator::LE: return BinaryOperator::GE; - case BinaryOperator::GE: return BinaryOperator::LE; - case BinaryOperator::EQ: - case BinaryOperator::NE: + case BO_LT: return BO_GT; + case BO_GT: return BO_LT; + case BO_LE: return BO_GE; + case BO_GE: return BO_LE; + case BO_EQ: + case BO_NE: return op; } } @@ -202,14 +202,14 @@ SVal SimpleSValuator::MakeSymIntVal(const SymExpr *LHS, default: // We can't reduce this case; just treat it normally. break; - case BinaryOperator::Mul: + case BO_Mul: // a*0 and a*1 if (RHS == 0) return ValMgr.makeIntVal(0, resultTy); else if (RHS == 1) isIdempotent = true; break; - case BinaryOperator::Div: + case BO_Div: // a/0 and a/1 if (RHS == 0) // This is also handled elsewhere. @@ -217,7 +217,7 @@ SVal SimpleSValuator::MakeSymIntVal(const SymExpr *LHS, else if (RHS == 1) isIdempotent = true; break; - case BinaryOperator::Rem: + case BO_Rem: // a%0 and a%1 if (RHS == 0) // This is also handled elsewhere. @@ -225,23 +225,23 @@ SVal SimpleSValuator::MakeSymIntVal(const SymExpr *LHS, else if (RHS == 1) return ValMgr.makeIntVal(0, resultTy); break; - case BinaryOperator::Add: - case BinaryOperator::Sub: - case BinaryOperator::Shl: - case BinaryOperator::Shr: - case BinaryOperator::Xor: + case BO_Add: + case BO_Sub: + case BO_Shl: + case BO_Shr: + case BO_Xor: // a+0, a-0, a<<0, a>>0, a^0 if (RHS == 0) isIdempotent = true; break; - case BinaryOperator::And: + case BO_And: // a&0 and a&(~0) if (RHS == 0) return ValMgr.makeIntVal(0, resultTy); else if (RHS.isAllOnesValue()) isIdempotent = true; break; - case BinaryOperator::Or: + case BO_Or: // a|0 and a|(~0) if (RHS == 0) isIdempotent = true; @@ -275,19 +275,19 @@ SVal SimpleSValuator::EvalBinOpNN(const GRState *state, switch (op) { default: break; - case BinaryOperator::EQ: - case BinaryOperator::LE: - case BinaryOperator::GE: + case BO_EQ: + case BO_LE: + case BO_GE: return ValMgr.makeTruthVal(true, resultTy); - case BinaryOperator::LT: - case BinaryOperator::GT: - case BinaryOperator::NE: + case BO_LT: + case BO_GT: + case BO_NE: return ValMgr.makeTruthVal(false, resultTy); - case BinaryOperator::Xor: - case BinaryOperator::Sub: + case BO_Xor: + case BO_Sub: return ValMgr.makeIntVal(0, resultTy); - case BinaryOperator::Or: - case BinaryOperator::And: + case BO_Or: + case BO_And: return EvalCastNL(lhs, resultTy); } @@ -312,9 +312,9 @@ SVal SimpleSValuator::EvalBinOpNN(const GRState *state, } default: switch (op) { - case BinaryOperator::EQ: + case BO_EQ: return ValMgr.makeTruthVal(false, resultTy); - case BinaryOperator::NE: + case BO_NE: return ValMgr.makeTruthVal(true, resultTy); default: // This case also handles pointer arithmetic. @@ -333,7 +333,7 @@ SVal SimpleSValuator::EvalBinOpNN(const GRState *state, return UnknownVal(); // Is this a logical not? (!x is represented as x == 0.) - if (op == BinaryOperator::EQ && rhs.isZeroConstant()) { + if (op == BO_EQ && rhs.isZeroConstant()) { // We know how to negate certain expressions. Simplify them here. BinaryOperator::Opcode opc = symIntExpr->getOpcode(); @@ -342,34 +342,34 @@ SVal SimpleSValuator::EvalBinOpNN(const GRState *state, // We don't know how to negate this operation. // Just handle it as if it were a normal comparison to 0. break; - case BinaryOperator::LAnd: - case BinaryOperator::LOr: + case BO_LAnd: + case BO_LOr: assert(false && "Logical operators handled by branching logic."); return UnknownVal(); - case BinaryOperator::Assign: - case BinaryOperator::MulAssign: - case BinaryOperator::DivAssign: - case BinaryOperator::RemAssign: - case BinaryOperator::AddAssign: - case BinaryOperator::SubAssign: - case BinaryOperator::ShlAssign: - case BinaryOperator::ShrAssign: - case BinaryOperator::AndAssign: - case BinaryOperator::XorAssign: - case BinaryOperator::OrAssign: - case BinaryOperator::Comma: + case BO_Assign: + case BO_MulAssign: + case BO_DivAssign: + case BO_RemAssign: + case BO_AddAssign: + case BO_SubAssign: + case BO_ShlAssign: + case BO_ShrAssign: + case BO_AndAssign: + case BO_XorAssign: + case BO_OrAssign: + case BO_Comma: assert(false && "'=' and ',' operators handled by GRExprEngine."); return UnknownVal(); - case BinaryOperator::PtrMemD: - case BinaryOperator::PtrMemI: + case BO_PtrMemD: + case BO_PtrMemI: assert(false && "Pointer arithmetic not handled here."); return UnknownVal(); - case BinaryOperator::LT: - case BinaryOperator::GT: - case BinaryOperator::LE: - case BinaryOperator::GE: - case BinaryOperator::EQ: - case BinaryOperator::NE: + case BO_LT: + case BO_GT: + case BO_LE: + case BO_GE: + case BO_EQ: + case BO_NE: // Negate the comparison and make a value. opc = NegateComparison(opc); assert(symIntExpr->getType(ValMgr.getContext()) == resultTy); @@ -402,9 +402,9 @@ SVal SimpleSValuator::EvalBinOpNN(const GRState *state, const llvm::APSInt *newRHS; if (lop == op) - newRHS = BVF.EvaluateAPSInt(BinaryOperator::Add, first, second); + newRHS = BVF.EvaluateAPSInt(BO_Add, first, second); else - newRHS = BVF.EvaluateAPSInt(BinaryOperator::Sub, first, second); + newRHS = BVF.EvaluateAPSInt(BO_Sub, first, second); return MakeSymIntVal(symIntExpr->getLHS(), lop, *newRHS, resultTy); } } @@ -429,26 +429,26 @@ SVal SimpleSValuator::EvalBinOpNN(const GRState *state, lhs = tmp; switch (op) { - case BinaryOperator::LT: - case BinaryOperator::GT: - case BinaryOperator::LE: - case BinaryOperator::GE: + case BO_LT: + case BO_GT: + case BO_LE: + case BO_GE: op = ReverseComparison(op); continue; - case BinaryOperator::EQ: - case BinaryOperator::NE: - case BinaryOperator::Add: - case BinaryOperator::Mul: - case BinaryOperator::And: - case BinaryOperator::Xor: - case BinaryOperator::Or: + case BO_EQ: + case BO_NE: + case BO_Add: + case BO_Mul: + case BO_And: + case BO_Xor: + case BO_Or: continue; - case BinaryOperator::Shr: + case BO_Shr: if (lhsValue.isAllOnesValue() && lhsValue.isSigned()) // At this point lhs and rhs have been swapped. return rhs; // FALL-THROUGH - case BinaryOperator::Shl: + case BO_Shl: if (lhsValue == 0) // At this point lhs and rhs have been swapped. return rhs; @@ -525,7 +525,7 @@ SVal SimpleSValuator::EvalBinOpLL(const GRState *state, // calling this function with another operation (PR7527). We don't attempt to // model this for now, but it could be useful, particularly when the // "location" is actually an integer value that's been passed through a void*. - if (!(BinaryOperator::isComparisonOp(op) || op == BinaryOperator::Sub)) + if (!(BinaryOperator::isComparisonOp(op) || op == BO_Sub)) return UnknownVal(); // Special cases for when both sides are identical. @@ -534,15 +534,15 @@ SVal SimpleSValuator::EvalBinOpLL(const GRState *state, default: assert(false && "Unimplemented operation for two identical values"); return UnknownVal(); - case BinaryOperator::Sub: + case BO_Sub: return ValMgr.makeZeroVal(resultTy); - case BinaryOperator::EQ: - case BinaryOperator::LE: - case BinaryOperator::GE: + case BO_EQ: + case BO_LE: + case BO_GE: return ValMgr.makeTruthVal(true, resultTy); - case BinaryOperator::NE: - case BinaryOperator::LT: - case BinaryOperator::GT: + case BO_NE: + case BO_LT: + case BO_GT: return ValMgr.makeTruthVal(false, resultTy); } } @@ -558,15 +558,15 @@ SVal SimpleSValuator::EvalBinOpLL(const GRState *state, switch (op) { default: break; - case BinaryOperator::Sub: + case BO_Sub: return EvalCastL(lhs, resultTy); - case BinaryOperator::EQ: - case BinaryOperator::LE: - case BinaryOperator::LT: + case BO_EQ: + case BO_LE: + case BO_LT: return ValMgr.makeTruthVal(false, resultTy); - case BinaryOperator::NE: - case BinaryOperator::GT: - case BinaryOperator::GE: + case BO_NE: + case BO_GT: + case BO_GE: return ValMgr.makeTruthVal(true, resultTy); } } @@ -609,13 +609,13 @@ SVal SimpleSValuator::EvalBinOpLL(const GRState *state, switch (op) { default: break; - case BinaryOperator::EQ: - case BinaryOperator::GT: - case BinaryOperator::GE: + case BO_EQ: + case BO_GT: + case BO_GE: return ValMgr.makeTruthVal(false, resultTy); - case BinaryOperator::NE: - case BinaryOperator::LT: - case BinaryOperator::LE: + case BO_NE: + case BO_LT: + case BO_LE: return ValMgr.makeTruthVal(true, resultTy); } } @@ -639,15 +639,15 @@ SVal SimpleSValuator::EvalBinOpLL(const GRState *state, switch (op) { default: break; - case BinaryOperator::Sub: + case BO_Sub: return EvalCastL(lhs, resultTy); - case BinaryOperator::EQ: - case BinaryOperator::LT: - case BinaryOperator::LE: + case BO_EQ: + case BO_LT: + case BO_LE: return ValMgr.makeTruthVal(false, resultTy); - case BinaryOperator::NE: - case BinaryOperator::GT: - case BinaryOperator::GE: + case BO_NE: + case BO_GT: + case BO_GE: return ValMgr.makeTruthVal(true, resultTy); } } @@ -675,9 +675,9 @@ SVal SimpleSValuator::EvalBinOpLL(const GRState *state, switch (op) { default: return UnknownVal(); - case BinaryOperator::EQ: + case BO_EQ: return ValMgr.makeTruthVal(false, resultTy); - case BinaryOperator::NE: + case BO_NE: return ValMgr.makeTruthVal(true, resultTy); } } @@ -737,17 +737,17 @@ SVal SimpleSValuator::EvalBinOpLL(const GRState *state, switch (op) { default: return UnknownVal(); - case BinaryOperator::LT: + case BO_LT: return ValMgr.makeTruthVal(left < right, resultTy); - case BinaryOperator::GT: + case BO_GT: return ValMgr.makeTruthVal(left > right, resultTy); - case BinaryOperator::LE: + case BO_LE: return ValMgr.makeTruthVal(left <= right, resultTy); - case BinaryOperator::GE: + case BO_GE: return ValMgr.makeTruthVal(left >= right, resultTy); - case BinaryOperator::EQ: + case BO_EQ: return ValMgr.makeTruthVal(left == right, resultTy); - case BinaryOperator::NE: + case BO_NE: return ValMgr.makeTruthVal(left != right, resultTy); } } @@ -785,16 +785,16 @@ SVal SimpleSValuator::EvalBinOpLL(const GRState *state, // We know for sure that the two fields are not the same, since that // would have given us the same SVal. - if (op == BinaryOperator::EQ) + if (op == BO_EQ) return ValMgr.makeTruthVal(false, resultTy); - if (op == BinaryOperator::NE) + if (op == BO_NE) return ValMgr.makeTruthVal(true, resultTy); // Iterate through the fields and see which one comes first. // [C99 6.7.2.1.13] "Within a structure object, the non-bit-field // members and the units in which bit-fields reside have addresses that // increase in the order in which they are declared." - bool leftFirst = (op == BinaryOperator::LT || op == BinaryOperator::LE); + bool leftFirst = (op == BO_LT || op == BO_LE); for (RecordDecl::field_iterator I = RD->field_begin(), E = RD->field_end(); I!=E; ++I) { if (*I == LeftFD) diff --git a/lib/Checker/SymbolManager.cpp b/lib/Checker/SymbolManager.cpp index f94e32cf15..7ab356d473 100644 --- a/lib/Checker/SymbolManager.cpp +++ b/lib/Checker/SymbolManager.cpp @@ -28,22 +28,22 @@ static void print(llvm::raw_ostream& os, BinaryOperator::Opcode Op) { default: assert(false && "operator printing not implemented"); break; - case BinaryOperator::Mul: os << '*' ; break; - case BinaryOperator::Div: os << '/' ; break; - case BinaryOperator::Rem: os << '%' ; break; - case BinaryOperator::Add: os << '+' ; break; - case BinaryOperator::Sub: os << '-' ; break; - case BinaryOperator::Shl: os << "<<" ; break; - case BinaryOperator::Shr: os << ">>" ; break; - case BinaryOperator::LT: os << "<" ; break; - case BinaryOperator::GT: os << '>' ; break; - case BinaryOperator::LE: os << "<=" ; break; - case BinaryOperator::GE: os << ">=" ; break; - case BinaryOperator::EQ: os << "==" ; break; - case BinaryOperator::NE: os << "!=" ; break; - case BinaryOperator::And: os << '&' ; break; - case BinaryOperator::Xor: os << '^' ; break; - case BinaryOperator::Or: os << '|' ; break; + case BO_Mul: os << '*' ; break; + case BO_Div: os << '/' ; break; + case BO_Rem: os << '%' ; break; + case BO_Add: os << '+' ; break; + case BO_Sub: os << '-' ; break; + case BO_Shl: os << "<<" ; break; + case BO_Shr: os << ">>" ; break; + case BO_LT: os << "<" ; break; + case BO_GT: os << '>' ; break; + case BO_LE: os << "<=" ; break; + case BO_GE: os << ">=" ; break; + case BO_EQ: os << "==" ; break; + case BO_NE: os << "!=" ; break; + case BO_And: os << '&' ; break; + case BO_Xor: os << '^' ; break; + case BO_Or: os << '|' ; break; } } diff --git a/lib/Checker/UnixAPIChecker.cpp b/lib/Checker/UnixAPIChecker.cpp index e9b8f0966a..de7346d627 100644 --- a/lib/Checker/UnixAPIChecker.cpp +++ b/lib/Checker/UnixAPIChecker.cpp @@ -100,7 +100,7 @@ static void CheckOpen(CheckerContext &C, UnixAPIChecker &UC, NonLoc ocreateFlag = cast(C.getValueManager().makeIntVal(UC.Val_O_CREAT.getValue(), oflagsEx->getType())); - SVal maskedFlagsUC = C.getSValuator().EvalBinOpNN(state, BinaryOperator::And, + SVal maskedFlagsUC = C.getSValuator().EvalBinOpNN(state, BO_And, oflags, ocreateFlag, oflagsEx->getType()); if (maskedFlagsUC.isUnknownOrUndef()) diff --git a/lib/Checker/VLASizeChecker.cpp b/lib/Checker/VLASizeChecker.cpp index 936991d613..0800b8be18 100644 --- a/lib/Checker/VLASizeChecker.cpp +++ b/lib/Checker/VLASizeChecker.cpp @@ -117,7 +117,7 @@ void VLASizeChecker::PreVisitDeclStmt(CheckerContext &C, const DeclStmt *DS) { SVal EleSizeVal = ValMgr.makeIntVal(EleSize.getQuantity(), SizeTy); // Multiply the array length by the element size. - SVal ArraySizeVal = SV.EvalBinOpNN(state, BinaryOperator::Mul, ArrayLength, + SVal ArraySizeVal = SV.EvalBinOpNN(state, BO_Mul, ArrayLength, cast(EleSizeVal), SizeTy); // Finally, Assume that the array's extent matches the given size. diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp index 1dceb32a5c..5feca9d2e0 100644 --- a/lib/CodeGen/CGBlocks.cpp +++ b/lib/CodeGen/CGBlocks.cpp @@ -337,7 +337,7 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) { SourceLocation()); if (VD->getType()->isReferenceType()) { E = new (getContext()) - UnaryOperator(const_cast(E), UnaryOperator::AddrOf, + UnaryOperator(const_cast(E), UO_AddrOf, getContext().getPointerType(E->getType()), SourceLocation()); } @@ -347,7 +347,7 @@ llvm::Value *CodeGenFunction::BuildBlockLiteralTmp(const BlockExpr *BE) { if (BDRE->isByRef()) { E = new (getContext()) - UnaryOperator(const_cast(E), UnaryOperator::AddrOf, + UnaryOperator(const_cast(E), UO_AddrOf, getContext().getPointerType(E->getType()), SourceLocation()); } diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index cf7d01bcd0..f6cf5920be 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -216,8 +216,8 @@ EmitExprForReferenceBinding(CodeGenFunction& CGF, const Expr* E, } if (const CastExpr *CE = dyn_cast(E)) { - if ((CE->getCastKind() == CastExpr::CK_DerivedToBase || - CE->getCastKind() == CastExpr::CK_UncheckedDerivedToBase) && + if ((CE->getCastKind() == CK_DerivedToBase || + CE->getCastKind() == CK_UncheckedDerivedToBase) && E->getType()->isRecordType()) { E = CE->getSubExpr(); CXXRecordDecl *Derived @@ -226,7 +226,7 @@ EmitExprForReferenceBinding(CodeGenFunction& CGF, const Expr* E, continue; } - if (CE->getCastKind() == CastExpr::CK_NoOp) { + if (CE->getCastKind() == CK_NoOp) { E = CE->getSubExpr(); continue; } @@ -1207,13 +1207,13 @@ LValue CodeGenFunction::EmitBlockDeclRefLValue(const BlockDeclRefExpr *E) { LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) { // __extension__ doesn't affect lvalue-ness. - if (E->getOpcode() == UnaryOperator::Extension) + if (E->getOpcode() == UO_Extension) return EmitLValue(E->getSubExpr()); QualType ExprTy = getContext().getCanonicalType(E->getSubExpr()->getType()); switch (E->getOpcode()) { default: assert(0 && "Unknown unary operator lvalue!"); - case UnaryOperator::Deref: { + case UO_Deref: { QualType T = E->getSubExpr()->getType()->getPointeeType(); assert(!T.isNull() && "CodeGenFunction::EmitUnaryOpLValue: Illegal type"); @@ -1230,18 +1230,18 @@ LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) { LV.setNonGC(!E->isOBJCGCCandidate(getContext())); return LV; } - case UnaryOperator::Real: - case UnaryOperator::Imag: { + case UO_Real: + case UO_Imag: { LValue LV = EmitLValue(E->getSubExpr()); - unsigned Idx = E->getOpcode() == UnaryOperator::Imag; + unsigned Idx = E->getOpcode() == UO_Imag; return MakeAddrLValue(Builder.CreateStructGEP(LV.getAddress(), Idx, "idx"), ExprTy); } - case UnaryOperator::PreInc: - case UnaryOperator::PreDec: { + case UO_PreInc: + case UO_PreDec: { LValue LV = EmitLValue(E->getSubExpr()); - bool isInc = E->getOpcode() == UnaryOperator::PreInc; + bool isInc = E->getOpcode() == UO_PreInc; if (E->getType()->isAnyComplexType()) EmitComplexPrePostIncDec(E, LV, isInc, true/*isPre*/); @@ -1340,7 +1340,7 @@ llvm::BasicBlock *CodeGenFunction::getTrapBB() { static const Expr *isSimpleArrayDecayOperand(const Expr *E) { // If this isn't just an array->pointer decay, bail out. const CastExpr *CE = dyn_cast(E); - if (CE == 0 || CE->getCastKind() != CastExpr::CK_ArrayToPointerDecay) + if (CE == 0 || CE->getCastKind() != CK_ArrayToPointerDecay) return 0; // If this is a decay from variable width array, bail out. @@ -1377,7 +1377,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) { if (CatchUndefined) { if (const ImplicitCastExpr *ICE = dyn_cast(E->getBase())){ if (const DeclRefExpr *DRE = dyn_cast(ICE->getSubExpr())) { - if (ICE->getCastKind() == CastExpr::CK_ArrayToPointerDecay) { + if (ICE->getCastKind() == CK_ArrayToPointerDecay) { if (const ConstantArrayType *CAT = getContext().getAsConstantArrayType(DRE->getType())) { llvm::APInt Size = CAT->getSize(); @@ -1745,10 +1745,10 @@ CodeGenFunction::EmitConditionalOperatorLValue(const ConditionalOperator* E) { /// cast from scalar to union. LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { switch (E->getCastKind()) { - case CastExpr::CK_ToVoid: + case CK_ToVoid: return EmitUnsupportedLValue(E, "unexpected cast lvalue"); - case CastExpr::CK_NoOp: + case CK_NoOp: if (E->getSubExpr()->Classify(getContext()).getKind() != Expr::Classification::CL_PRValue) { LValue LV = EmitLValue(E->getSubExpr()); @@ -1763,22 +1763,22 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { } // Fall through to synthesize a temporary. - case CastExpr::CK_Unknown: - case CastExpr::CK_BitCast: - case CastExpr::CK_ArrayToPointerDecay: - case CastExpr::CK_FunctionToPointerDecay: - case CastExpr::CK_NullToMemberPointer: - case CastExpr::CK_IntegralToPointer: - case CastExpr::CK_PointerToIntegral: - case CastExpr::CK_VectorSplat: - case CastExpr::CK_IntegralCast: - case CastExpr::CK_IntegralToFloating: - case CastExpr::CK_FloatingToIntegral: - case CastExpr::CK_FloatingCast: - case CastExpr::CK_DerivedToBaseMemberPointer: - case CastExpr::CK_BaseToDerivedMemberPointer: - case CastExpr::CK_MemberPointerToBoolean: - case CastExpr::CK_AnyPointerToBlockPointerCast: { + case CK_Unknown: + case CK_BitCast: + case CK_ArrayToPointerDecay: + case CK_FunctionToPointerDecay: + case CK_NullToMemberPointer: + case CK_IntegralToPointer: + case CK_PointerToIntegral: + case CK_VectorSplat: + case CK_IntegralCast: + case CK_IntegralToFloating: + case CK_FloatingToIntegral: + case CK_FloatingCast: + case CK_DerivedToBaseMemberPointer: + case CK_BaseToDerivedMemberPointer: + case CK_MemberPointerToBoolean: + case CK_AnyPointerToBlockPointerCast: { // These casts only produce lvalues when we're binding a reference to a // temporary realized from a (converted) pure rvalue. Emit the expression // as a value, copy it into a temporary, and return an lvalue referring to @@ -1788,20 +1788,20 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { return MakeAddrLValue(V, E->getType()); } - case CastExpr::CK_Dynamic: { + case CK_Dynamic: { LValue LV = EmitLValue(E->getSubExpr()); llvm::Value *V = LV.getAddress(); const CXXDynamicCastExpr *DCE = cast(E); return MakeAddrLValue(EmitDynamicCast(V, DCE), E->getType()); } - case CastExpr::CK_ConstructorConversion: - case CastExpr::CK_UserDefinedConversion: - case CastExpr::CK_AnyPointerToObjCPointerCast: + case CK_ConstructorConversion: + case CK_UserDefinedConversion: + case CK_AnyPointerToObjCPointerCast: return EmitLValue(E->getSubExpr()); - case CastExpr::CK_UncheckedDerivedToBase: - case CastExpr::CK_DerivedToBase: { + case CK_UncheckedDerivedToBase: + case CK_DerivedToBase: { const RecordType *DerivedClassTy = E->getSubExpr()->getType()->getAs(); CXXRecordDecl *DerivedClassDecl = @@ -1825,9 +1825,9 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { return MakeAddrLValue(Base, E->getType()); } - case CastExpr::CK_ToUnion: + case CK_ToUnion: return EmitAggExprToLValue(E); - case CastExpr::CK_BaseToDerived: { + case CK_BaseToDerived: { const RecordType *DerivedClassTy = E->getType()->getAs(); CXXRecordDecl *DerivedClassDecl = cast(DerivedClassTy->getDecl()); @@ -1842,7 +1842,7 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { return MakeAddrLValue(Derived, E->getType()); } - case CastExpr::CK_LValueBitCast: { + case CK_LValueBitCast: { // This must be a reinterpret_cast (or c-style equivalent). const ExplicitCastExpr *CE = cast(E); @@ -1851,7 +1851,7 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { ConvertType(CE->getTypeAsWritten())); return MakeAddrLValue(V, E->getType()); } - case CastExpr::CK_ObjCObjectLValueCast: { + case CK_ObjCObjectLValueCast: { LValue LV = EmitLValue(E->getSubExpr()); QualType ToType = getContext().getLValueReferenceType(E->getType()); llvm::Value *V = Builder.CreateBitCast(LV.getAddress(), @@ -1916,19 +1916,19 @@ RValue CodeGenFunction::EmitCallExpr(const CallExpr *E, LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) { // Comma expressions just emit their LHS then their RHS as an l-value. - if (E->getOpcode() == BinaryOperator::Comma) { + if (E->getOpcode() == BO_Comma) { EmitAnyExpr(E->getLHS()); EnsureInsertPoint(); return EmitLValue(E->getRHS()); } - if (E->getOpcode() == BinaryOperator::PtrMemD || - E->getOpcode() == BinaryOperator::PtrMemI) + if (E->getOpcode() == BO_PtrMemD || + E->getOpcode() == BO_PtrMemI) return EmitPointerToDataMemberBinaryExpr(E); // Can only get l-value for binary operator expressions which are a // simple assignment of aggregate type. - if (E->getOpcode() != BinaryOperator::Assign) + if (E->getOpcode() != BO_Assign) return EmitUnsupportedLValue(E, "binary l-value expression"); if (!hasAggregateLLVMType(E->getType())) { @@ -2085,7 +2085,7 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType, llvm::Value *Callee, LValue CodeGenFunction:: EmitPointerToDataMemberBinaryExpr(const BinaryOperator *E) { llvm::Value *BaseV; - if (E->getOpcode() == BinaryOperator::PtrMemI) + if (E->getOpcode() == BO_PtrMemI) BaseV = EmitScalarExpr(E->getLHS()); else BaseV = EmitLValue(E->getLHS()).getAddress(); diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 89fea398d3..2d8e2b2b42 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -242,7 +242,7 @@ void AggExprEmitter::EmitFinalDestCopy(const Expr *E, LValue Src, bool Ignore) { //===----------------------------------------------------------------------===// void AggExprEmitter::VisitCastExpr(CastExpr *E) { - if (!DestPtr && E->getCastKind() != CastExpr::CK_Dynamic) { + if (!DestPtr && E->getCastKind() != CK_Dynamic) { Visit(E->getSubExpr()); return; } @@ -250,7 +250,7 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) { switch (E->getCastKind()) { default: assert(0 && "Unhandled cast kind!"); - case CastExpr::CK_Dynamic: { + case CK_Dynamic: { assert(isa(E) && "CK_Dynamic without a dynamic_cast?"); LValue LV = CGF.EmitCheckedLValue(E->getSubExpr()); // FIXME: Do we also need to handle property references here? @@ -264,7 +264,7 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) { break; } - case CastExpr::CK_ToUnion: { + case CK_ToUnion: { // GCC union extension QualType Ty = E->getSubExpr()->getType(); QualType PtrTy = CGF.getContext().getPointerType(Ty); @@ -275,26 +275,26 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) { break; } - case CastExpr::CK_DerivedToBase: - case CastExpr::CK_BaseToDerived: - case CastExpr::CK_UncheckedDerivedToBase: { + case CK_DerivedToBase: + case CK_BaseToDerived: + case CK_UncheckedDerivedToBase: { assert(0 && "cannot perform hierarchy conversion in EmitAggExpr: " "should have been unpacked before we got here"); break; } // FIXME: Remove the CK_Unknown check here. - case CastExpr::CK_Unknown: - case CastExpr::CK_NoOp: - case CastExpr::CK_UserDefinedConversion: - case CastExpr::CK_ConstructorConversion: + case CK_Unknown: + case CK_NoOp: + case CK_UserDefinedConversion: + case CK_ConstructorConversion: assert(CGF.getContext().hasSameUnqualifiedType(E->getSubExpr()->getType(), E->getType()) && "Implicit cast types must be compatible"); Visit(E->getSubExpr()); break; - case CastExpr::CK_LValueBitCast: + case CK_LValueBitCast: llvm_unreachable("there are no lvalue bit-casts on aggregates"); break; } @@ -337,8 +337,7 @@ void AggExprEmitter::VisitStmtExpr(const StmtExpr *E) { } void AggExprEmitter::VisitBinaryOperator(const BinaryOperator *E) { - if (E->getOpcode() == BinaryOperator::PtrMemD || - E->getOpcode() == BinaryOperator::PtrMemI) + if (E->getOpcode() == BO_PtrMemD || E->getOpcode() == BO_PtrMemI) VisitPointerToDataMemberBinaryOperator(E); else CGF.ErrorUnsupported(E, "aggregate binary expression"); diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index 35c65ab0e6..7fb6b3edc2 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -165,7 +165,7 @@ CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, // Emit the 'this' pointer. llvm::Value *This; - if (BO->getOpcode() == BinaryOperator::PtrMemI) + if (BO->getOpcode() == BO_PtrMemI) This = EmitScalarExpr(BaseExpr); else This = EmitLValue(BaseExpr).getAddress(); @@ -827,7 +827,7 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) { // to void*. const Expr *Arg = E->getArgument(); while (const ImplicitCastExpr *ICE = dyn_cast(Arg)) { - if (ICE->getCastKind() != CastExpr::CK_UserDefinedConversion && + if (ICE->getCastKind() != CK_UserDefinedConversion && ICE->getType()->isVoidPointerType()) Arg = ICE->getSubExpr(); else @@ -913,7 +913,7 @@ llvm::Value * CodeGenFunction::EmitCXXTypeidExpr(const CXXTypeidExpr *E) { // FIXME: PointerType->hasAttr() bool CanBeZero = false; if (UnaryOperator *UO = dyn_cast(subE->IgnoreParens())) - if (UO->getOpcode() == UnaryOperator::Deref) + if (UO->getOpcode() == UO_Deref) CanBeZero = true; if (CanBeZero) { llvm::BasicBlock *NonZeroBlock = createBasicBlock(); diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp index 0927319db7..79e9dd42ee 100644 --- a/lib/CodeGen/CGExprComplex.cpp +++ b/lib/CodeGen/CGExprComplex.cpp @@ -347,7 +347,7 @@ ComplexPairTy ComplexExprEmitter::EmitCast(CastExpr::CastKind CK, Expr *Op, // FIXME: We should be looking at all of the cast kinds here, not // cherry-picking the ones we have test cases for. - if (CK == CastExpr::CK_LValueBitCast) { + if (CK == CK_LValueBitCast) { llvm::Value *V = CGF.EmitLValue(Op).getAddress(); V = Builder.CreateBitCast(V, CGF.ConvertType(CGF.getContext().getPointerType(DestTy))); @@ -532,7 +532,7 @@ EmitCompoundAssign(const CompoundAssignOperator *E, // improve codegen a little. It is possible for the RHS to be complex or // scalar. OpInfo.Ty = E->getComputationResultType(); - OpInfo.RHS = EmitCast(CastExpr::CK_Unknown, E->getRHS(), OpInfo.Ty); + OpInfo.RHS = EmitCast(CK_Unknown, E->getRHS(), OpInfo.Ty); LValue LHS = CGF.EmitLValue(E->getLHS()); // We know the LHS is a complex lvalue. diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 0dcee6ef6a..a3a1feaff2 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -491,7 +491,7 @@ public: llvm::Constant *VisitCastExpr(CastExpr* E) { switch (E->getCastKind()) { - case CastExpr::CK_ToUnion: { + case CK_ToUnion: { // GCC cast to union extension assert(E->getType()->isUnionType() && "Destination type is not union type!"); @@ -526,12 +526,12 @@ public: llvm::StructType::get(C->getType()->getContext(), Types, false); return llvm::ConstantStruct::get(STy, Elts); } - case CastExpr::CK_NullToMemberPointer: { + case CK_NullToMemberPointer: { const MemberPointerType *MPT = E->getType()->getAs(); return CGM.getCXXABI().EmitNullMemberPointer(MPT); } - case CastExpr::CK_BaseToDerivedMemberPointer: { + case CK_BaseToDerivedMemberPointer: { Expr *SubExpr = E->getSubExpr(); llvm::Constant *C = CGM.EmitConstantExpr(SubExpr, SubExpr->getType(), CGF); @@ -540,7 +540,7 @@ public: return CGM.getCXXABI().EmitMemberPointerConversion(C, E); } - case CastExpr::CK_BitCast: + case CK_BitCast: // This must be a member function pointer cast. return Visit(E->getSubExpr()); diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index ec491f7240..dd881350c6 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -883,7 +883,7 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) { static bool ShouldNullCheckClassCastValue(const CastExpr *CE) { const Expr *E = CE->getSubExpr(); - if (CE->getCastKind() == CastExpr::CK_UncheckedDerivedToBase) + if (CE->getCastKind() == CK_UncheckedDerivedToBase) return false; if (isa(E)) { @@ -906,7 +906,7 @@ static bool ShouldNullCheckClassCastValue(const CastExpr *CE) { Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { Expr *E = CE->getSubExpr(); QualType DestTy = CE->getType(); - CastExpr::CastKind Kind = CE->getCastKind(); + CastKind Kind = CE->getCastKind(); if (!DestTy->isVoidType()) TestAndClearIgnoreResultAssign(); @@ -915,30 +915,30 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { // a default case, so the compiler will warn on a missing case. The cases // are in the same order as in the CastKind enum. switch (Kind) { - case CastExpr::CK_Unknown: + case CK_Unknown: // FIXME: All casts should have a known kind! //assert(0 && "Unknown cast kind!"); break; - case CastExpr::CK_LValueBitCast: - case CastExpr::CK_ObjCObjectLValueCast: { + case CK_LValueBitCast: + case CK_ObjCObjectLValueCast: { Value *V = EmitLValue(E).getAddress(); V = Builder.CreateBitCast(V, ConvertType(CGF.getContext().getPointerType(DestTy))); return EmitLoadOfLValue(CGF.MakeAddrLValue(V, DestTy), DestTy); } - case CastExpr::CK_AnyPointerToObjCPointerCast: - case CastExpr::CK_AnyPointerToBlockPointerCast: - case CastExpr::CK_BitCast: { + case CK_AnyPointerToObjCPointerCast: + case CK_AnyPointerToBlockPointerCast: + case CK_BitCast: { Value *Src = Visit(const_cast(E)); return Builder.CreateBitCast(Src, ConvertType(DestTy)); } - case CastExpr::CK_NoOp: - case CastExpr::CK_UserDefinedConversion: + case CK_NoOp: + case CK_UserDefinedConversion: return Visit(const_cast(E)); - case CastExpr::CK_BaseToDerived: { + case CK_BaseToDerived: { const CXXRecordDecl *DerivedClassDecl = DestTy->getCXXRecordDeclForPointerType(); @@ -946,8 +946,8 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { CE->path_begin(), CE->path_end(), ShouldNullCheckClassCastValue(CE)); } - case CastExpr::CK_UncheckedDerivedToBase: - case CastExpr::CK_DerivedToBase: { + case CK_UncheckedDerivedToBase: + case CK_DerivedToBase: { const RecordType *DerivedClassTy = E->getType()->getAs()->getPointeeType()->getAs(); CXXRecordDecl *DerivedClassDecl = @@ -957,16 +957,16 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { CE->path_begin(), CE->path_end(), ShouldNullCheckClassCastValue(CE)); } - case CastExpr::CK_Dynamic: { + case CK_Dynamic: { Value *V = Visit(const_cast(E)); const CXXDynamicCastExpr *DCE = cast(CE); return CGF.EmitDynamicCast(V, DCE); } - case CastExpr::CK_ToUnion: + case CK_ToUnion: assert(0 && "Should be unreachable!"); break; - case CastExpr::CK_ArrayToPointerDecay: { + case CK_ArrayToPointerDecay: { assert(E->getType()->isArrayType() && "Array to pointer decay must have array source type!"); @@ -984,10 +984,10 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { return V; } - case CastExpr::CK_FunctionToPointerDecay: + case CK_FunctionToPointerDecay: return EmitLValue(E).getAddress(); - case CastExpr::CK_NullToMemberPointer: { + case CK_NullToMemberPointer: { // If the subexpression's type is the C++0x nullptr_t, emit the // subexpression, which may have side effects. if (E->getType()->isNullPtrType()) @@ -997,8 +997,8 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { return CGF.CGM.getCXXABI().EmitNullMemberPointer(MPT); } - case CastExpr::CK_BaseToDerivedMemberPointer: - case CastExpr::CK_DerivedToBaseMemberPointer: { + case CK_BaseToDerivedMemberPointer: + case CK_DerivedToBaseMemberPointer: { Value *Src = Visit(E); // Note that the AST doesn't distinguish between checked and @@ -1011,11 +1011,11 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { } - case CastExpr::CK_ConstructorConversion: + case CK_ConstructorConversion: assert(0 && "Should be unreachable!"); break; - case CastExpr::CK_IntegralToPointer: { + case CK_IntegralToPointer: { Value *Src = Visit(const_cast(E)); // First, convert to the correct width so that we control the kind of @@ -1027,7 +1027,7 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { return Builder.CreateIntToPtr(IntResult, ConvertType(DestTy)); } - case CastExpr::CK_PointerToIntegral: { + case CK_PointerToIntegral: { Value *Src = Visit(const_cast(E)); // Handle conversion to bool correctly. @@ -1036,14 +1036,14 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { return Builder.CreatePtrToInt(Src, ConvertType(DestTy)); } - case CastExpr::CK_ToVoid: { + case CK_ToVoid: { if (E->Classify(CGF.getContext()).isGLValue()) CGF.EmitLValue(E); else CGF.EmitAnyExpr(E, 0, false, true); return 0; } - case CastExpr::CK_VectorSplat: { + case CK_VectorSplat: { const llvm::Type *DstTy = ConvertType(DestTy); Value *Elt = Visit(const_cast(E)); @@ -1062,13 +1062,13 @@ Value *ScalarExprEmitter::EmitCastExpr(CastExpr *CE) { llvm::Value *Yay = Builder.CreateShuffleVector(UnV, UnV, Mask, "splat"); return Yay; } - case CastExpr::CK_IntegralCast: - case CastExpr::CK_IntegralToFloating: - case CastExpr::CK_FloatingToIntegral: - case CastExpr::CK_FloatingCast: + case CK_IntegralCast: + case CK_IntegralToFloating: + case CK_FloatingToIntegral: + case CK_FloatingCast: return EmitScalarConversion(Visit(E), E->getType(), DestTy); - case CastExpr::CK_MemberPointerToBoolean: { + case CK_MemberPointerToBoolean: { llvm::Value *MemPtr = Visit(E); const MemberPointerType *MPT = E->getType()->getAs(); return CGF.CGM.getCXXABI().EmitMemberPointerIsNotNull(CGF, MemPtr, MPT); @@ -1192,7 +1192,7 @@ EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, BinOp.LHS = InVal; BinOp.RHS = NextVal; BinOp.Ty = E->getType(); - BinOp.Opcode = BinaryOperator::Add; + BinOp.Opcode = BO_Add; BinOp.E = E; NextVal = EmitOverflowCheckedBinOp(BinOp); break; @@ -1242,7 +1242,7 @@ Value *ScalarExprEmitter::VisitUnaryMinus(const UnaryOperator *E) { else BinOp.LHS = llvm::Constant::getNullValue(BinOp.RHS->getType()); BinOp.Ty = E->getType(); - BinOp.Opcode = BinaryOperator::Sub; + BinOp.Opcode = BO_Sub; BinOp.E = E; return EmitSub(BinOp); } @@ -1512,18 +1512,18 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) { unsigned OpID = 0; switch (Ops.Opcode) { - case BinaryOperator::Add: - case BinaryOperator::AddAssign: + case BO_Add: + case BO_AddAssign: OpID = 1; IID = llvm::Intrinsic::sadd_with_overflow; break; - case BinaryOperator::Sub: - case BinaryOperator::SubAssign: + case BO_Sub: + case BO_SubAssign: OpID = 2; IID = llvm::Intrinsic::ssub_with_overflow; break; - case BinaryOperator::Mul: - case BinaryOperator::MulAssign: + case BO_Mul: + case BO_MulAssign: OpID = 3; IID = llvm::Intrinsic::smul_with_overflow; break; @@ -1797,12 +1797,12 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc, Value *Result; QualType LHSTy = E->getLHS()->getType(); if (const MemberPointerType *MPT = LHSTy->getAs()) { - assert(E->getOpcode() == BinaryOperator::EQ || - E->getOpcode() == BinaryOperator::NE); + assert(E->getOpcode() == BO_EQ || + E->getOpcode() == BO_NE); Value *LHS = CGF.EmitScalarExpr(E->getLHS()); Value *RHS = CGF.EmitScalarExpr(E->getRHS()); Result = CGF.CGM.getCXXABI().EmitMemberPointerComparison( - CGF, LHS, RHS, MPT, E->getOpcode() == BinaryOperator::NE); + CGF, LHS, RHS, MPT, E->getOpcode() == BO_NE); } else if (!LHSTy->isAnyComplexType()) { Value *LHS = Visit(E->getLHS()); Value *RHS = Visit(E->getRHS()); @@ -1846,10 +1846,10 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc, LHS.second, RHS.second, "cmp.i"); } - if (E->getOpcode() == BinaryOperator::EQ) { + if (E->getOpcode() == BO_EQ) { Result = Builder.CreateAnd(ResultR, ResultI, "and.ri"); } else { - assert(E->getOpcode() == BinaryOperator::NE && + assert(E->getOpcode() == BO_NE && "Complex comparison other than == or != ?"); Result = Builder.CreateOr(ResultR, ResultI, "or.ri"); } @@ -2234,7 +2234,7 @@ LValue CodeGenFunction::EmitCompoundAssignOperatorLValue( Value *Result = 0; switch (E->getOpcode()) { #define COMPOUND_OP(Op) \ - case BinaryOperator::Op##Assign: \ + case BO_##Op##Assign: \ return Scalar.EmitCompoundAssignLValue(E, &ScalarExprEmitter::Emit##Op, \ Result) COMPOUND_OP(Mul); @@ -2249,28 +2249,28 @@ LValue CodeGenFunction::EmitCompoundAssignOperatorLValue( COMPOUND_OP(Or); #undef COMPOUND_OP - case BinaryOperator::PtrMemD: - case BinaryOperator::PtrMemI: - case BinaryOperator::Mul: - case BinaryOperator::Div: - case BinaryOperator::Rem: - case BinaryOperator::Add: - case BinaryOperator::Sub: - case BinaryOperator::Shl: - case BinaryOperator::Shr: - case BinaryOperator::LT: - case BinaryOperator::GT: - case BinaryOperator::LE: - case BinaryOperator::GE: - case BinaryOperator::EQ: - case BinaryOperator::NE: - case BinaryOperator::And: - case BinaryOperator::Xor: - case BinaryOperator::Or: - case BinaryOperator::LAnd: - case BinaryOperator::LOr: - case BinaryOperator::Assign: - case BinaryOperator::Comma: + case BO_PtrMemD: + case BO_PtrMemI: + case BO_Mul: + case BO_Div: + case BO_Rem: + case BO_Add: + case BO_Sub: + case BO_Shl: + case BO_Shr: + case BO_LT: + case BO_GT: + case BO_LE: + case BO_GE: + case BO_EQ: + case BO_NE: + case BO_And: + case BO_Xor: + case BO_Or: + case BO_LAnd: + case BO_LOr: + case BO_Assign: + case BO_Comma: assert(false && "Not valid compound assignment operators"); break; } diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index 1c12d7f1ad..6a6d63df8f 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -404,13 +404,13 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP, if (getContext().getCanonicalType(Ivar->getType()) != getContext().getCanonicalType(ArgDecl->getType())) { ImplicitCastExpr ArgCasted(ImplicitCastExpr::OnStack, - Ivar->getType(), CastExpr::CK_BitCast, &Arg, + Ivar->getType(), CK_BitCast, &Arg, VK_RValue); - BinaryOperator Assign(&IvarRef, &ArgCasted, BinaryOperator::Assign, + BinaryOperator Assign(&IvarRef, &ArgCasted, BO_Assign, Ivar->getType(), Loc); EmitStmt(&Assign); } else { - BinaryOperator Assign(&IvarRef, &Arg, BinaryOperator::Assign, + BinaryOperator Assign(&IvarRef, &Arg, BO_Assign, Ivar->getType(), Loc); EmitStmt(&Assign); } diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 2b20dd9066..13ad034a0d 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -455,7 +455,7 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond, if (const BinaryOperator *CondBOp = dyn_cast(Cond)) { // Handle X && Y in a condition. - if (CondBOp->getOpcode() == BinaryOperator::LAnd) { + if (CondBOp->getOpcode() == BO_LAnd) { // If we have "1 && X", simplify the code. "0 && X" would have constant // folded if the case was simple enough. if (ConstantFoldsToSimpleInteger(CondBOp->getLHS()) == 1) { @@ -482,7 +482,7 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond, EndConditionalBranch(); return; - } else if (CondBOp->getOpcode() == BinaryOperator::LOr) { + } else if (CondBOp->getOpcode() == BO_LOr) { // If we have "0 || X", simplify the code. "1 || X" would have constant // folded if the case was simple enough. if (ConstantFoldsToSimpleInteger(CondBOp->getLHS()) == -1) { @@ -514,7 +514,7 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond, if (const UnaryOperator *CondUOp = dyn_cast(Cond)) { // br(!x, t, f) -> br(x, f, t) - if (CondUOp->getOpcode() == UnaryOperator::LNot) + if (CondUOp->getOpcode() == UO_LNot) return EmitBranchOnBoolExpr(CondUOp->getSubExpr(), FalseBlock, TrueBlock); } diff --git a/lib/CodeGen/ItaniumCXXABI.cpp b/lib/CodeGen/ItaniumCXXABI.cpp index 5e1bb255c9..354e72fbd0 100644 --- a/lib/CodeGen/ItaniumCXXABI.cpp +++ b/lib/CodeGen/ItaniumCXXABI.cpp @@ -241,8 +241,8 @@ llvm::Value * ItaniumCXXABI::EmitMemberPointerConversion(CodeGenFunction &CGF, const CastExpr *E, llvm::Value *Src) { - assert(E->getCastKind() == CastExpr::CK_DerivedToBaseMemberPointer || - E->getCastKind() == CastExpr::CK_BaseToDerivedMemberPointer); + assert(E->getCastKind() == CK_DerivedToBaseMemberPointer || + E->getCastKind() == CK_BaseToDerivedMemberPointer); if (isa(Src)) return EmitMemberPointerConversion(cast(Src), E); @@ -257,7 +257,7 @@ ItaniumCXXABI::EmitMemberPointerConversion(CodeGenFunction &CGF, const CXXRecordDecl *DestDecl = DestTy->getClass()->getAsCXXRecordDecl(); bool DerivedToBase = - E->getCastKind() == CastExpr::CK_DerivedToBaseMemberPointer; + E->getCastKind() == CK_DerivedToBaseMemberPointer; const CXXRecordDecl *BaseDecl, *DerivedDecl; if (DerivedToBase) @@ -312,7 +312,7 @@ ItaniumCXXABI::EmitMemberPointerConversion(llvm::Constant *C, E->getType()->getAs(); bool DerivedToBase = - E->getCastKind() == CastExpr::CK_DerivedToBaseMemberPointer; + E->getCastKind() == CK_DerivedToBaseMemberPointer; const CXXRecordDecl *DerivedDecl; if (DerivedToBase) diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index e91c31bfd0..b3ba72d220 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -443,7 +443,7 @@ namespace { // Helper function: create a CStyleCastExpr with trivial type source info. CStyleCastExpr* NoTypeInfoCStyleCastExpr(ASTContext *Ctx, QualType Ty, - CastExpr::CastKind Kind, Expr *E) { + CastKind Kind, Expr *E) { TypeSourceInfo *TInfo = Ctx->getTrivialTypeSourceInfo(Ty, SourceLocation()); return CStyleCastExpr::Create(*Ctx, Ty, Kind, E, 0, TInfo, SourceLocation(), SourceLocation()); @@ -1330,7 +1330,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV, assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl"); QualType castT = Context->getPointerType(Context->getTagDeclType(RD)); CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, castT, - CastExpr::CK_Unknown, + CK_Unknown, IV->getBase()); // Don't forget the parens to enforce the proper binding. ParenExpr *PE = new (Context) ParenExpr(IV->getBase()->getLocStart(), @@ -1375,7 +1375,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV, assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl"); QualType castT = Context->getPointerType(Context->getTagDeclType(RD)); CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, castT, - CastExpr::CK_Unknown, + CK_Unknown, IV->getBase()); // Don't forget the parens to enforce the proper binding. ParenExpr *PE = new (Context) ParenExpr(IV->getBase()->getLocStart(), @@ -1711,7 +1711,7 @@ Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) { std::string syncBuf; syncBuf += " objc_sync_exit("; Expr *syncExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(), - CastExpr::CK_Unknown, + CK_Unknown, S->getSynchExpr()); std::string syncExprBufS; llvm::raw_string_ostream syncExprBuf(syncExprBufS); @@ -2054,7 +2054,7 @@ CallExpr *RewriteObjC::SynthesizeCallToFunctionDecl( // Now, we cast the reference to a pointer to the objc_msgSend type. QualType pToFunc = Context->getPointerType(msgSendType); ImplicitCastExpr *ICE = - ImplicitCastExpr::Create(*Context, pToFunc, CastExpr::CK_Unknown, + ImplicitCastExpr::Create(*Context, pToFunc, CK_Unknown, DRE, 0, VK_RValue); const FunctionType *FT = msgSendType->getAs(); @@ -2573,12 +2573,12 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) { &Context->Idents.get(S), strType, 0, VarDecl::Static, VarDecl::None); DeclRefExpr *DRE = new (Context) DeclRefExpr(NewVD, strType, SourceLocation()); - Expr *Unop = new (Context) UnaryOperator(DRE, UnaryOperator::AddrOf, + Expr *Unop = new (Context) UnaryOperator(DRE, UO_AddrOf, Context->getPointerType(DRE->getType()), SourceLocation()); // cast to NSConstantString * CastExpr *cast = NoTypeInfoCStyleCastExpr(Context, Exp->getType(), - CastExpr::CK_Unknown, Unop); + CK_Unknown, Unop); ReplaceStmt(Exp, cast); // delete Exp; leak for now, see RewritePropertySetter() usage for more info. return cast; @@ -2692,7 +2692,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, // set the receiver to self, the first argument to all methods. InitExprs.push_back( NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(), - CastExpr::CK_Unknown, + CK_Unknown, new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(), Context->getObjCIdType(), SourceLocation())) @@ -2713,7 +2713,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, // (Class)objc_getClass("CurrentClass") CastExpr *ArgExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCClassType(), - CastExpr::CK_Unknown, Cls); + CK_Unknown, Cls); ClsExprs.clear(); ClsExprs.push_back(ArgExpr); Cls = SynthesizeCallToFunctionDecl(GetSuperClassFunctionDecl, @@ -2725,7 +2725,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, InitExprs.push_back( // set 'super class', using class_getSuperclass(). NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(), - CastExpr::CK_Unknown, Cls)); + CK_Unknown, Cls)); // struct objc_super QualType superType = getSuperStructType(); Expr *SuperRep; @@ -2744,12 +2744,12 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, // we need the cast below. For example: // (struct objc_super *)&__rw_objc_super((id)self, (id)objc_getClass("SUPER")) // - SuperRep = new (Context) UnaryOperator(SuperRep, UnaryOperator::AddrOf, + SuperRep = new (Context) UnaryOperator(SuperRep, UO_AddrOf, Context->getPointerType(SuperRep->getType()), SourceLocation()); SuperRep = NoTypeInfoCStyleCastExpr(Context, Context->getPointerType(superType), - CastExpr::CK_Unknown, SuperRep); + CK_Unknown, SuperRep); } else { // (struct objc_super) { } InitListExpr *ILE = @@ -2761,7 +2761,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, SuperRep = new (Context) CompoundLiteralExpr(SourceLocation(), superTInfo, superType, ILE, false); // struct objc_super * - SuperRep = new (Context) UnaryOperator(SuperRep, UnaryOperator::AddrOf, + SuperRep = new (Context) UnaryOperator(SuperRep, UO_AddrOf, Context->getPointerType(SuperRep->getType()), SourceLocation()); } @@ -2798,7 +2798,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, InitExprs.push_back( NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(), - CastExpr::CK_Unknown, + CK_Unknown, new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(), Context->getObjCIdType(), SourceLocation())) @@ -2818,7 +2818,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, // (Class)objc_getClass("CurrentClass") CastExpr *ArgExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCClassType(), - CastExpr::CK_Unknown, Cls); + CK_Unknown, Cls); ClsExprs.clear(); ClsExprs.push_back(ArgExpr); Cls = SynthesizeCallToFunctionDecl(GetSuperClassFunctionDecl, @@ -2830,7 +2830,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, InitExprs.push_back( // set 'super class', using class_getSuperclass(). NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(), - CastExpr::CK_Unknown, Cls)); + CK_Unknown, Cls)); // struct objc_super QualType superType = getSuperStructType(); Expr *SuperRep; @@ -2849,12 +2849,12 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, // we need the cast below. For example: // (struct objc_super *)&__rw_objc_super((id)self, (id)objc_getClass("SUPER")) // - SuperRep = new (Context) UnaryOperator(SuperRep, UnaryOperator::AddrOf, + SuperRep = new (Context) UnaryOperator(SuperRep, UO_AddrOf, Context->getPointerType(SuperRep->getType()), SourceLocation()); SuperRep = NoTypeInfoCStyleCastExpr(Context, Context->getPointerType(superType), - CastExpr::CK_Unknown, SuperRep); + CK_Unknown, SuperRep); } else { // (struct objc_super) { } InitListExpr *ILE = @@ -2877,7 +2877,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, while (CStyleCastExpr *CE = dyn_cast(recExpr)) recExpr = CE->getSubExpr(); recExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(), - CastExpr::CK_Unknown, recExpr); + CK_Unknown, recExpr); MsgExprs.push_back(recExpr); break; } @@ -2907,7 +2907,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, : ICE->getType(); // Make sure we convert "type (^)(...)" to "type (*)(...)". (void)convertBlockPointerToFunctionPointer(type); - userExpr = NoTypeInfoCStyleCastExpr(Context, type, CastExpr::CK_Unknown, + userExpr = NoTypeInfoCStyleCastExpr(Context, type, CK_Unknown, userExpr); } // Make id cast into an 'id' cast. @@ -2916,7 +2916,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, while ((CE = dyn_cast(userExpr))) userExpr = CE->getSubExpr(); userExpr = NoTypeInfoCStyleCastExpr(Context, Context->getObjCIdType(), - CastExpr::CK_Unknown, userExpr); + CK_Unknown, userExpr); } } MsgExprs.push_back(userExpr); @@ -2966,7 +2966,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, // xx.m:13: note: if this code is reached, the program will abort cast = NoTypeInfoCStyleCastExpr(Context, Context->getPointerType(Context->VoidTy), - CastExpr::CK_Unknown, DRE); + CK_Unknown, DRE); // Now do the "normal" pointer to function cast. QualType castType = Context->getFunctionType(returnType, @@ -2976,7 +2976,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, false, false, 0, 0, FunctionType::ExtInfo()); castType = Context->getPointerType(castType); - cast = NoTypeInfoCStyleCastExpr(Context, castType, CastExpr::CK_Unknown, + cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_Unknown, cast); // Don't forget the parens to enforce the proper binding. @@ -2999,7 +2999,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, // Need to cast objc_msgSend_stret to "void *" (see above comment). cast = NoTypeInfoCStyleCastExpr(Context, Context->getPointerType(Context->VoidTy), - CastExpr::CK_Unknown, STDRE); + CK_Unknown, STDRE); // Now do the "normal" pointer to function cast. castType = Context->getFunctionType(returnType, &ArgTypes[0], ArgTypes.size(), @@ -3007,7 +3007,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, false, false, 0, 0, FunctionType::ExtInfo()); castType = Context->getPointerType(castType); - cast = NoTypeInfoCStyleCastExpr(Context, castType, CastExpr::CK_Unknown, + cast = NoTypeInfoCStyleCastExpr(Context, castType, CK_Unknown, cast); // Don't forget the parens to enforce the proper binding. @@ -3033,7 +3033,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp, Context->IntTy, SourceLocation()); BinaryOperator *lessThanExpr = new (Context) BinaryOperator(sizeofExpr, limit, - BinaryOperator::LE, + BO_LE, Context->IntTy, SourceLocation()); // (sizeof(returnType) <= 8 ? objc_msgSend(...) : objc_msgSend_stret(...)) @@ -3082,11 +3082,11 @@ Stmt *RewriteObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) { ID, getProtocolType(), 0, VarDecl::Extern, VarDecl::None); DeclRefExpr *DRE = new (Context) DeclRefExpr(VD, getProtocolType(), SourceLocation()); - Expr *DerefExpr = new (Context) UnaryOperator(DRE, UnaryOperator::AddrOf, + Expr *DerefExpr = new (Context) UnaryOperator(DRE, UO_AddrOf, Context->getPointerType(DRE->getType()), SourceLocation()); CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, DerefExpr->getType(), - CastExpr::CK_Unknown, + CK_Unknown, DerefExpr); ReplaceStmt(Exp, castExpr); ProtocolExprDecls.insert(Exp->getProtocol()); @@ -4607,7 +4607,7 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) { PtrToFuncCastType = Context->getPointerType(PtrToFuncCastType); CastExpr *BlkCast = NoTypeInfoCStyleCastExpr(Context, PtrBlock, - CastExpr::CK_Unknown, + CK_Unknown, const_cast(BlockExp)); // Don't forget the parens to enforce the proper binding. ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), @@ -4621,7 +4621,7 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) { FD->getType()); CastExpr *FunkCast = NoTypeInfoCStyleCastExpr(Context, PtrToFuncCastType, - CastExpr::CK_Unknown, ME); + CK_Unknown, ME); PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), FunkCast); llvm::SmallVector BlkExprs; @@ -4696,7 +4696,7 @@ Stmt *RewriteObjC::RewriteLocalVariableExternalStorage(DeclRefExpr *DRE) { if (VarDecl *Var = dyn_cast(VD)) if (!ImportedLocalExternalDecls.count(Var)) return DRE; - Expr *Exp = new (Context) UnaryOperator(DRE, UnaryOperator::Deref, + Expr *Exp = new (Context) UnaryOperator(DRE, UO_Deref, DRE->getType(), DRE->getLocation()); // Need parens to enforce precedence. ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), @@ -5188,7 +5188,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, DeclRefExpr *Arg = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation()); CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, Context->VoidPtrTy, - CastExpr::CK_Unknown, Arg); + CK_Unknown, Arg); InitExprs.push_back(castExpr); // Initialize the block descriptor. @@ -5201,7 +5201,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, UnaryOperator *DescRefExpr = new (Context) UnaryOperator( new (Context) DeclRefExpr(NewVD, Context->VoidPtrTy, SourceLocation()), - UnaryOperator::AddrOf, + UO_AddrOf, Context->getPointerType(Context->VoidPtrTy), SourceLocation()); InitExprs.push_back(DescRefExpr); @@ -5219,21 +5219,21 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, if (HasLocalVariableExternalStorage(*I)) { QualType QT = (*I)->getType(); QT = Context->getPointerType(QT); - Exp = new (Context) UnaryOperator(Exp, UnaryOperator::AddrOf, QT, + Exp = new (Context) UnaryOperator(Exp, UO_AddrOf, QT, SourceLocation()); } } else if (isTopLevelBlockPointerType((*I)->getType())) { FD = SynthBlockInitFunctionDecl((*I)->getName()); Arg = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation()); Exp = NoTypeInfoCStyleCastExpr(Context, Context->VoidPtrTy, - CastExpr::CK_Unknown, Arg); + CK_Unknown, Arg); } else { FD = SynthBlockInitFunctionDecl((*I)->getName()); Exp = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation()); if (HasLocalVariableExternalStorage(*I)) { QualType QT = (*I)->getType(); QT = Context->getPointerType(QT); - Exp = new (Context) UnaryOperator(Exp, UnaryOperator::AddrOf, QT, + Exp = new (Context) UnaryOperator(Exp, UO_AddrOf, QT, SourceLocation()); } @@ -5256,10 +5256,10 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, FD = SynthBlockInitFunctionDecl((*I)->getName()); Exp = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation()); - Exp = new (Context) UnaryOperator(Exp, UnaryOperator::AddrOf, + Exp = new (Context) UnaryOperator(Exp, UO_AddrOf, Context->getPointerType(Exp->getType()), SourceLocation()); - Exp = NoTypeInfoCStyleCastExpr(Context, castT, CastExpr::CK_Unknown, Exp); + Exp = NoTypeInfoCStyleCastExpr(Context, castT, CK_Unknown, Exp); InitExprs.push_back(Exp); } } @@ -5274,10 +5274,10 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp, } NewRep = new (Context) CallExpr(*Context, DRE, &InitExprs[0], InitExprs.size(), FType, SourceLocation()); - NewRep = new (Context) UnaryOperator(NewRep, UnaryOperator::AddrOf, + NewRep = new (Context) UnaryOperator(NewRep, UO_AddrOf, Context->getPointerType(NewRep->getType()), SourceLocation()); - NewRep = NoTypeInfoCStyleCastExpr(Context, FType, CastExpr::CK_Unknown, + NewRep = NoTypeInfoCStyleCastExpr(Context, FType, CK_Unknown, NewRep); BlockDeclRefs.clear(); BlockByRefDecls.clear(); diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 120035c923..31d6f0dd32 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -210,7 +210,7 @@ void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty, // If this is a derived-to-base cast to a through a virtual base, we // need a vtable. - if (Kind == CastExpr::CK_DerivedToBase && + if (Kind == CK_DerivedToBase && BasePathInvolvesVirtualBase(*BasePath)) { QualType T = Expr->getType(); if (const PointerType *Pointer = T->getAs()) diff --git a/lib/Sema/SemaCXXCast.cpp b/lib/Sema/SemaCXXCast.cpp index 56531c7f70..89feea8a8d 100644 --- a/lib/Sema/SemaCXXCast.cpp +++ b/lib/Sema/SemaCXXCast.cpp @@ -43,15 +43,15 @@ static void CheckConstCast(Sema &Self, Expr *&SrcExpr, QualType DestType, static void CheckReinterpretCast(Sema &Self, Expr *&SrcExpr, QualType DestType, const SourceRange &OpRange, const SourceRange &DestRange, - CastExpr::CastKind &Kind); + CastKind &Kind); static void CheckStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType, const SourceRange &OpRange, - CastExpr::CastKind &Kind, + CastKind &Kind, CXXCastPath &BasePath); static void CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType, const SourceRange &OpRange, const SourceRange &DestRange, - CastExpr::CastKind &Kind, + CastKind &Kind, CXXCastPath &BasePath); static bool CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType); @@ -73,39 +73,39 @@ static TryCastResult TryStaticReferenceDowncast(Sema &Self, Expr *SrcExpr, QualType DestType, bool CStyle, const SourceRange &OpRange, unsigned &msg, - CastExpr::CastKind &Kind, + CastKind &Kind, CXXCastPath &BasePath); static TryCastResult TryStaticPointerDowncast(Sema &Self, QualType SrcType, QualType DestType, bool CStyle, const SourceRange &OpRange, unsigned &msg, - CastExpr::CastKind &Kind, + CastKind &Kind, CXXCastPath &BasePath); static TryCastResult TryStaticDowncast(Sema &Self, CanQualType SrcType, CanQualType DestType, bool CStyle, const SourceRange &OpRange, QualType OrigSrcType, QualType OrigDestType, unsigned &msg, - CastExpr::CastKind &Kind, + CastKind &Kind, CXXCastPath &BasePath); static TryCastResult TryStaticMemberPointerUpcast(Sema &Self, Expr *&SrcExpr, QualType SrcType, QualType DestType,bool CStyle, const SourceRange &OpRange, unsigned &msg, - CastExpr::CastKind &Kind, + CastKind &Kind, CXXCastPath &BasePath); static TryCastResult TryStaticImplicitCast(Sema &Self, Expr *&SrcExpr, QualType DestType, bool CStyle, const SourceRange &OpRange, unsigned &msg, - CastExpr::CastKind &Kind); + CastKind &Kind); static TryCastResult TryStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType, bool CStyle, const SourceRange &OpRange, unsigned &msg, - CastExpr::CastKind &Kind, + CastKind &Kind, CXXCastPath &BasePath); static TryCastResult TryConstCast(Sema &Self, Expr *SrcExpr, QualType DestType, bool CStyle, unsigned &msg); @@ -113,7 +113,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr, QualType DestType, bool CStyle, const SourceRange &OpRange, unsigned &msg, - CastExpr::CastKind &Kind); + CastKind &Kind); /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's. ExprResult @@ -157,7 +157,7 @@ Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, Ex, DestTInfo, OpLoc)); case tok::kw_dynamic_cast: { - CastExpr::CastKind Kind = CastExpr::CK_Unknown; + CastKind Kind = CK_Unknown; CXXCastPath BasePath; if (!TypeDependent) CheckDynamicCast(*this, Ex, DestType, OpRange, DestRange, Kind, BasePath); @@ -167,7 +167,7 @@ Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, OpLoc)); } case tok::kw_reinterpret_cast: { - CastExpr::CastKind Kind = CastExpr::CK_Unknown; + CastKind Kind = CK_Unknown; if (!TypeDependent) CheckReinterpretCast(*this, Ex, DestType, OpRange, DestRange, Kind); return Owned(CXXReinterpretCastExpr::Create(Context, @@ -176,7 +176,7 @@ Sema::BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, DestTInfo, OpLoc)); } case tok::kw_static_cast: { - CastExpr::CastKind Kind = CastExpr::CK_Unknown; + CastKind Kind = CK_Unknown; CXXCastPath BasePath; if (!TypeDependent) CheckStaticCast(*this, Ex, DestType, OpRange, Kind, BasePath); @@ -306,7 +306,7 @@ CastsAwayConstness(Sema &Self, QualType SrcType, QualType DestType) { static void CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType, const SourceRange &OpRange, - const SourceRange &DestRange, CastExpr::CastKind &Kind, + const SourceRange &DestRange, CastKind &Kind, CXXCastPath &BasePath) { QualType OrigDestType = DestType, OrigSrcType = SrcExpr->getType(); DestType = Self.Context.getCanonicalType(DestType); @@ -395,7 +395,7 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType, // C++ 5.2.7p3: If the type of v is the same as the required result type, // [except for cv]. if (DestRecord == SrcRecord) { - Kind = CastExpr::CK_NoOp; + Kind = CK_NoOp; return; } @@ -407,7 +407,7 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType, &BasePath)) return; - Kind = CastExpr::CK_DerivedToBase; + Kind = CK_DerivedToBase; // If we are casting to or through a virtual base class, we need a // vtable. @@ -428,7 +428,7 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType, cast(SrcRecord->getDecl())); // Done. Everything else is run-time checks. - Kind = CastExpr::CK_Dynamic; + Kind = CK_Dynamic; } /// CheckConstCast - Check that a const_cast\(SrcExpr) is valid. @@ -457,7 +457,7 @@ CheckConstCast(Sema &Self, Expr *&SrcExpr, QualType DestType, void CheckReinterpretCast(Sema &Self, Expr *&SrcExpr, QualType DestType, const SourceRange &OpRange, const SourceRange &DestRange, - CastExpr::CastKind &Kind) { + CastKind &Kind) { if (!DestType->isLValueReferenceType()) Self.DefaultFunctionArrayLvalueConversion(SrcExpr); @@ -475,13 +475,13 @@ CheckReinterpretCast(Sema &Self, Expr *&SrcExpr, QualType DestType, /// implicit conversions explicit and getting rid of data loss warnings. void CheckStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType, - const SourceRange &OpRange, CastExpr::CastKind &Kind, + const SourceRange &OpRange, CastKind &Kind, CXXCastPath &BasePath) { // This test is outside everything else because it's the only case where // a non-lvalue-reference target type does not lead to decay. // C++ 5.2.9p4: Any expression can be explicitly converted to type "cv void". if (DestType->isVoidType()) { - Kind = CastExpr::CK_ToVoid; + Kind = CK_ToVoid; return; } @@ -493,7 +493,7 @@ CheckStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType, Kind, BasePath) != TC_Success && msg != 0) Self.Diag(OpRange.getBegin(), msg) << CT_Static << SrcExpr->getType() << DestType << OpRange; - else if (Kind == CastExpr::CK_Unknown || Kind == CastExpr::CK_BitCast) + else if (Kind == CK_Unknown || Kind == CK_BitCast) Self.CheckCastAlign(SrcExpr, DestType, OpRange); } @@ -503,7 +503,7 @@ CheckStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType, static TryCastResult TryStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType, bool CStyle, const SourceRange &OpRange, unsigned &msg, - CastExpr::CastKind &Kind, + CastKind &Kind, CXXCastPath &BasePath) { // The order the tests is not entirely arbitrary. There is one conversion // that can be handled in two different ways. Given: @@ -534,7 +534,7 @@ static TryCastResult TryStaticCast(Sema &Self, Expr *&SrcExpr, // reference to cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1". tcr = TryLValueToRValueCast(Self, SrcExpr, DestType, msg); if (tcr != TC_NotApplicable) { - Kind = CastExpr::CK_NoOp; + Kind = CK_NoOp; return tcr; } @@ -569,7 +569,7 @@ static TryCastResult TryStaticCast(Sema &Self, Expr *&SrcExpr, if (SrcType->isComplexType() || SrcType->isVectorType()) { // Fall through - these cannot be converted. } else if (SrcType->isArithmeticType() || SrcType->isEnumeralType()) { - Kind = CastExpr::CK_IntegralCast; + Kind = CK_IntegralCast; return TC_Success; } } @@ -604,19 +604,19 @@ static TryCastResult TryStaticCast(Sema &Self, Expr *&SrcExpr, msg = diag::err_bad_cxx_cast_const_away; return TC_Failed; } - Kind = CastExpr::CK_BitCast; + Kind = CK_BitCast; return TC_Success; } } else if (DestType->isObjCObjectPointerType()) { // allow both c-style cast and static_cast of objective-c pointers as // they are pervasive. - Kind = CastExpr::CK_AnyPointerToObjCPointerCast; + Kind = CK_AnyPointerToObjCPointerCast; return TC_Success; } else if (CStyle && DestType->isBlockPointerType()) { // allow c-style cast of void * to block pointers. - Kind = CastExpr::CK_AnyPointerToBlockPointerCast; + Kind = CK_AnyPointerToBlockPointerCast; return TC_Success; } } @@ -665,7 +665,7 @@ TryLValueToRValueCast(Sema &Self, Expr *SrcExpr, QualType DestType, TryCastResult TryStaticReferenceDowncast(Sema &Self, Expr *SrcExpr, QualType DestType, bool CStyle, const SourceRange &OpRange, - unsigned &msg, CastExpr::CastKind &Kind, + unsigned &msg, CastKind &Kind, CXXCastPath &BasePath) { // C++ 5.2.9p5: An lvalue of type "cv1 B", where B is a class type, can be // cast to type "reference to cv2 D", where D is a class derived from B, @@ -700,7 +700,7 @@ TryStaticReferenceDowncast(Sema &Self, Expr *SrcExpr, QualType DestType, TryCastResult TryStaticPointerDowncast(Sema &Self, QualType SrcType, QualType DestType, bool CStyle, const SourceRange &OpRange, - unsigned &msg, CastExpr::CastKind &Kind, + unsigned &msg, CastKind &Kind, CXXCastPath &BasePath) { // C++ 5.2.9p8: An rvalue of type "pointer to cv1 B", where B is a class // type, can be converted to an rvalue of type "pointer to cv2 D", where D @@ -735,7 +735,7 @@ TryCastResult TryStaticDowncast(Sema &Self, CanQualType SrcType, CanQualType DestType, bool CStyle, const SourceRange &OpRange, QualType OrigSrcType, QualType OrigDestType, unsigned &msg, - CastExpr::CastKind &Kind, CXXCastPath &BasePath) { + CastKind &Kind, CXXCastPath &BasePath) { // We can only work with complete types. But don't complain if it doesn't work if (Self.RequireCompleteType(OpRange.getBegin(), SrcType, Self.PDiag(0)) || Self.RequireCompleteType(OpRange.getBegin(), DestType, Self.PDiag(0))) @@ -827,7 +827,7 @@ TryStaticDowncast(Sema &Self, CanQualType SrcType, CanQualType DestType, } Self.BuildBasePathArray(Paths, BasePath); - Kind = CastExpr::CK_BaseToDerived; + Kind = CK_BaseToDerived; return TC_Success; } @@ -842,7 +842,7 @@ TryCastResult TryStaticMemberPointerUpcast(Sema &Self, Expr *&SrcExpr, QualType SrcType, QualType DestType, bool CStyle, const SourceRange &OpRange, - unsigned &msg, CastExpr::CastKind &Kind, + unsigned &msg, CastKind &Kind, CXXCastPath &BasePath) { const MemberPointerType *DestMemPtr = DestType->getAs(); if (!DestMemPtr) @@ -930,7 +930,7 @@ TryStaticMemberPointerUpcast(Sema &Self, Expr *&SrcExpr, QualType SrcType, } Self.BuildBasePathArray(Paths, BasePath); - Kind = CastExpr::CK_DerivedToBaseMemberPointer; + Kind = CK_DerivedToBaseMemberPointer; return TC_Success; } @@ -942,7 +942,7 @@ TryStaticMemberPointerUpcast(Sema &Self, Expr *&SrcExpr, QualType SrcType, TryCastResult TryStaticImplicitCast(Sema &Self, Expr *&SrcExpr, QualType DestType, bool CStyle, const SourceRange &OpRange, unsigned &msg, - CastExpr::CastKind &Kind) { + CastKind &Kind) { if (DestType->isRecordType()) { if (Self.RequireCompleteType(OpRange.getBegin(), DestType, diag::err_bad_dynamic_cast_incomplete)) { @@ -973,9 +973,9 @@ TryStaticImplicitCast(Sema &Self, Expr *&SrcExpr, QualType DestType, } if (InitSeq.isConstructorInitialization()) - Kind = CastExpr::CK_ConstructorConversion; + Kind = CK_ConstructorConversion; else - Kind = CastExpr::CK_NoOp; + Kind = CK_NoOp; SrcExpr = Result.takeAs(); return TC_Success; @@ -1054,7 +1054,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr, QualType DestType, bool CStyle, const SourceRange &OpRange, unsigned &msg, - CastExpr::CastKind &Kind) { + CastKind &Kind) { bool IsLValueCast = false; DestType = Self.Context.getCanonicalType(DestType); @@ -1108,7 +1108,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr, } // A valid member pointer cast. - Kind = IsLValueCast? CastExpr::CK_LValueBitCast : CastExpr::CK_BitCast; + Kind = IsLValueCast? CK_LValueBitCast : CK_BitCast; return TC_Success; } @@ -1123,7 +1123,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr, msg = diag::err_bad_reinterpret_cast_small_int; return TC_Failed; } - Kind = CastExpr::CK_PointerToIntegral; + Kind = CK_PointerToIntegral; return TC_Success; } @@ -1142,7 +1142,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr, // If both types have the same size, we can successfully cast. if (Self.Context.getTypeSize(SrcType) == Self.Context.getTypeSize(DestType)) { - Kind = CastExpr::CK_BitCast; + Kind = CK_BitCast; return TC_Success; } @@ -1173,7 +1173,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr, // to the same type. However, the behavior of compilers is pretty consistent // on this point: allow same-type conversion if the involved types are // pointers, disallow otherwise. - Kind = CastExpr::CK_NoOp; + Kind = CK_NoOp; return TC_Success; } @@ -1186,7 +1186,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr, msg = diag::err_bad_reinterpret_cast_small_int; return TC_Failed; } - Kind = CastExpr::CK_PointerToIntegral; + Kind = CK_PointerToIntegral; return TC_Success; } @@ -1194,7 +1194,7 @@ static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr, assert(destIsPtr && "One type must be a pointer"); // C++ 5.2.10p5: A value of integral or enumeration type can be explicitly // converted to a pointer. - Kind = CastExpr::CK_IntegralToPointer; + Kind = CK_IntegralToPointer; return TC_Success; } @@ -1219,13 +1219,13 @@ static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr, // Any pointer can be cast to an Objective-C pointer type with a C-style // cast. if (CStyle && DestType->isObjCObjectPointerType()) { - Kind = CastExpr::CK_AnyPointerToObjCPointerCast; + Kind = CK_AnyPointerToObjCPointerCast; return TC_Success; } // Not casting away constness, so the only remaining check is for compatible // pointer categories. - Kind = IsLValueCast? CastExpr::CK_LValueBitCast : CastExpr::CK_BitCast; + Kind = IsLValueCast? CK_LValueBitCast : CK_BitCast; if (SrcType->isFunctionPointerType()) { if (DestType->isFunctionPointerType()) { @@ -1262,14 +1262,14 @@ static TryCastResult TryReinterpretCast(Sema &Self, Expr *SrcExpr, bool Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr, - CastExpr::CastKind &Kind, + CastKind &Kind, CXXCastPath &BasePath, bool FunctionalStyle) { // This test is outside everything else because it's the only case where // a non-lvalue-reference target type does not lead to decay. // C++ 5.2.9p4: Any expression can be explicitly converted to type "cv void". if (CastTy->isVoidType()) { - Kind = CastExpr::CK_ToVoid; + Kind = CK_ToVoid; return false; } @@ -1295,7 +1295,7 @@ Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr, TryCastResult tcr = TryConstCast(*this, CastExpr, CastTy, /*CStyle*/true, msg); if (tcr == TC_Success) - Kind = CastExpr::CK_NoOp; + Kind = CK_NoOp; if (tcr == TC_NotApplicable) { // ... or if that is not possible, a static_cast, ignoring const, ... @@ -1311,7 +1311,7 @@ Sema::CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr, if (tcr != TC_Success && msg != 0) Diag(R.getBegin(), msg) << (FunctionalStyle ? CT_Functional : CT_CStyle) << CastExpr->getType() << CastTy << R; - else if (Kind == CastExpr::CK_Unknown || Kind == CastExpr::CK_BitCast) + else if (Kind == CK_Unknown || Kind == CK_BitCast) CheckCastAlign(CastExpr, CastTy, R); return tcr != TC_Success; diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 271a02dc11..f759b02327 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -544,7 +544,7 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { // GCC does an implicit conversion to the pointer or integer ValType. This // can fail in some cases (1i -> int**), check for this error case now. - CastExpr::CastKind Kind = CastExpr::CK_Unknown; + CastKind Kind = CK_Unknown; CXXCastPath BasePath; if (CheckCastTypes(Arg->getSourceRange(), ValType, Arg, Kind, BasePath)) return ExprError(); @@ -1870,7 +1870,7 @@ static DeclRefExpr* EvalAddr(Expr *E) { // is AddrOf. All others don't make sense as pointers. UnaryOperator *U = cast(E); - if (U->getOpcode() == UnaryOperator::AddrOf) + if (U->getOpcode() == UO_AddrOf) return EvalVal(U->getSubExpr()); else return NULL; @@ -1880,9 +1880,9 @@ static DeclRefExpr* EvalAddr(Expr *E) { // Handle pointer arithmetic. All other binary operators are not valid // in this context. BinaryOperator *B = cast(E); - BinaryOperator::Opcode op = B->getOpcode(); + BinaryOperatorKind op = B->getOpcode(); - if (op != BinaryOperator::Add && op != BinaryOperator::Sub) + if (op != BO_Add && op != BO_Sub) return NULL; Expr *Base = B->getLHS(); @@ -1997,7 +1997,7 @@ do { // handling all sorts of rvalues passed to a unary operator. UnaryOperator *U = cast(E); - if (U->getOpcode() == UnaryOperator::Deref) + if (U->getOpcode() == UO_Deref) return EvalAddr(U->getSubExpr()); return NULL; @@ -2215,13 +2215,13 @@ IntRange GetExprRange(ASTContext &C, Expr *E, unsigned MaxWidth) { // user has an explicit widening cast, we should treat the value as // being of the new, wider type. if (ImplicitCastExpr *CE = dyn_cast(E)) { - if (CE->getCastKind() == CastExpr::CK_NoOp) + if (CE->getCastKind() == CK_NoOp) return GetExprRange(C, CE->getSubExpr(), MaxWidth); IntRange OutputTypeRange = IntRange::forType(C, CE->getType()); - bool isIntegerCast = (CE->getCastKind() == CastExpr::CK_IntegralCast); - if (!isIntegerCast && CE->getCastKind() == CastExpr::CK_Unknown) + bool isIntegerCast = (CE->getCastKind() == CK_IntegralCast); + if (!isIntegerCast && CE->getCastKind() == CK_Unknown) isIntegerCast = CE->getSubExpr()->getType()->isIntegerType(); // Assume that non-integer casts can span the full range of the type. @@ -2260,38 +2260,38 @@ IntRange GetExprRange(ASTContext &C, Expr *E, unsigned MaxWidth) { switch (BO->getOpcode()) { // Boolean-valued operations are single-bit and positive. - case BinaryOperator::LAnd: - case BinaryOperator::LOr: - case BinaryOperator::LT: - case BinaryOperator::GT: - case BinaryOperator::LE: - case BinaryOperator::GE: - case BinaryOperator::EQ: - case BinaryOperator::NE: + case BO_LAnd: + case BO_LOr: + case BO_LT: + case BO_GT: + case BO_LE: + case BO_GE: + case BO_EQ: + case BO_NE: return IntRange::forBoolType(); // The type of these compound assignments is the type of the LHS, // so the RHS is not necessarily an integer. - case BinaryOperator::MulAssign: - case BinaryOperator::DivAssign: - case BinaryOperator::RemAssign: - case BinaryOperator::AddAssign: - case BinaryOperator::SubAssign: + case BO_MulAssign: + case BO_DivAssign: + case BO_RemAssign: + case BO_AddAssign: + case BO_SubAssign: return IntRange::forType(C, E->getType()); // Operations with opaque sources are black-listed. - case BinaryOperator::PtrMemD: - case BinaryOperator::PtrMemI: + case BO_PtrMemD: + case BO_PtrMemI: return IntRange::forType(C, E->getType()); // Bitwise-and uses the *infinum* of the two source ranges. - case BinaryOperator::And: - case BinaryOperator::AndAssign: + case BO_And: + case BO_AndAssign: return IntRange::meet(GetExprRange(C, BO->getLHS(), MaxWidth), GetExprRange(C, BO->getRHS(), MaxWidth)); // Left shift gets black-listed based on a judgement call. - case BinaryOperator::Shl: + case BO_Shl: // ...except that we want to treat '1 << (blah)' as logically // positive. It's an important idiom. if (IntegerLiteral *I @@ -2303,12 +2303,12 @@ IntRange GetExprRange(ASTContext &C, Expr *E, unsigned MaxWidth) { } // fallthrough - case BinaryOperator::ShlAssign: + case BO_ShlAssign: return IntRange::forType(C, E->getType()); // Right shift by a constant can narrow its left argument. - case BinaryOperator::Shr: - case BinaryOperator::ShrAssign: { + case BO_Shr: + case BO_ShrAssign: { IntRange L = GetExprRange(C, BO->getLHS(), MaxWidth); // If the shift amount is a positive constant, drop the width by @@ -2327,11 +2327,11 @@ IntRange GetExprRange(ASTContext &C, Expr *E, unsigned MaxWidth) { } // Comma acts as its right operand. - case BinaryOperator::Comma: + case BO_Comma: return GetExprRange(C, BO->getRHS(), MaxWidth); // Black-list pointer subtractions. - case BinaryOperator::Sub: + case BO_Sub: if (BO->getLHS()->getType()->isPointerType()) return IntRange::forType(C, E->getType()); // fallthrough @@ -2350,12 +2350,12 @@ IntRange GetExprRange(ASTContext &C, Expr *E, unsigned MaxWidth) { if (UnaryOperator *UO = dyn_cast(E)) { switch (UO->getOpcode()) { // Boolean-valued operations are white-listed. - case UnaryOperator::LNot: + case UO_LNot: return IntRange::forBoolType(); // Operations with opaque sources are black-listed. - case UnaryOperator::Deref: - case UnaryOperator::AddrOf: // should be impossible + case UO_Deref: + case UO_AddrOf: // should be impossible return IntRange::forType(C, E->getType()); default: @@ -2428,20 +2428,20 @@ bool IsZero(Sema &S, Expr *E) { } void CheckTrivialUnsignedComparison(Sema &S, BinaryOperator *E) { - BinaryOperator::Opcode op = E->getOpcode(); - if (op == BinaryOperator::LT && IsZero(S, E->getRHS())) { + BinaryOperatorKind op = E->getOpcode(); + if (op == BO_LT && IsZero(S, E->getRHS())) { S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_true_comparison) << "< 0" << "false" << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange(); - } else if (op == BinaryOperator::GE && IsZero(S, E->getRHS())) { + } else if (op == BO_GE && IsZero(S, E->getRHS())) { S.Diag(E->getOperatorLoc(), diag::warn_lunsigned_always_true_comparison) << ">= 0" << "true" << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange(); - } else if (op == BinaryOperator::GT && IsZero(S, E->getLHS())) { + } else if (op == BO_GT && IsZero(S, E->getLHS())) { S.Diag(E->getOperatorLoc(), diag::warn_runsigned_always_true_comparison) << "0 >" << "false" << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange(); - } else if (op == BinaryOperator::LE && IsZero(S, E->getLHS())) { + } else if (op == BO_LE && IsZero(S, E->getLHS())) { S.Diag(E->getOperatorLoc(), diag::warn_runsigned_always_true_comparison) << "0 <=" << "true" << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange(); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 9b6680f312..242a4df86d 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -4238,7 +4238,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) { << Init->getSourceRange(); VDecl->setInvalidDecl(); } else if (!VDecl->getType()->isDependentType()) - ImpCastExprToType(Init, VDecl->getType(), CastExpr::CK_IntegralCast); + ImpCastExprToType(Init, VDecl->getType(), CK_IntegralCast); } } } else if (VDecl->isFileVarDecl()) { @@ -6751,7 +6751,7 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl *Enum, << (EnumVal.isUnsigned() || EnumVal.isNonNegative()); else if (!Context.hasSameType(Val->getType(), Context.IntTy)) { // Force the type of the expression to 'int'. - ImpCastExprToType(Val, Context.IntTy, CastExpr::CK_IntegralCast); + ImpCastExprToType(Val, Context.IntTy, CK_IntegralCast); } } @@ -7082,7 +7082,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, // Adjust the Expr initializer and type. if (ECD->getInitExpr()) ECD->setInitExpr(ImplicitCastExpr::Create(Context, NewTy, - CastExpr::CK_IntegralCast, + CK_IntegralCast, ECD->getInitExpr(), /*base paths*/ 0, VK_RValue)); diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index dbf22eba50..6a09a75ddc 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1539,7 +1539,7 @@ BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, CXXCastPath BasePath; BasePath.push_back(BaseSpec); SemaRef.ImpCastExprToType(CopyCtorArg, ArgTy, - CastExpr::CK_UncheckedDerivedToBase, + CK_UncheckedDerivedToBase, VK_LValue, &BasePath); InitializationKind InitKind @@ -4636,10 +4636,7 @@ BuildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, // operator is used. const ConstantArrayType *ArrayTy = S.Context.getAsConstantArrayType(T); if (!ArrayTy) { - ExprResult Assignment = S.CreateBuiltinBinOp(Loc, - BinaryOperator::Assign, - To, - From); + ExprResult Assignment = S.CreateBuiltinBinOp(Loc, BO_Assign, To, From); if (Assignment.isInvalid()) return S.StmtError(); @@ -4688,12 +4685,12 @@ BuildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, Expr *Comparison = new (S.Context) BinaryOperator(IterationVarRef->Retain(), new (S.Context) IntegerLiteral(Upper, SizeType, Loc), - BinaryOperator::NE, S.Context.BoolTy, Loc); + BO_NE, S.Context.BoolTy, Loc); // Create the pre-increment of the iteration variable. Expr *Increment = new (S.Context) UnaryOperator(IterationVarRef->Retain(), - UnaryOperator::PreInc, + UO_PreInc, SizeType, Loc); // Subscript the "from" and "to" expressions with the iteration variable. @@ -5085,8 +5082,8 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation, } // Take the address of the field references for "from" and "to". - From = CreateBuiltinUnaryOp(Loc, UnaryOperator::AddrOf, From.get()); - To = CreateBuiltinUnaryOp(Loc, UnaryOperator::AddrOf, To.get()); + From = CreateBuiltinUnaryOp(Loc, UO_AddrOf, From.get()); + To = CreateBuiltinUnaryOp(Loc, UO_AddrOf, To.get()); bool NeedsCollectableMemCpy = (BaseType->isRecordType() && @@ -5175,8 +5172,7 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation, if (!Invalid) { // Add a "return *this;" - ExprResult ThisObj = CreateBuiltinUnaryOp(Loc, UnaryOperator::Deref, - This); + ExprResult ThisObj = CreateBuiltinUnaryOp(Loc, UO_Deref, This); StmtResult Return = ActOnReturnStmt(Loc, ThisObj.get()); if (Return.isInvalid()) diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 6c25c272f3..fe9665e4d9 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -195,7 +195,7 @@ void Sema::DefaultFunctionArrayConversion(Expr *&E) { if (Ty->isFunctionType()) ImpCastExprToType(E, Context.getPointerType(Ty), - CastExpr::CK_FunctionToPointerDecay); + CK_FunctionToPointerDecay); else if (Ty->isArrayType()) { // In C90 mode, arrays only promote to pointers if the array expression is // an lvalue. The relevant legalese is C90 6.2.2.1p3: "an lvalue that has @@ -211,7 +211,7 @@ void Sema::DefaultFunctionArrayConversion(Expr *&E) { if (getLangOptions().C99 || getLangOptions().CPlusPlus || E->isLvalue(Context) == Expr::LV_Valid) ImpCastExprToType(E, Context.getArrayDecayedType(Ty), - CastExpr::CK_ArrayToPointerDecay); + CK_ArrayToPointerDecay); } } @@ -232,7 +232,7 @@ void Sema::DefaultFunctionArrayLvalueConversion(Expr *&E) { // If the lvalue has qualified type, the value has the unqualified // version of the type of the lvalue; otherwise, the value has the // type of the lvalue. - ImpCastExprToType(E, Ty.getUnqualifiedType(), CastExpr::CK_NoOp); + ImpCastExprToType(E, Ty.getUnqualifiedType(), CK_NoOp); } } @@ -261,12 +261,12 @@ Expr *Sema::UsualUnaryConversions(Expr *&Expr) { // other types are unchanged by the integer promotions. QualType PTy = Context.isPromotableBitField(Expr); if (!PTy.isNull()) { - ImpCastExprToType(Expr, PTy, CastExpr::CK_IntegralCast); + ImpCastExprToType(Expr, PTy, CK_IntegralCast); return Expr; } if (Ty->isPromotableIntegerType()) { QualType PT = Context.getPromotedIntegerType(Ty); - ImpCastExprToType(Expr, PT, CastExpr::CK_IntegralCast); + ImpCastExprToType(Expr, PT, CK_IntegralCast); return Expr; } @@ -284,7 +284,7 @@ void Sema::DefaultArgumentPromotion(Expr *&Expr) { // If this is a 'float' (CVR qualified or typedef) promote to double. if (Ty->isSpecificBuiltinType(BuiltinType::Float)) return ImpCastExprToType(Expr, Context.DoubleTy, - CastExpr::CK_FloatingCast); + CK_FloatingCast); UsualUnaryConversions(Expr); } @@ -358,8 +358,8 @@ QualType Sema::UsualArithmeticConversions(Expr *&lhsExpr, Expr *&rhsExpr, QualType destType = Context.UsualArithmeticConversionsType(lhs, rhs); if (!isCompAssign) - ImpCastExprToType(lhsExpr, destType, CastExpr::CK_Unknown); - ImpCastExprToType(rhsExpr, destType, CastExpr::CK_Unknown); + ImpCastExprToType(lhsExpr, destType, CK_Unknown); + ImpCastExprToType(rhsExpr, destType, CK_Unknown); return destType; } @@ -1555,7 +1555,7 @@ Sema::PerformObjectMemberConversion(Expr *&From, QualType UType = URecordType; if (PointerConversions) UType = Context.getPointerType(UType); - ImpCastExprToType(From, UType, CastExpr::CK_UncheckedDerivedToBase, + ImpCastExprToType(From, UType, CK_UncheckedDerivedToBase, VK, &BasePath); FromType = UType; FromRecordType = URecordType; @@ -1572,7 +1572,7 @@ Sema::PerformObjectMemberConversion(Expr *&From, IgnoreAccess)) return true; - ImpCastExprToType(From, DestType, CastExpr::CK_UncheckedDerivedToBase, + ImpCastExprToType(From, DestType, CK_UncheckedDerivedToBase, VK, &BasePath); return false; } @@ -2259,11 +2259,11 @@ QualType Sema::CheckRealImagOperand(Expr *&V, SourceLocation Loc, bool isReal) { ExprResult Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input) { - UnaryOperator::Opcode Opc; + UnaryOperatorKind Opc; switch (Kind) { default: assert(0 && "Unknown unary op!"); - case tok::plusplus: Opc = UnaryOperator::PostInc; break; - case tok::minusminus: Opc = UnaryOperator::PostDec; break; + case tok::plusplus: Opc = UO_PostInc; break; + case tok::minusminus: Opc = UO_PostDec; break; } return BuildUnaryOp(S, OpLoc, Opc, Input); @@ -2355,7 +2355,7 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Diag(LHSExp->getLocStart(), diag::ext_subscript_non_lvalue) << LHSExp->getSourceRange(); ImpCastExprToType(LHSExp, Context.getArrayDecayedType(LHSTy), - CastExpr::CK_ArrayToPointerDecay); + CK_ArrayToPointerDecay); LHSTy = LHSExp->getType(); BaseExpr = LHSExp; @@ -2366,7 +2366,7 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Diag(RHSExp->getLocStart(), diag::ext_subscript_non_lvalue) << RHSExp->getSourceRange(); ImpCastExprToType(RHSExp, Context.getArrayDecayedType(RHSTy), - CastExpr::CK_ArrayToPointerDecay); + CK_ArrayToPointerDecay); RHSTy = RHSExp->getType(); BaseExpr = RHSExp; @@ -3029,7 +3029,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, // is a reference to 'isa'. if (BaseType != Context.ObjCIdRedefinitionType) { BaseType = Context.ObjCIdRedefinitionType; - ImpCastExprToType(BaseExpr, BaseType, CastExpr::CK_BitCast); + ImpCastExprToType(BaseExpr, BaseType, CK_BitCast); } } @@ -3040,7 +3040,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, // is a reference to 'sel_id'. if (BaseType != Context.ObjCSelRedefinitionType) { BaseType = Context.ObjCSelRedefinitionType; - ImpCastExprToType(BaseExpr, BaseType, CastExpr::CK_BitCast); + ImpCastExprToType(BaseExpr, BaseType, CK_BitCast); } } @@ -3099,7 +3099,7 @@ Sema::LookupMemberExpr(LookupResult &R, Expr *&BaseExpr, if (BaseType->isObjCClassType() && BaseType != Context.ObjCClassRedefinitionType) { BaseType = Context.ObjCClassRedefinitionType; - ImpCastExprToType(BaseExpr, BaseType, CastExpr::CK_BitCast); + ImpCastExprToType(BaseExpr, BaseType, CK_BitCast); } if (IsArrow) { @@ -3644,8 +3644,8 @@ Sema::ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, // Determine whether this is a call to a pointer-to-member function. if (BinaryOperator *BO = dyn_cast(NakedFn)) { - if (BO->getOpcode() == BinaryOperator::PtrMemD || - BO->getOpcode() == BinaryOperator::PtrMemI) { + if (BO->getOpcode() == BO_PtrMemD || + BO->getOpcode() == BO_PtrMemI) { if (const FunctionProtoType *FPT = BO->getType()->getAs()) { QualType ResultTy = FPT->getCallResultType(Context); @@ -3867,44 +3867,44 @@ Sema::ActOnInitList(SourceLocation LBraceLoc, MultiExprArg initlist, return Owned(E); } -static CastExpr::CastKind getScalarCastKind(ASTContext &Context, +static CastKind getScalarCastKind(ASTContext &Context, QualType SrcTy, QualType DestTy) { if (Context.hasSameUnqualifiedType(SrcTy, DestTy)) - return CastExpr::CK_NoOp; + return CK_NoOp; if (SrcTy->hasPointerRepresentation()) { if (DestTy->hasPointerRepresentation()) return DestTy->isObjCObjectPointerType() ? - CastExpr::CK_AnyPointerToObjCPointerCast : - CastExpr::CK_BitCast; + CK_AnyPointerToObjCPointerCast : + CK_BitCast; if (DestTy->isIntegerType()) - return CastExpr::CK_PointerToIntegral; + return CK_PointerToIntegral; } if (SrcTy->isIntegerType()) { if (DestTy->isIntegerType()) - return CastExpr::CK_IntegralCast; + return CK_IntegralCast; if (DestTy->hasPointerRepresentation()) - return CastExpr::CK_IntegralToPointer; + return CK_IntegralToPointer; if (DestTy->isRealFloatingType()) - return CastExpr::CK_IntegralToFloating; + return CK_IntegralToFloating; } if (SrcTy->isRealFloatingType()) { if (DestTy->isRealFloatingType()) - return CastExpr::CK_FloatingCast; + return CK_FloatingCast; if (DestTy->isIntegerType()) - return CastExpr::CK_FloatingToIntegral; + return CK_FloatingToIntegral; } // FIXME: Assert here. // assert(false && "Unhandled cast combination!"); - return CastExpr::CK_Unknown; + return CK_Unknown; } /// CheckCastTypes - Check type constraints for casting between types. bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr, - CastExpr::CastKind& Kind, + CastKind& Kind, CXXCastPath &BasePath, bool FunctionalStyle) { if (getLangOptions().CPlusPlus) @@ -3917,7 +3917,7 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr, // type needs to be scalar. if (castType->isVoidType()) { // Cast to void allows any expr type. - Kind = CastExpr::CK_ToVoid; + Kind = CK_ToVoid; return false; } @@ -3932,7 +3932,7 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr, // FIXME: Check that the cast destination type is complete. Diag(TyR.getBegin(), diag::ext_typecheck_cast_nonscalar) << castType << castExpr->getSourceRange(); - Kind = CastExpr::CK_NoOp; + Kind = CK_NoOp; return false; } @@ -3952,7 +3952,7 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr, if (Field == FieldEnd) return Diag(TyR.getBegin(), diag::err_typecheck_cast_to_union_no_type) << castExpr->getType() << castExpr->getSourceRange(); - Kind = CastExpr::CK_ToUnion; + Kind = CK_ToUnion; return false; } @@ -3995,14 +3995,14 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr, Kind = getScalarCastKind(Context, castExpr->getType(), castType); - if (Kind == CastExpr::CK_Unknown || Kind == CastExpr::CK_BitCast) + if (Kind == CK_Unknown || Kind == CK_BitCast) CheckCastAlign(castExpr, castType, TyR); return false; } bool Sema::CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, - CastExpr::CastKind &Kind) { + CastKind &Kind) { assert(VectorTy->isVectorType() && "Not a vector type!"); if (Ty->isVectorType() || Ty->isIntegerType()) { @@ -4017,12 +4017,12 @@ bool Sema::CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, diag::err_invalid_conversion_between_vector_and_scalar) << VectorTy << Ty << R; - Kind = CastExpr::CK_BitCast; + Kind = CK_BitCast; return false; } bool Sema::CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *&CastExpr, - CastExpr::CastKind &Kind) { + CastKind &Kind) { assert(DestTy->isExtVectorType() && "Not an extended vector type!"); QualType SrcTy = CastExpr->getType(); @@ -4033,7 +4033,7 @@ bool Sema::CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *&CastExpr, if (Context.getTypeSize(DestTy) != Context.getTypeSize(SrcTy)) return Diag(R.getBegin(),diag::err_invalid_conversion_between_ext_vectors) << DestTy << SrcTy << R; - Kind = CastExpr::CK_BitCast; + Kind = CK_BitCast; return false; } @@ -4049,7 +4049,7 @@ bool Sema::CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *&CastExpr, ImpCastExprToType(CastExpr, DestElemTy, getScalarCastKind(Context, SrcTy, DestElemTy)); - Kind = CastExpr::CK_VectorSplat; + Kind = CK_VectorSplat; return false; } @@ -4075,7 +4075,7 @@ Sema::ActOnCastExpr(Scope *S, SourceLocation LParenLoc, ParsedType Ty, ExprResult Sema::BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *castExpr) { - CastExpr::CastKind Kind = CastExpr::CK_Unknown; + CastKind Kind = CK_Unknown; CXXCastPath BasePath; if (CheckCastTypes(SourceRange(LParenLoc, RParenLoc), Ty->getType(), castExpr, Kind, BasePath)) @@ -4221,8 +4221,8 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, if (!RHSTy->isVoidType()) Diag(LHS->getLocStart(), diag::ext_typecheck_cond_one_void) << LHS->getSourceRange(); - ImpCastExprToType(LHS, Context.VoidTy, CastExpr::CK_ToVoid); - ImpCastExprToType(RHS, Context.VoidTy, CastExpr::CK_ToVoid); + ImpCastExprToType(LHS, Context.VoidTy, CK_ToVoid); + ImpCastExprToType(RHS, Context.VoidTy, CK_ToVoid); return Context.VoidTy; } // C99 6.5.15p6 - "if one operand is a null pointer constant, the result has @@ -4230,12 +4230,12 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, if ((LHSTy->isAnyPointerType() || LHSTy->isBlockPointerType()) && RHS->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) { // promote the null to a pointer. - ImpCastExprToType(RHS, LHSTy, CastExpr::CK_Unknown); + ImpCastExprToType(RHS, LHSTy, CK_Unknown); return LHSTy; } if ((RHSTy->isAnyPointerType() || RHSTy->isBlockPointerType()) && LHS->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) { - ImpCastExprToType(LHS, RHSTy, CastExpr::CK_Unknown); + ImpCastExprToType(LHS, RHSTy, CK_Unknown); return RHSTy; } @@ -4251,8 +4251,8 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, if (!LHSTy->isBlockPointerType() || !RHSTy->isBlockPointerType()) { if (LHSTy->isVoidPointerType() || RHSTy->isVoidPointerType()) { QualType destType = Context.getPointerType(Context.VoidTy); - ImpCastExprToType(LHS, destType, CastExpr::CK_BitCast); - ImpCastExprToType(RHS, destType, CastExpr::CK_BitCast); + ImpCastExprToType(LHS, destType, CK_BitCast); + ImpCastExprToType(RHS, destType, CK_BitCast); return destType; } Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands) @@ -4276,13 +4276,13 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, // reason, but this is what gcc does, and we do have to pick // to get a consistent AST. QualType incompatTy = Context.getPointerType(Context.VoidTy); - ImpCastExprToType(LHS, incompatTy, CastExpr::CK_BitCast); - ImpCastExprToType(RHS, incompatTy, CastExpr::CK_BitCast); + ImpCastExprToType(LHS, incompatTy, CK_BitCast); + ImpCastExprToType(RHS, incompatTy, CK_BitCast); return incompatTy; } // The block pointer types are compatible. - ImpCastExprToType(LHS, LHSTy, CastExpr::CK_BitCast); - ImpCastExprToType(RHS, LHSTy, CastExpr::CK_BitCast); + ImpCastExprToType(LHS, LHSTy, CK_BitCast); + ImpCastExprToType(RHS, LHSTy, CK_BitCast); return LHSTy; } @@ -4299,9 +4299,9 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, = Context.getQualifiedType(lhptee, rhptee.getQualifiers()); QualType destType = Context.getPointerType(destPointee); // Add qualifiers if necessary. - ImpCastExprToType(LHS, destType, CastExpr::CK_NoOp); + ImpCastExprToType(LHS, destType, CK_NoOp); // Promote to void*. - ImpCastExprToType(RHS, destType, CastExpr::CK_BitCast); + ImpCastExprToType(RHS, destType, CK_BitCast); return destType; } if (rhptee->isVoidType() && lhptee->isIncompleteOrObjectType()) { @@ -4309,9 +4309,9 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, = Context.getQualifiedType(rhptee, lhptee.getQualifiers()); QualType destType = Context.getPointerType(destPointee); // Add qualifiers if necessary. - ImpCastExprToType(RHS, destType, CastExpr::CK_NoOp); + ImpCastExprToType(RHS, destType, CK_NoOp); // Promote to void*. - ImpCastExprToType(LHS, destType, CastExpr::CK_BitCast); + ImpCastExprToType(LHS, destType, CK_BitCast); return destType; } @@ -4327,8 +4327,8 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, // reason, but this is what gcc does, and we do have to pick // to get a consistent AST. QualType incompatTy = Context.getPointerType(Context.VoidTy); - ImpCastExprToType(LHS, incompatTy, CastExpr::CK_BitCast); - ImpCastExprToType(RHS, incompatTy, CastExpr::CK_BitCast); + ImpCastExprToType(LHS, incompatTy, CK_BitCast); + ImpCastExprToType(RHS, incompatTy, CK_BitCast); return incompatTy; } // The pointer types are compatible. @@ -4338,8 +4338,8 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, // type. // FIXME: Need to calculate the composite type. // FIXME: Need to add qualifiers - ImpCastExprToType(LHS, LHSTy, CastExpr::CK_BitCast); - ImpCastExprToType(RHS, LHSTy, CastExpr::CK_BitCast); + ImpCastExprToType(LHS, LHSTy, CK_BitCast); + ImpCastExprToType(RHS, LHSTy, CK_BitCast); return LHSTy; } @@ -4347,13 +4347,13 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, if (RHSTy->isPointerType() && LHSTy->isIntegerType()) { Diag(QuestionLoc, diag::warn_typecheck_cond_pointer_integer_mismatch) << LHSTy << RHSTy << LHS->getSourceRange() << RHS->getSourceRange(); - ImpCastExprToType(LHS, RHSTy, CastExpr::CK_IntegralToPointer); + ImpCastExprToType(LHS, RHSTy, CK_IntegralToPointer); return RHSTy; } if (LHSTy->isPointerType() && RHSTy->isIntegerType()) { Diag(QuestionLoc, diag::warn_typecheck_cond_pointer_integer_mismatch) << LHSTy << RHSTy << LHS->getSourceRange() << RHS->getSourceRange(); - ImpCastExprToType(RHS, LHSTy, CastExpr::CK_IntegralToPointer); + ImpCastExprToType(RHS, LHSTy, CK_IntegralToPointer); return LHSTy; } @@ -4375,34 +4375,34 @@ QualType Sema::FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS, // redefinition type if an attempt is made to access its fields. if (LHSTy->isObjCClassType() && (RHSTy.getDesugaredType() == Context.ObjCClassRedefinitionType)) { - ImpCastExprToType(RHS, LHSTy, CastExpr::CK_BitCast); + ImpCastExprToType(RHS, LHSTy, CK_BitCast); return LHSTy; } if (RHSTy->isObjCClassType() && (LHSTy.getDesugaredType() == Context.ObjCClassRedefinitionType)) { - ImpCastExprToType(LHS, RHSTy, CastExpr::CK_BitCast); + ImpCastExprToType(LHS, RHSTy, CK_BitCast); return RHSTy; } // And the same for struct objc_object* / id if (LHSTy->isObjCIdType() && (RHSTy.getDesugaredType() == Context.ObjCIdRedefinitionType)) { - ImpCastExprToType(RHS, LHSTy, CastExpr::CK_BitCast); + ImpCastExprToType(RHS, LHSTy, CK_BitCast); return LHSTy; } if (RHSTy->isObjCIdType() && (LHSTy.getDesugaredType() == Context.ObjCIdRedefinitionType)) { - ImpCastExprToType(LHS, RHSTy, CastExpr::CK_BitCast); + ImpCastExprToType(LHS, RHSTy, CK_BitCast); return RHSTy; } // And the same for struct objc_selector* / SEL if (Context.isObjCSelType(LHSTy) && (RHSTy.getDesugaredType() == Context.ObjCSelRedefinitionType)) { - ImpCastExprToType(RHS, LHSTy, CastExpr::CK_BitCast); + ImpCastExprToType(RHS, LHSTy, CK_BitCast); return LHSTy; } if (Context.isObjCSelType(RHSTy) && (LHSTy.getDesugaredType() == Context.ObjCSelRedefinitionType)) { - ImpCastExprToType(LHS, RHSTy, CastExpr::CK_BitCast); + ImpCastExprToType(LHS, RHSTy, CK_BitCast); return RHSTy; } // Check constraints for Objective-C object pointers types. @@ -4451,13 +4451,13 @@ QualType Sema::FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS, << LHSTy << RHSTy << LHS->getSourceRange() << RHS->getSourceRange(); QualType incompatTy = Context.getObjCIdType(); - ImpCastExprToType(LHS, incompatTy, CastExpr::CK_BitCast); - ImpCastExprToType(RHS, incompatTy, CastExpr::CK_BitCast); + ImpCastExprToType(LHS, incompatTy, CK_BitCast); + ImpCastExprToType(RHS, incompatTy, CK_BitCast); return incompatTy; } // The object pointer types are compatible. - ImpCastExprToType(LHS, compositeType, CastExpr::CK_BitCast); - ImpCastExprToType(RHS, compositeType, CastExpr::CK_BitCast); + ImpCastExprToType(LHS, compositeType, CK_BitCast); + ImpCastExprToType(RHS, compositeType, CK_BitCast); return compositeType; } // Check Objective-C object pointer types and 'void *' @@ -4468,9 +4468,9 @@ QualType Sema::FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS, = Context.getQualifiedType(lhptee, rhptee.getQualifiers()); QualType destType = Context.getPointerType(destPointee); // Add qualifiers if necessary. - ImpCastExprToType(LHS, destType, CastExpr::CK_NoOp); + ImpCastExprToType(LHS, destType, CK_NoOp); // Promote to void*. - ImpCastExprToType(RHS, destType, CastExpr::CK_BitCast); + ImpCastExprToType(RHS, destType, CK_BitCast); return destType; } if (LHSTy->isObjCObjectPointerType() && RHSTy->isVoidPointerType()) { @@ -4480,9 +4480,9 @@ QualType Sema::FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS, = Context.getQualifiedType(rhptee, lhptee.getQualifiers()); QualType destType = Context.getPointerType(destPointee); // Add qualifiers if necessary. - ImpCastExprToType(RHS, destType, CastExpr::CK_NoOp); + ImpCastExprToType(RHS, destType, CK_NoOp); // Promote to void*. - ImpCastExprToType(LHS, destType, CastExpr::CK_BitCast); + ImpCastExprToType(LHS, destType, CK_BitCast); return destType; } return QualType(); @@ -4904,14 +4904,14 @@ Sema::CheckTransparentUnionArgumentConstraints(QualType ArgType, Expr *&rExpr) { // 2) null pointer constant if (FromType->isPointerType()) if (FromType->getAs()->getPointeeType()->isVoidType()) { - ImpCastExprToType(rExpr, it->getType(), CastExpr::CK_BitCast); + ImpCastExprToType(rExpr, it->getType(), CK_BitCast); InitField = *it; break; } if (rExpr->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) { - ImpCastExprToType(rExpr, it->getType(), CastExpr::CK_IntegralToPointer); + ImpCastExprToType(rExpr, it->getType(), CK_IntegralToPointer); InitField = *it; break; } @@ -4955,7 +4955,7 @@ Sema::CheckSingleAssignmentConstraints(QualType lhsType, Expr *&rExpr) { lhsType->isBlockPointerType()) && rExpr->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) { - ImpCastExprToType(rExpr, lhsType, CastExpr::CK_Unknown); + ImpCastExprToType(rExpr, lhsType, CK_Unknown); return Compatible; } @@ -4979,7 +4979,7 @@ Sema::CheckSingleAssignmentConstraints(QualType lhsType, Expr *&rExpr) { // does not have reference type. if (result != Incompatible && rExpr->getType() != lhsType) ImpCastExprToType(rExpr, lhsType.getNonLValueExprType(Context), - CastExpr::CK_Unknown); + CK_Unknown); return result; } @@ -5011,11 +5011,11 @@ QualType Sema::CheckVectorOperands(SourceLocation Loc, Expr *&lex, Expr *&rex) { if (LV->getElementType() == RV->getElementType() && LV->getNumElements() == RV->getNumElements()) { if (lhsType->isExtVectorType()) { - ImpCastExprToType(rex, lhsType, CastExpr::CK_BitCast); + ImpCastExprToType(rex, lhsType, CK_BitCast); return lhsType; } - ImpCastExprToType(lex, rhsType, CastExpr::CK_BitCast); + ImpCastExprToType(lex, rhsType, CK_BitCast); return rhsType; } } @@ -5024,7 +5024,7 @@ QualType Sema::CheckVectorOperands(SourceLocation Loc, Expr *&lex, Expr *&rex) { // Handle the case of equivalent AltiVec and GCC vector types if (lhsType->isVectorType() && rhsType->isVectorType() && Context.areCompatibleVectorTypes(lhsType, rhsType)) { - ImpCastExprToType(lex, rhsType, CastExpr::CK_BitCast); + ImpCastExprToType(lex, rhsType, CK_BitCast); return rhsType; } @@ -5042,7 +5042,7 @@ QualType Sema::CheckVectorOperands(SourceLocation Loc, Expr *&lex, Expr *&rex) { QualType EltTy = LV->getElementType(); if (EltTy->isIntegralType(Context) && rhsType->isIntegralType(Context)) { if (Context.getIntegerTypeOrder(EltTy, rhsType) >= 0) { - ImpCastExprToType(rex, lhsType, CastExpr::CK_IntegralCast); + ImpCastExprToType(rex, lhsType, CK_IntegralCast); if (swapped) std::swap(rex, lex); return lhsType; } @@ -5050,7 +5050,7 @@ QualType Sema::CheckVectorOperands(SourceLocation Loc, Expr *&lex, Expr *&rex) { if (EltTy->isRealFloatingType() && rhsType->isScalarType() && rhsType->isRealFloatingType()) { if (Context.getFloatingTypeOrder(EltTy, rhsType) >= 0) { - ImpCastExprToType(rex, lhsType, CastExpr::CK_FloatingCast); + ImpCastExprToType(rex, lhsType, CK_FloatingCast); if (swapped) std::swap(rex, lex); return lhsType; } @@ -5350,7 +5350,7 @@ QualType Sema::CheckShiftOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, LHSTy = Context.getPromotedIntegerType(LHSTy); } if (!isCompAssign) - ImpCastExprToType(lex, LHSTy, CastExpr::CK_IntegralCast); + ImpCastExprToType(lex, LHSTy, CK_IntegralCast); UsualUnaryConversions(rex); @@ -5386,7 +5386,7 @@ static bool IsWithinTemplateSpecialization(Decl *D) { // C99 6.5.8, C++ [expr.rel] QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, unsigned OpaqueOpc, bool isRelational) { - BinaryOperator::Opcode Opc = (BinaryOperator::Opcode)OpaqueOpc; + BinaryOperatorKind Opc = (BinaryOperatorKind) OpaqueOpc; // Handle vector comparisons separately. if (lex->getType()->isVectorType() || rex->getType()->isVectorType()) @@ -5415,19 +5415,19 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, !IsWithinTemplateSpecialization(DRL->getDecl())) { DiagRuntimeBehavior(Loc, PDiag(diag::warn_comparison_always) << 0 // self- - << (Opc == BinaryOperator::EQ - || Opc == BinaryOperator::LE - || Opc == BinaryOperator::GE)); + << (Opc == BO_EQ + || Opc == BO_LE + || Opc == BO_GE)); } else if (lType->isArrayType() && rType->isArrayType() && !DRL->getDecl()->getType()->isReferenceType() && !DRR->getDecl()->getType()->isReferenceType()) { // what is it always going to eval to? char always_evals_to; switch(Opc) { - case BinaryOperator::EQ: // e.g. array1 == array2 + case BO_EQ: // e.g. array1 == array2 always_evals_to = 0; // false break; - case BinaryOperator::NE: // e.g. array1 != array2 + case BO_NE: // e.g. array1 != array2 always_evals_to = 1; // true break; default: @@ -5467,12 +5467,12 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, if (literalString) { std::string resultComparison; switch (Opc) { - case BinaryOperator::LT: resultComparison = ") < 0"; break; - case BinaryOperator::GT: resultComparison = ") > 0"; break; - case BinaryOperator::LE: resultComparison = ") <= 0"; break; - case BinaryOperator::GE: resultComparison = ") >= 0"; break; - case BinaryOperator::EQ: resultComparison = ") == 0"; break; - case BinaryOperator::NE: resultComparison = ") != 0"; break; + case BO_LT: resultComparison = ") < 0"; break; + case BO_GT: resultComparison = ") > 0"; break; + case BO_LE: resultComparison = ") <= 0"; break; + case BO_GE: resultComparison = ") >= 0"; break; + case BO_EQ: resultComparison = ") == 0"; break; + case BO_NE: resultComparison = ") != 0"; break; default: assert(false && "Invalid comparison operator"); } @@ -5542,7 +5542,7 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, if (isSFINAEContext()) return QualType(); - ImpCastExprToType(rex, lType, CastExpr::CK_BitCast); + ImpCastExprToType(rex, lType, CK_BitCast); return ResultTy; } } @@ -5568,8 +5568,8 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, << lex->getSourceRange() << rex->getSourceRange(); } - ImpCastExprToType(lex, T, CastExpr::CK_BitCast); - ImpCastExprToType(rex, T, CastExpr::CK_BitCast); + ImpCastExprToType(lex, T, CK_BitCast); + ImpCastExprToType(rex, T, CK_BitCast); return ResultTy; } // C99 6.5.9p2 and C99 6.5.8p2 @@ -5594,7 +5594,7 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, << lType << rType << lex->getSourceRange() << rex->getSourceRange(); } if (LCanPointeeTy != RCanPointeeTy) - ImpCastExprToType(rex, lType, CastExpr::CK_BitCast); + ImpCastExprToType(rex, lType, CK_BitCast); return ResultTy; } @@ -5606,8 +5606,8 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, (!isRelational && lType->isMemberPointerType()))) { ImpCastExprToType(rex, lType, lType->isMemberPointerType() - ? CastExpr::CK_NullToMemberPointer - : CastExpr::CK_IntegralToPointer); + ? CK_NullToMemberPointer + : CK_IntegralToPointer); return ResultTy; } if (LHSIsNull && @@ -5615,8 +5615,8 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, (!isRelational && rType->isMemberPointerType()))) { ImpCastExprToType(lex, rType, rType->isMemberPointerType() - ? CastExpr::CK_NullToMemberPointer - : CastExpr::CK_IntegralToPointer); + ? CK_NullToMemberPointer + : CK_IntegralToPointer); return ResultTy; } @@ -5647,8 +5647,8 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, << lex->getSourceRange() << rex->getSourceRange(); } - ImpCastExprToType(lex, T, CastExpr::CK_BitCast); - ImpCastExprToType(rex, T, CastExpr::CK_BitCast); + ImpCastExprToType(lex, T, CK_BitCast); + ImpCastExprToType(rex, T, CK_BitCast); return ResultTy; } @@ -5667,7 +5667,7 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks) << lType << rType << lex->getSourceRange() << rex->getSourceRange(); } - ImpCastExprToType(rex, lType, CastExpr::CK_BitCast); + ImpCastExprToType(rex, lType, CK_BitCast); return ResultTy; } // Allow block pointers to be compared with null pointer constants. @@ -5682,7 +5682,7 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks) << lType << rType << lex->getSourceRange() << rex->getSourceRange(); } - ImpCastExprToType(rex, lType, CastExpr::CK_BitCast); + ImpCastExprToType(rex, lType, CK_BitCast); return ResultTy; } @@ -5700,14 +5700,14 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers) << lType << rType << lex->getSourceRange() << rex->getSourceRange(); } - ImpCastExprToType(rex, lType, CastExpr::CK_BitCast); + ImpCastExprToType(rex, lType, CK_BitCast); return ResultTy; } if (lType->isObjCObjectPointerType() && rType->isObjCObjectPointerType()) { if (!Context.areComparableObjCPointerTypes(lType, rType)) Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers) << lType << rType << lex->getSourceRange() << rex->getSourceRange(); - ImpCastExprToType(rex, lType, CastExpr::CK_BitCast); + ImpCastExprToType(rex, lType, CK_BitCast); return ResultTy; } } @@ -5735,21 +5735,21 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc, } if (lType->isIntegerType()) - ImpCastExprToType(lex, rType, CastExpr::CK_IntegralToPointer); + ImpCastExprToType(lex, rType, CK_IntegralToPointer); else - ImpCastExprToType(rex, lType, CastExpr::CK_IntegralToPointer); + ImpCastExprToType(rex, lType, CK_IntegralToPointer); return ResultTy; } // Handle block pointers. if (!isRelational && RHSIsNull && lType->isBlockPointerType() && rType->isIntegerType()) { - ImpCastExprToType(rex, lType, CastExpr::CK_IntegralToPointer); + ImpCastExprToType(rex, lType, CK_IntegralToPointer); return ResultTy; } if (!isRelational && LHSIsNull && lType->isIntegerType() && rType->isBlockPointerType()) { - ImpCastExprToType(lex, rType, CastExpr::CK_IntegralToPointer); + ImpCastExprToType(lex, rType, CK_IntegralToPointer); return ResultTy; } return InvalidOperands(Loc, lex, rex); @@ -5844,8 +5844,8 @@ inline QualType Sema::CheckLogicalOperands( // C99 6.5.[13,14] Result.Val.getInt() != 0 && Result.Val.getInt() != 1) { Diag(Loc, diag::warn_logical_instead_of_bitwise) << rex->getSourceRange() - << (Opc == BinaryOperator::LAnd ? "&&" : "||") - << (Opc == BinaryOperator::LAnd ? "&" : "|"); + << (Opc == BO_LAnd ? "&&" : "||") + << (Opc == BO_LAnd ? "&" : "|"); } } @@ -6002,8 +6002,8 @@ QualType Sema::CheckAssignmentOperands(Expr *LHS, Expr *&RHS, if (ImplicitCastExpr *ICE = dyn_cast(RHSCheck)) RHSCheck = ICE->getSubExpr(); if (UnaryOperator *UO = dyn_cast(RHSCheck)) { - if ((UO->getOpcode() == UnaryOperator::Plus || - UO->getOpcode() == UnaryOperator::Minus) && + if ((UO->getOpcode() == UO_Plus || + UO->getOpcode() == UO_Minus) && Loc.isFileID() && UO->getOperatorLoc().isFileID() && // Only if the two operators are exactly adjacent. Loc.getFileLocWithOffset(1) == UO->getOperatorLoc() && @@ -6012,7 +6012,7 @@ QualType Sema::CheckAssignmentOperands(Expr *LHS, Expr *&RHS, Loc.getFileLocWithOffset(2) != UO->getSubExpr()->getLocStart() && UO->getSubExpr()->getLocStart().isFileID()) { Diag(Loc, diag::warn_not_compound_assign) - << (UO->getOpcode() == UnaryOperator::Plus ? "+" : "-") + << (UO->getOpcode() == UO_Plus ? "+" : "-") << SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc()); } } @@ -6033,7 +6033,7 @@ QualType Sema::CheckAssignmentOperands(Expr *LHS, Expr *&RHS, // only handles the pattern "*null = whatever", which is a very syntactic // check. if (UnaryOperator *UO = dyn_cast(LHS->IgnoreParenCasts())) - if (UO->getOpcode() == UnaryOperator::Deref && + if (UO->getOpcode() == UO_Deref && UO->getSubExpr()->IgnoreParenCasts()-> isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull) && !UO->getType().isVolatileQualified()) { @@ -6178,9 +6178,9 @@ static NamedDecl *getPrimaryDecl(Expr *E) { UnaryOperator *UO = cast(E); switch(UO->getOpcode()) { - case UnaryOperator::Real: - case UnaryOperator::Imag: - case UnaryOperator::Extension: + case UO_Real: + case UO_Imag: + case UO_Extension: return getPrimaryDecl(UO->getSubExpr()); default: return 0; @@ -6214,7 +6214,7 @@ QualType Sema::CheckAddressOfOperand(Expr *op, SourceLocation OpLoc) { if (getLangOptions().C99) { // Implement C99-only parts of addressof rules. if (UnaryOperator* uOp = dyn_cast(op)) { - if (uOp->getOpcode() == UnaryOperator::Deref) + if (uOp->getOpcode() == UO_Deref) // Per C99 6.5.3.2, the address of a deref always returns a valid result // (assuming the deref expression is valid). return uOp->getSubExpr()->getType(); @@ -6364,63 +6364,63 @@ QualType Sema::CheckIndirectionOperand(Expr *Op, SourceLocation OpLoc) { return Result; } -static inline BinaryOperator::Opcode ConvertTokenKindToBinaryOpcode( +static inline BinaryOperatorKind ConvertTokenKindToBinaryOpcode( tok::TokenKind Kind) { - BinaryOperator::Opcode Opc; + BinaryOperatorKind Opc; switch (Kind) { default: assert(0 && "Unknown binop!"); - case tok::periodstar: Opc = BinaryOperator::PtrMemD; break; - case tok::arrowstar: Opc = BinaryOperator::PtrMemI; break; - case tok::star: Opc = BinaryOperator::Mul; break; - case tok::slash: Opc = BinaryOperator::Div; break; - case tok::percent: Opc = BinaryOperator::Rem; break; - case tok::plus: Opc = BinaryOperator::Add; break; - case tok::minus: Opc = BinaryOperator::Sub; break; - case tok::lessless: Opc = BinaryOperator::Shl; break; - case tok::greatergreater: Opc = BinaryOperator::Shr; break; - case tok::lessequal: Opc = BinaryOperator::LE; break; - case tok::less: Opc = BinaryOperator::LT; break; - case tok::greaterequal: Opc = BinaryOperator::GE; break; - case tok::greater: Opc = BinaryOperator::GT; break; - case tok::exclaimequal: Opc = BinaryOperator::NE; break; - case tok::equalequal: Opc = BinaryOperator::EQ; break; - case tok::amp: Opc = BinaryOperator::And; break; - case tok::caret: Opc = BinaryOperator::Xor; break; - case tok::pipe: Opc = BinaryOperator::Or; break; - case tok::ampamp: Opc = BinaryOperator::LAnd; break; - case tok::pipepipe: Opc = BinaryOperator::LOr; break; - case tok::equal: Opc = BinaryOperator::Assign; break; - case tok::starequal: Opc = BinaryOperator::MulAssign; break; - case tok::slashequal: Opc = BinaryOperator::DivAssign; break; - case tok::percentequal: Opc = BinaryOperator::RemAssign; break; - case tok::plusequal: Opc = BinaryOperator::AddAssign; break; - case tok::minusequal: Opc = BinaryOperator::SubAssign; break; - case tok::lesslessequal: Opc = BinaryOperator::ShlAssign; break; - case tok::greatergreaterequal: Opc = BinaryOperator::ShrAssign; break; - case tok::ampequal: Opc = BinaryOperator::AndAssign; break; - case tok::caretequal: Opc = BinaryOperator::XorAssign; break; - case tok::pipeequal: Opc = BinaryOperator::OrAssign; break; - case tok::comma: Opc = BinaryOperator::Comma; break; + case tok::periodstar: Opc = BO_PtrMemD; break; + case tok::arrowstar: Opc = BO_PtrMemI; break; + case tok::star: Opc = BO_Mul; break; + case tok::slash: Opc = BO_Div; break; + case tok::percent: Opc = BO_Rem; break; + case tok::plus: Opc = BO_Add; break; + case tok::minus: Opc = BO_Sub; break; + case tok::lessless: Opc = BO_Shl; break; + case tok::greatergreater: Opc = BO_Shr; break; + case tok::lessequal: Opc = BO_LE; break; + case tok::less: Opc = BO_LT; break; + case tok::greaterequal: Opc = BO_GE; break; + case tok::greater: Opc = BO_GT; break; + case tok::exclaimequal: Opc = BO_NE; break; + case tok::equalequal: Opc = BO_EQ; break; + case tok::amp: Opc = BO_And; break; + case tok::caret: Opc = BO_Xor; break; + case tok::pipe: Opc = BO_Or; break; + case tok::ampamp: Opc = BO_LAnd; break; + case tok::pipepipe: Opc = BO_LOr; break; + case tok::equal: Opc = BO_Assign; break; + case tok::starequal: Opc = BO_MulAssign; break; + case tok::slashequal: Opc = BO_DivAssign; break; + case tok::percentequal: Opc = BO_RemAssign; break; + case tok::plusequal: Opc = BO_AddAssign; break; + case tok::minusequal: Opc = BO_SubAssign; break; + case tok::lesslessequal: Opc = BO_ShlAssign; break; + case tok::greatergreaterequal: Opc = BO_ShrAssign; break; + case tok::ampequal: Opc = BO_AndAssign; break; + case tok::caretequal: Opc = BO_XorAssign; break; + case tok::pipeequal: Opc = BO_OrAssign; break; + case tok::comma: Opc = BO_Comma; break; } return Opc; } -static inline UnaryOperator::Opcode ConvertTokenKindToUnaryOpcode( +static inline UnaryOperatorKind ConvertTokenKindToUnaryOpcode( tok::TokenKind Kind) { - UnaryOperator::Opcode Opc; + UnaryOperatorKind Opc; switch (Kind) { default: assert(0 && "Unknown unary op!"); - case tok::plusplus: Opc = UnaryOperator::PreInc; break; - case tok::minusminus: Opc = UnaryOperator::PreDec; break; - case tok::amp: Opc = UnaryOperator::AddrOf; break; - case tok::star: Opc = UnaryOperator::Deref; break; - case tok::plus: Opc = UnaryOperator::Plus; break; - case tok::minus: Opc = UnaryOperator::Minus; break; - case tok::tilde: Opc = UnaryOperator::Not; break; - case tok::exclaim: Opc = UnaryOperator::LNot; break; - case tok::kw___real: Opc = UnaryOperator::Real; break; - case tok::kw___imag: Opc = UnaryOperator::Imag; break; - case tok::kw___extension__: Opc = UnaryOperator::Extension; break; + case tok::plusplus: Opc = UO_PreInc; break; + case tok::minusminus: Opc = UO_PreDec; break; + case tok::amp: Opc = UO_AddrOf; break; + case tok::star: Opc = UO_Deref; break; + case tok::plus: Opc = UO_Plus; break; + case tok::minus: Opc = UO_Minus; break; + case tok::tilde: Opc = UO_Not; break; + case tok::exclaim: Opc = UO_LNot; break; + case tok::kw___real: Opc = UO_Real; break; + case tok::kw___imag: Opc = UO_Imag; break; + case tok::kw___extension__: Opc = UO_Extension; break; } return Opc; } @@ -6429,107 +6429,107 @@ static inline UnaryOperator::Opcode ConvertTokenKindToUnaryOpcode( /// operator @p Opc at location @c TokLoc. This routine only supports /// built-in operations; ActOnBinOp handles overloaded operators. ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc, - unsigned Op, - Expr *lhs, Expr *rhs) { + unsigned Op, + Expr *lhs, Expr *rhs) { QualType ResultTy; // Result type of the binary operator. - BinaryOperator::Opcode Opc = (BinaryOperator::Opcode)Op; + BinaryOperatorKind Opc = (BinaryOperatorKind) Op; // The following two variables are used for compound assignment operators QualType CompLHSTy; // Type of LHS after promotions for computation QualType CompResultTy; // Type of computation result switch (Opc) { - case BinaryOperator::Assign: + case BO_Assign: ResultTy = CheckAssignmentOperands(lhs, rhs, OpLoc, QualType()); break; - case BinaryOperator::PtrMemD: - case BinaryOperator::PtrMemI: + case BO_PtrMemD: + case BO_PtrMemI: ResultTy = CheckPointerToMemberOperands(lhs, rhs, OpLoc, - Opc == BinaryOperator::PtrMemI); + Opc == BO_PtrMemI); break; - case BinaryOperator::Mul: - case BinaryOperator::Div: + case BO_Mul: + case BO_Div: ResultTy = CheckMultiplyDivideOperands(lhs, rhs, OpLoc, false, - Opc == BinaryOperator::Div); + Opc == BO_Div); break; - case BinaryOperator::Rem: + case BO_Rem: ResultTy = CheckRemainderOperands(lhs, rhs, OpLoc); break; - case BinaryOperator::Add: + case BO_Add: ResultTy = CheckAdditionOperands(lhs, rhs, OpLoc); break; - case BinaryOperator::Sub: + case BO_Sub: ResultTy = CheckSubtractionOperands(lhs, rhs, OpLoc); break; - case BinaryOperator::Shl: - case BinaryOperator::Shr: + case BO_Shl: + case BO_Shr: ResultTy = CheckShiftOperands(lhs, rhs, OpLoc); break; - case BinaryOperator::LE: - case BinaryOperator::LT: - case BinaryOperator::GE: - case BinaryOperator::GT: + case BO_LE: + case BO_LT: + case BO_GE: + case BO_GT: ResultTy = CheckCompareOperands(lhs, rhs, OpLoc, Opc, true); break; - case BinaryOperator::EQ: - case BinaryOperator::NE: + case BO_EQ: + case BO_NE: ResultTy = CheckCompareOperands(lhs, rhs, OpLoc, Opc, false); break; - case BinaryOperator::And: - case BinaryOperator::Xor: - case BinaryOperator::Or: + case BO_And: + case BO_Xor: + case BO_Or: ResultTy = CheckBitwiseOperands(lhs, rhs, OpLoc); break; - case BinaryOperator::LAnd: - case BinaryOperator::LOr: + case BO_LAnd: + case BO_LOr: ResultTy = CheckLogicalOperands(lhs, rhs, OpLoc, Opc); break; - case BinaryOperator::MulAssign: - case BinaryOperator::DivAssign: + case BO_MulAssign: + case BO_DivAssign: CompResultTy = CheckMultiplyDivideOperands(lhs, rhs, OpLoc, true, - Opc == BinaryOperator::DivAssign); + Opc == BO_DivAssign); CompLHSTy = CompResultTy; if (!CompResultTy.isNull()) ResultTy = CheckAssignmentOperands(lhs, rhs, OpLoc, CompResultTy); break; - case BinaryOperator::RemAssign: + case BO_RemAssign: CompResultTy = CheckRemainderOperands(lhs, rhs, OpLoc, true); CompLHSTy = CompResultTy; if (!CompResultTy.isNull()) ResultTy = CheckAssignmentOperands(lhs, rhs, OpLoc, CompResultTy); break; - case BinaryOperator::AddAssign: + case BO_AddAssign: CompResultTy = CheckAdditionOperands(lhs, rhs, OpLoc, &CompLHSTy); if (!CompResultTy.isNull()) ResultTy = CheckAssignmentOperands(lhs, rhs, OpLoc, CompResultTy); break; - case BinaryOperator::SubAssign: + case BO_SubAssign: CompResultTy = CheckSubtractionOperands(lhs, rhs, OpLoc, &CompLHSTy); if (!CompResultTy.isNull()) ResultTy = CheckAssignmentOperands(lhs, rhs, OpLoc, CompResultTy); break; - case BinaryOperator::ShlAssign: - case BinaryOperator::ShrAssign: + case BO_ShlAssign: + case BO_ShrAssign: CompResultTy = CheckShiftOperands(lhs, rhs, OpLoc, true); CompLHSTy = CompResultTy; if (!CompResultTy.isNull()) ResultTy = CheckAssignmentOperands(lhs, rhs, OpLoc, CompResultTy); break; - case BinaryOperator::AndAssign: - case BinaryOperator::XorAssign: - case BinaryOperator::OrAssign: + case BO_AndAssign: + case BO_XorAssign: + case BO_OrAssign: CompResultTy = CheckBitwiseOperands(lhs, rhs, OpLoc, true); CompLHSTy = CompResultTy; if (!CompResultTy.isNull()) ResultTy = CheckAssignmentOperands(lhs, rhs, OpLoc, CompResultTy); break; - case BinaryOperator::Comma: + case BO_Comma: ResultTy = CheckCommaOperands(lhs, rhs, OpLoc); break; } if (ResultTy.isNull()) return ExprError(); if (ResultTy->isObjCObjectType() && LangOpts.ObjCNonFragileABI) { - if (Opc >= BinaryOperator::Assign && Opc <= BinaryOperator::OrAssign) + if (Opc >= BO_Assign && Opc <= BO_OrAssign) Diag(OpLoc, diag::err_assignment_requires_nonfragile_object) << ResultTy; } @@ -6584,7 +6584,7 @@ static void SuggestParentheses(Sema &Self, SourceLocation Loc, /// operators are mixed in a way that suggests that the programmer forgot that /// comparison operators have higher precedence. The most typical example of /// such code is "flags & 0x0020 != 0", which is equivalent to "flags & 1". -static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperator::Opcode Opc, +static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc,Expr *lhs,Expr *rhs){ typedef BinaryOperator BinOp; BinOp::Opcode lhsopc = static_cast(-1), @@ -6631,7 +6631,7 @@ static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperator::Opcode Opc, /// DiagnoseBinOpPrecedence - Emit warnings for expressions with tricky /// precedence. This currently diagnoses only "arg1 'bitwise' arg2 'eq' arg3". /// But it could also warn about arg1 && arg2 || arg3, as GCC 4.3+ does. -static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperator::Opcode Opc, +static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *lhs, Expr *rhs){ if (BinaryOperator::isBitwiseOp(Opc)) DiagnoseBitwisePrecedence(Self, Opc, OpLoc, lhs, rhs); @@ -6639,9 +6639,9 @@ static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperator::Opcode Opc, // Binary Operators. 'Tok' is the token for the operator. ExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc, - tok::TokenKind Kind, - Expr *lhs, Expr *rhs) { - BinaryOperator::Opcode Opc = ConvertTokenKindToBinaryOpcode(Kind); + tok::TokenKind Kind, + Expr *lhs, Expr *rhs) { + BinaryOperatorKind Opc = ConvertTokenKindToBinaryOpcode(Kind); assert((lhs != 0) && "ActOnBinOp(): missing left expression"); assert((rhs != 0) && "ActOnBinOp(): missing right expression"); @@ -6652,8 +6652,8 @@ ExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc, } ExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc, - BinaryOperator::Opcode Opc, - Expr *lhs, Expr *rhs) { + BinaryOperatorKind Opc, + Expr *lhs, Expr *rhs) { if (getLangOptions().CPlusPlus && (lhs->getType()->isOverloadableType() || rhs->getType()->isOverloadableType())) { @@ -6679,29 +6679,29 @@ ExprResult Sema::BuildBinOp(Scope *S, SourceLocation OpLoc, ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, unsigned OpcIn, Expr *Input) { - UnaryOperator::Opcode Opc = static_cast(OpcIn); + UnaryOperatorKind Opc = static_cast(OpcIn); QualType resultType; switch (Opc) { - case UnaryOperator::PreInc: - case UnaryOperator::PreDec: - case UnaryOperator::PostInc: - case UnaryOperator::PostDec: + case UO_PreInc: + case UO_PreDec: + case UO_PostInc: + case UO_PostDec: resultType = CheckIncrementDecrementOperand(Input, OpLoc, - Opc == UnaryOperator::PreInc || - Opc == UnaryOperator::PostInc, - Opc == UnaryOperator::PreInc || - Opc == UnaryOperator::PreDec); + Opc == UO_PreInc || + Opc == UO_PostInc, + Opc == UO_PreInc || + Opc == UO_PreDec); break; - case UnaryOperator::AddrOf: + case UO_AddrOf: resultType = CheckAddressOfOperand(Input, OpLoc); break; - case UnaryOperator::Deref: + case UO_Deref: DefaultFunctionArrayLvalueConversion(Input); resultType = CheckIndirectionOperand(Input, OpLoc); break; - case UnaryOperator::Plus: - case UnaryOperator::Minus: + case UO_Plus: + case UO_Minus: UsualUnaryConversions(Input); resultType = Input->getType(); if (resultType->isDependentType()) @@ -6713,13 +6713,13 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, resultType->isEnumeralType()) break; else if (getLangOptions().CPlusPlus && // C++ [expr.unary.op]p6 - Opc == UnaryOperator::Plus && + Opc == UO_Plus && resultType->isPointerType()) break; return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr) << resultType << Input->getSourceRange()); - case UnaryOperator::Not: // bitwise complement + case UO_Not: // bitwise complement UsualUnaryConversions(Input); resultType = Input->getType(); if (resultType->isDependentType()) @@ -6733,7 +6733,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr) << resultType << Input->getSourceRange()); break; - case UnaryOperator::LNot: // logical negation + case UO_LNot: // logical negation // Unlike +/-/~, integer promotions aren't done here (C99 6.5.3.3p5). DefaultFunctionArrayLvalueConversion(Input); resultType = Input->getType(); @@ -6746,11 +6746,11 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, // In C++, it's bool. C++ 5.3.1p8 resultType = getLangOptions().CPlusPlus ? Context.BoolTy : Context.IntTy; break; - case UnaryOperator::Real: - case UnaryOperator::Imag: - resultType = CheckRealImagOperand(Input, OpLoc, Opc == UnaryOperator::Real); + case UO_Real: + case UO_Imag: + resultType = CheckRealImagOperand(Input, OpLoc, Opc == UO_Real); break; - case UnaryOperator::Extension: + case UO_Extension: resultType = Input->getType(); break; } @@ -6761,10 +6761,10 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, } ExprResult Sema::BuildUnaryOp(Scope *S, SourceLocation OpLoc, - UnaryOperator::Opcode Opc, - Expr *Input) { + UnaryOperatorKind Opc, + Expr *Input) { if (getLangOptions().CPlusPlus && Input->getType()->isOverloadableType() && - Opc != UnaryOperator::Extension) { + Opc != UO_Extension) { // Find all of the overloaded operators visible from this // point. We perform both an operator-name lookup from the local // scope and an argument-dependent lookup based on the types of @@ -7820,7 +7820,7 @@ void Sema::DiagnoseAssignmentAsCondition(Expr *E) { if (isa(E)) { BinaryOperator *Op = cast(E); - if (Op->getOpcode() != BinaryOperator::Assign) + if (Op->getOpcode() != BO_Assign) return; // Greylist some idioms by putting them into a warning subcategory. diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 6b54e2e671..be84833995 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -320,7 +320,7 @@ ExprResult Sema::BuildCXXTypeId(QualType TypeInfoType, QualType UnqualT = Context.getUnqualifiedArrayType(T, Quals); if (!Context.hasSameType(T, UnqualT)) { T = UnqualT; - ImpCastExprToType(E, UnqualT, CastExpr::CK_NoOp, CastCategory(E)); + ImpCastExprToType(E, UnqualT, CK_NoOp, CastCategory(E)); } } @@ -402,7 +402,7 @@ bool Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E) { // the type from "array of T" or "function returning T" to "pointer to T" // or "pointer to function returning T", [...] if (E->getType().hasQualifiers()) - ImpCastExprToType(E, E->getType().getUnqualifiedType(), CastExpr::CK_NoOp, + ImpCastExprToType(E, E->getType().getUnqualifiedType(), CK_NoOp, CastCategory(E)); DefaultFunctionArrayConversion(E); @@ -534,7 +534,7 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, ParsedType TypeRep, // corresponding cast expression. // if (NumExprs == 1) { - CastExpr::CastKind Kind = CastExpr::CK_Unknown; + CastKind Kind = CK_Unknown; CXXCastPath BasePath; if (CheckCastTypes(TypeRange, Ty, Exprs[0], Kind, BasePath, /*FunctionalStyle=*/true)) @@ -742,7 +742,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, } ImpCastExprToType(ArraySize, Context.getSizeType(), - CastExpr::CK_IntegralCast); + CK_IntegralCast); } FunctionDecl *OperatorNew = 0; @@ -1464,7 +1464,7 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, // (5.2.11) of the pointer expression before it is used as the operand // of the delete-expression. ] ImpCastExprToType(Ex, Context.getPointerType(Context.VoidTy), - CastExpr::CK_NoOp); + CK_NoOp); DeclarationName DeleteName = Context.DeclarationNames.getCXXOperatorName( ArrayForm ? OO_Array_Delete : OO_Delete); @@ -1573,14 +1573,14 @@ Sema::IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType) { } static ExprResult BuildCXXCastArgument(Sema &S, - SourceLocation CastLoc, - QualType Ty, - CastExpr::CastKind Kind, - CXXMethodDecl *Method, - Expr *From) { + SourceLocation CastLoc, + QualType Ty, + CastKind Kind, + CXXMethodDecl *Method, + Expr *From) { switch (Kind) { default: assert(0 && "Unhandled cast kind!"); - case CastExpr::CK_ConstructorConversion: { + case CK_ConstructorConversion: { ASTOwningVector ConstructorArgs(S); if (S.CompleteConstructorCall(cast(Method), @@ -1598,7 +1598,7 @@ static ExprResult BuildCXXCastArgument(Sema &S, return S.MaybeBindToTemporary(Result.takeAs()); } - case CastExpr::CK_UserDefinedConversion: { + case CK_UserDefinedConversion: { assert(!From->getType()->isPointerType() && "Arg can't have pointer type!"); // Create an implicit call expr that calls it. @@ -1629,10 +1629,10 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, case ImplicitConversionSequence::UserDefinedConversion: { FunctionDecl *FD = ICS.UserDefined.ConversionFunction; - CastExpr::CastKind CastKind = CastExpr::CK_Unknown; + CastKind CastKind = CK_Unknown; QualType BeforeToType; if (const CXXConversionDecl *Conv = dyn_cast(FD)) { - CastKind = CastExpr::CK_UserDefinedConversion; + CastKind = CK_UserDefinedConversion; // If the user-defined conversion is specified by a conversion function, // the initial standard conversion sequence converts the source type to @@ -1640,7 +1640,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, BeforeToType = Context.getTagDeclType(Conv->getParent()); } else if (const CXXConstructorDecl *Ctor = dyn_cast(FD)) { - CastKind = CastExpr::CK_ConstructorConversion; + CastKind = CK_ConstructorConversion; // Do no conversion if dealing with ... for the first conversion. if (!ICS.UserDefined.EllipsisConversion) { // If the user-defined conversion is specified by a constructor, the @@ -1768,12 +1768,12 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, case ICK_Array_To_Pointer: FromType = Context.getArrayDecayedType(FromType); - ImpCastExprToType(From, FromType, CastExpr::CK_ArrayToPointerDecay); + ImpCastExprToType(From, FromType, CK_ArrayToPointerDecay); break; case ICK_Function_To_Pointer: FromType = Context.getPointerType(FromType); - ImpCastExprToType(From, FromType, CastExpr::CK_FunctionToPointerDecay); + ImpCastExprToType(From, FromType, CK_FunctionToPointerDecay); break; default: @@ -1798,33 +1798,33 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, return true; ImpCastExprToType(From, Context.getNoReturnType(From->getType(), false), - CastExpr::CK_NoOp); + CK_NoOp); break; case ICK_Integral_Promotion: case ICK_Integral_Conversion: - ImpCastExprToType(From, ToType, CastExpr::CK_IntegralCast); + ImpCastExprToType(From, ToType, CK_IntegralCast); break; case ICK_Floating_Promotion: case ICK_Floating_Conversion: - ImpCastExprToType(From, ToType, CastExpr::CK_FloatingCast); + ImpCastExprToType(From, ToType, CK_FloatingCast); break; case ICK_Complex_Promotion: case ICK_Complex_Conversion: - ImpCastExprToType(From, ToType, CastExpr::CK_Unknown); + ImpCastExprToType(From, ToType, CK_Unknown); break; case ICK_Floating_Integral: if (ToType->isRealFloatingType()) - ImpCastExprToType(From, ToType, CastExpr::CK_IntegralToFloating); + ImpCastExprToType(From, ToType, CK_IntegralToFloating); else - ImpCastExprToType(From, ToType, CastExpr::CK_FloatingToIntegral); + ImpCastExprToType(From, ToType, CK_FloatingToIntegral); break; case ICK_Compatible_Conversion: - ImpCastExprToType(From, ToType, CastExpr::CK_NoOp); + ImpCastExprToType(From, ToType, CK_NoOp); break; case ICK_Pointer_Conversion: { @@ -1837,7 +1837,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, } - CastExpr::CastKind Kind = CastExpr::CK_Unknown; + CastKind Kind = CK_Unknown; CXXCastPath BasePath; if (CheckPointerConversion(From, ToType, Kind, BasePath, IgnoreBaseAccess)) return true; @@ -1846,7 +1846,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, } case ICK_Pointer_Member: { - CastExpr::CastKind Kind = CastExpr::CK_Unknown; + CastKind Kind = CK_Unknown; CXXCastPath BasePath; if (CheckMemberPointerConversion(From, ToType, Kind, BasePath, IgnoreBaseAccess)) @@ -1857,9 +1857,9 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, break; } case ICK_Boolean_Conversion: { - CastExpr::CastKind Kind = CastExpr::CK_Unknown; + CastKind Kind = CK_Unknown; if (FromType->isMemberPointerType()) - Kind = CastExpr::CK_MemberPointerToBoolean; + Kind = CK_MemberPointerToBoolean; ImpCastExprToType(From, Context.BoolTy, Kind); break; @@ -1876,21 +1876,21 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, return true; ImpCastExprToType(From, ToType.getNonReferenceType(), - CastExpr::CK_DerivedToBase, CastCategory(From), + CK_DerivedToBase, CastCategory(From), &BasePath); break; } case ICK_Vector_Conversion: - ImpCastExprToType(From, ToType, CastExpr::CK_BitCast); + ImpCastExprToType(From, ToType, CK_BitCast); break; case ICK_Vector_Splat: - ImpCastExprToType(From, ToType, CastExpr::CK_VectorSplat); + ImpCastExprToType(From, ToType, CK_VectorSplat); break; case ICK_Complex_Real: - ImpCastExprToType(From, ToType, CastExpr::CK_Unknown); + ImpCastExprToType(From, ToType, CK_Unknown); break; case ICK_Lvalue_To_Rvalue: @@ -1913,7 +1913,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, ExprValueKind VK = ToType->isReferenceType() ? CastCategory(From) : VK_RValue; ImpCastExprToType(From, ToType.getNonLValueExprType(Context), - CastExpr::CK_NoOp, VK); + CK_NoOp, VK); if (SCS.DeprecatedStringLiteralToCharPtr) Diag(From->getLocStart(), diag::warn_deprecated_string_literal_conversion) @@ -2418,16 +2418,16 @@ QualType Sema::FindCompositePointerType(SourceLocation Loc, // the type of the other operand. if (E1->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) { if (T2->isMemberPointerType()) - ImpCastExprToType(E1, T2, CastExpr::CK_NullToMemberPointer); + ImpCastExprToType(E1, T2, CK_NullToMemberPointer); else - ImpCastExprToType(E1, T2, CastExpr::CK_IntegralToPointer); + ImpCastExprToType(E1, T2, CK_IntegralToPointer); return T2; } if (E2->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull)) { if (T1->isMemberPointerType()) - ImpCastExprToType(E2, T1, CastExpr::CK_NullToMemberPointer); + ImpCastExprToType(E2, T1, CK_NullToMemberPointer); else - ImpCastExprToType(E2, T1, CastExpr::CK_IntegralToPointer); + ImpCastExprToType(E2, T1, CK_IntegralToPointer); return T1; } diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 55ae6bfecf..9558d3c875 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -974,10 +974,10 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver, << Receiver->getSourceRange(); if (ReceiverType->isPointerType()) ImpCastExprToType(Receiver, Context.getObjCIdType(), - CastExpr::CK_BitCast); + CK_BitCast); else ImpCastExprToType(Receiver, Context.getObjCIdType(), - CastExpr::CK_IntegralToPointer); + CK_IntegralToPointer); ReceiverType = Receiver->getType(); } else if (getLangOptions().CPlusPlus && diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 57a1874ed4..7b9c25e456 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -3621,7 +3621,7 @@ InitializationSequence::Perform(Sema &S, VK_RValue); CurInit = S.Owned(ImplicitCastExpr::Create(S.Context, Step->Type, - CastExpr::CK_DerivedToBase, + CK_DerivedToBase, CurInit.get(), &BasePath, VK)); break; @@ -3672,7 +3672,7 @@ InitializationSequence::Perform(Sema &S, case SK_UserConversion: { // We have a user-defined conversion that invokes either a constructor // or a conversion function. - CastExpr::CastKind CastKind = CastExpr::CK_Unknown; + CastKind CastKind = CK_Unknown; bool IsCopy = false; FunctionDecl *Fn = Step->Function.Function; DeclAccessPair FoundFn = Step->Function.FoundDecl; @@ -3703,7 +3703,7 @@ InitializationSequence::Perform(Sema &S, FoundFn.getAccess()); S.DiagnoseUseOfDecl(FoundFn, Kind.getLocation()); - CastKind = CastExpr::CK_ConstructorConversion; + CastKind = CK_ConstructorConversion; QualType Class = S.Context.getTypeDeclType(Constructor->getParent()); if (S.Context.hasSameUnqualifiedType(SourceType, Class) || S.IsDerivedFrom(SourceType, Class)) @@ -3735,7 +3735,7 @@ InitializationSequence::Perform(Sema &S, if (CurInit.isInvalid() || !CurInit.get()) return S.ExprError(); - CastKind = CastExpr::CK_UserDefinedConversion; + CastKind = CK_UserDefinedConversion; CreatedObject = Conversion->getResultType()->isRecordType(); } @@ -3780,7 +3780,7 @@ InitializationSequence::Perform(Sema &S, (Step->Kind == SK_QualificationConversionXValue ? VK_XValue : VK_RValue); - S.ImpCastExprToType(CurInitExpr, Step->Type, CastExpr::CK_NoOp, VK); + S.ImpCastExprToType(CurInitExpr, Step->Type, CK_NoOp, VK); CurInit.release(); CurInit = S.Owned(CurInitExpr); break; @@ -3949,7 +3949,7 @@ InitializationSequence::Perform(Sema &S, case SK_ObjCObjectConversion: S.ImpCastExprToType(CurInitExpr, Step->Type, - CastExpr::CK_ObjCObjectLValueCast, + CK_ObjCObjectLValueCast, S.CastCategory(CurInitExpr)); CurInit.release(); CurInit = S.Owned(CurInitExpr); diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 4cc78ef976..eedfa92c3b 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -1958,7 +1958,7 @@ Sema::FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs, // parameter types and return type. Arg = Arg->IgnoreParens(); if (UnaryOperator *unaryOp = dyn_cast(Arg)) - if (unaryOp->getOpcode() == UnaryOperator::AddrOf) + if (unaryOp->getOpcode() == UO_AddrOf) Arg = unaryOp->getSubExpr(); UnresolvedLookupExpr *ULE = dyn_cast(Arg); diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 6e273f5ee8..7d5f15d814 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -497,7 +497,7 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, Expr *rhs = new (Context) DeclRefExpr(Param,Param->getType(), SourceLocation()); ExprResult Res = BuildBinOp(S, SourceLocation(), - BinaryOperator::Assign, lhs, rhs); + BO_Assign, lhs, rhs); PIDecl->setSetterCXXAssignment(Res.takeAs()); } } diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 0645d97617..5dbb966867 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -976,7 +976,7 @@ static bool IsStandardConversion(Sema &S, Expr* From, QualType ToType, // function, update the type of the resulting expression accordingly. if (FromType->getAs()) if (UnaryOperator *UnOp = dyn_cast(From->IgnoreParens())) - if (UnOp->getOpcode() == UnaryOperator::AddrOf) + if (UnOp->getOpcode() == UO_AddrOf) FromType = S.Context.getPointerType(FromType); // Check that we've computed the proper type after overload resolution. @@ -1722,7 +1722,7 @@ bool Sema::FunctionArgTypesAreEqual(FunctionProtoType* OldType, /// true. It returns true and produces a diagnostic if there was an /// error, or returns false otherwise. bool Sema::CheckPointerConversion(Expr *From, QualType ToType, - CastExpr::CastKind &Kind, + CastKind &Kind, CXXCastPath& BasePath, bool IgnoreBaseAccess) { QualType FromType = From->getType(); @@ -1749,7 +1749,7 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType, return true; // The conversion was successful. - Kind = CastExpr::CK_DerivedToBase; + Kind = CK_DerivedToBase; } } if (const ObjCObjectPointerType *FromPtrType = @@ -1814,7 +1814,7 @@ bool Sema::IsMemberPointerConversion(Expr *From, QualType FromType, /// true and produces a diagnostic if there was an error, or returns false /// otherwise. bool Sema::CheckMemberPointerConversion(Expr *From, QualType ToType, - CastExpr::CastKind &Kind, + CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess) { QualType FromType = From->getType(); @@ -1824,7 +1824,7 @@ bool Sema::CheckMemberPointerConversion(Expr *From, QualType ToType, assert(From->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNull) && "Expr must be null pointer constant!"); - Kind = CastExpr::CK_NullToMemberPointer; + Kind = CK_NullToMemberPointer; return false; } @@ -1868,7 +1868,7 @@ bool Sema::CheckMemberPointerConversion(Expr *From, QualType ToType, // Must be a base to derived member conversion. BuildBasePathArray(Paths, BasePath); - Kind = CastExpr::CK_BaseToDerivedMemberPointer; + Kind = CK_BaseToDerivedMemberPointer; return false; } @@ -3160,7 +3160,7 @@ Sema::PerformObjectArgumentInitialization(Expr *&From, return PerformObjectMemberConversion(From, Qualifier, FoundDecl, Method); if (!Context.hasSameType(From->getType(), DestType)) - ImpCastExprToType(From, DestType, CastExpr::CK_NoOp, + ImpCastExprToType(From, DestType, CK_NoOp, From->getType()->isPointerType() ? VK_RValue : VK_LValue); return false; } @@ -3846,7 +3846,7 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion, From->getLocStart()); ImplicitCastExpr ConversionFn(ImplicitCastExpr::OnStack, Context.getPointerType(Conversion->getType()), - CastExpr::CK_FunctionToPointerDecay, + CK_FunctionToPointerDecay, &ConversionRef, VK_RValue); // Note that it is safe to allocate CallExpr on the stack here because @@ -6762,7 +6762,7 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn, // For post-increment and post-decrement, add the implicit '0' as // the second argument, so that we know this is a post-increment or // post-decrement. - if (Opc == UnaryOperator::PostInc || Opc == UnaryOperator::PostDec) { + if (Opc == UO_PostInc || Opc == UO_PostDec) { llvm::APSInt Zero(Context.getTypeSize(Context.IntTy), false); Args[1] = new (Context) IntegerLiteral(Zero, Context.IntTy, SourceLocation()); @@ -6932,7 +6932,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, if (Fns.empty()) { // If there are no functions to store, just build a dependent // BinaryOperator or CompoundAssignment. - if (Opc <= BinaryOperator::Assign || Opc > BinaryOperator::OrAssign) + if (Opc <= BO_Assign || Opc > BO_OrAssign) return Owned(new (Context) BinaryOperator(Args[0], Args[1], Opc, Context.DependentTy, OpLoc)); @@ -6960,7 +6960,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, // If this is the .* operator, which is not overloadable, just // create a built-in binary operator. - if (Opc == BinaryOperator::PtrMemD) + if (Opc == BO_PtrMemD) return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]); // If this is the assignment operator, we only perform overload resolution @@ -6969,7 +6969,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, // various built-in candidates, but as DR507 points out, this can lead to // problems. So we do it this way, which pretty much follows what GCC does. // Note that we go the traditional code path for compound assignment forms. - if (Opc==BinaryOperator::Assign && !Args[0]->getType()->isOverloadableType()) + if (Opc == BO_Assign && !Args[0]->getType()->isOverloadableType()) return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]); // Build an empty overload set. @@ -7083,7 +7083,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, // If the operator is the operator , [...] and there are no // viable functions, then the operator is assumed to be the // built-in operator and interpreted according to clause 5. - if (Opc == BinaryOperator::Comma) + if (Opc == BO_Comma) break; // For class as left operand for assignment or compound assigment operator @@ -7091,7 +7091,7 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc, // assignment operator found ExprResult Result = ExprError(); if (Args[0]->getType()->isRecordType() && - Opc >= BinaryOperator::Assign && Opc <= BinaryOperator::OrAssign) { + Opc >= BO_Assign && Opc <= BO_OrAssign) { Diag(OpLoc, diag::err_ovl_no_viable_oper) << BinaryOperator::getOpcodeStr(Opc) << Args[0]->getSourceRange() << Args[1]->getSourceRange(); @@ -7793,7 +7793,7 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found, } if (UnaryOperator *UnOp = dyn_cast(E)) { - assert(UnOp->getOpcode() == UnaryOperator::AddrOf && + assert(UnOp->getOpcode() == UO_AddrOf && "Can only take the address of an overloaded function"); if (CXXMethodDecl *Method = dyn_cast(Fn)) { if (Method->isStatic()) { @@ -7821,7 +7821,7 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found, QualType MemPtrType = Context.getMemberPointerType(Fn->getType(), ClassType.getTypePtr()); - return new (Context) UnaryOperator(SubExpr, UnaryOperator::AddrOf, + return new (Context) UnaryOperator(SubExpr, UO_AddrOf, MemPtrType, UnOp->getOperatorLoc()); } } @@ -7830,7 +7830,7 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found, if (SubExpr == UnOp->getSubExpr()) return UnOp->Retain(); - return new (Context) UnaryOperator(SubExpr, UnaryOperator::AddrOf, + return new (Context) UnaryOperator(SubExpr, UO_AddrOf, Context.getPointerType(SubExpr->getType()), UnOp->getOperatorLoc()); } diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 41aec13e82..dd3dc6cf40 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -536,7 +536,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, // If the LHS is not the same type as the condition, insert an implicit // cast. - ImpCastExprToType(Lo, CondType, CastExpr::CK_IntegralCast); + ImpCastExprToType(Lo, CondType, CK_IntegralCast); CS->setLHS(Lo); // If this is a case range, remember it in CaseRanges, otherwise CaseVals. @@ -615,7 +615,7 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, // If the LHS is not the same type as the condition, insert an implicit // cast. - ImpCastExprToType(Hi, CondType, CastExpr::CK_IntegralCast); + ImpCastExprToType(Hi, CondType, CK_IntegralCast); CR->setRHS(Hi); // If the low value is bigger than the high value, the case is empty. diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index e7c506810d..8f00bf9d1b 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -2417,7 +2417,7 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, bool AddressTaken = false; SourceLocation AddrOpLoc; if (UnaryOperator *UnOp = dyn_cast(Arg)) { - if (UnOp->getOpcode() == UnaryOperator::AddrOf) { + if (UnOp->getOpcode() == UO_AddrOf) { DRE = dyn_cast(UnOp->getSubExpr()); AddressTaken = true; AddrOpLoc = UnOp->getOperatorLoc(); @@ -2664,7 +2664,7 @@ bool Sema::CheckTemplateArgumentPointerToMember(Expr *Arg, // A pointer-to-member constant written &Class::member. if (UnaryOperator *UnOp = dyn_cast(Arg)) { - if (UnOp->getOpcode() == UnaryOperator::AddrOf) { + if (UnOp->getOpcode() == UO_AddrOf) { DRE = dyn_cast(UnOp->getSubExpr()); if (DRE && !DRE->getQualifier()) DRE = 0; @@ -2799,7 +2799,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, } else if (IsIntegralPromotion(Arg, ArgType, ParamType) || !ParamType->isEnumeralType()) { // This is an integral promotion or conversion. - ImpCastExprToType(Arg, ParamType, CastExpr::CK_IntegralCast); + ImpCastExprToType(Arg, ParamType, CK_IntegralCast); } else { // We can't perform this conversion. Diag(Arg->getSourceRange().getBegin(), @@ -2920,7 +2920,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, Arg, Converted); if (IsQualificationConversion(ArgType, ParamType.getNonReferenceType())) { - ImpCastExprToType(Arg, ParamType, CastExpr::CK_NoOp, CastCategory(Arg)); + ImpCastExprToType(Arg, ParamType, CK_NoOp, CastCategory(Arg)); } else if (!Context.hasSameUnqualifiedType(ArgType, ParamType.getNonReferenceType())) { // We can't perform this conversion. @@ -2983,7 +2983,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, if (Context.hasSameUnqualifiedType(ParamType, ArgType)) { // Types match exactly: nothing more to do here. } else if (IsQualificationConversion(ArgType, ParamType)) { - ImpCastExprToType(Arg, ParamType, CastExpr::CK_NoOp, CastCategory(Arg)); + ImpCastExprToType(Arg, ParamType, CK_NoOp, CastCategory(Arg)); } else { // We can't perform this conversion. Diag(Arg->getSourceRange().getBegin(), @@ -3072,7 +3072,7 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, if (RefExpr.isInvalid()) return ExprError(); - RefExpr = CreateBuiltinUnaryOp(Loc, UnaryOperator::AddrOf, RefExpr.get()); + RefExpr = CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.get()); // We might need to perform a trailing qualification conversion, since // the element type on the parameter could be more qualified than the @@ -3080,8 +3080,7 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, if (IsQualificationConversion(((Expr*) RefExpr.get())->getType(), ParamType.getUnqualifiedType())) { Expr *RefE = RefExpr.takeAs(); - ImpCastExprToType(RefE, ParamType.getUnqualifiedType(), - CastExpr::CK_NoOp); + ImpCastExprToType(RefE, ParamType.getUnqualifiedType(), CK_NoOp); RefExpr = Owned(RefE); } @@ -3113,7 +3112,7 @@ Sema::BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, } // Take the address of everything else - return CreateBuiltinUnaryOp(Loc, UnaryOperator::AddrOf, RefExpr.get()); + return CreateBuiltinUnaryOp(Loc, UO_AddrOf, RefExpr.get()); } // If the non-type template parameter has reference type, qualify the diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h index 432caa7329..993762b79f 100644 --- a/lib/Sema/TreeTransform.h +++ b/lib/Sema/TreeTransform.h @@ -1067,7 +1067,7 @@ public: /// By default, performs semantic analysis to build the new expression. /// Subclasses may override this routine to provide different behavior. ExprResult RebuildUnaryOperator(SourceLocation OpLoc, - UnaryOperator::Opcode Opc, + UnaryOperatorKind Opc, Expr *SubExpr) { return getSema().BuildUnaryOp(/*Scope=*/0, OpLoc, Opc, SubExpr); } @@ -1188,7 +1188,7 @@ public: /// By default, performs semantic analysis to build the new expression. /// Subclasses may override this routine to provide different behavior. ExprResult RebuildBinaryOperator(SourceLocation OpLoc, - BinaryOperator::Opcode Opc, + BinaryOperatorKind Opc, Expr *LHS, Expr *RHS) { return getSema().BuildBinOp(/*Scope=*/0, OpLoc, Opc, LHS, RHS); } @@ -6610,7 +6610,7 @@ TreeTransform::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, if (!First->getType()->isOverloadableType()) { // The argument is not of overloadable type, so try to create a // built-in unary operation. - UnaryOperator::Opcode Opc + UnaryOperatorKind Opc = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec); return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First); @@ -6620,7 +6620,7 @@ TreeTransform::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, !Second->getType()->isOverloadableType()) { // Neither of the arguments is an overloadable type, so try to // create a built-in binary operation. - BinaryOperator::Opcode Opc = BinaryOperator::getOverloadedOpcode(Op); + BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op); ExprResult Result = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second); if (Result.isInvalid()) @@ -6650,7 +6650,7 @@ TreeTransform::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, // Create the overloaded operator invocation for unary operators. if (NumArgs == 1 || isPostIncDec) { - UnaryOperator::Opcode Opc + UnaryOperatorKind Opc = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec); return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First); } @@ -6662,8 +6662,7 @@ TreeTransform::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, Second); // Create the overloaded operator invocation for binary operators. - BinaryOperator::Opcode Opc = - BinaryOperator::getOverloadedOpcode(Op); + BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op); ExprResult Result = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions, Args[0], Args[1]); if (Result.isInvalid()) -- 2.40.0