Commit Graph

13870 Commits

Author SHA1 Message Date
Richard Smith 5e0cac784a Reject 'a = {0} = {0}' rather than parsing it as '(a = {0}) = {0}'. Also
improve the diagnostics for some attempts to use initializer lists in
expressions.

llvm-svn: 151794
2012-03-01 02:59:17 +00:00
Ted Kremenek 05e916bc95 Fix regression from llvm-gcc where we should NOT emit a warning about __attribute__((NSObject)) on a property declaration. This is needed to have retain properties for non-object pointers. Fixes <rdar://problem/10930507>.
llvm-svn: 151786
2012-03-01 01:40:32 +00:00
Nico Weber 2c21c449d9 Move suport for redefining operator keywords from -fms-extensions to -fms-compatibility.
llvm-svn: 151776
2012-03-01 00:13:46 +00:00
Nico Weber 2e686205e8 Allow operator keywords to be #defined in ms-ext mode.
Fixes PR10606.

I'm not sure if this is the best way to go about it, but
I locally enabled this code path without the msext conditional,
and all tests pass, except for test/Preprocessor/cxx_oper_keyword.cpp
which explicitly checks that operator keywords can't be redefined.

I also parsed chromium/win with a clang with and without this patch.
It introduced no new errors, but removes 43 existing errors.

llvm-svn: 151768
2012-02-29 22:54:43 +00:00
Fariborz Jahanian 203ea38085 Test for my last patch. // rdar://10267155.
llvm-svn: 151767
2012-02-29 22:21:36 +00:00
Fariborz Jahanian 86c2f5cc70 objective-c: provide fixit hint when atomic property does not
have matching user defined setter/getter and a warning is issued. 
In this case, a fixit note is displayed. // rdar://10267155

llvm-svn: 151766
2012-02-29 22:18:55 +00:00
Chad Rosier ff3f99bf0a I referenced the incorrect rdar in my previous commit (r151745). Add the
correct radar number to the test case for tracking purposes.
rdar://10551066

llvm-svn: 151746
2012-02-29 20:18:57 +00:00
Chad Rosier b1cfc6864f Allocate TargetLibraryInfo for the CodeGen passes. Otherwise, it's instantiated
by the BAA pass, which uses the default TargetLibraryInfo constructor.
Unfortunately, the default TargetLibraryInfo constructor assumes all library
calls are available and thus ignores -fno-builtin.
rdar://10947759

llvm-svn: 151745
2012-02-29 20:14:59 +00:00
Anna Zaks e0c03cab58 [analyzer] Malloc: A pointer might escape through CFContainers APIs,
funopen, setvbuf.

Teach the checker and the engine about these APIs to resolve malloc
false positives. As I am adding more of these APIs, it is clear that all
this should be factored out into a separate callback (for example,
region escapes). Malloc, KeyChainAPI and RetainRelease checkers could
all use it.

llvm-svn: 151737
2012-02-29 18:42:47 +00:00
Daniel Dunbar c2f9dc91c1 Revert r151702, "Add support for handling captured variables in lambda debug
info.", which broke some -O0 -g tests.

llvm-svn: 151730
2012-02-29 16:28:29 +00:00
Sebastian Redl c7b718eb53 Tentatively fix PR12117. The test case from the bug now passes, and all existing tests still pass, but there may still be corner cases.
llvm-svn: 151716
2012-02-29 12:47:43 +00:00
James Molloy 6f8780bed1 Reapply r151638 and r151641.
The bug that was caught by Apple's internal buildbots was valid and also showed another bug in my implementation.

These are now fixed, with regression tests added to catch them both (not Darwin-specific).

Original log:
====================

Revert r151638 because it causes assertion hit on PCH creation for Cocoa.h

Original log:
---------------------
Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped.

This fixes code such as:

enum e {x, y};
int f(enum {y, x} n) {
 return 0;
}

This finally fixes PR5464 and PR5477.
---------------------

I also reverted r151641 which was enhancement on top of r151638.

====================

llvm-svn: 151712
2012-02-29 10:24:19 +00:00
Erik Verbruggen 64aea6524d Remove a recursive visitiation in ExprEngine that is no longer needed
because the CFG is fully linearized.

llvm-svn: 151711
2012-02-29 08:42:57 +00:00
Ted Kremenek ef5c554df4 [analyzer] Tweak the UnreachableCode checker to not warning about unreachable default blocks. Patch by Cyril Roelandt!
llvm-svn: 151709
2012-02-29 06:05:28 +00:00
Eli Friedman e4f22dfa95 A couple minor bug-fixes for template instantiation for expressions which are sometimes potentially evaluated.
llvm-svn: 151707
2012-02-29 04:03:55 +00:00
Argyrios Kyrtzidis 3dbeb55874 [driver] Emit an error when trying to use ARC on macosx earlier than 10.6
rdar://10459258

llvm-svn: 151706
2012-02-29 03:43:52 +00:00
Eric Christopher 3203f6b9da Add support for handling captured variables in lambda debug info.
This currently doesn't handle capturing the 'this' pointer for any
enclosing class.

