summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-13 23:49:33 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-13 23:49:33 +0000
commit084d855a17f2755c995be4393eb3e1dbb018deb5 (patch)
tree9c16ff9c5fa71ea3026b874b384a664596c38ef2 /clang/lib/AST/Expr.cpp
parent1bb3b2ccf3ea6d8e2e8fd634824ff840991173f3 (diff)
downloadbcm5719-llvm-084d855a17f2755c995be4393eb3e1dbb018deb5.tar.gz
bcm5719-llvm-084d855a17f2755c995be4393eb3e1dbb018deb5.zip
Implement template instantiation for the prefix unary operators. As
always, refactored the existing logic to tease apart the parser action and the semantic analysis shared by the parser and template instantiation. llvm-svn: 66987
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r--clang/lib/AST/Expr.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 4b99eefcd4f..273b5ed72f7 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -91,6 +91,36 @@ const char *UnaryOperator::getOpcodeStr(Opcode Op) {
}
}
+UnaryOperator::Opcode
+UnaryOperator::getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix) {
+ switch (OO) {
+ 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;
+ default: assert(false && "No unary operator for overloaded function");
+ }
+}
+
+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;
+ default: return OO_None;
+ }
+}
+
+
//===----------------------------------------------------------------------===//
// Postfix Operators.
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud