[llvm-branch-commits] [cfe-branch] r119639 - /cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
Daniel Dunbar
daniel at zuster.org
Wed Nov 17 18:37:07 PST 2010
Author: ddunbar
Date: Wed Nov 17 20:37:07 2010
New Revision: 119639
URL: http://llvm.org/viewvc/llvm-project?rev=119639&view=rev
Log:
Merge r118961:
--
Author: Ted Kremenek <kremenek at apple.com>
Date: Sat Nov 13 00:58:18 2010 +0000
CursorVisitor: Migrate DeclRefExpr over to data-recursion algorithm.
Modified:
cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
Modified: cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp?rev=119639&r1=119638&r2=119639&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp Wed Nov 17 20:37:07 2010
@@ -137,7 +137,8 @@
class VisitorJob {
public:
enum Kind { DeclVisitKind, StmtVisitKind, MemberExprPartsKind,
- TypeLocVisitKind, OverloadExprPartsKind };
+ TypeLocVisitKind, OverloadExprPartsKind,
+ DeclRefExprPartsKind };
protected:
void *dataA;
void *dataB;
@@ -325,7 +326,6 @@
bool VisitStmt(Stmt *S);
// Expression visitors
- bool VisitDeclRefExpr(DeclRefExpr *E);
bool VisitBlockExpr(BlockExpr *B);
bool VisitObjCEncodeExpr(ObjCEncodeExpr *E);
bool VisitOffsetOfExpr(OffsetOfExpr *E);
@@ -352,6 +352,7 @@
DATA_RECURSIVE_VISIT(CompoundLiteralExpr)
DATA_RECURSIVE_VISIT(CXXMemberCallExpr)
DATA_RECURSIVE_VISIT(CXXOperatorCallExpr)
+ DATA_RECURSIVE_VISIT(DeclRefExpr)
DATA_RECURSIVE_VISIT(DeclStmt)
DATA_RECURSIVE_VISIT(ExplicitCastExpr)
DATA_RECURSIVE_VISIT(DoStmt)
@@ -1453,29 +1454,6 @@
return false;
}
-bool CursorVisitor::VisitDeclRefExpr(DeclRefExpr *E) {
- // Visit nested-name-specifier, if present.
- if (NestedNameSpecifier *Qualifier = E->getQualifier())
- if (VisitNestedNameSpecifier(Qualifier, E->getQualifierRange()))
- return true;
-
- // Visit declaration name.
- if (VisitDeclarationNameInfo(E->getNameInfo()))
- return true;
-
- // Visit explicitly-specified template arguments.
- if (E->hasExplicitTemplateArgs()) {
- ExplicitTemplateArgumentList &Args = E->getExplicitTemplateArgs();
- for (TemplateArgumentLoc *Arg = Args.getTemplateArgs(),
- *ArgEnd = Arg + Args.NumTemplateArgs;
- Arg != ArgEnd; ++Arg)
- if (VisitTemplateArgumentLoc(*Arg))
- return true;
- }
-
- return false;
-}
-
bool CursorVisitor::VisitCXXRecordDecl(CXXRecordDecl *D) {
if (D->isDefinition()) {
for (CXXRecordDecl::base_class_iterator I = D->bases_begin(),
@@ -1763,6 +1741,7 @@
DEF_JOB(StmtVisit, Stmt, StmtVisitKind)
DEF_JOB(MemberExprParts, MemberExpr, MemberExprPartsKind)
+DEF_JOB(DeclRefExprParts, DeclRefExpr, DeclRefExprPartsKind)
DEF_JOB(OverloadExprParts, OverloadExpr, OverloadExprPartsKind)
#undef DEF_JOB
@@ -1803,6 +1782,7 @@
void VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
void VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E);
+ void VisitDeclRefExpr(DeclRefExpr *D);
void VisitDeclStmt(DeclStmt *S);
void VisitExplicitCastExpr(ExplicitCastExpr *E);
void VisitForStmt(ForStmt *FS);
@@ -1861,6 +1841,9 @@
AddStmt(CE->getCallee());
AddStmt(CE->getArg(0));
}
+void EnqueueVisitor::VisitDeclRefExpr(DeclRefExpr *DR) {
+ WL.push_back(DeclRefExprParts(DR, Parent));
+}
void EnqueueVisitor::VisitDeclStmt(DeclStmt *S) {
unsigned size = WL.size();
bool isFirst = true;
@@ -2056,6 +2039,26 @@
}
continue;
}
+ case VisitorJob::DeclRefExprPartsKind: {
+ DeclRefExpr *DR = cast<DeclRefExprParts>(LI).get();
+ // Visit nested-name-specifier, if present.
+ if (NestedNameSpecifier *Qualifier = DR->getQualifier())
+ if (VisitNestedNameSpecifier(Qualifier, DR->getQualifierRange()))
+ return true;
+ // Visit declaration name.
+ if (VisitDeclarationNameInfo(DR->getNameInfo()))
+ return true;
+ // Visit explicitly-specified template arguments.
+ if (DR->hasExplicitTemplateArgs()) {
+ ExplicitTemplateArgumentList &Args = DR->getExplicitTemplateArgs();
+ for (TemplateArgumentLoc *Arg = Args.getTemplateArgs(),
+ *ArgEnd = Arg + Args.NumTemplateArgs;
+ Arg != ArgEnd; ++Arg)
+ if (VisitTemplateArgumentLoc(*Arg))
+ return true;
+ }
+ continue;
+ }
case VisitorJob::OverloadExprPartsKind: {
OverloadExpr *O = cast<OverloadExprParts>(LI).get();
// Visit the nested-name-specifier.
More information about the llvm-branch-commits
mailing list