Commit Graph

9448 Commits

Author SHA1 Message Date
Guy Benyei f0a014bbb7 Add intel_ocl_bicc calling convention as a function attribute to clang. The calling convention is already implemented in LLVM.
llvm-svn: 171056
2012-12-25 08:53:55 +00:00
Rafael Espindola 54606d57a2 Add 171048 back but invalidate the cache of all redeclarations when setting
the body of a functions. The problem was that hasBody looks at the entire chain
and causes problems to -fvisibility-inlines-hidden if the cache was not
invalidated.

Original message:

Cache visibility of decls.

This unifies the linkage and visibility caching. I first implemented this when
working on pr13844, but the previous fixes removed the performance advantage of
this one.
This is still a step in the right direction for making linkage and visibility
cheap to use.

llvm-svn: 171053
2012-12-25 07:31:49 +00:00
NAKAMURA Takumi eb63feb5bd Revert r171048, "Cache visibility of decls."
It broke stage2.

llvm-svn: 171050
2012-12-25 04:47:44 +00:00
Rafael Espindola f92a59f0cb Cache visibility of decls.
This unifies the linkage and visibility caching. I first implemented this when
working on pr13844, but the previous fixes removed the performance advantage of
this one.

This is still a step in the right direction for making linkage and visibility
cheap to use.

llvm-svn: 171048
2012-12-25 00:39:58 +00:00
Nico Weber cb4c7f4b18 Move a declaration closer to its use. No functionality change.
llvm-svn: 170992
2012-12-23 00:40:46 +00:00
Richard Smith 21bae43fab PR14695: Fix assert from bad cast<>. Not every namespace is a NamespaceDecl; it might instead be a TranslationUnitDecl.
llvm-svn: 170976
2012-12-22 02:46:14 +00:00
Ted Kremenek 6cae9ec643 Add back -Wduplicate-enum which I mistakenly removed.
This was removed with -Wunique-enum, which is still removed.  The
corresponding thread on cfe-comments for that warning is here:

  http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-September/024224.html

If we get specific user feedback for -Wduplicate-enum we can evaluate
whether or not to keep it.

llvm-svn: 170974
2012-12-22 01:34:09 +00:00
Ted Kremenek 6487335f43 Tweak Sema::CheckLiteralKind() to also include block literals
This simplifies some diagnostic logic in checkUnsafeAssignLiteral(),
hopefully making it less error prone.

llvm-svn: 170945
2012-12-21 22:46:35 +00:00
Chad Rosier 8a67a65a4b Add comments back that were accidentally removed in r170933.
llvm-svn: 170938
2012-12-21 22:38:37 +00:00
Chad Rosier 92f0dccbad Remove unused arguments and rename to conform to coding standards.
llvm-svn: 170933
2012-12-21 22:24:43 +00:00
Ted Kremenek 44c2a2a26e Change checkUnsafeAssignLiteral() to use the new Sema::CheckLiteralKind().
Along the way, fix a bug in CheckLiteralKind(), previously in diagnoseObjCLiteralComparison, where we didn't ignore parentheses
in boxed expressions for purpose of classification.

In other words, both @42 and @(42) should be classified as numeric
literals.

llvm-svn: 170931
2012-12-21 21:59:39 +00:00
Ted Kremenek 01a33f82d2 Hoist logic for classifying Objective-C literals into Sema (proper) for use with other diagnostics.
No immediate (intended) functionality change.

llvm-svn: 170930
2012-12-21 21:59:36 +00:00
Ted Kremenek b6439e6bfe Use descriptive enum instead of raw integers for checkUnsafeAssignLiteral().
llvm-svn: 170920
2012-12-21 19:45:33 +00:00
Ted Kremenek c1f014afc8 Sink call to checkUnsafeAssignLiteral() into checkUnsafeAssignObject().
llvm-svn: 170919
2012-12-21 19:45:30 +00:00
Roman Divacky 241f45118b Remove duplicate includes.
llvm-svn: 170903
2012-12-21 17:07:08 +00:00
Richard Smith 38a549bc42 Fix regression in r170489: when instantiating a direct initializer which is a
CXXScalarValueInitExpr (or an ImplicitValueInitExpr), strip it back down to an
empty pair of parentheses so that the initialization code can tell that we're
performing value-initialization.

llvm-svn: 170867
2012-12-21 08:13:35 +00:00
Ted Kremenek 9304da9578 Extend checkUnsafeAssigns() to also handle assigning an object literal to a weak reference.
Thanks to Jordan Rose and John McCall for their sage code review.

Fixes <rdar://problem/12569201>.

llvm-svn: 170864
2012-12-21 08:04:28 +00:00
Ted Kremenek b36234deca Refactor checkUnsafeAssigns() to avoid code duplication with while loop.
This is just a minor bit of refactoring, but it is nice cleanup for
the subsequent patch that adds warning support for assigning literals
to weak variables.

llvm-svn: 170863
2012-12-21 08:04:20 +00:00
Rafael Espindola 2be6b72ce0 Don't eagerly emit a global static merged with a local extern.
When we are visiting the extern declaration of 'i' in

static int i = 99;
int foo() {
  extern int i;
  return i;
}

We should not try to handle it as if it was an function static. That is, we
must consider the written storage class.

Fixing this then exposes that the assert in EmitGlobalVarDeclLValue and the
if leading to its call are not completely accurate. They were passing before
because the second decl was marked as having external storage. I changed them
to check the linkage, which I find easier to understand.

Last but not least, there is something strange going on with cuda and opencl.
My guess is that the linkage computation for these languages needs to be
audited, but I didn't want to change that in this patch so I just updated
the storage classes to keep the current behavior.

Thanks to Reed Kotler for reporting this.

llvm-svn: 170827
2012-12-21 01:21:33 +00:00
Ted Kremenek 9453721985 Revert "Warn if a __weak variable is initialized with an Objective-C object literal."
Per code feedback, I want to see if there is a more general way to do this.

llvm-svn: 170777
2012-12-20 22:31:27 +00:00
Ted Kremenek b39cfd41f2 Warn if a __weak variable is initialized with an Objective-C object literal.
Such variables may immediately become nil or may have unpredictable
behavior.

Fixes <rdar://problem/12569201>.

llvm-svn: 170763
2012-12-20 20:55:03 +00:00
Bill Wendling 4442605f18 Revert r170500. It over-zealously converted *ALL* things named Attributes, which is wrong here.
llvm-svn: 170721
2012-12-20 19:22:21 +00:00
Fariborz Jahanian a1f8571e84 objective-C: Don't warn of unimplemented property of protocols in
category, when those properties will be implemented in category's 
primary class or one of its super classes. // rdar://12568064

llvm-svn: 170573
2012-12-19 18:58:55 +00:00
Bill Wendling 7967fc14b9 Rename the 'Attributes' class to 'Attribute'. It's going to represent a single attribute in the future.
llvm-svn: 170500
2012-12-19 07:18:12 +00:00
Richard Smith 503053a737 Fix assertion failure in self-host (and probably bogus template instantiation
too). When instantiating a direct-initializer, if we find it has zero
arguments, produce an empty ParenListExpr rather than returning a null
expression.