Steal the lambda-expressions.cpp testcase and debugify it and try
to use more variables to proof it against random changes.

Part of rdar://10900684

llvm-svn: 151702
2012-02-29 03:25:30 +00:00
Eli Friedman c6237c6e05 Make the odr-use logic work correctly for constant-expressions. PR12006.
llvm-svn: 151699
2012-02-29 03:16:56 +00:00
NAKAMURA Takumi 10cea170d2 clang/test/Analysis/stats.c: Fix up r151656.
llvm-svn: 151695
2012-02-29 02:04:39 +00:00
NAKAMURA Takumi f1801d65e7 clang/test/Analysis/stats.c: Mark this as XFAIL: mingw32.
FIXME: Could we guarantee not to get stack overflow also on mingw?
llvm-svn: 151692
2012-02-29 01:50:38 +00:00
Eli Friedman 576cbd03b4 Make sure list-initialization of arrays works correctly in explicit type conversions. PR12121.
llvm-svn: 151674
2012-02-29 00:00:28 +00:00
Argyrios Kyrtzidis fcbfdee5df [libclang] Add a test I forgot to commit.
llvm-svn: 151669
2012-02-28 23:39:24 +00:00
Argyrios Kyrtzidis 5cb4760aed [PCH] Include a darwin-only PCH test on Cocoa.h.
llvm-svn: 151668
2012-02-28 23:39:20 +00:00
Argyrios Kyrtzidis 5929ef2ee7 Revert r151638 because it causes assertion hit on PCH creation for Cocoa.h
Original log:
---------------------
Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped.

This fixes code such as:

enum e {x, y};
int f(enum {y, x} n) {
 return 0;
}

This finally fixes PR5464 and PR5477.
---------------------

I also reverted r151641 which was enhancement on top of r151638.

llvm-svn: 151667
2012-02-28 23:39:14 +00:00
Sebastian Redl 12edeb0899 Single- and zero-element initializer lists to scalars are list-initializations. Fixes PR12118.
llvm-svn: 151666
2012-02-28 23:36:38 +00:00
Fariborz Jahanian 265a421dd9 Modern objective-c translator. rewriting ivars of aggregate type.
llvm-svn: 151662
2012-02-28 22:45:07 +00:00
Anna Zaks 75de32322a [analyzer] Leaks should be uniqued by the allocation point in the
closest function context (RetainCountChecker).

llvm-svn: 151661
2012-02-28 22:39:22 +00:00
Anna Zaks 16f3831064 [analyzer] Retain release: drop the line number info from the leak
message.

llvm-svn: 151657
2012-02-28 21:49:08 +00:00
Anna Zaks b6e2854f68 [analyzer] Stats: Add the stats about remove dead bindings, correct the
test.

llvm-svn: 151656
2012-02-28 21:49:04 +00:00
Chad Rosier 2ad368fce3 [driver] Add support for -g2 and -ggdb debug flags.
rdar://10947759

llvm-svn: 151654
2012-02-28 20:49:04 +00:00
James Molloy 051390fffa Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped.
This fixes code such as:

enum e {x, y};
int f(enum {y, x} n) {
  return 0;
}

This finally fixes PR5464 and PR5477.

llvm-svn: 151638
2012-02-28 18:12:11 +00:00
Eli Friedman 7dff8a68df Basic coverage test for conversion-to-block-pointer for lambda expressions.
llvm-svn: 151616
2012-02-28 03:32:48 +00:00
Anna Zaks 6ca4fd5b88 [analyzer] Leaks should be uniqued by the allocation point in the
closest function context (Keychain API).

llvm-svn: 151613
2012-02-28 03:07:06 +00:00
Anna Zaks 06a77fc1b9 [analyzer] Fix Malloc False Positive (PR 12100)
When allocated buffer is passed to CF/NS..NoCopy functions, the
ownership is transfered unless the deallocator argument is set to
'kCFAllocatorNull'.

llvm-svn: 151608
2012-02-28 01:54:22 +00:00
Ted Kremenek 3bc5372fae [analyzer] teach analyzer about ObjC literals, thus trimming out a false positive with the malloc() checker involving
comparing literal addresses to nil.

Fixes <rdar://problem/10579586>

llvm-svn: 151602
2012-02-28 00:56:05 +00:00
Anna Zaks 43ffba2676 [analyzer] Leaks should be uniqued by the allocation point in the
closest function context. 

This prevents us from uniqueing all leaks from the same allocation
helper. radar://10932226

llvm-svn: 151592
2012-02-27 23:40:55 +00:00
Richard Trieu 9cd797aa3e Fix a test case that was added in r151570. The redirect of output was broken
so no testing was actually done.  Further, the commands produce no output.
The redirection has been fixed and the test has been disabled.

llvm-svn: 151591
2012-02-27 23:40:41 +00:00
Sebastian Redl a235e2d8ad Hack in a loud error for PR12086. Better than a silent miscompile.
llvm-svn: 151586
2012-02-27 23:20:01 +00:00
Argyrios Kyrtzidis 465e137558 When evaluating integer expressions include a check for sub-expressions
depth and error if we exceed a max value, to make sure we avoid a stack overflow.

