[cfe-commits] r118964 - /cfe/trunk/tools/libclang/CIndex.cpp
Ted Kremenek
kremenek at apple.com
Fri Nov 12 17:09:29 PST 2010
Author: kremenek
Date: Fri Nov 12 19:09:29 2010
New Revision: 118964
URL: http://llvm.org/viewvc/llvm-project?rev=118964&view=rev
Log:
CursorVisitor: Migrate BlockExpr, CXXTemporaryOBjectExpr, and ObjCEncodeExpr to data-recursive 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=118964&r1=118963&r2=118964&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Nov 12 19:09:29 2010
@@ -312,8 +312,6 @@
bool VisitStmt(Stmt *S);
// Expression visitors
- bool VisitBlockExpr(BlockExpr *B);
- bool VisitObjCEncodeExpr(ObjCEncodeExpr *E);
bool VisitOffsetOfExpr(OffsetOfExpr *E);
bool VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E);
bool VisitAddrLabelExpr(AddrLabelExpr *E);
@@ -323,7 +321,6 @@
bool VisitCXXTypeidExpr(CXXTypeidExpr *E);
bool VisitCXXUuidofExpr(CXXUuidofExpr *E);
bool VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) { return false; }
- bool VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E);
bool VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E);
bool VisitCXXNewExpr(CXXNewExpr *E);
bool VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E);
@@ -335,9 +332,11 @@
#define DATA_RECURSIVE_VISIT(NAME)\
bool Visit##NAME(NAME *S) { return VisitDataRecursive(S); }
DATA_RECURSIVE_VISIT(BinaryOperator)
+ DATA_RECURSIVE_VISIT(BlockExpr)
DATA_RECURSIVE_VISIT(CompoundLiteralExpr)
DATA_RECURSIVE_VISIT(CXXMemberCallExpr)
DATA_RECURSIVE_VISIT(CXXOperatorCallExpr)
+ DATA_RECURSIVE_VISIT(CXXTemporaryObjectExpr)
DATA_RECURSIVE_VISIT(DeclRefExpr)
DATA_RECURSIVE_VISIT(DeclStmt)
DATA_RECURSIVE_VISIT(ExplicitCastExpr)
@@ -347,6 +346,7 @@
DATA_RECURSIVE_VISIT(ForStmt)
DATA_RECURSIVE_VISIT(GotoStmt)
DATA_RECURSIVE_VISIT(MemberExpr)
+ DATA_RECURSIVE_VISIT(ObjCEncodeExpr)
DATA_RECURSIVE_VISIT(ObjCMessageExpr)
DATA_RECURSIVE_VISIT(OverloadExpr)
DATA_RECURSIVE_VISIT(SwitchStmt)
@@ -1451,11 +1451,6 @@
return VisitTagDecl(D);
}
-
-bool CursorVisitor::VisitBlockExpr(BlockExpr *B) {
- return Visit(B->getBlockDecl());
-}
-
bool CursorVisitor::VisitOffsetOfExpr(OffsetOfExpr *E) {
// Visit the type into which we're computing an offset.
if (Visit(E->getTypeSourceInfo()->getTypeLoc()))
@@ -1567,14 +1562,6 @@
return VisitExpr(E);
}
-bool CursorVisitor::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
- if (TypeSourceInfo *TSInfo = E->getTypeSourceInfo())
- if (Visit(TSInfo->getTypeLoc()))
- return true;
-
- return VisitExpr(E);
-}
-
bool CursorVisitor::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
if (TypeSourceInfo *TSInfo = E->getTypeSourceInfo())
return Visit(TSInfo->getTypeLoc());
@@ -1697,11 +1684,6 @@
return false;
}
-bool CursorVisitor::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
- return Visit(E->getEncodedTypeSourceInfo()->getTypeLoc());
-}
-
-
bool CursorVisitor::VisitAttributes(Decl *D) {
for (AttrVec::const_iterator i = D->attr_begin(), e = D->attr_end();
i != e; ++i)
@@ -1765,8 +1747,10 @@
EnqueueVisitor(VisitorWorkList &wl, CXCursor parent)
: WL(wl), Parent(parent) {}
+ void VisitBlockExpr(BlockExpr *B);
void VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E);
+ void VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E);
void VisitDeclRefExpr(DeclRefExpr *D);
void VisitDeclStmt(DeclStmt *S);
void VisitExplicitCastExpr(ExplicitCastExpr *E);
@@ -1774,6 +1758,7 @@
void VisitIfStmt(IfStmt *If);
void VisitInitListExpr(InitListExpr *IE);
void VisitMemberExpr(MemberExpr *M);
+ void VisitObjCEncodeExpr(ObjCEncodeExpr *E);
void VisitObjCMessageExpr(ObjCMessageExpr *M);
void VisitOverloadExpr(OverloadExpr *E);
void VisitStmt(Stmt *S);
@@ -1814,6 +1799,9 @@
VisitorWorkList::iterator I = WL.begin() + size, E = WL.end();
std::reverse(I, E);
}
+void EnqueueVisitor::VisitBlockExpr(BlockExpr *B) {
+ AddDecl(B->getBlockDecl());
+}
void EnqueueVisitor::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
EnqueueChildren(E);
AddTypeLoc(E->getTypeSourceInfo());
@@ -1826,6 +1814,10 @@
AddStmt(CE->getCallee());
AddStmt(CE->getArg(0));
}
+void EnqueueVisitor::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
+ EnqueueChildren(E);
+ AddTypeLoc(E->getTypeSourceInfo());
+}
void EnqueueVisitor::VisitDeclRefExpr(DeclRefExpr *DR) {
WL.push_back(DeclRefExprParts(DR, Parent));
}
@@ -1871,6 +1863,9 @@
WL.push_back(MemberExprParts(M, Parent));
AddStmt(M->getBase());
}
+void EnqueueVisitor::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
+ AddTypeLoc(E->getEncodedTypeSourceInfo());
+}
void EnqueueVisitor::VisitObjCMessageExpr(ObjCMessageExpr *M) {
EnqueueChildren(M);
AddTypeLoc(M->getClassReceiverTypeInfo());
@@ -1965,18 +1960,21 @@
// Fall-through.
}
case Stmt::BinaryOperatorClass:
+ case Stmt::BlockExprClass:
case Stmt::CallExprClass:
case Stmt::CaseStmtClass:
case Stmt::CompoundLiteralExprClass:
case Stmt::CompoundStmtClass:
case Stmt::CXXMemberCallExprClass:
case Stmt::CXXOperatorCallExprClass:
+ case Stmt::CXXTemporaryObjectExprClass:
case Stmt::DefaultStmtClass:
case Stmt::DoStmtClass:
case Stmt::ForStmtClass:
case Stmt::IfStmtClass:
case Stmt::InitListExprClass:
case Stmt::MemberExprClass:
+ case Stmt::ObjCEncodeExprClass:
case Stmt::ObjCMessageExprClass:
case Stmt::ParenExprClass:
case Stmt::SwitchStmtClass:
More information about the cfe-commits
mailing list