summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* First step toward fixing <rdar://problem/6613046> refactor clang objc type ↵Steve Naroff2009-06-171-7/+7
| | | | | | | | | | | | representation. Add a type (ObjCObjectPointerType) and remove a type (ObjCQualifiedIdType). This large/tedious patch is just a first step. Next step is to remove ObjCQualifiedInterfaceType. After that, I will remove the magic TypedefType for 'id' (installed by Sema). This work will enable various simplifications throughout clang (when dealing with ObjC types). No functionality change. llvm-svn: 73649
* Support dependent extended vector types and template instantiationDouglas Gregor2009-06-171-0/+26
| | | | | | thereof. Patch by Anders Johnsen! llvm-svn: 73641
* Keep track of whether a type parameter type is a parameter pack.Anders Carlsson2009-06-161-0/+1
| | | | llvm-svn: 73452
* Add a new 'Pack' argument kind to TemplateArgument. This is not yet used.Anders Carlsson2009-06-151-0/+4
| | | | llvm-svn: 73391
* Update LLVM.Douglas Gregor2009-06-141-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | Implement support for C++ Substitution Failure Is Not An Error (SFINAE), which says that errors that occur during template argument deduction do *not* produce diagnostics and do not necessarily make a program ill-formed. Instead, template argument deduction silently fails. This is currently implemented for template argument deduction during matching of class template partial specializations, although the mechanism will also apply to template argument deduction for function templates. The scheme is simple: - If we are in a template argument deduction context, any diagnostic that is considered a SFINAE error (or warning) will be suppressed. The error will be propagated up the call stack via the normal means. - By default, all warnings and errors are SFINAE errors. Add the NoSFINAE class to a diagnostic in the .td file to make it a hard error (e.g., for access-control violations). Note that, to make this fully work, every place in Sema that emits an error *and then immediately recovers* will need to check Sema::isSFINAEContext() to determine whether it must immediately return an error rather than recovering. llvm-svn: 73332
* Fix for PR4382: allow instantiating dependent nested name specifiers. Eli Friedman2009-06-131-1/+1
| | | | | | | | I'm not completely sure this is the right way to fix this issue, but it seems reasonable, and it's consistent with the non-template code for this construct. llvm-svn: 73285
* Address comments from Doug - Add a Sema::SemaRef.BuildBlockPointerType and ↵Anders Carlsson2009-06-121-3/+1
| | | | | | use it. llvm-svn: 73264
* It looks like we've finished off matching of class template partial ↵Douglas Gregor2009-06-121-5/+23
| | | | | | specializations; add comments and update the C++ status page llvm-svn: 73263
* Finish implementing checking of class template partial specializationsDouglas Gregor2009-06-121-2/+5
| | | | llvm-svn: 73260
* Improve template argument deduction to keep track of why templateDouglas Gregor2009-06-121-3/+10
| | | | | | | | | | | | | | | | argument deduction failed. For example, given template<typename T> struct is_same<T, T> { ... }; template argument deduction will fail for is_same<int, float>, and now reports enough information Right now, we don't do anything with this extra information, but it can be used for informative diagnostics that say, e.g., "template argument deduction failed because T was deduced to 'int' in one context and 'float' in another". llvm-svn: 73237
* Deducation and instantiation of block types.Anders Carlsson2009-06-121-3/+7
| | | | llvm-svn: 73232
* Once we have deduced the template arguments of a class templateDouglas Gregor2009-06-111-9/+3
| | | | | | | | | | | | partial specialization, substitute those template arguments back into the template arguments of the class template partial specialization to see if the results still match the original template arguments. This code is more general than it needs to be, since we don't yet diagnose C++ [temp.class.spec]p9. However, it's likely to be needed for function templates. llvm-svn: 73196
* Separate TemplateArgument instantiation logic into its own function. No ↵Douglas Gregor2009-06-111-30/+39
| | | | | | functionality change. llvm-svn: 73176
* Template argument deduction for member pointers.Douglas Gregor2009-06-101-0/+44
| | | | | | | Also, introduced some of the framework for performing instantiation as part of template argument deduction. llvm-svn: 73175
* Handle member pointer types with dependent class types (e.g., intDouglas Gregor2009-06-091-3/+10
| | | | | | T::*) and implement template instantiation for member pointer types. llvm-svn: 73151
* Several improvements to template argument deduction:Douglas Gregor2009-06-051-10/+20
| | | | | | | | | | | | | | - Once we have deduced template arguments for a class template partial specialization, we use exactly those template arguments for instantiating the definition of the class template partial specialization. - Added template argument deduction for non-type template parameters. - Added template argument deduction for dependently-sized array types. With these changes, we can now implement, e.g., the remove_reference type trait. Also, Daniel's Ackermann template metaprogram now compiles properly. llvm-svn: 72909
* When performing template argument deduction, ensure that multipleDouglas Gregor2009-06-041-0/+4
| | | | | | | | | | deductions of the same template parameter are equivalent. This allows us to implement the is_same type trait (!). Also, move template argument deduction into its own file and update a few build systems with this change (grrrr). llvm-svn: 72819
* Initial infrastructure for class template partial specialization. HereDouglas Gregor2009-05-311-8/+27
| | | | | | | | | | | | | we have the basics of declaring and storing class template partial specializations, matching class template partial specializations at instantiation time via (limited) template argument deduction, and using the class template partial specialization's pattern for instantiation. This patch is enough to make a simple is_pointer type trait work, but not much else. llvm-svn: 72662
* Create a new PrintingPolicy class, which we pass down through the ASTDouglas Gregor2009-05-291-1/+2
| | | | | | | | | printing logic to help customize the output. For now, we use this rather than a special flag to suppress the "struct" when printing "struct X" and to print the Boolean type as "bool" in C++ but "_Bool" in C. llvm-svn: 72590
* Reduce the amount of stack space we use in SmallVectors duringDouglas Gregor2009-05-291-4/+4
| | | | | | | template instantiation. This helps reduce our stack footprint when performing deep template instantiations. llvm-svn: 72582
* Simplify, and improve the performance of, template instantiation forDouglas Gregor2009-05-271-6/+4
| | | | | | | | | | | declaration references. The key realization is that dependent Decls, which actually require instantiation, can only refer to the current instantiation or members thereof. And, since the current context during instantiation contains all of those members of the current instantiation, we can simply find the real instantiate that matches up with the "current instantiation" template. llvm-svn: 72486
* Initial stab at a generalized operation for determining theDouglas Gregor2009-05-271-9/+21
| | | | | | | | | | | | instantiation of a declaration from the template version (or version that lives in a template) and a given set of template arguments. This needs much, much more testing, but it suffices for simple examples like typedef T* iterator; iterator begin(); llvm-svn: 72461
* Template instantiation for "typeof" for both types and expressions.Douglas Gregor2009-05-261-6/+11
| | | | llvm-svn: 72440
* Make sure that CodeGen sees template instantiations.Douglas Gregor2009-05-261-0/+4
| | | | llvm-svn: 72433
* Use v.data() instead of &v[0] when SmallVector v might be empty.Jay Foad2009-05-211-2/+2
| | | | llvm-svn: 72210
* When instantiating the definition of a member function of a classDouglas Gregor2009-05-181-14/+28
| | | | | | | | | | | | | | template, introduce that member function into the template instantiation stack. Also, add diagnostics showing the member function within the instantiation stack and clean up the qualified-name printing so that we get something like: note: in instantiation of member function 'Switch1<int, 2, 2>::f' requested here in the template instantiation backtrace. llvm-svn: 72015
* Reflow some comments.Mike Stump2009-05-161-14/+10
| | | | llvm-svn: 71936
* Introduce basic support for instantiating the definitions of memberDouglas Gregor2009-05-141-0/+20
| | | | | | | functions of class templates. Only compound statements and expression statements are currently implemented. llvm-svn: 71814
* Implement explicit instantiations of member classes of class templates, e.g.,Douglas Gregor2009-05-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | template<typename T> struct X { struct Inner; }; template struct X<int>::Inner; This change is larger than it looks because it also fixes some a problem with nested-name-specifiers and tags. We weren't requiring the DeclContext associated with the scope specifier of a tag to be complete. Therefore, when looking for something like "struct X<int>::Inner", we weren't instantiating X<int>. This, naturally, uncovered a problem with member pointers, where we were requiring the left-hand side of a member pointer access expression (e.g., x->*) to be a complete type. However, this is wrong: the semantics of this expression does not require a complete type (EDG agrees). Stuart vouched for me. Blame him. llvm-svn: 71756
* Explicit instantiations of templates now instantiate the definitionsDouglas Gregor2009-05-131-0/+51
| | | | | | | | of class members (recursively). Only member classes are actually instantiated; the instantiation logic for member functions and variables are just stubs. llvm-svn: 71713
* Improve the semantic checking for explicit instantiations ofDouglas Gregor2009-05-131-4/+20
| | | | | | | | | | | | | | | | templates. In particular: - An explicit instantiation can follow an implicit instantiation (we were improperly diagnosing this as an error, previously). - In C++0x, an explicit instantiation that follows an explicit specialization of the same template specialization is ignored. In C++98, we just emit an extension warning. - In C++0x, an explicit instantiation must be in a namespace enclosing the original template. C++98 has no such requirement. Also, fixed a longstanding FIXME regarding the integral type that is used for the size of a constant array type when it is being instantiated. llvm-svn: 71689
* Semantic analysis for explicit instantiation of class templates. WeDouglas Gregor2009-05-131-4/+6
| | | | | | | | still aren't instantiating the definitions of class template members, and core issues 275 and 259 will both affect the checking that we do for explicit instantiations (but are not yet implemented). llvm-svn: 71613
* Encapsulate template arguments lists in a new class,Douglas Gregor2009-05-111-45/+22
| | | | | | | | TemplateArgumentList. This avoids the need to pass around pointer/length pairs of template arguments lists, and will eventually make it easier to introduce member templates and variadic templates. llvm-svn: 71517
* Replace more release+static_cast with takeAs.Anders Carlsson2009-05-011-1/+1
| | | | llvm-svn: 70567
* Replace a bunch of static_cast + release with takeAs.Anders Carlsson2009-05-011-1/+1
| | | | llvm-svn: 70566
* ObjCQualifiedClass is dead, remove it.Chris Lattner2009-04-221-8/+0
| | | | llvm-svn: 69783
* Propagate the ASTContext to various AST traversal and lookup functions.Douglas Gregor2009-04-091-2/+3
| | | | | | No functionality change (really). llvm-svn: 68726
* Parsing, semantic analysis, and template instantiation for typenameDouglas Gregor2009-04-011-10/+24
| | | | | | | | | | | | | specifiers that terminate in a simple-template-id, e.g., typename MetaFun::template apply<T1, T2> Also, implement template instantiation for dependent nested-name-specifiers that involve unresolved identifiers, e.g., typename T::type::type llvm-svn: 68166
* Some cleanup and renaming. No functionality changeDouglas Gregor2009-03-311-3/+2
| | | | llvm-svn: 68140
* Implement template instantiation for template names, including bothDouglas Gregor2009-03-311-4/+76
| | | | | | | | | | | template template parameters and dependent template names. For example, the oft-mentioned typename MetaFun::template apply<T1, T2>::type can now be instantiated, with the appropriate name lookup for "apply". llvm-svn: 68128
* Parsing and AST representation for dependent template names that occurDouglas Gregor2009-03-311-1/+1
| | | | | | | | | | | within nested-name-specifiers, e.g., for the "apply" in typename MetaFun::template apply<T1, T2>::type At present, we can't instantiate these nested-name-specifiers, so our testing is sketchy. llvm-svn: 68081
* Improve the representation of template names in the AST. ThisDouglas Gregor2009-03-301-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | representation handles the various ways in which one can name a template, including unqualified references ("vector"), qualified references ("std::vector"), and dependent template names ("MetaFun::template apply"). One immediate effect of this change is that the representation of nested-name-specifiers in type names for class template specializations (e.g., std::vector<int>) is more accurate. Rather than representing std::vector<int> as std::(vector<int>) we represent it as (std::vector)<int> which more closely follows the C++ grammar. Additionally, templates are no longer represented as declarations (DeclPtrTy) in Parse-Sema interactions. Instead, I've introduced a new OpaquePtr type (TemplateTy) that holds the representation of a TemplateName. This will simplify the handling of dependent template-names, once we get there. llvm-svn: 68074
* Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for aChris Lattner2009-03-281-5/+4
| | | | | | | | | | | | | | | | | | | | pointer. Its purpose in life is to be a glorified void*, but which does not implicitly convert to void* or other OpaquePtr's with a different UID. Introduce Action::DeclPtrTy which is a typedef for OpaquePtr<0>. Change the entire parser/sema interface to use DeclPtrTy instead of DeclTy*. This makes the C++ compiler enforce that these aren't convertible to other opaque types. We should also convert ExprTy, StmtTy, TypeTy, AttrTy, BaseTy, etc, but I don't plan to do that in the short term. The one outstanding known problem with this patch is that we lose the bitmangling optimization where ActionResult<DeclPtrTy> doesn't know how to bitmangle the success bit into the low bit of DeclPtrTy. I will rectify this with a subsequent patch. llvm-svn: 67952
* Initial implementation of parsing, semantic analysis, and templateDouglas Gregor2009-03-271-9/+32
| | | | | | | | | | | | | | | | | | | | | | | | instantiation for C++ typename-specifiers such as typename T::type The parsing of typename-specifiers is relatively easy thanks to annotation tokens. When we see the "typename", we parse the typename-specifier and produce a typename annotation token. There are only a few places where we need to handle this. We currently parse the typename-specifier form that terminates in an identifier, but not the simple-template-id form, e.g., typename T::template apply<U, V> Parsing of nested-name-specifiers has a similar problem, since at this point we don't have any representation of a class template specialization whose template-name is unknown. Semantic analysis is only partially complete, with some support for template instantiation that works for simple examples. llvm-svn: 67875
* Revamp our representation of C++ nested-name-specifiers. We now have aDouglas Gregor2009-03-261-27/+46
| | | | | | | | | | | uniqued representation that should both save some memory and make it far easier to properly build canonical types for types involving dependent nested-name-specifiers, e.g., "typename T::Nested::type". This approach will greatly simplify the representation of CXXScopeSpec. That'll be next. llvm-svn: 67799
* Fix notes regarding the instantiation of member classes (and test 'em).Douglas Gregor2009-03-251-2/+1
| | | | llvm-svn: 67708
* Instantiation for member classes of class templates. Note that onlyDouglas Gregor2009-03-251-66/+103
| | | | | | | | | | | the declarations of member classes are instantiated when the owning class template is instantiated. The definitions of such member classes are instantiated when a complete type is required. This change also introduces the injected-class-name into a class template specialization. llvm-svn: 67707
* Move template instantiation for expressions into a separate fileDouglas Gregor2009-03-251-401/+0
| | | | llvm-svn: 67660
* Eliminate post-diagnostic hooks. Instead, implement a Sema-specificDouglas Gregor2009-03-201-8/+0
| | | | | | | variant of DiagnosticBuilder that emits the template instantiation backtrace when needed. llvm-svn: 67413
* Introduce a new expression type, UnresolvedDeclRefExpr, that describesDouglas Gregor2009-03-191-2/+55
| | | | | | | | | | | | | | | | | | | | | | | | dependent qualified-ids such as Fibonacci<N - 1>::value where N is a template parameter. These references are "unresolved" because the name is dependent and, therefore, cannot be resolved to a declaration node (as we would do for a DeclRefExpr or QualifiedDeclRefExpr). UnresolvedDeclRefExprs instantiate to DeclRefExprs, QualifiedDeclRefExprs, etc. Also, be a bit more careful about keeping only a single set of specializations for a class template, and instantiating from the definition of that template rather than a previous declaration. In general, we need a better solution for this for all TagDecls, because it's too easy to accidentally look at a declaration that isn't the definition. We can now process a simple Fibonacci computation described as a template metaprogram. llvm-svn: 67308
OpenPOWER on IntegriCloud