Commit Graph

20125 Commits

Author SHA1 Message Date
Douglas Gregor 5476205b9b Move all of Sema's member-access-related checking out of SemaExpr.cpp
and into a new file, SemaExprMember.cpp, bringing SemaExpr.cpp just
under 10,000 lines of code (ugh). No functionality change, although I
intend to do some refactoring of this code to address PR8368 at some
point in the "near" future.

llvm-svn: 133674
2011-06-23 00:49:38 +00:00
Argyrios Kyrtzidis ab72b6792b Allow unavailable function calls inside unavailable functions in C++/ObjC++ as well. rdar://9660196
llvm-svn: 133672
2011-06-23 00:41:50 +00:00
Alexis Hunt 080709f82d Clean up the heart of the caching code and miss fewer edge cases.
llvm-svn: 133671
2011-06-23 00:26:20 +00:00
Douglas Gregor 835af98597 Check for placeholders early on in
Sema::CreateUnaryExprOrTypeTraitExpr() rather than recursing in some
cases. Fixes <rdar://problem/9659191>.

llvm-svn: 133663
2011-06-22 23:21:00 +00:00
Alexis Hunt 46d1ce23a7 Fix a think-o that amazingly didn't show up until I started writing
implicit move tests.

llvm-svn: 133655
2011-06-22 22:13:13 +00:00
Fariborz Jahanian 33e022650a Issue warning if weak_import attribute is added to an already
declared variable and ignore it. // rdar://9538608

llvm-svn: 133654
2011-06-22 22:08:50 +00:00
Fariborz Jahanian 0a3cfcc87f Alloa catching Objective-C id's being thrown with C++ throw
in Darwin's fragile abi mode.  // rdar://8940528

llvm-svn: 133639
2011-06-22 20:21:51 +00:00
Manuel Klimek f2b4b69346 Changes ParenListExpr to always require a type.
Removes dead code found in the process.
Adds a test to verify that ParenListExprs do not have NULL types.

llvm-svn: 133637
2011-06-22 20:02:16 +00:00
Douglas Gregor 3bde9b15a1 Copy diagnostic pragmas to the preprocessed output, from Richard Osborne!
llvm-svn: 133633
2011-06-22 19:41:48 +00:00
Douglas Gregor bb9a5e6df1 Fix the starting location of the Fix-It note for suspicious precedence
issues between a bitwise operator and a comparison operator. Fixes
<rdar://problem/9637759>.

llvm-svn: 133630
2011-06-22 18:41:08 +00:00
Douglas Gregor 1501f16cfe When instantiating a function template declaration that was expressed
via a typedef of a function, make sure to synthesize parameter
declarations. Fixes PR9654 / <rdar://problem/9257497>.

llvm-svn: 133628
2011-06-22 18:16:25 +00:00
Argyrios Kyrtzidis 59b5f356ad [arcmt] Make -Warc-unsafe-retained-assign an error when migrating. rdar://8939557
llvm-svn: 133627
2011-06-22 18:03:59 +00:00
Eric Christopher c235d0c635 Build and use libcompiler_rt whenever possible.
Patch by Jean-Daniel Dupas!

llvm-svn: 133624
2011-06-22 17:41:40 +00:00
Douglas Gregor ec793dde8e Try to silence GCC warning
llvm-svn: 133623
2011-06-22 16:43:25 +00:00
Fariborz Jahanian ec667fcc36 objc-arc: Allow unbridged cast of retainable object to
integral as it is not transferring ownership.. 
// rdar://9619861

llvm-svn: 133622
2011-06-22 16:36:45 +00:00
Douglas Gregor 1c8cd7c1a5 Implement the C++0x move optimization for Automatic Reference Counting
objects, so that we steal the retain count of a temporary __strong
pointer (zeroing out that temporary), eliding a retain/release
pair. Addresses <rdar://problem/9364932>.

llvm-svn: 133621
2011-06-22 16:32:26 +00:00
Douglas Gregor 58df509fc0 When binding a reference to an Automatic Reference Counting temporary,
retain/release the temporary object appropriately. Previously, we
would only perform the retain/release operations when the reference
would extend the lifetime of the temporary, but this does the wrong
thing across calls.

llvm-svn: 133620
2011-06-22 16:12:01 +00:00
Douglas Gregor 2fa40a3a06 Give MaterializeTemporaryExpr the exact type of the lvalue it binds
to, including cv-qualifications.

llvm-svn: 133618
2011-06-22 15:05:02 +00:00
Jay Foad 83be361b8a Replace the existing forms of ConstantArray::get() with a single form
that takes an ArrayRef.

llvm-svn: 133615
2011-06-22 09:24:39 +00:00
Argyrios Kyrtzidis c0c5dd2651 Introduce DelayedCleanupPool useful for simplifying clean-up of certain resources that, while their
lifetime is well-known and restricted, cleaning them up manually is easy to miss and cause a leak.

Use it to plug the leaking of TemplateIdAnnotation objects. rdar://9634138.

llvm-svn: 133610
2011-06-22 06:09:49 +00:00
Alexis Hunt 2949f02333 Actually, you know, fix the problem.
llvm-svn: 133604
2011-06-22 02:58:46 +00:00
John McCall 6b0feb7ed6 Emit @finally blocks completely lazily instead of forcing their
existence by always threading an edge from the catchall.  Not doing
this was previously causing a crash in the very extreme case where
neither the normal cleanup nor the EH catchall was actually reachable:
we would delete the catchall entry block, which would cause us to
delete the entry block of the finally cleanup as well because the
cleanup logic would merge the blocks, which in turn triggered an assert
because later blocks in the finally would still be using values from the
entry.  Laziness turns out to be the most elegant solution to the problem.

llvm-svn: 133601
2011-06-22 02:32:12 +00:00
Alexis Hunt 7b7fece4d4 Avoid making assumption that this is either a CXXMethodDecl or a
FunctionTemplateDecl. I'm not quite sure what else it could be, though,
and would appreciate some insight.

This ought to fix the broken builds

llvm-svn: 133600
2011-06-22 02:25:26 +00:00
Alexis Hunt d74c85fdcc Ensure that we delete implict copy members when explicit move members
are also present.

llvm-svn: 133593
2011-06-22 01:05:13 +00:00
John McCall b5f652e3ef It is possible to request the nonfragile ABI with -fobjc-abi-version=2;
respect that when deciding whether -objc-exceptions implies the
-fexceptions -cc1 option.

llvm-svn: 133590
2011-06-22 00:53:57 +00:00
Alexis Hunt 491ec60802 Attempt to reapply this patch for caching copy assignment operator
lookup. Previously, it was breaking self-host, but it's been a week and
a half and I can't reproduce, so I need to see if it's still failing.

llvm-svn: 133581
2011-06-21 23:42:56 +00:00
Richard Smith 2602a683e0 Fix PR10168: don't warn for unused non-dependent variables in both the template definition and each instantiation.
llvm-svn: 133580
2011-06-21 23:42:09 +00:00
Chandler Carruth cf5f43ce1f Fix a missing space noticed by matthewbg in code review.
llvm-svn: 133577
2011-06-21 23:26:32 +00:00
Richard Smith f9603354ea First part of PR9968: the __range variable in a dependent C++11 for-range statement is implicitly used by that statement.
llvm-svn: 133572
2011-06-21 23:07:19 +00:00
Chandler Carruth 889ed86d73 Fix some grammar nits in the comments from Nick.
llvm-svn: 133571
2011-06-21 23:04:20 +00:00
Chandler Carruth f51c5a5b71 Revert r133526 which re-orders the suggestions for -Wparentheses on ?:
operators. There is a consistent design of having the "silence the
warning" option first.

llvm-svn: 133570
2011-06-21 23:04:18 +00:00
Alexis Hunt 54a4e7b534 Unbreak the CMake build
llvm-svn: 133557
2011-06-21 22:16:17 +00:00
John McCall 575fda19b3 Fix the mangling of dependent-scope decl ref expressions so that they
use the unresolved-name production correctly.

llvm-svn: 133554
2011-06-21 22:12:46 +00:00
Bob Wilson f64a560d74 Make InitHeaderSearch::AddPath and HeaderSearchOptions::AddPath consistent
use an "IgnoreSysRoot" argument.  HeaderSearchOptions had been using the
opposite form with "IsSysRootRelative", which made for much confusion when
looking at true/false values in calls in AddPath.  No functional change.

llvm-svn: 133550
2011-06-21 21:53:08 +00:00
Daniel Dunbar 3d125d329c Driver/Darwin: Fixup version check for -object_path_lto support.
llvm-svn: 133548
2011-06-21 21:18:32 +00:00
Bob Wilson b02ea3d70d Fix the default libc++ header search path to be sysrooted. Radar 9639692.
The -cxx-isystem path is not prefixed with the sysroot directory, so it's
not a good way for the driver to set the system default C++ search path.
Instead, add -stdlib as a cc1 option and teach the frontend how to find the
headers.  The driver can then just pass -stdlib through to "cc1".

