blob: 82626d864adbb42806de1f8c6b294c8535df4e76 [file] [log] [blame]
Ted Kremeneka758d092007-08-24 20:21:10 +00001//===--- ExprCXX.cpp - (C++) Expression AST Node Implementation -----------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-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 Kremeneka758d092007-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
Argyrios Kyrtzidis4189a762008-09-10 02:14:49 +000017void CXXConditionDeclExpr::Destroy(ASTContext& C) {
18 getVarDecl()->Destroy(C);
19 delete this;
20}
Argyrios Kyrtzidis9e922b12008-09-09 23:47:53 +000021
22
Ted Kremeneka758d092007-08-24 20:21:10 +000023//===----------------------------------------------------------------------===//
24// Child Iterators for iterating over subexpressions/substatements
25//===----------------------------------------------------------------------===//
26
27
Ted Kremeneka758d092007-08-24 20:21:10 +000028// CXXBoolLiteralExpr
Ted Kremenek9ac59282007-10-18 23:28:49 +000029Stmt::child_iterator CXXBoolLiteralExpr::child_begin() {
30 return child_iterator();
31}
32Stmt::child_iterator CXXBoolLiteralExpr::child_end() {
33 return child_iterator();
34}
Chris Lattner50dd2892008-02-26 00:51:44 +000035
36// CXXThrowExpr
Ted Kremenek1060aff2008-06-17 03:11:08 +000037Stmt::child_iterator CXXThrowExpr::child_begin() { return &Op; }
Chris Lattner50dd2892008-02-26 00:51:44 +000038Stmt::child_iterator CXXThrowExpr::child_end() {
39 // If Op is 0, we are processing throw; which has no children.
Ted Kremenek1060aff2008-06-17 03:11:08 +000040 return Op ? &Op+1 : &Op;
Chris Lattner50dd2892008-02-26 00:51:44 +000041}
Chris Lattner04421082008-04-08 04:40:51 +000042
43// CXXDefaultArgExpr
44Stmt::child_iterator CXXDefaultArgExpr::child_begin() {
Chris Lattner8123a952008-04-10 02:22:51 +000045 return child_iterator();
Chris Lattner04421082008-04-08 04:40:51 +000046}
47Stmt::child_iterator CXXDefaultArgExpr::child_end() {
Chris Lattner8123a952008-04-10 02:22:51 +000048 return child_iterator();
Chris Lattner04421082008-04-08 04:40:51 +000049}
Argyrios Kyrtzidis987a14b2008-08-22 15:38:55 +000050
51// CXXZeroInitValueExpr
52Stmt::child_iterator CXXZeroInitValueExpr::child_begin() {
53 return child_iterator();
54}
55Stmt::child_iterator CXXZeroInitValueExpr::child_end() {
56 return child_iterator();
57}
Argyrios Kyrtzidis9e922b12008-09-09 23:47:53 +000058
59// CXXConditionDeclExpr
60Stmt::child_iterator CXXConditionDeclExpr::child_begin() {
61 return getVarDecl();
62}
63Stmt::child_iterator CXXConditionDeclExpr::child_end() {
64 return child_iterator();
65}
Douglas Gregor49badde2008-10-27 19:41:14 +000066
67//===----------------------------------------------------------------------===//
68// Named casts
69//===----------------------------------------------------------------------===//
70
71/// getCastName - Get the name of the C++ cast being used, e.g.,
72/// "static_cast", "dynamic_cast", "reinterpret_cast", or
73/// "const_cast". The returned pointer must not be freed.
74const char *CXXNamedCastExpr::getCastName() const {
75 switch (getStmtClass()) {
76 case CXXStaticCastExprClass: return "static_cast";
77 case CXXDynamicCastExprClass: return "dynamic_cast";
78 case CXXReinterpretCastExprClass: return "reinterpret_cast";
79 case CXXConstCastExprClass: return "const_cast";
80 default: return "<invalid cast>";
81 }
82}