Skip to content
  1. Oct 20, 2009
  2. Oct 18, 2009
    • John McCall's avatar
      When performing template-substitution into a type, don't just replace the · cebee16b
      John McCall authored
      TemplateTypeParmType with the substituted type directly;  instead, replace it
      with a SubstTemplateTypeParmType which will note that the type was originally
      written as a template type parameter.  This makes it reasonable to preserve
      source information even through template substitution.
      
      Also define the new SubstTemplateTypeParmType class, obviously.
      
      For consistency with current behavior, we stringize these types as if they
      were the underlying type.  I'm not sure this is the right thing to do.
      At any rate, I paled at adding yet another clause to the don't-desugar 'if'
      statement, so I extracted a function to do it.  The new function also does
      The Right Thing more often, I think:  e.g. if we have a chain of typedefs
      leading to a vector type, we will now desugar all but the last one.
      
      llvm-svn: 84412
      cebee16b
  3. Oct 16, 2009
  4. Oct 14, 2009
    • Douglas Gregor's avatar
      Improve diagnostics when the parser encounters a declarator with an · 15e5602e
      Douglas Gregor authored
      unknown type name, e.g.,
      
        foo::bar x;
      
      when "bar" does not refer to a type in "foo". 
      
      With this change, the parser now calls into the action to perform
      diagnostics and can try to recover by substituting in an appropriate
      type. For example, this allows us to easily diagnose some missing
      "typename" specifiers, which we now do:
      
        test/SemaCXX/unknown-type-name.cpp:29:1: error: missing 'typename'
              prior to dependent type name 'A<T>::type'
        A<T>::type A<T>::f() { return type(); }
        ^~~~~~~~~~
        typename 
      
      Fixes PR3990.
      
      llvm-svn: 84053
      15e5602e
  5. Oct 13, 2009
  6. Sep 30, 2009
  7. Sep 24, 2009
  8. Sep 17, 2009
    • Douglas Gregor's avatar
      Initial implementation of a code-completion interface in Clang. In · 2436e711
      Douglas Gregor authored
      essence, code completion is triggered by a magic "code completion"
      token produced by the lexer [*], which the parser recognizes at
      certain points in the grammar. The parser then calls into the Action
      object with the appropriate CodeCompletionXXX action.
      
      Sema implements the CodeCompletionXXX callbacks by performing minimal
      translation, then forwarding them to a CodeCompletionConsumer
      subclass, which uses the results of semantic analysis to provide
      code-completion results. At present, only a single, "printing" code
      completion consumer is available, for regression testing and
      debugging. However, the design is meant to permit other
      code-completion consumers.
      
      This initial commit contains two code-completion actions: one for
      member access, e.g., "x." or "p->", and one for
      nested-name-specifiers, e.g., "std::". More code-completion actions
      will follow, along with improved gathering of code-completion results
      for the various contexts.
      
      [*] In the current -code-completion-dump testing/debugging mode, the
      file is truncated at the completion point and EOF is translated into
      "code completion".
      
      llvm-svn: 82166
      2436e711
  9. Sep 16, 2009
    • Douglas Gregor's avatar
      When implicitly declaring operators new, new[], delete, and delete[], · 87f54060
      Douglas Gregor authored
      give them the appropriate exception specifications. This,
      unfortunately, requires us to maintain and/or implicitly generate
      handles to namespace "std" and the class "std::bad_alloc". However,
      every other approach I've come up with was more hackish, and this
      standard requirement itself is quite the hack.
      
      Fixes PR4829.
      
      llvm-svn: 81939
      87f54060
  10. Sep 15, 2009
  11. Sep 11, 2009
  12. Sep 09, 2009
  13. Sep 08, 2009
  14. Sep 05, 2009
  15. Aug 30, 2009
  16. Aug 27, 2009
  17. Aug 26, 2009
    • Douglas Gregor's avatar
      Improve diagnostics and recovery when the nested-name-specifier of a · 053f691d
      Douglas Gregor authored
      qualified name does not actually refer into a class/class
      template/class template partial specialization. 
      
      Improve printing of nested-name-specifiers to eliminate redudant
      qualifiers. Also, make it possible to output a nested-name-specifier
      through a DiagnosticBuilder, although there are relatively few places
      that will use this leeway.
      
      llvm-svn: 80056
      053f691d
  18. Aug 17, 2009
    • David Chisnall's avatar
      Initial patch to support definitions of id and Class from headers in Objective-C code. · 9f57c290
      David Chisnall authored
      This currently breaks test/SemaObjC/id-isa-ref.m and issues some spurious warnings when you attempt to assign a struct objc_class* value to a Class variable.  The test case probably should fail as it's written, because without the definition of Class the compiler should not assume struct objc_class* is a valid receiver type, but it's left broken because it would be nice if we could get that passing too for the special case of isa.
      
      Approved by snaroff.
      
      llvm-svn: 79248
      9f57c290
  19. Aug 10, 2009
  20. Aug 08, 2009
  21. Jul 31, 2009
  22. Jul 30, 2009
  23. Jul 15, 2009
    • Steve Naroff's avatar
      Implement the ObjC pseudo built-in types as clang "BuiltinType's". I say... · 1329fa0e
      Steve Naroff authored
      Implement the ObjC pseudo built-in types as clang "BuiltinType's". I say pseudo built-in types, since Sema still injects a typedef for recognition (i.e. they aren't truly built-ins from a parser perspective).
      
      This removes the static data/methods on ObjCObjectPointerType while preserving the nice API (no need to fiddle with ASTContext:-).
      
      This patch also adds Type::isObjCBuiltinType().
      
      This should be the last fairly large patch related to recrafting the ObjC type system. The follow-on patches should be fairly small.
      
      llvm-svn: 75808
      1329fa0e
  24. Jul 11, 2009
    • Steve Naroff's avatar
      This patch includes a conceptually simple, but very intrusive/pervasive change. · 7cae42b0
      Steve Naroff authored
      The idea is to segregate Objective-C "object" pointers from general C pointers (utilizing the recently added ObjCObjectPointerType). The fun starts in Sema::GetTypeForDeclarator(), where "SomeInterface *" is now represented by a single AST node (rather than a PointerType whose Pointee is an ObjCInterfaceType). Since a significant amount of code assumed ObjC object pointers where based on C pointers/structs, this patch is very tedious. It should also explain why it is hard to accomplish this in smaller, self-contained patches.
      
      This patch does most of the "heavy lifting" related to moving from PointerType->ObjCObjectPointerType. It doesn't include all potential "cleanups". The good news is additional cleanups can be done later (some are noted in the code). This patch is so large that I didn't want to include any changes that are purely aesthetic.
      
      By making the ObjC types truly built-in, they are much easier to work with (and require fewer "hacks"). For example, there is no need for ASTContext::isObjCIdStructType() or ASTContext::isObjCClassStructType()! We believe this change (and the follow-up cleanups) will pay dividends over time. 
      
      Given the amount of code change, I do expect some fallout from this change (though it does pass all of the clang tests). If you notice any problems, please let us know asap! Thanks.
      
      llvm-svn: 75314
      7cae42b0
  25. Jul 06, 2009
  26. Jul 02, 2009
    • Douglas Gregor's avatar
      Add support for retrieving the Doxygen comment associated with a given · c6d5edd2
      Douglas Gregor authored
      declaration in the AST. 
      
      The new ASTContext::getCommentForDecl function searches for a comment
      that is attached to the given declaration, and returns that comment, 
      which may be composed of several comment blocks.
      
      Comments are always available in an AST. However, to avoid harming
      performance, we don't actually parse the comments. Rather, we keep the
      source ranges of all of the comments within a large, sorted vector,
      then lazily extract comments via a binary search in that vector only
      when needed (which never occurs in a "normal" compile).
      
      Comments are written to a precompiled header/AST file as a blob of
      source ranges. That blob is only lazily loaded when one requests a
      comment for a declaration (this never occurs in a "normal" compile). 
      
      The indexer testbed now supports comment extraction. When the
      -point-at location points to a declaration with a Doxygen-style
      comment, the indexer testbed prints the associated comment
      block(s). See test/Index/comments.c for an example.
      
      Some notes:
        - We don't actually attempt to parse the comment blocks themselves,
        beyond identifying them as Doxygen comment blocks to associate them
        with a declaration.
        - We won't find comment blocks that aren't adjacent to the
        declaration, because we start our search based on the location of
        the declaration.
        - We don't go through the necessary hops to find, for example,
        whether some redeclaration of a declaration has comments when our
        current declaration does not. Similarly, we don't attempt to
        associate a \param Foo marker in a function body comment with the
        parameter named Foo (although that is certainly possible).
        - Verification of my "no performance impact" claims is still "to be
        done".
      
      llvm-svn: 74704
      c6d5edd2
  27. Jun 23, 2009
  28. Jun 22, 2009
    • Douglas Gregor's avatar
      Rework the way we track which declarations are "used" during · 0b6a6242
      Douglas Gregor authored
      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
      0b6a6242
  29. Jun 20, 2009
  30. Jun 18, 2009
    • Steve Naroff's avatar
      First step toward fixing <rdar://problem/6613046> refactor clang objc type representation. · fb4330f2
      Steve Naroff authored
      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
      fb4330f2
  31. Jun 16, 2009
  32. Jun 14, 2009
    • Douglas Gregor's avatar
      Introduce a SFINAE "trap" that keeps track of the number of errors · e141633f
      Douglas Gregor authored
      that were suppressed due to SFINAE. By checking whether any errors
      occur at the end of template argument deduction, we avoid the
      possibility of suppressing an error (due to SFINAE) and then
      recovering so well that template argument deduction never detects that
      there was a problem. Thanks to Eli for the push in this direction.
      
      llvm-svn: 73336
      e141633f
    • Douglas Gregor's avatar
      Update LLVM. · 33834516
      Douglas Gregor authored
      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
      33834516
  33. Jun 03, 2009
Loading