[llvm-branch-commits] [cfe-branch] r119632 - /cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
Daniel Dunbar
daniel at zuster.org
Wed Nov 17 18:36:51 PST 2010
Author: ddunbar
Date: Wed Nov 17 20:36:51 2010
New Revision: 119632
URL: http://llvm.org/viewvc/llvm-project?rev=119632&view=rev
Log:
Merge r118929:
--
Author: Ted Kremenek <kremenek at apple.com>
Date: Fri Nov 12 21:34:16 2010 +0000
CursorVisitor: migrate UnresolvedMemberExpr and UnresolvedLookupExpr 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=119632&r1=119631&r2=119632&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp Wed Nov 17 20:36:51 2010
@@ -137,7 +137,7 @@
class VisitorJob {
public:
enum Kind { DeclVisitKind, StmtVisitKind, MemberExprPartsKind,
- TypeLocVisitKind };
+ TypeLocVisitKind, OverloadExprPartsKind };
protected:
void *dataA;
void *dataB;
@@ -164,6 +164,7 @@
DEF_JOB(DeclVisit, Decl, DeclVisitKind)
DEF_JOB(StmtVisit, Stmt, StmtVisitKind)
DEF_JOB(MemberExprParts, MemberExpr, MemberExprPartsKind)
+DEF_JOB(OverloadExprParts, OverloadExpr, OverloadExprPartsKind)
#undef DEF_JOB
class TypeLocVisit : public VisitorJob {
@@ -389,11 +390,9 @@
bool VisitCXXNewExpr(CXXNewExpr *E);
bool VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E);
bool VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E);
- bool VisitOverloadExpr(OverloadExpr *E);
bool VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E);
bool VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E);
bool VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E);
- bool VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E);
#define DATA_RECURSIVE_VISIT(NAME)\
bool Visit##NAME(NAME *S) { return VisitDataRecursive(S); }
@@ -406,8 +405,10 @@
DATA_RECURSIVE_VISIT(InitListExpr)
DATA_RECURSIVE_VISIT(ForStmt)
DATA_RECURSIVE_VISIT(MemberExpr)
+ DATA_RECURSIVE_VISIT(OverloadExpr)
DATA_RECURSIVE_VISIT(SwitchStmt)
DATA_RECURSIVE_VISIT(WhileStmt)
+ DATA_RECURSIVE_VISIT(UnresolvedMemberExpr)
// Data-recursive visitor functions.
bool IsInRegionOfInterest(CXCursor C);
@@ -1737,34 +1738,6 @@
return Visit(E->getQueriedTypeSourceInfo()->getTypeLoc());
}
-bool CursorVisitor::VisitOverloadExpr(OverloadExpr *E) {
- // Visit the nested-name-specifier.
- if (NestedNameSpecifier *Qualifier = E->getQualifier())
- if (VisitNestedNameSpecifier(Qualifier, E->getQualifierRange()))
- return true;
-
- // Visit the declaration name.
- if (VisitDeclarationNameInfo(E->getNameInfo()))
- return true;
-
- // Visit the overloaded declaration reference.
- if (Visit(MakeCursorOverloadedDeclRef(E, TU)))
- return true;
-
- // Visit the explicitly-specified template arguments.
- if (const ExplicitTemplateArgumentList *ArgList
- = E->getOptionalExplicitTemplateArgs()) {
- for (const TemplateArgumentLoc *Arg = ArgList->getTemplateArgs(),
- *ArgEnd = Arg + ArgList->NumTemplateArgs;
- Arg != ArgEnd; ++Arg) {
- if (VisitTemplateArgumentLoc(*Arg))
- return true;
- }
- }
-
- return false;
-}
-
bool CursorVisitor::VisitDependentScopeDeclRefExpr(
DependentScopeDeclRefExpr *E) {
// Visit the nested-name-specifier.
@@ -1829,15 +1802,6 @@
return false;
}
-bool CursorVisitor::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
- // Visit the base expression, if there is one.
- if (!E->isImplicitAccess() &&
- Visit(MakeCXCursor(E->getBase(), StmtParent, TU)))
- return true;
-
- return VisitOverloadExpr(E);
-}
-
bool CursorVisitor::VisitObjCMessageExpr(ObjCMessageExpr *E) {
if (TypeSourceInfo *TSInfo = E->getClassReceiverTypeInfo())
if (Visit(TSInfo->getTypeLoc()))
@@ -1878,6 +1842,11 @@
std::reverse(I, E);
}
+static void EnqueueOverloadExpr(VisitorWorkList &WL, CXCursor Parent,
+ OverloadExpr *E) {
+ WL.push_back(OverloadExprParts(E, Parent));
+}
+
void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, Stmt *S) {
CXCursor C = MakeCXCursor(S, StmtParent, TU);
switch (S->getStmtClass()) {
@@ -1956,6 +1925,16 @@
WLAddDecl(WL, C, W->getConditionVariable());
break;
}
+ case Stmt::UnresolvedLookupExprClass:
+ EnqueueOverloadExpr(WL, C, cast<OverloadExpr>(S));
+ break;
+ case Stmt::UnresolvedMemberExprClass: {
+ UnresolvedMemberExpr *U = cast<UnresolvedMemberExpr>(S);
+ EnqueueOverloadExpr(WL, C, U);
+ if (!U->isImplicitAccess())
+ WLAddStmt(WL, C, U->getBase());
+ break;
+ }
}
}
@@ -2025,6 +2004,8 @@
case Stmt::ParenExprClass:
case Stmt::SwitchStmtClass:
case Stmt::UnaryOperatorClass:
+ case Stmt::UnresolvedLookupExprClass:
+ case Stmt::UnresolvedMemberExprClass:
case Stmt::WhileStmtClass:
{
if (!IsInRegionOfInterest(Cursor))
@@ -2066,6 +2047,30 @@
}
continue;
}
+ case VisitorJob::OverloadExprPartsKind: {
+ OverloadExpr *O = cast<OverloadExprParts>(LI).get();
+ // Visit the nested-name-specifier.
+ if (NestedNameSpecifier *Qualifier = O->getQualifier())
+ if (VisitNestedNameSpecifier(Qualifier, O->getQualifierRange()))
+ return true;
+ // Visit the declaration name.
+ if (VisitDeclarationNameInfo(O->getNameInfo()))
+ return true;
+ // Visit the overloaded declaration reference.
+ if (Visit(MakeCursorOverloadedDeclRef(O, TU)))
+ return true;
+ // Visit the explicitly-specified template arguments.
+ if (const ExplicitTemplateArgumentList *ArgList
+ = O->getOptionalExplicitTemplateArgs()) {
+ for (const TemplateArgumentLoc *Arg = ArgList->getTemplateArgs(),
+ *ArgEnd = Arg + ArgList->NumTemplateArgs;
+ Arg != ArgEnd; ++Arg) {
+ if (VisitTemplateArgumentLoc(*Arg))
+ return true;
+ }
+ }
+ continue;
+ }
}
}
return false;
More information about the llvm-branch-commits
mailing list