summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Refactor the way we handle operator overloading and templateDouglas Gregor2009-03-131-8/+55
| | | | | | | | | | | | | | | | | | | | | | | | | instantiation for binary operators. This change moves most of the operator-overloading code from the parser action ActOnBinOp to a new, parser-independent semantic checking routine CreateOverloadedBinOp. Of particular importance is the fact that CreateOverloadedBinOp does *not* perform any name lookup based on the current parsing context (it doesn't take a Scope*), since it has to be usable during template instantiation, when there is no scope information. Rather, it takes a pre-computed set of functions that are visible from the context or via argument-dependent lookup, and adds to that set any member operators and built-in operator candidates. The set of functions is computed in the parser action ActOnBinOp based on the current context (both operator name lookup and argument-dependent lookup). Within a template, the set computed by ActOnBinOp is saved within the type-dependent AST node and is augmented with the results of argument-dependent name lookup at instantiation time (see TemplateExprInstantiator::VisitCXXOperatorCallExpr). Sadly, we can't fully test this yet. I'll follow up with template instantiation for sizeof so that the real fun can begin. llvm-svn: 66923
* Improve the representation of operator expressions like "x + y" withinDouglas Gregor2009-03-131-0/+27
| | | | | | | | | | | | | | | | C++ templates. In particular, keep track of the overloaded operators that are visible from the template definition, so that they can be merged with those operators visible via argument-dependent lookup at instantiation time. Refactored the lookup routines for argument-dependent lookup and for operator name lookup, so they can be called without immediately adding the results to an overload set. Instantiation of these expressions is completely wrong. I'll work on that next. llvm-svn: 66851
* Implement template instantiation for builtin binary operatorsDouglas Gregor2009-03-121-1/+28
| | | | llvm-svn: 66835
* Store the type of the integral value within a TemplateArgument, so that we ↵Douglas Gregor2009-03-121-12/+4
| | | | | | can more efficiently reconstruct an IntegerLiteral from it during template instantiation llvm-svn: 66833
* Use StmtVisitor to handle the decoding of expressions forDouglas Gregor2009-03-121-36/+75
| | | | | | | instantiation. This is roughly the structure we want to expression instantiation. llvm-svn: 66816
* Straw man for instantiation of expressions. Use it to instantiate theDouglas Gregor2009-03-121-1/+66
| | | | | | | | | width of bitfields. I'll be burning this down and replacing it with a properly-dispatched implementation like the one used for types. llvm-svn: 66796
* Make sure that we set the access specifier for an instantiated FieldDecl, ↵Douglas Gregor2009-03-111-0/+1
| | | | | | and that the aggregate and POD flags for an instantiated class template are updated based on instantiation of a FieldDecl llvm-svn: 66701
* Implement basic template instantiation for fields. Reshuffle checkingDouglas Gregor2009-03-111-7/+42
| | | | | | | for FieldDecls so that the parser and the template instantiation make use of the same semantic checking module. llvm-svn: 66685
* Add basic, hackish support for instantiation of typedefs in a classDouglas Gregor2009-03-111-2/+33
| | | | | | | | | template. More importantly, start to sort out the issues regarding complete types and nested-name-specifiers, especially the question of: when do we instantiate a class template specialization that occurs to the left of a '::' in a nested-name-specifier? llvm-svn: 66662
* Extend the notion of active template instantiations to include theDouglas Gregor2009-03-101-16/+75
| | | | | | | | | | | | context of a template-id for which we need to instantiate default template arguments. In the TextDiagnosticPrinter, don't suppress the caret diagnostic if we are producing a non-note diagnostic that follows a note diagnostic with the same location, because notes are (conceptually) a part of the warning or error that comes before them. llvm-svn: 66572
* If we run into multiple errors within the same template instantiation,Douglas Gregor2009-03-101-3/+7
| | | | | | | | | only print the template instantiation backtrace for the first error. Also, if a base class has failed to type-check during instantiation, just drop that base class and continue on to check other base classes. llvm-svn: 66563
* Add a notion of "post-diagnostic hooks", which are callbacks attachedDouglas Gregor2009-03-101-0/+24
| | | | | | | | | | | | | | | | | to a diagnostic that will be invoked after the diagnostic (if it is not suppressed). The hooks are allowed to produce additional diagnostics (typically notes) that provide more information. We should be able to use this to help diagnostic clients link notes back to the diagnostic they clarify. Comments welcome; I'll write up documentation and convert other clients (e.g., overload resolution failures) if there are no screams of protest. As the first client of post-diagnostic hooks, we now produce a template instantiation backtrace when a failure occurs during template instantiation. There's still more work to do to make this output pretty, if that's even possible. llvm-svn: 66557
* Limit the template instantiation depth to some user-configurable valueDouglas Gregor2009-03-101-0/+34
| | | | | | | | | | | | | | | | (default: 99). Beyond this limit, produce an error and consider the current template instantiation a failure. The stack we're building to track the instantiations will, eventually, be used to produce instantiation backtraces from diagnostics within template instantiation. However, we're not quite there yet. This adds a new Clang driver option -ftemplate-depth=NNN, which should eventually be generated from the GCC command-line operation -ftemplate-depth-NNN (note the '-' rather than the '='!). I did not make the driver changes to do this mapping. llvm-svn: 66513
* Implement template instantiation for ClassTemplateSpecializationTypes,Douglas Gregor2009-03-091-3/+38
| | | | | | | | | | | | | | | | | | | | | | such as replacing 'T' in vector<T>. There are a few aspects to this: - Extend TemplateArgument to allow arbitrary expressions (an Expr*), and switch ClassTemplateSpecializationType to store TemplateArguments rather than it's own type-or-expression representation. - ClassTemplateSpecializationType can now store dependent types. In that case, the canonical type is another ClassTemplateSpecializationType (with default template arguments expanded) rather than a declaration (we don't build Decls for dependent types). - Split ActOnClassTemplateId into ActOnClassTemplateId (called from the parser) and CheckClassTemplateId (called from ActOnClassTemplateId and InstantiateType). They're smart enough to handle dependent types, now. llvm-svn: 66509
* Revert r66423, which was not the right fix for this issue.Douglas Gregor2009-03-091-1/+3
| | | | llvm-svn: 66431
* Fix a little FIXME, thanks to SebastianDouglas Gregor2009-03-091-3/+1
| | | | llvm-svn: 66423
* Implement the basics of implicit instantiation of class templates, inDouglas Gregor2009-03-031-0/+121
| | | | | | | | | | | | | | | | | | | | response to attempts to diagnose an "incomplete" type. This will force us to use DiagnoseIncompleteType more regularly (rather than looking at isIncompleteType), but that's also a good thing. Implicit instantiation is still very simplistic, and will create a new definition for the class template specialization (as it should) but it only actually instantiates the base classes and attaches those. Actually instantiating class members will follow. Also, instantiate the types of non-type template parameters before checking them, allowing, e.g., template<typename T, T Value> struct Constant; to work properly. llvm-svn: 65924
* Eliminate CXXRecordTypeDouglas Gregor2009-02-281-8/+0
| | | | llvm-svn: 65671
* Add a FIXME for something I can't look at just yetDouglas Gregor2009-02-281-0/+2
| | | | llvm-svn: 65669
* Template instantiation for function typesDouglas Gregor2009-02-281-6/+21
| | | | llvm-svn: 65668
* Implement template instantiation for pointer, reference, and (some)Douglas Gregor2009-02-281-235/+189
| | | | | | | | | | | | | array types. Semantic checking for the construction of these types has been factored out of GetTypeForDeclarator and into separate subroutines (BuildPointerType, BuildReferenceType, BuildArrayType). We'll be doing the same thing for all other types (and declarations and expressions). As part of this, moved the type-instantiation functions into a class in an anonymous namespace. llvm-svn: 65663
* Fix a typoDouglas Gregor2009-02-271-1/+1
| | | | llvm-svn: 65652
* Implement the basic approach for instantiating types, with a lot of FIXME'dDouglas Gregor2009-02-271-0/+438
stubs for those types we don't yet know how to instantiate (everything that isn't a template parameter!). We now instantiate default arguments for template type parameters when needed. This will be our testbed while I fill out the remaining type-instantiation logic. llvm-svn: 65649
OpenPOWER on IntegriCloud