Граф коммитов

11151 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor 5cbe101b50 Look through parenthesized declarators when determining whether an
instantiated function template was written with a prototype or via
some kind of typedef. Fixes PR10273 / <rdar://problem/9723679>. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134426 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-05 18:30:26 +00:00
Douglas Gregor 9a30c9946e ActOnCXXConditionDeclaration should take into account that
ActOnDeclarator can return NULL. Fixes PR10270, from Hans Wennborg!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134416 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-05 16:13:20 +00:00
Eli Friedman 14508ff0bf Don't use x86_mmx where it isn't necessary.
The start of some work on getting -mno-mmx working the way we want it to.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134300 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-02 00:57:27 +00:00
Eli Friedman d18eecac71 Make clang behave in a gcc-compatible way in the presence of multiple flags for the same x86 target feature (e.g. -mno-sse -msse). gcc uses a somewhat unintuitive algorithm here in that the enabled SSE instructions is based on the order of the *last* flag for *each* feature-level, so that "-mno-sse -msse2" only enables SSE2, but "-mno-sse -msse2 -msse" enables all SSE levels.
Issue reported on cfe-dev.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134296 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-02 00:34:19 +00:00
Eric Christopher 12c738d8d7 Add a testcase for r134292.
Part of rdar://9714064


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134295 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-02 00:28:30 +00:00
Argyrios Kyrtzidis 28445f0b62 -Fix mistake in ASTContext::getInnerObjCOwnership noticed by Doug
-Remove unnecessary 'return'.
-Remove unnecessary 'if' check (llvm_unreachable make sure attrStr will be non-null)
-Add a test of transferring ownership to a reference cast type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134285 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 23:01:46 +00:00
Argyrios Kyrtzidis 05d4876a64 Fix the warning that is emitted when an ownership attribute is applied incorrectly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134278 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 22:23:09 +00:00
Argyrios Kyrtzidis 1c73dcbe1f Fix assertion hit in inferARCWriteback.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134276 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 22:23:03 +00:00
Argyrios Kyrtzidis 0a85183be6 [ARC] When casting from a pointer to an objective-c object with known ownership, if the
cast type has no ownership specified, implicitly "transfer" the ownership of the cast'ed type
to the cast type:

id x;
(NSString**)&x; // Casting as (__strong NSString**).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134275 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 22:22:59 +00:00
Argyrios Kyrtzidis 31862ba5ea [ARC] When casting from a pointer to an objective-c object with known ownership, if the
cast type has no ownership specified, implicitly "transfer" the ownership of the cast'ed type
to the cast type:

id x;
static_cast<NSString**>(&x); // Casting as (__strong NSString**).

This currently only works for C++ named casts, C casts to follow.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134273 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 22:22:50 +00:00
Argyrios Kyrtzidis 17b6399f84 Introduce Declarator::ObjCCatchContext, this will result in correct error for 'auto' in obj-c catch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134271 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 22:22:40 +00:00
Douglas Gregor e67d1512f2 Emit guard variables for any weak global that has a run-time
initializer. Previously, we only used guard variables for weak static
data members. Fixes <rdar://problem/9692249>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134266 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 21:54:36 +00:00
Douglas Gregor 07f4a06c40 When adding boolean keywords for typo correction, add either "bool" or
"_Bool" (depending on dialect), but not both, since they have the same
edit distance from "Bool".


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134263 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 21:27:45 +00:00
Douglas Gregor df9a41f3c1 Fix testcase
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134262 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 21:19:15 +00:00
Douglas Gregor bcc3e660a1 Don't zero-initialize default-initialized local variables that have
trivial default constructors. This generated-code regression was
caused by r131796, which had simplified the handling of default
initialization in Sema. Fixes <rdar://problem/9694300>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134260 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 21:08:19 +00:00
Richard Trieu 31fd2b7881 For code such as:
int f(int x) {
  if (int foo = f(bar)) {}
  return 0;
}

Clang produces the following error messages:

paren_imbalance.cc:2:19: error: use of undeclared identifier 'bar'
  if (int foo = f(bar)) {}
                  ^
paren_imbalance.cc:2:26: error: expected ')'
  if (int foo = f(bar)) {}
                        ^
paren_imbalance.cc:2:6: note: to match this '('
  if (int foo = f(bar)) {}
     ^