llvm-svn: 133547
2011-06-21 21:12:29 +00:00
Daniel Dunbar ef889c7c9b Driver/Darwin: When invoking the linker, automatically pass -object_path_lto so
that the linker has a place to put the temporary object file and can leave it
around (for the driver to clean up). This is important so that the object file
references in the debug info are preserved for possible use by dsymutil.
 - <rdar://problem/8294279> executable has no debug symbols when compiled with LTO

llvm-svn: 133543
2011-06-21 20:55:11 +00:00
Daniel Dunbar 8f1fe5b5c3 Driver: Factor out IsUsingLTO helper function.
llvm-svn: 133542
2011-06-21 20:55:08 +00:00
Argyrios Kyrtzidis e5acb84e63 [arcmt] Merge 'removeEmptyStatements' and 'removeDeallocMethod' passes to cut down on one compilation
pass and increase migration speed.

llvm-svn: 133540
2011-06-21 20:20:42 +00:00
Argyrios Kyrtzidis e5b475c688 [arcmt] Break apart Transforms.cpp.
llvm-svn: 133539
2011-06-21 20:20:39 +00:00
Fariborz Jahanian 9b83be832b objc-arc: Add support for unbridged cast of
__builtin___CFStringMakeConstantString and CF typed function calls 
with explicit cf_returns_retained/cf_returns_not_retained attributes.
// rdar://9544832

llvm-svn: 133535
2011-06-21 19:42:38 +00:00
Daniel Dunbar d3f3d932ee IRgen: Add a -fuse-register-sized-bitfield-access option, for testing.
- Changes bit-field access policy to try to use (aligned) register sized accesses.

The idea here is that by using larger accesses we expose more coalescing
potential to the backend when we have situations like adjacent bit-fields in the
same structure (which is common), and that the backend should be smart enough to
narrow the accesses down when no coalescing is done or when it is shown not to
be profitable.

--
$ clang -m32 -O3 -S -o - t.c
_f0:                                    ## @f0
	pushl	%ebp
	movl	%esp, %ebp
	movl	8(%ebp), %eax
	movb	(%eax), %cl
	andb	$-128, %cl
	orb	$1, %cl
	movb	%cl, (%eax)
	movb	1(%eax), %cl
	andb	$-128, %cl
	orb	$1, %cl
	movb	%cl, 1(%eax)
	movb	2(%eax), %cl
	andb	$-128, %cl
	orb	$1, %cl
	movb	%cl, 2(%eax)
	movb	3(%eax), %cl
	andb	$-128, %cl
	orb	$1, %cl
	movb	%cl, 3(%eax)
	popl	%ebp
	ret

$ clang -m32 -O3 -S -o - t.c -Xclang -fuse-register-sized-bitfield-access
_f0:                                    ## @f0
	pushl	%ebp
	movl	%esp, %ebp
	movl	8(%ebp), %eax
	movl	$-2139062144, %ecx      ## imm = 0xFFFFFFFF80808080
	andl	(%eax), %ecx
	orl	$16843009, %ecx         ## imm = 0x1010101
	movl	%ecx, (%eax)
	popl	%ebp
	ret
--

llvm-svn: 133532
2011-06-21 18:54:46 +00:00
Daniel Dunbar 0de2faae4d IRgen: Add CGOptions to CGTypes.
llvm-svn: 133530
2011-06-21 18:54:39 +00:00
Fariborz Jahanian 2e9e89aa36 ^cat^cast^
llvm-svn: 133529
2011-06-21 18:21:32 +00:00
Douglas Gregor d410c08ebe A few tweaks to MaterializeTemporaryExpr suggested by John.
llvm-svn: 133528
2011-06-21 18:20:46 +00:00
Fariborz Jahanian 40502b1229 Add comment before CheckObjCARCConversion is called on
Expr value not getting changed by this call.

llvm-svn: 133527
2011-06-21 18:19:51 +00:00
Chandler Carruth fc8a0fbeed Switch the order of the notes for the parentheses suggested in the case
of: a + b ? x : y. In our testing of this flag we've yet to hit a single
case where the existing precedence was correct, so we should suggest
grouping the ?: first.

llvm-svn: 133526
2011-06-21 18:07:33 +00:00
Fariborz Jahanian 7887637c82 objc-arc: CodeGen part of unbridged cast of CF types.
// rdar://9474349

llvm-svn: 133525
2011-06-21 17:38:29 +00:00
Chandler Carruth 4352b0b876 Fix a crash when a pointer-to-member function is called in the condition
expression of '?:'. Add a test case for this pattern, and also test the
code that led to the crash in a "working" case as well.

llvm-svn: 133523
2011-06-21 17:22:09 +00:00
Douglas Gregor fe31481f68 Introduce a new AST node describing reference binding to temporaries.
MaterializeTemporaryExpr captures a reference binding to a temporary
value, making explicit that the temporary value (a prvalue) needs to
be materialized into memory so that its address can be used. The
intended AST invariant here is that a reference will always bind to a
glvalue, and MaterializeTemporaryExpr will be used to convert prvalues
into glvalues for that binding to happen. For example, given

  const int& r = 1.0;

The initializer of "r" will be a MaterializeTemporaryExpr whose
subexpression is an implicit conversion from the double literal "1.0"
to an integer value. 

IR generation benefits most from this new node, since it was
previously guessing (badly) when to materialize temporaries for the
purposes of reference binding. There are likely more refactoring and
cleanups we could perform there, but the introduction of
MaterializeTemporaryExpr fixes PR9565, a case where IR generation
would effectively bind a const reference directly to a bitfield in a
struct. Addresses <rdar://problem/9552231>.

llvm-svn: 133521
2011-06-21 17:03:29 +00:00
Jay Foad 9a6b09874d Make more use of llvm::StringRef in various APIs. In particular, don't
use the deprecated forms of llvm::StringMap::GetOrCreateValue().

llvm-svn: 133515
2011-06-21 15:13:30 +00:00
Joerg Sonnenberger 4eb724ffdf Fix typo. From Damjan Marion.
llvm-svn: 133511
2011-06-21 08:45:08 +00:00
NAKAMURA Takumi 5364847a84 De-Unicode-ify in comments.
llvm-svn: 133501
2011-06-21 03:19:28 +00:00
Daniel Dunbar 471c4f8299 Driver/Darwin: Honor -Xarch_FOO when the arch matches either the toolchain or
the architecture being bound.
 - Fixes things like -Xarch_armv7.

llvm-svn: 133490
2011-06-21 00:20:17 +00:00
Nick Lewycky ca6b90d8af Add support for -Wa,--noexecstack when building from a non-assembly file. For
an assembly file it worked correctly, while for a .c file it would given an
error about how --noexecstack is not a supported argument to -Wa.

llvm-svn: 133489
2011-06-21 00:14:18 +00:00
Eric Christopher b4a791f7bc Canonicalize register names properly.
Fixes rdar://9425559

llvm-svn: 133486
2011-06-21 00:07:10 +00:00
Eric Christopher cdd3635b09 Move additional register names to their own lookup, separate from
register aliases. Fixes unnecessary renames of clobbers.

Fixes part of rdar://9425559

llvm-svn: 133485
2011-06-21 00:05:20 +00:00
Argyrios Kyrtzidis 0a9d652331 [arcmt] Always add '__bridge' cast when 'self' is cast to a C pointer. rdar://9644061
llvm-svn: 133480
2011-06-20 23:39:20 +00:00
Jordy Rose b41f7c55f5 [analyzer] Finish size argument checking for strncat (and strncpy).
llvm-svn: 133472
2011-06-20 21:55:40 +00:00
Fariborz Jahanian 4ad5686399 objc-arc: allow explicit unbridged casts if the source of the cast is a
message sent to an objc method (or property access)
// rdar://9474349

llvm-svn: 133469
2011-06-20 20:54:42 +00:00
Argyrios Kyrtzidis 81a3590a0e [arcmt] Find out whether there is an ARC runtime directly from the triple, avoid hacky delegation to the driver for that.
llvm-svn: 133464
2011-06-20 19:59:52 +00:00
Argyrios Kyrtzidis 01bf777597 Warn for un-parenthesized '&' inside '|' (a & b | c), rdar://9553326.
Patch by Henry Mason with tweaks by me.

llvm-svn: 133453
2011-06-20 18:41:26 +00:00
Fariborz Jahanian ab578bf355 llvm-gcc treats a tentative definition with a previous
(or follow up) extern declaration with weak_import as 
an actual definition. make clang follows this behavior. 
// rdar://9538608
llvm-gcc treats an extern declaration with weak_import

llvm-svn: 133450
2011-06-20 17:50:03 +00:00
Douglas Gregor 21ad5dfc69 Define va_copy when in C++0x mode; C++0x picked it up from C99.
llvm-svn: 133438
2011-06-20 15:03:22 +00:00
Douglas Gregor 10c1d268ea Define __cplusplus to 201103L when in (non-GNU) C++0x mode.
llvm-svn: 133437
2011-06-20 15:00:58 +00:00
Jay Foad e03c05c35a Change how PHINodes store their operands.
Change PHINodes to store simple pointers to their incoming basic blocks,
instead of full-blown Uses.

Note that this loses an optimization in SplitCriticalEdge(), because we
can no longer walk the use list of a BasicBlock to find phi nodes. See
the comment I removed starting "However, the foreach loop is slow for
blocks with lots of predecessors".

Extend replaceAllUsesWith() on a BasicBlock to also update any phi
nodes in the block's successors. This mimics what would have happened
when PHINodes were proper Users of their incoming blocks. (Note that
this only works if OldBB->replaceAllUsesWith(NewBB) is called when
OldBB still has a terminator instruction, so it still has some
successors.)

llvm-svn: 133435
2011-06-20 14:38:01 +00:00
Chandler Carruth 5f380da06f Fix a problem with the diagnostics of invalid arithmetic with function
pointers I found while working on the NULL arithmetic warning. We here
always assuming the LHS was the pointer, instead of using the selected
pointer expression.

llvm-svn: 133428
2011-06-20 07:52:11 +00:00
Chandler Carruth 4f04b436f8 Move away from the poor "abstraction" I added to Type. John argued
effectively that this abstraction simply doesn't exist. That is
highlighted by the fact that by using it we were papering over a more
serious error in this warning: the fact that we warned for *invalid*
constructs involving member pointers and block pointers.

I've fixed the obvious issues with the warning here, but this is
confirming an original suspicion that this warning's implementation is
flawed. I'm looking into how we can implement this more reasonably. WIP
on that front.

llvm-svn: 133425
2011-06-20 07:38:51 +00:00
Francois Pichet 1b8d5ddafb Remove more unnecessary #include <llvm/ADT/SmallVector.h>
llvm-svn: 133418
2011-06-20 06:11:46 +00:00
Chris Lattner e64d7ba153 Update to match mainline ConstantStruct::get API change. Also, use
ConvertType on InitListExprs as they are being converted.  This is
needed for a forthcoming patch, and improves the IR generated anyway
(see additional type names in testcases). 

This patch also converts a bunch of std::vector's in CGObjCMac to use
C arrays.  There are a ton more that should be converted as well.

llvm-svn: 133413
2011-06-20 04:01:35 +00:00
Jordy Rose 789adbb3ed [analyzer] Replace stream-built error message with constant string. No functionality change.
llvm-svn: 133410
2011-06-20 03:51:53 +00:00
Jordy Rose 328deeed7f [analyzer] Re-enable checking for strncpy, along with a new validation of the size argument. strncat is not yet up-to-date, but I'm leaving it enabled for now (there shouldn't be any false positives, at least...)
llvm-svn: 133408
2011-06-20 03:49:16 +00:00
Jordy Rose dceb0cf3f3 [analyzer] Eliminate "byte string function" from CStringChecker's diagnostics, and make it easier to provide custom messages for overflow checking, in preparation for re-enabling strncpy checking.
llvm-svn: 133406
2011-06-20 02:06:40 +00:00
Chandler Carruth 92c810be2c Restructure the API in Type based on a conversation with Richard Smith.
This makes 'isPointerLikeType' a little less confusing, and pulls the
decay check into a separate interface that is much more clear and
concrete. Also, just implement these as logical wrappers around other
predicates. Having a switch based implementation isn't likely to be
necessary. We can try to optimize them later if they show up on
a profile.

llvm-svn: 133405
2011-06-20 01:23:19 +00:00
Chandler Carruth e1db1cf0c3 Add test cases for false positives on -Wnull-arithmetic from Richard
Trieu, and fix them by checking for array and function types as well as
pointer types.

I've added a predicate method on Type to bundle together the logic we're
using here: isPointerLikeType(). I'd welcome better names for this
predicate, this is the best I came up with. It's implemented as a switch
to be a touch lighter weight than all the chained isa<...> casts that
would result otherwise.

llvm-svn: 133383
2011-06-19 09:05:14 +00:00
Francois Pichet e878cb6bd1 Handle decltype keyword in Parser::isDeclarationSpecifier.
Fixes PR10154. Found by parsing MFC 2010 code with clang.

llvm-svn: 133380
2011-06-19 08:02:06 +00:00
Chris Lattner 845511fe1c update for api change.
llvm-svn: 133365
2011-06-18 22:49:11 +00:00
Benjamin Kramer 8a9cc4fe28 Remove dead variables.
llvm-svn: 133346
2011-06-18 10:34:07 +00:00
Benjamin Kramer dd19c0114d 80 cols.
llvm-svn: 133345
2011-06-18 10:34:00 +00:00
Chandler Carruth 53e61b05ce Accept no-return stripping conversions for pointer type arguments after
deducing template parameter types. Recently Clang began enforcing the
more strict checking that the argument type and the deduced function
parameter type (after substitution) match, but that only consideres
qualification conversions.