This is a hacky temporary fix. rdar://10913206.

llvm-svn: 151585
2012-02-27 23:18:37 +00:00
Ted Kremenek 59b10db2bc After numerous requests, have Objective-C 'method declared here' notes mention the actual method. This looks better within an IDE, where text isn't always regurgitated in the presentation of a warning. Fixes radar 10914035.
llvm-svn: 151579
2012-02-27 22:55:11 +00:00
Sebastian Redl aa6feaa7ea Implement a FIXME for conversion sequence distinction. Should fix PR12092.
llvm-svn: 151577
2012-02-27 22:38:26 +00:00
Anna Zaks b028654031 [analyzer] Add -analyzer-stats, which hooks up LLVM stats tracking.
As in http://llvm.org/docs/ProgrammersManual.html#Statistic

llvm-svn: 151570
2012-02-27 21:33:16 +00:00
Eli Friedman 84e6e5cd1a Fix a couple bugs in the way we handle array indexes in array bounds checking. Specifically, make sure we don't ignore explicit casts in indexes, and make sure we use unsigned extension/comparisons on indexes. Fixes <rdar://problem/10916006>.
llvm-svn: 151569
2012-02-27 21:21:40 +00:00
Sebastian Redl 6776673f09 Convert initializer lists to temporaries in CreateBuiltinBinOp. Allows assignment of init lists to built-in types and resolves PR12088.
llvm-svn: 151551
2012-02-27 20:34:02 +00:00
Eli Friedman afa84ae85b Add missing code for compound literals of complex type. <rdar://problem/10938628>
llvm-svn: 151549
2012-02-27 20:26:13 +00:00
Chad Rosier d6a56db7b6 Test case for r151429/r151430, which ensures llvm.lifetime intrinsics are not
being emitted at -O0, but are emitted when optimizations are enabled.

llvm-svn: 151533
2012-02-27 18:45:03 +00:00
Eric Christopher 5bd52c1b3e Make this test a bit more robust for debug info changes.
llvm-svn: 151518
2012-02-27 08:22:57 +00:00
Richard Smith 619ecdc80f Ensure that we delete default constructors in the right cases. Don't delete the
default constructor of a union if it has a const member with no user-provided
default constructor.

llvm-svn: 151516
2012-02-27 06:07:25 +00:00
Richard Smith fa933d1225 Fix decltype crash-on-invalid, if we don't find a matching ')' for an ill-formed
decltype expression.

llvm-svn: 151515
2012-02-27 05:24:00 +00:00
Richard Smith 2fbb3d84a2 Tests for r151508.
llvm-svn: 151509
2012-02-26 23:49:01 +00:00
Benjamin Kramer 6b2dc73d48 Okay, makes sense to change all the occurences to match clang.EXE.
llvm-svn: 151491
2012-02-26 14:55:10 +00:00
Benjamin Kramer 1c45c9c8b0 Allow any file extension for the clang binary in the linux-header-search test.
Turns out this can be .exe or .EXE, depending on the build system.

llvm-svn: 151490
2012-02-26 14:50:31 +00:00
Richard Smith 8e1c932ffb Don't assert when trying to diagnose why a class with a constructor template is
non-trivial.

llvm-svn: 151486
2012-02-26 10:50:32 +00:00
Chandler Carruth df8ae4b949 Add the critical crtbegin.o files necessary for any of the tests in
r151482 and r151484 to work. Sorry about the fallout...

llvm-svn: 151485
2012-02-26 10:46:17 +00:00
Chandler Carruth 2e9d731761 A follow-up to r151482 which added support for powerpc and powerpc64
Debian multiarch libraries, this should in theory add support for those
platform's header search rules. I don't have a system to check this
with, so review appreciated. I've added the corresponding tests
referring to the debian multiarch tree.

We are starting to have a relatively completely tested Linux platform
for header search and library search, with several interesting
peculiarities. We should point people at the debian_multiarch_tree when
suggesting new tests. Folks with Debian systems that can check this for
correctness, it would be much appreciated. The missing chunks I know of
are testing bi-arch peudo-cross-compiling toolchains betwen 32-bit and
64-bit variants of platforms, and the MIPS and ARM Debian toolchains.

llvm-svn: 151484
2012-02-26 09:21:43 +00:00
Richard Smith 921bd20ddd Ensure that we delete destructors in the right cases. Specifically:
- variant members with nontrivial destructors make the containing class's
   destructor deleted
 - check for a virtual destructor after checking for overridden methods in the
   base class(es)
 - check for an inaccessible operator delete for a class with a virtual
   destructor.

Do not try to call an anonymous union field's destructor from the destructor of
the containing class.

llvm-svn: 151483
2012-02-26 09:11:52 +00:00
Chandler Carruth af3c2090b4 Add support for PPC and PPC64 multiarch toolchains on Debain.
Patch from Michel Dänzer, sent our way via Jeremy Huddleston who added
64-bit support. I just added one other place where powerpc64-linux-gnu
was missing (we only had powerpc64-unknown-linux-gnu).

