CursorVisitor: special-case CompoundStmt in data-recursion algorithm so we don't have to enqueue
its children and then reverse them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118986 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index a20e739..e87ec05 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -1749,6 +1749,7 @@
void VisitBlockExpr(BlockExpr *B);
void VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
+ void VisitCompoundStmt(CompoundStmt *S);
void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E);
void VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E);
void VisitDeclRefExpr(DeclRefExpr *D);
@@ -1806,6 +1807,12 @@
EnqueueChildren(E);
AddTypeLoc(E->getTypeSourceInfo());
}
+void EnqueueVisitor::VisitCompoundStmt(CompoundStmt *S) {
+ for (CompoundStmt::reverse_body_iterator I = S->body_rbegin(),
+ E = S->body_rend(); I != E; ++I) {
+ AddStmt(*I);
+ }
+}
void EnqueueVisitor::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *CE) {
// Note that we enqueue things in reverse order so that
// they are visited correctly by the DFS.