One problem with this patch is that we check noreturn conversions and
qualification conversions independently. If a valid conversion would
require *both*, perhaps interleaved with each other, it will be
rejected. If this actually occurs (I'm not yet sure it does) and is in
fact a problem (I'm not yet sure it is), there is a FIXME to implement
more intelligent conversion checking.

However, this step at least allows Clang to resume accepting valid code
we're seeing in the wild.

llvm-svn: 133327
2011-06-18 01:19:03 +00:00
Argyrios Kyrtzidis 90b6a2a6a7 [arcmt] Fix the ARC migrator. -arcmt-modify requires running before the initialization of SourceManager
because it is going to modify the input file.

llvm-svn: 133323
2011-06-18 00:53:41 +00:00
Argyrios Kyrtzidis 0f3f9f78f8 [arcmt] Const'ify.
llvm-svn: 133322
2011-06-18 00:53:34 +00:00
Argyrios Kyrtzidis 1240f4e53a [arcmt] Remove '-arcmt-modify-in-memory', it turned out less useful than we hoped it would be.
llvm-svn: 133315
2011-06-17 23:49:31 +00:00
Argyrios Kyrtzidis 95a76f3715 Fix regression with @encode string. rdar://9624314.
llvm-svn: 133312
2011-06-17 23:19:38 +00:00
Douglas Gregor d7357a9b8e Objective-C++ ARC: eliminate the utterly unjustified loophole that
silently dropped ownership qualifiers that were being applied to
ownership-qualified, substituted type that was *not* a substituted
template type parameter. We now provide a diagnostic in such cases,
and recover by dropping the added qualifiers.

Document this behavior in the ARC specification.

llvm-svn: 133309
2011-06-17 23:16:24 +00:00
Douglas Gregor b5176a5328 Objective-C++ ARC: do not mangle __unsafe_unretained lifetime
qualifiers, so that an __unsafe_unretained-qualified type T in ARC code
will have the same mangling as T in non-ARC code, improving ABI
interoperability. This works now because we infer or require a
lifetime qualifier everywhere one can appear in an external
interface. Another part of <rdar://problem/9595486>.

llvm-svn: 133306
2011-06-17 22:26:49 +00:00
Douglas Gregor e46db90c9a Objective-ARC++: infer template type arguments of
ownership-unqualified retainable object type as __strong. This allows
us to write, e.g.,

  std::vector<id>

and we'll infer that the vector's element types have __strong
ownership semantics, which is far nicer than requiring:

  std::vector<__strong id>

Note that we allow one to override the ownership qualifier of a
substituted template type parameter, e.g., given

  template<typename T>
  struct X {
    typedef __weak T type;
  };

X<id> is treated the same as X<__strong id>. At instantiation type,
the __weak in "__weak T" overrides the (inferred or specified)
__strong on the template argument type, so that we can still provide
metaprogramming transformations.

This is part of <rdar://problem/9595486>.

llvm-svn: 133303
2011-06-17 22:11:49 +00:00
John McCall 0c07bee8bd Only accept __bridge_retain in system headers, as Doug suggested.
llvm-svn: 133300
2011-06-17 21:56:12 +00:00
John McCall 0c32925aa0 As a hopefully temporary workaround for a header mistake, treat
__bridge_retain as a synonym for __bridge_retained.

llvm-svn: 133295
2011-06-17 21:23:37 +00:00
Eli Friedman 8e6f5a641d Add a minor hack to avoid using isNullPointerConstant on a hot path. Fixes -O0 compile-time regressions from r133196.
rdar://9629775 .

llvm-svn: 133290
2011-06-17 20:52:22 +00:00
Argyrios Kyrtzidis c30661f3a8 Don't emit 'unavailable' errors inside an unavailable function. rdar://9623855.
llvm-svn: 133264
2011-06-17 17:28:30 +00:00
Douglas Gregor 6c9d31eb25 When emitting a compound literal of POD type, continue to emit a
separate aggregate temporary and then memcpy it over to the
destination. This fixes a regression I introduced with r133235, where
the compound literal on the RHS of an assignment makes use of the
structure on the LHS of the assignment.

I'm deeply suspicious of AggExprEmitter::VisitBinAssign()'s
optimization where it emits the RHS of an aggregate assignment
directly into the LHS lvalue without checking whether there is any
aliasing between the LHS/RHS. However, I'm not in a position to
revisit this now.

Big thanks to Eli for finding the regression!

llvm-svn: 133261
2011-06-17 16:37:20 +00:00
Douglas Gregor ddaae52a4e Fix refactoro, silencing an MSVC warning. Thanks, Francois.
llvm-svn: 133257
2011-06-17 14:36:00 +00:00
John McCall 5aa5259f5e Perform an acquire memory barrier on the fast path of a thread-safe
static initializer check, as required by the Itanium ABI.

llvm-svn: 133250
2011-06-17 07:33:57 +00:00
John McCall 640767fff6 Initialize a couple of variables to shut GCC up.
llvm-svn: 133246
2011-06-17 06:50:50 +00:00
John McCall d463132f27 Objective-C fast enumeration loop variables are not retained in ARC, but
they should still be officially __strong for the purposes of errors, 
block capture, etc.  Make a new bit on variables, isARCPseudoStrong(),
and set this for 'self' and these enumeration-loop variables.  Change
the code that was looking for the old patterns to look for this bit,
and change IR generation to find this bit and treat the resulting         
variable as __unsafe_unretained for the purposes of init/destroy in
the two places it can come up.

llvm-svn: 133243
2011-06-17 06:42:21 +00:00
Douglas Gregor 518bc4cd55 Extend the deduced/actual argument type checking of C++
[temp.deduct.call]p4 to the deduction performed for 'auto', finishing
the fix for PR9233.

llvm-svn: 133239
2011-06-17 05:31:46 +00:00
Douglas Gregor 2ead4c41e8 Factor the checking of the deduced argument type against the actual
argument type for C++ [temp.deduct.call]p4 out of
Sema::FinishTemplateArgumentDeduction(). No functionality change.

llvm-svn: 133237
2011-06-17 05:18:17 +00:00
Douglas Gregor 84265a09d6 When an explicit specialization has a storage specifier, error if that
storage specifier is different from the storage specifier on the
template. If that storage specifier is the same, then we only warn.

Thanks to John for the prodding.

llvm-svn: 133236
2011-06-17 05:09:08 +00:00
Douglas Gregor 9b71f0cfac Implement proper support for generating code for compound literals in
C++, which means:
  - binding the temporary as needed in Sema, so that we generate the
  appropriate call to the destructor, and
  - emitting the compound literal into the appropriate location for
  the aggregate, rather than trying to emit it as a temporary and
  memcpy() it.

Fixes PR10138 / <rdar://problem/9615901>.

llvm-svn: 133235
2011-06-17 04:59:12 +00:00
Douglas Gregor c976f01d3f Downgrade the error complaining about presence of a storage class
specifier on an explicit specialization to a warning, since neither
EDG nor GCC diagnose this code as ill-formed.

llvm-svn: 133232
2011-06-17 03:41:35 +00:00
Eric Christopher e9544258ef Check the specific target to figure out if a constraint is a valid
register constraint. Note that we're not checking if the register itself
is valid for the constraint.

Fixes rdar://9382985

llvm-svn: 133226
2011-06-17 01:53:34 +00:00
Eric Christopher d10485412d Add some more memory constraints for ARM.
Part of rdar://9197685

llvm-svn: 133225
2011-06-17 01:40:49 +00:00
Eric Christopher 7d237c1882 On ARM make sure that we continue translating 'p' to 'r' for the
constraints.

rdar://9618597

llvm-svn: 133222
2011-06-17 00:40:18 +00:00
John McCall 1b1a1dbbe7 When synthesizing implicit copy/move constructors and copy/move assignment
operators, don't make an initializer or sub-operation for zero-width
bitfields.

llvm-svn: 133221
2011-06-17 00:18:42 +00:00
Douglas Gregor cbd446d325 Check for placeholder expressions before promoting an argument passed
through an ellipsis. Fixes <rdar://problem/9623945>.

llvm-svn: 133219
2011-06-17 00:15:10 +00:00
Eli Friedman 623e2ba435 Add support for -force_load flag, for compat with Apple gcc. rdar://9555962 .
llvm-svn: 133218
2011-06-16 23:59:43 +00:00
John McCall fa27234afb Be sure to try a final ARC-production even in Objective-C++.
llvm-svn: 133215
2011-06-16 23:24:51 +00:00
Francois Pichet ea22bab7a5 Finish 2 sentences.
llvm-svn: 133214
2011-06-16 23:19:36 +00:00
Chris Lattner 705c5c8d22 Fix a regression introduced by r131955 which broke #include_next in subtle situations
because the Angled directories and the System directories were not being uniqued 
together, breaking #include_next.  I'll see about a testcase, but it will be insane.

llvm-svn: 133212
2011-06-16 22:58:10 +00:00
Chris Lattner 0c64f4b27e code cleanups, no behavior change.
llvm-svn: 133211
2011-06-16 22:56:45 +00:00
Fariborz Jahanian d9bc6c3f59 For the purpose of @encode'ing, accept 'void' type
(even though it is incomplete type) because gcc
says so. // rdar://9622422

llvm-svn: 133208
2011-06-16 22:34:44 +00:00
Richard Trieu 701fb36b95 Add a new warning when a NULL constant is used in arithmetic operations. The warning will fire on cases such as:
int x = 1 + NULL;

llvm-svn: 133196
2011-06-16 21:36:56 +00:00
Fariborz Jahanian 8feee2d169 Move computation of __private_extern__ visibilty to
getLVForNamespaceScopeDecl(). // rdar://9609649

llvm-svn: 133182
2011-06-16 20:14:50 +00:00
Evan Cheng d863adb201 Stylistic fix: move virtual keyword before return type.
llvm-svn: 133181
2011-06-16 19:13:15 +00:00
Douglas Gregor 3e85c9c561 Allow comparison between block pointers and NULL pointer
constants. Fixes PR10145.

llvm-svn: 133179
2011-06-16 18:52:05 +00:00
Douglas Gregor 18739c343c Teach the warning about non-POD memset/memcpy/memmove to deal with the
__builtin_ versions of these functions as well as the normal function
versions, so that it works on platforms where memset/memcpy/memmove
are macros that map down to the builtins (e.g., Darwin). Fixes
<rdar://problem/9372688>.

llvm-svn: 133173
2011-06-16 17:56:04 +00:00
Fariborz Jahanian 62c72d06ff arc: diagnose dereferencing a __weak pointer which may be
null at any time. // rdar://9612030

llvm-svn: 133168
2011-06-16 17:29:56 +00:00
Douglas Gregor e65aacb9e9 Implement the consistency checking for C++ [temp.deduct.call]p3, which
checks that the deduced argument type for a function call matches the
actual argument type provided. The only place we've found where the
consistency checking should actually cause template argument deduction
failure is due to qualifier differences that don't fall into the realm
of qualification conversions (which are *not* checked when we
initially perform deduction). However, we're performing the full
checking as specified in the standard to ensure that no other cases
exist.

Fixes PR9233 / <rdar://problem/9039590>.

llvm-svn: 133163
2011-06-16 16:50:48 +00:00
Chandler Carruth b570351059 Raise the ARCMT functionality in Clang into proper FrontendActions.
These are somewhat special in that they wrap any other FrontendAction,
running various ARC transformations or checks prior to the standard
action's run. To implement them easily, this extends FrontendAction to
have a WrapperFrontendAction utility class which forwards all calls by
default to an inner action setup at construction time. This is then
subclassed to override the specific behavior needed by the different
ARCMT tools.

Finally, FrontendTool is taught how to create these wrapper actions from
the existing flags and options structures.

The result is that clangFrontend no longer depends on clangARCMigrate.
This is very important, as clangARCMigrate *heavily* depends on
clangFrontend. Fundamentally ARCMigrate is at the same layer as
a library like Rewrite, sitting firmly on top of the Frontend, but tied
together with the FrontendTool when building the clang binary itself.

llvm-svn: 133161
2011-06-16 16:17:05 +00:00
Fariborz Jahanian a27070db0c Set the visibility to 'hidden' when previous
declaration of global var is __private_extern__.
// rdar://9609649

llvm-svn: 133157
2011-06-16 14:49:42 +00:00
NAKAMURA Takumi 0df100e1aa Be aware of (x86_64-redhat-linux6E-)g++44 on RHEL5.
AFAIK, RHEL5 (and its clones) provides g++44 as the package "gcc44-c++".
By default, g++-4.1.1 is available, though, its libstdc++ would not be suitable to clang++.

llvm-svn: 133156
2011-06-16 12:43:57 +00:00
Chandler Carruth 8b9e5a72cb Rework the warning for 'memset(p, 0, sizeof(p))' where 'p' is a pointer
and the programmer intended to write 'sizeof(*p)'. There are several
elements to the new version:

1) The actual expressions are compared in order to more accurately flag
   the case where the pattern that works for an array has been used, or
   a '*' has been omitted.
2) Only do a loose type-based check for record types. This prevents us
   from warning when we happen to be copying around chunks of data the
   size of a pointer and the pointer types for the sizeof and
   source/dest match.
