Commit Graph

8825 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 3446898e90 Use -emit-llvm-only in the test.
llvm-svn: 114636
2010-09-23 09:40:20 +00:00
Daniel Dunbar 1fae17a8e5 Tweak test to pass -ffreestanding, to avoid platform dependent header issues.
llvm-svn: 114627
2010-09-23 04:40:10 +00:00
Daniel Dunbar 19964dbe3b IRgen/ABI/ARM: Return large vectors in memory.
llvm-svn: 114619
2010-09-23 01:54:32 +00:00
Daniel Dunbar b34b08098c IRgen/ABI/ARM: Trust the backend to pass vectors correctly for the given ABI.
- Therefore, we can lower out the NEON wrapper structs and pass the vectors
   directly. This makes a huge difference in the cleanliness of the IR after
   optimization.
 - I will trust, but verify, via future ABITest testing (for APCS-GNU, at
   least).

llvm-svn: 114618
2010-09-23 01:54:28 +00:00
Devang Patel f063cb49d8 Testcase for r114585.
llvm-svn: 114586
2010-09-22 21:13:48 +00:00
Argyrios Kyrtzidis ca0d0cd3b9 Implement -Wpadded and -Wpacked.
-Wpadded warns when undesired padding is introduced in a struct. (rdar://7469556)
-Wpacked warns if a struct is given the packed attribute, but the packed attribute has no effect
  on the layout or the size of the struct. Such structs may be mis-aligned for little benefit.

The warnings are emitted at the point where layout is calculated, that is at RecordLayoutBuilder.
To avoid calculating the layouts of all structs regardless of whether they are needed or not,
I let the layouts be lazily constructed when needed. This has the disadvantage that the above warnings
will be emitted only when they are used for IR gen, and not e.g with -fsyntax-only:

$ cat t.c
struct S {
  char c;
  int i;
};
void f(struct S* s) {}

$ clang -fsyntax-only -Wpadded t.c
$ clang -c -Wpadded t.c -o t.o
t.c:3:7: warning: padding struct 'struct S' with 3 bytes to align 'i' [-Wpadded]
  int i;
      ^
1 warning generated.

This is a good tradeoff between providing the warnings and not calculating layouts for all
structs in case the user has enabled a couple of rarely used warnings.

llvm-svn: 114544
2010-09-22 14:32:24 +00:00
Chris Lattner 775e635b5a update a bunch of tests that are using the x86 backend instead of grepping IR :(
llvm-svn: 114535
2010-09-22 06:09:31 +00:00
Chris Lattner b2f659b7a0 fix the rest of rdar://8461279 - clang miscompiles address-space qualified atomics
llvm-svn: 114503
2010-09-21 23:40:48 +00:00
Chris Lattner c9066d3072 same bug as before, this time with __sync_val_compare_and_swap.
llvm-svn: 114502
2010-09-21 23:35:30 +00:00
Chris Lattner 7cf46bfda0 fix __sync_bool_compare_and_swap to work with address-space qualified types.
llvm-svn: 114498
2010-09-21 23:24:52 +00:00
Chris Lattner 65dce5eeee filecheckize.
llvm-svn: 114497
2010-09-21 23:22:41 +00:00
Fariborz Jahanian 521c72c756 Fixes an IRgen ICE due to cast of null pointer to
a vla type (fixes pr7827).

llvm-svn: 114495
2010-09-21 22:53:33 +00:00
Ted Kremenek 2f07563f47 Correctly register the class extension as the lexical DeclContext for ObjC methods declared with @property in class extensions.
This matches the behavior for setters.

Also pass the class extension to ProcessPropertyDecl as the lexical DeclContext, even when not redeclaring the @property.

This fixes the remaining issues in <rdar://problem/7410145>.

llvm-svn: 114477
2010-09-21 20:52:59 +00:00
Fariborz Jahanian cb75021034 IRgen for gnu extension's conditional lvalue expression
with missing LHS. radar 8453812. Executable test is checked 
into llvm test suite.

llvm-svn: 114457
2010-09-21 18:32:21 +00:00
Ted Kremenek e3a7d1ba40 For ObjCPropertyDecls in class extensions, use the class extension as the lexical DeclContext for newly created
ObjCMethodDecls.  Further, use the location of the new property declaration as the location of new ObjCMethodDecls
(if they didn't previously exist).

This fixes more of the issues reported in <rdar://problem/7410145>.

llvm-svn: 114456
2010-09-21 18:28:43 +00:00
Douglas Gregor 0212fd7169 Add code completion for C++ constructors wherever we see the class (or
class template) and are in a context where we can have a value.

llvm-svn: 114441
2010-09-21 16:06:22 +00:00
Argyrios Kyrtzidis 03f0e2b5b4 Do not warn with -Wuninitialized when the member is used in a sizeof or address-of expression.
Fixes rdar://8331312.

llvm-svn: 114426
2010-09-21 10:47:20 +00:00
Douglas Gregor 7466127a4b When providing code completions for an argument in an Objective-C
message send, e.g.,

  [[NSString alloc] initWithCString:<CC>

look up all of the possible methods and determine the preferred type
for the argument expression based on the type of the corresponding
parameter.

llvm-svn: 114379
2010-09-21 00:03:25 +00:00
Fariborz Jahanian 8162d4ad31 Implements in IRgen gnu extensions missing LHS for
complex conditionals. Radar 8453812.

llvm-svn: 114376
2010-09-20 23:50:22 +00:00
Douglas Gregor 5fb901deee Code completion has no reason to prefer values over types, especially
at the statement level or in Objective-C message receivers. Therefore,
just give types and declarations the same basic priority, and adjust
from there.

llvm-svn: 114374
2010-09-20 23:11:55 +00:00
Nate Begeman abb5a7370d Check in support for OpenCL conditional operator on vector types.
llvm-svn: 114371
2010-09-20 22:41:17 +00:00
Douglas Gregor db5c09a8cd Get rid of the lame attempt to prioritize "void" functions at
statement context; it really isn't helpful in practice (remember
printf!) and we'll be doing other adjustments for statements very soon.

llvm-svn: 114358
2010-09-20 21:25:19 +00:00
Douglas Gregor 9dcf58a546 Tweak priorities for some types and macros:
- In Objective-C, we prefer BOOL to bool for historic reasons;
  slightly penalize "bool".
  - Treat Nil macro as a NULL pointer constant.
  - Treat YES, NO, true, and false macros as constants.
  - Treat the bool macro as a type.

llvm-svn: 114356
2010-09-20 21:11:48 +00:00
Douglas Gregor 8af2ff89f7 Introduce a simple, substitution-based compression scheme for USRs, so
that redundant types don't result in super-long USRs. Fixes
<rdar://problem/8447875>.

llvm-svn: 114347
2010-09-20 20:37:39 +00:00
Douglas Gregor db8c6fd18f Check that an overloaded function name, when used by the ! operator,
actually resolves to a particular function. Fixes PR8181, from Faisal
Vali!

llvm-svn: 114331
2010-09-20 17:13:33 +00:00
Argyrios Kyrtzidis 40cec8326c Revert r114316, -Wunused-value enabled by default was intended.
llvm-svn: 114318
2010-09-19 23:03:35 +00:00
Argyrios Kyrtzidis 3698bf1c6d Make -Wunused-value off by default, matching GCC. Fixes rdar://7126194.
llvm-svn: 114316
2010-09-19 21:21:44 +00:00
Argyrios Kyrtzidis 72664df103 Implement -Wunused-label.
llvm-svn: 114315
2010-09-19 21:21:25 +00:00
Argyrios Kyrtzidis 9096341310 Warn when an expression result in a LabelStmt is unused.
llvm-svn: 114314
2010-09-19 21:21:10 +00:00
Fariborz Jahanian 4fbf4af0f6 Fixes IRgen bug in objc++ reference binding of a
getter expression. 
Fixes // rdar://8437240

llvm-svn: 114299
2010-09-18 20:47:25 +00:00
Fariborz Jahanian 2b1d88abfb Problem with gnu conditional extension with missing
LHS and when conditional expression is an array. Since
it will be decayed, saved expression must be saved with
decayed expression. This is necessary to preserve semantics
of this extension (and prevent an IRGen crash which expects
an array to always be decayed). I am sure there will be other
cases in c++ (aggregate conditionals for example) when saving of the 
expression must happen after some transformation on conditional
expression has happened. 
Doug, please review.  Fixes // rdar://8446940

llvm-svn: 114296
2010-09-18 19:38:38 +00:00
Douglas Gregor 521db40c15 Give the Objective-C _cmd an "unlikely" code completion priority; it's
very rarely used.

llvm-svn: 114286
2010-09-18 15:16:27 +00:00
John McCall 386dfc738e static local variables with destructors don't require a global destructor
unless we're on a platform without __cxa_atexit (or use thereof has been
disabled).  This patch actually just disables the check completely for
static locals, but I've filed http://llvm.org/bugs/show_bug.cgi?id=8176 to
track the platform-specific fix.

llvm-svn: 114269
2010-09-18 05:25:11 +00:00
Douglas Gregor 112b51e72d Add another text for code completion after recovery
llvm-svn: 114257
2010-09-18 02:10:40 +00:00
Douglas Gregor eda7e545e6 Continue parsing more postfix expressions, even after semantic
errors. Improves code completion in yet another case.

llvm-svn: 114255
2010-09-18 01:28:11 +00:00
John Thompson 1224061281 Added '|' delimiter to separate inline asm multiple alternative constraints for Clang side of support.
llvm-svn: 114253
2010-09-18 01:15:13 +00:00
John Thompson 9a587aaaa9 Add more error checking to attribute vecreturn
llvm-svn: 114251
2010-09-18 01:12:07 +00:00
John McCall 8ea46b6654 Fix a bug with binding l-values to elided temporaries, and leave a couple
helpful asserts behind.

llvm-svn: 114250
2010-09-18 00:58:34 +00:00
Bill Wendling cbacefd36f Testcase for r114239.
llvm-svn: 114247
2010-09-18 00:26:29 +00:00
Daniel Dunbar 60785eb0f2 Sema/transparent_union: Make sure to add implicit cast when constructing
implicit union values for the transparent_union extension.

llvm-svn: 114236
2010-09-17 23:21:43 +00:00
Douglas Gregor 196cf88a01 Update test
llvm-svn: 114234
2010-09-17 23:01:08 +00:00
Douglas Gregor ec06c124f1 Improve recovery when the middle expression of a ternary operator is ill-formed
llvm-svn: 114231
2010-09-17 22:41:34 +00:00
Douglas Gregor 29d907de03 When we run into an error parsing or type-checking the left-hand side
of a binary expression, continue on and parse the right-hand side of
the binary expression anyway, but don't call the semantic actions to
type-check. Previously, we would see the error and then, effectively,
skip tokens until the end of the statement. 

The result should be more useful recovery, both in the normal case
(we'll actually see errors beyond the first one in a statement), but
it also helps code completion do a much better job, because we do
"real" code completion on the right-hand side of an invalid binary
expression rather than completing with the recovery completion. For
example, given

  x = p->y

if there is no variable named "x", we can still complete after the p->
as a member expression. Along the recovery path, we would have
completed after the "->" as if we were in an expression context, which
is mostly useless.

llvm-svn: 114225
2010-09-17 22:25:06 +00:00
Fariborz Jahanian b3e8712a14 Diagnose use of incomplete type on method argument type of
method definitions instead of crashing in code gen.
Fixes radar 8421082.

llvm-svn: 114223
2010-09-17 22:07:07 +00:00
Chris Lattner bb3bcd868a fix rdar://8445858 - __sync_* intrinsics erroneously reject ObjC pointers
llvm-svn: 114209
2010-09-17 21:12:38 +00:00
Fariborz Jahanian aaf44b2237 Only assignment operator triggers property setter call.
Fixes radar 8437253.

llvm-svn: 114207
2010-09-17 20:45:45 +00:00
Douglas Gregor f9088c93be When traversing an InitListExpr, there may not be a syntactic form;
check for NULL and visit the InitListExpr we have if there is no
syntactic form.

llvm-svn: 114203
2010-09-17 20:26:51 +00:00
David Chisnall dd84ef1e62 Add a -ftrapv-handler= option which allows a handler to invoke instead of simply aborting when a signed operation overflows. This mirrors the (GCC-incompatible) behaviour from clang 1.0 and 1.1 when -ftrapv was specified, but allows the handler to be defined for each compilation unit.
llvm-svn: 114192
2010-09-17 18:29:54 +00:00
Argyrios Kyrtzidis d059997000 Use a temporary file for output which gets renamed after all the writing is finished.
This mainly prevents failures and/or crashes when multiple processes try to read/write the same PCH file. (rdar://8392711&8294781); suggestion & review by Daniel!

llvm-svn: 114187
2010-09-17 17:38:48 +00:00
John McCall 00f1a67ad3 Fix test for no-asserts builds.
llvm-svn: 114185
2010-09-17 17:03:41 +00:00
Fariborz Jahanian 5bbd1b0051 Patch to add IRgen support for Gnu's conditional operator
extension when missing LHS. This patch covers scalar
conditionals only. Others are wip.
(pr7726, radar 8353567).

llvm-svn: 114182
2010-09-17 15:51:28 +00:00
Daniel Dunbar 7eba1bf0b7 Fix this test to use -cc1.
llvm-svn: 114156
2010-09-17 02:47:35 +00:00
John McCall 769250ea70 Currently we're initializing the vtable pointers of a class only after
the bases are completely initialized.  This won't work --- base
initializer expressions can rely on the vtables having been set up.
Check for uses of 'this' in the initializers and force a vtable
initialization if found.

This might not be good enough;  we might need to extend this to handle
the possibility of arbitrary code finding an external reference to this
(not yet completely-constructed!) object and accessing through it,
in which case we'll probably find ourselves doing a lot more unnecessary
stores.

llvm-svn: 114153
2010-09-17 02:31:44 +00:00
John McCall 7f9c92a9a0 When emitting a new-expression inside a conditional expression,
the cleanup might not be dominated by the allocation code.
In this case, we have to store aside all the delete arguments
in case we need them later.  There's room for optimization here
in cases where we end up not actually needing the cleanup in
different branches (or being able to pop it after the
initialization code).

Also make sure we only call this operator delete along the path
where we actually allocated something.

Fixes rdar://problem/8439196.

llvm-svn: 114145
2010-09-17 00:50:28 +00:00
Ted Kremenek 6174ca456f Handle '#line' in '-E' that has an empty file name. Fixes <rdar://problem/8439412>.
llvm-svn: 114142
2010-09-17 00:41:18 +00:00
Douglas Gregor 009f69979a When dealing with an anonymous enumeration declared in function
prototype scope, temporarily set the context of the enumeration
declaration to the translation unit. We do the same thing for
parameters, until we have an actual function declaration on which to
hang them. Fixes <rdar://problem/8435682>.

There is more work to do in this area, since we have existing bugs
with tags being declared/defined in function parameter lists. This fix
is correct, and we'll end up extending it when we deal with those
existing bugs.

llvm-svn: 114135
2010-09-16 23:58:57 +00:00
Daniel Dunbar dd38fbc7fb IRgen/ABI/x86-32: Realign indirect arguments when the ABI requires us to pass
them with a smaller alignment than the rest of codegen expects.

llvm-svn: 114115
2010-09-16 20:42:06 +00:00
Daniel Dunbar ed23de3348 IRgen/ABI/x86_32/Darwin: On Darwin, only structures with SSE vector types get passed
with a non-default-stack-ABI-alignment (of 16).
 - This fixes the ABI convenient, but breaks codegen since we now have
   underaligned arguments. Marginal improvement overall though, and will be
   fixed in next commit.

llvm-svn: 114113
2010-09-16 20:42:00 +00:00
Daniel Dunbar 8a6c91ff76 IRgen/x86_32/Linux: Linux seems to align all stack objects to 4 bytes, unlike
Darwin. Checked vs the handiest Linux llvm-gcc I had around, someone on Linux is
welcome to investigate more.

llvm-svn: 114112
2010-09-16 20:41:56 +00:00
Chris Lattner 516790870e improve the "enumeration value 'g' not handled in switch"
warning to handle multiple enumerators with one warning.

llvm-svn: 114093
2010-09-16 17:09:42 +00:00
Douglas Gregor e9e641cce1 Swap the priorities of constants and types, so that we prefer types.
llvm-svn: 114086
2010-09-16 16:21:35 +00:00
Douglas Gregor 1154e27b4f Don't add two code-completion results for the same selector; it
doesn't add any value. Instead, we'll just take the first method with
that selector that we find and create a completion for it.

llvm-svn: 114082
2010-09-16 16:06:31 +00:00
Douglas Gregor f37c9498bf When collecting Objective-C methods for message send completions, be
sure to visit the protocols of protocols.

llvm-svn: 114079
2010-09-16 15:34:59 +00:00
Douglas Gregor bfcea8b5b1 Implement code completion for Objective-C class message sends that are
missing the opening bracket '[', e.g.,

  NSArray <CC>

at function scope. Previously, we would only give trivial completions
(const, volatile, etc.), because we're in a "declaration name"
scope. Now, we also provide completions for class methods of NSArray,
e.g.,

  alloc

Note that we already had support for this after the first argument,
e.g.,

  NSArray method:x <CC>

would get code completion for class methods of NSArray whose selector
starts with "method:". This was already present because we recover
as if NSArray method:x were a class message send missing the opening
bracket (which was committed in r114057).

llvm-svn: 114078
2010-09-16 15:14:18 +00:00
John McCall f4ee1ddfa2 Right, there are *two* cases of pr-value class-type expressions that don't
derive from temporaries of the same type.  Black-list member expressions
as well.

llvm-svn: 114071
2010-09-16 06:57:56 +00:00
Douglas Gregor abf4a3e4c6 Implement automatic bracket insertion for Objective-C class message
sends. These are far trickier than instance messages, because we
typically have something like

  NSArray alloc]

where it appears to be a declaration of a variable named "alloc" up
until we see the ']' (or a ':'), and at that point we can't backtrace.
So, we use a combination of syntactic and semantic disambiguation to
treat this as a message send only when the type is an Objective-C type
and it has the syntax of a class message send (which would otherwise
be ill-formed).

llvm-svn: 114057
2010-09-16 01:51:54 +00:00
Ted Kremenek 8eeec5bd03 Do not warn about empty bodies for 'if' statements if the body is expanded from a macro.
Fixes <rdar://problem/8436021>.

llvm-svn: 114049
2010-09-16 00:37:05 +00:00
Ted Kremenek 853734e558 For self-comparison warning, check the source location of both the LHS and RHS to see if they
are expanded from macros (and if so, omit the warning).  Previously we were just looking at the
location of the binary expression.

Fixes <rdar://problem/8435950>.

llvm-svn: 114044
2010-09-16 00:03:01 +00:00
Douglas Gregor 3e972009fb Handle bracket insertion for Objective-C class messages in a very
narrow, almost useless case where we're inside a parenthesized
expression, e.g.,

  (NSArray alloc])

The solution to the general case still eludes me.

llvm-svn: 114039
2010-09-15 23:19:31 +00:00
Devang Patel 28b5286bda While handling change of file, check if _current_ file is already seen or not. If current file is seen then it indicates that end of previous file's lexical scope.
This fixes radar 8396182.

llvm-svn: 114018
2010-09-15 20:50:40 +00:00
Jakob Stoklund Olesen f7c67d9f46 Revert "Clean up in buildbot directories."
This reverts commit 113814.

This patch was never intended to stay in the repository. If you are reading this
from the future, we apologize for the noise.

llvm-svn: 113990
2010-09-15 18:08:14 +00:00
Douglas Gregor ed0b69dc81 Improve code completion for Objective-C message sends when the opening
'[' is missing. Prior commits improving recovery also improved code
completion beyond the first selector, e.g., at or after the "to" in

  calculator add:x to:y

but not after "calculator". We now provide the same completions for

  calculator <CC>

that we would for

  [calculator <CC>

if "calculator" is an expression whose type is something that can
receive Objective-C messages.

This code completion works for instance and super message sends, but not
class message sends.

llvm-svn: 113976
2010-09-15 16:23:04 +00:00
Douglas Gregor 7617c7d295 Extend bracket insertion to message sends to "super", e.g.,
super method:arg]

will now recover nicely and insert the '[' before 'super'.

llvm-svn: 113971
2010-09-15 15:09:43 +00:00
Douglas Gregor d6d980044e Extend bracket insertion to handle nullary selectors, e.g.
a getFoo]

llvm-svn: 113969
2010-09-15 14:54:45 +00:00
Douglas Gregor e9bba4f1a4 Implement bracket insertion for Objective-C instance message sends as
part of parser recovery. For example, given:

  a method1:arg];