The second error is incorrect.  This patch will stop Clang from producing an error on parenthesis imbalance during error recovery when there isn't one.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134258 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 20:54:02 +00:00
Richard Trieu 304e233921 Fix for PR7410. Allow functions in a derived class that improperly overwrite a virtual function in the base class to be inserted into the derived class function list to prevent extra errors every time the derived class is used.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134251 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 20:02:53 +00:00
Richard Smith c89edf5aaa Fix AST representations of alias-declarations which define tag types. Inside classes, the tag types need to have an associated access specifier, and inside function definitions, they need to be included in the declarations of the DeclStmt. These issues manifested as assertions during template instantiation, and also in a WIP constexpr patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134250 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 19:46:12 +00:00
John McCall 35ee32e800 Just mangle substituted template parameter types as unresolved types.
This is kindof questionable but seems to do more-or-less the right thing.
This is not a particularly friendly part of the ABI.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134227 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 02:19:08 +00:00
Douglas Gregor 561f81243f Introduce the notion of instantiation dependence into Clang's AST. A
type/expression/template argument/etc. is instantiation-dependent if
it somehow involves a template parameter, even if it doesn't meet the
requirements for the more common kinds of dependence (dependent type,
type-dependent expression, value-dependent expression).

When we see an instantiation-dependent type, we know we always need to
perform substitution into that instantiation-dependent type. This
keeps us from short-circuiting evaluation in places where we
shouldn't, and lets us properly implement C++0x [temp.type]p2.

In theory, this would also allow us to properly mangle
instantiation-dependent-but-not-dependent decltype types per the
Itanium C++ ABI, but we aren't quite there because we still mangle
based on the canonical type in cases like, e.g.,

  template<unsigned> struct A { };
  template<typename T>
    void f(A<sizeof(sizeof(decltype(T() + T())))>) { }
  template void f<int>(A<sizeof(sizeof(int))>);

and therefore get the wrong answer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134225 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 01:22:09 +00:00
John McCall 68a51a7f9c Change the mangling of enclosing template template parameters
that serve as the base template name of an unresolved-name to
be mangled as a substitution.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134213 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-01 00:04:39 +00:00
Hans Wennborg 935a70c1e7 Fix off-by-one error in StringLiteral::getLocationOfByte.
This fixes PR10223.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134183 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-30 20:17:41 +00:00
Hans Wennborg 150fee8b2b Move test/Sema/return.cpp into test/SemaCXX/return.cpp
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134171 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-30 17:20:18 +00:00
John McCall ea4aba0e97 Perform lvalue-to-rvalue conversions on both operands of ->*
and the RHS of .*.  Noticed by Enea Zaffanella!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134170 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-30 17:15:34 +00:00
Hans Wennborg 62273f91b6 Test for errors for returning a value from a ctor or dtor.
This fell out when Chandler landed the patch in r134138.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-30 15:48:23 +00:00
Douglas Gregor 54001c1e6a Check for deprecated/unavailable/etc attributes on fields that are
initialized via initializer lists. Fixes <rdar://problem/9694686>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134099 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 21:51:31 +00:00
Douglas Gregor e12a11f26b When redeclaring a local extern in the same scope, make sure that we
replace the existing declaration appropriately. Patch by Jordy Rose,
fixes PR10013 / <rdar://problem/9584157>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134097 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 21:22:02 +00:00
Fariborz Jahanian 8fefc8e245 objc-arc: fix a IRGen crash when checking for
accessibility of an initializer which is a compound 
statement. // rdar://9694706


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134091 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 20:00:16 +00:00
Fariborz Jahanian 5d9b6bf9de Use existing -fcatch-undefined-behavior option,
replacing -freset-local-blocks. // rdar://9227352


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134082 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 18:41:17 +00:00
Eli Friedman ded137fcab We don't pass classes with a copy-constructor or destructor byval, so the address takes up an integer register (if one is available). Make sure the x86-64 ABI implementation takes that into account properly.
The fixed implementation is compatible with the implementation both gcc and llvm-gcc use.

rdar://9686430 . (This is the issue that was reported in the thread "[LLVMdev] Segfault calling LLVM libs from a clang-compiled executable".)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134059 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-29 07:04:55 +00:00
Fariborz Jahanian 1077e420b8 Under a compiler flag, -freset-local-blocks,
wipe out stack blocks when they go out of scope.
// rdar://9227352


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134045 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 23:51:26 +00:00
Daniel Dunbar d6a4d18f52 Revert r133024, "[format strings] correctly suggest correct type for '%@'
specifiers.  Fixes <rdar://problem/9607158>." because it causes false positives
on some code that uses CF toll free bridging.
 - I'll let Doug or Ted figure out the right fix here, possibly just to accept
   any pointer type.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134041 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 23:33:55 +00:00
