aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-07-23 22:18:43 +0000
committerTed Kremenek <kremenek@apple.com>2008-07-23 22:18:43 +0000
commit5a56ac30d04e8f0431a08980885662a47a6308aa (patch)
tree25e36361a14d75aa9257dfb8f214628497355d0f
parenta32980435ab2e3a5e037b2ebe936682e1ffe80e1 (diff)
Added UnaryOperator::isPrefix().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53963 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Expr.h4
-rw-r--r--lib/AST/Expr.cpp10
2 files changed, 14 insertions, 0 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 51b8588d5f..692a0ea85f 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -481,6 +481,10 @@ public:
/// isPostfix - Return true if this is a postfix operation, like x++.
static bool isPostfix(Opcode Op);
+ /// isPostfix - Return true if this is a prefix operation, like --x.
+ static bool isPrefix(Opcode Op);
+
+ bool isPrefix() const { return isPrefix(Opc); }
bool isPostfix() const { return isPostfix(Opc); }
bool isIncrementOp() const {return Opc==PreInc || Opc==PostInc; }
bool isIncrementDecrementOp() const { return Opc>=PostInc && Opc<=PreDec; }
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index de0c740fd2..6c7d170d03 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -61,6 +61,16 @@ bool UnaryOperator::isPostfix(Opcode Op) {
}
}
+bool UnaryOperator::isPrefix(Opcode Op) {
+ switch (Op) {
+ case PreInc:
+ case PreDec:
+ return true;
+ default:
+ return false;
+ }
+}
+
/// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
/// corresponds to, e.g. "sizeof" or "[pre]++".
const char *UnaryOperator::getOpcodeStr(Opcode Op) {