Sebastian Redl [Sat, 4 Feb 2012 21:27:33 +0000 (21:27 +0000)]
Don't unwrap initializer lists before calling TryConstructorInitialization, instead doing a little more work inside. This should make finding initializer list constructors easier, as well as fix one place where the ({}) vs {} issue was probably poorly handled.
Benjamin Kramer [Sat, 4 Feb 2012 12:31:12 +0000 (12:31 +0000)]
Move various diagnostic operator<< overloads out of line and remove includes of Diagnostic.h.
Fix all the files that depended on transitive includes of Diagnostic.h.
With this patch in place changing a diagnostic no longer requires a full rebuild of the StaticAnalyzer.
Richard Smith [Sat, 4 Feb 2012 09:53:13 +0000 (09:53 +0000)]
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.
Richard Smith [Sat, 4 Feb 2012 07:07:42 +0000 (07:07 +0000)]
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.
Anna Zaks [Sat, 4 Feb 2012 06:40:52 +0000 (06:40 +0000)]
[analyzer] Make sure Containers OutOfBounds checker does not crash on undefined arguments, when CF functions are called with wrong number of arguments.
Richard Smith [Sat, 4 Feb 2012 05:35:53 +0000 (05:35 +0000)]
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.
Sean Callanan [Sat, 4 Feb 2012 01:29:37 +0000 (01:29 +0000)]
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.
Richard Smith [Sat, 4 Feb 2012 00:33:54 +0000 (00:33 +0000)]
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.
Douglas Gregor [Fri, 3 Feb 2012 17:16:23 +0000 (17:16 +0000)]
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.
Douglas Gregor [Fri, 3 Feb 2012 07:34:46 +0000 (07:34 +0000)]
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.
Bob Wilson [Fri, 3 Feb 2012 06:27:22 +0000 (06:27 +0000)]
Fix -ftrap-function fallout from llvm r145714. <rdar://problem/10799325>
That llvm change removed the -trap-func backend option, so that using
-ftrap-function with clang would cause the backend to complain. Fix it
by adding the trap function name to the CodeGenOptions and passing it through
to the TargetOptions.
Change Lexer::makeFileCharRange() to have it accept a CharSourceRange
instead of a SourceRange, and handle the case where the range is
a char (not token) range.
Richard Smith [Fri, 3 Feb 2012 04:45:26 +0000 (04:45 +0000)]
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.
Richard Smith [Fri, 3 Feb 2012 03:30:07 +0000 (03:30 +0000)]
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.
Chad Rosier [Fri, 3 Feb 2012 02:54:37 +0000 (02:54 +0000)]
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.
Eli Friedman [Fri, 3 Feb 2012 02:04:35 +0000 (02:04 +0000)]
Refactor capture in blocks to use new-style capture hooks. Start adding a bit of the code for lambdas. The only visible changes are that we use the C++11 odr-used rules to figure out when a variable is captured, and type-checking in lambdas is slightly more accurate.
Ted Kremenek [Fri, 3 Feb 2012 01:30:34 +0000 (01:30 +0000)]
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.
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
Replace the old --with-cxx-* configure options with a single --with-gcc-toolchain
that just uses the new toolchain probing logic. This fixes linking with -m32 on
64 bit systems (the /32 dir was not being added to the search).
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
Douglas Gregor [Thu, 2 Feb 2012 18:42:48 +0000 (18:42 +0000)]
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.
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
Eli Friedman [Thu, 2 Feb 2012 03:46:19 +0000 (03:46 +0000)]
Split Sema::MarkDeclarationReferenced into multiple functions; the additional entry points are needed to implement C++11 odr-use marking correctly. No functional change in this patch; I'll actually make the change which fixes the odr-use marking in a followup patch.
Anna Zaks [Thu, 2 Feb 2012 01:30:08 +0000 (01:30 +0000)]
[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):
Richard Smith [Thu, 2 Feb 2012 01:16:57 +0000 (01:16 +0000)]
constexpr:
* support the gcc __builtin_constant_p() ? ... : ... folding hack in C++11
* check for unspecified values in pointer comparisons and pointer subtractions
r149474 went a bit too far when combined with type caching. If we want
a full type go ahead and emit it if we currently only have a forward
declaration.
Fixes gdb bots for gdb1090.exp and call-ar-st.exp.
Douglas Gregor [Wed, 1 Feb 2012 21:00:38 +0000 (21:00 +0000)]
Make sure that imported definitions get completed before we add
anything into the corresponding DeclContext. Co-hacked with Sean;
fixes <rdar://problem/10768928>.