Jordy Rose [Wed, 16 May 2012 16:01:07 +0000 (16:01 +0000)]
[analyzer] Introduce clang_analyzer_eval for regression test constraint checks.
The new debug.ExprInspection checker looks for calls to clang_analyzer_eval,
and emits a warning of TRUE, FALSE, or UNKNOWN (or UNDEFINED) based on the
constrained value of its (boolean) argument. It does not modify the analysis
state though the conditions tested can result in branches (e.g. through the
use of short-circuit operators).
David Blaikie [Wed, 16 May 2012 04:20:04 +0000 (04:20 +0000)]
Include the correct conversion context locations for condition expressions.
This improves the conversion diagnostics (by correctly pointing to the loop
construct for conversions that may've been caused by the contextual conversion
to bool caused by a condition expression) and also causes the NULL conversion
warnings to be correctly suppressed when crossing a macro boundary in such a
context. (previously, since the conversion context location was incorrect, the
suppression could not be performed)
objective-c: perform strict type checking on property
type and its accessor type and issue error if types
are incompatible, instead of crashing in IRgen.
// rdar://1105153
David Blaikie [Tue, 15 May 2012 21:57:38 +0000 (21:57 +0000)]
Don't warn when NULL is used within a macro but its conversion is outside a macro.
This fixes the included test case & was reported by Nico Weber.
It's a little bit nasty using the difference in the conversion context, but
seems to me like a not unreasonable solution. I did have to fix up the
conversion context for conditional operators (it seems correct to me to include
the context for which we're actually doing the comparison - across all the
nested conditionals, rather than the innermost conditional which might not
actually have the problematic implicit conversion at all) and template default
arguments (this is a bit of a hack, since we don't have the source location of
the '=' anymore, so I just used the start of the parameter - open to
suggestions there)
Richard Smith [Tue, 15 May 2012 21:29:55 +0000 (21:29 +0000)]
If we see a declaration which is either missing a type or has a malformed type,
and the thing we have has a scope specifier, and we're in a context that doesn't
allow declaring a qualified name, then the error is a malformed type, not a
missing type.
[objcmt] Rewrite [NSNumber numberWith*] messages to the new @() boxing syntax.
There are some caveats:
-If an implicit cast (e.g. int -> float for numberWithFloat:) was required, the message
will not get rewritten
-If the message was with numberWithInteger:/numberWithUnsignedInteger:, which are very
commonly used, be more liberal and allow the boxing syntax if the underlying type has
same signedness and will not lose precision.
objective-c nonfragile abi: discourage ivar declarations
in @interface by issuing warning (off by default) under
opt'ed in flag -Winterface-block-ivar. // rdar://10763173
Richard Smith [Tue, 15 May 2012 06:21:54 +0000 (06:21 +0000)]
Further improvement to wording of overload resolution diagnostics, and including
the sole parameter name in the diagnostic in more cases. Patch by Terry Long!
Richard Smith [Tue, 15 May 2012 06:15:11 +0000 (06:15 +0000)]
PR12798: Don't drop part of the nested name specifier when instantiating a
pseudo-destructor expression. This can affect whether virtual dispatch for
the destructor call is bypassed.
Richard Smith [Tue, 15 May 2012 04:39:51 +0000 (04:39 +0000)]
Fold the six functions checking explicitly-defaulted special member functions
into one. These were all performing almost identical checks, with different bugs
in each of them.
This fixes PR12806 (we weren't setting the exception specification for an
explicitly-defaulted, non-user-provided default constructor) and enforces
8.4.2/2's rule that an in-class defaulted member must exactly match the implicit
parameter type.
John McCall [Tue, 15 May 2012 02:01:59 +0000 (02:01 +0000)]
Change the mangling of a ref-qualifier on a function type so that
it is placed in a position which is never ambiguous with a
reference-to-function type. This follows some recent discussion
and ensuing proposal on cxx-abi-dev. It is not necessary to
change the mangling of CV-qualifiers because you cannot
apply CV-qualification in the normal sense to a function type.
It is not necessary to change the mangling of ref-qualifiers on
method declarations because they appear in an unambiguous
location.
In addition, mangle CV-qualifiers and ref-qualifiers on function
types when they occur in positions other than member pointers
(that is, when they appear as template arguments).
This is a minor ABI break with previous releases of clang. It
is not considered critical because (1) ref-qualifiers are
relatively rare, since AFAIK we're the only implementing compiler,
and (2) they're particularly likely to come up in contexts that
do not rely on the ODR for correctness. We apologize for any
inconvenience; this is the right thing to do.
Richard Smith [Mon, 14 May 2012 22:43:34 +0000 (22:43 +0000)]
Recover properly from a redundant 'typename' before a non-nested name. This is
permitted as a Microsoft extension. Patch by William Wilson! (Plus some minor
tweaking by me.)
Jordy Rose [Mon, 14 May 2012 17:58:35 +0000 (17:58 +0000)]
[analyzer] strncpy: Special-case a length of 0 to avoid an incorrect warning.
We check the address of the last element accessed, but with 0 calculating that
address results in element -1. This patch bails out early (and avoids a bunch
of other work at that).
Benjamin Kramer [Sat, 12 May 2012 21:10:52 +0000 (21:10 +0000)]
Add support for __attribute__((hot)) and __attribute__((cold)).
Currently cold functions are marked with the "optsize" attribute in CodeGen
so they are always optimized for size. The hot attribute is just ignored,
LLVM doesn't have a way to express hotness at the moment.
Gregory Szorc [Sat, 12 May 2012 20:49:13 +0000 (20:49 +0000)]
[clang.py] Followup to TranslationUnit refactor
* Document index argument in TranslationUnit.from_source
* Add numeric error code to TranslationUnitSaveError string representation
* Use None instead of [] for default argument value in
TranslationUnit.codeComplete
Jordy Rose [Sat, 12 May 2012 17:32:56 +0000 (17:32 +0000)]
Only check NSArray/NSDictionary boxing method params once.
Once we've found a "good" method, we don't need to check its argument types
again. (Even if we might have later found a "bad" method, we were already
caching the method we first looked up.)
Douglas Gregor [Fri, 11 May 2012 23:01:43 +0000 (23:01 +0000)]
Make sure that we recognize __attribute__((align)) as a synonym for
__attribute__((aligned)). Fixes <rdar://problem/11435441>, a
regression I introduced in r156003. This is the narrow fix; a more
comprehensive fix is coming.
Richard Smith [Fri, 11 May 2012 22:20:10 +0000 (22:20 +0000)]
When diagnosing inaccessible temporary destructors in decltype expressions, use
the correct type and the correct source location in the diagnostic. Spotted by
Johannes Schaub!
Richard Smith [Fri, 11 May 2012 05:16:41 +0000 (05:16 +0000)]
PR11857: When the wrong number of arguments are provided for a function
which expects exactly one argument, include the name of the argument in
the diagnostic text. Patch by Terry Long!
[objc] When boxing a BOOL/NSInteger/NSUInteger type, use the corresponding
numberWithBool:/numberWithInteger:/numberWithUnsignedInteger: NSNumber selectors.
Ted Kremenek [Thu, 10 May 2012 22:02:39 +0000 (22:02 +0000)]
Fix insidious RegionStore bug where we (a) didn't handle vector types and (b) had
a horrible bug in GetLazyBindings where we falsely appended a field suffix when traversing 3 or more
layers of lazy bindings. I don't have a reduced test case yet; but I have added the original source
to an internal regression test suite. I'll see about coming up with a reduced test case.