Commit Graph

14816 Commits

Author SHA1 Message Date
Kaelyn Uhrain 864d0b002c Suggest adding 'typename' when it would make the compiler
accept the template argument expression as a type.

llvm-svn: 157085
2012-05-18 23:42:49 +00:00
Anna Zaks 457ace7611 [analyzer] Fix a c++11 crash: xvalues can be locations (VisitMemberExpr)
llvm-svn: 157082
2012-05-18 22:47:43 +00:00
Fariborz Jahanian d945ce5fb7 objc: use "class extension" instead of "continuation class"
to match documentation. // rdar://11309706

llvm-svn: 157074
2012-05-18 21:22:49 +00:00
Rafael Espindola 3619104239 Centralize the handling of the "attribute declaration must precede definition"
warning. This also makes us warn on tags, which, ironically, is the only case
gcc warns on.

llvm-svn: 157039
2012-05-18 01:47:00 +00:00
Anna Zaks 46d01605ee [analyzer]Malloc: refactor and report use after free by memory
allocating functions.

llvm-svn: 157037
2012-05-18 01:16:10 +00:00
Fariborz Jahanian b4bef15ae6 Another test for r157025 <rdar://problem/11460990>.
llvm-svn: 157034
2012-05-18 00:19:25 +00:00
Douglas Gregor 0bf70f4be8 A selector match between two Objective-C methods does *not* guarantee
that the methods have the same number of parameters, although we
certainly assumed this in many places. Objective-C can be insane
sometimes. Fixes <rdar://problem/11460990>.

llvm-svn: 157025
2012-05-17 23:13:29 +00:00
Douglas Gregor c5928afb69 In the override search for Objective-C methods, protect against ASTs that have NULL interfaces behind a category, which can happen in invalid code. Fixes <rdar://problem/11478173>, a recent regression
llvm-svn: 157021
2012-05-17 22:39:14 +00:00
Argyrios Kyrtzidis 3d6439517c [arcmt] Remove the "it is not safe to remove an unused 'autorelease' message" ARC
migration error.

This is more trouble that it is worth; autoreleasing a value without holding on it
is a valid use-case, we should not "punish" correct code for the minority of
broken/fragile programs that depend on the behavior of  -autorelease.

rdar://9914061

llvm-svn: 156999
2012-05-17 18:16:05 +00:00
Matt Beaumont-Gay 32d825a4db Use the argument location instead of the format string location when warning
about argument type mismatch.

This gives a nicer diagnostic in cases like
  printf(fmt,
         i);
where previously the snippet just pointed at 'fmt' (with a note at the
definition of fmt).

It's a wash for cases like
  printf("%f",
         i);
where previously we snippeted the offending portion of the format string,
but didn't indicate which argument was at fault.

llvm-svn: 156968
2012-05-17 00:03:16 +00:00
Argyrios Kyrtzidis fbb2bb5a3d [libclang/AST] When declaring a local class, don't neglect to set the end location
of the DeclStmt node, otherwise libclang will not work for anything inside that
class.

rdar://10837710

llvm-svn: 156966
2012-05-16 23:49:15 +00:00
Richard Smith 109d5ed96d Recover better from a missing 'typename' in a function template definition.
Disambiguate past such a potential problem, and use the absence of 'typename'
to break ties in favor of a parenthesized thingy being an initializer, if
nothing else in the declaration disambiguates it as declaring a function.

llvm-svn: 156963
2012-05-16 23:40:17 +00:00
NAKAMURA Takumi 01152f9c63 clang/test/Tooling: Remark as XFAIL again in 5 tests for msvc hosts.
FIXME: JSON doesn't like path separator '\', on Win32 hosts.
llvm-svn: 156957
2012-05-16 22:14:14 +00:00
Akira Hatanaka b08cb81f37 XFAIL this test on MIPS.
Since r156650, clang has stopped emitting byval arguments for MIPS targets.

llvm-svn: 156954
2012-05-16 22:06:47 +00:00
Chad Rosier c14ded7182 Rename the driver option to -mno-implicit-float, per Eli's suggestion.
llvm-svn: 156950
2012-05-16 21:19:55 +00:00
Jordy Rose ea8f0319dc Add triples for test.
llvm-svn: 156949
2012-05-16 21:13:36 +00:00
Chad Rosier f1985d2a44 [driver] Allow the driver to directly accept the -no-implicit-float option, so that the
generation of implicit floating point instructions can be disable for ARM. 
rdar://11409142

llvm-svn: 156942
2012-05-16 20:40:09 +00:00
Jordy Rose 5934226067 [analyzer] Fix test for PR12206, which was failing on i386.
llvm-svn: 156941
2012-05-16 20:29:44 +00:00
Douglas Gregor 6cda0715c3 Add _alignof and __builtin_alignof as aliases for __alignof in
Microsoft mode, from Will Wilson!

llvm-svn: 156940
2012-05-16 20:04:05 +00:00
Chad Rosier e2d8fbbbf1 Tweek r156937 a bit so that the suggestions are correct.
llvm-svn: 156938
2012-05-16 19:42:03 +00:00
Chad Rosier 286852a10c Warn about -Wno-foo where foo is an unknown warning option. This is helpful
for subtle misspellings such as -Wno-unused-command-line-arguments instead of
-Wno-unused-command-line-argument.

Also fix the diagnostic messages to properly handle -Wno- options.  Previously,
the positive version was always emitted (i.e., -Wfoo was emitted for -Wno-foo).
rdar://11461500

llvm-svn: 156937
2012-05-16 19:28:02 +00:00
Richard Trieu 2f7dc46a58 Move the warnings for extra semi-colons under -Wextra-semi. Also, added
a warning for an extra semi-colon after function definitions.  Added logic
so that a block of semi-colons on a line will only get one warning instead
of a warning for each semi-colon.

llvm-svn: 156934
2012-05-16 19:04:59 +00:00
Anna Zaks f8be8595ae [analyzer] Revert a regression committed in r156920.
This breaks the build with -triple i386-apple-darwin9.

llvm-svn: 156932
2012-05-16 18:46:25 +00:00
NAKAMURA Takumi faf78d5665 clang/test/Tooling: Remove XFAIL in 5 tests to unveil the real failure.
FYI, they can pass on Cygwin w/o any tweaks.

llvm-svn: 156930
2012-05-16 17:38:04 +00:00
NAKAMURA Takumi fe3fa7867e clang/test/Tooling/clang-check-pwd.cpp: Add "REQUIRES: shell".
This passes on MSYS bash and Cygwin.

