blob: ff97e688b8dcf2c1b6615405c480c5b02ef826f3 [file] [log] [blame]
Ted Kremenekfc7b6f72007-08-24 20:21:10 +00001//===--- ExprCXX.cpp - (C++) Expression AST Node Implementation -----------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner959e5be2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Ted Kremenekfc7b6f72007-08-24 20:21:10 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the subclesses of Expr class declared in ExprCXX.h
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang/AST/ExprCXX.h"
15using namespace clang;
16
Argiris Kirtzidis080b9cc2008-09-10 02:14:49 +000017void CXXConditionDeclExpr::Destroy(ASTContext& C) {
18 getVarDecl()->Destroy(C);
19 delete this;
20}
Argiris Kirtzidisdbce6c12008-09-09 23:47:53 +000021
22
Ted Kremenekfc7b6f72007-08-24 20:21:10 +000023//===----------------------------------------------------------------------===//
24// Child Iterators for iterating over subexpressions/substatements
25//===----------------------------------------------------------------------===//
26
Sebastian Redlb93b49c2008-11-11 11:37:55 +000027// CXXTypeidExpr - has child iterators if the operand is an expression
28Stmt::child_iterator CXXTypeidExpr::child_begin() {
29 return isTypeOperand() ? child_iterator() : (Stmt**)&Operand;
30}
31Stmt::child_iterator CXXTypeidExpr::child_end() {
32 return isTypeOperand() ? child_iterator() : (Stmt**)&Operand+1;
33}
Ted Kremenekfc7b6f72007-08-24 20:21:10 +000034
Ted Kremenekfc7b6f72007-08-24 20:21:10 +000035// CXXBoolLiteralExpr
Ted Kremeneka6478552007-10-18 23:28:49 +000036Stmt::child_iterator CXXBoolLiteralExpr::child_begin() {
37 return child_iterator();
38}
39Stmt::child_iterator CXXBoolLiteralExpr::child_end() {
40 return child_iterator();
41}
Chris Lattnera7447ba2008-02-26 00:51:44 +000042
Douglas Gregora5b022a2008-11-04 14:32:21 +000043// CXXThisExpr
44Stmt::child_iterator CXXThisExpr::child_begin() { return child_iterator(); }
45Stmt::child_iterator CXXThisExpr::child_end() { return child_iterator(); }
46
Chris Lattnera7447ba2008-02-26 00:51:44 +000047// CXXThrowExpr
Ted Kremenek156714e2008-06-17 03:11:08 +000048Stmt::child_iterator CXXThrowExpr::child_begin() { return &Op; }
Chris Lattnera7447ba2008-02-26 00:51:44 +000049Stmt::child_iterator CXXThrowExpr::child_end() {
50 // If Op is 0, we are processing throw; which has no children.
Ted Kremenek156714e2008-06-17 03:11:08 +000051 return Op ? &Op+1 : &Op;
Chris Lattnera7447ba2008-02-26 00:51:44 +000052}
Chris Lattner3e254fb2008-04-08 04:40:51 +000053
54// CXXDefaultArgExpr
55Stmt::child_iterator CXXDefaultArgExpr::child_begin() {
Chris Lattner97316c02008-04-10 02:22:51 +000056 return child_iterator();
Chris Lattner3e254fb2008-04-08 04:40:51 +000057}
58Stmt::child_iterator CXXDefaultArgExpr::child_end() {
Chris Lattner97316c02008-04-10 02:22:51 +000059 return child_iterator();
Chris Lattner3e254fb2008-04-08 04:40:51 +000060}
Argiris Kirtzidis7a1e7412008-08-22 15:38:55 +000061
62// CXXZeroInitValueExpr
63Stmt::child_iterator CXXZeroInitValueExpr::child_begin() {
64 return child_iterator();
65}
66Stmt::child_iterator CXXZeroInitValueExpr::child_end() {
67 return child_iterator();
68}
Argiris Kirtzidisdbce6c12008-09-09 23:47:53 +000069
70// CXXConditionDeclExpr
71Stmt::child_iterator CXXConditionDeclExpr::child_begin() {
72 return getVarDecl();
73}
74Stmt::child_iterator CXXConditionDeclExpr::child_end() {
75 return child_iterator();
76}
Douglas Gregor21a04f32008-10-27 19:41:14 +000077
78//===----------------------------------------------------------------------===//
79// Named casts
80//===----------------------------------------------------------------------===//
81
82/// getCastName - Get the name of the C++ cast being used, e.g.,
83/// "static_cast", "dynamic_cast", "reinterpret_cast", or
84/// "const_cast". The returned pointer must not be freed.
85const char *CXXNamedCastExpr::getCastName() const {
86 switch (getStmtClass()) {
87 case CXXStaticCastExprClass: return "static_cast";
88 case CXXDynamicCastExprClass: return "dynamic_cast";
89 case CXXReinterpretCastExprClass: return "reinterpret_cast";
90 case CXXConstCastExprClass: return "const_cast";
91 default: return "<invalid cast>";
92 }
93}