[llvm-branch-commits] [cfe-branch] r119658 - /cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp
Daniel Dunbar
daniel at zuster.org
Wed Nov 17 18:37:53 PST 2010
Author: ddunbar
Date: Wed Nov 17 20:37:53 2010
New Revision: 119658
URL: http://llvm.org/viewvc/llvm-project?rev=119658&view=rev
Log:
Merge r119442:
--
Author: Ted Kremenek <kremenek at apple.com>
Date: Wed Nov 17 00:50:47 2010 +0000
CursorVisitor: refactor visitation of
explicit template args within 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=119658&r1=119657&r2=119658&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp (original)
+++ cfe/branches/Apple/whitney/tools/libclang/CIndex.cpp Wed Nov 17 20:37:53 2010
@@ -136,7 +136,8 @@
public:
enum Kind { DeclVisitKind, StmtVisitKind, MemberExprPartsKind,
TypeLocVisitKind, OverloadExprPartsKind,
- DeclRefExprPartsKind, LabelRefVisitKind };
+ DeclRefExprPartsKind, LabelRefVisitKind,
+ ExplicitTemplateArgsVisitKind };
protected:
void *dataA;
void *dataB;
@@ -1638,6 +1639,8 @@
DEF_JOB(MemberExprParts, MemberExpr, MemberExprPartsKind)
DEF_JOB(DeclRefExprParts, DeclRefExpr, DeclRefExprPartsKind)
DEF_JOB(OverloadExprParts, OverloadExpr, OverloadExprPartsKind)
+DEF_JOB(ExplicitTemplateArgsVisit, ExplicitTemplateArgumentList,
+ ExplicitTemplateArgsVisitKind)
#undef DEF_JOB
class DeclVisit : public VisitorJob {
@@ -1651,7 +1654,6 @@
Decl *get() const { return static_cast<Decl*>(dataA); }
bool isFirst() const { return dataB ? true : false; }
};
-
class TypeLocVisit : public VisitorJob {
public:
TypeLocVisit(TypeLoc tl, CXCursor parent) :
@@ -1718,6 +1720,7 @@
void VisitVAArgExpr(VAArgExpr *E);
private:
+ void AddExplicitTemplateArgs(const ExplicitTemplateArgumentList *A);
void AddStmt(Stmt *S);
void AddDecl(Decl *D, bool isFirst = true);
void AddTypeLoc(TypeSourceInfo *TI);
@@ -1733,6 +1736,12 @@
if (D)
WL.push_back(DeclVisit(D, Parent, isFirst));
}
+void EnqueueVisitor::
+ AddExplicitTemplateArgs(const ExplicitTemplateArgumentList *A) {
+ if (A)
+ WL.push_back(ExplicitTemplateArgsVisit(
+ const_cast<ExplicitTemplateArgumentList*>(A), Parent));
+}
void EnqueueVisitor::AddTypeLoc(TypeSourceInfo *TI) {
if (TI)
WL.push_back(TypeLocVisit(TI->getTypeLoc(), Parent));
@@ -1800,6 +1809,9 @@
AddTypeLoc(E->getTypeSourceInfo());
}
void EnqueueVisitor::VisitDeclRefExpr(DeclRefExpr *DR) {
+ if (DR->hasExplicitTemplateArgs()) {
+ AddExplicitTemplateArgs(&DR->getExplicitTemplateArgs());
+ }
WL.push_back(DeclRefExprParts(DR, Parent));
}
void EnqueueVisitor::VisitDeclStmt(DeclStmt *S) {
@@ -1855,6 +1867,7 @@
AddTypeLoc(M->getClassReceiverTypeInfo());
}
void EnqueueVisitor::VisitOverloadExpr(OverloadExpr *E) {
+ AddExplicitTemplateArgs(E->getOptionalExplicitTemplateArgs());
WL.push_back(OverloadExprParts(E, Parent));
}
void EnqueueVisitor::VisitStmt(Stmt *S) {
@@ -1919,6 +1932,17 @@
continue;
}
+ case VisitorJob::ExplicitTemplateArgsVisitKind: {
+ const ExplicitTemplateArgumentList *ArgList =
+ cast<ExplicitTemplateArgsVisit>(&LI)->get();
+ for (const TemplateArgumentLoc *Arg = ArgList->getTemplateArgs(),
+ *ArgEnd = Arg + ArgList->NumTemplateArgs;
+ Arg != ArgEnd; ++Arg) {
+ if (VisitTemplateArgumentLoc(*Arg))
+ return true;
+ }
+ continue;
+ }
case VisitorJob::TypeLocVisitKind: {
// Perform default visitation for TypeLocs.
if (Visit(cast<TypeLocVisit>(&LI)->get()))
@@ -2005,15 +2029,6 @@
// 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: {
@@ -2028,16 +2043,6 @@
// 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;
}
}
More information about the llvm-branch-commits
mailing list