From: Bruno Ricci Date: Tue, 13 Nov 2018 19:27:39 +0000 (+0000) Subject: [AST][NFC] Style fixes for UnaryOperator X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=32e393f332fcadb404e469cd9567d0dcfa5bba48;p=clang [AST][NFC] Style fixes for UnaryOperator In preparation for the patch which will move some data to the bit-fields of Stmt. In particular, rename the private variable "Val" -> "Operand" since the substatement is the operand of the unary operator. Run clang-format on UnaryOperator. NFC otherwise. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@346781 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index f39278e5ea..d06e9bc4bf 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -1876,27 +1876,27 @@ private: unsigned Opc : 5; unsigned CanOverflow : 1; SourceLocation Loc; - Stmt *Val; + Stmt *Operand; + public: - UnaryOperator(Expr *input, Opcode opc, QualType type, ExprValueKind VK, - ExprObjectKind OK, SourceLocation l, bool CanOverflow) - : Expr(UnaryOperatorClass, type, VK, OK, - input->isTypeDependent() || type->isDependentType(), - input->isValueDependent(), - (input->isInstantiationDependent() || - type->isInstantiationDependentType()), - input->containsUnexpandedParameterPack()), - Opc(opc), CanOverflow(CanOverflow), Loc(l), Val(input) {} + UnaryOperator(Expr *Operand, Opcode Opc, QualType Ty, ExprValueKind VK, + ExprObjectKind OK, SourceLocation Loc, bool CanOverflow) + : Expr(UnaryOperatorClass, Ty, VK, OK, + Operand->isTypeDependent() || Ty->isDependentType(), + Operand->isValueDependent(), + (Operand->isInstantiationDependent() || + Ty->isInstantiationDependentType()), + Operand->containsUnexpandedParameterPack()), + Opc(Opc), CanOverflow(CanOverflow), Loc(Loc), Operand(Operand) {} /// Build an empty unary operator. - explicit UnaryOperator(EmptyShell Empty) - : Expr(UnaryOperatorClass, Empty), Opc(UO_AddrOf) { } + explicit UnaryOperator(EmptyShell Empty) : Expr(UnaryOperatorClass, Empty) {} Opcode getOpcode() const { return static_cast(Opc); } void setOpcode(Opcode O) { Opc = O; } - Expr *getSubExpr() const { return cast(Val); } - void setSubExpr(Expr *E) { Val = E; } + Expr *getSubExpr() const { return cast(Operand); } + void setSubExpr(Expr *E) { Operand = E; } /// getOperatorLoc - Return the location of the operator. SourceLocation getOperatorLoc() const { return Loc; } @@ -1912,45 +1912,41 @@ public: void setCanOverflow(bool C) { CanOverflow = C; } /// isPostfix - Return true if this is a postfix operation, like x++. - static bool isPostfix(Opcode Op) { - return Op == UO_PostInc || Op == UO_PostDec; + static bool isPostfix(Opcode Opc) { + return Opc == UO_PostInc || Opc == UO_PostDec; } /// isPrefix - Return true if this is a prefix operation, like --x. - static bool isPrefix(Opcode Op) { - return Op == UO_PreInc || Op == UO_PreDec; + static bool isPrefix(Opcode Opc) { + return Opc == UO_PreInc || Opc == UO_PreDec; } bool isPrefix() const { return isPrefix(getOpcode()); } bool isPostfix() const { return isPostfix(getOpcode()); } - static bool isIncrementOp(Opcode Op) { - return Op == UO_PreInc || Op == UO_PostInc; - } - bool isIncrementOp() const { - return isIncrementOp(getOpcode()); + static bool isIncrementOp(Opcode Opc) { + return Opc == UO_PreInc || Opc == UO_PostInc; } + bool isIncrementOp() const { return isIncrementOp(getOpcode()); } - static bool isDecrementOp(Opcode Op) { - return Op == UO_PreDec || Op == UO_PostDec; - } - bool isDecrementOp() const { - return isDecrementOp(getOpcode()); + static bool isDecrementOp(Opcode Opc) { + return Opc == UO_PreDec || Opc == UO_PostDec; } + bool isDecrementOp() const { return isDecrementOp(getOpcode()); } - static bool isIncrementDecrementOp(Opcode Op) { return Op <= UO_PreDec; } + static bool isIncrementDecrementOp(Opcode Opc) { return Opc <= UO_PreDec; } bool isIncrementDecrementOp() const { return isIncrementDecrementOp(getOpcode()); } - static bool isArithmeticOp(Opcode Op) { - return Op >= UO_Plus && Op <= UO_LNot; + static bool isArithmeticOp(Opcode Opc) { + return Opc >= UO_Plus && Opc <= UO_LNot; } bool isArithmeticOp() const { return isArithmeticOp(getOpcode()); } /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it /// corresponds to, e.g. "sizeof" or "[pre]++" - static StringRef getOpcodeStr(Opcode Op); + static StringRef getOpcodeStr(Opcode Opc); /// Retrieve the unary opcode that corresponds to the given /// overloaded operator. @@ -1961,21 +1957,21 @@ public: static OverloadedOperatorKind getOverloadedOperator(Opcode Opc); SourceLocation getBeginLoc() const LLVM_READONLY { - return isPostfix() ? Val->getBeginLoc() : Loc; + return isPostfix() ? Operand->getBeginLoc() : getOperatorLoc(); } SourceLocation getEndLoc() const LLVM_READONLY { - return isPostfix() ? Loc : Val->getEndLoc(); + return isPostfix() ? getOperatorLoc() : Operand->getEndLoc(); } - SourceLocation getExprLoc() const LLVM_READONLY { return Loc; } + SourceLocation getExprLoc() const { return getOperatorLoc(); } static bool classof(const Stmt *T) { return T->getStmtClass() == UnaryOperatorClass; } // Iterators - child_range children() { return child_range(&Val, &Val+1); } + child_range children() { return child_range(&Operand, &Operand + 1); } const_child_range children() const { - return const_child_range(&Val, &Val + 1); + return const_child_range(&Operand, &Operand + 1); } }; diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 564484ed03..b65ec2c611 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1174,8 +1174,8 @@ StringLiteral::getLocationOfByte(unsigned ByteNo, const SourceManager &SM, /// getOpcodeStr - Turn an Opcode enum value into the punctuation char it /// corresponds to, e.g. "sizeof" or "[pre]++". -StringRef UnaryOperator::getOpcodeStr(Opcode Op) { - switch (Op) { +StringRef UnaryOperator::getOpcodeStr(Opcode Opc) { + switch (Opc) { #define UNARY_OPERATION(Name, Spelling) case UO_##Name: return Spelling; #include "clang/AST/OperationKinds.def" }