llvm-svn: 156929
2012-05-16 17:37:56 +00:00
Douglas Gregor a8182f9b66 Clean up r156925, so that we only mark the capturing DeclRefExpr of a
lambda as referring to a local in an enclosing scope if we're in the
enclosing scope of the lambda (not it's function call operator). Also,
turn the test into an IR generation test, since that's where the
crashes occurred. Really fixes PR12746 / <rdar://problem/11465120>.

llvm-svn: 156926
2012-05-16 17:01:33 +00:00
Douglas Gregor 26b51746ec Fix code generation of variables reference expressions when mixing
blocks and lambdas, based heavily on a patch from Meador Inge. Fixes
PR12746 / <rdar://problem/11465120>.

llvm-svn: 156925
2012-05-16 16:50:20 +00:00
Douglas Gregor c48eafea50 Fix ASTReader handling of ImportDecls, from Meador Inge!
llvm-svn: 156923
2012-05-16 16:31:58 +00:00
Jordy Rose 09e7c88940 [analyzer] Fix RUN lines for old XFAIL tests, one of which actually works.
llvm-svn: 156921
2012-05-16 16:01:14 +00:00
Jordy Rose 6d5a8caac3 [analyzer] Convert many existing tests to use clang_analyzer_eval.
llvm-svn: 156920
2012-05-16 16:01:10 +00:00
Jordy Rose 31ae259a41 [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).

llvm-svn: 156919
2012-05-16 16:01:07 +00:00
Douglas Gregor 9841df655e Produce more useful 'duplicate case' diagnostics. Fixes PR9243, from Terry Long!
llvm-svn: 156904
2012-05-16 05:32:58 +00:00
David Blaikie a5696dff5c 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)

Reported by Nico Weber as feedback to r156826.

llvm-svn: 156901
2012-05-16 04:20:04 +00:00
Rafael Espindola 96e6824c31 Fix the visibility of instantiations of static data members.
Fixes pr12835.

llvm-svn: 156897
2012-05-16 02:10:38 +00:00
Argyrios Kyrtzidis 8154147942 [objcmt] Accept char arrays for rewriting to @() syntax.
Part of rdar://11438360

llvm-svn: 156880
2012-05-16 00:21:21 +00:00
Anna Zaks 7a0d86be26 [analyzer] Add a test for dead stores, which uses OpaqueValExpr.
llvm-svn: 156875
2012-05-15 23:12:53 +00:00
Fariborz Jahanian 0ebc0fa974 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

llvm-svn: 156871
2012-05-15 22:37:04 +00:00
Anna Zaks 58d986c866 [analyzer] Fix a regression in ObjCUnusedIVars checker.
We can no longer rely on children iterator to visit all the AST
tree children of an expression (OpaqueValueExpr has no children).

llvm-svn: 156870
2012-05-15 22:31:56 +00:00
Argyrios Kyrtzidis 7bd957c12a [objcmt] Rewrite messages to NSString's stringWithUTF8String:/stringWithCString:
to use the @() boxing syntax.

It will also rewrite uses of stringWithCString:encoding: where the encoding that is
used is NSASCIIStringEncoding or NSUTF8StringEncoding.

rdar://11438360

llvm-svn: 156868
2012-05-15 22:22:10 +00:00
David Blaikie 18e9ac7914 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)

llvm-svn: 156861
2012-05-15 21:57:38 +00:00
Richard Smith fe904f0c9c 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.

llvm-svn: 156856
2012-05-15 21:29:55 +00:00
Richard Smith a952ebbcee Don't use the implicit int rule for error recovery in C++. Instead, try to
disambiguate whether the type name was forgotten or mistyped.

llvm-svn: 156854
2012-05-15 21:01:51 +00:00
Douglas Gregor 9295df0569 Add the Objective-C runtime linking arguments after user-specified
linker arguments. Fixes <rdar://problem/11417441>. 

llvm-svn: 156853
2012-05-15 21:00:27 +00:00
Argyrios Kyrtzidis da6d7679e8 Add documentation about boxing enum types and a codegen test to make
sure we pick up the underlying type, per suggestion by Fariborz.

No functionality change.

llvm-svn: 156851
2012-05-15 20:45:35 +00:00
Argyrios Kyrtzidis 491e4aed31 [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.

Part of rdar://11438360

llvm-svn: 156844
2012-05-15 19:17:49 +00:00
Argyrios Kyrtzidis 8e6951d81b Allow objc @() syntax for enum types.
Previously we would reject it as illegal using a value of
enum type and on ObjC++ it was illegal to use an enumerator
as well.

rdar://11454917

llvm-svn: 156843
2012-05-15 19:17:44 +00:00
Bob Wilson 16d939584b Do not link with Objective-C libraries with -nostdlib or -nodefaultlibs.
<rdar://problem/11433499>

llvm-svn: 156841
2012-05-15 18:57:39 +00:00
Fariborz Jahanian 3da7775a6d objc: avoid duplicate diagnostics on certain type mismatches
between property and its backing ivar.

llvm-svn: 156832
2012-05-15 18:12:51 +00:00
Fariborz Jahanian e1ada58ef4 Remove word 'block' from option and diagnostic I added
in r156825.

llvm-svn: 156831
2012-05-15 17:43:16 +00:00
David Blaikie 7555b6a4e5 Improve some of the conversion warnings to fire on conversion to bool.
Moves the bool bail-out down a little in SemaChecking - so now
-Wnull-conversion and -Wliteral-conversion can fire when the target type is
bool.

Also improve the wording/details in the -Wliteral-conversion warning to match
the -Wconstant-conversion.

llvm-svn: 156826
2012-05-15 16:56:36 +00:00
Fariborz Jahanian 80297b1d90 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

llvm-svn: 156825
2012-05-15 16:33:04 +00:00
Rafael Espindola 7f90b7d4c2 Fix our handling of visibility in explicit template instantiations.
* Don't copy the visibility attribute during instantiations. We have to be able
  to distinguish

 struct HIDDEN foo {};
 template<class T>
 DEFAULT void bar() {}
 template DEFAULT void bar<foo>();

from

 struct HIDDEN foo {};
 template<class T>
 DEFAULT void bar() {}
 template void bar<foo>();

* If an instantiation has an attribute, it takes precedence over an attribute
  in the template.

* With instantiation attributes handled with the above logic, we can now
  select the minimum visibility when looking at template arguments.

llvm-svn: 156821
2012-05-15 14:09:55 +00:00
Richard Smith d72da1513a Further improvement to wording of overload resolution diagnostics, and including
the sole parameter name in the diagnostic in more cases. Patch by Terry Long!

llvm-svn: 156807
2012-05-15 06:21:54 +00:00
Richard Smith 8e4a3868fe 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.

llvm-svn: 156806
2012-05-15 06:15:11 +00:00
Richard Smith 5db7f6cb1e Test file I forgot to 'svn add' in r156802.
llvm-svn: 156805
2012-05-15 05:39:53 +00:00
Richard Smith 9dd6e8f3ac PR12826: Converting an lvalue to an xvalue is a no-op conversion, not an lvalue-to-rvalue conversion.
llvm-svn: 156803
2012-05-15 05:04:02 +00:00
Richard Smith b9e90b13cf 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.

llvm-svn: 156802
2012-05-15 04:39:51 +00:00
John McCall 8b3f5ffb0a 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.

llvm-svn: 156794
2012-05-15 02:01:59 +00:00
Argyrios Kyrtzidis 0bbe94f737 [objcmt] When rewriting to subscripting syntax, make sure we put
the receiver in parentheses when necessary.

Part of rdar://11438360

llvm-svn: 156789
2012-05-14 23:33:49 +00:00
Fariborz Jahanian 16d71bb834 objc: allow typedef'ing an id to a pointer to a c-struct only.
// rdar://11356439

llvm-svn: 156788
2012-05-14 22:48:56 +00:00
Richard Smith b71e73243b 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.)