Chandler Carruth be098b32bf Update this test to reflect the new (deterministic) order in r134038.
This was part of Kaelyn's original patch that got dropped while I was
working on it, but after I ran my tests. =/ Sorry.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134039 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 22:58:10 +00:00
Chad Rosier ea76d8a996 Modify test case to allow buildbots to make forward progress. This test should
now (incorrectly) pass.  Once the appropriate fixes have been made this test
should be reverted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134035 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 22:29:53 +00:00
Daniel Dunbar 99ca47b21f Driver/Darwin: -force_load can be specified multiple times.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134025 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 20:16:02 +00:00
Eric Christopher de31fd7eee Split out logic for valid clobbers and valid inline asm registers.
Fixes rdar://9281377


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134016 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 18:20:53 +00:00
John McCall d3d49bb27c Be more thorough about mangling unresolved types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134011 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 16:49:23 +00:00
Douglas Gregor d8bba9c152 Add support for C++ namespace-aware typo correction, e.g., correcting
vector<int>

to

  std::vector<int>

Patch by Kaelyn Uhrain, with minor tweaks + PCH support from me. Fixes
PR5776/<rdar://problem/8652971>.

Thanks Kaelyn!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134007 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 16:20:02 +00:00
Douglas Gregor 020540b740 Fix test case; we may end up linking against the libprofile_rt dylib.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134006 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 15:40:31 +00:00
Jordy Rose 0fa6bf7f02 [analyzer] strnlen isn't a builtin, don't test for it
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133994 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 05:34:40 +00:00
Chris Lattner 83068315f7 Fix PR9279 - Macro expansion stack trace seriously broken with function-style macros, by not recursively printing notes for other 'instantiated from' notes.
This is a one line fix here:
+      // Don't print recursive instantiation notes from an instantiation note.
+      Loc = SM.getSpellingLoc(Loc);

While here, fix the testcase to be more precise (it got filecheck'ized
brutally), and fix EmitCaretDiagnostic to be private and to not pass down
the unused 'Level' argument.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133993 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 05:11:33 +00:00
Argyrios Kyrtzidis db7abf78de Remove the call to GetTypeForDeclarator in Sema::ActOnCXXConditionDeclaration.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133984 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 03:01:12 +00:00
Argyrios Kyrtzidis 2ba68b2964 Cut down a few of the excess errors in the test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133983 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 03:01:09 +00:00
Fariborz Jahanian 6326e05fe8 Provide fix-it for '.' <-> '->' for Objective-C ivar/property access.
// rdar://7811841


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133970 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-28 00:00:52 +00:00
John McCall c03fa498b9 ARC writeback isn't supposed to apply to local indirect pointers,
only to pointers to locals.  But it should work inside blocks, too.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133969 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 23:59:58 +00:00
John McCall 6ce51ee94b Don't factor in visibility for templates and template arguments
for explicit specializations with their own explicit visibility.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133958 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 23:06:04 +00:00
John McCall a0b7d2ed23 Merge this test into another.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133957 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 22:57:05 +00:00
John McCall 239cad79cb Update test for r133934.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133942 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 21:23:26 +00:00
Fariborz Jahanian 68fe96adf7 Handle nonnull attribute with optional argument number on
functions with arguments of transparent unions type.
// rdar://9584012


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133941 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 21:12:03 +00:00
Jordy Rose eda368791b [analyzer] Use UnknownVal when default-initializing arrays whose element types we don't model, to distinguish them from uninitialized arrays (PR10163).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133937 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 20:36:38 +00:00
Nico Weber 9d11e6f475 Revert parts of r133860 to fix a crash. Add a test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133931 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 19:46:54 +00:00
Argyrios Kyrtzidis 064c44b8a1 [libclang] Avoid having the cursor of an expression replace the declaration cursor
when the expression source range overlaps the declaration range.

This can happen for C++ constructor expressions whose range generally
include the variable declaration, e.g.:

  MyCXXClass foo; // Make sure pointing at 'foo' returns a VarDecl cursor.

rdar://9124499.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133930 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 19:42:23 +00:00
Argyrios Kyrtzidis 5517b89953 [libclang] Avoid having the cursor of an expression "overwrite" the annotation of the
variable declaration that it belongs to.

This can happen for C++ constructor expressions whose range generally
include the variable declaration, e.g.:

  MyCXXClass foo; // Make sure we don't annotate 'foo' as a CallExpr cursor.

rdar://9124499.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133929 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 19:42:20 +00:00
Douglas Gregor d0e8b78278 When instantiating a C++ "new" expression, don't fake source locations
for the '(' and ')' around the initializer unless we actually have an
initializer. Fixes PR10197, an issue where we were value-initializing
rather than default-initializing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133913 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 16:55:54 +00:00
Chandler Carruth 6628969c3e Cleanup a fixme by using a specific diagnostic for subscripting
a pointer to void.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133912 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 16:32:27 +00:00
Chandler Carruth ae19806d2c Fix missing braces around two statements that were intended to be part
of a single if block. This is really annoying to track down and test.
Silly changes to the test case caused it to stop showing up. I wish
there were a more concrete way of asserting that a note attaches to the
intended diagnostic.

