summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateVariadic.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Support for C1x _Atomic specifier (see testcase). This is primarily being ↵Eli Friedman2011-10-061-1/+2
| | | | | | | | committed at the moment to help support C++0x <atomic>, but it should be a solid base for implementing the full specification of C1x _Atomic. Thanks to Jeffrey Yasskin for the thorough review! llvm-svn: 141330
* ArrayRef-ifying the UnexpandedParameterPacks passed to ↵David Blaikie2011-09-221-9/+10
| | | | | | Sema::CheckParameterPacksForExpansion llvm-svn: 140290
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-16/+16
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Add support for C++ namespace-aware typo correction, e.g., correctingDouglas Gregor2011-06-281-7/+9
| | | | | | | | | | | | | | | vector<int> to std::vector<int> Patch by Kaelyn Uhrain, with minor tweaks + PCH support from me. Fixes PR5776/<rdar://problem/8652971>. Thanks Kaelyn! llvm-svn: 134007
* Implement a new type node, UnaryTransformType, designed to represent aAlexis Hunt2011-05-241-1/+1
| | | | | | | | type that turns one type into another. This is used as the basis to implement __underlying_type properly - with TypeSourceInfo and proper behavior in the face of templates. llvm-svn: 132017
* Implement __underlying_type for libc++.Alexis Hunt2011-05-191-1/+2
| | | | llvm-svn: 131633
* Switch the interface name for both TemplateTypeParmType andChandler Carruth2011-05-011-2/+2
| | | | | | | | | | | SubstTemplateTypeParmType to be 'getIdentifier' instead of 'getName' as it returns an identifier. This makes them more consistent with the NamedDecl interface. Also, switch back to using this interface to acquire the indentifier in TypePrinter.cpp. I missed this in r130628. llvm-svn: 130629
* Fix a bunch of major problems with __unknown_anytype and properly testJohn McCall2011-04-091-0/+1
| | | | | | for them. The only major missing feature is references. llvm-svn: 129234
* remove some defensive code: LocalInstantiationScope::getInstantiationOfChris Lattner2011-02-171-3/+2
| | | | | | and findInstantiationOf can never return null, even on invalid code. llvm-svn: 125769
* Null initialize a few variables flagged byTed Kremenek2011-01-231-2/+1
| | | | | | | | | | clang's -Wuninitialized-experimental warning. While these don't look like real bugs, clang's -Wuninitialized-experimental analysis is stricter than GCC's, and these fixes have the benefit of being general nice cleanups. llvm-svn: 124072
* Fix a use of uninitialized variables, found by Ted!Douglas Gregor2011-01-201-7/+9
| | | | llvm-svn: 123947
* Implement basic support for the use of variadic templates and blocksDouglas Gregor2011-01-191-1/+10
| | | | | | | | | | | | | | | | | together. In particular: - Handle the use of captured parameter pack names within blocks (BlockDeclRefExpr understands parameter packs now) - Handle the declaration and expansion of parameter packs within a block's parameter list, e.g., ^(Args ...args) { ... }) - Handle instantiation of blocks where the return type was not explicitly specified. (unrelated, but necessary for my tests). Together, these fixes should make blocks and variadic templates work reasonably well together. Note that BlockDeclRefExpr is still broken w.r.t. its computation of type and value dependence, which will still cause problems for blocks in templates. llvm-svn: 123849
* Teach PackExpansionExpr to keep track of the number of pack expansionsDouglas Gregor2011-01-141-5/+6
| | | | | | it will expand to, if known. Propagate this information throughout Sema. llvm-svn: 123470
* Keep track of the number of expansions to be produced from a type packDouglas Gregor2011-01-141-11/+19
| | | | | | | | | | | | | | | | | | | | | | | expansion, when it is known due to the substitution of an out parameter pack. This allows us to properly handle substitution into pack expansions that involve multiple parameter packs at different template parameter levels, even when this substitution happens one level at a time (as with partial specializations of member class templates and the signatures of member function templates). Note that the diagnostic we provide when there is an arity mismatch between an outer parameter pack and an inner parameter pack in this case isn't as clear as the normal diagnostic for an arity mismatch. However, this doesn't matter because these cases are very, very rare and (even then) only typically occur in a SFINAE context. The other kinds of pack expansions (expression, template, etc.) still need to support optional tracking of the number of expansions, and we need the moral equivalent of SubstTemplateTypeParmPackType for substituted argument packs of template template and non-type template parameters. llvm-svn: 123448
* Start implementing support for substitution into pack expansions thatDouglas Gregor2011-01-141-0/+4
| | | | | | | | | | | | | | | | | involve template parameter packs at multiple template levels that occur within the signatures members of class templates (and partial specializations thereof). This is a work-in-progress that is deficient in several ways, notably: - It only works for template type parameter packs, but we need to also support non-type template parameter packs and template template parameter packs. - It doesn't keep track of the lengths of the substituted argument packs in the expansion, so it can't properly diagnose length mismatches. However, this is a concrete step in the right direction. llvm-svn: 123425
* Teach TreeTransform how to transform a pack expansion type intoDouglas Gregor2011-01-121-10/+21
| | | | | | | | | another pack expansion type. This can happen when rebuilding types in the current instantiation. Fixes <rdar://problem/8848837> (Clang crashing on libc++ <functional>). llvm-svn: 123316
* When mapping from a function parameter pack to the set of functionDouglas Gregor2011-01-111-0/+44
| | | | | | | | | parameters it expanded to, map exactly the number of function parameters that were expanded rather than just running to the end of the instantiated parameter list. This finishes the implementation of the last sentence of C++0x [temp.deduct.call]p1. llvm-svn: 123213
* Work-in-progress implementation of C++0x [temp.arg.explicit]p9, whichDouglas Gregor2011-01-101-14/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | allows an argument pack determines via explicit specification of function template arguments to be extended by further, deduced arguments. For example: template<class ... Types> void f(Types ... values); void g() { f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int } There are a number of FIXMEs in here that indicate places where we need to implement + test retained expansions, plus a number of other places in deduction where we need to correctly cope with the explicitly-specified arguments when deducing an argument pack. Furthermore, it appears that the RecursiveASTVisitor needs to be auditied; it's missing some traversals (especially w.r.t. template arguments) that cause it not to find unexpanded parameter packs when it should. The good news, however, is that the tr1::tuple implementation now works fully, and the tr1::bind example (both from N2080) is actually working now. llvm-svn: 123163
* Implement substitution of a function parameter pack for its set ofDouglas Gregor2011-01-071-19/+39
| | | | | | | | | | | | | | | | | | | | | | | | instantiated function parameters, enabling instantiation of arbitrary pack expansions involving function parameter packs. At this point, we can now correctly compile a simple, variadic print() example: #include <iostream> #include <string> void print() {} template<typename Head, typename ...Tail> void print(const Head &head, const Tail &...tail) { std::cout << head; print(tail...); } int main() { std::string hello = "Hello"; print(hello, ", world!", " ", 2011, '\n'); } llvm-svn: 123000
* Add Decl::isParameterPack(), which covers both function and templateDouglas Gregor2011-01-051-4/+2
| | | | | | | | parameter packs, along with ParmVarDecl::isParameterPack(), which looks for function parameter packs. Use these routines to fix some obvious FIXMEs. llvm-svn: 122904
* Add semantic analysis for the creation of and an AST representationDouglas Gregor2011-01-051-2/+26
| | | | | | | | | | | | | | | | | | | | | for template template argument pack expansions. This allows fun such as: template<template<class> class ...> struct apply_impl { /*...*/ }; template<template<class> class ...Metafunctions> struct apply { typedef typename apply_impl<Metafunctions...>::type type; }; However, neither template argument deduction nor template instantiation is implemented for template template argument packs, so this functionality isn't useful yet. I'll probably replace the encoding of template template argument pack expansions in TemplateArgument so that it's harder to accidentally forget about the expansion. However, this is a step in the right general direction. llvm-svn: 122890
* Implement support for template template parameter packs, e.g.,Douglas Gregor2011-01-051-2/+10
| | | | | | | template<template<class> class ...Metafunctions> struct apply_to_each; llvm-svn: 122874
* Implement the sizeof...(pack) expression to compute the length of aDouglas Gregor2011-01-041-0/+69
| | | | | | | | | parameter pack. Note that we're missing proper libclang support for the new SizeOfPackExpr expression node. llvm-svn: 122813
* Implement pack expansions whose pattern is a base-specifier.Douglas Gregor2011-01-031-0/+5
| | | | llvm-svn: 122782
* Properly rebuild pack expansions whose pattern is a non-type templateDouglas Gregor2011-01-031-1/+2
| | | | | | | argument. As part of this, be more careful when determining if there are any parameter packs that cannot be expanded. llvm-svn: 122776
* Diagnose the presence of unexpanded parameter packs within classDouglas Gregor2011-01-031-0/+14
| | | | | | template partial specialization arguments. llvm-svn: 122769
* Implement support for pack expansions whose pattern is a non-typeDouglas Gregor2011-01-031-10/+28
| | | | | | | | | | | | | | | | | template argument (described by an expression, of course). For example: template<int...> struct int_tuple { }; template<int ...Values> struct square { typedef int_tuple<(Values*Values)...> type; }; It also lays the foundation for pack expansions in an initializer-list. llvm-svn: 122751
* When instantiating a non-type template parameter pack, be sure toDouglas Gregor2010-12-241-1/+1
| | | | | | | | extract the appropriate argument from the argument pack (based on the current substitution index, of course). Simple instantiation of pack expansions involving non-type template parameter packs now works. llvm-svn: 122532
* Add an AST representation for non-type template parameterDouglas Gregor2010-12-231-4/+17
| | | | | | | | | | | | | | packs, e.g., template<typename T, unsigned ...Dims> struct multi_array; along with semantic analysis support for finding unexpanded non-type template parameter packs in types, expressions, and so on. Template instantiation involving non-type template parameter packs probably doesn't work yet. That'll come soon. llvm-svn: 122527
* Implement parsing of function parameter packs and non-type templateDouglas Gregor2010-12-231-0/+69
| | | | | | | | | | | | parameter packs (C++0x [dcl.fct]p13), including disambiguation between unnamed function parameter packs and varargs (C++0x [dcl.fct]p14) for cases like void f(T...) where T may or may not contain unexpanded parameter packs. llvm-svn: 122520
* Implement template argument deduction for pack expansions whoseDouglas Gregor2010-12-221-0/+6
| | | | | | | | | | | pattern is a template argument, which involves repeatedly deducing template arguments using the pattern of the pack expansion, then bundling the resulting deductions into an argument pack. We can now handle a variety of simple list-handling metaprograms using variadic templates. See, e.g., the new "count" metaprogram. llvm-svn: 122439
* Implement instantiation of pack expansions whose pattern is a type-idDouglas Gregor2010-12-211-0/+80
| | | | | | in an exception specification. llvm-svn: 122297
* Give the RecursiveASTVisitor a configuration functionDouglas Gregor2010-12-201-0/+2
| | | | | | | | | | | 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
* Implement basic support for template instantiation of pack expansionsDouglas Gregor2010-12-201-14/+25
| | | | | | | | | | | | | | | | | 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
* Introduce a new type, PackExpansionType, to capture types that areDouglas Gregor2010-12-201-0/+60
| | | | | | | | | | | | | | | | | | | | 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
* Tweak a commentDouglas Gregor2010-12-161-1/+1
| | | | llvm-svn: 121979
* Check for unexpanded parameter packs in default arguments.Douglas Gregor2010-12-161-0/+16
| | | | llvm-svn: 121962
* Fix a regression I caused in r121930. It turns out thatDouglas Gregor2010-12-161-3/+7
| | | | | | | DeclarationNameInfo instances don't always have a non-NULL TypeSourceInfo? llvm-svn: 121940
* Check for unexpanded parameter packs in using declarations. As aDouglas Gregor2010-12-161-1/+51
| | | | | | | drive-by, make sure to check for unexpanded parameter packs within the name of a declaration. llvm-svn: 121930
* Test that all of the relevant types properly compute the "containsDouglas Gregor2010-12-151-3/+8
| | | | | | | unexpanded parameter pack" bit and that the recursive AST visitor can then find those unexpanded parameter packs. llvm-svn: 121899
* Introduce a RecursiveASTVisitor subclass that finds all unexpandedDouglas Gregor2010-12-151-6/+141
| | | | | | | | | | | | | | | | 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
* Move the work-in-progress implementation of variadic templates to its own ↵Douglas Gregor2010-12-151-0/+46
file in Sema. No functionality change. llvm-svn: 121869
OpenPOWER on IntegriCloud