Commit Graph

60 Commits

Author SHA1 Message Date
Douglas Gregor 15b4ec22f1 Give the RecursiveASTVisitor a configuration function
shouldWalkTypesOfTypeLocs() that determines whether it should walk the
Types within TypeLocs. This walk is redundant, but perhaps required
for some clients. Disabling this redundant walk in the unexpanded
parameter pack finder produces better results, because we get
parameter packs with source location info *unless* such source
location information isn't available.

llvm-svn: 122287
2010-12-20 23:07:20 +00:00
Douglas Gregor 840bd6cce5 Implement basic support for template instantiation of pack expansions
whose patterns are template arguments. We can now instantiate, e.g.,

  typedef tuple<pair<OuterTypes, InnerTypes>...> type;

where OuterTypes and InnerTypes are template type parameter packs.

There is a horrible inefficiency in
TemplateArgumentLoc::getPackExpansionPattern(), where we need to
create copies of TypeLoc data because our interfaces traffic in
TypeSourceInfo pointers where they should traffic in TypeLocs
instead. I've isolated in efficiency in this one routine; once we
refactor our interfaces to traffic in TypeLocs, we can eliminate it.

llvm-svn: 122278
2010-12-20 22:05:00 +00:00
Douglas Gregor d2fa766ad0 Introduce a new type, PackExpansionType, to capture types that are
pack expansions, e.g. given

  template<typename... Types> struct tuple;

  template<typename... Types>
  struct tuple_of_refs {
    typedef tuple<Types&...> types;
  };

the type of the "types" typedef is a PackExpansionType whose pattern
is Types&. 

This commit introduces support for creating pack expansions for
template type arguments, as above, but not for any other kind of pack
expansion, nor for any form of instantiation.

llvm-svn: 122223
2010-12-20 02:24:11 +00:00
Douglas Gregor 062ecac8ed Tweak a comment
llvm-svn: 121979
2010-12-16 17:19:19 +00:00
Douglas Gregor 6ff1fbf65f Check for unexpanded parameter packs in default arguments.
llvm-svn: 121962
2010-12-16 08:48:57 +00:00
Douglas Gregor 6ab34afc4e Fix a regression I caused in r121930. It turns out that
DeclarationNameInfo instances don't always have a non-NULL
TypeSourceInfo?

llvm-svn: 121940
2010-12-16 01:40:04 +00:00
Douglas Gregor c435653998 Check for unexpanded parameter packs in using declarations. As a
drive-by, make sure to check for unexpanded parameter packs within the
name of a declaration.

llvm-svn: 121930
2010-12-16 00:46:58 +00:00
Douglas Gregor a8461bb439 Test that all of the relevant types properly compute the "contains
unexpanded parameter pack" bit and that the recursive AST visitor can
then find those unexpanded parameter packs.

llvm-svn: 121899
2010-12-15 21:57:59 +00:00
Douglas Gregor 1da294a9d6 Introduce a RecursiveASTVisitor subclass that finds all unexpanded
parameter packs within a statement, type, etc. Use this visitor to
provide improved diagnostics for the presence of unexpanded parameter
packs in a full expression, base type, declaration type, etc., by
highlighting the unexpanded parameter packs and providing their names,
e.g.,

test/CXX/temp/temp.decls/temp.variadic/p5.cpp:28:85: error: declaration type
      contains unexpanded parameter packs 'VeryInnerTypes',
      'OuterTypes', ...
  ...VeryInnerTypes, OuterTypes>, pair<InnerTypes, OuterTypes> > types;
     ~~~~~~~~~~~~~~  ~~~~~~~~~~        ~~~~~~~~~~  ~~~~~~~~~~    ^

llvm-svn: 121883
2010-12-15 19:43:21 +00:00
Douglas Gregor b55fdf8c6f Move the work-in-progress implementation of variadic templates to its own file in Sema. No functionality change.
llvm-svn: 121869
2010-12-15 17:38:57 +00:00