[cfe-commits] r40967 - in /cfe/trunk: AST/StmtPrinter.cpp include/clang/AST/ExprCXX.h
Chris Lattner
sabre at nondot.org
Thu Aug 9 10:34:19 PDT 2007
Author: lattner
Date: Thu Aug 9 12:34:19 2007
New Revision: 40967
URL: http://llvm.org/viewvc/llvm-project?rev=40967&view=rev
Log:
move a switch to common code.
Modified:
cfe/trunk/AST/StmtPrinter.cpp
cfe/trunk/include/clang/AST/ExprCXX.h
Modified: cfe/trunk/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/StmtPrinter.cpp?rev=40967&r1=40966&r2=40967&view=diff
==============================================================================
--- cfe/trunk/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/AST/StmtPrinter.cpp Thu Aug 9 12:34:19 2007
@@ -501,16 +501,7 @@
// C++
void StmtPrinter::VisitCXXCastExpr(CXXCastExpr *Node) {
- switch (Node->getOpcode()) {
- default:
- assert(0 && "Not a C++ cast expression");
- abort();
- case CXXCastExpr::ConstCast: OS << "const_cast<"; break;
- case CXXCastExpr::DynamicCast: OS << "dynamic_cast<"; break;
- case CXXCastExpr::ReinterpretCast: OS << "reinterpret_cast<"; break;
- case CXXCastExpr::StaticCast: OS << "static_cast<"; break;
- }
-
+ OS << CXXCastExpr::getOpcodeStr(Node->getOpcode()) << '<';
OS << Node->getDestType().getAsString() << ">(";
PrintExpr(Node->getSubExpr());
OS << ")";
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=40967&r1=40966&r2=40967&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Thu Aug 9 12:34:19 2007
@@ -46,6 +46,19 @@
Opcode getOpcode() const { return Opc; }
+ /// getOpcodeStr - Turn an Opcode enum value into the string it represents,
+ /// e.g. "reinterpret_cast".
+ static const char *getOpcodeStr(Opcode Op) {
+ // FIXME: move out of line.
+ switch (Op) {
+ default: assert(0 && "Not a C++ cast expression");
+ case CXXCastExpr::ConstCast: return "const_cast";
+ case CXXCastExpr::DynamicCast: return "dynamic_cast";
+ case CXXCastExpr::ReinterpretCast: return "reinterpret_cast";
+ case CXXCastExpr::StaticCast: return "static_cast";
+ }
+ }
+
virtual SourceRange getSourceRange() const {
return SourceRange(Loc, getSubExpr()->getSourceRange().End());
}
More information about the cfe-commits
mailing list