llvm-svn: 156786
2012-05-14 22:43:34 +00:00
Anna Zaks b4e71e8f58 [analyzer] Fix a crash in templated code which uses blocks.
We should investigate why signature info is not set in this case.

llvm-svn: 156784
2012-05-14 22:38:24 +00:00
Richard Smith 48d5418df8 Slightly generalize FileCheck patterns to unbreak -Asserts builds.
llvm-svn: 156783
2012-05-14 22:06:02 +00:00
Argyrios Kyrtzidis c1dfed6572 [objcmt] When rewriting to array/dictionary literals, add an explicit
cast to 'id' for any argument that requires it.

Part of rdar://11438360.

llvm-svn: 156782
2012-05-14 22:01:53 +00:00
Richard Smith bb653bd5f9 Implement IRGen for C++11's "T{1, 2, 3}", where T is an aggregate and the
expression is treated as an lvalue.

llvm-svn: 156781
2012-05-14 21:57:21 +00:00
Chandler Carruth 94a3201179 Teach the driver on Linux to respect -nodefaultlibs.
Patch from Andrew C. Morrow.

llvm-svn: 156771
2012-05-14 18:31:18 +00:00
Jordy Rose 459d5f62c2 [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).

Fixes PR12807.

llvm-svn: 156769
2012-05-14 17:58:35 +00:00
Jordy Rose 0b9cfa2b06 Test for -fdebugger-objc-literal: missing methods should be generated like missing classes.
llvm-svn: 156746
2012-05-13 20:36:47 +00:00
Rafael Espindola 9869c3a10f Produce a warning for mismatched section attributes. Completest pr9356.
llvm-svn: 156727
2012-05-13 02:42:42 +00:00
Rafael Espindola bac0fdbd0b We were already passing the case in pr9356. Add it to attributes.c to make
sure we don't regress. I will add a warning in a sec.

llvm-svn: 156726
2012-05-13 01:56:10 +00:00
Benjamin Kramer 29c2b4330c 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.

llvm-svn: 156723
2012-05-12 21:10:52 +00:00
Jordy Rose d3fb1773e2 [analyzer] Test case: p->x is the same as p[0].x. (PR7297)
llvm-svn: 156720
2012-05-12 17:32:59 +00:00
Jordy Rose 4af4487ba4 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.)

llvm-svn: 156719
2012-05-12 17:32:56 +00:00
Jordy Rose 890f4577b1 Don't crash on boxed strings when +stringWithUTF8String: is missing.
Also, unify some diagnostics for boxed expressions that have the same form.

Fixes PR12804.

llvm-svn: 156713
2012-05-12 15:53:41 +00:00
Jordy Rose 6393f82b5b [analyzer] RetainCountChecker: track ObjC boxed expression objects.
llvm-svn: 156699
2012-05-12 05:10:43 +00:00
Anna Zaks 3236bad851 [analyzer] Test variable modified types.
llvm-svn: 156664
2012-05-11 23:34:14 +00:00
Anna Zaks 5983aa67d5 [analyzer] Test objC boxing.
llvm-svn: 156660
2012-05-11 23:15:16 +00:00
Anna Zaks 2d10fdd4ec [analyzer] Add buffer overflow test case.
llvm-svn: 156659
2012-05-11 23:15:11 +00:00
Douglas Gregor 4f362c7960 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.

llvm-svn: 156657
2012-05-11 23:01:43 +00:00
Richard Smith 7d847b1ec1 When diagnosing inaccessible temporary destructors in decltype expressions, use
the correct type and the correct source location in the diagnostic. Spotted by
Johannes Schaub!

llvm-svn: 156654
2012-05-11 22:20:10 +00:00
Matt Beaumont-Gay d873508975 Merge branch 'format-string-braced-init'
llvm-svn: 156653
2012-05-11 22:10:59 +00:00
Akira Hatanaka 8ab86cb344 Coerce byval aggregate arguments to integers whose size matches the integer
register size of the target architecture.
 

llvm-svn: 156650
2012-05-11 21:56:58 +00:00
Argyrios Kyrtzidis 45f5118248 The Lexer constructor expects a source location at the start of the
file buffer, not at the start of lexing.

Fixes assertion hit in format diagnostics. rdar://11418366

llvm-svn: 156647
2012-05-11 21:39:18 +00:00
Akira Hatanaka c37eddf7a7 Fix handling of vector return types.
A vector should be returned via the hidden pointer argument except if its size
is equal to or smaller than 16-bytes and the target ABI is N32 or N64.

llvm-svn: 156642
2012-05-11 21:01:17 +00:00
Richard Smith 10ff50d7d8 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!

llvm-svn: 156607
2012-05-11 05:16:41 +00:00
Argyrios Kyrtzidis 74d7f15aed Add a test case for going through typedefs until we reach "BOOL", that NSAPI::isObjCTypedef() is doing.
llvm-svn: 156604
2012-05-11 01:53:27 +00:00
Rafael Espindola 92d49459ab Fix a recent regression with the merging of format attributes.
llvm-svn: 156597
2012-05-11 00:36:07 +00:00
Argyrios Kyrtzidis 6062da47b8 [objc] When boxing a BOOL/NSInteger/NSUInteger type, use the corresponding
numberWithBool:/numberWithInteger:/numberWithUnsignedInteger: NSNumber selectors.

rdar://11428703

llvm-svn: 156583
2012-05-10 23:12:03 +00:00
Anna Zaks fe1ccee0f5 [analyzer] Exit early if constraint solver is given a non-integer symbol
to reason about.

As part of taint propagation, we now allow creation of non-integer
symbolic expressions like a cast from int to float.