This fixes PR10195.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133907 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 08:31:58 +00:00
Chandler Carruth 13b21be065 Factor out (some of) the checking for invalid forms of pointer
arithmetic into a couple of common routines. Use these to make the
messages more consistent in the various contexts, especially in terms of
consistently diagnosing binary operators with invalid types on both the
left- and right-hand side. Also, improve the grammar and wording of the
messages some, handling both two pointers and two (different) types.

The wording of function pointer arithmetic diagnostics still strikes me
as poorly phrased, and I worry this makes them slightly more awkward if
more consistent. I'm hoping to fix that with a follow-on patch and test
case that will also make them more helpful when a typedef or template
type parameter makes the type completely opaque.

Suggestions on better wording are very welcome, thanks to Richard Smith
for some initial help on that front.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133906 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-27 08:02:19 +00:00
Richard Smith 2ced044c34 Fix PR10187: when diagnosing a two-phase-lookup-related failure, don't assert that any names we find are valid candidates for the call.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133898 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-26 22:19:54 +00:00
Richard Smith 1ab0d90af4 Fix a couple more issues related to r133854:
When performing semantic analysis on a member declaration, fix the check for whether we are declaring a function to check for parenthesized declarators, declaration via decltype, etc.

Also fix the semantic check to not treat FuncType* as a function type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133862 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-25 02:28:38 +00:00
John McCall df7b091c58 Do not apply the ARC move optimization to 'const'-qualified xvalues.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133861 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-25 02:26:44 +00:00
John McCall 913dab2525 Mark the multiply which occurs as part of performing pointer
arithmetic on a VLA as 'nsw', per discussion with djg, and
implement pointer arithmetic (other than array accesses) and
pointer subtraction for VLA types.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133855 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-25 01:32:37 +00:00
Douglas Gregor 555f57e354 When deciding how to parse "= something" as part of a member
declaration, determine whether the declaration will end up declaring a
function using semantic criteria (e.g., it will have function type)
rather than purely syntactic criteria (e.g., it has the form of a
function declarator). Fixes <rdar://problem/9670557>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133854 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-25 00:56:27 +00:00
Fariborz Jahanian 831fb96225 objc-arc/mrc: Allow ns_returns_not_retained attribute on properties
to turn off warning on those properties which follow Cocoa naming
convention for retaining objects and yet they were not meant for
such purposes. Also, perform consistancy checking for declared
getters of such methods. // rdar://9636091



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133849 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-25 00:17:46 +00:00
John McCall 88c1dfccf8 Two more test cases which have been long uncommitted.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133842 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 23:30:52 +00:00
John McCall 4027f09736 Test case for r133840, neglectfully uncommitted.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133841 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 23:29:50 +00:00
Devang Patel 1d323e0482 Fix struct member's scope. Patch by Xi Wang.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133829 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 22:00:59 +00:00
John McCall bc8d40d85f Change the IR-generation of VLAs so that we capture bounds,
not sizes;  so that we use well-typed allocas;  and so that we
properly recurse through the full set of variably-modified types.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133827 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 21:55:10 +00:00
Fariborz Jahanian 327126ee3d No need to warn if 'unavailable' method/property
is not implemented. // rdar://9651605


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133819 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 20:31:37 +00:00
Argyrios Kyrtzidis a7bf7bbdb1 Only do delayed diagnostics if there were no errors when parsing the decl.
Fixes crash in http://llvm.org/PR10109 & rdar://9584039.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133816 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 19:59:27 +00:00
Argyrios Kyrtzidis cf79eba65b [arcmt] Add test for rdar://9601437.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133807 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 18:41:23 +00:00
Fariborz Jahanian 921c143229 objc-arc: Check on a variety of unsafe assignment of retained
objects.  // rdar://9495837


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133806 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 18:25:34 +00:00
Argyrios Kyrtzidis 7ddf6b2d77 Allow Lexer::getLocForEndOfToken to return the location just passed the macro instantiation
if the location given points at the last token of the macro instantiation.

Fixes rdar://9045701.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133804 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 17:58:59 +00:00
Argyrios Kyrtzidis b5303aa20e Allow the fixit for missing ':' in the ?: ternary operator if it is pointing
at the start of a macro instantiation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133801 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 17:28:29 +00:00
Sean Hunt c39b6bc958 This patch started as an attempt to fix up the horrid naming
conventions. I then discovered a typo in the using declaration bit in
LookupSpecialMember. This led to discovering [namespace.udecl]p15, which
clang implements incorrectly. Thus I've added a comment and implemented
the code consistently with the rest of clang - that is incorrectly.

