r346781 - [AST][NFC] Style fixes for UnaryOperator
Bruno Ricci via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 13 11:27:39 PST 2018
Author: brunoricci
Date: Tue Nov 13 11:27:39 2018
New Revision: 346781
URL: http://llvm.org/viewvc/llvm-project?rev=346781&view=rev
Log:
[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.
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=346781&r1=346780&r2=346781&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Nov 13 11:27:39 2018
@@ -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<Opcode>(Opc); }
void setOpcode(Opcode O) { Opc = O; }
- Expr *getSubExpr() const { return cast<Expr>(Val); }
- void setSubExpr(Expr *E) { Val = E; }
+ Expr *getSubExpr() const { return cast<Expr>(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);
}
};
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=346781&r1=346780&r2=346781&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Nov 13 11:27:39 2018
@@ -1174,8 +1174,8 @@ StringLiteral::getLocationOfByte(unsigne
/// 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"
}
More information about the cfe-commits
mailing list