3) Move all the diagnostics behind the runtime diagnostic filter. Not
   sure this is really important for this particular diagnostic, but
   almost everything else in SemaChecking.cpp does so.
4) Make the wording of the diagnostic more precise and informative. At
   least to my eyes.
5) Provide highlighting for the two expressions which had the unexpected
   similarity.
6) Place this diagnostic under a flag: -Wsizeof-pointer-memaccess

This uses the Stmt::Profile system for computing #1. Because of the
potential cost, this is guarded by the warning flag. I'd be interested
in feedback on how bad this is in practice; I would expect it to be
quite cheap in practice. Ideas for a cheaper / better way to do this are
also welcome.

The diagnostic wording could likely use some further wordsmithing.
Suggestions welcome here. The goals I had were to: clarify that its the
interaction of 'memset' and 'sizeof' and give more reasonable
suggestions for a resolution.

An open question is whether these diagnostics should have the note
attached for silencing by casting the dest/source pointer to void*.

llvm-svn: 133155
2011-06-16 09:09:40 +00:00
Jordy Rose c026370858 [analyzer] Clean up modeling of strcmp, including cases where a string literal has an embedded null character, and where both arguments are the same buffer. Also use nested ifs rather than early returns; in this case early returns will lose any assumptions we've made earlier in the function.
llvm-svn: 133154
2011-06-16 07:13:34 +00:00
Chandler Carruth 631abd9365 Make the Stmt::Profile method const, and the StmtProfile visitor
a ConstStmtVisitor. This also required adding some const iteration
support for designated initializers and making some of the getters on
the designators const.

It also made the formatting of StmtProfile.cpp rather awkward. I'm happy
to adjust any of the formatting if folks have suggestions. I've at least
fitted it all within 80 columns.

llvm-svn: 133152
2011-06-16 06:47:06 +00:00
Jordy Rose 0585a61821 [analyzer] Fix trivial errors in previous commit.
I will not commit without building first.
I will not commit without building first.
I will not commit without building first...

llvm-svn: 133150
2011-06-16 05:56:50 +00:00
Jordy Rose 455bd58d4e [analyzer] Cleanup: mainly 80-char violations and preferring SValBuilder::getComparisonType() to just referencing IntTy.
llvm-svn: 133149
2011-06-16 05:51:02 +00:00
John McCall 1553b19067 Restore correct use of GC barriers.
llvm-svn: 133144
2011-06-16 04:16:24 +00:00
Argyrios Kyrtzidis bdf3ca9186 [arcmt] Fix tests in non-darwin.
llvm-svn: 133140
2011-06-16 02:41:46 +00:00
Chandler Carruth a05e09ba48 Skip both character pointers and void pointers when diagnosing bad
argument types for mem{set,cpy,move}. Character pointers, much like void
pointers, often point to generic "memory", so trying to check whether
they match the type of the argument to 'sizeof' (or other checks) is
unproductive and often results in false positives.

Nico, please review; does this miss any of the bugs you were trying to
find with this warning? The array test case you had should be caught by
the array-specific sizeof warning I think.

llvm-svn: 133136
2011-06-16 02:00:04 +00:00
John McCall 54507ab83c Weaken the type-matching rules for methods that return aggregates when
complaining about mismatches in the global method pool.

llvm-svn: 133123
2011-06-16 01:15:19 +00:00
Chandler Carruth b00e8c0cad Refactor parentheses suggestion notes to have less code duplication and
be more consistent in how parenthesized ranges which hit macros are
handled. Also makes the code significantly shorter, and the diagnostics
when macros are present a bit more useful.

Pair programmed w/ Matthew.

llvm-svn: 133122
2011-06-16 01:05:14 +00:00
Chandler Carruth 08dc2ba4df Cleanup the parameter naming style.
llvm-svn: 133120
2011-06-16 01:05:08 +00:00
John McCall 5d36a8cc70 Unconditionally #define the ARC ownership qualifiers, instead of #defining
them only on Darwin tool chains.

llvm-svn: 133112
2011-06-16 00:03:19 +00:00
John McCall 101236969f Suppress a warning in -Asserts builds.
llvm-svn: 133110
2011-06-15 23:40:09 +00:00
John McCall d70fb9812a The ARC Migration Tool. All the credit goes to Argyrios and Fariborz
for this.

llvm-svn: 133104
2011-06-15 23:25:17 +00:00
John McCall 31168b077c Automatic Reference Counting.
Language-design credit goes to a lot of people, but I particularly want
to single out Blaine Garst and Patrick Beard for their contributions.

Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself,
in no particular order.

llvm-svn: 133103
2011-06-15 23:02:42 +00:00
John McCall ce45f88e45 Introduce a utility routine for checking whether a block's captures
include a specific variable.

llvm-svn: 133102
2011-06-15 22:51:16 +00:00
Eli Friedman f7456194a3 Per Chris's suggestion, simplify code using llvm::getOrEnforceKnownAlignment.
llvm-svn: 133095
2011-06-15 22:09:18 +00:00
John McCall a877d9231d Generate enumerators for diagnostic categories. Patch by Argyrios!
Depends on LLVM r133093.

llvm-svn: 133094
2011-06-15 21:46:43 +00:00
Eli Friedman 471a22febc Use isAnyComplexType here so we don't pass complex numbers into the aggregate handling code; found by inspection.
llvm-svn: 133070
2011-06-15 18:27:44 +00:00
Eli Friedman 7e68c88bf7 Fix a regression from r132957 involving complex integers. (Fixes failures on gcc-testsuite bot.)
llvm-svn: 133069
2011-06-15 18:26:32 +00:00
Devang Patel 7bf741ac36 Do not emit stoppoint before emitting debug info for parameters.
- llvm.dbg.declare already receives line number information from ParmDecl
- Additional extra stoppoint messes up gdb's understanding of where function body starts.

llvm-svn: 133065
2011-06-15 17:57:08 +00:00
Douglas Gregor 39c0272f65 Eliminate a 'default' case in template argument deduction, where we
were just punting on template argument deduction for a number of type
nodes. Most of them, obviously, didn't matter.

As a consequence of this, make extended vector types (via the
ext_vector_type attribute) actually work properly for several
important cases:
  - If the attribute appears in a type-id (i.e, not attached to a
  typedef), actually build a proper vector type
  - Build ExtVectorType whenever the size is constant; previously, we
  were building DependentSizedExtVectorType when the size was constant
  but the type was dependent, which makes no sense at all.
  - Teach template argument deduction to handle
  ExtVectorType/DependentSizedExtVectorType.

llvm-svn: 133060
2011-06-15 16:02:29 +00:00
Douglas Gregor 4e5df95e49 Eliminate an unnecessary include. FIXMEs -=1
llvm-svn: 133056
2011-06-15 14:26:34 +00:00
Douglas Gregor 55462626b6 When performing substitution of default template template parameters
before the template parameters have acquired a proper context (e.g.,
because the enclosing context has yet to be built), provide empty
parameter lists for all outer template parameter scopes to inhibit any
substitution for those template parameters. Fixes PR9643 /
<rdar://problem/9251019>.

llvm-svn: 133055
2011-06-15 14:20:42 +00:00
Jordy Rose 634c12d23f [analyzer] Revise CStringChecker's modelling of strcpy() and strcat():
- (bounded copies) Be more conservative about how much is being copied.
- (str(n)cat) If we can't compute the exact final length of an append operation, we can still lower-bound it.
- (stpcpy) Fix the conjured return value at the end to actually be returned.

This requires these supporting changes:
- C string metadata symbols are still live even when buried in a SymExpr.
- "Hypothetical" C string lengths, to represent a value that /will/ be passed to setCStringLength() if all goes well. (The idea is to allow for temporary constrainable symbols that may end up becoming permanent.)
- The 'checkAdditionOverflow' helper makes sure that the two strings being appended in a strcat don't overflow size_t. This should never *actually* happen; the real effect is to keep the final string length from "wrapping around" in the constraint manager.

This doesn't actually test the "bounded" operations (strncpy and strncat) because they can leave strings unterminated. Next on the list!

