From: Ted Kremenek Date: Sat, 13 Nov 2010 05:38:03 +0000 (+0000) Subject: CursorVisitor: special-case CompoundStmt in data-recursion algorithm so we don't... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=083c7e2d564033af87e507fbbd02f1c77ff462b1;p=clang 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 a20e739896..e87ec059b5 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -1749,6 +1749,7 @@ public: 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 @@ void EnqueueVisitor::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { 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.