we detect after parsing the expression "a" that we have the start of a
message send expression. We pretend we've seen a '[' prior to the a,
then parse the remainder as a message send. We'll then give a
diagnostic+fix-it such as:

fixit-objc-message.m:17:3: error: missing '[' at start of message
      send expression
  a method1:arg];
  ^
  [

The algorithm here is very simple, and always assumes that the open
bracket goes at the beginning of the message send. It also only works
for non-super instance message sends at this time.

llvm-svn: 113968
2010-09-15 14:51:05 +00:00
Benjamin Kramer 6cbfca121b Tweak regex not to accidentally match a trailing \r.
llvm-svn: 113966
2010-09-15 12:31:46 +00:00
Cameron Esfahani 70004ec456 Fix pointer-signext.c test case: it was relying on value names, which don't appear in the non-assert build. Switch to using check-next as well.
llvm-svn: 113964
2010-09-15 10:52:02 +00:00
John McCall 5a948500c5 Test hardening.
llvm-svn: 113963
2010-09-15 10:38:11 +00:00
John McCall 7a626f63f7 one piece of code is responsible for the lifetime of every aggregate
slot.  The easiest way to do that was to bundle up the information
we care about for aggregate slots into a new structure which demands
that its creators at least consider the question.

I could probably be convinced that the ObjC 'needs GC' bit should
be rolled into this structure.
Implement generalized copy elision.  The main obstacle here is that
IR-generation must be much more careful about making sure that exactly

llvm-svn: 113962
2010-09-15 10:14:12 +00:00
Ted Kremenek 7b31a61d10 Relax assertion in CFG builder when processing ForStmts. This fixes an assertion failure
on code containing GNU statement expressions reported in PR 8141.

llvm-svn: 113953
2010-09-15 07:01:20 +00:00
Ted Kremenek c4deb92316 Disallow the use of UnknownVal as the index for ElementRegions. UnknownVals can be used as
the index when the value evaluation isn't powerful enough.  By creating ElementRegions with
UnknownVals as the index, this gives the false impression that they are the same element, when
they really aren't.  This becomes really problematic when deriving symbols from these regions
(e.g., those representing the initial value of the index), since two different indices will
get the same symbol for their binding.

This fixes an issue with the idempotent operations checker that would cause two indices that
are clearly not the same to make it appear as if they always had the same value.

Fixes <rdar://problem/8431728>.

llvm-svn: 113920
2010-09-15 03:13:30 +00:00
Cameron Esfahani eb85650e67 Fix Windows64 target info so pointer arithmetic is done correctly, and no sign extension code is emitted: PtrDiffType needs to be a signed long long. Add a corresponding test case.
llvm-svn: 113910
2010-09-15 00:28:12 +00:00
Francois Pichet f657b639fd Microsoft's flexible array rules relaxation:
- in union
   - as the only element of a struct/class.

llvm-svn: 113909
2010-09-15 00:14:08 +00:00
Douglas Gregor 5e35d59188 Introduce a new code-completion context for a parenthesized
expression, e.g., after the '(' that could also be a type cast. Here,
we provide types as code-completion results in C/Objective-C (C++
already had them), although we wouldn't in a normal expression context.

llvm-svn: 113904
2010-09-14 23:59:36 +00:00
Sebastian Redl 058fc820d7 Fix destructor and assignment operator lookup in the has_nothrow traits.
llvm-svn: 113897
2010-09-14 23:40:14 +00:00
Ted Kremenek c95589d2e6 Don't divide-by-zero in RegionStoreManager::getSizeInElements() when getting the size of a VLA. We don't track VLA extents yet,
but we should at least not crash.  Fixes <rdar://problem/8424269>.

llvm-svn: 113888
2010-09-14 23:08:34 +00:00
Fariborz Jahanian 805b74ea30 RHS of property expression assignment requires
copy initialization before passing it to 
a setter. Fixes radar 8427922.

llvm-svn: 113885
2010-09-14 23:02:38 +00:00
Douglas Gregor 6ed2feebfc When marking the declarations in a default argument expression as
"used", at the time that the default argument itself is used, also
mark destructors that will be called by this expression. This fixes a
regression that I introduced in r113700, which broke WebKit, and fixes
<rdar://problem/8427926>.

llvm-svn: 113883
2010-09-14 22:55:20 +00:00
John McCall d3be2c83d5 The paired 'operator delete' for a placement 'operator new' is always a
placement 'operator delete', even if there are no placement args (i.e.
overload resolution selected an operator new with default arguments).

llvm-svn: 113861
2010-09-14 21:34:24 +00:00
John McCall 824c2f537c Implement the EH cleanup to call 'operator delete' if a new-expression throws
(but not if destructors associated with the full-expression throw).

llvm-svn: 113836
2010-09-14 07:57:04 +00:00
Ted Kremenek 8abff774aa Fix CFGBuilder crash reported in PR 8141.
llvm-svn: 113826
2010-09-14 01:13:32 +00:00
Argyrios Kyrtzidis 9efa1ce145 Fix VLA miscompilation.
llvm.stacksave/llvm.stackrestore wasn't emitted for VLAs in inner scopes.
Fixes r8403108.

llvm-svn: 113822
2010-09-14 00:42:34 +00:00
Jakob Stoklund Olesen 54481e5948 Clean up in buildbot directories.
This test created a statements.ll file until about a month ago. Some buildbots
still have this file in their source dir. This is the easiest way to remove the
file on all bots. Then I'll revert.

llvm-svn: 113814
2010-09-13 23:26:28 +00:00
Douglas Gregor 83d61f914a Add __char16_t and __char32_t as aliases for the C++0x char16_t and
char32_t, respectively, but which can also be used in C++98/03
mode. Fixes <rdar://problem/8418510>.

llvm-svn: 113813
2010-09-13 23:21:44 +00:00
Douglas Gregor 16a2bdd6b0 Introduce a new kind of cursor into libclang, which covers a reference
to an "overloaded" set of declarations. This cursor kind works for
unresolved references to functions/templates (e.g., a call within a
template), using declarations, and Objective-C class and protocol
forward declarations.

llvm-svn: 113805
2010-09-13 22:52:57 +00:00
Sebastian Redl 5c649bc7bb Don't crash when using type traits on a class with a constructor template.
llvm-svn: 113796
2010-09-13 22:18:28 +00:00
Sebastian Redl c15c326b51 Remove CXXRecordDecl::getDefaultConstructor(), an inherently unsafe function due to lazy declaration of default constructors. Now that __has_nothrow_constructor doesn't use it anymore, part of PR8101 is fixed.
llvm-svn: 113794
2010-09-13 22:02:47 +00:00
Eric Christopher 26c045d9ff Try to get this to stop leaving a temporary file on linux.
llvm-svn: 113793
2010-09-13 21:51:42 +00:00
Sebastian Redl 951006f510 Have __has_nothrow_copy use Sema's lookup routines. This fixes the problem with not finding implicitly declared copy constructors, part of PR8107.
llvm-svn: 113784
2010-09-13 21:10:20 +00:00
Devang Patel 068b5b3d61 Recognize .ll as input files.
Handle %test_debuginfo on a RUN command line.

This set up now allows one to write small test cases to check debug info.
e.g.

; RUN: %clang -O0 -g %s -c -o %t.o
; RUN: %clang %t.o -o %t.out  
; RUN: %test_debuginfo %s %t.out

define i32 @f1(i32 %i) nounwind ssp {
; DEBUGGER: break f1                                                               
; DEBUGGER: r                                                                      
; DEBUGGER: p i                                                                    
; CHECK: $1 = 42                                                                   
entry:
  %i.addr = alloca i32, align 4
...
...
}

It is also possible now to write test cases in c/c++.
The plan is to store these debug info testcases in a separate place.

llvm-svn: 113780
2010-09-13 20:46:23 +00:00
Argyrios Kyrtzidis 14ec9f674a When applying 'delete' on a pointer-to-array type match GCC and EDG behavior and treat it as 'delete[]'.
Also offer a fix-it hint adding '[]'.

llvm-svn: 113778
2010-09-13 20:15:54 +00:00
Fariborz Jahanian 0aa35b9cf5 Block description for trivial block literals have
their 'isa' field scanned regardless.

llvm-svn: 113749
2010-09-13 16:09:44 +00:00
Argyrios Kyrtzidis f24d569f9e Fix C++ PCH issue.
The canonical FunctionTemplateDecl contains the specializations but we cannot use getCanonicalDecl on Template because it may still be initializing.
Write and read it from PCH.
Fixes http://llvm.org/PR8134

llvm-svn: 113744
2010-09-13 11:45:48 +00:00
Abramo Bagnara 3aabb4b452 Congruent diagnostic for void* arithmetic.
llvm-svn: 113740
2010-09-13 06:50:07 +00:00
Abramo Bagnara 6a0c4097f1 Parentheses around address non-type template argument is demoted to an extension warning.
llvm-svn: 113739
2010-09-13 06:06:58 +00:00
Douglas Gregor bdd7b2358b Don't assert when attempting to take the address of an overloaded
function fails due to ambiguities in partial ordering of function
templates. Fixes PR8033.

llvm-svn: 113725
2010-09-12 08:16:09 +00:00
Douglas Gregor d5b730c9d5 When performing overload resolution, only compare the final conversion
sequences for two conversion functions when in fact we are in the text
of initialization by a user-defined conversion sequences. Fixes PR8034.

llvm-svn: 113724
2010-09-12 08:07:23 +00:00
Douglas Gregor 6162334ce0 Diagnose the instantiation of variables (including static data
members) with function type. Fixes PR8047.

llvm-svn: 113723
2010-09-12 07:37:24 +00:00
Douglas Gregor 6309e3d18e Don't complain about useless user-defined conversion functions when
they were instantiated from a template. In template metaprogramming,
stuff happens. Fixes PR8065.

llvm-svn: 113722
2010-09-12 07:22:28 +00:00
Douglas Gregor 8ce63154d0 When diagnosing C++ [temp.expl.spec]p3 in C++98/03 mode, downgrade the
error to a warning if we're in a case that would be allowed in
C++0x. This "fixes" PR8084 by making Clang accept more code than GCC
and (non-strict) EDG do. 

Also, add the missing test case for the C++0x semantics, which should
have been in r113717.

llvm-svn: 113718
2010-09-12 05:24:55 +00:00
Francois Pichet 488b4a7d94 Add basic support for Microsoft enum forward declaration.
Assigning an underlying integral type to an enum forward declaration will come in a next patch.

llvm-svn: 113716
2010-09-12 05:06:55 +00:00
Douglas Gregor 2bbc0266e0 Implement the "note" in C++ [over.built]p1, which is actually meant to
be a semantic requirement that a built-in overloaded operator is not
added to the overload set of there is already a user-defined
overloaded operator with the same parameter types. Fixes PR8087.

llvm-svn: 113713
2010-09-12 04:28:07 +00:00
Douglas Gregor c87f4d4aba Don't perform integral promotions from an incompletion enumeration
type. Fixes PR8089 in a slightly different way than had been suggested.

llvm-svn: 113711
2010-09-12 03:38:25 +00:00
Douglas Gregor 32b3de519d Teach the EvaluatedExprVisitor and its client, which marks
declarations in potentially-evaluated subexpressions, about
recursion. Fixes the release-mode self-host failure I introduced in
r113700.

llvm-svn: 113708
2010-09-11 23:32:50 +00:00
Francois Pichet 8f170b8239 Fix last test still failing on Win32. 100% pass rate now!
llvm-svn: 113702
2010-09-11 20:43:12 +00:00
Douglas Gregor 8a01b2a392 When parsing default function arguments, do not mark any declarations
used in the default function argument as "used". Instead, when we
actually use the default argument, make another pass over the
expression to mark any used declarations as "used" at that point. This
addresses two kinds of related problems:

  1) We were marking some declarations "used" that shouldn't be,
  because we were marking them too eagerly.
  2) We were failing to mark some declarations as "used" when we
  should, if the first time it was instantiated happened to be an
  unevaluated context, we wouldn't mark them again at a later point.