Addresses PR12511 (radar://11215362).

llvm-svn: 156578
2012-05-10 21:49:52 +00:00
Argyrios Kyrtzidis 9b4fe35689 Don't crash when using objc boxed expression with parsing error.
rdar://11426994

llvm-svn: 156565
2012-05-10 20:02:36 +00:00
Argyrios Kyrtzidis 671ce47d60 [preprocessor] Make sure that MacroExpands callbacks are always in source order.
Fixes assertion hit in the preprocessing record. rdar://11426523

llvm-svn: 156557
2012-05-10 18:57:19 +00:00
Fariborz Jahanian b6e9b6cfe7 Test for previously checked in patch.
// rdar://11374235

llvm-svn: 156552
2012-05-10 17:05:15 +00:00
Argyrios Kyrtzidis b16ff5d1ce Fix an assertion hit when the serialized diagnostics writer receive a diagnostic
from the frontend when the location is invalid and the SourceManager null.

Instead of keeping the SourceManager object in DiagnosticRenderer, propagate it
to the calls accordingly (as reference when it is expected to not be null, or pointer
when it may be null).
This effectively makes DiagnosticRenderer not tied to a specific SourceManager,
removing a hack from TextDiagnosticPrinter.

rdar://11386874

llvm-svn: 156536
2012-05-10 05:03:45 +00:00
Rafael Espindola a6b3cd493c Warn about visibility attributes in typedefs.
llvm-svn: 156534
2012-05-10 03:01:34 +00:00
Rafael Espindola c67f223c9e Fix an old (2009) FIXME:
// FIXME: This needs to happen before we merge declarations. Then,
// let attribute merging cope with attribute conflicts.

This was already being done for variables, but for functions we were merging
then first and then applying the attributes. To avoid duplicating merging
logic, some of the helpers in SemaDeclAttr.cpp become methods that can
handle merging two attributes in one decl or inheriting attributes from one
decl to another.

With this change we are now able to produce errors for variables with
incompatible visibility attributes or warn about unused dllimports in
variables.

This changes the attribute list iteration back to being in reverse source
code order, as that matches what decl merging does and avoids differentiating
the two cases is the merge*Attr methods.

llvm-svn: 156531
2012-05-10 02:50:16 +00:00
Anna Zaks 62cce9e47d [analyzer] Do not highlight the range of the statement in case of leak.
We report a leak at a point a leaked variable is no longer accessible.
The statement that happens to be at that point is not relevant to the
leak diagnostic and, thus, should not be highlighted.

radar://11178519

llvm-svn: 156530
2012-05-10 01:37:40 +00:00
Fariborz Jahanian 7a055366f2 objective-c. Fixes a 'fixit' where location of
'*' on objective-c class name was misplaced.
// rdar://11311333

llvm-svn: 156517
2012-05-09 21:49:29 +00:00
Nuno Lopes 729e6a056c hopefully fix a bunch of ARM buildbot failures
llvm-svn: 156513
2012-05-09 21:21:49 +00:00
Richard Trieu 43a2fc7b9e Pull some cases of initialization with self-reference warnings out of
-Wconditional-uninitialized into -Wuninitialized.

llvm-svn: 156512
2012-05-09 21:08:22 +00:00
Richard Smith 2f07ad5a70 Push the knowledge that we are parsing a type-id/type-name further into the
parser, and use it to emit better diagnostics in cases where an identifer
can't be looked up as a type name.

llvm-svn: 156508
2012-05-09 20:55:26 +00:00
Richard Smith 3092a3b43c Stop AltiVec parsing from going down the 'implicit int' codepath as part of its
normal parse for token sequences like 'vector pixel foo'. This incidentally also
fixes a couple of wrong-parse issues.

llvm-svn: 156503
2012-05-09 18:56:43 +00:00
Simon Atanasyan ce005eb2c6 Pass a target triple explicitly to check platform specific macros definitions.
That allows to run the tests on all platforms successfully.

llvm-svn: 156500
2012-05-09 18:49:52 +00:00
Chad Rosier 3adc08e1ad Update test case for new default of 3.0
llvm-svn: 156493
2012-05-09 18:23:04 +00:00
Chad Rosier f761fe9d23 [driver] Use the iOS target triple to infer the deployment target.
rdar://11409204

llvm-svn: 156489
2012-05-09 18:09:58 +00:00
Argyrios Kyrtzidis dd83f5e779 [libclang] Add a test for objc boxed expressions.
rdar://11407754

llvm-svn: 156485
2012-05-09 17:46:47 +00:00
Anna Zaks 325520a7b8 [analyzer] Allow pointers to escape through selector callbacks.
llvm-svn: 156481
2012-05-09 17:23:11 +00:00
Fariborz Jahanian 44645837bc Remove this test again which fails the build-bot for reasons yet
unknown to me.

llvm-svn: 156480
2012-05-09 17:18:19 +00:00
Simon Atanasyan 32df72db66 Declare abstract class ArgumentsAdjuster. This abstract interface describes
a command line argument adjuster, which is responsible for command line
arguments modification before the arguments are used to run a frontend action.

Define class ClangSyntaxOnlyAdjuster implements ArgumentsAdjuster interface.
This class converts input command line arguments to the "syntax check only"
variant.

Reviewed by Manuel Klimek.

llvm-svn: 156478
2012-05-09 16:18:30 +00:00
Fariborz Jahanian cbabea83d4 Re-add test for // rdar://11374235
llvm-svn: 156477
2012-05-09 16:15:46 +00:00
Argyrios Kyrtzidis 08f96a9b5e [AST/libclang] Speed up clang_getOverriddenCursors() considerably by reserving a bit
in ObjCMethodDecl to indicate whether the method does not override any other method,
which is the majority of cases.

That way we can avoid unnecessary work doing lookups, especially when PCH is involved.

rdar://11360082

llvm-svn: 156476
2012-05-09 16:12:57 +00:00
Nuno Lopes ddcce0bb90 update calls to objectsize intrinsic to match LLVM r156473
add a test for -fbounds-checking code generation

llvm-svn: 156474
2012-05-09 15:53:34 +00:00
Richard Smith 45855df4c6 Recover properly if a class member declaration starts with a scope specifier
or template-id which can't be parsed.

llvm-svn: 156468
2012-05-09 08:23:23 +00:00
Ted Kremenek 7ebb493375 Teach IsTailPaddedMemberArray() (used by -Warray-bounds) that a FieldDecl may have a Typedef type, and not always a ConstantArrayType.
Fixes <rdar://problem/11387038>.

llvm-svn: 156464
2012-05-09 05:35:08 +00:00
Richard Smith 6f8d2c6c9c A little tweak to the SFINAE condition reporting. Don't say:
candidate template ignored: substitution failed [with T = int]: no type named 'type' in 'std::enable_if<false, void>'

Instead, just say:

  candidate template ignored: disabled by 'enable_if' [with T = int]

... and point at the enable_if condition which (we assume) failed.

This is applied to all cases where the user writes 'typename enable_if<...>::type' (optionally prefixed with a nested name specifier), and 'enable_if<...>' names a complete class type which does not have a member named 'type', and this results in a candidate function being ignored in a SFINAE context. Thus it catches 'std::enable_if', 'std::__1::enable_if', 'boost::enable_if' and 'llvm::enable_if'.

llvm-svn: 156463
2012-05-09 05:17:00 +00:00
Fariborz Jahanian f60f5ee43d Remove thid test for now.
llvm-svn: 156455
2012-05-09 00:27:52 +00:00
Richard Trieu 64c51abf7f Update the SelfReferenceChecker. Refactored some of the visitor methods.
Added support for conditional operators and tightened the exclusion of the
unary operator from all operators to only the address of operator.

llvm-svn: 156450
2012-05-09 00:21:34 +00:00
Fariborz Jahanian 89919ccd17 Modern objective-c translation. Translating default
synthesis of property getter/setters. // rdar://11374235

llvm-svn: 156447
2012-05-08 23:54:35 +00:00
Anna Zaks d0f89283cf [analyzer] We currently do not fully support CompoundLiterals in
RegionStore, so be explicit about it and generate UnknownVal().

This is a hack to ensure we never produce undefined values for a value
coming from a compound value. (The undefined values can lead to
false positives.) 

radar://10127782

llvm-svn: 156446
2012-05-08 23:40:38 +00:00
Nuno Lopes 3d6311d5f7 add -fbounds-checking option.
When enabled, clang generates bounds checks for array and pointers dereferences. Work to follow in LLVM's backend.

OK'ed by Chad; thanks for the review.

llvm-svn: 156431
2012-05-08 22:10:46 +00:00
Ted Kremenek f534e91882 Having RegionStore lower field bindings to raw offsets, just like ElementRegions. This is a bit
disruptive, but it allows RegionStore to better "see" through casts that reinterpret arrays of values
as structs.  Fixes <rdar://problem/11405978>.

llvm-svn: 156428
2012-05-08 21:49:54 +00:00
John McCall 0bd3e404af Bind cleanups after doing l2r conversion on the operand of a
@throw expression;  l2r conversion can introduce new cleanups
in certain cases, like when the expression is an ObjC property
reference of retainable type in ARC.

llvm-svn: 156425
2012-05-08 21:41:25 +00:00
Anna Zaks 66843480a6 [analyzer] SelfInit: Stop tracking self if it's assigned a value we
don't reason about.

Self is just like a local variable in init methods, so it can be
assigned anything like result of static functions, other methods ... So
to suppress false positives that result in such cases, stop tracking the
checker-specific state after self is being assigned to (unless the
value is't being assigned to is either self or conforms to our rules).

This change does not invalidate any existing regression tests.

llvm-svn: 156420
2012-05-08 21:19:21 +00:00
Fariborz Jahanian 9c0c0501e8 modern objc translation. objc_getClass() and objc_getMetaClass()
prototypes should both return  `struct objc_class *`.
// rdar://11375495

llvm-svn: 156418
2012-05-08 20:55:55 +00:00
Eric Christopher c0e7a3d78c The address of a vla is actually complex and requires a dereference.
Part of rdar://11352000

llvm-svn: 156407
2012-05-08 18:56:47 +00:00
Douglas Gregor a5f9c064ec Fix fmin*/fmax* library builtin signatures.
llvm-svn: 156396
2012-05-08 18:29:52 +00:00
Hans Wennborg 967b9cec23 Make -Wformat accept printf("%hhx", c); with -funsigned-char
For "%hhx", printf expects an unsigned char. This makes Clang
accept a 'char' argument for that also when using -funsigned-char.

This fixes PR12761.

llvm-svn: 156388
2012-05-08 17:21:31 +00:00
Ted Kremenek e87b55214b Teach the analyzer about CXXScaleValueInitExpr.
llvm-svn: 156369
2012-05-08 05:13:40 +00:00
Jordy Rose 728be7f6ac [analyzer] Rework both constraint managers to handle mixed-type comparisons.
This involves keeping track of three separate types: the symbol type, the
adjustment type, and the comparison type. For example, in "$x + 5 > 0ULL",
if the type of $x is 'signed char', the adjustment type is 'int' and the
comparison type is 'unsigned long long'. Most of the time these three types
will be the same, but we should still do the right thing when the
comparison value is out of range, and wraparound should be calculated in
the adjustment type.

This also re-disables an out-of-bounds test; we were extracting the symbol
from non-additive SymIntExprs, but then throwing away the integer.

Sorry for the large patch; both the basic and range constraint managers needed
to be updated together, since they share code in SimpleConstraintManager.

llvm-svn: 156361
2012-05-08 03:27:16 +00:00
Nuno Lopes 9f5616a005 hopefully unbreak some buildbots
llvm-svn: 156357
2012-05-08 01:54:53 +00:00
Argyrios Kyrtzidis d6560a6384 [libclang] Map 'id'/'Class'/'SEL' to the corresponding CXType kinds.
rdar://11357807

llvm-svn: 156352
2012-05-08 01:22:12 +00:00
Douglas Gregor 0ee5df8264 Robustify test
llvm-svn: 156349
2012-05-08 00:29:04 +00:00
Douglas Gregor d6225d304e Introduce a new libclang API to determine the platform availability of
a given entity, so that we can tell when the entity was
introduced/deprecated/obsoleted on each platform for which we have an
annotation. Addresses <rdar://problem/11365715>.

llvm-svn: 156347
2012-05-08 00:14:45 +00:00
Ted Kremenek ececf9f0ae Teach the static analyzer that NSLog() and friends do not hold on to object references (thus extending their lifetime).
llvm-svn: 156346
2012-05-08 00:12:09 +00:00
Rafael Espindola 3c9d9479b0 Process attributes in the order they appear in the source code. This make clang
match gcc behavior for two conflicting visibilities in the same decl. It also
makes handling of dllimport/dllexport more natural.

As a bonus we now warn on the dllimport in

void __attribute__((dllimport)) foo13();
void __attribute__((dllexport)) foo13();

as does gcc.

llvm-svn: 156343
2012-05-07 23:58:18 +00:00
Anna Zaks 590c7bc12e [analyzer]Turn on MallocSizeOfChecker by default; shorten the diagnostic
llvm-svn: 156341
2012-05-07 23:30:29 +00:00
Chandler Carruth 4496c44e5f Remove the 'intrin.h' builtin header file and its tests for now.
After discussion with several people, including Doug Gregor, we've
decided to change our approach here. If you have questions about this
header file, the commit removing it, etc., please reach out to me
off-list.

llvm-svn: 156322
2012-05-07 20:46:58 +00:00
Nuno Lopes f4c7679f35 make this test a little more useful. I'll add more tests for bound checking once -fbounds-checking patch gets in
llvm-svn: 156321
2012-05-07 20:23:03 +00:00
Anna Zaks 386e832c07 [analyzer] Fix a crash in triggered by OSAtomicChecker.
SValBuilder should return an UnknownVal() when comparison of int and ptr
fails. Previous to this commit, it went on assuming that we are dealing
with pointer arithmetic.

PR12509, radar://11390991

llvm-svn: 156320
2012-05-07 19:40:49 +00:00
Douglas Gregor 8a59a957fb Revert r156097, which appears to be causing some breakage.
llvm-svn: 156304
2012-05-07 14:17:47 +00:00
Manuel Klimek 805d8dc52a Fixes resolution of relative paths when running clang tools.
The chdir is not the perfect fix, as it is thread hostile. The
real fix will be to make -working-dir work correctly, which will
take time to implement. Before that, the tooling library cannot
be used concurrently.

llvm-svn: 156299
2012-05-07 09:17:48 +00:00
Richard Smith 9ca6461f5a When we suppress an error due to SFINAE, stash the diagnostic away with the
overload candidate, and include its message in any subsequent 'candidate not
viable due to substitution failure' note we may produce.

To keep the note small (since the 'overload resolution failed' diagnostics are
often already very verbose), the text of the SFINAE diagnostic is included as
part of the text of the note, and any notes which were attached to it are
discarded.

There happened to be spare space in OverloadCandidate into which a
PartialDiagnosticAt could be squeezed, and this patch goes to lengths to avoid
unnecessary PartialDiagnostic copies, resulting in no slowdown that I could
measure. (Removal in passing of some PartialDiagnostic copies has resulted in a
slightly smaller clang binary overall.) Even on a torture test, I was unable to
measure a memory increase of above 0.2%.

llvm-svn: 156297
2012-05-07 09:03:25 +00:00
John McCall 6347b68fd9 Change how we suppress access control in explicit instantiations
so that we actually accumulate all the delayed diagnostics.  Do
this so that we can restore those diagnostics to good standing
if it turns out that we were wrong to suppress, e.g. if the
tag specifier is actually an elaborated type specifier and not
a declaration.

llvm-svn: 156291
2012-05-07 06:16:58 +00:00
Aaron Ballman 5f299dd827 Updating the test case based on previous patch
llvm-svn: 156275
2012-05-07 01:10:33 +00:00
Richard Smith e2648bac3a A union can have a constexpr defaulted default constructor, if it has an
in-class initializer for one of its fields. Value-initialization of such
a type should use the in-class initializer!

The former was just a bug, the latter is a (reported) standard defect.

llvm-svn: 156274
2012-05-07 01:07:30 +00:00
Aaron Ballman ea03214a5e Detecting illegal instantiations of abstract types when using a function-style cast. Fixed PR12658.
llvm-svn: 156271
2012-05-07 00:02:00 +00:00
Jordy Rose 54569448f8 [analyzer] Reduce parallel code paths in SimpleSValBuilder::evalBinOpNN, and handle mixed-type operations more generally.
The logical change is that the integers in SymIntExprs may not have the same type as the symbols they are paired with. This was already the case with taint-propagation expressions created by SValBuilder::makeSymExprValNN, but I think those integers may never have been used. SimpleSValBuilder should be able to handle mixed-integer-type SymIntExprs fine now, though, and the constraint managers were already being defensive (though not entirely correct). All existing tests pass.

The logic in evalBinOpNN has been simplified so that conversion is done as late as possible. As a result, most of the switch cases have been reduced to do the minimal amount of work, delegating to another case when they can by substituting ConcreteInts and (as before) reversing the left and right arguments when useful.

Comparisons require special handling in two places (building SymIntExprs and evaluating constant-constant operations) because we don't /know/ the best type for comparing the two values. I've approximated the rules in Sema [C99 6.3.1.8]  but it'd be nice to refactor Sema's actual algorithm into ASTContext.

This is also groundwork for handling mixed-type constraints better than we do now.

llvm-svn: 156270
2012-05-06 23:40:02 +00:00
Rafael Espindola 2d243bfe2f Split mergeAvailabilityAttr out of handleAvailabilityAttr. This is important
for having a uniform logic for adding attributes to a decl. This in turn
is needed to fix the FIXME:

  // FIXME: This needs to happen before we merge declarations. Then,
  // let attribute merging cope with attribute conflicts.
  ProcessDeclAttributes(S, NewFD, D,
                        /*NonInheritable=*/false, /*Inheritable=*/true);

The idea is that mergeAvailabilityAttr will become a method. Once attributes
are processed before merging, it will be called from handleAvailabilityAttr to
handle multiple attributes in one decl:

void f(int) __attribute__((availability(ios,deprecated=3.0),
                           availability(ios,introduced=2.0)));

and from SemaDecl.cpp to handle multiple decls:

void f(int) __attribute__((availability(ios,deprecated=3.0)));
void f(int) __attribute__((availability(ios,introduced=2.0)));

As a bonus, use the new structure to diagnose incompatible availability
attributes added to different decls (see included testcases).

llvm-svn: 156269
2012-05-06 19:56:25 +00:00
Rafael Espindola d8b1b908b5 Put the availability warnings in a group.
llvm-svn: 156261
2012-05-06 16:49:20 +00:00
Richard Smith 99fdf8d418 A conversion operator in a base class shouldn't hide another conversion operator
in the same class, even if they convert to the same type. Fixes PR12712.

llvm-svn: 156247
2012-05-06 00:04:32 +00:00
Argyrios Kyrtzidis a18347eddb Use raw_ostream in TypePrinter and eliminate uses of temporary std::strings.
Part of rdar://10796159

llvm-svn: 156228
2012-05-05 04:20:37 +00:00
Anna Zaks f4c5ea515f [analyzer] RetainCountChecker: Allow objects to escape through callbacks
Fixes radar://10973977.

llvm-svn: 156215
2012-05-04 22:18:39 +00:00
Anna Zaks 7577686a41 [analyzer] One more pointer escape test.
llvm-svn: 156214
2012-05-04 22:18:36 +00:00
Ted Kremenek fd727748bd Explicitly model capturing variables for blocks in the static analyzer. Fixes <rdar://problem/11125868>.
llvm-svn: 156211
2012-05-04 21:48:42 +00:00
Jean-Daniel Dupas 2b7da83759 Inhibit ObjC format warning only in system headers (NSLocalizedString).
Add a test case for the related NSAssert workaround.

llvm-svn: 156205
2012-05-04 21:08:08 +00:00
Anna Zaks 63509fbacc [analyzer]Fixup r156134: Handle the case when FunctionDecl isn't avail.
llvm-svn: 156183
2012-05-04 17:37:16 +00:00
DeLesley Hutchins 5ff430ce06 Thread safety analysis: check for LOCKABLE attribute on base classes.
llvm-svn: 156175
2012-05-04 16:28:38 +00:00
James Molloy 222f27858f Add a predefine __WINT_UNSIGNED__, similar to __WCHAR_UNSIGNED__, and test them both for ARM and X86.
Use this to fully fix Sema/format-strings.c for non-x86 platforms.

Reviewed by Chandler on IRC.

llvm-svn: 156169
2012-05-04 11:23:40 +00:00
James Molloy 3636554b63 Fix handling of wint_t - we can't assume wint_t is purely an integer promotion of wchar_t - they may differ in signedness.
Teach ASTContext about WIntType, and have it taken from TargetInfo like WCharType. Should fix test/Sema/format-strings.c for ARM, with the exception of one subtest which will fail if wint_t and wchar_t are the same size and wint_t is signed, wchar_t is unsigned.

There'll be a followup commit to fix that.

Reviewed by Chandler and Hans at http://llvm.org/reviews/r/8

llvm-svn: 156165
2012-05-04 10:55:22 +00:00
Jean-Daniel Dupas 73d801cd8a Fix -Wlarge-by-value-copy option handling in the driver.
CC1 supports only the joined format.

llvm-svn: 156161
2012-05-04 08:08:37 +00:00
Alexey Samsonov 74a3868dbb This patch adds a new Clang compiler flag "-gline-tables-only".
It reduces the amount of emitted debug information:
1) DIEs in .debug_info have types DW_TAG_compile_unit, DW_TAG_subprogram,
DW_TAG_inlined_subroutine (for opt builds) and DW_TAG_lexical_block only.
2) .debug_str contains only function names.
3) No debug data for types/namespaces/variables is emitted.
4) The data in .debug_line is enough to produce valid stack traces with
function names and line numbers.

