[cfe-commits] r80862 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/Expr.cpp lib/AST/StmtDumper.cpp
Anders Carlsson
andersca at mac.com
Wed Sep 2 17:59:21 PDT 2009
Author: andersca
Date: Wed Sep 2 19:59:21 2009
New Revision: 80862
URL: http://llvm.org/viewvc/llvm-project?rev=80862&view=rev
Log:
Add CastExpr::getCastKindName and use it in the StmtDumper.
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/StmtDumper.cpp
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=80862&r1=80861&r2=80862&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Wed Sep 2 19:59:21 2009
@@ -1395,7 +1395,8 @@
public:
CastKind getCastKind() const { return Kind; }
void setCastKind(CastKind K) { Kind = K; }
-
+ const char *getCastKindName() const;
+
Expr *getSubExpr() { return cast<Expr>(Op); }
const Expr *getSubExpr() const { return cast<Expr>(Op); }
void setSubExpr(Expr *E) { Op = E; }
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=80862&r1=80861&r2=80862&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Wed Sep 2 19:59:21 2009
@@ -319,6 +319,38 @@
ty);
}
+const char *CastExpr::getCastKindName() const {
+ switch (getCastKind()) {
+ case CastExpr::CK_Unknown:
+ return "Unknown";
+ case CastExpr::CK_BitCast:
+ return "BitCast";
+ case CastExpr::CK_NoOp:
+ return "NoOp";
+ case CastExpr::CK_DerivedToBase:
+ return "DerivedToBase";
+ case CastExpr::CK_Dynamic:
+ return "Dynamic";
+ case CastExpr::CK_ToUnion:
+ return "ToUnion";
+ case CastExpr::CK_ArrayToPointerDecay:
+ return "ArrayToPointerDecay";
+ case CastExpr::CK_FunctionToPointerDecay:
+ return "FunctionToPointerDecay";
+ case CastExpr::CK_NullToMemberPointer:
+ return "NullToMemberPointer";
+ case CastExpr::CK_BaseToDerivedMemberPointer:
+ return "BaseToDerivedMemberPointer";
+ case CastExpr::CK_UserDefinedConversion:
+ return "UserDefinedConversion";
+ case CastExpr::CK_ConstructorConversion:
+ return "ConstructorConversion";
+ }
+
+ assert(0 && "Unhandled cast kind!");
+ return 0;
+}
+
/// getOpcodeStr - Turn an Opcode enum value into the punctuation char it
/// corresponds to, e.g. "<<=".
const char *BinaryOperator::getOpcodeStr(Opcode Op) {
Modified: cfe/trunk/lib/AST/StmtDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtDumper.cpp?rev=80862&r1=80861&r2=80862&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtDumper.cpp (original)
+++ cfe/trunk/lib/AST/StmtDumper.cpp Wed Sep 2 19:59:21 2009
@@ -301,45 +301,7 @@
void StmtDumper::VisitCastExpr(CastExpr *Node) {
DumpExpr(Node);
- fprintf(F, " ");
- switch (Node->getCastKind()) {
- case CastExpr::CK_Unknown:
- fprintf(F, "<Unknown>");
- break;
- case CastExpr::CK_BitCast:
- fprintf(F, "<BitCast>");
- break;
- case CastExpr::CK_NoOp:
- fprintf(F, "<NoOp>");
- break;
- case CastExpr::CK_DerivedToBase:
- fprintf(F, "<DerivedToBase>");
- break;
- case CastExpr::CK_Dynamic:
- fprintf(F, "<Dynamic>");
- break;
- case CastExpr::CK_ToUnion:
- fprintf(F, "<ToUnion>");
- break;
- case CastExpr::CK_ArrayToPointerDecay:
- fprintf(F, "<ArrayToPointerDecay>");
- break;
- case CastExpr::CK_FunctionToPointerDecay:
- fprintf(F, "<FunctionToPointerDecay>");
- break;
- case CastExpr::CK_NullToMemberPointer:
- fprintf(F, "<NullToMemberPointer>");
- break;
- case CastExpr::CK_BaseToDerivedMemberPointer:
- fprintf(F, "<BaseToDerivedMemberPointer>");
- break;
- case CastExpr::CK_UserDefinedConversion:
- fprintf(F, "<UserDefinedConversion>");
- break;
- case CastExpr::CK_ConstructorConversion:
- fprintf(F, "<ConstructorConversion>");
- break;
- }
+ fprintf(F, " <%s>", Node->getCastKindName());
}
void StmtDumper::VisitDeclRefExpr(DeclRefExpr *Node) {
@@ -480,8 +442,9 @@
void StmtDumper::VisitCXXNamedCastExpr(CXXNamedCastExpr *Node) {
DumpExpr(Node);
- fprintf(F, " %s<%s>", Node->getCastName(),
- Node->getTypeAsWritten().getAsString().c_str());
+ fprintf(F, " %s<%s> <%s>", Node->getCastName(),
+ Node->getTypeAsWritten().getAsString().c_str(),
+ Node->getCastKindName());
}
void StmtDumper::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *Node) {
More information about the cfe-commits
mailing list