I've also added a potentially-handy visitor class template
EvaluatedExprVisitor, which only visits the potentially-evaluated
subexpressions of an expression. I bet this would have been useful for
noexcept...

Fixes PR5810 and PR8127.

llvm-svn: 113700
2010-09-11 20:24:53 +00:00
Douglas Gregor 250ab1dc0e The two libclang crash-recovery tests that involve precompiled
preambles end up leaving the precompiled preambles around. This is by
design, since we do minimal cleanup during crash recovery. However,
it's unfortunate for testing, so introduce a hook that allows these
two tests to put the precompiled preamble somewhere where we can
delete them after testing.

llvm-svn: 113698
2010-09-11 18:05:19 +00:00
Douglas Gregor ce3449f5bd Tweak GetPreamblePCHPath() to more closely match the behavior of the
Windows GetTempPath() function, and be sure to create the directory in
which the precompiled preamble will reside before creating the
temporary file itself.

llvm-svn: 113695
2010-09-11 17:51:16 +00:00
Fariborz Jahanian 933c6723a4 Fixes an obscure bug in importd block variable layout
information when imported variable is used
more than once. Originally though to be a bug in importing
block varibles. Fixes radar 8417746.

llvm-svn: 113675
2010-09-11 01:27:29 +00:00
Sebastian Redl a8bac37bb1 Test destructors in delete expressions and of temporaries for throwing.
llvm-svn: 113664
2010-09-10 23:27:10 +00:00
John McCall db76892e72 Support in-class initialization of static const floating-point data members.
llvm-svn: 113663
2010-09-10 23:21:22 +00:00
Sebastian Redl b8a76c42b5 Address Doug's comments.
llvm-svn: 113650
2010-09-10 22:34:40 +00:00
Douglas Gregor ca3682d486 Make sure we're producing a newline in the preprocessed output before
emitting a #pragma, whenever one is needed. Fixes <rdar://problem/8417307>.

