Commit Graph

10953 Commits

Author SHA1 Message Date
John McCall 1553b19067 Restore correct use of GC barriers.
llvm-svn: 133144
2011-06-16 04:16:24 +00:00
Chandler Carruth 30f3210242 Fix my test case from r133136 so that it actually represents the code
pattern found in the wild where this warning was firing.

llvm-svn: 133143
2011-06-16 04:13:47 +00:00
Argyrios Kyrtzidis bdf3ca9186 [arcmt] Fix tests in non-darwin.
llvm-svn: 133140
2011-06-16 02:41:46 +00:00
Chandler Carruth 55b42d5ad4 Add another dependency to the clang-test CMake target, this time to support lit.
llvm-svn: 133138
2011-06-16 02:21:11 +00:00
Chandler Carruth d8bc97c644 Add the new arcmt-test tool to the clang-test dependencies with
c-index-test and friends. This brings the failures on CMake clang tests
from 23 to 2 on Linux.

llvm-svn: 133137
2011-06-16 02:01:48 +00:00
Chandler Carruth a05e09ba48 Skip both character pointers and void pointers when diagnosing bad
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
2011-06-16 02:00:04 +00:00
Andrew Trick f008c3e518 Update clang's lit.site.cfg.in in preparation for adding config.llvm_build_modes.
llvm-svn: 133130
2011-06-16 01:32:21 +00:00
John McCall 17b4c83c91 Make this test pretend to be on a darwin host.
llvm-svn: 133125
2011-06-16 01:18:08 +00:00
John McCall 54507ab83c Weaken the type-matching rules for methods that return aggregates when
complaining about mismatches in the global method pool.

llvm-svn: 133123
2011-06-16 01:15:19 +00:00
Chandler Carruth f8e06c96ca Make the presentation of the warnings on 'x + y ? 1 : 0' a bit more
pretty. In particular this makes it much easier for me to read messages
such as:

  x.cc:42: ?: has lower ...

Where I'm inclined to associate the third ':' with a missing column
number, but in fact column numbers have been turned off. Similar
punctuation collisions happened elsewhere as well.

llvm-svn: 133121
2011-06-16 01:05:12 +00:00
Argyrios Kyrtzidis 6e4ef20baf [arcmt] Make arcmt-test accept cc1 options to make it more portable and hopefully fix MSVC failures.
llvm-svn: 133119
2011-06-16 00:53:46 +00:00
John McCall ada065ff52 Give this test a triple; I don't think we want to #define __unsafe_unretained
on all platforms in non-ARC mode.

llvm-svn: 133114
2011-06-16 00:32:01 +00:00
John McCall d70fb9812a The ARC Migration Tool. All the credit goes to Argyrios and Fariborz
for this.

llvm-svn: 133104
2011-06-15 23:25:17 +00:00
John McCall 31168b077c Automatic Reference Counting.
Language-design credit goes to a lot of people, but I particularly want
to single out Blaine Garst and Patrick Beard for their contributions.

Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself,
in no particular order.

llvm-svn: 133103
2011-06-15 23:02:42 +00:00
Eli Friedman e4ff968f56 Test for r133070.
llvm-svn: 133079
2011-06-15 20:17:07 +00:00
Eli Friedman e2a79e9ce8 Fix a couple more tests with ARM ABI.
llvm-svn: 133073
2011-06-15 18:37:44 +00:00
Eli Friedman 7e68c88bf7 Fix a regression from r132957 involving complex integers. (Fixes failures on gcc-testsuite bot.)
llvm-svn: 133069
2011-06-15 18:26:32 +00:00
Douglas Gregor 39c0272f65 Eliminate a 'default' case in template argument deduction, where we
were just punting on template argument deduction for a number of type
nodes. Most of them, obviously, didn't matter.

As a consequence of this, make extended vector types (via the
ext_vector_type attribute) actually work properly for several
important cases:
  - If the attribute appears in a type-id (i.e, not attached to a
  typedef), actually build a proper vector type
  - Build ExtVectorType whenever the size is constant; previously, we
  were building DependentSizedExtVectorType when the size was constant
  but the type was dependent, which makes no sense at all.
  - Teach template argument deduction to handle
  ExtVectorType/DependentSizedExtVectorType.

llvm-svn: 133060
2011-06-15 16:02:29 +00:00
Douglas Gregor 55462626b6 When performing substitution of default template template parameters
before the template parameters have acquired a proper context (e.g.,
because the enclosing context has yet to be built), provide empty
parameter lists for all outer template parameter scopes to inhibit any
substitution for those template parameters. Fixes PR9643 /
<rdar://problem/9251019>.

