blob: 030a0423f74b80c63670b2be1f4125f34fad3835 [file] [log] [blame]
Douglas Gregorc4633352010-12-15 17:38:57 +00001//===------- SemaTemplateVariadic.cpp - C++ Variadic Templates ------------===/
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//===----------------------------------------------------------------------===/
8//
9// This file implements semantic analysis for C++0x variadic templates.
10//===----------------------------------------------------------------------===/
11
12#include "clang/Sema/Sema.h"
Douglas Gregor7536dd52010-12-20 02:24:11 +000013#include "clang/Sema/ParsedTemplate.h"
Douglas Gregorc4633352010-12-15 17:38:57 +000014#include "clang/Sema/SemaInternal.h"
Douglas Gregor8491ffe2010-12-20 22:05:00 +000015#include "clang/Sema/Template.h"
Douglas Gregorc4633352010-12-15 17:38:57 +000016#include "clang/AST/Expr.h"
Douglas Gregor9ef75892010-12-15 19:43:21 +000017#include "clang/AST/RecursiveASTVisitor.h"
Douglas Gregorc4633352010-12-15 17:38:57 +000018#include "clang/AST/TypeLoc.h"
19
20using namespace clang;
21
Douglas Gregor9ef75892010-12-15 19:43:21 +000022//----------------------------------------------------------------------------
23// Visitor that collects unexpanded parameter packs
24//----------------------------------------------------------------------------
25
Douglas Gregor9ef75892010-12-15 19:43:21 +000026namespace {
27 /// \brief A class that collects unexpanded parameter packs.
28 class CollectUnexpandedParameterPacksVisitor :
29 public RecursiveASTVisitor<CollectUnexpandedParameterPacksVisitor>
30 {
31 typedef RecursiveASTVisitor<CollectUnexpandedParameterPacksVisitor>
32 inherited;
33
34 llvm::SmallVectorImpl<UnexpandedParameterPack> &Unexpanded;
35
36 public:
37 explicit CollectUnexpandedParameterPacksVisitor(
38 llvm::SmallVectorImpl<UnexpandedParameterPack> &Unexpanded)
39 : Unexpanded(Unexpanded) { }
40
Douglas Gregora40bc722010-12-20 23:07:20 +000041 bool shouldWalkTypesOfTypeLocs() const { return false; }
42
Douglas Gregor9ef75892010-12-15 19:43:21 +000043 //------------------------------------------------------------------------
44 // Recording occurrences of (unexpanded) parameter packs.
45 //------------------------------------------------------------------------
46
47 /// \brief Record occurrences of template type parameter packs.
48 bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
49 if (TL.getTypePtr()->isParameterPack())
50 Unexpanded.push_back(std::make_pair(TL.getTypePtr(), TL.getNameLoc()));
51 return true;
52 }
53
54 /// \brief Record occurrences of template type parameter packs
55 /// when we don't have proper source-location information for
56 /// them.
57 ///
58 /// Ideally, this routine would never be used.
59 bool VisitTemplateTypeParmType(TemplateTypeParmType *T) {
60 if (T->isParameterPack())
61 Unexpanded.push_back(std::make_pair(T, SourceLocation()));
62
63 return true;
64 }
65
Douglas Gregor10738d32010-12-23 23:51:58 +000066 /// \brief Record occurrences of (FIXME: function and) non-type template
67 /// parameter packs in an expression.
68 bool VisitDeclRefExpr(DeclRefExpr *E) {
69 if (NonTypeTemplateParmDecl *NTTP
70 = dyn_cast<NonTypeTemplateParmDecl>(E->getDecl())) {
71 if (NTTP->isParameterPack())
72 Unexpanded.push_back(std::make_pair(NTTP, E->getLocation()));
73 }
74
75 // FIXME: Function parameter packs.
76
77 return true;
78 }
79
80 // FIXME: Record occurrences of template template parameter packs.
Douglas Gregor9ef75892010-12-15 19:43:21 +000081
Douglas Gregor9ef75892010-12-15 19:43:21 +000082 //------------------------------------------------------------------------
83 // Pruning the search for unexpanded parameter packs.
84 //------------------------------------------------------------------------
85
86 /// \brief Suppress traversal into statements and expressions that
87 /// do not contain unexpanded parameter packs.
88 bool TraverseStmt(Stmt *S) {
89 if (Expr *E = dyn_cast_or_null<Expr>(S))
90 if (E->containsUnexpandedParameterPack())
91 return inherited::TraverseStmt(E);
92
93 return true;
94 }
95
96 /// \brief Suppress traversal into types that do not contain
97 /// unexpanded parameter packs.
98 bool TraverseType(QualType T) {
99 if (!T.isNull() && T->containsUnexpandedParameterPack())
100 return inherited::TraverseType(T);
101
102 return true;
103 }
104
105 /// \brief Suppress traversel into types with location information
106 /// that do not contain unexpanded parameter packs.
107 bool TraverseTypeLoc(TypeLoc TL) {
Douglas Gregor10738d32010-12-23 23:51:58 +0000108 if (!TL.getType().isNull() &&
109 TL.getType()->containsUnexpandedParameterPack())
Douglas Gregor9ef75892010-12-15 19:43:21 +0000110 return inherited::TraverseTypeLoc(TL);
111
112 return true;
113 }
114
Douglas Gregorcff163e2010-12-15 21:57:59 +0000115 /// \brief Suppress traversal of non-parameter declarations, since
116 /// they cannot contain unexpanded parameter packs.
117 bool TraverseDecl(Decl *D) {
118 if (D && isa<ParmVarDecl>(D))
119 return inherited::TraverseDecl(D);
120
121 return true;
122 }
Douglas Gregor9ef75892010-12-15 19:43:21 +0000123 };
124}
125
126/// \brief Diagnose all of the unexpanded parameter packs in the given
127/// vector.
128static void
129DiagnoseUnexpandedParameterPacks(Sema &S, SourceLocation Loc,
130 Sema::UnexpandedParameterPackContext UPPC,
131 const llvm::SmallVectorImpl<UnexpandedParameterPack> &Unexpanded) {
132 llvm::SmallVector<SourceLocation, 4> Locations;
133 llvm::SmallVector<IdentifierInfo *, 4> Names;
134 llvm::SmallPtrSet<IdentifierInfo *, 4> NamesKnown;
135
136 for (unsigned I = 0, N = Unexpanded.size(); I != N; ++I) {
137 IdentifierInfo *Name = 0;
138 if (const TemplateTypeParmType *TTP
139 = Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>())
140 Name = TTP->getName();
141 else
142 Name = Unexpanded[I].first.get<NamedDecl *>()->getIdentifier();
143
144 if (Name && NamesKnown.insert(Name))
145 Names.push_back(Name);
146
147 if (Unexpanded[I].second.isValid())
148 Locations.push_back(Unexpanded[I].second);
149 }
150
151 DiagnosticBuilder DB
152 = Names.size() == 0? S.Diag(Loc, diag::err_unexpanded_parameter_pack_0)
153 << (int)UPPC
154 : Names.size() == 1? S.Diag(Loc, diag::err_unexpanded_parameter_pack_1)
155 << (int)UPPC << Names[0]
156 : Names.size() == 2? S.Diag(Loc, diag::err_unexpanded_parameter_pack_2)
157 << (int)UPPC << Names[0] << Names[1]
158 : S.Diag(Loc, diag::err_unexpanded_parameter_pack_3_or_more)
159 << (int)UPPC << Names[0] << Names[1];
160
161 for (unsigned I = 0, N = Locations.size(); I != N; ++I)
162 DB << SourceRange(Locations[I]);
163}
164
Douglas Gregorc4633352010-12-15 17:38:57 +0000165bool Sema::DiagnoseUnexpandedParameterPack(SourceLocation Loc,
166 TypeSourceInfo *T,
167 UnexpandedParameterPackContext UPPC) {
168 // C++0x [temp.variadic]p5:
169 // An appearance of a name of a parameter pack that is not expanded is
170 // ill-formed.
171 if (!T->getType()->containsUnexpandedParameterPack())
172 return false;
173
Douglas Gregor9ef75892010-12-15 19:43:21 +0000174 llvm::SmallVector<UnexpandedParameterPack, 2> Unexpanded;
175 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseTypeLoc(
176 T->getTypeLoc());
177 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
178 DiagnoseUnexpandedParameterPacks(*this, Loc, UPPC, Unexpanded);
Douglas Gregorc4633352010-12-15 17:38:57 +0000179 return true;
180}
181
182bool Sema::DiagnoseUnexpandedParameterPack(Expr *E,
Douglas Gregor56c04582010-12-16 00:46:58 +0000183 UnexpandedParameterPackContext UPPC) {
Douglas Gregorc4633352010-12-15 17:38:57 +0000184 // C++0x [temp.variadic]p5:
185 // An appearance of a name of a parameter pack that is not expanded is
186 // ill-formed.
187 if (!E->containsUnexpandedParameterPack())
188 return false;
189
Douglas Gregor9ef75892010-12-15 19:43:21 +0000190 llvm::SmallVector<UnexpandedParameterPack, 2> Unexpanded;
191 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseStmt(E);
192 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
193 DiagnoseUnexpandedParameterPacks(*this, E->getLocStart(), UPPC, Unexpanded);
Douglas Gregorc4633352010-12-15 17:38:57 +0000194 return true;
195}
Douglas Gregor56c04582010-12-16 00:46:58 +0000196
197bool Sema::DiagnoseUnexpandedParameterPack(const CXXScopeSpec &SS,
198 UnexpandedParameterPackContext UPPC) {
199 // C++0x [temp.variadic]p5:
200 // An appearance of a name of a parameter pack that is not expanded is
201 // ill-formed.
202 if (!SS.getScopeRep() ||
203 !SS.getScopeRep()->containsUnexpandedParameterPack())
204 return false;
205
206 llvm::SmallVector<UnexpandedParameterPack, 2> Unexpanded;
207 CollectUnexpandedParameterPacksVisitor(Unexpanded)
208 .TraverseNestedNameSpecifier(SS.getScopeRep());
209 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
210 DiagnoseUnexpandedParameterPacks(*this, SS.getRange().getBegin(),
211 UPPC, Unexpanded);
212 return true;
213}
214
215bool Sema::DiagnoseUnexpandedParameterPack(const DeclarationNameInfo &NameInfo,
216 UnexpandedParameterPackContext UPPC) {
217 // C++0x [temp.variadic]p5:
218 // An appearance of a name of a parameter pack that is not expanded is
219 // ill-formed.
220 switch (NameInfo.getName().getNameKind()) {
221 case DeclarationName::Identifier:
222 case DeclarationName::ObjCZeroArgSelector:
223 case DeclarationName::ObjCOneArgSelector:
224 case DeclarationName::ObjCMultiArgSelector:
225 case DeclarationName::CXXOperatorName:
226 case DeclarationName::CXXLiteralOperatorName:
227 case DeclarationName::CXXUsingDirective:
228 return false;
229
230 case DeclarationName::CXXConstructorName:
231 case DeclarationName::CXXDestructorName:
232 case DeclarationName::CXXConversionFunctionName:
Douglas Gregor099ffe82010-12-16 17:19:19 +0000233 // FIXME: We shouldn't need this null check!
Douglas Gregor0762bfd2010-12-16 01:40:04 +0000234 if (TypeSourceInfo *TSInfo = NameInfo.getNamedTypeInfo())
235 return DiagnoseUnexpandedParameterPack(NameInfo.getLoc(), TSInfo, UPPC);
236
237 if (!NameInfo.getName().getCXXNameType()->containsUnexpandedParameterPack())
Douglas Gregor56c04582010-12-16 00:46:58 +0000238 return false;
Douglas Gregor0762bfd2010-12-16 01:40:04 +0000239
Douglas Gregor56c04582010-12-16 00:46:58 +0000240 break;
241 }
242
243 llvm::SmallVector<UnexpandedParameterPack, 2> Unexpanded;
244 CollectUnexpandedParameterPacksVisitor(Unexpanded)
Douglas Gregor0762bfd2010-12-16 01:40:04 +0000245 .TraverseType(NameInfo.getName().getCXXNameType());
Douglas Gregor56c04582010-12-16 00:46:58 +0000246 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
247 DiagnoseUnexpandedParameterPacks(*this, NameInfo.getLoc(), UPPC, Unexpanded);
248 return true;
249}
Douglas Gregor6f526752010-12-16 08:48:57 +0000250
251bool Sema::DiagnoseUnexpandedParameterPack(SourceLocation Loc,
252 TemplateName Template,
253 UnexpandedParameterPackContext UPPC) {
254
255 if (Template.isNull() || !Template.containsUnexpandedParameterPack())
256 return false;
257
258 llvm::SmallVector<UnexpandedParameterPack, 2> Unexpanded;
259 CollectUnexpandedParameterPacksVisitor(Unexpanded)
260 .TraverseTemplateName(Template);
261 assert(!Unexpanded.empty() && "Unable to find unexpanded parameter packs");
262 DiagnoseUnexpandedParameterPacks(*this, Loc, UPPC, Unexpanded);
263 return true;
264}
265
Douglas Gregore02e2622010-12-22 21:19:48 +0000266void Sema::collectUnexpandedParameterPacks(TemplateArgument Arg,
267 llvm::SmallVectorImpl<UnexpandedParameterPack> &Unexpanded) {
268 CollectUnexpandedParameterPacksVisitor(Unexpanded)
269 .TraverseTemplateArgument(Arg);
270}
271
Douglas Gregor8491ffe2010-12-20 22:05:00 +0000272void Sema::collectUnexpandedParameterPacks(TemplateArgumentLoc Arg,
273 llvm::SmallVectorImpl<UnexpandedParameterPack> &Unexpanded) {
274 CollectUnexpandedParameterPacksVisitor(Unexpanded)
275 .TraverseTemplateArgumentLoc(Arg);
276}
277
Douglas Gregorb99268b2010-12-21 00:52:54 +0000278void Sema::collectUnexpandedParameterPacks(QualType T,
279 llvm::SmallVectorImpl<UnexpandedParameterPack> &Unexpanded) {
280 CollectUnexpandedParameterPacksVisitor(Unexpanded).TraverseType(T);
281}
282
Douglas Gregor7536dd52010-12-20 02:24:11 +0000283ParsedTemplateArgument
284Sema::ActOnPackExpansion(const ParsedTemplateArgument &Arg,
285 SourceLocation EllipsisLoc) {
286 if (Arg.isInvalid())
287 return Arg;
288
289 switch (Arg.getKind()) {
290 case ParsedTemplateArgument::Type: {
291 TypeResult Result = ActOnPackExpansion(Arg.getAsType(), EllipsisLoc);
292 if (Result.isInvalid())
293 return ParsedTemplateArgument();
294
295 return ParsedTemplateArgument(Arg.getKind(), Result.get().getAsOpaquePtr(),
296 Arg.getLocation());
297 }
298
Douglas Gregorbe230c32011-01-03 17:17:50 +0000299 case ParsedTemplateArgument::NonType: {
300 ExprResult Result = ActOnPackExpansion(Arg.getAsExpr(), EllipsisLoc);
301 if (Result.isInvalid())
302 return ParsedTemplateArgument();
303
304 return ParsedTemplateArgument(Arg.getKind(), Result.get(),
305 Arg.getLocation());
306 }
307
Douglas Gregor7536dd52010-12-20 02:24:11 +0000308 case ParsedTemplateArgument::Template:
Douglas Gregorbe230c32011-01-03 17:17:50 +0000309 Diag(EllipsisLoc, diag::err_pack_expansion_unsupported);
Douglas Gregor7536dd52010-12-20 02:24:11 +0000310 return ParsedTemplateArgument();
311 }
312 llvm_unreachable("Unhandled template argument kind?");
313 return ParsedTemplateArgument();
314}
315
316TypeResult Sema::ActOnPackExpansion(ParsedType Type,
317 SourceLocation EllipsisLoc) {
318 TypeSourceInfo *TSInfo;
319 GetTypeFromParser(Type, &TSInfo);
320 if (!TSInfo)
321 return true;
322
Douglas Gregor8491ffe2010-12-20 22:05:00 +0000323 TypeSourceInfo *TSResult = CheckPackExpansion(TSInfo, EllipsisLoc);
324 if (!TSResult)
325 return true;
326
327 return CreateParsedType(TSResult->getType(), TSResult);
328}
329
330TypeSourceInfo *Sema::CheckPackExpansion(TypeSourceInfo *Pattern,
331 SourceLocation EllipsisLoc) {
Douglas Gregor7536dd52010-12-20 02:24:11 +0000332 // C++0x [temp.variadic]p5:
333 // The pattern of a pack expansion shall name one or more
334 // parameter packs that are not expanded by a nested pack
335 // expansion.
Douglas Gregor8491ffe2010-12-20 22:05:00 +0000336 if (!Pattern->getType()->containsUnexpandedParameterPack()) {
Douglas Gregor7536dd52010-12-20 02:24:11 +0000337 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
Douglas Gregor8491ffe2010-12-20 22:05:00 +0000338 << Pattern->getTypeLoc().getSourceRange();
339 return 0;
Douglas Gregor7536dd52010-12-20 02:24:11 +0000340 }
Douglas Gregor8491ffe2010-12-20 22:05:00 +0000341
Douglas Gregor7536dd52010-12-20 02:24:11 +0000342 // Create the pack expansion type and source-location information.
Douglas Gregor8491ffe2010-12-20 22:05:00 +0000343 QualType Result = Context.getPackExpansionType(Pattern->getType());
Douglas Gregor7536dd52010-12-20 02:24:11 +0000344 TypeSourceInfo *TSResult = Context.CreateTypeSourceInfo(Result);
345 PackExpansionTypeLoc TL = cast<PackExpansionTypeLoc>(TSResult->getTypeLoc());
346 TL.setEllipsisLoc(EllipsisLoc);
Douglas Gregor8491ffe2010-12-20 22:05:00 +0000347
Douglas Gregor7536dd52010-12-20 02:24:11 +0000348 // Copy over the source-location information from the type.
349 memcpy(TL.getNextTypeLoc().getOpaqueData(),
Douglas Gregor8491ffe2010-12-20 22:05:00 +0000350 Pattern->getTypeLoc().getOpaqueData(),
351 Pattern->getTypeLoc().getFullDataSize());
352 return TSResult;
Douglas Gregor7536dd52010-12-20 02:24:11 +0000353}
Douglas Gregorb99268b2010-12-21 00:52:54 +0000354
Douglas Gregorbe230c32011-01-03 17:17:50 +0000355ExprResult Sema::ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc) {
356 if (!Pattern)
357 return ExprError();
358
359 // C++0x [temp.variadic]p5:
360 // The pattern of a pack expansion shall name one or more
361 // parameter packs that are not expanded by a nested pack
362 // expansion.
363 if (!Pattern->containsUnexpandedParameterPack()) {
364 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
365 << Pattern->getSourceRange();
366 return ExprError();
367 }
368
369 // Create the pack expansion expression and source-location information.
370 return Owned(new (Context) PackExpansionExpr(Context.DependentTy, Pattern,
371 EllipsisLoc));
372}
Douglas Gregorb99268b2010-12-21 00:52:54 +0000373
374bool Sema::CheckParameterPacksForExpansion(SourceLocation EllipsisLoc,
375 SourceRange PatternRange,
376 const UnexpandedParameterPack *Unexpanded,
377 unsigned NumUnexpanded,
378 const MultiLevelTemplateArgumentList &TemplateArgs,
379 bool &ShouldExpand,
380 unsigned &NumExpansions) {
381 ShouldExpand = true;
382 std::pair<IdentifierInfo *, SourceLocation> FirstPack;
383 bool HaveFirstPack = false;
384
385 for (unsigned I = 0; I != NumUnexpanded; ++I) {
386 // Compute the depth and index for this parameter pack.
387 unsigned Depth;
388 unsigned Index;
389 IdentifierInfo *Name;
390
391 if (const TemplateTypeParmType *TTP
392 = Unexpanded[I].first.dyn_cast<const TemplateTypeParmType *>()) {
393 Depth = TTP->getDepth();
394 Index = TTP->getIndex();
395 Name = TTP->getName();
396 } else {
397 NamedDecl *ND = Unexpanded[I].first.get<NamedDecl *>();
398 if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(ND)) {
399 Depth = TTP->getDepth();
400 Index = TTP->getIndex();
401 } else if (NonTypeTemplateParmDecl *NTTP
402 = dyn_cast<NonTypeTemplateParmDecl>(ND)) {
403 Depth = NTTP->getDepth();
404 Index = NTTP->getIndex();
405 } else {
406 TemplateTemplateParmDecl *TTP = cast<TemplateTemplateParmDecl>(ND);
407 Depth = TTP->getDepth();
408 Index = TTP->getIndex();
409 }
410 // FIXME: Variadic templates function parameter packs?
411 Name = ND->getIdentifier();
412 }
413
414 // If we don't have a template argument at this depth/index, then we
415 // cannot expand the pack expansion. Make a note of this, but we still
Douglas Gregor56bc9832010-12-24 00:15:10 +0000416 // want to check any parameter packs we *do* have arguments for.
Douglas Gregorb99268b2010-12-21 00:52:54 +0000417 if (!TemplateArgs.hasTemplateArgument(Depth, Index)) {
418 ShouldExpand = false;
419 continue;
420 }
421
422 // Determine the size of the argument pack.
423 unsigned NewPackSize = TemplateArgs(Depth, Index).pack_size();
424 if (!HaveFirstPack) {
425 // The is the first pack we've seen for which we have an argument.
426 // Record it.
427 NumExpansions = NewPackSize;
428 FirstPack.first = Name;
429 FirstPack.second = Unexpanded[I].second;
430 HaveFirstPack = true;
431 continue;
432 }
433
434 if (NewPackSize != NumExpansions) {
435 // C++0x [temp.variadic]p5:
436 // All of the parameter packs expanded by a pack expansion shall have
437 // the same number of arguments specified.
438 Diag(EllipsisLoc, diag::err_pack_expansion_length_conflict)
439 << FirstPack.first << Name << NumExpansions << NewPackSize
440 << SourceRange(FirstPack.second) << SourceRange(Unexpanded[I].second);
441 return true;
442 }
443 }
444
445 return false;
446}
Douglas Gregora8bc8c92010-12-23 22:44:42 +0000447
448bool Sema::containsUnexpandedParameterPacks(Declarator &D) {
449 const DeclSpec &DS = D.getDeclSpec();
450 switch (DS.getTypeSpecType()) {
451 case TST_typename:
452 case TST_typeofType: {
453 QualType T = DS.getRepAsType().get();
454 if (!T.isNull() && T->containsUnexpandedParameterPack())
455 return true;
456 break;
457 }
458
459 case TST_typeofExpr:
460 case TST_decltype:
461 if (DS.getRepAsExpr() &&
462 DS.getRepAsExpr()->containsUnexpandedParameterPack())
463 return true;
464 break;
465
466 case TST_unspecified:
467 case TST_void:
468 case TST_char:
469 case TST_wchar:
470 case TST_char16:
471 case TST_char32:
472 case TST_int:
473 case TST_float:
474 case TST_double:
475 case TST_bool:
476 case TST_decimal32:
477 case TST_decimal64:
478 case TST_decimal128:
479 case TST_enum:
480 case TST_union:
481 case TST_struct:
482 case TST_class:
483 case TST_auto:
484 case TST_error:
485 break;
486 }
487
488 for (unsigned I = 0, N = D.getNumTypeObjects(); I != N; ++I) {
489 const DeclaratorChunk &Chunk = D.getTypeObject(I);
490 switch (Chunk.Kind) {
491 case DeclaratorChunk::Pointer:
492 case DeclaratorChunk::Reference:
493 case DeclaratorChunk::Paren:
494 // These declarator chunks cannot contain any parameter packs.
495 break;
496
497 case DeclaratorChunk::Array:
498 case DeclaratorChunk::Function:
499 case DeclaratorChunk::BlockPointer:
500 // Syntactically, these kinds of declarator chunks all come after the
501 // declarator-id (conceptually), so the parser should not invoke this
502 // routine at this time.
503 llvm_unreachable("Could not have seen this kind of declarator chunk");
504 break;
505
506 case DeclaratorChunk::MemberPointer:
507 if (Chunk.Mem.Scope().getScopeRep() &&
508 Chunk.Mem.Scope().getScopeRep()->containsUnexpandedParameterPack())
509 return true;
510 break;
511 }
512 }
513
514 return false;
515}