llvm-svn: 113648
2010-09-10 22:27:29 +00:00
Sebastian Redl e56be2f72c Eli helped me understand how evaluation contexts work.
llvm-svn: 113642
2010-09-10 21:57:27 +00:00
Sebastian Redl 8c40ba392c Test CXXNoexceptExpr codegen and serialization.
llvm-svn: 113630
2010-09-10 21:04:03 +00:00
Sebastian Redl 4fa4a6b85e Add another small test case.
llvm-svn: 113628
2010-09-10 21:03:58 +00:00
Sebastian Redl dbd14bdefc Tests for noexcept in templates.
llvm-svn: 113625
2010-09-10 20:55:50 +00:00
Sebastian Redl 5f0180d815 First version of a testcase, plus fixes.
llvm-svn: 113624
2010-09-10 20:55:47 +00:00
Ted Kremenek 0a3f523614 Polish diagnostics for null dereferences via ObjC ivar accesses. Finishes up <rdar://problem/6352035>.
llvm-svn: 113612
2010-09-10 20:20:49 +00:00
Fariborz Jahanian f93ac89414 IRGen fix for using property-dot syntax to pass
reference object to a c++ member function.
fixes radar 8409336.

llvm-svn: 113602
2010-09-10 18:56:35 +00:00
Douglas Gregor 6a6dac2fbf Support strlen() and __builtin_strlen() as constant expressions with
the call argument is a string literal. Fixes
<rdar://problem/8413477>.