And because I don't want to include tests of something incorrect, I've
ripped the test out.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133784 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 02:11:39 +00:00
Argyrios Kyrtzidis b8b0313e84 Rename objc_lifetime -> objc_ownership, and modify diagnostics to talk about 'ownership', not 'lifetime'.
rdar://9477613.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133779 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-24 00:08:59 +00:00
Fariborz Jahanian a81397323c When forming a cycle in objc's inheritance hierarchy,
diagnose it properly and don't throw clang into an
infinit loop. // rdar://9653341


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133773 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-23 23:16:19 +00:00
Argyrios Kyrtzidis b1094a0621 [arcmt] Fully migrate ObjC++ classes, rdar://9660007.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133763 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-23 21:21:33 +00:00
Argyrios Kyrtzidis 7707c75ff9 [arcmt] Remove rewriteAllocCopyWithZone transformation; not needed anymore.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133762 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-23 21:21:28 +00:00
Fariborz Jahanian d028302b57 Improve on warning when objc pointer is used in
c++ catch in fragile abi - per Eli's request.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133760 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-23 21:17:59 +00:00
Fariborz Jahanian cf5abc7ba0 Support for catching objc pointer objects in c++ catch-statement
in fragile abi mode and some other cleanups. // rdar://8940528



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133747 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-23 19:00:08 +00:00
Eli Friedman b9b4b789eb Fix Sema::CheckVectorOperands so that it doesn't try to insert a cast expression into the LHS of a compound assignment. Fixes compound assignment of various "compatible" vector types, including NEON-vector and gcc-vector types.
<rdar://problem/9640356>



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133737 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-23 18:10:35 +00:00
Andrew Trick 7140b3cde0 cmake+lit: final cleanup related to the recent churn
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133730 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-23 18:00:48 +00:00
Nick Lewycky 115f2b95d5 Fix this test on machines that don't run clang -cc1as when asked to assemble.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133688 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-23 05:38:06 +00:00
Argyrios Kyrtzidis 572bbec2e0 Allow unavailable function calls inside unavailable functions in C++/ObjC++ as well. rdar://9660196
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133672 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-23 00:41:50 +00:00
Sean Hunt 4cc12c6e47 Clean up the heart of the caching code and miss fewer edge cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133671 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-23 00:26:20 +00:00
Andrew Trick b7bca251bc lit support for REQUIRES: asserts.
Take #2. Don't piggyback on the existing config.build_mode. Instead,
define a new lit feature for each build feature we need (currently
just "asserts"). Teach both autoconf'd and cmake'd Makefiles to define
this feature within test/lit.site.cfg. This doesn't require any lit
harness changes and should be more robust across build systems.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133665 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 23:23:49 +00:00
Douglas Gregor 4f0845ec62 Check for placeholders early on in
Sema::CreateUnaryExprOrTypeTraitExpr() rather than recursing in some
cases. Fixes <rdar://problem/9659191>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133663 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 23:21:00 +00:00
Fariborz Jahanian d543130a30 Issue warning if weak_import attribute is added to an already
declared variable and ignore it. // rdar://9538608


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133654 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 22:08:50 +00:00
Daniel Dunbar 9c7f469318 test/Unit: Fixup lit.cfg to allow running inside test/Unit (with llvm-config in
path).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133653 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 21:46:43 +00:00
Fariborz Jahanian 9d96bce991 Alloa catching Objective-C id's being thrown with C++ throw
in Darwin's fragile abi mode.  // rdar://8940528


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133639 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 20:21:51 +00:00
Manuel Klimek 0d9106fc97 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133637 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 20:02:16 +00:00
Douglas Gregor c09ce1224d Copy diagnostic pragmas to the preprocessed output, from Richard Osborne!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133633 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 19:41:48 +00:00
Douglas Gregor 1d441ee69a 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133628 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 18:16:25 +00:00
Argyrios Kyrtzidis 7bf952e601 [arcmt] Make -Warc-unsafe-retained-assign an error when migrating. rdar://8939557
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133627 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 18:03:59 +00:00
Argyrios Kyrtzidis d26fef0e80 Change "cannot assign retained object.." warning to "assigning retained object.."
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133625 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 18:03:53 +00:00
Fariborz Jahanian 8295b7b51b objc-arc: Allow unbridged cast of retainable object to
integral as it is not transferring ownership.. 
// rdar://9619861


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133622 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 16:36:45 +00:00
Douglas Gregor d1bd98a2c2 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133621 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 16:32:26 +00:00
Douglas Gregor d7b2316776 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133620 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 16:12:01 +00:00
Andrew Trick fc0f40acc6 Only do config-time substitution of LLVM_BUILD_MODE in
test/lit.site.cfg, not Unit/test/lit.site.cfg.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133609 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 05:44:01 +00:00
John McCall d768e9d29a 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133601 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 02:32:12 +00:00
John McCall d71315c551 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133590 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-22 00:53:57 +00:00
Richard Smith e3499cae8e Fix PR10168: don't warn for unused non-dependent variables in both the template definition and each instantiation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133580 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 23:42:09 +00:00
Richard Smith cd6f36693e First part of PR9968: the __range variable in a dependent C++11 for-range statement is implicitly used by that statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133572 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 23:07:19 +00:00
John McCall 26a6ec7be5 Fix the mangling of dependent-scope decl ref expressions so that they
use the unresolved-name production correctly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133554 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 22:12:46 +00:00
Daniel Dunbar a68e1c398a Driver/Darwin: Fixup version check for -object_path_lto support.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133548 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 21:18:32 +00:00
Daniel Dunbar 5bfa656e13 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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133543 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 20:55:11 +00:00
Fariborz Jahanian c8505ad918 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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133535 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 19:42:38 +00:00
Fariborz Jahanian af9751747b objc-arc: CodeGen part of unbridged cast of CF types.
// rdar://9474349


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133525 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 17:38:29 +00:00
Chandler Carruth 14d251cd62 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133523 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 17:22:09 +00:00
Douglas Gregor 03e8003051 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>.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133521 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 17:03:29 +00:00
Nick Lewycky 0c25d285fb Also fix the warning about using "clang" instead of %clang.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133492 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 00:23:47 +00:00
Nick Lewycky 1110425df2 Remove the leading hyphen so that grep doesn't parse it as one long option :)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133491 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 00:21:22 +00:00
Daniel Dunbar 2a45fa7cf6 Driver/Darwin: Honor -Xarch_FOO when the arch matches either the toolchain or
the architecture being bound.
 - Fixes things like -Xarch_armv7.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133490 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 00:20:17 +00:00