llvm-svn: 133055
2011-06-15 14:20:42 +00:00
Jordy Rose 634c12d23f [analyzer] Revise CStringChecker's modelling of strcpy() and strcat():
- (bounded copies) Be more conservative about how much is being copied.
- (str(n)cat) If we can't compute the exact final length of an append operation, we can still lower-bound it.
- (stpcpy) Fix the conjured return value at the end to actually be returned.

This requires these supporting changes:
- C string metadata symbols are still live even when buried in a SymExpr.
- "Hypothetical" C string lengths, to represent a value that /will/ be passed to setCStringLength() if all goes well. (The idea is to allow for temporary constrainable symbols that may end up becoming permanent.)
- The 'checkAdditionOverflow' helper makes sure that the two strings being appended in a strcat don't overflow size_t. This should never *actually* happen; the real effect is to keep the final string length from "wrapping around" in the constraint manager.

This doesn't actually test the "bounded" operations (strncpy and strncat) because they can leave strings unterminated. Next on the list!

llvm-svn: 133046
2011-06-15 05:52:56 +00:00
Douglas Gregor 88336839b9 Don't add redundant FormatAttr, ConstAttr, or NoThrowAttr attributes,
either imlicitly (for builtins) or explicitly (due to multiple
specification of the same attributes). Fixes <rdar://problem/9612060>.

llvm-svn: 133045
2011-06-15 05:45:11 +00:00
Nico Weber 50340d5c87 Build fix attempt.
llvm-svn: 133039
2011-06-15 04:50:13 +00:00
Douglas Gregor 1778b030c0 Properly implement C++0x [stmt.dcl]p3, which requires a scope to be
protected in the case where a variable is being initialized by a
trivial default constructor but has a non-trivial destructor.

llvm-svn: 133037
2011-06-15 03:23:34 +00:00
Nico Weber 0870debb8b Warn on "void f(int a[10]) { sizeof(a); }"
llvm-svn: 133036
2011-06-15 02:47:03 +00:00
Ted Kremenek 70f05fdfee Sema: show shift result in hexadecimal
Change the output for -Wshift-overflow and
-Wshift-sign-overflow to an unsigned hexadecimal. It makes
more sense for looking at bits than a signed decimal does.
Also, change the diagnostic's wording from "overrides"
to "sets".

This uses a new optional argument in APInt::toString()
that adds the '0x' prefix to hexademical numbers.

This fixes PR 9651.

Patch by nobled@dreamwidth.org!

llvm-svn: 133033
2011-06-15 00:54:52 +00:00
Douglas Gregor a860e6aebc Introduce a -cc1-level option to turn off related result type
inference, to be used (only) by the Objective-C rewriter.

llvm-svn: 133025
2011-06-14 23:20:43 +00:00
Ted Kremenek 192ed0b7ee [format strings] correctly suggest correct type for '%@' specifiers. Fixes <rdar://problem/9607158>.
llvm-svn: 133024
2011-06-14 22:56:51 +00:00
Fariborz Jahanian d53eca68f0 Bad table discription of fromat-y2k causes
no-format-y2k turn off -Wformat altogether. 
// rdar://9504680

llvm-svn: 133015
2011-06-14 21:54:00 +00:00
Eli Friedman 50ed150632 Whack a bunch of tests in CodeGenCXX to work on ARM (using ARM ABI). Batch 2 of 3.
llvm-svn: 133011
2011-06-14 21:20:53 +00:00
Chris Lattner 848fa212e8 revert r133003 and fix the bug properly: the issue was that ## in a token
lexer is not a paste operator, it is a normal token.  This fixes a conformance
issue shown here:
http://p99.gforge.inria.fr/c99-conformance/c99-conformance-clang-2.9.html

and it defines away the crash from before.

llvm-svn: 133005
2011-06-14 18:19:37 +00:00
Chris Lattner 07efdfdafa Fix a crash on the testcase in PR9981 / rdar://9486765.
llvm-svn: 133003
2011-06-14 18:12:03 +00:00
Douglas Gregor d1cff77200 When profiling FunctionProtoTypes, don't canonicalize the expression
in a noexcept exception specification because it isn't part of the
canonical type. This ensures that we keep the exact expression written
in the noexcept exception specification, rather than accidentally
"adopting" a previously-written and canonically "equivalent" function
prototype. Fixes PR10087.

