Skip to content
  1. 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
  2. Jun 16, 2009
  3. 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
  4. Jun 03, 2009
  5. May 29, 2009
  6. May 14, 2009
  7. Apr 30, 2009
  8. Apr 24, 2009
  9. Apr 22, 2009
    • Douglas Gregor's avatar
      Eliminate Sema::KnownFunctionIDs, so that Sema doesn't end up pulling · fedd428d
      Douglas Gregor authored
      in a bunch of declarations from the PCH file. We're down to loading
      very few declarations in Carbon-prefixed "Hello, World!":
      
      *** PCH Statistics:
        6/20693 types read (0.028995%)
        7/59230 declarations read (0.011818%)
        50/44914 identifiers read (0.111324%)
        0/32954 statements read (0.000000%)
        5/6187 macros read (0.080815%)
      
      llvm-svn: 69825
      fedd428d
  10. Apr 21, 2009
    • Douglas Gregor's avatar
      Explictly track tentative definitions within Sema, then hand those · beecd58e
      Douglas Gregor authored
      tentative definitions off to the ASTConsumer at the end of the
      translation unit. 
      
      Eliminate CodeGen's internal tracking of tentative definitions, and
      instead hook into ASTConsumer::CompleteTentativeDefinition. Also,
      tweak the definition-deferal logic for C++, where there are no
      tentative definitions.
      
      Fixes <rdar://problem/6808352>, and will make it much easier for
      precompiled headers to cope with tentative definitions in the future.
      
      llvm-svn: 69681
      beecd58e
  11. Apr 15, 2009
  12. Apr 14, 2009
  13. Apr 01, 2009
    • Douglas Gregor's avatar
      Give Type::getDesugaredType a "for-display" mode that can apply more · 2e0757f3
      Douglas Gregor authored
      heuristics to determine when it's useful to desugar a type for display
      to the user. Introduce two C++-specific heuristics:
      
        - For a qualified type (like "foo::bar"), only produce a new
          desugred type if desugaring the qualified type ("bar", in this
          case) produces something interesting. For example, if "foo::bar"
          refers to a class named "bar", don't desugar. However, if
          "foo::bar" refers to a typedef of something else, desugar to that
          something else. This gives some useful desugaring such as
          "foo::bar (aka 'int')".
        - Don't desugar class template specialization types like
          "basic_string<char>" down to their underlying "class
          basic_string<char, char_traits<char>, allocator<char>>, etc.";
          it's better just to leave such types alone. 
      
      Update diagnostics.html with some discussion and examples of type
      preservation in C++, showing qualified names and class template
      specialization types.
      
      llvm-svn: 68207
      2e0757f3
  14. 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
  15. Mar 20, 2009
  16. Mar 13, 2009
  17. Mar 11, 2009
  18. Feb 28, 2009
    • Steve Naroff's avatar
      Fix <rdar://problem/6451399> problems with labels and blocks. · d123bd05
      Steve Naroff authored
      - Move the 'LabelMap' from Sema to Scope. To avoid layering problems, the second element is now a 'StmtTy *', which makes the LabelMap a bit more verbose to deal with.
      - Add 'ActiveScope' to Sema. Managed by ActOnStartOfFunctionDef(), ObjCActOnStartOfMethodDef(), ActOnBlockStmtExpr().
      - Changed ActOnLabelStmt(), ActOnGotoStmt(), ActOnAddrLabel(), and ActOnFinishFunctionBody() to use the new ActiveScope.
      - Added FIXME to workaround in ActOnFinishFunctionBody() (for dealing with C++ nested functions).  
      
      llvm-svn: 65694
      d123bd05
  19. Feb 20, 2009
    • Chris Lattner's avatar
      replace a dirty hack with a clean solution. Too bad we can't · cf868c45
      Chris Lattner authored
      use Blocks for our callbacks ;-)
      
      llvm-svn: 65083
      cf868c45
    • Chris Lattner's avatar
      Fix a long standard problem with clang retaining "too much" sugar · 810d330c
      Chris Lattner authored
      information about types.  We often print diagnostics where we say 
      "foo_t" is bad, but the user doesn't know how foo_t is declared 
      (because it is a typedef).  Fix this by expanding sugar when present
      in a diagnostic (and not one of a few special cases, like vectors).
      
      Before:
      t.m:5:2: error: invalid operands to binary expression ('typeof(P)' and 'typeof(F)')
       MAX(P, F);
       ^~~~~~~~~
      t.m:1:78: note: instantiated from:
      #define MAX(A,B)    ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
                                                                                   ^
      
      After:
      t.m:5:2: error: invalid operands to binary expression ('typeof(P)' (aka 'struct mystruct') and 'typeof(F)' (aka 'float'))
       MAX(P, F);
       ^~~~~~~~~
      t.m:1:78: note: instantiated from:
      #define MAX(A,B)    ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __b : __a; })
                                                                                   ^
      
      llvm-svn: 65081
      810d330c
  20. Feb 14, 2009
    • Douglas Gregor's avatar
      Add hook to add attributes to function declarations that we know · e711f705
      Douglas Gregor authored
      about, whether they are builtins or not. Use this to add the
      appropriate "format" attribute to NSLog, NSLogv, asprintf, and
      vasprintf, and to translate builtin attributes (from Builtins.def)
      into actual attributes on the function declaration.
      
      Use the "printf" format attribute on function declarations to
      determine whether we should do format string checking, rather than
      looking at an ad hoc list of builtins and "known" function names.
      
      Be a bit more careful about when we consider a function a "builtin" in
      C++.
      
      llvm-svn: 64561
      e711f705
    • Douglas Gregor's avatar
      Make it possible for builtins to expression FILE* arguments, so that · 538c3d84
      Douglas Gregor authored
      we can define builtins such as fprintf, vfprintf, and
      __builtin___fprintf_chk. Give a nice error message when we need to
      implicitly declare a function like fprintf.
      
      llvm-svn: 64526
      538c3d84
    • Douglas Gregor's avatar
      Extend builtin "attribute" syntax to include a notation for · ac5d4c5f
      Douglas Gregor authored
      printf-like functions, both builtin functions and those in the
      C library. The function-call checker now queries this attribute do
      determine if we have a printf-like function, rather than scanning
      through the list of "known functions IDs". However, there are 5
      functions they are not yet "builtins", so the function-call checker
      handles them specifically still:
      
        - fprintf and vfprintf: the builtins mechanism cannot (yet)
          express FILE* arguments, so these can't be encoded.
        - NSLog: the builtins mechanism cannot (yet) express NSString*
          arguments, so this (and NSLogv) can't be encoded.
        - asprintf and vasprintf: these aren't part of the C99 standard
          library, so we really shouldn't be defining them as builtins in
          the general case (and we don't seem to have the machinery to make
          them builtins only on certain targets and depending on whether
          extensions are enabled).
      
      llvm-svn: 64512
      ac5d4c5f
  21. Feb 07, 2009
    • Ted Kremenek's avatar
      Overhaul of Stmt allocation: · 5a201951
      Ted Kremenek authored
      - Made allocation of Stmt objects using vanilla new/delete a *compiler
        error* by making this new/delete "protected" within class Stmt.
      - Now the only way to allocate Stmt objects is by using the new
        operator that takes ASTContext& as an argument.  This ensures that
        all Stmt nodes are allocated from the same (pool) allocator.
      - Naturally, these two changes required that *all* creation sites for
        AST nodes use new (ASTContext&).  This is a large patch, but the
        majority of the changes are just this mechanical adjustment.
      - The above changes also mean that AST nodes can no longer be
        deallocated using 'delete'.  Instead, one most do
        StmtObject->Destroy(ASTContext&) or do
        ASTContextObject.Deallocate(StmtObject) (the latter not running the
        'Destroy' method).
      
      Along the way I also...
      - Made CompoundStmt allocate its array of Stmt* using the allocator in
        ASTContext (previously it used std::vector).  There are a whole
        bunch of other Stmt classes that need to be similarly changed to
        ensure that all memory allocated for ASTs comes from the allocator
        in ASTContext.
      - Added a new smart pointer ExprOwningPtr to Sema.h.  This replaces
        the uses of llvm::OwningPtr within Sema, as llvm::OwningPtr used
        'delete' to free memory instead of a Stmt's 'Destroy' method.
      
      Big thanks to Doug Gregor for helping with the acrobatics of making
      'new/delete' private and the new smart pointer ExprOwningPtr!
      
      llvm-svn: 63997
      5a201951
  22. Feb 04, 2009
    • Douglas Gregor's avatar
      Implement semantic analysis for the GNU flexible array initialization · fc4f8a18
      Douglas Gregor authored
      extension. The interaction with designated initializers is a
      bit... interesting... but we follow GNU's lead and don't permit too
      much crazy code in this area.
      
      Also, make the "excess initializers" error message a bit more
      informative.
      
      Addresses PR2561: http://llvm.org/bugs/show_bug.cgi?id=2561
      
      llvm-svn: 63785
      fc4f8a18
    • Douglas Gregor's avatar
      Some name-lookup-related fixes, from Piotr Rak! · 2ada0489
      Douglas Gregor authored
      - Changes Lookup*Name functions to return NamedDecls, instead of
      Decls. Unfortunately my recent statement that it will simplify lot of
      code, was not quite right, but it simplifies some...
      - Makes MergeLookupResult SmallPtrSet instead of vector, following
      Douglas suggestions.
      - Adds %qN format for printing qualified names to Diagnostic.
      - Avoids searching for using-directives in Scopes, which are not
      DeclScope, during unqualified name lookup.
      
      llvm-svn: 63739
      2ada0489
  23. Jan 29, 2009
  24. Jan 27, 2009
  25. Jan 22, 2009
    • Chris Lattner's avatar
      inline Sema::getLangOptions, rdar://6515190. This speeds up · 4da04a4e
      Chris Lattner authored
      fsyntax-only with PTH by 3%.
      
      llvm-svn: 62774
      4da04a4e
    • Douglas Gregor's avatar
      Initial implementation of semantic analysis and ASTs for C99 · e4a0bb7a
      Douglas Gregor authored
      designated initializers. This implementation should cover all of the
      constraints in C99 6.7.8, including long, complex designations and
      computing the size of incomplete array types initialized with a
      designated initializer. Please see the new test-case and holler if you
      find cases where this doesn't work.
      
      There are still some wrinkles with GNU's anonymous structs and
      anonymous unions (it isn't clear how these should work; we'll just
      follow GCC's lead) and with designated initializers for the members of a
      union. I'll tackle those very soon.
      
      CodeGen is still nonexistent, and there's some leftover code in the
      parser's representation of designators that I'll also need to clean up.
      
      llvm-svn: 62737
      e4a0bb7a
  26. Jan 20, 2009
    • Douglas Gregor's avatar
      Remove ScopedDecl, collapsing all of its functionality into Decl, so · 6e6ad602
      Douglas Gregor authored
      that every declaration lives inside a DeclContext.
      
      Moved several things that don't have names but were ScopedDecls (and,
      therefore, NamedDecls) to inherit from Decl rather than NamedDecl,
      including ObjCImplementationDecl and LinkageSpecDecl. Now, we don't
      store empty DeclarationNames for these things, nor do we try to insert
      them into DeclContext's lookup structure.
      
      The serialization tests are temporarily disabled. We'll re-enable them
      once we've sorted out the remaining ownership/serialiazation issues
      between DeclContexts and TranslationUnion, DeclGroups, etc.
      
      llvm-svn: 62562
      6e6ad602
  27. Jan 18, 2009
  28. Jan 09, 2009
    • Douglas Gregor's avatar
      Addressed the issue in <rdar://problem/6479085>, where we failed to · c25d7a7f
      Douglas Gregor authored
      rewrite @class declarations that showed up within linkage
      specifications because those @class declarations never made it any
      place where the rewriter could find them.
      
      Moved all of the ObjC*Decl nodes over to ScopedDecls, so that they can
      live in the appropriate top-level or transparent DeclContext near the
      top level, e.g., TranslationUnitDecl or LinkageSpecDecl. Objective-C
      declarations now show up in a traversal of the declarations in a
      DeclContext (they didn't before!). This way, the rewriter finds all
      Objective-C declarations within linkage specifications.
      
      llvm-svn: 61966
      c25d7a7f
  29. Jan 08, 2009
    • Steve Naroff's avatar
      This is a large/messy diff that unifies the ObjC AST's with DeclContext. · 35c62ae6
      Steve Naroff authored
      - ObjCContainerDecl's (ObjCInterfaceDecl/ObjCCategoryDecl/ObjCProtocolDecl), ObjCCategoryImpl, & ObjCImplementation are all DeclContexts.
      - ObjCMethodDecl is now a ScopedDecl (so it can play nicely with DeclContext).
      - ObjCContainerDecl now does iteration/lookup using DeclContext infrastructure (no more linear search:-)
      - Removed ASTContext argument to DeclContext::lookup(). It wasn't being used and complicated it's use from an ObjC AST perspective.
      - Added Sema::ProcessPropertyDecl() and removed Sema::diagnosePropertySetterGetterMismatch().
      - Simplified Sema::ActOnAtEnd() considerably. Still more work to do.
      - Fixed an incorrect casting assumption in Sema::getCurFunctionOrMethodDecl(), now that ObjCMethodDecl is a ScopedDecl.
      - Removed addPropertyMethods from ObjCInterfaceDecl/ObjCCategoryDecl/ObjCProtocolDecl.
      
      This passes all the tests on my machine. Since many of the changes are central to the way ObjC finds it's methods, I expect some fallout (and there are still a handful of FIXME's). Nevertheless, this should be a step in the right direction.
      
      llvm-svn: 61929
      35c62ae6
  30. Dec 22, 2008
  31. Dec 11, 2008
    • Douglas Gregor's avatar
      Unifies the name-lookup mechanisms used in various parts of the AST · 91f84216
      Douglas Gregor authored
      and separates lexical name lookup from qualified name lookup. In
      particular:
        * Make DeclContext the central data structure for storing and
          looking up declarations within existing declarations, e.g., members
          of structs/unions/classes, enumerators in C++0x enums, members of
          C++ namespaces, and (later) members of Objective-C
          interfaces/implementations. DeclContext uses a lazily-constructed
          data structure optimized for fast lookup (array for small contexts,
          hash table for larger contexts). 
      
        * Implement C++ qualified name lookup in terms of lookup into
          DeclContext.
      
        * Implement C++ unqualified name lookup in terms of
          qualified+unqualified name lookup (since unqualified lookup is not
          purely lexical in C++!)
      
        * Limit the use of the chains of declarations stored in
          IdentifierInfo to those names declared lexically.
      
        * Eliminate CXXFieldDecl, collapsing its behavior into
          FieldDecl. (FieldDecl is now a ScopedDecl).
      
        * Make RecordDecl into a DeclContext and eliminates its
          Members/NumMembers fields (since one can just iterate through the
          DeclContext to get the fields).
      
      llvm-svn: 60878
      91f84216
  32. Dec 05, 2008
Loading