llvm-svn: 170490
2012-12-19 02:27:38 +00:00
Richard Smith d59b832320 PR13470: Ensure that copy-list-initialization isntantiates as
copy-list-initialization (and doesn't add an additional copy step):

Fill in the ListInitialization bit when creating a CXXConstructExpr. Use it
when instantiating initializers in order to correctly handle instantiation of
copy-list-initialization. Teach TreeTransform that function arguments are
initializations, and so need this special treatment too. Finally, remove some
hacks which were working around SubstInitializer's shortcomings.

llvm-svn: 170489
2012-12-19 01:39:02 +00:00
David Blaikie ff7d47a354 Change DeclContextLookup(Const)Result to (Mutable)ArrayRef<NamedDecl*>, as per review discussion in r170365
This does limit these typedefs to being sequences, but no current usage
requires them to be contiguous (we could expand this to a more general
iterator pair range concept at some point).

Also, it'd be nice if SmallVector were constructible directly from an ArrayRef
but this is a bit tricky since ArrayRef depends on SmallVectorBaseImpl for the
inverse conversion. (& generalizing over all range-like things, while nice,
would require some nontrivial SFINAE I haven't thought about yet)

llvm-svn: 170482
2012-12-19 00:45:41 +00:00
Guy Benyei d8a08ea98d Re-commit r170428 changes with Linux style file endings.
Add OpenCL images as clang builtin types.

llvm-svn: 170432
2012-12-18 14:38:23 +00:00
Guy Benyei 11169dded0 Revert changes from r170428, as I accidentally changed the line endings of these files to Windows style.
llvm-svn: 170431
2012-12-18 14:30:41 +00:00
Guy Benyei b13abb952a Add OpenCL images as clang builtin types.
llvm-svn: 170428
2012-12-18 12:30:03 +00:00
Rafael Espindola 74a133fa9a Merge storage classes even when contexts don't match.
This fixes the storage class of extern decls that are merged with file level
statics. The patch also fixes the linkage computation so that they are
considered internal.

llvm-svn: 170406
2012-12-18 04:18:55 +00:00
Eli Friedman 52f32b9b2b The underlying type for an enum should be an integer type, not another enum.
(This change only affects ObjC.)

<rdar://problem/12857117>.

llvm-svn: 170402
2012-12-18 02:37:32 +00:00
Anders Carlsson 2a45e409a8 When warning about a missing prototype because a function declaration is missing 'void', insert a fixit to add the void.
llvm-svn: 170399
2012-12-18 01:29:20 +00:00
Nico Weber 555d1aa3a4 IdentifierResolver: Remove an unnecessary include and an unused parameter.
llvm-svn: 170297
2012-12-17 03:51:09 +00:00
Argyrios Kyrtzidis 26444c5243 Have Sema::ActOnStartOfFunctionDef return the declaration that was passed it.
This fixes the missing warning here:

struct S {
    template <typename T>
    void meth() {
        char arr[3];
        arr[4] = 0; // warning: array index 4 is past the end of the array
    }
};

template <typename T>
void func() {
    char arr[3];
    arr[4] = 0; // no warning
}

llvm-svn: 170180
2012-12-14 06:54:03 +00:00
Argyrios Kyrtzidis 6fada2ddbd Remove code from Sema::ActOnStartOfFunctionTemplateDef that duplicates what
Sema::ActOnStartOfFunctionDef is already doing.

llvm-svn: 170179
2012-12-14 06:53:58 +00:00
Eli Friedman 07bab73c7f Using CanQualType::getAs<ArrayType> is unsafe; fix the code currently using it,
and make sure additional uses don't get introduced.  <rdar://problem/12858424>.

llvm-svn: 170081
2012-12-13 01:43:21 +00:00
Fariborz Jahanian b487388be1 objc: DOn't complain if a (SEL) expression is typecast
to (SEL). Fixes // rdar://12859590

llvm-svn: 170058
2012-12-13 00:42:06 +00:00
Eli Friedman 89a4a2cd3d Add missing check for error return from DefaultLvalueConversion. Fixes <rdar://problem/12857416>.
llvm-svn: 170056
2012-12-13 00:37:17 +00:00
Argyrios Kyrtzidis f5b993f7b1 [objc] For the ARC error that is emitted when a synthesized property implementation
has inconsistent ownership with the backing ivar, point the error location to the
ivar.

Pointing to the ivar (instead of the @synthesize) is better since this is where a fix is needed.
Also provide the location of @synthesize via a note.

This also fixes the problem where an auto-synthesized property would emit an error without
any location.

llvm-svn: 170039
2012-12-12 22:48:25 +00:00
Manuel Klimek 5704e4e91c Speeds up parsing of global declarations in cases where the warning
is switched of by about 0.8% (tested with int i<N>).

Additionally, this puts computing the diagnostic class into the hot
path more when parsing, in preparation for upcoming optimizations
in this area.

llvm-svn: 169976
2012-12-12 13:26:54 +00:00
Douglas Gregor c2e3d5cb29 Don't complain about incomplete implementations for methods that are
unavailable due to availability attributes. <rdar://problem/12798237>

llvm-svn: 169903
2012-12-11 18:53:07 +00:00
Richard Smith bd3051272c PR14558: Compute triviality of special members (etc) at the end of the class
definition, rather than at the end of the definition of the set of nested
classes. We still defer checking of the user-specified exception specification
to the end of the nesting -- we can't check that until we've parsed the
in-class initializers for non-static data members.

llvm-svn: 169805
2012-12-11 01:14:52 +00:00
Aaron Ballman 02df2e0872 Virtual method overrides can no longer have mismatched calling conventions. This fixes PR14339.
llvm-svn: 169705
2012-12-09 17:45:41 +00:00
Richard Smith 0db1ea5f68 Fix overload resolution for the initialization of a multi-dimensional
array from a braced-init-list. There seems to be a core wording wart
here (it suggests we should be testing whether the elements of the init
list are implicitly convertible to the array element type, not whether
there is an implicit conversion sequence) but our prior behavior appears
to be a bug, not a deliberate effort to implement the standard as written.

llvm-svn: 169690
2012-12-09 06:48:56 +00:00
Richard Smith f86b5dc700 PR14550: If a system header contains a bogus constexpr function definition,
don't mark the function as invalid, since we suppress the error.

llvm-svn: 169689
2012-12-09 05:55:43 +00:00
Richard Smith 6b02d46dae Finish implementing 'selected constructor' rules for triviality in C++11. In
the cases where we can't determine whether special members would be trivial
while building the class, we eagerly declare those special members. The impact
of this is bounded, since it does not trigger implicit declarations of special
members in classes which merely *use* those classes.

In order to determine whether we need to apply this rule, we also need to
eagerly declare move operations and destructors in cases where they might be
deleted. If a move operation were supposed to be deleted, it would instead
be suppressed, and we could need overload resolution to determine if we fall
back to a trivial copy operation. If a destructor were implicitly deleted,
it would cause the move constructor of any derived classes to be suppressed.

As discussed on cxx-abi-dev, C++11's selected constructor rules are also
retroactively applied as a defect resolution in C++03 mode, in order to
identify that class B has a non-trivial copy constructor (since it calls
A's constructor template, not A's copy constructor):

struct A { template<typename T> A(T &); };
struct B { mutable A a; };

llvm-svn: 169673
2012-12-08 08:32:28 +00:00
Richard Smith 1a2532b3fe Remove some remnants of the assumption that there is at most one of each
flavour of special member.

llvm-svn: 169670
2012-12-08 04:10:18 +00:00
Richard Smith 92f241f188 Properly compute triviality for explicitly-defaulted or deleted special members.
Remove pre-standard restriction on explicitly-defaulted copy constructors with
'incorrect' parameter types, and instead just make those special members
non-trivial as the standard requires.

This required making CXXRecordDecl correctly handle classes which have both a
trivial and a non-trivial special member of the same kind.

This also fixes PR13217 by reimplementing DiagnoseNontrivial in terms of the
new triviality computation technology.

llvm-svn: 169667
2012-12-08 02:53:02 +00:00
Richard Smith 189aba9305 Add a FIXME.
llvm-svn: 169664
2012-12-08 02:13:02 +00:00
Richard Smith 593f993a68 Implement C++03 [dcl.init]p5's checking for value-initialization of references
properly, rather than faking it up by pretending that a reference member makes
the default constructor non-trivial. That leads to rejects-valids when putting
such types inside unions.

llvm-svn: 169662
2012-12-08 02:01:17 +00:00
DeLesley Hutchins 8ecd491e75 Fix analysis based warnings so that all warnings are emitted when compiling
with -Werror.  Previously, compiling with -Werror would emit only the first
warning in a compilation unit, because clang assumes that once an error occurs,
further analysis is unlikely to return valid results.  However, warnings that
have been upgraded to errors should not be treated as "errors" in this sense.

llvm-svn: 169649
2012-12-07 22:53:48 +00:00
Richard Smith 50d705b5b0 Per [dcl.fct.def.default]p1, don't allow variadic special members to be defaulted.
llvm-svn: 169574
2012-12-07 02:10:28 +00:00
Argyrios Kyrtzidis 1eb71a1ba7 Add a bit on FunctionDecl/ObjCMethodDecl to indicate if there was a body
that was skipped by the parser.

llvm-svn: 169531
2012-12-06 18:59:10 +00:00
Benjamin Kramer 6928cf7826 Sema: Don't emit a warning when __func__ is used in a lambda outside of a function.
Fixes PR14518.

llvm-svn: 169510
2012-12-06 15:42:21 +00:00
Richard Smith 16b65394ee Fix http://stackoverflow.com/questions/13521163
Don't require that, during template deduction, a template specialization type
as a function parameter has at least as many template arguments as one used in
a function argument (not even if the argument has been resolved to an exact
type); the additional parameters might be provided by default template
arguments in the template. We don't need this check, since we now implement
[temp.deduct.call]p4 with an additional check after deduction.

llvm-svn: 169475
2012-12-06 06:44:44 +00:00
Jordan Rose 0e5badd93b Format strings: offer a cast to 'unichar' for %C in Objective-C contexts.
For most cases where a conversion specifier doesn't match an argument,
we usually guess that the conversion specifier is wrong. However, if
the argument is an integer type and the specifier is %C, it's likely
the user really did mean to print the integer as a character.

(This is more common than %c because there is no way to specify a unichar
literal -- you have to write an integer literal, such as '0x2603',
and then cast it to unichar.)

This does not change the behavior of %S, since there are fewer cases
where printing a literal Unicode *string* is necessary, but this could
easily be changed in the future.

<rdar://problem/11982013>

llvm-svn: 169400
2012-12-05 18:44:49 +00:00
Jordan Rose ea0fdfe146 Format strings: add more expression types that don't need parens to cast.
No functionality change (the test change is a comment only, and the new
functionality can't be tested using the current test).

llvm-svn: 169399
2012-12-05 18:44:44 +00:00
Jordan Rose 598ec0992d Format strings: a character literal should be printed with %c, not %d.
The type of a character literal is 'int' in C, but if the user writes a
character /as/ a literal, we should assume they meant it to be a
character and not a numeric value, and thus offer %c as a correction
rather than %d.

There's a special case for multi-character literals (like 'MooV'), which
have implementation-defined value and usually cannot be printed with %c.
These still use %d as the suggestion.

In C++, the type of a character literal is 'char', and so this problem
doesn't exist.

<rdar://problem/12282316>

llvm-svn: 169398
2012-12-05 18:44:40 +00:00
Richard Smith 3e284699d9 In C++, if we hit an error in the class-head, don't try to parse the class body.
Our error recovery path may have made the class anonymous, and that has a pretty
disastrous impact on any attempt to parse a class body containing constructors.

llvm-svn: 169374
2012-12-05 11:34:06 +00:00
DeLesley Hutchins 8edae13dd0 Thread safety analysis: Add a new "beta" warning flag: -Wthread-safety-beta.
As the analysis improves, it will continue to add new warnings that are
potentially disruptive to existing users.  From now on, such warnings will
first be introduced under the "beta" flag.  Such warnings are not turned on by
default; their purpose is to allow users to test their code against future
planned changes, before those changes are actually made.  After a suitable
migration period, beta warnings will be folded into the standard
-Wthread-safety.

llvm-svn: 169338
2012-12-05 00:06:15 +00:00
Chandler Carruth 3a02247dc9 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

llvm-svn: 169237
2012-12-04 09:13:33 +00:00
Richard Smith 2be35f5fbb Consistently use 'needsImplicit<special member>' to determine whether we need
an implicit special member, rather than sometimes using '!hasDeclared<special
member>'. No functionality change.

llvm-svn: 169075
2012-12-01 02:35:44 +00:00
Douglas Gregor c401755f46 Fix the determination of whether a capture refers to an enclosing
scope when dealing with nested blocks. Fixes <rdar://problem/12778708>.

llvm-svn: 169065
2012-12-01 01:01:09 +00:00
Eli Friedman 5ac9875160 Make -Wtautological-constant-out-of-range-compare behave sanely for enums with a signed fixed type.
<rdar://problem/12780159>.

llvm-svn: 169051
2012-11-30 23:09:29 +00:00
Rafael Espindola 8778c28022 Merge function types in C.
Among other differences, GCC accepts

  typedef int IA[];
  typedef int A10[10];
  static A10 *f(void);
  static IA  *f(void);
  void g(void) {
    (void)sizeof(*f());
  }

but clang used to reject it with:

  invalid application of 'sizeof' to an incomplete type 'IA' (aka 'int []')

The intention of c99's 6.2.7 seems to be that we should use the composite type
and accept as gcc does.

Doing the type merging required some extra fixes:
  * Use the type from the function type in initializations, even if an parameter
    is available.
  * Fix the merging of the noreturn attribute in function types.
  * Make CodeGen  handle the fact that an parameter type can be different from
    the corresponding type in the function type.

llvm-svn: 168895
2012-11-29 16:09:03 +00:00
Richard Smith e6a56db2e6 Reject uses of __int128 on platforms that don't support it. Also move the ugly
'getPointerWidth(0) >= 64' test to be a method on TargetInfo, ready to be
properly cleaned up.

llvm-svn: 168856
2012-11-29 05:41:51 +00:00
Eli Friedman fd41aee2f8 Fix crash-on-invalid. <rdar://problem/12765391>.
llvm-svn: 168851
2012-11-29 03:13:49 +00:00
Richard Smith 8bf22e5b52 The declaration of a special member can require overload resolution to be
performed, to determine whether that special member is deleted or constexpr.
That overload resolution process can in turn trigger the instantiation of a
template, which can do anything, including triggering the declaration of that
very same special member function. When this happens, do not try to recursively
declare the special member -- that's impossible. Instead, only try to realise
the truth. There is no special member.

llvm-svn: 168847
2012-11-29 01:34:07 +00:00
Richard Smith a118c6a8c0 Per C++11 [except.spec]p2, rvalue references are not permitted in exception specifications.
llvm-svn: 168824
2012-11-28 22:52:42 +00:00
Richard Smith 8606d75265 PR14388: An array or function type in an exception specification should be
decayed to a pointer type. Patch by WenHan Gu, with a little tweaking and
additional testcases by me.

llvm-svn: 168822
2012-11-28 22:33:28 +00:00
Richard Smith 58db83d11d PR13098: If we're instantiating an overloaded binary operator and we could
determine which member function would be the callee from within the template
definition, don't pass that function as a "non-member function" to
CreateOverloadedBinOp. Instead, just rely on it to select the member function
for itself.

llvm-svn: 168818
2012-11-28 21:47:39 +00:00
Richard Smith 1c33fe8fea Store on the CXXRecordDecl whether the class has, or would have, a copy
constructor/assignment operator with a const-qualified parameter type. The
prior method for determining this incorrectly used overload resolution.

llvm-svn: 168775
2012-11-28 06:23:12 +00:00
Argyrios Kyrtzidis a6567c4102 Don't return a pointer to an UnresolvedSetImpl in the CXXRecordDecl interface,
expose only the iterators instead.

llvm-svn: 168770
2012-11-28 03:56:09 +00:00
Richard Smith 58c3cc12da C++ core issue 1344, PR10618: promote "addition of default argument makes this
a special member" diagnostic from warning to error, and fix the cases where it
produced diagnostics with incorrect wording.

We don't support this as an extension, and we ban it even in C++98 mode. This
breaks too much (for instance, the ABI-specified calling convention for a type
can change if it acquires a copy constructor through the addition of a default
argument).

llvm-svn: 168769
2012-11-28 03:45:24 +00:00
Fariborz Jahanian 32c1350673 objective-C arc: Underline the selector when issuing
arc specific diagnostic on the selector. This is objc-arc
part of // rdar://11303469

llvm-svn: 168756
2012-11-28 01:27:44 +00:00
Fariborz Jahanian fbd19749a3 objective-C arc: load of a __weak object happens via call to
objc_loadWeak. This retains and autorelease the weakly-refereced
object. This hidden autorelease sometimes makes __weak variable alive even
after the weak reference is erased, because the object is still referenced
by an autorelease pool. This patch overcomes this behavior by loading a 
weak object via call to objc_loadWeakRetained(), followng it by objc_release
at appropriate place, thereby removing the hidden autorelease. // rdar://10849570

llvm-svn: 168740
2012-11-27 23:02:53 +00:00
Richard Smith 9219d1b764 Allow an ASTConsumer to selectively skip function bodies while parsing. Patch
by Olivier Goffart!

llvm-svn: 168726
2012-11-27 21:31:01 +00:00
Richard Smith 7d125a11f1 Simplify checking for whether we should implicitly declare special members and
add some assertions. No functionality change.

llvm-svn: 168725
2012-11-27 21:20:31 +00:00
Richard Smith dd2ca571ae PR14428: When instantiating a 'new' expression, if we had a non-dependent
initialization, don't rebuild it. Remove a couple of hacks which were trying to
work around this. Fix the special case for one-argument CXXConstructExprs to
not apply if the one argument is a default argument.

llvm-svn: 168582
2012-11-26 08:32:48 +00:00
Rafael Espindola befe130dd2 Add r168519 back, but with a fix to also merge the used flag in variables.
llvm-svn: 168564
2012-11-25 14:07:59 +00:00
NAKAMURA Takumi c232cb8542 Revert r168519, "Merge used flags so that we don't have to iterate on isUsed. With this change"
It brought bunch of (possibly false) warnings.

llvm/unittests/VMCore/PassManagerTest.cpp:60:22: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    char ModuleNDNM::ID=0;
                     ^
llvm/unittests/VMCore/PassManagerTest.cpp:86:22: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    char ModuleNDM2::ID=0;
                     ^
llvm/unittests/VMCore/PassManagerTest.cpp:106:21: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    char ModuleDNM::ID=0;
                    ^
llvm/unittests/VMCore/PassManagerTest.cpp:217:16: warning: variable 'initcount' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    int LPass::initcount=0;
               ^
llvm/unittests/VMCore/PassManagerTest.cpp:218:16: warning: variable 'fincount' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    int LPass::fincount=0;
               ^
llvm/unittests/VMCore/PassManagerTest.cpp:259:16: warning: variable 'inited' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    int BPass::inited=0;
               ^
llvm/unittests/VMCore/PassManagerTest.cpp:260:16: warning: variable 'fin' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    int BPass::fin=0;
               ^
llvm/unittests/VMCore/PassManagerTest.cpp:283:24: warning: variable 'ID' is not needed and will not be emitted [-Wunneeded-internal-declaration]
    char OnTheFlyTest::ID=0;
                       ^
8 warnings generated.

llvm-svn: 168549
2012-11-24 23:17:09 +00:00
Benjamin Kramer 90633e39fc Sema: Provide a valid source location when instantiating templates based on a CXXDefaultArgExpr.
Fixes PR13758.

llvm-svn: 168521
2012-11-23 17:04:52 +00:00
Rafael Espindola 99e3bfbd17 Merge used flags so that we don't have to iterate on isUsed. With this change
"clang -cc1 -fsyntax-only" on the preprocessed output of

#define M extern int a;
#define M2 M M
#define M4 M2 M2
#define M8 M4 M4
#define M16 M8 M8
#define M32 M16 M16
#define M64 M32 M32
#define M128 M64 M64
#define M256 M128 M128
#define M512 M256 M256
#define M1024 M512 M512
#define M2048 M1024 M1024
#define M4096 M2048 M2048
#define M8192 M4096 M4096
#define M16384 M8192 M8192
M16384

goes from 2.994s to 1.416s. GCC is at 0.022s, so we still have a long way to go.

llvm-svn: 168519
2012-11-23 16:26:30 +00:00
Richard Smith b2c5f963d6 Fix regression in r168477. Use canonical decl when looking for base class
specified as a qualified name.

llvm-svn: 168479
2012-11-22 00:40:54 +00:00
Richard Smith d80b2d57cf Fix CXXRecordDecl::forallBases to not look through bases which are dependent
and defined within the current instantiation, but which are not part of the
current instantiation. Previously, it would look at bases which could be
specialized separately from the current template.

llvm-svn: 168477
2012-11-22 00:24:47 +00:00
Benjamin Kramer 3d3ddcec70 SemaCXX: an enumeral type can be of character or boolean type in a C++11 enum class. Make sure we create a literal of the right type.
Fixes PR14386.

llvm-svn: 168441
2012-11-21 17:42:47 +00:00
David Blaikie 3c0c536300 Fix some trailing whitespace (on a blank line) to cycle/test bots.
llvm-svn: 168340
2012-11-19 23:12:51 +00:00
Richard Smith 1ab34b3ad5 PR14381: Never skip constexpr function bodies when code-completing. We may need
them in order to parse the rest of the file.

llvm-svn: 168327
2012-11-19 21:13:18 +00:00
Kaelyn Uhrain f60b55ae49 When adding a NamedDecl to a correction, add the underlying Decl (via
getUnderlyingDecl()) so that derivatives of
CorrectionCandidateCallback::ValidateCandidate(...) don't have to worry
about being thrown by UsingDecls and such.

llvm-svn: 168317
2012-11-19 18:49:53 +00:00
Dmitri Gribenko d4bc5ac69d Remove redundant (duplicated) check.
llvm-svn: 168293
2012-11-18 22:28:42 +00:00
Fariborz Jahanian d91d21cc33 objective-C: Do not issue deprecated warning about implementation
of a deprecated method in original class (or category), only
in overrides. // rdar://12717705

llvm-svn: 168270
2012-11-17 20:53:53 +00:00
Nick Lewycky cc8990f629 Store this Decl* as a Decl* instead of a uintptr_t. No functionality change.
llvm-svn: 168145
2012-11-16 08:40:59 +00:00
Richard Trieu 08b5fef122 Take into account the zero sign bit for positive numbers when computing the bit
width of an enum with negative values in IntRange.  Include a test for
-Wtautological-constant-out-of-range-compare where this had manifested.

llvm-svn: 168126
2012-11-16 01:32:40 +00:00
Richard Smith 1648847248 A step towards sorting out handling of triviality of special members in C++11.
Separate out the notions of 'has a trivial special member' and 'has a
non-trivial special member', and use them appropriately. These are not
opposites of one another (there might be no special member, or in C++11 there
might be a trivial one and a non-trivial one). The CXXRecordDecl predicates
continue to produce incorrect results, but do so in fewer cases now, and
they document the cases where they might be wrong.

No functionality changes are intended here (they will come when the predicates
start producing the right answers...).

llvm-svn: 168119
2012-11-16 00:53:38 +00:00
Benjamin Kramer 671f4c0ce1 Do not cache a pointer to ExprEvalContexts.back().
It may become a dangling pointer if the underlying SmallVector reallocates.
Sadly the testcase is really large and doesn't reduce well because of
SmallVector's reallocation patterns.

Fixes PR14336.

llvm-svn: 168045
2012-11-15 15:18:42 +00:00
Nick Lewycky c363afb19e Teach the uninitialized field warning about anonymous structs and union members.
Fixes PR14073!

llvm-svn: 168031
2012-11-15 08:19:20 +00:00
Richard Trieu 03c3a2f5bb Fix an off-by-one error by switching < to <= in -Wtautological-constant-out-of-range-compare and added test case.
llvm-svn: 168023
2012-11-15 03:43:50 +00:00
Richard Smith af41696bc4 Per [basic.lookup.classref]p3, in an expression of the form p->~type-name, the
type-name is looked up in the context of the complete postfix-expression. Don't
forget to pass the scope into this lookup when the type-name is a template-id;
it might name an alias template which can't be found within the class itself.

Bug spotted by Johannes Schaub on #llvm.

llvm-svn: 168011
2012-11-15 00:31:27 +00:00
Eli Friedman 37feb2d6a6 Fix DiagnoseBitwisePrecedence so it doesn't cast "-1" to the type
BinaryOperator::Opcode.  This is bad form, and the behavior of the static_cast
in this case is unspecified according to the standard.

Fixes a warning that showed up from r167992 on self-host.

llvm-svn: 168010
2012-11-15 00:29:07 +00:00
Richard Trieu 560910c9b8 Improve -Wtautological-constant-out-of-range-compare by taking into account
type conversion between integers.  This allows the warning to be more accurate.

Also, turned the warning off in an analyzer test.  The relavent test cases
are covered by the tests in Sema.

llvm-svn: 167992
2012-11-14 22:50:24 +00:00
Benjamin Kramer d81108f0bc s/tranform/transform/
llvm-svn: 167929
2012-11-14 15:08:31 +00:00
Richard Smith 4f6a2c4acb When we have a MemberExpr referring to an overloaded static member function,
and we resolve it to a specific function based on the type which it's used as,
don't forget to mark it as referenced.

Fixes a regression introduced in r167514.

llvm-svn: 167918
2012-11-14 07:06:31 +00:00
NAKAMURA Takumi bae23ed8c5 SemaTemplateDeduction.cpp: Prune two obsolete descriptions. [-Wdocumentation]
* getMostSpecialized()

/// \param Index if non-NULL and the result of this function is non-nULL,
/// receives the index corresponding to the resulting function template
/// specialization.

* DeduceTemplateArguments()

/// \param Name the name of the function being called. This is only significant
/// when the function template is a conversion function template, in which
/// case this routine will also perform template argument deduction based on
/// the function to which

llvm-svn: 167909
2012-11-14 02:21:48 +00:00
David Blaikie 095deba533 Provide the correct mangling and linkage for certain unnamed nested classes.
This corrects the mangling and linkage of classes (& their member functions) in
cases like this:

  struct foo {
    struct {
      void func() { ... }
    } x;
  };

we were accidentally giving this nested unnamed struct 'no' linkage where it
should've had the linkage of the outer class. The mangling was incorrecty too,
mangling as TU-wide unnamed type mangling of $_X rather than class-scoped
mangling of UtX_.

This also fixes -Wunused-member-function which would incorrectly diagnose
'func' as unused due to it having no linkage & thus appearing to be TU-local
when in fact it might be correctly used in another TU.

Similar mangling should be applied to function local classes in similar cases
but I've deferred that for a subsequent patch.

Review/discussion by Richard Smith, John McCall, & especially Eli Friedman.

llvm-svn: 167906
2012-11-14 01:52:05 +00:00
Richard Smith 41ae3288fd Remove another questionable use of hasTrivial*. The relevant thing for this
test was whether the /selected/ operator= was trivial, not whether the class
had any trivial (or any non-trivial) operator=s.

llvm-svn: 167897
2012-11-14 00:50:40 +00:00
John McCall ea0a39e7ad Accept and pass arguments to __unknown_anytype in argument
positions of Objective-C methods.

It is possible to recover a lot of type information about
Objective-C methods from the reflective metadata for their
implementations.  This information is not rich when it
comes to struct types, however, and it is not possible to
produce a type in the debugger's round-tripped AST which
will really do anything useful during type-checking.
Therefore we allow __unknown_anytype in these positions,
which essentially disables type-checking for that argument.
We infer the parameter type to be the unqualified type of
the argument expression unless that expression is an
explicit cast, in which case it becomes the type-as-written
of that cast.

rdar://problem/12565338

llvm-svn: 167896
2012-11-14 00:49:39 +00:00
Eli Friedman 00fa429b5d Don't try to save the assigned value in a Objective-C property assignment
if the type of the value is a non-trivial class type.  Fixes PR14318.

(There's a minor ObjC++ language change here: given that we can't save the
value, the type of the assignment expression is void in such cases.)

llvm-svn: 167884
2012-11-13 23:16:33 +00:00
Kaelyn Uhrain 1137001938 For classes that have the warn_unused_result attribute, don't apply the
attribute to the class' methods even when they return an instance of the
class (e.g. assignment operators).

llvm-svn: 167873
2012-11-13 21:23:31 +00:00
Argyrios Kyrtzidis 243d82345d Copy the decls returned by DeclContext::lookup_result to a
new container so we can safely iterate over them.

The container holding the lookup decls can under certain conditions
be changed while iterating (e.g. because of deserialization).

llvm-svn: 167816
2012-11-13 05:07:23 +00:00
Richard Smith 52c0b58d33 Fix some wrong-code bugs in implicitly-defined assignment operators:
- In C++11, perform overload resolution over all assignment operators, rather than just looking for copy/move assignment operators.
 - Clean up after temporaries produced by operator= immediately, rather than accumulating them until the end of the function.

llvm-svn: 167798
2012-11-13 00:54:12 +00:00
Kaelyn Uhrain 3d699e02ae A couple of small fixes to r167783
llvm-svn: 167791
2012-11-13 00:18:47 +00:00
Nick Lewycky a21719d688 When filtering the list of associated namespaces so that we don't suggest people
add functions to namespace 'std', also filter out namespaces with '__' anywhere
in the name.

llvm-svn: 167786
2012-11-13 00:08:34 +00:00
Kaelyn Uhrain 8681f9d46d Enable C++11 attribute syntax for warn_unused_result and allow it to be
applied to CXXRecordDecls, where functions with that return type will
inherit the warn_unused_result attribute.

Also includes a tiny fix (with no discernable behavior change for
existing code) to re-sync AttributeDeclKind enum and
err_attribute_wrong_decl_type with warn_attribute_wrong_decl_type since
the enum is used with both diagnostic messages to chose the correct
description.

llvm-svn: 167783
2012-11-12 23:48:05 +00:00
Richard Smith 11d1959ff2 Factor duplicated implicit memcpy call generation code out of copy/move
assignment generation. This incidentally avoids reusing the same Expr* across
multiple statements in the same object; that was generating slightly broken
ASTs, but I couldn't trigger any observable bad behavior, so no test.

llvm-svn: 167779
2012-11-12 23:33:00 +00:00
Eric Christopher d41010af44 Finish reverting r167761, it's causing test failures.
llvm-svn: 167777
2012-11-12 23:13:34 +00:00
David Blaikie 1d6178065c Fix more try scoping bugs introduced by r167650.
Introduces more clear scoping flags & flag combinations which should hopefully
be more understandable.

llvm-svn: 167766
2012-11-12 22:25:41 +00:00
Bill Wendling b1da2cb3fd Don't test for incomplete types.
llvm-svn: 167761
2012-11-12 22:01:56 +00:00
Ted Kremenek da5919ffa1 Per discussion on cfe-dev, re-enable suppression of -Wimplicit-fallthrough on C, but also include dialects of C++ earlier than C++11.
There was enough consensus that we *can* get a good language solution
to have an annotation outside of C++11, and without this annotation
this warning doesn't quite mean's completeness criteria for this
kind of warning.  For now, restrict this warning to C++11 (where an
annotation exists), and make this the behavior for the LLVM 3.2 release.
Afterwards, we will hammer out a language solution that we are all
happy with.

llvm-svn: 167749
2012-11-12 21:20:48 +00:00
Bill Wendling 887b485dbe Check that the input size is correct for the given constraint.
The 'a', 'c', and 'd' constraints on i386 mean a 32-bit register. We cannot
place a 64-bit value into the 32-bit register. Error out instead of causing the
compiler to spew general badness.
<rdar://problem/12415959>

llvm-svn: 167717
2012-11-12 06:42:51 +00:00
Douglas Gregor dc97457178 Rework my implementation of circular-reference finding to not use
CXXRecordDecl::forallBases, which does *not* do what I need. Fixes the
failure introduced in r167651.

llvm-svn: 167668
2012-11-10 07:24:09 +00:00
Ted Kremenek ca90ecdb72 Revert "Disable -Wimplicit-fallthrough when not using C++.", pending further discussion on cfe-dev.
llvm-svn: 167662
2012-11-10 04:03:41 +00:00
Ted Kremenek 15da29c682 Disable -Wimplicit-fallthrough when not using C++.
The rationale is that there is no good workflow to silence the warning
for specific cases, other than using pragmas.  This is because the
attribute to decorate an explicit fall through is only available
in C++11.

By that argument, this should probably also be disabled unless one
is using C++11, but apparently there is an explicit test case for
this warning when using C++98.  This will require further discussion
on cfe-commits.

Fixes:  <rdar://problem/12584746>
llvm-svn: 167655
2012-11-10 01:47:40 +00:00
David Blaikie 43df4cc568 Handle redeclarations of catch variables in catch blocks.
Fix to regression caused by r167650, caught by Richard Smith in code review.

llvm-svn: 167653
2012-11-10 01:38:24 +00:00
Douglas Gregor 6200470112 Diagnostic circular inheritance involving dependent base classes. We
would have diagnosed this at instantiation time anyway, if only we
didn't hang on all of these test cases. Fixes <rdar://problem/12629723>

llvm-svn: 167651
2012-11-10 01:18:17 +00:00
David Blaikie 1c9c90495d PR14296: function parameter name collisions in function try/catch
C++11 3.3.3/2 "A parameter name shall not be redeclared in the outermost block
of the function definition nor in the outermost block of any handler associated
with a function-try-block."

It's not totally clear to me whether the "FIXME" case is covered by this, but
Richard Smith thinks it probably should be. It's just a bit more involved to
fix that case.

llvm-svn: 167650
2012-11-10 01:04:23 +00:00
Jordan Rose e2028139e9 -Wobjc-literal-compare: look through implicit casts.
This warning was failing to fire under ARC because of the implicit
lifetime casts added around the object literal expression.

<rdar://problem/11300873>, again.

llvm-svn: 167648
2012-11-09 23:55:21 +00:00
Richard Smith de63d36fb2 PR13788: Don't perform checks on the initializer of a dependently-typed
variable. Previously we didn't notice the type was dependent if the only
dependence came from an array bound.

Patch by Brian Brooks!

llvm-svn: 167642
2012-11-09 23:03:14 +00:00
Nico Weber 9512d3f161 Use isInvalidDecl() instead of isStatic() as suggested by dblaikie.
I couldn't think of a way to make an operator() invalid without returning
earlier from this function other than making it static, so no new test.

llvm-svn: 167609
2012-11-09 08:38:04 +00:00
Nico Weber 1fefe417f0 Don't crash on calling static member overloaded operator, PR14120
Patch from Brian Brooks!

llvm-svn: 167604
2012-11-09 06:06:14 +00:00
Matt Beaumont-Gay 641bd89d6b Fix a bug I found while preparing my devmtg talk: When passing NULL to a
function that takes a const Foo&, where Foo is convertible from a large number
of pointer types, we print ALL the overloads, no matter the setting of
-fshow-overloads.

There is potential follow-on work in unifying the "print candidates, but not
too many" logic between OverloadCandidateSet::NoteCandidates and
ImplicitConversionSequence::DiagnoseAmbiguousConversion.

llvm-svn: 167596
2012-11-08 20:50:02 +00:00
Abramo Bagnara ad9f2e21cd Avoid to write function name in comment. Thanks to Dmitri Gribenko.
llvm-svn: 167588
2012-11-08 16:27:30 +00:00
Abramo Bagnara 3b8a9e5e6b Readded line removed by mistake.
llvm-svn: 167587
2012-11-08 16:01:51 +00:00
Abramo Bagnara 341ab737e9 Fixed converted ConstantArrayTypeLoc range. Added a missing testcase for ConstructorDecl source range.
llvm-svn: 167583
2012-11-08 14:44:42 +00:00
David Blaikie a1edff0046 PR14284: crash on ext-valid returning NULL from a void function
llvm-svn: 167565
2012-11-08 00:41:20 +00:00
Nico Weber efa45b2508 Reduce nesting. No functionality change.
llvm-svn: 167551
2012-11-07 21:31:36 +00:00
Richard Trieu 23bafad985 When template deduction fails on a derived class, try a template deduction on
the base class.  If the base class deduction succeeds, use those results.  If
it fails, keep using the results from the derived class template deduction.

This prevents an assertion later where the type of deduction failure doesn't
match up with the template deduction info.

llvm-svn: 167550
2012-11-07 21:17:13 +00:00
Richard Smith e10d304d20 PR11851 (and duplicates): Whenever a constexpr function is referenced,
instantiate it if it can be instantiated and implicitly define it if it can be
implicitly defined. This matches g++'s approach. Remove some cases from
SemaOverload which were marking functions as referenced when just planning how
overload resolution would proceed; such cases are not actually references.

llvm-svn: 167514
2012-11-07 01:14:25 +00:00
Eli Friedman c087c3f6c5 Add missing check to warning for packed attribute. PR14259.
llvm-svn: 167510
2012-11-07 00:35:20 +00:00
David Blaikie 7b97aef997 PR13552: Fix the end location of a CXXNewExpr.
Spent longer than reasonable looking for a nice way to test this & decided to
give up for now. Open to suggestions/requests. Richard Smith suggested adding
something to ASTMatchers but it wasn't readily apparent how to test this with
that.

llvm-svn: 167507
2012-11-07 00:12:38 +00:00
Eli Friedman e43109557c Fix assertion failure with auto and nested initializer list; PR14272.
llvm-svn: 167506
2012-11-06 23:56:42 +00:00
Nick Lewycky 3811582038 Put the usage-directive inside the nearest namespace or TU decl. We don't want
to have UsingDirectiveDecl inside anything other than those two.

No user-visible functionality change.

llvm-svn: 167376
2012-11-04 20:21:54 +00:00
Dmitri Gribenko f21203b17c Address review comments for r167358: explicitly check for CK_BitCast instead of
checking against a blacklist.

llvm-svn: 167362
2012-11-03 22:10:18 +00:00
Dmitri Gribenko 5ac744e006 Handle CK_NullToPointer casts in -Wtype-safety properly. Fixes PR14249.
llvm-svn: 167358
2012-11-03 16:07:49 +00:00
Quentin Colombet 4e172067b2 Update the front end to use minsize attribute
llvm-svn: 167266
2012-11-01 23:55:47 +00:00
Eli Friedman 1e95d4bb1e Correctly reject gotos in function-level try blocks. PR14225.
llvm-svn: 167184
2012-10-31 23:55:28 +00:00
Anna Zaks 408f7d0144 Address Jordan's review: comments, spaces.
llvm-svn: 167091
2012-10-31 01:18:22 +00:00
Quentin Colombet ee3e0fb632 Revert commit r166946
llvm-svn: 166957
2012-10-29 18:28:57 +00:00
Richard Smith bf83009c7f Partially roll back r166898; it exposed a bug in the standard.
The problem is as follows: C++11 has contexts which are not
potentially-evaluated, and yet in which we are required or encouraged to
perform constant evaluation. In such contexts, we are not permitted to
implicitly define special member functions for literal types, therefore
we cannot evalaute those constant expressions.

Punt on this in one more context for now by skipping checking constexpr
variable initializers if they occur in dependent contexts.

llvm-svn: 166956
2012-10-29 18:26:47 +00:00
Quentin Colombet 0d6b5e5fde Make forcesizeopt attribute available to the end user
llvm-svn: 166946
2012-10-29 17:56:23 +00:00
Jordan Rose 25c0ea8995 -Warc-repeated-use-of-weak: allow single reads in loops from local variables.
Previously, the warning would erroneously fire on this:

for (Test *a in someArray)
  use(a.weakProp);

...because it looks like the same property is being accessed over and over.
However, clearly this is not the case. We now ignore loops like this for
local variables, but continue to warn if the base object is a parameter,
global variable, or instance variable, on the assumption that these are
not repeatedly usually assigned to within loops.

Additionally, do-while loops where the condition is 'false' are not really
loops at all; usually they're just used for semicolon-swallowing macros or
using "break" like "goto".

<rdar://problem/12578785&12578849>

llvm-svn: 166942
2012-10-29 17:46:47 +00:00
Richard Smith 59a8e49f01 Revert functional part of r166896 and just suppress -Wunneeded-internal-declaration for reference types for now. This needs more work; the cases we currently miss are a bit random.
llvm-svn: 166899
2012-10-28 07:39:29 +00:00
Richard Smith 2f36dae5c0 When determining whether to try evaluating the initializer of a variable, check
whether the initializer is value-dependent rather than whether we are in a
dependent context. This allows us to detect some errors sooner, and fixes a
crash-on-invalid if a dependent type leaks out to a non-dependent context in
error recovery.

llvm-svn: 166898
2012-10-28 06:18:02 +00:00
Richard Smith 27501e787c In -Wunneeded-internal-declaration, suppress the warning for variables which
might have been used in constant expressions, rather than suppressing it for
variables which are const. The important thing here is that such variables
can have their values used without actually being marked as 'used'.

llvm-svn: 166896
2012-10-28 04:47:21 +00:00
Rafael Espindola 44938a738a Fix invalid jump scopes again. This time without trying to find out if an
incomplete type has a destructor or not.

llvm-svn: 166895
2012-10-28 02:44:03 +00:00
Rafael Espindola bd2c99b77c Revert 166876 while I debug a bootstrap problem.
llvm-svn: 166878
2012-10-27 16:49:47 +00:00
Rafael Espindola 2ea126e73e Reapply 166855 with an early exit on null QualTypes.
llvm-svn: 166876
2012-10-27 14:56:08 +00:00
Rafael Espindola 8c0739d332 Revert r166855. I can reproduce the bootstrap failure and have a testcase
to reduce.

llvm-svn: 166863
2012-10-27 03:06:02 +00:00
Rafael Espindola c5f9943a60 Fix cases where we were not producing an error when a computed goto could
jump over destructor calls.
Fixes pr13812.

llvm-svn: 166855
2012-10-27 01:17:42 +00:00
Bill Wendling 9d1ee1175d Recommit Eric's code to validate ASM string's constraints and modifiers.
This code checks the ASM string to see if the output size is able to fit within
the variable specified as the output. For instance, scalar-to-vector conversions
may not really work. It's on by default, but can be turned off with a flag if
you think you know what you're doing.

This is placed under a flag ('-Wasm-operand-widths') and flag group ('-Wasm').

<rdar://problem/12284092>

llvm-svn: 166737
2012-10-25 23:28:48 +00:00
Chad Rosier 5c56364be9 [ms-inline asm] Add support for field lookup in the SemaCallback. Patch by Eli.
llvm-svn: 166723
2012-10-25 21:49:22 +00:00
Bill Wendling d75987dde9 Revert r166647 to rethink the patch...
llvm-svn: 166655
2012-10-25 00:32:44 +00:00
Bill Wendling 753c8782df Add some support for diagnosing possibly mismatched constraint, type size and
modifiers. (From an idea by Eric...)
<rdar://problem/12284092>

llvm-svn: 166647
2012-10-25 00:05:55 +00:00
Richard Smith 527b15e8f1 PR14171: Don't crash if we hit one of the paths where GetFullTypeForDeclarator
rebuilds a function type, and that function type has parens around its name.

llvm-svn: 166644
2012-10-24 23:51:56 +00:00
David Blaikie a9d4a936a8 Fix false positive in -Wunused-variable when a ctor call make involve cleanups.
llvm-svn: 166625
2012-10-24 21:29:06 +00:00
Douglas Gregor 7959178eb0 Use a .def file for most of the diagnostic options.
llvm-svn: 166520
2012-10-23 23:11:23 +00:00
Fariborz Jahanian 6f5309cf50 Objective-C: check that when a category method is being implemented,
method type in cateogry matches the implementation.
// rdar://12519216

llvm-svn: 166518
2012-10-23 23:06:22 +00:00
Eli Friedman 7d14b3c9b3 Add a new warning -Wmissing-variable-declarations, to warn about variables
defined without a previous declaration.  This is similar to
-Wmissing-prototypes, but for variables instead of functions.

Patch by Ed Schouten.

llvm-svn: 166498
2012-10-23 20:19:32 +00:00
Richard Smith 40c180db13 When rebuilding a DependentScopeDeclRefExpr, perform a lookup into the scope
even if it's dependent, in case it now names a member of the current instantiation.

llvm-svn: 166496
2012-10-23 19:56:01 +00:00
Chad Rosier b8097dec8f [ms-inline asm] Update for r166433.
llvm-svn: 166489
2012-10-23 17:44:40 +00:00
Eli Friedman d5d136be5b [ms-inline-asm] Add handling for errors coming out of the backend.
llvm-svn: 166463
2012-10-23 02:43:30 +00:00
Richard Smith 2ddcbab8ff Ugly ugly hack for libstdc++-4.6 and libstdc++-4.7 compatibility. These
libraries have an incorrect definition of std::common_type (inherited from a
bug in the standard -- see LWG issue 2141), whereby they produce reference
types when they should not.

If we instantiate a typedef named std::common_type<...>::type, which is defined
in a system header as decltype(... ? ... : ...), and the decltype produces a
reference type, convert it to the non-reference type. (This doesn't affect any
LWG2141-conforming implementation of common_type, such as libc++'s, because the
default implementation of common_type<...>::type isn't supposed to produce a
reference type.)

This is horrible. I'm really sorry. :( Better ideas appreciated!

llvm-svn: 166455
2012-10-23 00:32:41 +00:00
Richard Smith db2630fb04 Unrevert r166268, reverted in r166272, with a fix for the issue which Nick
found: if an overloaded operator& is present before a template definition,
the expression &T::foo is represented as a CXXOperatorCallExpr, not as a
UnaryOperator, so we didn't notice that it's permitted to reference a non-static
data member of an unrelated class.

While investigating this, I discovered another problem in this area: we are
treating template default arguments as unevaluated contexts during substitution,
resulting in performing incorrect checks for uses of non-static data members in
C++11. That is not fixed by this patch (I'll look into this soon; it's related
to the failure to correctly instantiate constexpr function templates), but was
resulting in this bug not firing in C++11 mode (except with -Wc++98-compat).

Original message:

PR14124: When performing template instantiation of a qualified-id outside of a
class, diagnose if the qualified-id instantiates to a non-static class member.

llvm-svn: 166385
2012-10-21 03:28:35 +00:00
Benjamin Kramer 1cdb23db13 Move private classes into anonymous namespaces.
llvm-svn: 166377
2012-10-20 13:02:06 +00:00
Richard Smith 66f3ac9d21 Rework implementation of DR1492: Apply the resolution to operator delete too,
since it also has an implicit exception specification. Downgrade the error to
an extwarn, since at least for operator delete, system headers like to declare
it as 'noexcept' whereas the implicit definition does not have an explicit
exception specification. Move the exception specification for user-declared
'operator delete' functions from the type-as-written into the type, to reflect
reality and to allow us to detect whether there was an implicit exception spec
or not.

llvm-svn: 166372
2012-10-20 08:26:51 +00:00
Logan Chien 2957489b3d Fix __builtin_va_arg assertion failure in ARM AAPCS.
llvm-svn: 166369
2012-10-20 06:11:33 +00:00
Richard Smith 5a1104bd3a DR1472: A reference isn't odr-used if it has preceding initialization,
initialized by a reference constant expression.

Our odr-use modeling still needs work here: we don't yet implement the 'set of
potential results of an expression' DR.

llvm-svn: 166361
2012-10-20 01:38:33 +00:00
Chad Rosier 46d8fc9d6b [ms-inline asm] Set the SemaCallback in the TargetAsmParser.
llvm-svn: 166310
2012-10-19 20:36:37 +00:00
David Blaikie 82d3ab9225 Clarify wording of -Wshift-op-parentheses.
Suggestion from Matt Beaumont-Gay reviewing r165283.

llvm-svn: 166296
2012-10-19 18:26:06 +00:00
Chad Rosier db97454f8e [ms-inline asm] Set the MCTargetAsmParser as paring MS-style inline asm.
llvm-svn: 166293
2012-10-19 17:58:45 +00:00
Jordan Rose 2afd661685 Allow objc_requires_super to be used to check class methods as well.
Also, unify ObjCShouldCallSuperDealloc and ObjCShouldCallSuperFinalize.
The two have identical behavior and will never be active at the same time.

There's one last simplification now, which is that if we see a call to
[super foo] and we are currently in a method named 'foo', we will
/unconditionally/ clear the ObjCShouldCallSuper flag, rather than check
first to see if we're in a method where calling super is required. There's
no reason to pay the extra lookup price here.

llvm-svn: 166285
2012-10-19 16:05:26 +00:00
Nick Lewycky 2e3b716959 Revert r166268, this fix for a crash-on-invalid introduced a rejects-valid.
Richard has an unreduced testcase to work with.

llvm-svn: 166272
2012-10-19 08:08:02 +00:00
Richard Smith b2d6df5c95 PR14124: When performing template instantiation of a qualified-id outside of a
class, diagnose if the qualified-id instantiates to a non-static class member.

llvm-svn: 166268
2012-10-19 06:32:17 +00:00
David Blaikie 282c92a708 Handle diamond inheritance in -Woverloaded-virtual.
llvm-svn: 166254
2012-10-19 00:53:08 +00:00
Chad Rosier b91b3f88ad [ms-inline asm] Add a size argument to the LookupInlineAsmIdentifier() callback,
which will be used by the asm matcher in the near future.

llvm-svn: 166221
2012-10-18 20:27:06 +00:00
Eli Friedman eaf3414979 Fix Objective-C implicit property synthesis for C++ classes so we use valid
source locations in places where it is necessary for diagnostics.  By itself,
this causes assertions, so while I'm here, also fix property synthesis
for properties of C++ class type so we use so we properly set up a scope
and mark variable declarations.

<rdar://problem/12514189>.

llvm-svn: 166219
2012-10-18 20:14:08 +00:00
Chad Rosier 791bbe298d [ms-inline asm] Have the LookupInlineAsmIdentifier() callback function return a
*NamedDecl.  In turn, build the expressions after we're finished parsing the
asm.  This avoids a crasher if the lookup fails.

llvm-svn: 166213
2012-10-18 19:39:37 +00:00
Anna Zaks 673d76b0bc Factor CollectClassPropertyImplementations out of Sema into AST
This would make it possible for the analyzer to use the function.

llvm-svn: 166210
2012-10-18 19:17:53 +00:00
Axel Naumann dd433f0b2f From Vassil Vassilev: enable Sema to deal with multiple ExternalSemaSources.
llvm-svn: 166208
2012-10-18 19:05:02 +00:00
Richard Smith b6626748c2 DR1442: In a range-based for statement, namespace 'std' is not an associated
namespace.

llvm-svn: 166194
2012-10-18 17:56:02 +00:00
David Blaikie 12be639dfc PR14021: Copy lookup results to ensure safe iteration.
Within the body of the loop the underlying map may be modified via

  Sema::AddOverloadCandidate
    -> Sema::CompareReferenceRelationship
    -> Sema::RequireCompleteType

to avoid the use of invalid iterators the sequence is copied first.

A reliable, though large, test case is available - it will be reduced and
committed shortly.

Patch by Robert Muth. Review by myself, Nico Weber, and Rafael Espindola.

llvm-svn: 166188
2012-10-18 16:57:32 +00:00
Chad Rosier ce2bcbf8c0 [ms-inline asm] Move most of the AsmParsing logic in clang back into the MC
layer.  Use the new ParseMSInlineAsm() API and add an implementation of the
MCAsmParserSemaCallback interface.

llvm-svn: 166184
2012-10-18 15:49:40 +00:00
Richard Smith fb26652c43 Tests for DR1507.
llvm-svn: 166162
2012-10-18 00:44:17 +00:00
Richard Smith fafc52c786 Update comment to match DR1502.
llvm-svn: 166158
2012-10-17 23:55:38 +00:00
David Blaikie ea4d259041 Fix -Woverloaded-virtual when the using statement refers to a base declaration of a virtual function.
GCC and Clang both do not warn on:

  struct a { virtual void func(); };
  struct b: a { virtual void func(); void func(int); };
  struct c: b { void func(int); using b::func; };

but if the "using" was using a::func GCC would still remain silent where Clang
would warn. This change makes Clang consistent with GCC's existing behavior.

llvm-svn: 166154
2012-10-17 23:45:39 +00:00
Richard Smith 87e795174c DR1528: C++11 doesn't allow repeated cv-qualifiers in declarators after all.
llvm-svn: 166152
2012-10-17 23:31:46 +00:00
David Blaikie 7e414261f6 Implement C++ 10.3p16 - overrides involving deleted functions must match.
Only deleted functions may override deleted functions and non-deleted functions
may only override non-deleted functions.

llvm-svn: 166082
2012-10-17 00:47:58 +00:00
Richard Smith 1ee6352788 DR1492: In a definition of a destructor, the exception specification must be
explicitly specified iff it was specified in the declaration.

llvm-svn: 166071
2012-10-16 23:30:16 +00:00
Derek Schuff a202096dc0 Add pnaclcall convention to Native Client targets.
Because PNaCl bitcode must be target-independent, it uses some
different bitcode representations from other targets (e.g. byval and
sret for structures). This means that without additional type
information, it cannot meet some native ABI requirements for some
targets (e.g. passing structures containing unions by value on
x86-64). To allow generation of code which uses the correct native
ABIs, we also support triples such as x86_64-nacl, which uses
target-dependent IR (as opposed to le32-nacl, which uses byval and
sret).

To allow interoperation between the two types of code, this patch adds
a calling convention attribute to be used in code compiled with the
target-dependent triple, which will generate code using the le32-style
bitcode. This calling convention does not need to be explicitly
supported in the backend because it determines bitcode representation
rather than native conventions (the backend just needs to undersand
how to handle byval and sret for the Native Client OS).

This patch implements __attribute__((pnaclcall)) to generate calls in
bitcode according to the le32 bitcode conventions, an attribute which
is accepted by any Native Client target, but issues a warning
otherwise.

llvm-svn: 166065
2012-10-16 22:30:41 +00:00
Chad Rosier f8037a1fb6 [ms-inline asm] Move some logic around to simplify the interface between the
front-end and the AsmParser.  No functional change intended.

llvm-svn: 166063
2012-10-16 21:55:39 +00:00
David Blaikie 282ad876bd Implement GCC's -Wint-to-pointer-cast.
This implementation doesn't warn on anything that GCC doesn't warn on with the
exception of templates specializations (GCC doesn't warn, Clang does). The
specific skipped cases (boolean, constant expressions, enums) are open for
debate/adjustment if anyone wants to demonstrate that GCC is being overly
conservative here. The only really obvious false positive I found was in the
Clang regression suite's MPI test - apparently MPI uses specific flag values in
pointer constants. (eg: #define FOO (void*)~0)

llvm-svn: 166039
2012-10-16 18:53:14 +00:00
Fariborz Jahanian eab1730fe8 Minor tweak to last patch along with a test case.
// rdar://12491143

llvm-svn: 166030
2012-10-16 17:08:11 +00:00
Fariborz Jahanian 379e5363f6 fixes an objc crash involving objc bool literal on
hopelessly poorly written code after spewing several
errors. // rdar://12491143

llvm-svn: 166025
2012-10-16 16:21:20 +00:00
Daniel Dunbar bd847cc562 Un-revert r164907 and r164902 (+ follow-ups), 10.6 build fix to follow.
llvm-svn: 165988
2012-10-15 22:23:53 +00:00
Abramo Bagnara 9fb43869eb Fixed CXXNamedCast right paren location propagation to instantiations.
llvm-svn: 165977
2012-10-15 21:08:58 +00:00
Abramo Bagnara 598b943410 Fixed LabelDecl source range.
llvm-svn: 165976
2012-10-15 21:07:44 +00:00
Nico Weber bec2bf1326 Revert r164907 and r164902 (+ follow-ups). They broke building on 10.6.
See PR14013.

llvm-svn: 165962
2012-10-15 20:37:01 +00:00
Chad Rosier 4a0054f383 [ms-inline asm] Rework the front-end to use the API introduced in r165946.
-The front-end now builds a single assembly string and feeds it to the
 AsmParser.  The front-end iterates on a per statement basis by calling the
 ParseStatement() function.  Please note, the calling of ParseStatement() and
 and any notion of MCAsmParsedOperands will be sunk into the MC layer in the
 near future.  I plan to expose more basic APIs such as getClobbers, etc.

-The enumeration of the AsmString expressions have been reworked to use SMLocs
 rather than assembly Pieces, which were being parsed in the front-end.

-The test case, t8(), was modified due to r129223.  I'll have to find a way to
 work around things such as these.

Sorry for the large commit, but breaking this in multiple smaller commits proved
too irritating.

llvm-svn: 165957
2012-10-15 19:56:10 +00:00
Chad Rosier ce17b0f5b8 Update for r165858.
llvm-svn: 165859
2012-10-13 00:26:22 +00:00
Chad Rosier aac08d2c3d [ms-inline asm] Remove a bunch of parsing code from the front-end.
llvm-svn: 165851
2012-10-12 23:32:10 +00:00
Eli Friedman 9ee2d04753 Make -mms-bitfields behave consistently.
Patch by Jeremiah Zanin.

llvm-svn: 165849
2012-10-12 23:29:20 +00:00
Chad Rosier 7d1ec922ff Update for r165833.
llvm-svn: 165834
2012-10-12 22:53:52 +00:00
DeLesley Hutchins 6c6e8599bd Fix warnings introduced by r165826.
llvm-svn: 165829
2012-10-12 21:49:04 +00:00
DeLesley Hutchins 2d0881b577 Thread-safety analysis: support multiple thread-safety attributes on
declarations.

llvm-svn: 165826
2012-10-12 21:38:12 +00:00
Chad Rosier 941faac455 [ms-inline asm] Remove a bunch of parsing code from the front-end, which will be
reimplemented in the AsmParser where it belongs.

llvm-svn: 165825
2012-10-12 21:37:00 +00:00
David Blaikie 04ea41c39a Fix typo correction of one qualified name to another.
When suggesting "foo::bar" as a correction for "fob::bar" we mistakenly
replaced only "bar" with "foo::bar" producing "fob::foo::bar" which was broken.

This corrects that replacement in as many places as I could find & provides
test cases for all those cases I could find a test case for. There are a couple
that don't seem to be reachable (one looks entirely dead, the other just
doesn't seem to ever get called with a namespace to namespace change).

Review by Richard Smith ( http://llvm-reviews.chandlerc.com/D57 ).

llvm-svn: 165817
2012-10-12 20:00:44 +00:00
Richard Trieu f20d90582f Change (!ptr != 0) to (!ptr) to make the code more readable.
No functional change.

llvm-svn: 165811
2012-10-12 17:48:40 +00:00
Benjamin Kramer 25a3470371 Remove unused variable.
llvm-svn: 165793
2012-10-12 14:01:58 +00:00
Chad Rosier 98b4164503 Remove dead code introduced in r165751.
llvm-svn: 165772
2012-10-12 00:02:48 +00:00
David Blaikie c2ff8e125a Provide a fixit when taking the address of an unqualified member function.
This only applies if the type has a name. (we could potentially do something
crazy with decltype in C++11 to qualify members of unnamed types but that
seems excessive)

It might be nice to also suggest a fixit for "&this->i", "&foo->i",
and "&foo.i" but those expressions produce 'bound' member functions that have
a different AST representation & make error recovery a little trickier. Left
as future work.

llvm-svn: 165763
2012-10-11 22:55:07 +00:00
Chad Rosier dc12c45058 [ms-inline asm] Remove a bunch of parsing code from the front-end, which will be
reimplemented in the AsmParser where it belongs.

llvm-svn: 165752
2012-10-11 21:44:41 +00:00
Chad Rosier e66f42634f [ms-inline asm] Lookup the IdentifierInfo using the Idents table and remove the
now unused static helper function.

The test case needs to be remove temporarily until I can better filter memory
operands that aren't actual variable reference.

llvm-svn: 165751
2012-10-11 21:28:29 +00:00
Ted Kremenek 241f1ef4cc Add null check for malformed code.
llvm-svn: 165733
2012-10-11 19:06:43 +00:00
Jordan Rose b1e3e5f553 -Warc-repeated-use-of-weak: fix a use-of-uninitialized and add a test case.
Fix-up for r165718, should get the buildbots back online.

llvm-svn: 165723
2012-10-11 17:02:00 +00:00
Jordan Rose 76831c6cd4 -Warc-repeated-use-of-weak: Don't warn on a single read followed by writes.
This is a "safe" pattern, or at least one that cannot be helped by using
a strong local variable. However, if the single read is within a loop,
it should /always/ be treated as potentially dangerous.

<rdar://problem/12437490>

llvm-svn: 165719
2012-10-11 16:10:19 +00:00
Jordan Rose 2248765591 -Warc-repeated-use-of-weak: Check messages to property accessors as well.
Previously, [foo weakProp] was not being treated the same as foo.weakProp.
Now, for every explicit message send, we check if it's a property access,
and if so, if the property is weak. Then for every assignment of a
message, we have to do the same thing again.

This is a potentially expensive increase because determining whether a
method is a property accessor requires searching through the methods it
overrides. However, without it -Warc-repeated-use-of-weak will miss cases
from people who prefer not to use dot syntax. If this turns out to be
too expensive, we can try caching the result somewhere, or even lose
precision by not checking superclass methods. The warning is off-by-default,
though.

<rdar://problem/12407765>

llvm-svn: 165718
2012-10-11 16:06:21 +00:00
Nico Weber cf4ff586e8 Add codegen support for __uuidof().
llvm-svn: 165710
2012-10-11 10:13:44 +00:00
Eli Friedman adf42185f6 Minor cleanup for r165678; no functional change.
llvm-svn: 165679
2012-10-11 00:34:15 +00:00
Eli Friedman 726d11c41b Make sure we perform the variadic method check correctly for calls to a member operator(). PR14057.
llvm-svn: 165678
2012-10-11 00:30:58 +00:00
Jordan Rose e723a27ffe -Warc-repeated-use-of-weak: look through explicit casts on assigned values.
Reading from a weak property, casting the result, and assigning to a
strong pointer should still be considered safe.

llvm-svn: 165629
2012-10-10 16:43:06 +00:00
Jordan Rose 2bd991a1c0 Move Sema::PropertyIfSetterOrGetter to ObjCMethodDecl::findPropertyDecl.
Then, switch users of PropertyIfSetterOrGetter and LookupPropertyDecl
(the latter by name) over to findPropertyDecl. This actually makes
-Wreceiver-is-weak a bit stronger than it was before.

llvm-svn: 165628
2012-10-10 16:42:54 +00:00
Jordan Rose 79af985bad Change Sema::PropertyIfSetterOrGetter to make use of isPropertyAccessor.
Old algorithm:
1. See if the name looks like a getter or setter.
2. Use the name to look up a property in the current ObjCContainer
   and all its protocols.
3. If the current container is an interface, also look in all categories
   and superclasses (and superclass categories, and so on).

New algorithm:
1. See if the method is marked as a property accessor. If so, look through
   all properties in the current container and find one that has a matching
   selector.
2. Find all overrides of the method using ObjCMethodDecl's
   getOverriddenMethods. This collects methods in superclasses and protocols
   (as well as superclass categories, which isn't really necessary), and
   checks if THEY are accessors. This part is not done recursively, since
   getOverriddenMethods is already recursive.

This lets us handle getters and setters that do not match the property
names.

llvm-svn: 165627
2012-10-10 16:42:38 +00:00
Jordan Rose d01e83ab3e Rename ObjCMethodDecl::isSynthesized to isPropertyAccessor.
This more accurately reflects its use: this flag is set when a method
matches the getter or setter name for a property in the same class,
and does not actually specify whether or not the definition of the method
will be synthesized (either implicitly or explicitly with @synthesize).

This renames the setter and backing field as well, and changes the
(soon-to-be-obsolete?) XML dump format to use 'property_accessor'
instead of 'synthesized'.

llvm-svn: 165626
2012-10-10 16:42:25 +00:00
Argyrios Kyrtzidis 8e50297652 Fix stack overflow when trying to create an implicit moving
constructor with invalid code.

rdar://12240916

llvm-svn: 165623
2012-10-10 16:14:06 +00:00
Douglas Gregor 8cb174654f If a macro has been #undef'd in a precompiled header, we still need to
write out the macro history for that macro. Similarly, we need to cope
with reading a macro definition that has been #undef'd.

Take advantage of this new ability so that global code-completion
results can refer to #undef'd macros, rather than losing them
entirely. For multiply defined/#undef'd macros, we will still get the
wrong result, but it's better than getting no result.

llvm-svn: 165502
2012-10-09 16:01:50 +00:00
Benjamin Kramer 97e5949068 Clearing a SmallPtrSet is still expensive, split it out from OverloadCandidateSet::clear and don't do it on destruction.
llvm-svn: 165501
2012-10-09 15:52:25 +00:00
Argyrios Kyrtzidis cc4ca0a324 When storing the C++ overridden methods, store them once for the
canonical method; avoid storing them again for an out-of-line definition.

llvm-svn: 165472
2012-10-09 01:23:45 +00:00
David Blaikie dac86fd24c Use a single note diagnostic for all the precedent/parentheses warnings.
llvm-svn: 165384
2012-10-08 01:19:49 +00:00
David Blaikie 1d202a6bae StringRef-ify Binary/UnaryOperator::getOpcodeStr
llvm-svn: 165383
2012-10-08 01:11:04 +00:00
Richard Smith f501cc313e Workaround for libstdc++4.6 <atomic> bug: make comment more explicit about what's going on, per Sean Silva's suggestion.
llvm-svn: 165286
2012-10-05 01:46:25 +00:00
David Blaikie 15f17cbbd8 Implement -Wshift-op-parentheses for: a << b + c
This appears to be consistent with GCC's implementation of the same warning
under -Wparentheses. Suppressing a << b + c for cases where 'a' is a user
defined type for compatibility with C++ stream IO. Otherwise suggest
parentheses around the addition or subtraction subexpression.

(this came up when MSVC was complaining (incorrectly, so far as I can tell)
about a perceived violation of this within the LLVM codebase, PR14001)

llvm-svn: 165283
2012-10-05 00:41:03 +00:00
Argyrios Kyrtzidis 50e5b1dab3 [libclang] Introduce CXCursor_ModuleImportDecl cursor kind, used for a module
import declaration.

llvm-svn: 165277
2012-10-05 00:22:24 +00:00
Richard Smith 45bb8855e0 Egriegious hack to support libstdc++4.6's broken <atomic> header, which defines
a non-inline namespace, then reopens it as inline to try to add its symbols to
the surrounding namespace. In this one special case, permit the namespace to be
reopened as inline, and patch up the name lookup tables to match.

llvm-svn: 165263
2012-10-04 22:13:39 +00:00
Abramo Bagnara aeeb989cc4 Fixed FunctionTypeLoc source range.
llvm-svn: 165259
2012-10-04 21:42:10 +00:00
Abramo Bagnara 0d4fce1c2e Fixed instantiated operators source range.
llvm-svn: 165258
2012-10-04 21:40:42 +00:00
Abramo Bagnara 71f32c14b1 Fixed ParamDecl source range for implicit typed k&r parameters.
llvm-svn: 165256
2012-10-04 21:38:29 +00:00
Michael Han 360d225ae9 Fix scope location when parsing GNU attributes.
For GNU attributes, instead of reusing attribute source 
location for the scope location, use SourceLocation() since 
GNU attributes don not have scope tokens. 

llvm-svn: 165234
2012-10-04 16:42:52 +00:00
Eli Friedman 68be1649ee Permanently end the whole "pragma got handled by the parser too early"
mess by handling all pragmas which the parser touches uniformly.
<rdar://problem/12248901>, etc.

llvm-svn: 165195
2012-10-04 02:36:51 +00:00
Fariborz Jahanian 4a67508685 objective-C arc: Warn under arc about a use of an ivar inside a block
that doesn't have a 'self' as this implicitly captures 'self' and could
create retain cycles. Provide fixit. // rdar://11194874

llvm-svn: 165133
2012-10-03 17:55:29 +00:00
Michael Han 23214e5046 Improve C++11 attribute parsing.
- General C++11 attributes were previously parsed and ignored. Now they are parsed and stored in AST.
- Add support to parse arguments of attributes that in 'gnu' namespace.
- Differentiate unknown attributes and known attributes that can't be applied to statements when emitting diagnostic.

llvm-svn: 165082
2012-10-03 01:56:22 +00:00