Reviewed by Eric Christopher.

llvm-svn: 156160
2012-05-04 07:39:27 +00:00
NAKAMURA Takumi dcb0e394a9 test/PCH/remap-file-from-pch.cpp: Fix expression for DOS pathsep.
llvm-svn: 156153
2012-05-04 03:42:28 +00:00
Richard Trieu 0030f1dbc1 Skip checking for infinite for-loops if there are global or static variables
in the conditional.

llvm-svn: 156148
2012-05-04 03:01:54 +00:00
Argyrios Kyrtzidis 0f7d7ab968 [PCH] Really, pinky swear, fix for PR12689
rdar://11353109

llvm-svn: 156145
2012-05-04 01:49:36 +00:00
Anna Zaks 6ccfcf346d [analyzer] Assume pointer escapes when a callback is passed inside
a struct.

llvm-svn: 156135
2012-05-03 23:50:33 +00:00
Anna Zaks 228f9c7b68 [analyzer] Allow pointers escape through calls containing callback args.
(Since we don't have a generic pointer escape callback, modify
ExprEngineCallAndReturn as well as the malloc checker.)

llvm-svn: 156134
2012-05-03 23:50:28 +00:00
Chandler Carruth b41171b70b Fix non-deterministic iteration order when walking the specializations
of templates by using the newly introduce FoldingSetVector. This
preserves insertion order for all iteration of specializations.

