[cfe-commits] r123846 - in /cfe/trunk: test/Index/annotate-tokens-cxx0x.cpp tools/libclang/CIndex.cpp
Douglas Gregor
dgregor at apple.com
Wed Jan 19 12:34:17 PST 2011
Author: dgregor
Date: Wed Jan 19 14:34:17 2011
New Revision: 123846
URL: http://llvm.org/viewvc/llvm-project?rev=123846&view=rev
Log:
Teach libclang about SizeOfPackExpr.
Added:
cfe/trunk/test/Index/annotate-tokens-cxx0x.cpp (with props)
Modified:
cfe/trunk/tools/libclang/CIndex.cpp
Added: cfe/trunk/test/Index/annotate-tokens-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens-cxx0x.cpp?rev=123846&view=auto
==============================================================================
--- cfe/trunk/test/Index/annotate-tokens-cxx0x.cpp (added)
+++ cfe/trunk/test/Index/annotate-tokens-cxx0x.cpp Wed Jan 19 14:34:17 2011
@@ -0,0 +1,8 @@
+template<typename ...Args>
+int f(Args ...args) {
+ return sizeof...(args) + sizeof...(Args);
+}
+
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:5:1 -std=c++0x %s | FileCheck %s
+// CHECK: Identifier: "args" [3:20 - 3:24] UnexposedExpr=args:2:15
+// CHECK: Identifier: "Args" [3:38 - 3:42] TypeRef=Args:1:22
Propchange: cfe/trunk/test/Index/annotate-tokens-cxx0x.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/trunk/test/Index/annotate-tokens-cxx0x.cpp
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: cfe/trunk/test/Index/annotate-tokens-cxx0x.cpp
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=123846&r1=123845&r2=123846&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Jan 19 14:34:17 2011
@@ -141,7 +141,7 @@
ExplicitTemplateArgsVisitKind,
NestedNameSpecifierVisitKind,
DeclarationNameInfoVisitKind,
- MemberRefVisitKind };
+ MemberRefVisitKind, SizeOfPackExprPartsKind };
protected:
void *data[3];
CXCursor parent;
@@ -1497,6 +1497,7 @@
DEF_JOB(OverloadExprParts, OverloadExpr, OverloadExprPartsKind)
DEF_JOB(ExplicitTemplateArgsVisit, ExplicitTemplateArgumentList,
ExplicitTemplateArgsVisitKind)
+DEF_JOB(SizeOfPackExprParts, SizeOfPackExpr, SizeOfPackExprPartsKind)
#undef DEF_JOB
class DeclVisit : public VisitorJob {
@@ -1637,7 +1638,7 @@
void VisitBinaryTypeTraitExpr(BinaryTypeTraitExpr *E);
void VisitUnresolvedMemberExpr(UnresolvedMemberExpr *U);
void VisitVAArgExpr(VAArgExpr *E);
- // FIXME: Variadic templates SizeOfPackExpr!
+ void VisitSizeOfPackExpr(SizeOfPackExpr *E);
private:
void AddDeclarationNameInfo(Stmt *S);
@@ -1929,6 +1930,9 @@
AddStmt(E->getSubExpr());
AddTypeLoc(E->getWrittenTypeInfo());
}
+void EnqueueVisitor::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
+ WL.push_back(SizeOfPackExprParts(E, Parent));
+}
void CursorVisitor::EnqueueWorkList(VisitorWorkList &WL, Stmt *S) {
EnqueueVisitor(WL, MakeCXCursor(S, StmtParent, TU)).Visit(S);
@@ -2074,6 +2078,29 @@
return true;
continue;
}
+ case VisitorJob::SizeOfPackExprPartsKind: {
+ SizeOfPackExpr *E = cast<SizeOfPackExprParts>(&LI)->get();
+ NamedDecl *Pack = E->getPack();
+ if (isa<TemplateTypeParmDecl>(Pack)) {
+ if (Visit(MakeCursorTypeRef(cast<TemplateTypeParmDecl>(Pack),
+ E->getPackLoc(), TU)))
+ return true;
+
+ continue;
+ }
+
+ if (isa<TemplateTemplateParmDecl>(Pack)) {
+ if (Visit(MakeCursorTemplateRef(cast<TemplateTemplateParmDecl>(Pack),
+ E->getPackLoc(), TU)))
+ return true;
+
+ continue;
+ }
+
+ // Non-type template parameter packs and function parameter packs are
+ // treated like DeclRefExpr cursors.
+ continue;
+ }
}
}
return false;
@@ -2658,6 +2685,10 @@
if (SubstNonTypeTemplateParmPackExpr *NTTP
= dyn_cast<SubstNonTypeTemplateParmPackExpr>(E))
return NTTP->getParameterPack();
+ if (SizeOfPackExpr *SizeOfPack = dyn_cast<SizeOfPackExpr>(E))
+ if (isa<NonTypeTemplateParmDecl>(SizeOfPack->getPack()) ||
+ isa<ParmVarDecl>(SizeOfPack->getPack()))
+ return SizeOfPack->getPack();
return 0;
}
@@ -2673,6 +2704,9 @@
return Member->getMemberLoc();
if (ObjCIvarRefExpr *Ivar = dyn_cast<ObjCIvarRefExpr>(E))
return Ivar->getLocation();
+ if (SizeOfPackExpr *SizeOfPack = dyn_cast<SizeOfPackExpr>(E))
+ return SizeOfPack->getPackLoc();
+
return E->getLocStart();
}
More information about the cfe-commits
mailing list