summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiate.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Template instantiation for static data members that are defined out-of-line.Douglas Gregor2009-07-241-5/+8
| | | | | | | | Note that this also fixes a bug that affects non-template code, where we were not treating out-of-line static data members are "file-scope" variables, and therefore not checking their initializers. llvm-svn: 77002
* Improve template argument deduction for array types, so that a parameterDouglas Gregor2009-07-221-0/+1
| | | | | | | | | | const T can be matched with, e.g., volatile int [5] llvm-svn: 76773
* Allocate BaseOrMemberInitializers and CXXBaseSpecifier nodesFariborz Jahanian2009-07-221-2/+1
| | | | | | via ASTContext. llvm-svn: 76758
* Remove ObjCQualifiedInterfaceType:-)Steve Naroff2009-07-181-8/+0
| | | | llvm-svn: 76321
* Remove ASTContext::getCanonicalDecl() and use Decl::getCanonicalDecl in its ↵Argyrios Kyrtzidis2009-07-181-1/+1
| | | | | | place. llvm-svn: 76274
* Keep track of the Expr used to describe the size of an array type,Douglas Gregor2009-07-061-4/+20
| | | | | | from Enea Zaffanella! llvm-svn: 74831
* Keep track of more information within the template instantiation stack, e.g.,Douglas Gregor2009-07-011-20/+59
| | | | | | | | | | | | | | by distinguishing between substitution that occurs for template argument deduction vs. explicitly-specifiad template arguments. This is used both to improve diagnostics and to make sure we only provide SFINAE in those cases where SFINAE should apply. In addition, deal with the sticky issue where SFINAE only considers substitution of template arguments into the *type* of a function template; we need to issue hard errors beyond this point, as test/SemaTemplate/operator-template.cpp illustrates. llvm-svn: 74651
* Cope with explicitly-specified function template arguments when thereDouglas Gregor2009-07-011-0/+9
| | | | | | | are fewer template arguments than there are template parameters for that function. llvm-svn: 74578
* De-ASTContext-ify DeclContext.Argyrios Kyrtzidis2009-06-301-4/+4
| | | | | | | Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating". Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit. llvm-svn: 74506
* Remove the ASTContext parameter from the getBody() methods of Decl and ↵Argyrios Kyrtzidis2009-06-301-1/+1
| | | | | | | | subclasses. Timings showed no significant difference before and after the commit. llvm-svn: 74504
* Improvements to decltype. We now don't crash anymore when the expr is an ↵Anders Carlsson2009-06-291-2/+2
| | | | | | overloaded function decl. llvm-svn: 74472
* A little template argument deduction test uncovered an "oops". As partDouglas Gregor2009-06-261-87/+61
| | | | | | | | | | of template instantiation, we were dropping cv-qualifiers on the instantiated type in a few places. This change reshuffles the type-instantiation code a little bit so that there's a single place where we add qualifiers to the instantiated type, so that we won't end up with this same bug in the future. llvm-svn: 74331
* Fix PR4448.Anders Carlsson2009-06-261-0/+5
| | | | llvm-svn: 74257
* Implicit instantiation for function template specializations.Douglas Gregor2009-06-261-2/+13
| | | | | | | | | For a FunctionDecl that has been instantiated due to template argument deduction, we now store the primary template from which it was instantiated and the deduced template arguments. From this information, we can instantiate the body of the function template. llvm-svn: 74232
* Add a DecltypeType type.Anders Carlsson2009-06-241-0/+12
| | | | llvm-svn: 74099
* Rework the way we track which declarations are "used" duringDouglas Gregor2009-06-221-0/+11
| | | | | | | | | | | | | | | | | | | | | compilation, and (hopefully) introduce RAII objects for changing the "potentially evaluated" state at all of the necessary places within Sema and Parser. Other changes: - Set the unevaluated/potentially-evaluated context appropriately during template instantiation. - We now recognize three different states while parsing or instantiating expressions: unevaluated, potentially evaluated, and potentially potentially evaluated (for C++'s typeid). - When we're in a potentially potentially-evaluated context, queue up MarkDeclarationReferenced calls in a stack. For C++ typeid expressions that are potentially evaluated, we will play back these MarkDeclarationReferenced calls when we exit the corresponding potentially potentially-evaluated context. - Non-type template arguments are now parsed as constant expressions, so they are not potentially-evaluated. llvm-svn: 73899
* Some cleanups suggested by ChrisDouglas Gregor2009-06-181-4/+4
| | | | llvm-svn: 73713
* 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
OpenPOWER on IntegriCloud