I've also included a somewhat terrifying testcase that rapidly builds up
a large number of functions. This is enough that any system with ASLR
will have non-deterministic debug information generated for the test
case without the fix here as the debug information is generated in part
by walking these specializations.

llvm-svn: 156133
2012-05-03 23:49:05 +00:00
Bob Wilson e31772fc44 Add a test for r156092.
llvm-svn: 156132
2012-05-03 23:38:51 +00:00
Fariborz Jahanian e9863b5c8e objc modern translator: fix up attribute for dynamic property in a category.
// rdar://11095151

llvm-svn: 156127
2012-05-03 23:19:33 +00:00
Fariborz Jahanian f687e7b2ff modern objc translator: support for default property
synthesis translation. // rdar://11374235 - wip.

llvm-svn: 156125
2012-05-03 22:52:13 +00:00
Stephen Canon fdc6c1a461 Add support for full-width 128-bit integer literals.
llvm-svn: 156123
2012-05-03 22:49:43 +00:00
Richard Smith d106a98fe9 Use the standard values for the __cplusplus macro, even when in GNU mode. GCC
dropped its prior behavior of always defining __cplusplus to 1 in GNU mode in
version 4.7.

llvm-svn: 156113
2012-05-03 22:18:20 +00:00
Argyrios Kyrtzidis 6eec06d0d4 [PCH] When validating that the files coming from PCH did not change, also
validate that we didn't override the contents of any of such files.

