Skip to content
  1. Jun 21, 2011
  2. Jun 20, 2011
  3. Jun 19, 2011
    • Chandler Carruth's avatar
      Add test cases for false positives on -Wnull-arithmetic from Richard · e1db1cf0
      Chandler Carruth authored
      Trieu, and fix them by checking for array and function types as well as
      pointer types.
      
      I've added a predicate method on Type to bundle together the logic we're
      using here: isPointerLikeType(). I'd welcome better names for this
      predicate, this is the best I came up with. It's implemented as a switch
      to be a touch lighter weight than all the chained isa<...> casts that
      would result otherwise.
      
      llvm-svn: 133383
      e1db1cf0
  4. Jun 18, 2011
    • Chandler Carruth's avatar
      Accept no-return stripping conversions for pointer type arguments after · 53e61b05
      Chandler Carruth authored
      deducing template parameter types. Recently Clang began enforcing the
      more strict checking that the argument type and the deduced function
      parameter type (after substitution) match, but that only consideres
      qualification conversions.
      
      One problem with this patch is that we check noreturn conversions and
      qualification conversions independently. If a valid conversion would
      require *both*, perhaps interleaved with each other, it will be
      rejected. If this actually occurs (I'm not yet sure it does) and is in
      fact a problem (I'm not yet sure it is), there is a FIXME to implement
      more intelligent conversion checking.
      
      However, this step at least allows Clang to resume accepting valid code
      we're seeing in the wild.
      
      llvm-svn: 133327
      53e61b05
    • Douglas Gregor's avatar
      Objective-C++ ARC: eliminate the utterly unjustified loophole that · d7357a9b
      Douglas Gregor authored
      silently dropped ownership qualifiers that were being applied to
      ownership-qualified, substituted type that was *not* a substituted
      template type parameter. We now provide a diagnostic in such cases,
      and recover by dropping the added qualifiers.
      
      Document this behavior in the ARC specification.
      
      llvm-svn: 133309
      d7357a9b
    • Douglas Gregor's avatar
      Objective-ARC++: infer template type arguments of · e46db90c
      Douglas Gregor authored
      ownership-unqualified retainable object type as __strong. This allows
      us to write, e.g.,
      
        std::vector<id>
      
      and we'll infer that the vector's element types have __strong
      ownership semantics, which is far nicer than requiring:
      
        std::vector<__strong id>
      
      Note that we allow one to override the ownership qualifier of a
      substituted template type parameter, e.g., given
      
        template<typename T>
        struct X {
          typedef __weak T type;
        };
      
      X<id> is treated the same as X<__strong id>. At instantiation type,
      the __weak in "__weak T" overrides the (inferred or specified)
      __strong on the template argument type, so that we can still provide
      metaprogramming transformations.
      
      This is part of <rdar://problem/9595486>.
      
      llvm-svn: 133303
      e46db90c
  5. Jun 17, 2011
  6. Jun 16, 2011
    • Richard Trieu's avatar
      Add a new warning when a NULL constant is used in arithmetic operations. The... · 701fb36b
      Richard Trieu authored
      Add a new warning when a NULL constant is used in arithmetic operations.  The warning will fire on cases such as:
      
      int x = 1 + NULL;
      
      llvm-svn: 133196
      701fb36b
    • Douglas Gregor's avatar
      Allow comparison between block pointers and NULL pointer · 3e85c9c5
      Douglas Gregor authored
      constants. Fixes PR10145.
      
      llvm-svn: 133179
      3e85c9c5
    • Douglas Gregor's avatar
      Teach the warning about non-POD memset/memcpy/memmove to deal with the · 18739c34
      Douglas Gregor authored
      __builtin_ versions of these functions as well as the normal function
      versions, so that it works on platforms where memset/memcpy/memmove
      are macros that map down to the builtins (e.g., Darwin). Fixes
      <rdar://problem/9372688>.
      
      llvm-svn: 133173
      18739c34
    • Fariborz Jahanian's avatar
      arc: diagnose dereferencing a __weak pointer which may be · 62c72d06
      Fariborz Jahanian authored
      null at any time. // rdar://9612030
      
      llvm-svn: 133168
      62c72d06
    • Douglas Gregor's avatar
      Implement the consistency checking for C++ [temp.deduct.call]p3, which · e65aacb9
      Douglas Gregor authored
      checks that the deduced argument type for a function call matches the
      actual argument type provided. The only place we've found where the
      consistency checking should actually cause template argument deduction
      failure is due to qualifier differences that don't fall into the realm
      of qualification conversions (which are *not* checked when we
      initially perform deduction). However, we're performing the full
      checking as specified in the standard to ensure that no other cases
      exist.
      
      Fixes PR9233 / <rdar://problem/9039590>.
      
      llvm-svn: 133163
      e65aacb9
    • Chandler Carruth's avatar
      Rework the warning for 'memset(p, 0, sizeof(p))' where 'p' is a pointer · 8b9e5a72
      Chandler Carruth authored
      and the programmer intended to write 'sizeof(*p)'. There are several
      elements to the new version:
      
      1) The actual expressions are compared in order to more accurately flag
         the case where the pattern that works for an array has been used, or
         a '*' has been omitted.
      2) Only do a loose type-based check for record types. This prevents us
         from warning when we happen to be copying around chunks of data the
         size of a pointer and the pointer types for the sizeof and
         source/dest match.
      3) Move all the diagnostics behind the runtime diagnostic filter. Not
         sure this is really important for this particular diagnostic, but
         almost everything else in SemaChecking.cpp does so.
      4) Make the wording of the diagnostic more precise and informative. At
         least to my eyes.
      5) Provide highlighting for the two expressions which had the unexpected
         similarity.
      6) Place this diagnostic under a flag: -Wsizeof-pointer-memaccess
      
      This uses the Stmt::Profile system for computing #1. Because of the
      potential cost, this is guarded by the warning flag. I'd be interested
      in feedback on how bad this is in practice; I would expect it to be
      quite cheap in practice. Ideas for a cheaper / better way to do this are
      also welcome.
      
      The diagnostic wording could likely use some further wordsmithing.
      Suggestions welcome here. The goals I had were to: clarify that its the
      interaction of 'memset' and 'sizeof' and give more reasonable
      suggestions for a resolution.
      
      An open question is whether these diagnostics should have the note
      attached for silencing by casting the dest/source pointer to void*.
      
      llvm-svn: 133155
      8b9e5a72
    • Chandler Carruth's avatar
      Skip both character pointers and void pointers when diagnosing bad · a05e09ba
      Chandler Carruth authored
      argument types for mem{set,cpy,move}. Character pointers, much like void
      pointers, often point to generic "memory", so trying to check whether
      they match the type of the argument to 'sizeof' (or other checks) is
      unproductive and often results in false positives.
      
      Nico, please review; does this miss any of the bugs you were trying to
      find with this warning? The array test case you had should be caught by
      the array-specific sizeof warning I think.
      
      llvm-svn: 133136
      a05e09ba
Loading