Nick Lewycky c3b9014c72 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133489 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 00:14:18 +00:00
Eric Christopher 43fec879a5 Canonicalize register names properly.
Fixes rdar://9425559


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133486 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 00:07:10 +00:00
Eric Christopher cfd323d0d4 Move additional register names to their own lookup, separate from
register aliases. Fixes unnecessary renames of clobbers.

Fixes part of rdar://9425559


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133485 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-21 00:05:20 +00:00
Argyrios Kyrtzidis 8e2ce7fdf9 [arcmt] Always add '__bridge' cast when 'self' is cast to a C pointer. rdar://9644061
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133480 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 23:39:20 +00:00
Jordy Rose 8912aaedb4 [analyzer] Finish size argument checking for strncat (and strncpy).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133472 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 21:55:40 +00:00
Fariborz Jahanian 1522a7c35e 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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133469 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 20:54:42 +00:00
Argyrios Kyrtzidis 33f46e22b7 Warn for un-parenthesized '&' inside '|' (a & b | c), rdar://9553326.
Patch by Henry Mason with tweaks by me.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133453 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 18:41:26 +00:00
Fariborz Jahanian ab27d6ea7b 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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133450 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 17:50:03 +00:00
Douglas Gregor 0678899e0d Define __cplusplus to 201103L when in (non-GNU) C++0x mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133437 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 15:00:58 +00:00
Chandler Carruth bc9bd0e79a Use an explicitly 64-bit triple flag to ensure we can easily verify the
types printed in various diagnostics.

