summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprCXX.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-10-27 19:41:14 +0000
committerDouglas Gregor <dgregor@apple.com>2008-10-27 19:41:14 +0000
commite200adc5031edd8e9289fd918027fab324f5f43b (patch)
tree4007341937425281d97b1fa35066326ac0ef62e8 /clang/lib/AST/ExprCXX.cpp
parent4e6ad3c12b2ba2db49db51b7893f68424c2adb94 (diff)
downloadbcm5719-llvm-e200adc5031edd8e9289fd918027fab324f5f43b.tar.gz
bcm5719-llvm-e200adc5031edd8e9289fd918027fab324f5f43b.zip
Refactor the expression class hierarchy for casts. Most importantly:
- CastExpr is the root of all casts - ImplicitCastExpr is (still) used for all explicit casts - ExplicitCastExpr is now the root of all *explicit* casts - ExplicitCCastExpr (new name needed!?) is a C-style cast in C or C++ - CXXFunctionalCastExpr inherits from ExplicitCastExpr - CXXNamedCastExpr inherits from ExplicitCastExpr and is the root of all of the C++ named cast expression types (static_cast, dynamic_cast, etc.) - Added classes CXXStaticCastExpr, CXXDynamicCastExpr, CXXReinterpretCastExpr, and CXXConstCastExpr to Also, fixed returned-stack-addr.cpp, which broke once when we fixed reinterpret_cast to diagnose double->int* conversions and again when we eliminated implicit conversions to reference types. The fix is in both testcase and SemaChecking.cpp. Most of this patch is simply support for the renaming. There's very little actual change in semantics. llvm-svn: 58264
Diffstat (limited to 'clang/lib/AST/ExprCXX.cpp')
-rw-r--r--clang/lib/AST/ExprCXX.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 0c374ff5cce..82626d864ad 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -25,10 +25,6 @@ void CXXConditionDeclExpr::Destroy(ASTContext& C) {
//===----------------------------------------------------------------------===//
-// CXXCastExpr
-Stmt::child_iterator CXXCastExpr::child_begin() { return &Op; }
-Stmt::child_iterator CXXCastExpr::child_end() { return &Op+1; }
-
// CXXBoolLiteralExpr
Stmt::child_iterator CXXBoolLiteralExpr::child_begin() {
return child_iterator();
@@ -67,3 +63,20 @@ Stmt::child_iterator CXXConditionDeclExpr::child_begin() {
Stmt::child_iterator CXXConditionDeclExpr::child_end() {
return child_iterator();
}
+
+//===----------------------------------------------------------------------===//
+// Named casts
+//===----------------------------------------------------------------------===//
+
+/// getCastName - Get the name of the C++ cast being used, e.g.,
+/// "static_cast", "dynamic_cast", "reinterpret_cast", or
+/// "const_cast". The returned pointer must not be freed.
+const char *CXXNamedCastExpr::getCastName() const {
+ switch (getStmtClass()) {
+ case CXXStaticCastExprClass: return "static_cast";
+ case CXXDynamicCastExprClass: return "dynamic_cast";
+ case CXXReinterpretCastExprClass: return "reinterpret_cast";
+ case CXXConstCastExprClass: return "const_cast";
+ default: return "<invalid cast>";
+ }
+}
OpenPOWER on IntegriCloud