If this is detected, emit a diagnostic error and recover gracefully
by using the contents of the original file that the PCH was built from.

Part of rdar://11305263

llvm-svn: 156107
2012-05-03 21:50:39 +00:00
Fariborz Jahanian 2e7f638b23 modern objc translator: used size_t in couple
of places. // rdar://11375908

llvm-svn: 156106
2012-05-03 21:44:12 +00:00
Fariborz Jahanian 3dc3669858 modern objc translation. objc_getClass() and objc_getMetaClass()
prototypes should both return  `struct objc_class *`.
// rdar://11375495

llvm-svn: 156097
2012-05-03 20:23:37 +00:00
Jordy Rose 1d4660bc51 [analyzer] When promoting constant integers in a comparison, use the larger width of the two to avoid truncation.
llvm-svn: 156089
2012-05-03 19:05:48 +00:00
Richard Smith 84837d5b5a Add -Wimplicit-fallthrough warning flag, which warns on fallthrough between
cases in switch statements. Also add a [[clang::fallthrough]] attribute, which
can be used to suppress the warning in the case of intentional fallthrough.

Patch by Alexander Kornienko!

The handling of C++11 attribute namespaces in this patch is temporary, and will
be replaced with a cleaner mechanism in a subsequent patch.

llvm-svn: 156086
2012-05-03 18:27:39 +00:00
Anna Zaks b3b56bb960 [analyzer] CString Checker: Do not split the path unless the user
specifically checks for equality to null.

Enforcing this general practice, which keeps the analyzer less
noisy, in the CString Checker. This change suppresses "Assigned value is
garbage or undefined" warning in the added test case.

llvm-svn: 156085
2012-05-03 18:21:28 +00:00
Fariborz Jahanian d5f34f9fee objective-c: warn for properties being default synthesized
under -Wobjc-missing-property-synthesis which must be
opted-in. // rdar://11295716

llvm-svn: 156078
2012-05-03 16:43:30 +00:00
Simon Atanasyan e16a8c8db8 Test case Clang::Driver/debug-options-as.c depends on the integrated assembler. Turn it on explicitly on all platforms by the "-integrated-as" option.
llvm-svn: 156063
2012-05-03 13:57:00 +00:00
Jordy Rose d23232975f [analyzer] Equality ops are like relational ops in that the arguments shouldn't be converted to the result type. Fixes PR12206 and dupe PR12510.
This was probably the original intent of r133041 (also me, a year ago).

