Skip to content
  1. Apr 09, 2009
  2. Apr 01, 2009
  3. Mar 31, 2009
    • Douglas Gregor's avatar
      Some cleanup and renaming. No functionality change · b046ffb0
      Douglas Gregor authored
      llvm-svn: 68140
      b046ffb0
    • Douglas Gregor's avatar
      Implement template instantiation for template names, including both · aa59489b
      Douglas Gregor authored
      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
      aa59489b
    • Douglas Gregor's avatar
      Parsing and AST representation for dependent template names that occur · b67535d1
      Douglas Gregor authored
      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
      b67535d1
    • Douglas Gregor's avatar
      Improve the representation of template names in the AST. This · dc572a32
      Douglas Gregor authored
      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
      dc572a32
  4. Mar 28, 2009
    • Chris Lattner's avatar
      Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for a · 83f095cc
      Chris Lattner authored
      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
      83f095cc
    • Douglas Gregor's avatar
      Initial implementation of parsing, semantic analysis, and template · 333489bb
      Douglas Gregor authored
      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
      333489bb
  5. Mar 27, 2009
    • Douglas Gregor's avatar
      Revamp our representation of C++ nested-name-specifiers. We now have a · f21eb49a
      Douglas Gregor authored
      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
      f21eb49a
  6. Mar 25, 2009
  7. Mar 20, 2009
  8. Mar 19, 2009
    • Douglas Gregor's avatar
      Introduce a new expression type, UnresolvedDeclRefExpr, that describes · 90a1a651
      Douglas Gregor authored
      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
      90a1a651
    • Douglas Gregor's avatar
      Introduce a representation for types that we referred to via a · 5253768a
      Douglas Gregor authored
      qualified name, e.g., 
      
        foo::x
      
      so that we retain the nested-name-specifier as written in the source
      code and can reproduce that qualified name when printing the types
      back (e.g., in diagnostics). This is PR3493, which won't be complete
      until finished the other tasks mentioned near the end of this commit.
      
      The parser's representation of nested-name-specifiers, CXXScopeSpec,
      is now a bit fatter, because it needs to contain the scopes that
      precede each '::' and keep track of whether the global scoping
      operator '::' was at the beginning. For example, we need to keep track
      of the leading '::', 'foo', and 'bar' in
       
        ::foo::bar::x
      
      The Action's CXXScopeTy * is no longer a DeclContext *. It's now the
      opaque version of the new NestedNameSpecifier, which contains a single
      component of a nested-name-specifier (either a DeclContext * or a Type
      *, bitmangled). 
      
      The new sugar type QualifiedNameType composes a sequence of
      NestedNameSpecifiers with a representation of the type we're actually
      referring to. At present, we only build QualifiedNameType nodes within
      Sema::getTypeName. This will be extended to other type-constructing
      actions (e.g., ActOnClassTemplateId).
      
      Also on the way: QualifiedDeclRefExprs will also store a sequence of
      NestedNameSpecifiers, so that we can print out the property
      nested-name-specifier. I expect to also use this for handling
      dependent names like Fibonacci<I - 1>::value.
      
      llvm-svn: 67265
      5253768a
    • Gabor Greif's avatar
      Use the instantiated expressions to build the ConditionalOperator. This... · 5e09283e
      Gabor Greif authored
      Use the instantiated expressions to build the ConditionalOperator. This addresses the second part of review feedback.
      
      llvm-svn: 67259
      5e09283e
  9. Mar 18, 2009
  10. Mar 17, 2009
  11. Mar 15, 2009
  12. Mar 14, 2009
  13. Mar 13, 2009
    • Douglas Gregor's avatar
      Implement template instantiation for several more kinds of expressions: · 0950e41b
      Douglas Gregor authored
        - C++ function casts, e.g., T(foo)
        - sizeof(), alignof()
      
      More importantly, this allows us to verify that we're performing
      overload resolution during template instantiation, with
      argument-dependent lookup and the "cached" results of name lookup from
      the template definition.
      
      llvm-svn: 66947
      0950e41b
    • Douglas Gregor's avatar
      Remove an already-fixed FIXME · f50abb42
      Douglas Gregor authored
      llvm-svn: 66924
      f50abb42
    • Douglas Gregor's avatar
      Refactor the way we handle operator overloading and template · 1baf54e1
      Douglas Gregor authored
      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
      1baf54e1
    • Douglas Gregor's avatar
      Improve the representation of operator expressions like "x + y" within · d2b7ef6e
      Douglas Gregor authored
      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
      d2b7ef6e
  14. Mar 12, 2009
  15. Mar 11, 2009
Loading