[cfe-commits] r118934 - /cfe/trunk/tools/libclang/CIndex.cpp
Ted Kremenek
kremenek at apple.com
Fri Nov 12 14:24:57 PST 2010
Author: kremenek
Date: Fri Nov 12 16:24:57 2010
New Revision: 118934
URL: http://llvm.org/viewvc/llvm-project?rev=118934&view=rev
Log:
CursorVisitor: Pull ObjCMessageExpr and explicit casts into data-recursion algorithm.
Modified:
cfe/trunk/tools/libclang/CIndex.cpp
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=118934&r1=118933&r2=118934&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Nov 12 16:24:57 2010
@@ -359,7 +359,6 @@
// Expression visitors
bool VisitDeclRefExpr(DeclRefExpr *E);
bool VisitBlockExpr(BlockExpr *B);
- bool VisitExplicitCastExpr(ExplicitCastExpr *E);
bool VisitObjCEncodeExpr(ObjCEncodeExpr *E);
bool VisitOffsetOfExpr(OffsetOfExpr *E);
bool VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
@@ -385,6 +384,7 @@
DATA_RECURSIVE_VISIT(CompoundLiteralExpr)
DATA_RECURSIVE_VISIT(CXXMemberCallExpr)
DATA_RECURSIVE_VISIT(CXXOperatorCallExpr)
+ DATA_RECURSIVE_VISIT(ExplicitCastExpr)
DATA_RECURSIVE_VISIT(DoStmt)
DATA_RECURSIVE_VISIT(IfStmt)
DATA_RECURSIVE_VISIT(InitListExpr)
@@ -1580,14 +1580,6 @@
return VisitExpr(E);
}
-bool CursorVisitor::VisitExplicitCastExpr(ExplicitCastExpr *E) {
- if (TypeSourceInfo *TSInfo = E->getTypeInfoAsWritten())
- if (Visit(TSInfo->getTypeLoc()))
- return true;
-
- return VisitCastExpr(E);
-}
-
bool CursorVisitor::VisitAddrLabelExpr(AddrLabelExpr *E) {
return Visit(MakeCursorLabelRef(E->getLabel(), E->getLabelLoc(), TU));
}
@@ -1824,8 +1816,16 @@
WL.push_back(OverloadExprParts(E, Parent));
}
+// FIXME: Refactor into StmtVisitor?
void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, Stmt *S) {
CXCursor C = MakeCXCursor(S, StmtParent, TU);
+
+ if (ExplicitCastExpr *E = dyn_cast<ExplicitCastExpr>(S)) {
+ EnqueueChildren(WL, C, S);
+ WLAddTypeLoc(WL, C, cast<ExplicitCastExpr>(S)->getTypeInfoAsWritten());
+ return;
+ }
+
switch (S->getStmtClass()) {
default:
EnqueueChildren(WL, C, S);
@@ -1964,10 +1964,15 @@
switch (S->getStmtClass()) {
default: {
- // Perform default visitation for other cases.
- if (Visit(Cursor))
- return true;
- continue;
+ // FIXME: this entire switch stmt will eventually
+ // go away.
+ if (!isa<ExplicitCastExpr>(S)) {
+ // Perform default visitation for other cases.
+ if (Visit(Cursor))
+ return true;
+ continue;
+ }
+ // Fall-through.
}
case Stmt::BinaryOperatorClass:
case Stmt::CallExprClass:
More information about the cfe-commits
mailing list