Skip to content
  1. Feb 10, 2010
  2. Feb 09, 2010
  3. Feb 08, 2010
  4. Feb 06, 2010
  5. Feb 05, 2010
  6. Feb 04, 2010
    • John McCall's avatar
      Extract a common structure for holding information about the definition · 67da35c8
      John McCall authored
      of a C++ record.  Exposed a lot of problems where various routines were
      silently doing The Wrong Thing (or The Acceptable Thing in The Wrong Order)
      when presented with a non-definition.  Also cuts down on memory usage.
      
      llvm-svn: 95330
      67da35c8
    • Douglas Gregor's avatar
      Fix an obscure crash found in the Boost.MPL test suite, along with a · c42075a1
      Douglas Gregor authored
      ton of potential crashes of the same kind. The fundamental problem is
      that type creation was following a dangerous pattern when using its
      FoldingSets:
        1) Use FindNodeOrInsertPos to see if the type is available
        2) If not, and we aren't looking at a canonical type, build the
        canonical type
        3) Build and insert the new node into the FoldingSet
      
      The problem here is that building the canonical type can, in very rare
      circumstances, force the hash table inside the FoldingSet to
      reallocate. That invalidates the insertion position we computed in
      step 1, and in step 3 we end up inserting the new node into the wrong
      place. BOOM!
      
      I've audited all of ASTContext, fixing this problem everywhere I found
      it. The vast majority of wrong code was C++-specific (and *ahem*
      written by me), so I also audited other major folding sets in the C++
      code (e.g., template specializations), but found no other instances of
      this problem.
      
      llvm-svn: 95315
      c42075a1
    • John McCall's avatar
      cddbad00
  7. Feb 03, 2010
    • Anders Carlsson's avatar
      Don't try to fold DeclRefExprs that point to ParmVarDecls. This had the... · b0695ef0
      Anders Carlsson authored
      Don't try to fold DeclRefExprs that point to ParmVarDecls. This had the side-effect of always folding the expression to the default argument of the parameter. For example:
      
      void f(int a = 10) {
        return a;
      }
      
      would always return 10, regardless of the passed in argument.
      
      This fixes another 600 test failures. We're now down to only 137 failures!
      
      llvm-svn: 95262
      b0695ef0
    • Douglas Gregor's avatar
      Define two types to be "compatible" in C++ if they are the same, and · 21e771e9
      Douglas Gregor authored
      remove some age-old FIXMEs and C++ workarounds within the
      type-compatibility logic.
      
      llvm-svn: 95249
      21e771e9
    • Daniel Dunbar's avatar
      Revert "Numerous changes to selector handling:", this breaks a whole bunch of · 45858d2d
      Daniel Dunbar authored
      working code, for no apparent reason.
      
      llvm-svn: 95244
      45858d2d
    • Douglas Gregor's avatar
      When determining whether a function without a prototype is compatible · 2973d406
      Douglas Gregor authored
      with a function with a prototype, treat parameters of enumeration type
      based on the enumeration type's promotion type.
      
      llvm-svn: 95238
      2973d406
    • Douglas Gregor's avatar
      When a function or variable somehow depends on a type or declaration · 7dc5c17d
      Douglas Gregor authored
      that is in an anonymous namespace, give that function or variable
      internal linkage.
      
      This change models an oddity of the C++ standard, where names declared
      in an anonymous namespace have external linkage but, because anonymous
      namespace are really "uniquely-named" namespaces, the names cannot be
      referenced from other translation units. That means that they have
      external linkage for semantic analysis, but the only sensible
      implementation for code generation is to give them internal
      linkage. We now model this notion via the UniqueExternalLinkage
      linkage type. There are several changes here:
      
        - Extended NamedDecl::getLinkage() to produce UniqueExternalLinkage
          when the declaration is in an anonymous namespace.
        - Added Type::getLinkage() to determine the linkage of a type, which
          is defined as the minimum linkage of the types (when we're dealing
          with a compound type that is not a struct/class/union).
        - Extended NamedDecl::getLinkage() to consider the linkage of the
          template arguments and template parameters of function template
          specializations and class template specializations.
        - Taught code generation to rely on NamedDecl::getLinkage() when
          determining the linkage of variables and functions, also
          considering the linkage of the types of those variables and
          functions (C++ only). Map UniqueExternalLinkage to internal
          linkage, taking out the explicit checks for
          isInAnonymousNamespace().
      
      This fixes much of PR5792, which, as discovered by Anders Carlsson, is
      actually the reason behind the pass-manager assertion that causes the
      majority of clang-on-clang regression test failures. With this fix,
      Clang-built-Clang+LLVM passes 88% of its regression tests (up from
      67%). The specific numbers are:
      
      LLVM:
        Expected Passes    : 4006
        Expected Failures  : 32
        Unsupported Tests  : 40
        Unexpected Failures: 736
      
      Clang:
        Expected Passes    : 1903
        Expected Failures  : 14
        Unexpected Failures: 75
      
      Overall:
        Expected Passes    : 5909
        Expected Failures  : 46
        Unsupported Tests  : 40
        Unexpected Failures: 811
      
      Still to do:
        - Improve testing
        - Check whether we should allow the presence of types with
        InternalLinkage (in addition to UniqueExternalLinkage) given
        variables/functions internal linkage in C++, as mentioned in
        PR5792. 
        - Determine how expensive the getLinkage() calls are in practice;
        consider caching the result in NamedDecl.
        - Assess the feasibility of Chris's idea in comment #1 of PR5792.
      
      llvm-svn: 95216
      7dc5c17d
    • Sam Weinig's avatar
      Implement Doug's suggestion. Eliminate the Stmts pointer from CXXTryStmt and... · a16b0dd1
      Sam Weinig authored
      Implement Doug's suggestion. Eliminate the Stmts pointer from CXXTryStmt and instead allocate the statements after the object.
      
      llvm-svn: 95199
      a16b0dd1
    • Sam Weinig's avatar
      Remove the SmallVector from CXXTryStmt. · ebcea988
      Sam Weinig authored
      llvm-svn: 95190
      ebcea988
    • David Chisnall's avatar
      Numerous changes to selector handling: · 92b762e2
      David Chisnall authored
      - Don't use GlobalAliases with non-0 GEPs (GNU runtime) - this was unsupported and LLVM will be generating errors if you do it soon.  This also simplifies the code generated by the GNU runtime a bit.  
      
      - Make GetSelector() return a constant (GNU runtime), not a load of a store of a constant.
      
      - Recognise @selector() expressions as valid static initialisers (as GCC does).
      
      - Add methods to GCObjCRuntime to emit selectors as constants (needed for using @selector() expressions as constants.  These need implementing for the Mac runtimes - I couldn't figure out how to do this, they seem to require a load.
      
      - Store an ObjCMethodDecl in an ObjCSelectorExpr so that we can get at the type information for the selector.  This is needed for generating typed selectors from @selector() expressions (as GCC does).  Ideally, this information should be stored in the Selector, but that would be an invasive change.  We should eventually add checks for common uses of @selector() expressions.  Possibly adding an attribute that can be applied to method args providing the types of a selector so, for example, you'd do something like this:
      
      - (id)performSelector: __attribute__((selector_types(id, SEL, id)))(SEL)
                 withObject: (id)object;
      
      Then, any @selector() expressions passed to the method will be check to ensure that it conforms to this signature.  We do this at run time on the GNU runtime already, but it would be nice to do it at compile time on all runtimes.
      
      - Made @selector() expressions emit type info if available and the runtime supports it.
      
      Someone more familiar with the Mac runtime needs to implement the GetConstantSelector() function in CGObjCMac.  This currently just assert()s.
      
      llvm-svn: 95189
      92b762e2
    • John McCall's avatar
      Remove abstract expression kinds from the StmtClass enum. Update a few users · 2adddcae
      John McCall authored
      appropriately.  Call out a few missing cases in the expression mangler.
      
      llvm-svn: 95176
      2adddcae
  8. Feb 02, 2010
    • Douglas Gregor's avatar
      Implement promotion for enumeration types. · a71cc153
      Douglas Gregor authored
      WHAT!?!
      
      It turns out that Type::isPromotableIntegerType() was not considering
      enumeration types to be promotable, so we would never do the
      promotion despite having properly computed the promotion type when the
      enum was defined. Various operations on values of enum type just
      "worked" because we could still compute the integer rank of an enum
      type; the oddity, however, is that operations such as "add an enum and
      an unsigned" would often have an enum result type (!). The bug
      actually showed up as a spurious -Wformat diagnostic
      (<rdar://problem/7595366>), but in theory it could cause miscompiles.
      
      In this commit:
        - Enum types with a promotion type of "int" or "unsigned int" are
        promotable.
        - Tweaked the computation of promotable types for enums
        - For all of the ABIs, treat enum types the same way as their
        underlying types (*not* their promotion types) for argument passing
        and return values
        - Extend the ABI tester with support for enumeration types
      
      llvm-svn: 95117
      a71cc153
    • John McCall's avatar
      Dump the constructor type for a CXXConstructExpr. · eba90cd6
      John McCall authored
      llvm-svn: 95106
      eba90cd6
    • Sebastian Redl's avatar
      Fix a C++ regression where redefinitions weren't diagnosed. · ccdb5ff1
      Sebastian Redl authored
      llvm-svn: 95096
      ccdb5ff1
    • John McCall's avatar
      Extract a common base class between UnresolvedLookupExpr and · 1acbbb5a
      John McCall authored
      UnresolvedMemberExpr and employ it in a few places where it's useful.
      
      llvm-svn: 95072
      1acbbb5a
  9. Feb 01, 2010
  10. Jan 31, 2010
    • Sebastian Redl's avatar
      Add VarDecl::isThisDeclarationADefinition(), which properly encapsulates the... · 35351a95
      Sebastian Redl authored
      Add VarDecl::isThisDeclarationADefinition(), which properly encapsulates the logic for when a variable declaration is a (possibly tentativ) definition. Add a few functions building on this, and shift C tentative definition handling over to this new functionality. This shift also kills the Sema::TentativeDefinitions map and instead simply stores all declarations in the renamed list. The correct handling for multiple tentative definitions is instead shifted to the final walk of the list.
      
      llvm-svn: 94968
      35351a95
    • Anders Carlsson's avatar
      Diagnose binding a non-const reference to a vector element. · 8abde4b4
      Anders Carlsson authored
      llvm-svn: 94963
      8abde4b4
    • Douglas Gregor's avatar
      Rework base and member initialization in constructors, with several · 7ae2d775
      Douglas Gregor authored
      (necessarily simultaneous) changes:
      
        - CXXBaseOrMemberInitializer now contains only a single initializer
          rather than a set of initialiation arguments + a constructor. The
          single initializer covers all aspects of initialization, including
          constructor calls as necessary but also cleanup of temporaries
          created by the initializer (which we never handled
          before!).
      
        - Rework + simplify code generation for CXXBaseOrMemberInitializers,
          since we can now just emit the initializer as an initializer.
      
        - Switched base and member initialization over to the new
          initialization code (InitializationSequence), so that it
      
        - Improved diagnostics for the new initialization code when
          initializing bases and members, to match the diagnostics produced
          by the previous (special-purpose) code.
      
        - Simplify the representation of type-checked constructor initializers in
          templates; instead of keeping the fully-type-checked AST, which is
          rather hard to undo at template instantiation time, throw away the
          type-checked AST and store the raw expressions in the AST. This
          simplifies instantiation, but loses a little but of information in
          the AST.
      
        - When type-checking implicit base or member initializers within a
          dependent context, don't add the generated initializers into the
          AST, because they'll look like they were explicit.
      
        - Record in CXXConstructExpr when the constructor call is to
        initialize a base class, so that CodeGen does not have to infer it
        from context. This ensures that we call the right kind of
        constructor.
      
      There are also a few "opportunity" fixes here that were needed to not
      regress, for example:
      
        - Diagnose default-initialization of a const-qualified class that
          does not have a user-declared default constructor. We had this
          diagnostic specifically for bases and members, but missed it for
          variables. That's fixed now.
      
        - When defining the implicit constructors, destructor, and
          copy-assignment operator, set the CurContext to that constructor
          when we're defining the body.
      
      llvm-svn: 94952
      7ae2d775
Loading