summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiate.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor the template-instantiation logic for expressions into aDouglas Gregor2009-08-111-8/+112
| | | | | | | generic tree transformation (also used for recanonicalization) and a small amount of template-instantiation-specific logic. llvm-svn: 78645
* Implement transformation of template names within the generic treeDouglas Gregor2009-08-061-69/+16
| | | | | | | | | | | | | | | transform, then use the result for template instantiation. The generic transformation fixes a few issues: - It copes better with template template parameters and member templates (when they're implemented). - The logic used to replace template template parameters with their arguments is now centralized in TransformDecl, so that it will apply for other declaration-instantiation steps. - The error-recovery strategy is normalized now, so that any error results in a NULL TemplateName. llvm-svn: 78292
* Implement transformation of nested-name-specifiers within the generalDouglas Gregor2009-08-061-63/+3
| | | | | | | tree transformation. Template instantiation uses this general transformation rather than implementing its own transformation. llvm-svn: 78286
* Move the template instantiation logic for template arguments into theDouglas Gregor2009-08-041-46/+3
| | | | | | | | | | general tree transformation. Also, implement template instantiation for parameter packs. In addition, introduce logic to enter the appropriate context for subexpressions that are not potentially evaluated. llvm-svn: 78114
* Refactor template instantiation for types into a generic treeDouglas Gregor2009-08-041-442/+71
| | | | | | | | | transformation template (TreeTransform) that handles the transformation and reconstruction of AST nodes. Template instantiation for types is a (relatively small) customization of the generic tree transformation. llvm-svn: 78071
* Keep track of the template arguments deduced when matching a classDouglas Gregor2009-08-021-2/+3
| | | | | | | | template partial specialization. Then, use those template arguments when instantiating members of that class template partial specialization. Fixes PR4607. llvm-svn: 77925
* 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
OpenPOWER on IntegriCloud