Commit Graph

13342 Commits

Author SHA1 Message Date
Richard Smith 2de5a939e2 constexpr: Implement DR1358: An instantiation of a constexpr function which
can't produce a constant expression is not ill-formed (so long as some
instantiation of that function can produce a constant expression).

llvm-svn: 149802
2012-02-05 02:30:54 +00:00
Richard Smith c82fae6070 constexpr: Fix implementation of DR1311: check for volatile qualifiers in
lvalue-to-rvalue conversions on the source type of the conversion, not the
target type (which has them removed for non-class types).

llvm-svn: 149796
2012-02-05 01:23:16 +00:00
Bob Wilson 49708d41a6 Preserve alignment for Neon vld1_lane/dup and vst1_lane intrinsics.
We had been generating load/store instructions with the default alignment
for the vector element type, even when the pointer argument had less alignment.
<rdar://problem/10538555>

llvm-svn: 149794
2012-02-04 23:58:08 +00:00
Bob Wilson 6fb01c2c96 Skip freebsd driver test when ppc32/ppc64 targets are not configured.
Otherwise, the clang driver falls back to invoking gcc and the ppc tests
fail.

llvm-svn: 149793
2012-02-04 23:15:59 +00:00
Fariborz Jahanian 42d05f2faf Also, these objc++ rewriter tests are meant to run in NeXt's
fragile-abi mode.

llvm-svn: 149788
2012-02-04 19:06:06 +00:00
Fariborz Jahanian 27062dd7d2 These tests are intended to run in NeXt's legacy objective-c abi (fragile-abi).
Make this explicit since default is now nonfragile-abi.

llvm-svn: 149787
2012-02-04 18:56:43 +00:00
Richard Smith f4c51d9d76 In C++11 mode, when an integral constant expression is desired and we have a
value of class type, look for a unique conversion operator converting to
integral or unscoped enumeration type and use that. Implements [expr.const]p5.

Sema::VerifyIntegerConstantExpression now performs the conversion and returns
the converted result. Some important callers of Expr::isIntegralConstantExpr
have been switched over to using it (including all of those required for C++11
conformance); this switch brings a side-benefit of improved diagnostics and, in
several cases, simpler code. However, some language extensions and attributes
have not been moved across and will not perform implicit conversions on
constant expressions of literal class type where an ICE is required.

In passing, fix static_assert to perform a contextual conversion to bool on its
argument.

llvm-svn: 149776
2012-02-04 09:53:13 +00:00
Richard Smith 8dd3425077 Don't allow a value of a scoped enumeration to be used as the first bound for an
array new expression. This lays some groundwork for the implicit conversion to
integral or unscoped enumeration which C++11 ICEs undergo.

llvm-svn: 149772
2012-02-04 07:07:42 +00:00
Anna Zaks 88598248f9 [analyzer] Make sure Containers OutOfBounds checker does not crash on undefined arguments, when CF functions are called with wrong number of arguments.
llvm-svn: 149771
2012-02-04 06:40:52 +00:00
Richard Smith 3f333f2edf Disallow constexpr main.
llvm-svn: 149770
2012-02-04 06:10:17 +00:00
Richard Smith bcc9bcb65f Fix a rejects-valid in C++11: array new of a negative size, or overflowing array
new, is well-formed with defined semantics of throwing (a type which can be
caught by a handler for) std::bad_array_new_length, unlike in C++98 where it is
somewhere nebulous between undefined behavior and ill-formed.

If the array size is an integral constant expression and satisfies one of these
criteria, we would previous the array new expression, but now in C++11 mode, we
merely issue a warning (the code is still rejected in C++98 mode, naturally).

We don't yet implement new C++11 semantics correctly (see PR11644), but we do
implement the overflow checking, and (for the default operator new) convert such
expressions to an exception, so accepting such code now does not seem especially
unsafe.

llvm-svn: 149767
2012-02-04 05:35:53 +00:00
Richard Smith 5d8e7593e3 Unbreak failing test added in r149738.
llvm-svn: 149766
2012-02-04 05:33:36 +00:00
Nick Lewycky 96ed7b62f9 Don't warn on use of default allocator with an over-aligned type when the
allocator is given the pointer to allocate into.

llvm-svn: 149760
2012-02-04 03:30:14 +00:00
Anna Zaks 8e009df96e [analyzer] Turn on by default two checkers:
- osx.coreFoundation.containers.IndexOutOfBounds
 - osx.cocoa.SelfInit

llvm-svn: 149747
2012-02-04 02:31:57 +00:00
Anna Zaks 922b86e7e1 [analyzer] fixup to the previous commit.
llvm-svn: 149746
2012-02-04 02:31:53 +00:00
Anna Zaks 00790d9a3b [analyzer] Minor cleanups to the ObjCSelfInitChecker.
(Also renames in other ObjC checkers to create one category of checks.)

llvm-svn: 149745
2012-02-04 02:31:37 +00:00
Sean Callanan 8870a32408 Fixed some testsuite problems introduced by my
last commit.  Sorry for the outage.

llvm-svn: 149744
2012-02-04 02:28:18 +00:00
Nico Weber d1928cb912 Revert r149721. chapuni tells me akyrtzi already fixed the test
by adding a triple, and the typedef makes things worse on windows.

llvm-svn: 149740
2012-02-04 01:50:30 +00:00
Devang Patel c047c4d15b New test case.
llvm-svn: 149738
2012-02-04 01:30:45 +00:00
Sean Callanan 1ce3a6b650 Clang has existing support for debuggers that
want to provide "po"-like functionality which
treats the result of an expression implicitly as
"id" (if it is not otherwise known) and prints
it as an Objective-C object.

This has in the past been gated by the
"DebuggerSupport" language option, but that is
too general.  Debuggers also provide other commands
like "print" that do not make any assumptions
about whether the object is an Objective-C object.

This patch makes the assumption conditional on a
new language option: DebuggerCastResultToId.  I
have also made corresponding modifications to the
testsuite.

llvm-svn: 149735
2012-02-04 01:29:37 +00:00
Eli Friedman 130bbd0302 Suppress the used-but-not-defined warning for static data members while I look into a rather nasty bug in the new odr-use marking code.
llvm-svn: 149731
2012-02-04 00:54:05 +00:00
Richard Smith 74388b4ec0 constexpr:
The recent support for potential constant expressions exposed a bug in the
  implementation of libstdc++4.6, where numeric_limits<int>::min() is defined
  as (int)1 << 31, which isn't a constant expression. Disable the 'constexpr
  function never produces a constant expression' error inside system headers
  to compensate.

llvm-svn: 149729
2012-02-04 00:33:54 +00:00
Devang Patel fb04ece198 Update tests so that they don't rely upon LLVMDebugVersion number.
llvm-svn: 149726
2012-02-03 23:58:39 +00:00
Nico Weber bf5e6442e7 Try to get test passing on windows.
Idea by Jean-Daniel Dupas.

llvm-svn: 149721
2012-02-03 23:36:13 +00:00
Eli Friedman a023e0c619 Make explicit captures which cause implicit captures work correctly.
llvm-svn: 149719
2012-02-03 23:06:43 +00:00
Eli Friedman 24af850470 Implement implicit capture for lambda expressions.
Still left: explicit captures in lambdas need to cause implicit capture, and I need to take a look at the diagnostics for some cases.

llvm-svn: 149718
2012-02-03 22:47:37 +00:00
Douglas Gregor 3dd5fe2006 Make sure that the layout-override parser grabs the size, not the data
size. Otherwise, we can end up with bogus layouts.

llvm-svn: 149703
2012-02-03 19:31:51 +00:00
Douglas Gregor 1f79ca839c When a pack expansion occurs in the template argument list of an alias
template without a corresponding parameter pack, don't immediately
substitute the alias template. This is under discussion in the C++
committee, and may become ill-formed, but for now we match GCC.

llvm-svn: 149697
2012-02-03 17:16:23 +00:00
Argyrios Kyrtzidis e340deedbf Add a triple to test/SemaObjC/format-strings-objc.m to make it pass in windows hosts.
llvm-svn: 149696
2012-02-03 17:13:43 +00:00
Hans Wennborg b64a1fa65c Don't warn about anonymous struct/union in C11.
Also, in C, call this a C11 extension rather than a GNU extension.

llvm-svn: 149695
2012-02-03 15:47:04 +00:00
Douglas Gregor 8e07261362 Implement support for a pack expansion into a fixed-length
template. Such pack expansions can easily fail at template
instantiation time, if the expanded parameter packs are of the wrong
length. Fixes <rdar://problem/10040867>, PR9021, and the example that
came up today at Going Native.

llvm-svn: 149685
2012-02-03 07:34:46 +00:00
Ted Kremenek 60bbeb345b Further downgrade -Warc-bridge-casts-disallowed-in-nonarc to a warning (not mapped to an error). We can consider mapping it back to an error later.
llvm-svn: 149670
2012-02-03 05:01:51 +00:00
Richard Smith 922866783b Thread safety analysis:
* When we detect that a CFG block has inconsistent lock sets, point the
   diagnostic at the location where we found the inconsistency, and point a note
   at somewhere the inconsistently-locked mutex was locked.
 * Fix the wording of the normal (non-loop, non-end-of-function) case of this
   diagnostic to not suggest that the mutex is going out of scope.
 * Fix the diagnostic emission code to keep a warning and its note together when
   sorting the diagnostics into source location order.

llvm-svn: 149669
2012-02-03 04:45:26 +00:00
Richard Smith 815b29d7c9 Thread safety analysis: at a CFG join point between a block terminating in a
'continue' and another block, prefer the lockset from the other block, and
diagnose the 'continue' block as being the end of a loop.

llvm-svn: 149666
2012-02-03 03:30:07 +00:00
Chad Rosier 96c755d13c C++ 5.2.10p2 has a note that mentions that, subject to all other restrictions,
a cast to the same type is allowed so long as it does not cast away constness.

Fix for PR11747. Patch by Aaron Ballman. Reviewed by Eli.

llvm-svn: 149664
2012-02-03 02:54:37 +00:00
Chad Rosier d1956e46dd [frontend] Don't allow a mapping to a warning override an error/fatal mapping.
rdar://10736625

llvm-svn: 149662
2012-02-03 01:49:51 +00:00
Ted Kremenek 172039a89c Make error about using bridge casts in non-ARC mode a warning that is default mapped to an error. This is to ease the transition of large apps moving from non-ARC to ARC.
llvm-svn: 149659
2012-02-03 01:30:34 +00:00
Anna Zaks 5069aa33b9 Do not show macro expansion in strncat warnings, which can be defined as
a builtin.

llvm-svn: 149657
2012-02-03 01:27:37 +00:00
Fariborz Jahanian c934de67e0 objc: Issue diagnostic when receiver type is a forward class declaration and
it is treated as of 'id' type resulting in multiple method lookup.
// rdar://10686120

llvm-svn: 149653
2012-02-03 01:02:44 +00:00
Eli Friedman 3bda6b1f8e Add some code to accurately perform odr-used marking for variables per the C++11 rules.
llvm-svn: 149641
2012-02-02 23:15:15 +00:00
Douglas Gregor 9f93dc7582 Use -isystem rather than relying on -isysroot to work consistently
llvm-svn: 149626
2012-02-02 19:35:15 +00:00
Douglas Gregor ac8a57787f Yet more data from failing buildbots...
llvm-svn: 149624
2012-02-02 19:30:09 +00:00
Fariborz Jahanian 6a73384b53 objective-c: When redeclaraing in continuation class a 'readonly'
property to 'readwrite', also allow redeclaration of
property type to a narrowring object type.
// rdar://10790488

llvm-svn: 149614
2012-02-02 18:54:58 +00:00
Douglas Gregor 510340fdc2 Drop -verify to get better diagnostics from failing buildbots. Plus, we don't need it here
llvm-svn: 149613
2012-02-02 18:54:34 +00:00
Douglas Gregor 3ec6663be0 Back out my heinous hack that tricked the module generation mechanism
into using non-absolute system includes (<foo>)...

... and introduce another hack that is simultaneously more heineous
and more effective. We whitelist Clang-supplied headers that augment
or override system headers (such as float.h, stdarg.h, and
tgmath.h). For these headers, Clang does not provide a module
mapping. Instead, a system-supplied module map can refer to these
headers in a system module, and Clang will look both in its own
include directory and wherever the system-supplied module map
suggests, then adds either or both headers. The end result is that
Clang-supplied headers get merged into the system-supplied module for
the C standard library.

As a drive-by, fix up a few dependencies in the _Builtin_instrinsics
module.

llvm-svn: 149611
2012-02-02 18:42:48 +00:00
Alexander Potapenko ef41fd31d4 Move the code that sets the AddressSafety
attribute into CodeGenModule::SetLLVMFunctionAttributesForDefinition().

Previously it resided in CodeGenModule::GetOrCreateLLVMFunction, which
for some reason wasn't called for ObjC class methods, see
http://code.google.com/p/address-sanitizer/issues/detail?id=33

llvm-svn: 149605
2012-02-02 11:49:28 +00:00
Anton Yartsev 79de4d49a6 r149587 reverted
llvm-svn: 149594
2012-02-02 06:06:34 +00:00
Anton Yartsev 3da212585e Fix for PR10657 (http://llvm.org/bugs/show_bug.cgi?id=10657)
extern inline case considered

llvm-svn: 149587
2012-02-02 05:13:59 +00:00
Anna Zaks 699f55b98c [analyzer] Fix a false positive in the CFArrayCreate check that surfaces
the the code like this (due to x and &x being the same value but
different size):

void* x[] = { ptr1, ptr2, ptr3 };
CFArrayCreate(NULL, (const void **) &x, count, NULL);

llvm-svn: 149579
2012-02-02 01:30:08 +00:00
Richard Smith 84f6dcf2b5 constexpr:
* support the gcc __builtin_constant_p() ? ... : ... folding hack in C++11
  * check for unspecified values in pointer comparisons and pointer subtractions

llvm-svn: 149578
2012-02-02 01:16:57 +00:00