llvm-svn: 133046
2011-06-15 05:52:56 +00:00
Douglas Gregor 88336839b9 Don't add redundant FormatAttr, ConstAttr, or NoThrowAttr attributes,
either imlicitly (for builtins) or explicitly (due to multiple
specification of the same attributes). Fixes <rdar://problem/9612060>.

llvm-svn: 133045
2011-06-15 05:45:11 +00:00
Jordy Rose 0e9fb28e95 [analyzer] If a C string length is UnknownVal, clear any existing length binding. No tests yet because the only thing that sets string length is strcpy(), and that needs some work anyway.
llvm-svn: 133044
2011-06-15 05:14:03 +00:00
Jordy Rose b891bd8a3c [analyzer] When performing a binary operation on symbolic operands, we convert the symbol values to a common type. But in a relational operation, the result is an 'int' or 'bool', which may not be the appropriate type to convert the operands to. In these cases, use the left-hand operand's type as the conversion type.
There's no associated test for this because fully-constrained symbolic values are evaluated ahead of time in normal expressions. This can only come up in checker-constructed expressions (like the ones in an upcoming patch to CStringChecker).

llvm-svn: 133041
2011-06-15 04:55:49 +00:00
Douglas Gregor 1778b030c0 Properly implement C++0x [stmt.dcl]p3, which requires a scope to be
protected in the case where a variable is being initialized by a
trivial default constructor but has a non-trivial destructor.

llvm-svn: 133037
2011-06-15 03:23:34 +00:00
Nico Weber 0870debb8b Warn on "void f(int a[10]) { sizeof(a); }"
llvm-svn: 133036
2011-06-15 02:47:03 +00:00
Ted Kremenek 70f05fdfee Sema: show shift result in hexadecimal
Change the output for -Wshift-overflow and
-Wshift-sign-overflow to an unsigned hexadecimal. It makes
more sense for looking at bits than a signed decimal does.
Also, change the diagnostic's wording from "overrides"
to "sets".

This uses a new optional argument in APInt::toString()
that adds the '0x' prefix to hexademical numbers.

This fixes PR 9651.

Patch by nobled@dreamwidth.org!

llvm-svn: 133033
2011-06-15 00:54:52 +00:00
Douglas Gregor a860e6aebc Introduce a -cc1-level option to turn off related result type
inference, to be used (only) by the Objective-C rewriter.

llvm-svn: 133025
2011-06-14 23:20:43 +00:00
Ted Kremenek 192ed0b7ee [format strings] correctly suggest correct type for '%@' specifiers. Fixes <rdar://problem/9607158>.
llvm-svn: 133024
2011-06-14 22:56:51 +00:00
Chris Lattner 848fa212e8 revert r133003 and fix the bug properly: the issue was that ## in a token
lexer is not a paste operator, it is a normal token.  This fixes a conformance
issue shown here:
http://p99.gforge.inria.fr/c99-conformance/c99-conformance-clang-2.9.html

and it defines away the crash from before.

llvm-svn: 133005
2011-06-14 18:19:37 +00:00
Chris Lattner 07efdfdafa Fix a crash on the testcase in PR9981 / rdar://9486765.
llvm-svn: 133003
2011-06-14 18:12:03 +00:00
Douglas Gregor d1cff77200 When profiling FunctionProtoTypes, don't canonicalize the expression
in a noexcept exception specification because it isn't part of the
canonical type. This ensures that we keep the exact expression written
in the noexcept exception specification, rather than accidentally
"adopting" a previously-written and canonically "equivalent" function
prototype. Fixes PR10087.

llvm-svn: 132998
2011-06-14 16:42:44 +00:00
Nico Weber c5e7386983 Warn on memset(ptr, 0, sizeof(ptr)). Diagnostic wording by Jordy Rose.
llvm-svn: 132996
2011-06-14 16:14:58 +00:00
David Majnemer c6a998712d Remove the Fix-it for missing statement in switches
llvm-svn: 132994
2011-06-14 15:24:38 +00:00
Benjamin Kramer 648788e722 StaticDiagNameIndex is never written to, place it into .rodata.
llvm-svn: 132990
2011-06-14 13:15:38 +00:00
Chris Lattner f35de48c90 when compiling in a GNU mode (e.g. gnu99) treat VLAs with a size that can be folded to a constant
as constant size arrays.  This has slightly different semantics in some insane cases, but allows
us to accept some constructs that GCC does.  Continue to be pedantic in -std=c99 and other
modes.  This addressed rdar://8733881 - error "variable-sized object may not be initialized"; g++ accepts same code

llvm-svn: 132983
2011-06-14 06:38:10 +00:00
Chris Lattner 9925ec8bf4 fix rdar://9204520 - Accept int(0.85 * 10) as an initializer in a class member
as an extension.

llvm-svn: 132980
2011-06-14 05:46:29 +00:00
David Majnemer c75d1a1098 Properly diagnose using abstract and incomplete types in va_arg
- Move a test from test/SemaTemplate/instantiate-expr-3.cpp, it did not belong there
- Incomplete and abstract types are considered hard errors

llvm-svn: 132979
2011-06-14 05:17:32 +00:00
Bruno Cardoso Lopes 3b0297a98c Update the prefetch intrinsic usage. Now the last argument tells codegen
whether it's a data or instruction cache access.

llvm-svn: 132977
2011-06-14 05:00:30 +00:00
Chris Lattner ee7286f02d fix rdar://9546171 - -Wshorten-64-to-32 shouldn't warn on vector bitcasts.
llvm-svn: 132975
2011-06-14 04:51:15 +00:00
Peter Collingbourne ee781d586e Move GlobalDecl to AST
llvm-svn: 132973
2011-06-14 04:02:39 +00:00
Jordy Rose bc7483f505 [analyzer] CStringChecker checks functions in the C standard library, not C++. Its external name is now unix.experimental.CString.
llvm-svn: 132958
2011-06-14 01:40:43 +00:00
Eli Friedman eb7fab61bd The LLVM IR representation of byval arguments has a rather strange property: if the alignment of an argument to a call is less than the specified byval alignment for that argument, there is no way to specify the alignment of the implied copy. Therefore, we must ensure that the alignment of the argument is at least the byval alignment. To do this, we have to mess with the alignment of relevant alloca's in some cases, and insert a copy that conceptually shouldn't be necessary in some cases.
This patch tries relatively hard to avoid creating an extra copy if it can be avoided (see test3 in the included testcase), but it is not possible to avoid in some cases (like test2 in the included testcase).

rdar://9483886

llvm-svn: 132957
2011-06-14 01:37:52 +00:00
Jordy Rose 45d8c12b68 [analyzer] Change large if body to early return. No functionality change.
llvm-svn: 132956
2011-06-14 01:26:48 +00:00
Jordy Rose d359289669 [analyzer] Fix modeling of strnlen to be more conservative. Move tests we can't properly model (yet?) to string-fail.c.
llvm-svn: 132955
2011-06-14 01:15:31 +00:00
Eli Friedman 51dd0185d6 Make __gnu_inline__ functions in gnu99 mode work the same way as inline functions in gnu89 mode in terms of redefinitions.
rdar://9559708 .

llvm-svn: 132953
2011-06-13 23:56:42 +00:00
Devang Patel 297207f813 Put local variables in appropriate debug info scope.
This fixes radar 8757124.

llvm-svn: 132949
2011-06-13 23:15:32 +00:00
Benjamin Kramer dc0a46d29a Put classes into anonymous namespaces.
llvm-svn: 132924
2011-06-13 18:38:45 +00:00
Douglas Gregor c9224d6714 Eliminate the -f[no]objc-infer-related-result-type flags; there's no
reason to allow the user to control these semantics through a flag.

llvm-svn: 132919
2011-06-13 16:42:53 +00:00
Douglas Gregor c0629e031c Document CheckObjCMethodOverrides
llvm-svn: 132917
2011-06-13 16:07:18 +00:00
David Majnemer 254a5c07e7 Give a diagnostic when using non-POD types in a va_arg
llvm-svn: 132905
2011-06-13 06:37:03 +00:00
David Majnemer 0ac67fa22f Improve the diagnostics generated for switch statements missing expressions
- Move the diagnostic to the case statement instead of at the end of the switch
- Add a fix-it hint as to how to fix the compilation error

llvm-svn: 132903
2011-06-13 05:50:12 +00:00
Chandler Carruth ff455bbc3c Fix a broken index left over from before this function was converted to
handle memcpy and memmove. Spotted by Nico.

llvm-svn: 132902
2011-06-13 05:00:35 +00:00
David Majnemer bffdbd288a Correct the spelling of instantiation
llvm-svn: 132901
2011-06-13 04:29:15 +00:00
Richard Smith 4a4beec7b0 Don't assert on initialized typedef declarations in classes:
struct {
    typedef int A = 0;
  };

According to the C++11 standard, this is not ill-formed, but does not have any ascribed meaning. We can't reasonably accept it, so treat it as ill-formed.