llvm-svn: 113580
2010-09-10 06:27:15 +00:00
Ted Kremenek e495c99055 Implement: <rdar://problem/6351970> rule request: warn if @synchronized mutex can be nil
llvm-svn: 113573
2010-09-10 03:05:40 +00:00
Tom Care 4545b2df42 Added AnalyzerStatsChecker, a path sensitive check that reports visitation statistics about analysis. Running clang with the -analyzer-stats flag will emit warnings containing the information. We can then run a postanalysis script to take this data and give useful information about how much the analyzer missed in a project.
llvm-svn: 113568
2010-09-10 00:44:44 +00:00
Douglas Gregor a93ab66331 Add libclang support for label statements, gotos, and taking the
address of a label (GNU extension).

llvm-svn: 113564
2010-09-10 00:22:18 +00:00
Douglas Gregor d198047ef3 Add libclang visitation for C99 designated initializers.
llvm-svn: 113560
2010-09-09 23:28:23 +00:00
Douglas Gregor 0d4d88cf38 Add libclang visitation for __builtin_offsetof's components (fields
and array references).

llvm-svn: 113556
2010-09-09 23:10:46 +00:00
Fariborz Jahanian e89d03f619 property reference expression used on lhs of assignment
follows objective's semantics and is not overload'able
with an assignment operator. Fixes a crash and a missing
diagnostics. Radar 8379892.

