Skip to content
  1. Feb 14, 2009
    • 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
  2. 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
  3. 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
  4. Jan 29, 2009
  5. Jan 27, 2009
  6. 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
  7. 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
  8. Jan 18, 2009
  9. 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
  10. 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
  11. Dec 22, 2008
  12. 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
  13. Dec 05, 2008
  14. Dec 03, 2008
  15. Nov 24, 2008
    • Chris Lattner's avatar
      Rename Selector::getName() to Selector::getAsString(), and add · e4b95698
      Chris Lattner authored
      a new NamedDecl::getAsString() method.
      
      Change uses of Selector::getName() to just pass in a Selector 
      where possible (e.g. to diagnostics) instead of going through
      an std::string.
      
      This also adds new formatters for objcinstance and objcclass
      as described in the dox.
      
      llvm-svn: 59933
      e4b95698
  16. Nov 23, 2008
  17. Nov 22, 2008
  18. Nov 20, 2008
  19. Nov 19, 2008
  20. Nov 18, 2008
    • Chris Lattner's avatar
      start converting Sema over to using its canonical Diag method. · 377d1f8e
      Chris Lattner authored
      llvm-svn: 59561
      377d1f8e
    • Chris Lattner's avatar
    • Chris Lattner's avatar
      This reworks some of the Diagnostic interfaces a bit to change how diagnostics · 8488c829
      Chris Lattner authored
      are formed.  In particular, a diagnostic with all its strings and ranges is now
      packaged up and sent to DiagnosticClients as a DiagnosticInfo instead of as a 
      ton of random stuff.  This has the benefit of simplifying the interface, making
      it more extensible, and allowing us to do more checking for things like access
      past the end of the various arrays passed in.
      
      In addition to introducing DiagnosticInfo, this also substantially changes how 
      Diagnostic::Report works.  Instead of being passed in all of the info required
      to issue a diagnostic, Report now takes only the required info (a location and 
      ID) and returns a fresh DiagnosticInfo *by value*.  The caller is then free to
      stuff strings and ranges into the DiagnosticInfo with the << operator.  When
      the dtor runs on the DiagnosticInfo object (which should happen at the end of
      the statement), the diagnostic is actually emitted with all of the accumulated
      information.  This is a somewhat tricky dance, but it means that the 
      accumulated DiagnosticInfo is allowed to keep pointers to other expression 
      temporaries without those pointers getting invalidated.
      
      This is just the minimal change to get this stuff working, but this will allow
      us to eliminate the zillions of variant "Diag" methods scattered throughout
      (e.g.) sema.  For example, instead of calling:
      
        Diag(BuiltinLoc, diag::err_overload_no_match, typeNames,
             SourceRange(BuiltinLoc, RParenLoc));
      
      We will soon be able to just do:
      
        Diag(BuiltinLoc, diag::err_overload_no_match)
            << typeNames << SourceRange(BuiltinLoc, RParenLoc));
      
      This scales better to support arbitrary types being passed in (not just 
      strings) in a type-safe way.  Go operator overloading?!
      
      llvm-svn: 59502
      8488c829
    • Chris Lattner's avatar
      Change the diagnostics interface to take an array of pointers to · 16ba9139
      Chris Lattner authored
      strings instead of array of strings.  This reduces string copying
      in some not-very-important cases, but paves the way for future 
      improvements.
      
      llvm-svn: 59494
      16ba9139
  21. Nov 17, 2008
  22. Nov 12, 2008
    • Douglas Gregor's avatar
      Implement support for operator overloading using candidate operator · a11693bc
      Douglas Gregor authored
      functions for built-in operators, e.g., the builtin
      
        bool operator==(int const*, int const*)
      
      can be used for the expression "x1 == x2" given:
      
        struct X {
          operator int const*();
        } x1, x2;
      
      The scheme for handling these built-in operators is relatively simple:
      for each candidate required by the standard, create a special kind of
      candidate function for the built-in. If overload resolution picks the
      built-in operator, we perform the appropriate conversions on the
      arguments and then let the normal built-in operator take care of it. 
      
      There may be some optimization opportunity left: if we can reduce the
      number of built-in operator overloads we generate, overload resolution
      for these cases will go faster. However, one must be careful when
      doing this: GCC generates too few operator overloads in our little
      test program, and fails to compile it because none of the overloads it
      generates match.
      
      Note that we only support operator overload for non-member binary
      operators at the moment. The other operators will follow.
      
      As part of this change, ImplicitCastExpr can now be an lvalue.
      
      llvm-svn: 59148
      a11693bc
  23. Nov 11, 2008
  24. Nov 08, 2008
Loading