Also switch C++ from an incorrect 'fields can only be initialized in constructors' diagnostic for this case to C's 'illegal initializer (only variables can be initialized)'

llvm-svn: 132890
2011-06-12 11:43:46 +00:00
Fariborz Jahanian 8086dfc7d4 Added 'atomic' for objc properties.
llvm-svn: 132879
2011-06-11 17:37:19 +00:00
Richard Smith 938f40b5aa Implement support for C++11 in-class initialization of non-static data members.
llvm-svn: 132878
2011-06-11 17:19:42 +00:00
Fariborz Jahanian 1c2d29e3c3 Add code completetion code for the new 'atomic' attribute
keyword in objc property decl.

llvm-svn: 132877
2011-06-11 17:14:27 +00:00
Douglas Gregor 2720dc656b Fix order of operands for the warning about incompatible Objective-C
pointer assignment in C++. This was a longstanding problem spotted by
Jordy Rose.

llvm-svn: 132873
2011-06-11 04:42:12 +00:00
Douglas Gregor 33823727c8 Implement Objective-C Related Result Type semantics.
Related result types apply Cocoa conventions to the type of message
sends and property accesses to Objective-C methods that are known to
always return objects whose type is the same as the type of the
receiving class (or a subclass thereof), such as +alloc and
-init. This tightens up static type safety for Objective-C, so that we
now diagnose mistakes like this:

t.m:4:10: warning: incompatible pointer types initializing 'NSSet *'
with an
      expression of type 'NSArray *' [-Wincompatible-pointer-types]
  NSSet *array = [[NSArray alloc] init];
         ^       ~~~~~~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:72:1:
note: 
      instance method 'init' is assumed to return an instance of its
      receiver
      type ('NSArray *')
- (id)init;
^

It also means that we get decent type inference when writing code in
Objective-C++0x:

  auto array = [[NSMutableArray alloc] initWithObjects:@"one",  @"two",nil];
  //    ^ now infers NSMutableArray* rather than id

llvm-svn: 132868
2011-06-11 01:09:30 +00:00
Fariborz Jahanian c3bcde088f Restore 'atomic' as an attribute of objc
properties.

llvm-svn: 132866
2011-06-11 00:45:12 +00:00
Eli Friedman 300f55dcad PR10120: Make CodeGenModule::getVTableLinkage use NamedDecl::getLinkage to determine whether the vtable should be externally visible, instead of a rough approximation of it which messes up with templates.
While I'm here, zap the other user of isInAnonymousNamespace outside of Decl.cpp.

llvm-svn: 132861
2011-06-10 21:53:06 +00:00
Nick Lewycky cd4cfb3e29 __OBJC__ is also a standard predefined macro.
llvm-svn: 132855
2011-06-10 20:56:43 +00:00
Alexis Hunt b1b368f36d This change is breaking selfhost. Revert it until I have more time
to study it.

llvm-svn: 132843
2011-06-10 12:07:09 +00:00
Alexis Hunt ff0ff6549d Implement caching of copy assignment operator lookup.
I believe, upon, careful review, that this code causes us to incorrectly
handle exception specifications of copy assignment operators in C++03
mode. However, we currently do not seem to properly implement the subtle
distinction between copying of members and bases made by implicit copy
constructors and assignment operators in C++03 - namely that they are
limited in their overload selection - in all cases. As such, I feel that
committing this code is correct pending a careful review of our
implementation of these semantics.