llvm-svn: 113555
2010-09-09 23:01:10 +00:00
Ted Kremenek 5cdaeaaa1d Clean up obtuse wording of checker diagnostic of using an uninitialized value in a function call.
Fixes: <rdar://problem/8409480> “warning: Pass-by-value argument in function call is undefined” message can be improved
llvm-svn: 113554
2010-09-09 22:51:55 +00:00
Douglas Gregor c7d6576d54 When we parse a pragma, keep track of how that pragma was originally
spelled (#pragma, _Pragma, __pragma). In -E mode, use that information
to add appropriate newlines when translating _Pragma and __pragma into
#pragma, like GCC does. Fixes <rdar://problem/8412013>.

llvm-svn: 113553
2010-09-09 22:45:38 +00:00
Douglas Gregor f3af311382 Teach libclang to walk the base and member initializers of a
constructor, in source order. Also introduces a new reference kind for
class members, which is used here (for member initializers) and will
also be used for designated initializers and offsetof.

llvm-svn: 113545
2010-09-09 21:42:20 +00:00
Ted Kremenek ff3a4ff6e9 Use FindReportInEquivalenceClass to identify all the nodes used for the trimmed graph (in BugReporter). This fixes a problem where a leak that happened to occur on both an exit() path and a non-exit() path was getting reported with the exit() path (which users don't care about).
This fixes:

<rdar://problem/8331641> leak reports should not show paths that end with exit() (but ones that don't end with exit())

llvm-svn: 113524
2010-09-09 19:05:34 +00:00
Douglas Gregor 57df3b4b12 Use temporary files for this test, to see if we can flush out an inexplicable error on Windows
llvm-svn: 113493
2010-09-09 16:16:39 +00:00
Douglas Gregor 54e5b13a27 Add proper type-source information to UnaryTypeTraitExpr, including
libclang visitation.

llvm-svn: 113492
2010-09-09 16:14:44 +00:00
Ted Kremenek 5f256da834 Rename GRState::getSVal() -> getRawSVal() and getSimplifiedSVal() -> getSVal().
The end result is now we eagarly constant-fold symbols in the analyzer that are perfectly constrained
to be a constant value.  This allows us to recover some path-sensitivity in some cases by lowering
the required level of reasoning power needed to evaluate some expressions.

The net win from this change is that the false positive in PR 8015 is fixed, and we also
find more idempotent operations bugs.

We do, however, regress with the BugReporterVisitors, which need to be modified to understand
this constant folding (and look past it).  This causes some diagnostic regressions in plist-output.m
which will get addressed in a future patch.  plist-output.m is now marked XFAIL, while
plist-output-alternate.m now tests that the plist output is working, but with the suboptimal
diagnostics.  This second test file will eventually be removed.

llvm-svn: 113477
2010-09-09 07:13:00 +00:00
Ted Kremenek b8176da314 Check format strings when a called function has more than one FormatAttr (one for 'scanf' and one for 'printf'). Fixes <rdar://problem/8409437>.
llvm-svn: 113472
2010-09-09 04:33:05 +00:00
Ted Kremenek 1520dae606 It appears that technically a null format string is not warned under -Wformat-nonliteral, as
the function processing the format string can decided whether or not to accept a null format string (e.g., asl_log).  Fixes <rdar://problem/8269537>.

llvm-svn: 113469
2010-09-09 03:51:42 +00:00
Ted Kremenek 0f107e4386 Relax __attribute_((nonnull)) checking to allow the attribute on functions with no pointer arguments. GCC doesn't warn
in this case, and the attribute is trivially satisfied (and benign).  Fixes <rdar://problem/8364828>.

llvm-svn: 113464
2010-09-09 01:17:32 +00:00
Ted Kremenek 5ebb6156d8 Include test case for <rdar://problem/5880430>.
llvm-svn: 113458
2010-09-09 00:40:43 +00:00
Fariborz Jahanian cfddabf5a3 Block ivar layout must assume that the 'isa'
field of the block descriptor is GC'able (scanned)
as this what the runtime expects (one can send it 
messages). Radar 8394947.

llvm-svn: 113454
2010-09-09 00:21:45 +00:00
Ted Kremenek f2b0a1bfa0 Enhance -Wunreachable-code to not consider the 'default:' branch of a switch statement live if a switch on an enum value has
explicit 'case:' statements for each enum value.

llvm-svn: 113451
2010-09-09 00:06:10 +00:00