llvm-svn: 132998
2011-06-14 16:42:44 +00:00
Nico Weber c5e7386983 Warn on memset(ptr, 0, sizeof(ptr)). Diagnostic wording by Jordy Rose.
llvm-svn: 132996
2011-06-14 16:14:58 +00:00
Jay Foad 0b16695d93 Hyphenate "argument-dependent".
llvm-svn: 132989
2011-06-14 12:59:25 +00:00
Chris Lattner f35de48c90 when compiling in a GNU mode (e.g. gnu99) treat VLAs with a size that can be folded to a constant
as constant size arrays.  This has slightly different semantics in some insane cases, but allows
us to accept some constructs that GCC does.  Continue to be pedantic in -std=c99 and other
modes.  This addressed rdar://8733881 - error "variable-sized object may not be initialized"; g++ accepts same code

llvm-svn: 132983
2011-06-14 06:38:10 +00:00
Chris Lattner 9925ec8bf4 fix rdar://9204520 - Accept int(0.85 * 10) as an initializer in a class member
as an extension.

llvm-svn: 132980
2011-06-14 05:46:29 +00:00
David Majnemer c75d1a1098 Properly diagnose using abstract and incomplete types in va_arg
- Move a test from test/SemaTemplate/instantiate-expr-3.cpp, it did not belong there
- Incomplete and abstract types are considered hard errors

llvm-svn: 132979
2011-06-14 05:17:32 +00:00
Chris Lattner ee7286f02d fix rdar://9546171 - -Wshorten-64-to-32 shouldn't warn on vector bitcasts.
llvm-svn: 132975
2011-06-14 04:51:15 +00:00
Jordy Rose bc7483f505 [analyzer] CStringChecker checks functions in the C standard library, not C++. Its external name is now unix.experimental.CString.
llvm-svn: 132958
2011-06-14 01:40:43 +00:00
Eli Friedman eb7fab61bd The LLVM IR representation of byval arguments has a rather strange property: if the alignment of an argument to a call is less than the specified byval alignment for that argument, there is no way to specify the alignment of the implied copy. Therefore, we must ensure that the alignment of the argument is at least the byval alignment. To do this, we have to mess with the alignment of relevant alloca's in some cases, and insert a copy that conceptually shouldn't be necessary in some cases.
This patch tries relatively hard to avoid creating an extra copy if it can be avoided (see test3 in the included testcase), but it is not possible to avoid in some cases (like test2 in the included testcase).

rdar://9483886

llvm-svn: 132957
2011-06-14 01:37:52 +00:00
Jordy Rose d359289669 [analyzer] Fix modeling of strnlen to be more conservative. Move tests we can't properly model (yet?) to string-fail.c.
llvm-svn: 132955
2011-06-14 01:15:31 +00:00
Eli Friedman 51dd0185d6 Make __gnu_inline__ functions in gnu99 mode work the same way as inline functions in gnu89 mode in terms of redefinitions.
rdar://9559708 .

llvm-svn: 132953
2011-06-13 23:56:42 +00:00
Devang Patel b4956a7fac Remote this unreliable test case because it did not do its job.
llvm-svn: 132948
2011-06-13 23:14:35 +00:00
Eli Friedman a526f275e3 Whack a bunch of tests in CodeGenCXX to work on ARM (using ARM ABI). Batch 1 of 3 or so.
llvm-svn: 132945
2011-06-13 22:51:21 +00:00
Douglas Gregor c9224d6714 Eliminate the -f[no]objc-infer-related-result-type flags; there's no
reason to allow the user to control these semantics through a flag.

llvm-svn: 132919
2011-06-13 16:42:53 +00:00
Fariborz Jahanian bf31c4e4ca Update Indexer test for new 'atomic' keyword.
llvm-svn: 132918
2011-06-13 16:42:02 +00:00
David Majnemer 254a5c07e7 Give a diagnostic when using non-POD types in a va_arg
llvm-svn: 132905
2011-06-13 06:37:03 +00:00
David Majnemer 0ac67fa22f Improve the diagnostics generated for switch statements missing expressions
- Move the diagnostic to the case statement instead of at the end of the switch
- Add a fix-it hint as to how to fix the compilation error

llvm-svn: 132903
2011-06-13 05:50:12 +00:00
Richard Smith 4a4beec7b0 Don't assert on initialized typedef declarations in classes:
struct {
    typedef int A = 0;
  };

According to the C++11 standard, this is not ill-formed, but does not have any ascribed meaning. We can't reasonably accept it, so treat it as ill-formed.

Also switch C++ from an incorrect 'fields can only be initialized in constructors' diagnostic for this case to C's 'illegal initializer (only variables can be initialized)'

llvm-svn: 132890
2011-06-12 11:43:46 +00:00
Richard Smith e4073e0ae1 Test for C++11 [class]p6 (trivial classes).
llvm-svn: 132889
2011-06-12 09:24:32 +00:00