llvm-svn: 156062
2012-05-03 07:34:01 +00:00
Jordy Rose cac46e87e9 [analyzer] Fix RUN line and general cleanup for additive folding tests.
llvm-svn: 156061
2012-05-03 07:33:56 +00:00
Argyrios Kyrtzidis 2a5deff59d [PCH] Clear switch case IDs when deserializing a objc method body.
Fixes rdar://11353109 & http://llvm.org/bugs/show_bug.cgi?id=12689

llvm-svn: 156056
2012-05-03 02:26:32 +00:00
Anna Zaks 1655aee1e3 [analyzer] Conjure a symbol to ensure we can identify pointer arithmetic
We need to identify the value of ptr as
ElementRegion (result of pointer arithmetic) in the following code.
However, before this commit '(2-x)' evaluated to Unknown value, and as
the result, 'p + (2-x)' evaluated to Unknown value as well.

int *p = malloc(sizeof(int));
ptr = p + (2-x);

llvm-svn: 156052
2012-05-03 02:13:56 +00:00
Anna Zaks f0e9ca8604 [analyzer] Do not assert on constructing SymSymExpr with diff types.
The resulting type info is stored in the SymSymExpr, so no reason not to
support construction of expression with different subexpression types.

llvm-svn: 156051
2012-05-03 02:13:53 +00:00
Anna Zaks 1d3d51a6e6 [analyzer] Add a complexity bound on history tracking.
(Currently, this is only relevant for tainted data.)

llvm-svn: 156050
2012-05-03 02:13:50 +00:00
Anna Zaks 7124b4b124 [analyzer] Revert the functional part of r155944.
The change resulted in multiple issues on the buildbot, so it's not
ready for prime time. Only enable history tracking for tainted
data(which is experimental) for now.

llvm-svn: 156049
2012-05-03 02:13:46 +00:00
John McCall 26ebbb748b Merge x86-64-abi-sret-vs-2word-struct-param.cpp into the generic
x86_64-arguments.cpp test file and be sure to test the coerced
case as well.  Thanks to Wei-Ren Chen for bringing this test
to my attention.

llvm-svn: 156047
2012-05-03 01:34:46 +00:00
Richard Trieu 2cdcf82396 Fix a note without a SourceLocation.
#define TEST int y; int x = y;
void foo() {
  TEST
}

-Wuninitialized gives this warning:
invalid-loc.cc:4:3: warning: variable 'y' is uninitialized when used here
      [-Wuninitialized]
  TEST
  ^~~~
invalid-loc.cc:2:29: note: expanded from macro 'TEST'
#define TEST int y; int x = y;
                            ^
note: initialize the variable 'y' to silence this warning
1 warning generated.

The second note lacks filename, line number, and code snippet.  This change
will remove the fixit and only point to variable declaration.

invalid-loc.cc:4:3: warning: variable 'y' is uninitialized when used here
      [-Wuninitialized]
  TEST
  ^~~~
invalid-loc.cc:2:29: note: expanded from macro 'TEST'
#define TEST int y; int x = y;
                            ^
invalid-loc.cc:4:3: note: variable 'y' is declared here
  TEST
  ^
invalid-loc.cc:2:14: note: expanded from macro 'TEST'
#define TEST int y; int x = y;
             ^
1 warning generated.

llvm-svn: 156045
2012-05-03 01:09:59 +00:00
Richard Trieu e4348cc26b Add commas to for loop warning to separate variable names.
llvm-svn: 156033
2012-05-02 22:48:45 +00:00
DeLesley Hutchins 90ff4683f7 Thread safety analysis: additional support for smart pointers in lock expressions.
llvm-svn: 156030
2012-05-02 22:18:42 +00:00
Rafael Espindola cd997e02b2 Walk the decls looking for the last one that has an attribute. We do have to walk
them, otherwise we cannot produce an error for both

struct HIDDEN test4; // canonical
struct test4;
struct DEFAULT test4;

and

struct test5; // canonical
struct HIDDEN test5;
struct DEFAULT test5;

llvm-svn: 156016
2012-05-02 20:36:57 +00:00
DeLesley Hutchins d96b46ace2 Thread Safety Analysis: fixed attribute handling for lock_returned attribute.
llvm-svn: 156005
2012-05-02 17:38:37 +00:00
Fariborz Jahanian d7c6777d50 Modern objective-c translation: Fixing couple of bugs
related to laying out ivar structs and accessing non-fragile-ivar
in more compilated cases. // rdar://11323187

llvm-svn: 156004
2012-05-02 17:34:59 +00:00
Benjamin Kramer c242ef245c Driver: Turn the default value for -fmath-errno into a proper target hook and disable it by default on more platforms.
For now -fno-math-errno is the default on BSD-derived platforms (Darwin,
DragonFlyBSD, FreeBSD, NetBSD, OpenBSD). If the default is not right for
your platform, please yell. I only verified the result with the default
compilers on Darwin and FreeBSD.

llvm-svn: 155990
2012-05-02 14:55:48 +00:00
James Molloy cebf75e8ca Fix forwarding of -fpack-struct from driver to CC1, and add a test.
-fpack-struct's handling has changed in CC1 (one of only two flags that needed changing) because the driver treats "-fpack-struct" as a boolean flag, and CC1 (did) treat it as an option with a separated value.

This change causes -fpack-struct=X to be forwarded correctly to -fpack-struct=X instead of erroneously to "-fpack-struct X"

llvm-svn: 155981
2012-05-02 07:56:14 +00:00
Richard Smith 38f7c7bca5 Disable our non-standard delayed parsing of exception specifications. Delaying
the parsing of such things appears to be a conforming extension, but it breaks
libstdc++4.7's std::pair.

llvm-svn: 155975
2012-05-02 01:29:43 +00:00
Ted Kremenek 170641b0e0 Refine analyzer diagnostics by adding an expression "cone-of-influence" to reverse track interesting
values through interesting expressions.  This allows us to map from interesting values in a caller
to interesting values in a caller, thus recovering some precision in diagnostics lost from IPA.

Fixes <rdar://problem/11327497>

llvm-svn: 155971
2012-05-02 00:31:29 +00:00
Anna Zaks 70de772d45 [analyzer] RetainRelease: Self assignment should not suppress a leak
warning.

llvm-svn: 155966
2012-05-02 00:15:40 +00:00
Kaelyn Uhrain 7179205f49 Try harder to recognize hidden tag type names in potential declarations instead
of giving unhelpful errors about undeclared identifers and missing semicolons.

llvm-svn: 155965
2012-05-02 00:11:40 +00:00
Anna Zaks 06be9117bf [analyzer] Fix an assertion failure triggered by the analyzer buildbot.
llvm-svn: 155964
2012-05-02 00:05:23 +00:00