Skip to content
  1. Mar 23, 2009
  2. Mar 22, 2009
  3. Mar 21, 2009
  4. Mar 20, 2009
  5. 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
      Extend the use of QualifiedNameType to the creation of class template · e177b725
      Douglas Gregor authored
      specialization names. This way, we keep track of sugared types like
      
        std::vector<Real>
      
      I believe we are now using QualifiedNameTypes everywhere we can. Next
      step: QualifiedDeclRefExprs.
      
      llvm-svn: 67268
      e177b725
    • 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
  6. Mar 18, 2009
  7. Mar 17, 2009
  8. Mar 15, 2009
  9. Mar 14, 2009
  10. 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
      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
    • Steve Naroff's avatar
      Reimplement fix for <rdar://problem/6451399> problems with labels and blocks. · cfb6cf4c
      Steve Naroff authored
      This solution is much simpler (and doesn't add any per-scope overhead, which concerned Chris). 
      
      The only downside is the LabelMap is now declared in two places (Sema and BlockSemaInfo). My original fix tried to unify the LabelMap in "Scope" (which would support nested functions in general). In any event, this fixes the bug given the current language definition. If/when we decide to support GCC style nested functions, this will need to be tweaked.
      
      llvm-svn: 66896
      cfb6cf4c
    • Steve Naroff's avatar
      Remove ActiveScope (revert... · 846b1ec4
      Steve Naroff authored
      Remove ActiveScope (revert http://llvm.org/viewvc/llvm-project?view=rev&revision=65694 and http://llvm.org/viewvc/llvm-project?view=rev&revision=66741).
      
      Will replace with something better today...
      
      llvm-svn: 66893
      846b1ec4
    • 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
  11. Mar 12, 2009
  12. Mar 11, 2009
  13. Mar 10, 2009
    • Douglas Gregor's avatar
      Extend the notion of active template instantiations to include the · 79cf6034
      Douglas Gregor authored
      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
      79cf6034
    • Douglas Gregor's avatar
      If we run into multiple errors within the same template instantiation, · 2a72edd4
      Douglas Gregor authored
      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
      2a72edd4
    • Douglas Gregor's avatar
      Add a notion of "post-diagnostic hooks", which are callbacks attached · 4ea568f2
      Douglas Gregor authored
      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
      4ea568f2
    • Douglas Gregor's avatar
      Limit the template instantiation depth to some user-configurable value · fcd5db3b
      Douglas Gregor authored
      (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
      fcd5db3b
    • Douglas Gregor's avatar
      Implement template instantiation for ClassTemplateSpecializationTypes, · c40290e4
      Douglas Gregor authored
      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
      c40290e4
  14. Mar 09, 2009
  15. Mar 08, 2009
  16. Mar 07, 2009
  17. Mar 05, 2009
Loading