We could omit checking for the types, but that can mask errors where the
wrong type is streamed into the diagnostic. There was at least one of
these caught by this test already.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133429 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 08:59:25 +00:00
Chandler Carruth ae0bafa229 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133428 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 07:52:11 +00:00
Chandler Carruth 1567a8ba8d 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133425 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 07:38:51 +00:00
Chris Lattner c5cbb909e8 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133413 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 04:01:35 +00:00
Jordy Rose 5e5f15062b [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...)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133408 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 03:49:16 +00:00
Jordy Rose 9e49d9fbdc [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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133406 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-20 02:06:40 +00:00
Chandler Carruth 2af68e4761 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133383 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-19 09:05:14 +00:00
Francois Pichet e3d49b44ad Handle decltype keyword in Parser::isDeclarationSpecifier.
Fixes PR10154. Found by parsing MFC 2010 code with clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133380 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-19 08:02:06 +00:00
Chandler Carruth 18e0461ad7 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133327 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-18 01:19:03 +00:00
Argyrios Kyrtzidis e665d6929e [arcmt] Fix the ARC migrator. -arcmt-modify requires running before the initialization of SourceManager
because it is going to modify the input file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133323 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-18 00:53:41 +00:00
Argyrios Kyrtzidis 829f20097e Fix regression with @encode string. rdar://9624314.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133312 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 23:19:38 +00:00
Douglas Gregor 4020caec54 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133309 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 23:16:24 +00:00
Douglas Gregor c22d699d3a 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133306 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 22:26:49 +00:00
Douglas Gregor e559ca1672 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>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133303 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 22:11:49 +00:00
John McCall b64915a41b Only accept __bridge_retain in system headers, as Doug suggested.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133300 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 21:56:12 +00:00
John McCall 1816442fd1 As a hopefully temporary workaround for a header mistake, treat
__bridge_retain as a synonym for __bridge_retained.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133295 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 21:23:37 +00:00
Richard Trieu 4e938df048 Put the new warning from revision 133196 on NULL arithmetic behind the flag -Wnull-arthimetic and set to DefaultIgnore. A few edge cases need to be worked out before this can be set to default.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133287 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 20:35:48 +00:00
Argyrios Kyrtzidis 12189f573f Don't emit 'unavailable' errors inside an unavailable function. rdar://9623855.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133264 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 17:28:30 +00:00
Douglas Gregor ebfbf9f005 Loosen up the IR matching slightly
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133263 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 17:23:28 +00:00
Eric Christopher 8837d747bf Remove another variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133262 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 17:04:30 +00:00
Douglas Gregor 673e98b481 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!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133261 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 16:37:20 +00:00
John McCall 0502a22498 Perform an acquire memory barrier on the fast path of a thread-safe
static initializer check, as required by the Itanium ABI.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133250 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 07:33:57 +00:00
John McCall 7acddacc92 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133243 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 06:42:21 +00:00
Eric Christopher 3724020559 Clean up test to avoid using standard headers and remove an unneeded
#define.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133241 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 06:16:34 +00:00
Douglas Gregor 9a636e8403 Extend the deduced/actual argument type checking of C++
[temp.deduct.call]p4 to the deduction performed for 'auto', finishing
the fix for PR9233.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133239 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 05:31:46 +00:00
Eric Christopher b165ed7f28 Make this test suitable for optimized builds by avoiding the name.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133238 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 05:24:17 +00:00
Douglas Gregor 0f9dc86a14 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133236 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 05:09:08 +00:00
Douglas Gregor 751ec9be96 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>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133235 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 04:59:12 +00:00
Douglas Gregor 51d7cdd4bf 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133232 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 03:41:35 +00:00
Eric Christopher e3e07a5b34 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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133226 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 01:53:34 +00:00
John McCall b77115d7b9 When synthesizing implicit copy/move constructors and copy/move assignment
operators, don't make an initializer or sub-operation for zero-width
bitfields.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133221 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 00:18:42 +00:00
Douglas Gregor 8d5e18c69e Check for placeholder expressions before promoting an argument passed
through an ellipsis. Fixes <rdar://problem/9623945>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133219 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-17 00:15:10 +00:00
Eli Friedman 7a883e3e17 Add support for -force_load flag, for compat with Apple gcc. rdar://9555962 .
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133218 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 23:59:43 +00:00
John McCall 856d3798af Be sure to try a final ARC-production even in Objective-C++.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133215 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 23:24:51 +00:00
Fariborz Jahanian 6c91615e5d For the purpose of @encode'ing, accept 'void' type
(even though it is incomplete type) because gcc
says so. // rdar://9622422


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133208 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 22:34:44 +00:00
Andrew Trick 70f55bb104 cmake may require LIT_TOOLS_DIR.
Reviewed by chapuni. Sorry for breaking.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133199 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 21:47:59 +00:00
Richard Trieu 3e95ba94fd 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;



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133196 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 21:36:56 +00:00
Argyrios Kyrtzidis 22b2bc8403 [arcmt] Fix test for MSVC build.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133183 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 20:19:55 +00:00
Douglas Gregor 16cd4b744a Allow comparison between block pointers and NULL pointer
constants. Fixes PR10145.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133179 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 18:52:05 +00:00
Douglas Gregor 707a23e8b8 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133173 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 17:56:04 +00:00
Fariborz Jahanian b1f7d2496a arc: diagnose dereferencing a __weak pointer which may be
null at any time. // rdar://9612030


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133168 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 17:29:56 +00:00
Argyrios Kyrtzidis 952105343c [arcmt] Fix the test when running in Lion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133167 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 17:28:31 +00:00
John McCall 16f971fc48 Give arcmt-test an explicit triple for this test.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133165 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 17:13:30 +00:00
Douglas Gregor dbfb371e29 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>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 16:50:48 +00:00
Fariborz Jahanian 119f19b46b Set the visibility to 'hidden' when previous
declaration of global var is __private_extern__.
// rdar://9609649


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133157 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 14:49:42 +00:00
Chandler Carruth 000d428347 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*.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133155 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 09:09:40 +00:00
Jordy Rose adc42d412d [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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133154 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 07:13:34 +00:00
John McCall a07398ed98 Restore correct use of GC barriers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133144 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 04:16:24 +00:00
Chandler Carruth c7b993b4df Fix my test case from r133136 so that it actually represents the code
pattern found in the wild where this warning was firing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133143 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 04:13:47 +00:00
Argyrios Kyrtzidis d0ba7fca71 [arcmt] Fix tests in non-darwin.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133140 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 02:41:46 +00:00
Chandler Carruth fd8af77307 Add another dependency to the clang-test CMake target, this time to support lit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133138 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 02:21:11 +00:00
Chandler Carruth 4f5ef6e11f Add the new arcmt-test tool to the clang-test dependencies with
c-index-test and friends. This brings the failures on CMake clang tests
from 23 to 2 on Linux.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133137 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 02:01:48 +00:00
Chandler Carruth 5546e69729 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133136 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 02:00:04 +00:00
Andrew Trick 62c3711994 Update clang's lit.site.cfg.in in preparation for adding config.llvm_build_modes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133130 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 01:32:21 +00:00
John McCall 5861b4b4ba Make this test pretend to be on a darwin host.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133125 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 01:18:08 +00:00
John McCall 0f4c4c4445 Weaken the type-matching rules for methods that return aggregates when
complaining about mismatches in the global method pool.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133123 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 01:15:19 +00:00
Chandler Carruth 9d4562445d Make the presentation of the warnings on 'x + y ? 1 : 0' a bit more
pretty. In particular this makes it much easier for me to read messages
such as:

  x.cc:42: ?: has lower ...

Where I'm inclined to associate the third ':' with a missing column
number, but in fact column numbers have been turned off. Similar
punctuation collisions happened elsewhere as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133121 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 01:05:12 +00:00
Argyrios Kyrtzidis eaed19e241 [arcmt] Make arcmt-test accept cc1 options to make it more portable and hopefully fix MSVC failures.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133119 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 00:53:46 +00:00
John McCall edb150bcf9 Give this test a triple; I don't think we want to #define __unsafe_unretained
on all platforms in non-ARC mode.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133114 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-16 00:32:01 +00:00
John McCall 8f0e8d2296 The ARC Migration Tool. All the credit goes to Argyrios and Fariborz
for this.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133104 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 23:25:17 +00:00
John McCall f85e193739 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133103 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 23:02:42 +00:00
Eli Friedman 43e890b035 Test for r133070.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133079 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 20:17:07 +00:00
Eli Friedman 065bb5e034 Fix a couple more tests with ARM ABI.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133073 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 18:37:44 +00:00
Eli Friedman 70cbd2a2a0 Fix a regression from r132957 involving complex integers. (Fixes failures on gcc-testsuite bot.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133069 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 18:26:32 +00:00
Douglas Gregor 4ac01401b1 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133060 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 16:02:29 +00:00
Douglas Gregor 383041d31c 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133055 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 14:20:42 +00:00
Jordy Rose d5af0e17b0 [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!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133046 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 05:52:56 +00:00
Douglas Gregor b30cd4a09b 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133045 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 05:45:11 +00:00
Nico Weber 55080a78c8 Build fix attempt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133039 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 04:50:13 +00:00
Douglas Gregor 1454cb952b 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133037 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 03:23:34 +00:00
Nico Weber cf739927f9 Warn on "void f(int a[10]) { sizeof(a); }"
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133036 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 02:47:03 +00:00
Ted Kremenek fa82138018 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!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133033 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 00:54:52 +00:00
Douglas Gregor 74da19fc3a Introduce a -cc1-level option to turn off related result type
inference, to be used (only) by the Objective-C rewriter.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133025 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-14 23:20:43 +00:00
Ted Kremenek 84862f6a0b [format strings] correctly suggest correct type for '%@' specifiers. Fixes <rdar://problem/9607158>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133024 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-14 22:56:51 +00:00
Fariborz Jahanian 997e15cfdc Bad table discription of fromat-y2k causes
no-format-y2k turn off -Wformat altogether. 
// rdar://9504680


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133015 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-14 21:54:00 +00:00
Eli Friedman 12e9f8edcf Whack a bunch of tests in CodeGenCXX to work on ARM (using ARM ABI). Batch 2 of 3.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133011 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-14 21:20:53 +00:00
Chris Lattner b11e43c31d 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.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133005 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-14 18:19:37 +00:00
Chris Lattner 0e0b693159 Fix a crash on the testcase in PR9981 / rdar://9486765.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133003 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-14 18:12:03 +00:00