summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Instantiate unresolved using declarations.Anders Carlsson2009-08-281-1/+20
| | | | llvm-svn: 80366
* Omnibus friend decl refactoring. Instead of cloning AST classes for friendJohn McCall2009-08-281-55/+64
| | | | | | | | | | | | | | declarations of same, introduce a single AST class and add appropriate bits (encoded in the namespace) for whether a decl is "real" or not. Much hackery about previously-declared / not-previously-declared, but it's essentially mandated by the standard that friends alter lookup, and this is at least fairly non-intrusive. Refactor the Sema methods specific to friends for cleaner flow and less nesting. Incidentally solve a few bugs, but I remain confident that we can put them back. llvm-svn: 80353
* Fix for PR4794 (instantiating friend class decl); this version shouldn't Eli Friedman2009-08-271-1/+5
| | | | | | cause any regressions. llvm-svn: 80277
* PR4794: Make instantiating friend class decls not crash.Eli Friedman2009-08-271-0/+2
| | | | llvm-svn: 80272
* Implement instantiation of the declarations of member functionDouglas Gregor2009-08-271-9/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | templates within class templates, producing a member function template of a class template specialization. If you can parse that, I'm sorry. Example: template<typename T> struct X { template<typename U> void f(T, U); }; When we instantiate X<int>, we now instantiate the declaration X<int>::f, which looks like this: template<typename U> void X<int>::f(int, U); The path this takes through TemplateDeclInstantiator::VisitCXXMethodDecl is convoluted and ugly, but I don't know how to improve it yet. I'm resting my hopes on the multi-level substitution required to instantiate definitions of nested templates, which may simplify this code as well. More testing to come... llvm-svn: 80252
* Make sure to bump the reference count of the last element in the ↵Douglas Gregor2009-08-261-0/+1
| | | | | | ParenListExpr representing the direct initializer of a declaration llvm-svn: 80177
* Implement support for C++ direct initializers that involve dependentDouglas Gregor2009-08-261-1/+26
| | | | | | types or type-dependent expressions. llvm-svn: 80143
* Clarify the difference between substitution and instantiation by renamingJohn McCall2009-08-251-38/+38
| | | | | | functions that don't instantiate definitions. llvm-svn: 80037
* Basic support for default argument expressions for function templates.Anders Carlsson2009-08-251-10/+4
| | | | llvm-svn: 79972
* Implement conversion function templates, along with the ability to useDouglas Gregor2009-08-211-37/+19
| | | | | | | template argument deduction from a conversion function (C++ [temp.deduct.conv]) with implicit conversions. llvm-svn: 79693
* Refactor instantiation of destructors to use the common CXXMethodDeclDouglas Gregor2009-08-211-34/+13
| | | | | | | | | | | code, fixing a problem where instantiations of out-of-line destructor definitions would had the wrong lexical context. Introduce tests for out-of-line definitions of the constructors, destructors, and conversion functions of a class template partial specialization. llvm-svn: 79682
* Introduce support for constructor templates, which can now be declaredDouglas Gregor2009-08-211-60/+36
| | | | | | | | and will participate in overload resolution. Unify the instantiation of CXXMethodDecls and CXXConstructorDecls, which had already gotten out-of-sync. llvm-svn: 79658
* Remove TypeSpecStartLocation from VarDecl/FunctionDecl/FieldDecl, and use ↵Argyrios Kyrtzidis2009-08-211-3/+2
| | | | | | DeclaratorInfo to get this information. llvm-svn: 79584
* Implement support for calling member function templates, which involves:Douglas Gregor2009-08-211-4/+31
| | | | | | | | | | - Allowing one to name a member function template within a class template and on the right-hand side of a member access expression. - Template argument deduction for calls to member function templates. - Registering specializations of member function templates (and finding them later). llvm-svn: 79581
* Basic nested-template implementation.John McCall2009-08-201-0/+94
| | | | llvm-svn: 79504
* Introduce DeclaratorDecl and pass DeclaratorInfo through the Decl/Sema ↵Argyrios Kyrtzidis2009-08-191-13/+17
| | | | | | | | | | | | interfaces. DeclaratorDecl contains a DeclaratorInfo* to keep type source info. Subclasses of DeclaratorDecl are FieldDecl, FunctionDecl, and VarDecl. EnumConstantDecl still inherits from ValueDecl since it has no need for DeclaratorInfo. Decl/Sema interfaces accept a DeclaratorInfo as parameter but no DeclaratorInfo is created yet. llvm-svn: 79392
* Implement __is_empty. Patch by Sean Hunt.Eli Friedman2009-08-151-0/+1
| | | | llvm-svn: 79143
* Support friend declarations in templates and test that argdep lookupJohn McCall2009-08-141-6/+56
| | | | | | still works. llvm-svn: 78979
* Patch should implement packed enums - PR4098. Credit to Anders Johnsen.Edward O'Callaghan2009-08-081-1/+3
| | | | llvm-svn: 78471
* Introduce reference counting for statements and expressions, using itDouglas Gregor2009-08-081-1/+2
| | | | | | | to allow sharing of nodes. Simplifies some aspects of template instantiation, and fixes both PR3444 and <rdar://problem/6757457>. llvm-svn: 78450
* Introduce the canonical type smart pointers, and use them in a few places toDouglas Gregor2009-08-051-2/+2
| | | | | | tighten up the static type system. llvm-svn: 78164
* Canonicalize else.Mike Stump2009-08-041-5/+4
| | | | llvm-svn: 78102
* Use the new statement/expression profiling code to unique dependentDouglas Gregor2009-07-291-1/+2
| | | | | | | | template arguments, as in template specialization types. This permits matching out-of-line definitions of members for class templates that involve non-type template parameters. llvm-svn: 77462
* When instantiating a variable without an initializer, callDouglas Gregor2009-07-271-3/+2
| | | | | | ActOnUninitializedDecl. llvm-svn: 77211
* Template instantiation for static data members that are defined out-of-line.Douglas Gregor2009-07-241-7/+135
| | | | | | | | 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
* Add the location of the tag keyword into TagDecl. From EneaDouglas Gregor2009-07-211-1/+3
| | | | | | Zaffanella, with tweaks from Abramo Bagnara. llvm-svn: 76576
* Remove ASTContext::getCanonicalDecl() and use Decl::getCanonicalDecl in its ↵Argyrios Kyrtzidis2009-07-181-8/+8
| | | | | | place. llvm-svn: 76274
* Fix unused variable warnings (with -Asserts)Daniel Dunbar2009-07-161-0/+1
| | | | llvm-svn: 76112
* Add a "TypeSpecStartLoc" to FieldDecl. Patch contributed by Enea Zaffanella.Steve Naroff2009-07-141-0/+1
| | | | | Note: One day, it might be useful to consider adding this info to DeclGroup (as the comments in FunctionDecl/VarDecl suggest). For now, I think this works fine. I considered moving this to ValueDecl (a common ancestor of FunctionDecl/VarDecl/FieldDecl), however this would add overhead to EnumConstantDecl (which would burn memory and isn't necessary). llvm-svn: 75635
* Keep track of more information within the template instantiation stack, e.g.,Douglas Gregor2009-07-011-0/+22
| | | | | | | | | | | | | | 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
* When recursively instantiating function templates, keep track of theDouglas Gregor2009-06-301-4/+29
| | | | | | | | | | | | instantiation stack so that we provide a full instantiation backtrace. Previously, we performed all of the instantiations implied by the recursion, but each looked like a "top-level" instantiation. The included test case tests the previous fix for the instantiation of DeclRefExprs. Note that the "instantiated from" diagnostics still don't tell us which template arguments we're instantiating with. llvm-svn: 74540
* Refactor ActOnDeclarationNameExpr into a "parsing action" part and aDouglas Gregor2009-06-301-1/+1
| | | | | | | | | | | "semantic analysis" part. Use the "semantic analysis" part when performing template instantiation on a DeclRefExpr, rather than an ad hoc list of rules to construct DeclRefExprs from the instantiation. A test case for this change will come in with a large commit, which illustrates what I was actually trying to work on. llvm-svn: 74528
* De-ASTContext-ify DeclContext.Argyrios Kyrtzidis2009-06-301-16/+15
| | | | | | | 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-3/+3
| | | | | | | | subclasses. Timings showed no significant difference before and after the commit. llvm-svn: 74504
* Keep track of function template specializations, to eliminateDouglas Gregor2009-06-291-4/+26
| | | | | | | redundant, implicit instantiations of function templates and provide a place where we can hang function template specializations. llvm-svn: 74454
* Implicit instantiation for function template specializations.Douglas Gregor2009-06-261-4/+5
| | | | | | | | | 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
* Improved semantic analysis and AST respresentation for functionDouglas Gregor2009-06-251-6/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | templates. For example, this now type-checks (but does not instantiate the body of deref<int>): template<typename T> T& deref(T* t) { return *t; } void test(int *ip) { int &ir = deref(ip); } Specific changes/additions: * Template argument deduction from a call to a function template. * Instantiation of a function template specializations (just the declarations) from the template arguments deduced from a call. * FunctionTemplateDecls are stored directly in declaration contexts and found via name lookup (all forms), rather than finding the FunctionDecl and then realizing it is a template. This is responsible for most of the churn, since some of the core declaration matching and lookup code assumes that all functions are FunctionDecls. llvm-svn: 74213
* Implement implicit instantiation of the member functions of a class templateDouglas Gregor2009-06-221-0/+17
| | | | | | | specialization. At present, all implicit instantiations occur at the end of the translation unit. llvm-svn: 73915
* Rework the way we track which declarations are "used" duringDouglas Gregor2009-06-221-1/+12
| | | | | | | | | | | | | | | | | | | | | 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
* Reduce the amount of stack space we use in SmallVectors duringDouglas Gregor2009-05-291-6/+6
| | | | | | | template instantiation. This helps reduce our stack footprint when performing deep template instantiations. llvm-svn: 72582
* Now that we have declared/defined tag types within DeclGroups,Douglas Gregor2009-05-291-6/+0
| | | | | | | | | | | | | instantiation of tags local to member functions of class templates (and, eventually, function templates) works when the tag is defined as part of the decl-specifier-seq, e.g., struct S { T x, y; } s1; Also, make sure that we don't try to default-initialize a dependent type. llvm-svn: 72568
* Introduced DeclContext::isDependentContext, which determines whether aDouglas Gregor2009-05-281-0/+7
| | | | | | | | | | | | | | | | | | | given DeclContext is dependent on type parameters. Use this to properly determine whether a TagDecl is dependent; previously, we were missing the case where the TagDecl is a local class of a member function of a class template (phew!). Also, make sure that, when we instantiate declarations within a member function of a class template (or a function template, eventually), that we add those declarations to the "instantiated locals" map so that they can be found when instantiating declaration references. Unfortunately, I was not able to write a useful test for this change, although the assert() that fires when uncommenting the FIXME'd line in test/SemaTemplate/instantiate-declref.cpp tells the "experienced user" that we're now doing the right thing. llvm-svn: 72526
* Simplify, and improve the performance of, template instantiation forDouglas Gregor2009-05-271-20/+26
| | | | | | | | | | | 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
* Enumeration declarations that were instantiated from an enumerationDouglas Gregor2009-05-271-1/+4
| | | | | | | | within a template now have a link back to the enumeration from which they were instantiated. This means that we can now find the instantiation of an anonymous enumeration. llvm-svn: 72482
* Improve name lookup for and template instantiation of declarationDouglas Gregor2009-05-271-8/+6
| | | | | | | | | | | | | | | | | | | | | | | references. There are several smallish fixes here: - Make sure we look through template parameter scope when determining whether we're parsing a nested class (or nested class *template*). This makes sure that we delay parsing the bodies of inline member functions until after we're out of the outermost class (template) scope. - Since the bodies of member functions are always parsed "out-of-line", even when they were declared in-line, teach unqualified name lookup to look into the (semantic) parents. - Use the new InstantiateDeclRef to handle the instantiation of a reference to a declaration (in DeclRefExpr), which drastically simplifies template instantiation for DeclRefExprs. - When we're instantiating a ParmVarDecl, it must be in the current instantiation scope, so only look there. Also, remove the #if 0's and FIXME's from the dynarray example, which now compiles and executes thanks to Anders and Eli. llvm-svn: 72481
* Initial stab at a generalized operation for determining theDouglas Gregor2009-05-271-0/+122
| | | | | | | | | | | | 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
* 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-3/+3
| | | | llvm-svn: 72210
* Template instantiation for C++ try/catch statements.Douglas Gregor2009-05-181-0/+2
| | | | llvm-svn: 72035
* When instantiating the definition of a member function of a classDouglas Gregor2009-05-181-2/+5
| | | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud