[cfe-commits] r122904 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/AST/DeclBase.h lib/AST/Decl.cpp lib/AST/DeclBase.cpp lib/AST/Expr.cpp lib/Sema/SemaTemplateVariadic.cpp
Douglas Gregor
dgregor at apple.com
Wed Jan 5 13:11:38 PST 2011
Author: dgregor
Date: Wed Jan 5 15:11:38 2011
New Revision: 122904
URL: http://llvm.org/viewvc/llvm-project?rev=122904&view=rev
Log:
Add Decl::isParameterPack(), which covers both function and template
parameter packs, along with ParmVarDecl::isParameterPack(), which
looks for function parameter packs. Use these routines to fix some
obvious FIXMEs.
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=122904&r1=122903&r2=122904&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Jan 5 15:11:38 2011
@@ -1133,6 +1133,10 @@
return getType();
}
+ /// \brief Determine whether this parameter is actually a function
+ /// parameter pack.
+ bool isParameterPack() const;
+
/// setOwningFunction - Sets the function declaration that owns this
/// ParmVarDecl. Since ParmVarDecls are often created before the
/// FunctionDecls that own them, this routine is required to update
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=122904&r1=122903&r2=122904&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Wed Jan 5 15:11:38 2011
@@ -567,6 +567,9 @@
/// template parameter pack.
bool isTemplateParameterPack() const;
+ /// \brief Whether this declaration is a parameter pack.
+ bool isParameterPack() const;
+
/// \brief Whether this declaration is a function or function template.
bool isFunctionOrFunctionTemplate() const;
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=122904&r1=122903&r2=122904&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Jan 5 15:11:38 2011
@@ -1221,6 +1221,10 @@
return SourceRange();
}
+bool ParmVarDecl::isParameterPack() const {
+ return isa<PackExpansionType>(getType());
+}
+
//===----------------------------------------------------------------------===//
// FunctionDecl Implementation
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=122904&r1=122903&r2=122904&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Wed Jan 5 15:11:38 2011
@@ -119,6 +119,13 @@
return false;
}
+bool Decl::isParameterPack() const {
+ if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(this))
+ return Parm->isParameterPack();
+
+ return isTemplateParameterPack();
+}
+
bool Decl::isFunctionOrFunctionTemplate() const {
if (const UsingShadowDecl *UD = dyn_cast<UsingShadowDecl>(this))
return UD->getTargetDecl()->isFunctionOrFunctionTemplate();
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=122904&r1=122903&r2=122904&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Wed Jan 5 15:11:38 2011
@@ -211,11 +211,8 @@
// Determine whether this expression contains any unexpanded parameter
// packs.
// Is the declaration a parameter pack?
- if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
- if (NTTP->isParameterPack())
- ExprBits.ContainsUnexpandedParameterPack = true;
- }
- // FIXME: Variadic templates function parameter packs.
+ if (D->isParameterPack())
+ ExprBits.ContainsUnexpandedParameterPack = true;
}
DeclRefExpr::DeclRefExpr(NestedNameSpecifier *Qualifier,
Modified: cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp?rev=122904&r1=122903&r2=122904&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp Wed Jan 5 15:11:38 2011
@@ -602,9 +602,8 @@
case LookupResult::NotFoundInCurrentInstantiation:
if (DeclarationName CorrectedName = CorrectTypo(R, S, 0, 0, false,
CTC_NoKeywords)) {
- // FIXME: Variadic templates function parameter packs.
if (NamedDecl *CorrectedResult = R.getAsSingle<NamedDecl>())
- if (CorrectedResult->isTemplateParameterPack()) {
+ if (CorrectedResult->isParameterPack()) {
ParameterPack = CorrectedResult;
Diag(NameLoc, diag::err_sizeof_pack_no_pack_name_suggest)
<< &Name << CorrectedName
@@ -624,8 +623,7 @@
return ExprError();
}
- // FIXME: Variadic templates function parameter packs.
- if (!ParameterPack || !ParameterPack->isTemplateParameterPack()) {
+ if (!ParameterPack || !ParameterPack->isParameterPack()) {
Diag(NameLoc, diag::err_sizeof_pack_no_pack_name)
<< &Name;
return ExprError();
More information about the cfe-commits
mailing list