llvm-svn: 132841
2011-06-10 09:24:41 +00:00
Jordy Rose 1734737d9f [analyzer] PR8962 again. Ban ParenExprs (and friends) from block-level expressions (by calling IgnoreParens before adding expressions to blocks). Undo 132769 (LiveVariables' local IgnoreParens), since it's no longer necessary.
Also, have Environment stop looking through NoOp casts; it didn't match the behavior of LiveVariables. And once that's gone, the whole cast block of that switch is unnecessary.

llvm-svn: 132840
2011-06-10 08:49:37 +00:00
Alexis Hunt 899bd447cf Implement caching for copy constructors in similar situations.
llvm-svn: 132835
2011-06-10 04:44:37 +00:00
Alexis Hunt eef8ee0c8d Implement caching of default constructors on the resolution table. This
isn't yet used for the less controlled environments of initialization.

Also a few random text fixups.

llvm-svn: 132833
2011-06-10 03:50:41 +00:00
Richard Trieu caa33d36fb Made changes to how 'struct'/'class' mismatches are handled in -Wmismatched-tags.
- Removed fix-it hints from template instaniations since changes to the
templates are rarely helpful.
- Changed the caret in template instaniations from the class/struct name to the
class/struct keyword, matching the other warnings.
- Do not offer fix-it hints when multiple declarations disagree.  Warnings are
still given.
- Once a definition is found, offer a fix-it hint to all previous declarations
with wrong tag.
- Declarations that disagree with a previous definition will get a fix-it hint
to change the declaration.

llvm-svn: 132831
2011-06-10 03:11:26 +00:00
Fariborz Jahanian 624b299685 Don't add objc method name mangling to locally declared function.
// rdar://9566314

llvm-svn: 132791
2011-06-09 19:25:01 +00:00
Hans Wennborg de2e67e546 Handle overloaded operators in ?: precedence warning
This is a follow-up to r132565, and should address the rest of PR9969:

Warn about cases such as

int foo(A a, bool b) {
 return a + b ? 1 : 2; // user probably meant a + (b ? 1 : 2);
}

also when + is an overloaded operator call.

llvm-svn: 132784
2011-06-09 17:06:51 +00:00
Jordy Rose 891d613289 [analyzer] Ignore parentheses around block-level expressions when computing liveness. Fixes the other half of PR8962.
llvm-svn: 132769
2011-06-09 05:44:04 +00:00
Jordy Rose ab8a668849 [analyzer] Look through __extension__ expressions in a GRState's Environment. Fixes PR8962.
llvm-svn: 132762
2011-06-08 22:47:39 +00:00
Fariborz Jahanian 5d5cf1905c Remove 'atomic' as a property attribute keyword.
It is not a sanctioned keyword and is assumed as default.
// rdar://8790791

llvm-svn: 132753
2011-06-08 16:40:09 +00:00
Stuart Hastings 5b7b11cedb Followup to 132737; make two-character string explicit, add some
comments.  rdar://problem/9037836

llvm-svn: 132752
2011-06-08 16:06:31 +00:00
Peter Collingbourne 23f1bee3c0 Modify a diagnostic introduced in r132612 to emit QualTypes directly
This fixes a memory error on FreeBSD (and is the right thing to do
in any case).

llvm-svn: 132750
2011-06-08 15:15:17 +00:00
Chandler Carruth e6c881843d Fix a bunch more notes that were emitted even when the diagnostic they
were intended for was suppressed.

llvm-svn: 132746
2011-06-08 10:26:03 +00:00
Chandler Carruth 2561f09c9b Revert "hack in my new variables for GCC"
Very sorry for the accidental commit of WIP code.

llvm-svn: 132745
2011-06-08 10:14:38 +00:00
Chandler Carruth d54186ac33 Fix a regression in the two-phase lookup diagnostics that switching the
namespace set algorithm (re-)introduced. We may not have seen the 'std'
namespace, but we should still suggested associated namespaces. Easy
fix, but a bit annoying to test.

llvm-svn: 132744
2011-06-08 10:13:17 +00:00
Chandler Carruth 0169ec0988 hack in my new variables for GCC
llvm-svn: 132743
2011-06-08 10:13:14 +00:00
Stuart Hastings 7fdc6707ac Clang support for ARM Uv/Uy/Uq inline-asm constraints.
rdar://problem/9037836

llvm-svn: 132737
2011-06-07 23:45:05 +00:00
Joerg Sonnenberger 87717773e2 Sort -lgcc after -lgcc_s for NetBSD, otherwise shared libraries on i386
may pick it up. This would create bad text relocations.

llvm-svn: 132736
2011-06-07 23:39:17 +00:00
Fariborz Jahanian c32830cd64 More coherent diagnostic when a stack variable is
declared __weak objc-gc mode.  // rdar://9666091.

llvm-svn: 132731
2011-06-07 20:15:46 +00:00
Nick Lewycky a6820332b3 The macros defined by the language standard are still available even when the
-undef flag is passed in. Also __ASSEMBLER__ with -x assembler-with-cpp. (Don't
ask.)

llvm-svn: 132708
2011-06-07 06:07:12 +00:00
Alexis Hunt ba8e18d9ae Catch the memory leak in a bucket
llvm-svn: 132700
2011-06-07 00:11:58 +00:00
Jonathan D. Turner 780a6bf05b Touchup to comments that weren't quite in sync with code
llvm-svn: 132679
2011-06-06 16:22:39 +00:00
Douglas Gregor 522d5eb7c3 Diagnose the condition in C++ [temp.expl.spec]p16 that prohibits
specializing a member of an unspecialized template, and recover from
such errors without crashing. Fixes PR10024 / <rdar://problem/9509761>.

llvm-svn: 132677
2011-06-06 15:22:55 +00:00
Chandler Carruth d50f169098 Richard Smith was correct about how the sets should be computed for
this. My suggestion assumed a viable erase method for iterators on
SmallPtrSet.

This patch restores his original pattern.

llvm-svn: 132673
2011-06-05 23:36:55 +00:00
Richard Smith 998a591e32 Fix PR10053: Improve diagnostics and error recovery for code which some compilers incorrectly accept due to a lack of proper support for two-phase name lookup.
llvm-svn: 132672
2011-06-05 22:42:48 +00:00
Benjamin Kramer f90b5de834 Toolchain support for Ubuntu Oneiric. Patch by Michael Wild!
llvm-svn: 132669
2011-06-05 16:08:59 +00:00
Sebastian Redl d201edf1fc Drop most of InitializationSequence::SequenceKind's values. They didn't really contain any information that the step array didn't contain too. This makes debugging dumps a bit less informative, but probably not significantly so. The advantage is that the redundancy is gone, so the code is easier to understand.
ReferenceBinding is still there, because it is used in some unclear code.

llvm-svn: 132667
2011-06-05 13:59:11 +00:00
Sebastian Redl 724bfe18b7 Remove more references to FailedSequence.
llvm-svn: 132666
2011-06-05 13:59:05 +00:00
Sebastian Redl c7ca587512 Remove all references to InitializationSequence::FailedSequence from outside SemaInit.cpp. Replace them with the boolean conversion or the new Failed() function. This is a first step towards removing InitializationSequence::SequenceKind. No functionality change.
llvm-svn: 132664
2011-06-05 12:23:28 +00:00
Sebastian Redl 3da3489e49 Parse C++0x generalized initializers.
llvm-svn: 132662
2011-06-05 12:23:16 +00:00
Douglas Gregor 377c109f21 Identity and non-identity standard conversion sequences can be
compared even when one is a reference binding and the other is not
(<rdar://problem/9173984>), but the definition of an identity sequence
does not involve lvalue-to-rvalue adjustments (PR9507). Fix both
inter-related issues.

llvm-svn: 132660
2011-06-05 06:15:20 +00:00
Douglas Gregor c507db4f70 Add name mangling for expr .* expr. Fixes PR9983 / <rdar://problem/9486332>.
llvm-svn: 132659
2011-06-05 05:27:58 +00:00
Douglas Gregor 7f139d8103 Allow block returns in C++ with the form
return <expression> ;

in blocks with a 'void' result type, so long as <expression> has type
'void'. This follows the rules for C++ functions.

llvm-svn: 132658
2011-06-05 05:14:41 +00:00
Douglas Gregor 0aa91e0a66 When inferring the result type of a block based on a return statement
with a type-dependent expression, infer the placeholder type
'Context.DependentTy' to indicate that this is just a
placeholder. Fixes PR9982 / <rdar://problem/9486685>.

llvm-svn: 132657
2011-06-05 05:04:23 +00:00
Rafael Espindola d1ca71a294 Fix cmake build.
llvm-svn: 132653
2011-06-04 23:22:38 +00:00
Richard Smith c2ed270c0f Remove the old implementation of -verify, which has been dead code since r88750.
llvm-svn: 132651
2011-06-04 21:35:57 +00:00
Roman Divacky 5e300b82e2 Adjust the linker for PowerPC64/-m32 on FreeBSD too.
llvm-svn: 132635
2011-06-04 07:40:24 +00:00
Roman Divacky 00859c29bf Make -m32 work on FreeBSD/PowerPC64.
llvm-svn: 132634
2011-06-04 07:37:31 +00:00
Nick Lewycky 97864dac76 On linux, -nostdlib was causing a --start-group with no --end-group to be passed
to the linker.

llvm-svn: 132629
2011-06-04 06:27:06 +00:00
Nick Lewycky 62188bbb90 Identifiers with _CapitalLetter are reserved, so don't use them. Prefer the
common C++ pattern of using the same name for the constructor argument as you
do for the member. Noticed by inspection.

llvm-svn: 132626
2011-06-04 05:19:42 +00:00
Alexis Hunt 4ac55e33be Reimplement r132572 on top of a FoldingSet, thus hopefully solving both
the self-host failures and Chandler's concerns.

llvm-svn: 132622
2011-06-04 04:32:43 +00:00
Jordy Rose fb5e8c2814 [analyzer] Change an indent-if to an early return. No functionality change.
llvm-svn: 132618
2011-06-04 01:50:25 +00:00
Jordy Rose 097c5397a8 [analyzer] Don't crash when copying an unknown number of bytes with memcpy(). Also handle all memcpy-family return values in evalCopyCommon(), rather than having some outside and some inside.
llvm-svn: 132617
2011-06-04 01:47:27 +00:00
Jordy Rose 64ae92e5c5 [analyzer] Remove extra assignment that actually lost a few of the assumptions.
llvm-svn: 132614
2011-06-04 01:22:21 +00:00
Tanya Lattner 55808c1026 Add support for builtin astype:
__builtin_astype(): Used to reinterpreted as another data type of the same size using for both scalar and vector data types.
Added test case.

llvm-svn: 132612
2011-06-04 00:47:47 +00:00
Devang Patel 1b291b22d0 Rework r132576.
Emit debug info only if there is an insertion point. The debug info should not force an insertion point. Codegen may later on decide to not emit code for some reason, see extensive comment in CodeGenFunction::EmitStmt(), and debug info should not get in the way.

llvm-svn: 132610
2011-06-04 00:38:02 +00:00
Jordy Rose 4451cd4511 [analyzer] Fix comment for (still-disabled) evalStrncpy
llvm-svn: 132608
2011-06-04 00:05:23 +00:00
Jordy Rose 63b84be6cb [analyzer] Fix handling of "copy zero bytes" for memcpy and friends.
llvm-svn: 132607
2011-06-04 00:04:22 +00:00
Jordy Rose aee7fb9e64 [analyzer] __mempcpy_chk is the same as mempcpy (at least to CStringChecker)
llvm-svn: 132605
2011-06-03 23:42:56 +00:00
Jonathan D. Turner 205c7d559f Improvements to abbreviations for PCH which add support for EnumDecl, ObjCIvarDecl, TypedefDecl, VarDecl and FieldDecl and improve support for ParmVarDecl.
llvm-svn: 132604
2011-06-03 23:11:16 +00:00
Douglas Gregor 4cd65962dc Expose @synthesize and @dynamic via their own cursor kinds in
libclang. Fixes <rdar://problem/9537904>.

llvm-svn: 132603
2011-06-03 23:08:58 +00:00
Jonathan D. Turner d09655fce5 Test of commit access.
llvm-svn: 132596
2011-06-03 21:46:44 +00:00
Alexis Hunt 967ea7ca6b Revert r132572 to figure out why it broke selfhost and clean it up as
suggested by Chandler.

llvm-svn: 132593
2011-06-03 21:10:40 +00:00
Devang Patel 887e215e64 Emit debug info only if there is an insertion point. The debug info should not force an insertion point. Codegen may later on decide to not emit code for some reason, see extensive comment in CodeGenFunction::EmitStmt(), and debug info should not get in the way.
llvm-svn: 132576
2011-06-03 19:21:47 +00:00
Alexis Hunt 1b02ed8c7c Begin implementing a cache of special member lookups. Currently only
destructors are implemented but other special members are on the way,
which is where the real benefits of this will be visible.

llvm-svn: 132572
2011-06-03 18:36:49 +00:00
Matt Beaumont-Gay aef8c72255 Don't warn about -Wno-foo where foo is an unknown warning option. Explicitly
passing -Wunknown-warning-option will re-enable warnings about -Wno-foo.

llvm-svn: 132570
2011-06-03 18:30:50 +00:00
Hans Wennborg cf9bac4bc9 Warn about missing parentheses for conditional operator.
Warn in cases such as "x + someCondition ? 42 : 0;",
where the condition expression looks arithmetic, and has
a right-hand side that looks boolean.

This (partly) addresses http://llvm.org/bugs/show_bug.cgi?id=9969

llvm-svn: 132565
2011-06-03 18:00:36 +00:00
Hans Wennborg 0bb0df5839 Make -Wignored-qualifiers point to the first ignored qualifier.
In code such as "char* volatile const j()", Clang warns that "volatile
const" will be ignored. Make it point to the first ignored qualifier,
and simplify the code a bit.

llvm-svn: 132563
2011-06-03 17:37:26 +00:00
Devang Patel f1e2a7f0f0 Simplify.
llvm-svn: 132560
2011-06-03 17:23:47 +00:00
Devang Patel 597a730cb8 Fix typedef's context.
llvm-svn: 132557
2011-06-03 17:05:26 +00:00