]> granicus.if.org Git - clang/commitdiff
Added UnaryOperator::isPrefix().
authorTed Kremenek <kremenek@apple.com>
Wed, 23 Jul 2008 22:18:43 +0000 (22:18 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 23 Jul 2008 22:18:43 +0000 (22:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53963 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Expr.h
lib/AST/Expr.cpp

index 51b8588d5fda0f3cf9464308cb46d48872a00a5b..692a0ea85f505d4bdcf36dde7ea3a3b6fceaf7e6 100644 (file)
@@ -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; }
index de0c740fd293bbd1ad6219cd9e0900ee539b654e..6c7d170d0365e8d887fc40245d96ba3c5af55861 100644 (file)
@@ -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) {