I've also added a tree to test out the debian multiarch stuff. I don't
use debian regularly, so I'm not certain this is entirely accurate. If
anyone wants to check it against a debian system and fix any
inaccuracies, fire away. This way at least folks can see how this is
*supposed* to be tested.

It'd be particularly good to get the Debian MIPS toolchains tested in
this way.

llvm-svn: 151482
2012-02-26 09:03:21 +00:00
Richard Smith 273c4e9d82 Make sure we don't try to produce a definition of an implicitly-deleted function
llvm-svn: 151478
2012-02-26 07:51:39 +00:00
Richard Smith 0d1f3cb1b5 Special members which are defaulted or deleted on their first declaration are
trivial if the implicit declaration would be. Don't forget to set the Trivial
flag on the special member as well as on the class. It doesn't seem ideal that
we have two separate mechanisms for storing this information, but this patch
does not attempt to address that.

This leaves us in an interesting position where the has_trivial_X trait for a
class says 'yes' for a deleted but trivial X, but is_trivially_Xable says 'no'.
This seems to be what the standard requires.

llvm-svn: 151465
2012-02-26 00:31:33 +00:00
Argyrios Kyrtzidis 8d4677ad26 Revert r151460 as it is not enough to address the issue.
Original log:
When evaluating integer expressions handle logical operators outside
VisitBinaryOperator() to reduce stack pressure for source with huge number
of logical operators.

Fixes rdar://10913206.

llvm-svn: 151464
2012-02-25 23:21:37 +00:00
Sebastian Redl aeac3ff82a Richard Smith pointed out that there already is a proposal for init list mangling.
llvm-svn: 151462
2012-02-25 22:59:28 +00:00
Argyrios Kyrtzidis 70f9eb571e When evaluating integer expressions handle logical operators outside
VisitBinaryOperator() to reduce stack pressure for source with huge number
of logical operators.

Fixes rdar://10913206.

llvm-svn: 151460
2012-02-25 21:38:16 +00:00
Sebastian Redl d89c218a2b Initializer lists are now supported.
llvm-svn: 151458
2012-02-25 20:51:27 +00:00
Sebastian Redl 4a7eab2545 CodeGen support for global variables of type std::initializer_list<X>.
This emits a backing array with internal linkage and fills it with data,
then has the initializer_list point at the array. Dynamic initialization
and global destructors are correctly supported.

What doesn't work is nested initializer_lists. I have no idea how to
get them to work, either. However, these should be very rare, and so
I'll just call it a known bug and declare generalized initializers
DONE!

llvm-svn: 151457
2012-02-25 20:51:20 +00:00
Sebastian Redl dadc06494d Better mangling for new-expressions. Also, although we can't mangle arbitrary initializer lists yet (we will need this), turn the crash into a controlled error.
llvm-svn: 151455
2012-02-25 20:51:07 +00:00
Richard Smith 2cca7b5ca9 Accept __has_feature(__feature__) as a synonym for __has_feature(feature) (and
likewise for __has_extension). Patch by Jonathan Sauer!

llvm-svn: 151445
2012-02-25 10:41:10 +00:00
Richard Smith 2a986117e9 Fix r151443 to only apply C++11's exception for non-static data member access
in cases where we would otherwise disallow the access, and add a -Wc++98-compat
diagnostic for this C++11 feature.

llvm-svn: 151444
2012-02-25 10:20:59 +00:00
Richard Smith eae99680e3 PR11956: C++11's special exception for accessing non-static data members from
unevaluated operands applies within member functions, too.

llvm-svn: 151443
2012-02-25 10:04:07 +00:00
Richard Smith 978cc7306c Fix assertion (too few Diag arguments) when diagnosing a deleted operator delete
llvm-svn: 151442
2012-02-25 09:42:26 +00:00
Richard Smith 561fb15801 Teach CXXRecordDecl::hasIrrelevantDestructor to check the base classes and
data members for deleted or user-provided destructors.

Now it's computed in advance, serialize it, and in passing fix all the other
record DefinitionData flags whose serialization was missing.

llvm-svn: 151441
2012-02-25 07:33:38 +00:00
Richard Smith e06a2c1893 Fix a regression from r151117: ADL requires that we attempt to complete any
associated classes, since it can find friend functions declared within them,
but overload resolution does not otherwise require argument types to be
complete.

llvm-svn: 151434
2012-02-25 06:24:24 +00:00
Argyrios Kyrtzidis 335c5a42e9 Don't record nested macro expansions in the preprocessing record,
it can only bring pain when dealing with preprocessor abuse (see: boost).

rdar://10898986

llvm-svn: 151427
2012-02-25 02:41:16 +00:00
Ted Kremenek ef31f376bb RetainCountChecker: don't adjust the retain count when analyzing a ReturnStmt unless we are in the top-level call frame. We can do more later, but this makes the checker self-consistent (and fixes a crash).
llvm-svn: 151426
2012-02-25 02:09:09 +00:00
Argyrios Kyrtzidis 01c047e003 [arcmt] GC migrator: don't try to remove redundant __strong, it does
more harm than good.

Fixes rdar://10522805&10521433

llvm-svn: 151424
2012-02-25 01:57:42 +00:00
Eli Friedman 8a78a58188 Improve the diagnostic in ARC mode when a conditional with an Objective-C type and void* is used. <rdar://problem/10486347>.
llvm-svn: 151416
2012-02-25 00:23:44 +00:00
DeLesley Hutchins 5b330db270 Bugfix: bogus warning -- "invalid use of non-static data member",
when a class is forward declared, and the reference to the data
member in question does not occur within a method body.

llvm-svn: 151413
2012-02-25 00:11:55 +00:00
Douglas Gregor f8ab049f17 Add test for C++ DR899.
llvm-svn: 151411
2012-02-24 23:57:42 +00:00
Anna Zaks 7ac344a48a [analyzer] Malloc: reason about the ObjC messages and C++.
Assume none of the ObjC messages defined in system headers free memory,
except for the ones containing 'freeWhenDone' selector. Currently, just
assume that the region escapes to the messages with 'freeWhenDone'
(ideally, we want to treat it as 'free()').

For now, always assume that regions escape when passed to C++ methods.

llvm-svn: 151410
2012-02-24 23:56:53 +00:00
Douglas Gregor 6073dcab38 Implement C++11 [over.match.copy]p1b2, which allows the use of
explicit conversion functions to initialize the argument to a
copy/move constructor that itself is the subject of direct
initialization. Since we don't have that much context in overload
resolution, we end up threading more flags :(.

Fixes <rdar://problem/10903741> / PR10456. 

llvm-svn: 151409
2012-02-24 23:56:31 +00:00
Eli Friedman cb3785e450 Fix a stupid mistake in r151133. Reported to me by Joerg Sonnenberger.
llvm-svn: 151407
2012-02-24 23:53:49 +00:00
Richard Smith 5e1148e31d Remove FIXME: as Eli points out, the behavior here is now correct.
llvm-svn: 151405
2012-02-24 23:21:24 +00:00
Douglas Gregor 4f283c8b20 For the purposes of building LLVM types, a forward-declared
enumeration type with a fixed underlying type is complete. Fixes
<rdar://problem/10916155>.

llvm-svn: 151403
2012-02-24 22:40:36 +00:00
Richard Smith 324df5564e Back out __decltype warning from r151377: we should either warn on all the GNU
__keywords or none of them.

llvm-svn: 151401
2012-02-24 22:30:04 +00:00
Richard Smith 6365c9138e When checking whether a reference to a variable is an ICE, look at the type of
the declaration, not at the type of the DeclRefExpr, since within a lambda the
DeclRefExpr can be more const than the declaration is.

llvm-svn: 151399
2012-02-24 22:12:32 +00:00
Douglas Gregor 232ee49c7b C++11 [class.ctor]p5 says that
A defaulted default constructor for a class X is defined as deleted if [...]
    -  X is a union and all of its variant members are of const-qualified type.

A pedantic reading therefore says that

 union X { };

has a deleted default constructor, which is both silly and almost
certainly unintended. Pretend as if this this read

    - X is a union with one or more variant members, and all of its
      variant members are of const-qualified type. 

llvm-svn: 151394
2012-02-24 21:25:53 +00:00
Argyrios Kyrtzidis f0fc594be5 [libclang] Add a triple to the test.
llvm-svn: 151386
2012-02-24 19:45:42 +00:00
Fariborz Jahanian 7e75de84bd test for writing modern ivar of struct type.
llvm-svn: 151378
2012-02-24 18:17:50 +00:00
Richard Smith fd3da9358f __decltype is a GNU extension, not a C++11 extension.
llvm-svn: 151377
2012-02-24 18:10:23 +00:00
Fariborz Jahanian 5e6842bfea more objective-c modern translator ivar tests.
llvm-svn: 151376
2012-02-24 18:03:42 +00:00
Douglas Gregor 3a08c1cd3b Two minor, related fixes for template instantiation with blocks:
- Make sure that the block expression is instantiation-dependent if the
    block is in a dependent context
  - Make sure that the C++ 'this' expression gets captured even if we
  don't rebuild the AST node during template instantiation. This would
  also have manifested as a bug for lambdas.

Fixes <rdar://problem/10832617>.

llvm-svn: 151372
2012-02-24 17:41:38 +00:00
Fariborz Jahanian dd5a59baed objc modern translator. Fixes writing of block pointer ivar access.
llvm-svn: 151371
2012-02-24 17:35:35 +00:00
Anna Zaks 18de54b1a6 [analyzer] Run remove dead bindings before each call.
This ensures that we report the bugs associated with symbols going
out of scope in the correct function context.

llvm-svn: 151369
2012-02-24 16:49:46 +00:00
Anna Zaks cdf24a9a5e [analyzer] We were silently stopping exploring the path after
visiting 'return;' statement!

This most likely caused us to skip a bunch of code when analyzing with
inlining.

llvm-svn: 151368
2012-02-24 16:49:41 +00:00
Douglas Gregor 29c42f2a25 Implement a new type trait __is_trivially_constructible(T, Args...)
that provides the behavior of the C++11 library trait
std::is_trivially_constructible<T, Args...>, which can't be
implemented purely as a library.

Since __is_trivially_constructible can have zero or more arguments, I
needed to add Yet Another Type Trait Expression Class, this one
handling arbitrary arguments. The next step will be to migrate
UnaryTypeTrait and BinaryTypeTrait over to this new, more general
TypeTrait class.

Fixes the Clang side of <rdar://problem/10895483> / PR12038.

llvm-svn: 151352
2012-02-24 07:38:34 +00:00
Ted Kremenek 1bf3b04726 Make PathDiagnosticBuilder sensitive to varying LocationContexts, thus fixing a bug in the inlining diagnostics where the wrong location could be used.
llvm-svn: 151349
2012-02-24 07:12:52 +00:00
Ted Kremenek 29cebb377d Remove stray path in test file.
llvm-svn: 151347
2012-02-24 06:01:01 +00:00
Ted Kremenek 60a7820ffe Reapply r151317, but when computing the PathDiagnostic profile and size keep into account the nested structure. Also fix a problem with how
inlining impacted Plist diagnostics, and adjust some ranges in the Plist output due to richer information.

llvm-svn: 151346
2012-02-24 06:00:00 +00:00
David Blaikie b260a2ea2a Fix test for non-block-default platforms.
llvm-svn: 151343
2012-02-24 04:20:32 +00:00
Argyrios Kyrtzidis ffe055a86f [PCH] When keeping track of top-level decls for "targeted deserialization"
make sure we don't mistake ParmVarDecls for top-level decls.

Fixes rdar://10920009.

llvm-svn: 151330
2012-02-24 01:12:38 +00:00
Fariborz Jahanian eee9bca03d Add an ivar test for modern objc abi translator.
llvm-svn: 151316
2012-02-24 00:34:58 +00:00
Fariborz Jahanian 77a9255329 Make test works with FileCheck.
llvm-svn: 151314
2012-02-24 00:29:20 +00:00
Chad Rosier f62290a19b Reapply r151172 - Unwind path cleanup for array new list initializers - with a
test case that only runs on debug builds.

llvm-svn: 151311
2012-02-24 00:13:55 +00:00
Eli Friedman ec52f92db3 Handle "#pragma GCC visibility" in a few more places. Switch over "#pragma pack" to use the same handling that gcc does. Fixes <rdar://problem/10871094> and <rdar://problem/10893316>.
(Hopefully, common usage of these pragmas isn't irregular enough to break our current handling.  Doug has ideas for a more crazy approach if necessary.)

llvm-svn: 151307
2012-02-23 23:47:16 +00:00
Anna Zaks 4b062cb904 [analyzer] KeyChainAPI: unique the leaks by allocation site.
(Very similar to the previous change in malloc.)

llvm-svn: 151297
2012-02-23 22:53:29 +00:00
Fariborz Jahanian 86f8266b9f objective-c++: Type of an objc string literal is NSString, not 'id'.
// rdar://10907410

llvm-svn: 151296
2012-02-23 22:51:36 +00:00
Aaron Ballman 0c84ebb539 Turned on support for __declspecs: noreturn, noinline, nothrow and naked in MS compatibility mode.
llvm-svn: 151295
2012-02-23 22:46:33 +00:00
Jim Grosbach ce398aa03b Update test for r151288
llvm-svn: 151290
2012-02-23 22:12:53 +00:00
Anna Zaks df901a4419 [analyzer] Malloc: unique leak reports by allocation site.
When we find two leak reports with the same allocation site, report only
one of them.

Provide a helper method to BugReporter to facilitate this.

llvm-svn: 151287
2012-02-23 21:38:21 +00:00
Argyrios Kyrtzidis 2e85c5f297 [libclang] Make sure that all top-level decls in a @implementation are
marked as such.

Previously we missed tag declarations; fixes rdar://10902015

llvm-svn: 151283
2012-02-23 21:11:20 +00:00
Fariborz Jahanian e5d9b0b8c8 Test is fixed.
llvm-svn: 151280
2012-02-23 20:43:56 +00:00
Fariborz Jahanian 1e2303379d XFAIL test until I figure out how to make test pass on different platforms.
llvm-svn: 151277
2012-02-23 20:22:21 +00:00
Fariborz Jahanian 7cef65a3b6 Change test again so it passes in build-bot until I can figure out what is
going on.

llvm-svn: 151275
2012-02-23 20:07:38 +00:00
Fariborz Jahanian b96a293a59 fix test for patch in r151268.
llvm-svn: 151272
2012-02-23 18:57:03 +00:00
Fariborz Jahanian 2f0de8bdb9 objective-c default synthesis. classes which adopt protocol properties
must still auto synthesize those propeties which have been redeclared 
in the class. // rdar://10907410

llvm-svn: 151268
2012-02-23 18:21:25 +00:00
Richard Smith c899892485 PR12067: When emitting an evaluated constant structure in C++11 mode, don't
forget the vptrs.

llvm-svn: 151245
2012-02-23 08:33:23 +00:00
Douglas Gregor 1be329d838 Provide the __is_trivially_assignable type trait, which provides
compiler support for the std::is_trivially_assignable library type
trait.

llvm-svn: 151240
2012-02-23 07:33:15 +00:00
Rafael Espindola 8093fdfab1 Two fixes to how we compute visibility:
* Handle some situations where we should never make a decl more visible,
  even when merging in an explicit visibility.

* Handle attributes in members of classes that are explicitly specialized.

Thanks Nico for the report and testing, Eric for the initial review, and dgregor
for the awesome test27 :-)

llvm-svn: 151236
2012-02-23 04:17:32 +00:00
Douglas Gregor 34b2e8bb17 Clang now supports lambda expressions.
llvm-svn: 151231
2012-02-23 03:02:32 +00:00
Eli Friedman 91f5ae5022 Try to handle qualifiers more consistently for array InitListExprs. Fixes <rdar://problem/10907510>, and makes the ASTs a bit more self-consistent.
(I've chosen to keep the qualifiers, but it isn't a strong preference; if anyone prefers removing them, please yell.)

llvm-svn: 151229
2012-02-23 02:25:10 +00:00
Richard Smith 1e3b0f0614 Update parser's disambiguation to cope with braced function-style casts in
C++11, and with braced-init-list initializers in conditions. This exposed an
ambiguity with enum underlying types versus bitfields, which we resolve by
treating 'enum E : T {' as always defining an enumeration (even if it would
only successfully parse as a bitfield). This appears to be g++ compatible.

llvm-svn: 151227
2012-02-23 01:36:12 +00:00
Aaron Ballman 96e7c09cad Turned on support for __declspec(deprecated) in MS compatibility mode.
llvm-svn: 151225
2012-02-23 01:19:31 +00:00
Anna Zaks 07de9c12f3 [analyzer] Invalidate the region passed to pthread_setspecific() call.
Make this call an exception in ExprEngine::invalidateArguments:
'int pthread_setspecific(ptheread_key k, const void *)' stores
a value into thread local storage. The value can later be retrieved
with 'void *ptheread_getspecific(pthread_key)'. So even thought the
parameter is 'const void *', the region escapes through the
call.

(Here we just blacklist the call in the ExprEngine's default
logic. Another option would be to add a checker which evaluates
the call and triggers the call to invalidate regions.)

Teach the Malloc Checker, which treats all system calls as safe about
the API.

llvm-svn: 151220
2012-02-23 01:05:27 +00:00
Fariborz Jahanian 77171d343b another test for modern ivar access rewrite.
llvm-svn: 151208
2012-02-22 22:32:05 +00:00
Chad Rosier 1a3c3d4537 Revert r151172: Unwind path cleanup for array new list initializers.
llvm-svn: 151203
2012-02-22 21:36:06 +00:00
Fariborz Jahanian 31ebebfb58 more tests for modern objc translator.
llvm-svn: 151201
2012-02-22 21:13:49 +00:00
Anna Zaks 40a7eb3837 [analyzer] Malloc cleanup:
- We should not evaluate strdup in the Malloc Checker, it's the job of
CString checker, so just update the RefState to reflect allocated
memory.

- Refactor to reduce LOC: remove some wrapper auxiliary functions, make
all functions return the state and add the transition in one place
(instead of in each auxiliary function).

llvm-svn: 151188
2012-02-22 19:24:52 +00:00
Joerg Sonnenberger 17d7551e73 Revert part of r148839 and keep DefaultTargetTriple in the form adjusted
by -target and similar options. As discussed in PR 12026, the change
broke support for target-prefixed tools, i.e. calling x86_64--linux-ld
when compiling for x86_64--linux. Improve the test cases added
originally in r149083 to not require execution, just executable files.
Document the hack with appropiate FIXME comments.

llvm-svn: 151185
2012-02-22 19:15:16 +00:00
Fariborz Jahanian 5e49eb95b5 modern objc translator. more writing of modern ivar access
abi.

llvm-svn: 151176
2012-02-22 18:13:25 +00:00
Sebastian Redl 74b173e5c8 Doug's review comments.
llvm-svn: 151173
2012-02-22 17:38:04 +00:00
Sebastian Redl 674c77e555 Unwind path cleanup for array new list initializers.
llvm-svn: 151172
2012-02-22 17:37:59 +00:00
Sebastian Redl f862eb6a9f CodeGen for array new list initializers. Doesn't correctly clean up in the face of exceptions yet.
llvm-svn: 151171
2012-02-22 17:37:52 +00:00
Douglas Gregor 2837aa2932 Teach overload resolution to prefer user-defined conversion via a
lambda closure type's function pointer conversion over user-defined
conversion via a lambda closure type's block pointer conversion,
always. This is a preference for more-standard code (since blocks
are an extension)  and a nod to efficiency, since function pointers
don't require any memory management. Fixes PR12063.

llvm-svn: 151170
2012-02-22 17:32:19 +00:00
Sebastian Redl eef474ce1b Fix parsing and processing initializer lists in return statements and as direct member initializers.
llvm-svn: 151155
2012-02-22 10:50:08 +00:00
Hans Wennborg c9dd946852 Warn about non-standard format strings (pr12017)
This adds the -Wformat-non-standard flag (off by default,
enabled by -pedantic), which warns about non-standard
things in format strings (such as the 'q' length modifier,
the 'S' conversion specifier, etc.)

llvm-svn: 151154
2012-02-22 10:17:01 +00:00
Sebastian Redl e7c31a9a22 Throw away stray CXXDefaultArgExprs. Fixes PR12061.
I think there's a deeper problem here in the way TransformCXXConstructExpr works, but I won't tackle it now.

llvm-svn: 151146
2012-02-22 09:07:21 +00:00
Francois Pichet e6664762ec In -fdelayed-template-parsing mode, reenter every scope when late parsing a templated function; (Not just the template parameter scope as previously). Also enter the scope stack in the correct order.
Otherwise this breaks some invariant during name lookup especially when dealing with shadowed declaration

Fix PR11931.

llvm-svn: 151140
2012-02-22 08:25:53 +00:00
Richard Smith 2a15b74605 Accept braced-init-lists in conditions, and, in passing, dramatically improve
the diagnostic for using a parenthesized direct-initializer in a condition.

llvm-svn: 151137
2012-02-22 06:49:09 +00:00
Eli Friedman 91d5bb1ee5 Make sure null initialization in arrays works correctly with ARC types. <rdar://problem/10907547>.
llvm-svn: 151133
2012-02-22 05:38:59 +00:00
Douglas Gregor ed90df3800 Generate an AST for the conversion from a lambda closure type to a
block pointer that returns a block literal which captures (by copy)
the lambda closure itself. Some aspects of the block literal are left
unspecified, namely the capture variable (which doesn't actually
exist) and the body (which will be filled in by IRgen because it can't
be written as an AST).

Because we're switching to this model, this patch also eliminates
tracking the copy-initialization expression for the block capture of
the conversion function, since that information is now embedded in the
synthesized block literal. -1 side tables FTW.

llvm-svn: 151131
2012-02-22 05:02:47 +00:00
Eli Friedman 7cd4a9ba48 Improve diagnostics a bit for bad member initializers, and fix an obscure bug involving packs. Fixes PR12049.
llvm-svn: 151130
2012-02-22 04:49:04 +00:00
NAKAMURA Takumi 0716b50db6 test/CodeGenCXX/thiscall-struct-return.cpp: Relax expressions for -Asserts.
llvm-svn: 151126
2012-02-22 03:36:54 +00:00
Anna Zaks 199e8e585b [analyzer] Malloc checker: mark 'strdup' and 'strndup' as allocators.
llvm-svn: 151124
2012-02-22 03:14:20 +00:00
Aaron Ballman 3c42441b2c Adding support for Microsoft's thiscall calling convention. Clang side of the patch.
llvm-svn: 151122
2012-02-22 03:04:13 +00:00
Anna Zaks 4ca45b1d00 [analyzer] Malloc: fix another false positive.
, when we return a symbol reachable to the malloced one via pointer
arithmetic.

llvm-svn: 151121
2012-02-22 02:36:01 +00:00
Anna Zaks 3705a1ee10 [analyzer] Change naming in bug reports "tainted" -> "untrusted"
llvm-svn: 151120
2012-02-22 02:35:58 +00:00
Argyrios Kyrtzidis a1bed4cd96 [libclang] Index the field references of a designated initializer, rdar://10906206
llvm-svn: 151118
2012-02-22 02:10:41 +00:00
Richard Smith fd555f6b1f Implement C++11 [expr.call]p11: If the operand to a decltype-specifier is a
function call (or a comma expression with a function call on its right-hand
side), possibly parenthesized, then the return type is not required to be
complete and a temporary is not bound. Other subexpressions inside a decltype
expression do not get this treatment.

This is implemented by deferring the relevant checks for all calls immediately
within a decltype expression, then, when the expression is fully-parsed,
checking the relevant constraints and stripping off any top-level temporary
binding.

Deferring the completion of the return type exposed a bug in overload
resolution where completion of the argument types was not attempted, which
is also fixed by this change.

llvm-svn: 151117
2012-02-22 02:04:18 +00:00
Kaelyn Uhrain 0178200062 Fix typo correction of template arguments to once again allow type names.
llvm-svn: 151112
2012-02-22 01:03:07 +00:00
Fariborz Jahanian 8e1118cbd5 modern objc translator: fixes a bug where a class declaration with not
any implementation in tu was not being translated.

llvm-svn: 151106
2012-02-21 23:58:41 +00:00
Fariborz Jahanian c481c0c0f5 objective-c modern translator. accessing ivars using modern abi - wip.
llvm-svn: 151103
2012-02-21 23:46:48 +00:00