Commit Graph

9448 Commits

Author SHA1 Message Date
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
Richard Trieu 742c6ed9bf Change how the SelfReferenceChecker handles MemberExpr. Instead of treating
each one separately, process a stack of MemberExpr's as a single unit so that
static calls and member access will not be warned on.

llvm-svn: 165074
2012-10-03 00:41:36 +00:00
Chad Rosier 0c1b62779e Revert 165058, per Jim request. This requires further discussion.
llvm-svn: 165070
2012-10-02 23:38:55 +00:00
Chad Rosier 09d7710e04 [ms-inline asm] Rewrite the symbol references as wildcard MCParsedAsmOperands.
A Sema lookup is used to determine the size of the variable, which is in turn
used during wildcard matching.

llvm-svn: 165058
2012-10-02 21:49:14 +00:00
Chad Rosier 04d5664295 [ms-inline asm] Enhance the isSimpleMSAsm() function to handle operands with pointer size
directives (e.g., dword ptr [eax]).

llvm-svn: 165031
2012-10-02 18:51:05 +00:00
Chad Rosier 0ede0986b9 No need to call the InitializeAll* functions.
llvm-svn: 165025
2012-10-02 16:41:12 +00:00
Aaron Ballman e91c6be01e Allowing individual targets to determine whether a given calling convention is allowed or ignored with warning. This allows for correct name mangling for x64 targets on Windows, which in turn allows for linking against the Win32 APIs.
Fixes PR13782

llvm-svn: 165015
2012-10-02 14:26:08 +00:00
Ted Kremenek 2f88c40ded Tweak diagnostic text to indicate that __weak on a local variable is only allowed
for ARC.  Fixes <rdar://problem/12407705>

llvm-svn: 164990
2012-10-02 05:36:02 +00:00
Lang Hames 5de91cc35f Add FP_CONTRACT support for clang.
Clang will now honor the FP_CONTRACT pragma and emit LLVM
fmuladd intrinsics for expressions of the form A * B + C (when they occur in a
single statement).

llvm-svn: 164989
2012-10-02 04:45:10 +00:00
Ted Kremenek b67c6cc24d Check if an IdentifierInfo* is null when the FunctionDecl isn't a simple C function.
Fixes <rdar://problem/12355298>

llvm-svn: 164988
2012-10-02 04:36:54 +00:00
Jordan Rose 3c14b2339d -Wformat: Don't check format strings in uninstantiated templates.
Also applies to -Wnonnull, -Wtype-safety, and -Wnon-pod-varargs.
All of these can be better checked at instantiation time.

This change does not actually affect regular CallExpr function calls,
since the checks there only happen after overload resolution.
However, it will affect Objective-C method calls.

<rdar://problem/12373934>

llvm-svn: 164984
2012-10-02 01:49:54 +00:00
Chad Rosier bb90c414c4 [ms-inline asm] Use the convertToMapAndConstraints() function in the front-end.
Rework the logic to account for the fact that we no longer create a MCInst.

llvm-svn: 164980
2012-10-01 23:45:59 +00:00
Richard Smith 1620ebd98f PR13978: A 'decltype' DeclSpec has an expression representation, not a type
representation. Fix crash if it appears in the return type of a member function
definition.

llvm-svn: 164967
2012-10-01 20:35:07 +00:00
Anna Zaks 97c7ce3368 Move isObjCSelf into Expr.
llvm-svn: 164966
2012-10-01 20:34:04 +00:00
Richard Trieu 3267347cca Cleaning up the self initialization checker.
-Allow Sema to do more processing on the initial Expr before checking it.
-Remove the special conditions in HandleExpr()
-Move the code so that only one call site is needed.
-Removed the function from Sema and only call it locally.
-Warn on potentially evaluated reference variables, not just casts to r-values.
-Update tests.

llvm-svn: 164951
2012-10-01 17:39:51 +00:00
Dmitri Gribenko 6743e04699 Move the 'find macro by spelling' infrastructure to the Preprocessor class and
use it to suggest appropriate macro for __attribute__((deprecated)) in
-Wdocumentation-deprecated-sync.

llvm-svn: 164892
2012-09-29 11:40:46 +00:00
Jordan Rose d61f3b4dae Fix buildbots by not using a template from another namespace.
No need to specialize BeforeThanCompare for a comparator that's only
going to be used once.

llvm-svn: 164859
2012-09-28 22:29:02 +00:00
Alexander Kornienko e61e5625e7 Compatibility macro detection for the -Wimplicit-fallthrough diagnostic.
Summary:
When issuing a diagnostic message for the -Wimplicit-fallthrough diagnostics, always try to find the latest macro, defined at the point of fallthrough, which is immediately expanded to "[[clang::fallthrough]]", and use it's name instead of the actual sequence.

Known issues: 
  * uses PP.getSpelling() to compare macro definition with a string (anyone can suggest a convenient way to fill a token array, or maybe lex it in runtime?);
  * this can be generalized and used in other similar cases, any ideas where it should reside then?

Reviewers: doug.gregor, rsmith

Reviewed By: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D50

llvm-svn: 164858
2012-09-28 22:24:03 +00:00
Jordan Rose 13d6b71929 -Wreceiver-is-weak: rephrase warning text and add a suggestion Note.
New output:
  warning: weak property may be unpredictably set to nil
  note: property declared here
  note: assign the value to a strong variable to keep the object alive
        during use

<rdar://problem/12277204>

llvm-svn: 164857
2012-09-28 22:21:42 +00:00
Jordan Rose 62b379873d Pull ScopeInfo implementation into its own file.
The infrastructure for -Warc-repeated-use-of-weak got a little too heavy
to leave sitting at the top of Sema.cpp.

No functionality change.

llvm-svn: 164856
2012-09-28 22:21:39 +00:00
Jordan Rose 657b5f464d -Warc-repeated-use-of-weak: check ivars and variables as well.
Like properties, loading from a weak ivar twice in the same function can
give you inconsistent results if the object is deallocated between the
two loads. It is safer to assign to a strong local variable and use that.

Second half of <rdar://problem/12280249>.

llvm-svn: 164855
2012-09-28 22:21:35 +00:00
Jordan Rose d393458c33 Add a warning (off by default) for repeated use of the same weak property.
The motivating example:

if (self.weakProp)
  use(self.weakProp);

As with any non-atomic test-then-use, it is possible a weak property to be
non-nil at the 'if', but be deallocated by the time it is used. The correct
way to write this example is as follows:

id tmp = self.weakProp;
if (tmp)
  use(tmp);

The warning is controlled by -Warc-repeated-use-of-receiver, and uses the
property name and base to determine if the same property on the same object
is being accessed multiple times. In cases where the base is more
complicated than just a single Decl (e.g. 'foo.bar.weakProp'), it picks a
Decl for some degree of uniquing and reports the problem under a subflag,
-Warc-maybe-repeated-use-of-receiver. This gives a way to tune the
aggressiveness of the warning for a particular project.

The warning is not on by default because it is not flow-sensitive and thus
may have a higher-than-acceptable rate of false positives, though it is
less noisy than -Wreceiver-is-weak. On the other hand, it will not warn
about some cases that may be legitimate issues that -Wreceiver-is-weak
will catch, and it does not attempt to reason about methods returning weak
values.

Even though this is not a real "analysis-based" check I've put the bug
emission code in AnalysisBasedWarnings for two reasons: (1) to run on
every kind of code body (function, method, block, or lambda), and (2) to
suggest that it may be enhanced by flow-sensitive analysis in the future.

The second (smaller) half of this work is to extend it to weak locals
and weak ivars. This should use most of the same infrastructure.

Part of <rdar://problem/12280249>

llvm-svn: 164854
2012-09-28 22:21:30 +00:00
Richard Smith 845aa66a8a When processing an InitListExpr and skipping the initialization of an invalid
record, skip at least one element from the InitListExpr to avoid an infinite
loop if we're initializing an array of unknown bound.

llvm-svn: 164851
2012-09-28 21:23:50 +00:00
Anna Zaks 454477cd07 Make getDefaultSynthIvarName() a member of ObjCPropertyDecl.
llvm-svn: 164789
2012-09-27 19:45:11 +00:00
Sylvestre Ledru 33b5baf189 Revert 'Fix a typo 'iff' => 'if''. iff is an abreviation of if and only if. See: http://en.wikipedia.org/wiki/If_and_only_if Commit 164766
llvm-svn: 164769
2012-09-27 10:16:10 +00:00
Sylvestre Ledru a876013dc9 Fix a typo 'iff' => 'if'
llvm-svn: 164766
2012-09-27 09:57:10 +00:00
Argyrios Kyrtzidis 5c8b1cd220 [libclang] Always report a CXCursor_MacroDefinition for code-completion
results for a macro name, not CXCursor_NotImplemented.

llvm-svn: 164740
2012-09-27 00:24:09 +00:00
Anna Zaks 9802f9fb2a [analyzer] Add experimental ObjC invalidation method checker.
This checker is annotation driven. It checks that the annotated
invalidation method accesses all ivars of the enclosing objects that are
objects of type, which in turn contains an invalidation method.

This is driven by
__attribute((annotation("objc_instance_variable_invalidator")).

llvm-svn: 164716
2012-09-26 18:55:16 +00:00
DeLesley Hutchins f39c0c2487 Fix template instantiation of attributes. More specifically, fix the case
where an attribute is attached to a forward declaration of a template function,
and refers to parameters of that declaration, but is then inherited by the
definition of that function.  When the definition is instantiated, the
parameter references need to be remapped.

llvm-svn: 164710
2012-09-26 17:57:31 +00:00
Argyrios Kyrtzidis 9ae3956f22 [libclang] Remove the ParentKind cursor kind from code-completion results.
This is to reduce dependency to cursors for the code-completion results.

llvm-svn: 164705
2012-09-26 16:39:56 +00:00
Eli Friedman 15681d6852 Fix an edge case of mangling involving the combination of a lambda and typeid.
typeid (and a couple other non-standard places where we can transform an
unevaluated expression into an evaluated expression) is special
because it introduces an an expression evaluation context,
which conflicts with the mechanism to compute the current
lambda mangling context.  PR12123.

I would appreciate if someone would double-check that we get the mangling
correct with this patch.

llvm-svn: 164658
2012-09-26 04:34:21 +00:00
Eli Friedman b826a00857 Fix the AST representation for non-type template arguments to encode
enough information so we can mangle them correctly in cases involving
dependent parameter types. (This specifically impacts cases involving
null pointers and cases involving parameters of reference type.)
Fix the mangler to use this information instead of trying to scavenge
it out of the parameter declaration.

<rdar://problem/12296776>.

llvm-svn: 164656
2012-09-26 02:36:12 +00:00
Bob Wilson 24719e3236 Examine the last, not the first, instruction from the MC matcher.
If an MS-style inline asm is matched to multiple instructions, e.g., with a
a WAIT-prefix, then we need to examine the operands of the last instruction
instruction, not the prefix instruction.

llvm-svn: 164608
2012-09-25 16:30:16 +00:00
John McCall bf4a7d7193 Add the Microsoft __is_interface_class type trait.
Patch by Andy Gibbs!

llvm-svn: 164591
2012-09-25 07:32:49 +00:00
John McCall db632ac004 Fix for r163013 regression and further __interface enhancement.
Patch by Andy Gibbs!

llvm-svn: 164590
2012-09-25 07:32:39 +00:00
John McCall b0433eeb2e During jump-scope checking, build an ExprWithCleanups immediately
into the enclosing scope;  this is a more accurate model but is
(I believe) unnecessary in my test case due to other flaws.
However, one of those flaws is now intentional:  blocks which
appear in return statements can be trivially observed to not
extend in lifetime past the return, and so we can allow a jump
past them.  Do the necessary magic in IR-generation to make
this work.

llvm-svn: 164589
2012-09-25 06:56:03 +00:00
Richard Smith 88d67f3412 Fix crash when a decltype expression in a trailing return type refers to the
function being instantiated. An error recovery codepath was recursively
performing name lookup (and triggering an unbounded stack of template
instantiations which blew out the stack before hitting the depth limit).

Patch by Wei Pan!

llvm-svn: 164586
2012-09-25 04:46:05 +00:00
Eli Friedman cda3db801f Delete some code which is, as far as I can tell, dead.
llvm-svn: 164580
2012-09-25 01:02:42 +00:00
Richard Smith 60f2e1efb8 Don't produce diagnostics for missing ctor-initializers during template
instantiations if we encountered errors parsing some of the initializers.

llvm-svn: 164578
2012-09-25 00:23:05 +00:00
Chad Rosier 93b3eb7793 Update for r164567.
llvm-svn: 164568
2012-09-24 22:58:50 +00:00
Bob Wilson 317be45091 Replace an assertion with an error for empty __asm statements.
llvm-svn: 164551
2012-09-24 19:57:59 +00:00
Bob Wilson 0fc64f0b11 Fix a comment typo and clean up formatting.
llvm-svn: 164550
2012-09-24 19:57:55 +00:00
Dmitri Gribenko 1cd2305703 Change the wording of the extension warning from
> 'long long' is an extension when C99 mode is not enabled
to
> 'long long' is a C++11 extension
while compiling in C++98 mode.

llvm-svn: 164545
2012-09-24 18:19:21 +00:00
Dmitri Gribenko 7ba91723e7 Small cleanup of literal semantic analysis: hiding 'char *' pointers behind
StringRef makes code cleaner.  Also, make the temporary buffer smaller:
512 characters is unreasonably large for integer literals.

llvm-svn: 164484
2012-09-24 09:53:54 +00:00
Abramo Bagnara 6cba23a649 Avoid multiple atomic builtin declaration.
llvm-svn: 164454
2012-09-22 09:05:22 +00:00
Chad Rosier 90cad09ba5 [ms-inline asm] Use mnemonicIsValid() in a helpful assert.
llvm-svn: 164421
2012-09-21 22:22:39 +00:00
Fariborz Jahanian 974c948049 objective-C: when diagnosing deprecated/unavailable usage of
setter or getter backing a deprecated/unavailable property,
also not location of the property. // rdar://12324295

llvm-svn: 164412
2012-09-21 20:46:37 +00:00
Hans Wennborg 61b2ffa60f Make warnings about uninitialized fields include the field name.
This makes the wording more informative, and consistent with the other
warnings about uninitialized variables.

Also, me and David who reviewed this couldn't figure out why we would
need to do a lookup to get the name of the variable; so just print the
name directly.

llvm-svn: 164366
2012-09-21 08:58:33 +00:00
Craig Topper e479428546 Doxygen-ify a comment.
llvm-svn: 164360
2012-09-21 04:33:26 +00:00
David Blaikie 348df509a0 PR13890: Warn on abstract final classes.
llvm-svn: 164359
2012-09-21 03:21:07 +00:00
Richard Smith a05b3b5435 If the range in a for range statement doesn't have a viable begin/end function,
but can be dereferenced to form an expression which does have viable begin/end
functions, then typo-correct the range, even if something else goes wrong with
the statement (such as inaccessible begin/end or the wrong type of loop
variable).

In order to ensure we recover correctly and produce any followup diagnostics in
this case, redo semantic analysis on the for-range statement outside of the
diagnostic trap, after issuing the typo-correction.

llvm-svn: 164323
2012-09-20 21:52:32 +00:00
Fariborz Jahanian 2f4e33aba2 Improvements to my patch in r164143 per
Richard's comments. // rdar://12202422

llvm-svn: 164316
2012-09-20 19:36:41 +00:00
David Blaikie 6590220181 Include types when a definition's type differs from a prior declaration.
This is some really old code (took me a while to find the test cases) & the
diagnostic text is slightly incorrect (it should really only apply to
re/declarations/, redefinitions are an error regardless of whether the types
match). Not sure if anyone cares about it, though.

For now this just makes the diagnostic more clear in less obvious cases where
the type of a declaration might not be explicitly written (eg: because it
uses decltype)

llvm-svn: 164313
2012-09-20 18:38:57 +00:00
Eli Friedman 8f5e983029 Handle lambdas where the lambda-declarator is an explicit "(void)". PR13854.
llvm-svn: 164274
2012-09-20 01:40:23 +00:00
Richard Smith a31a89a38e Per C++11 [class.friend]p3, the 'friend' keyword must appear first in a
non-function friend declaration. Patch by Josh Magee!

llvm-svn: 164273
2012-09-20 01:31:00 +00:00
Eli Friedman ee2ff1cb96 Fix a small FIXME involving template partial ordering and
member function templates with an rvalue ref qualifier.

llvm-svn: 164267
2012-09-19 23:52:13 +00:00
Eli Friedman 3b5774ab0f Fix function template partial ordering rules for static vs. non-static
functions.

llvm-svn: 164263
2012-09-19 23:27:04 +00:00
DeLesley Hutchins a15e1b4f63 Thread-safety analysis: fix ICE when EXCLUSIVE_LOCKS_REQUIRED or
LOCKS_EXCLUDED is used on a method with a name that is is not a simple
identifier.

llvm-svn: 164242
2012-09-19 19:18:29 +00:00
Craig Topper e6706e40bb Remove Context argument from TemplateDeductionInfo constructor. It was no longer needed after the unused Context member was removed in r164104.
llvm-svn: 164196
2012-09-19 02:26:47 +00:00
Eli Friedman d564afb0ad Add the TypeSourceInfo for the lambda call operator to the lambda's
definition info; it needs to be there because the mangler needs to
access it before we're finished defining the lambda class.
PR12808.

llvm-svn: 164186
2012-09-19 01:18:11 +00:00
Eli Friedman 14f082b69d Fix a small bug in the way we handle builtin candidates for
relational operators of enumeration type.  From the gcc testsuite.

llvm-svn: 164171
2012-09-18 21:52:24 +00:00
Eli Friedman e979db1583 Add an extra check for invalid decls in the lambda semantic analysis to avoid a crash. PR13860.
llvm-svn: 164168
2012-09-18 21:11:30 +00:00
Fariborz Jahanian 282071efcc minor refactoring of my last check-in.
llvm-svn: 164145
2012-09-18 17:46:26 +00:00
Fariborz Jahanian b1885425c4 c: warn when an integer value comparison with an
integral expression have the obvious result.
Patch reviewed by John McCall off line.
// rdar://12202422

llvm-svn: 164143
2012-09-18 17:37:21 +00:00
Hans Wennborg 44fd70a3ad Warn about self references in in-class initializers.
This makes Clang warn about self references in in-class initializers,
for example:

  struct S {
    int a = a + 42;
  };

This basically just moves UninitializedFieldVisitor up a bit in
SemaDeclCXX.cpp, and adds a call to it from ActOnCXXInClassMemberInitializer.

llvm-svn: 164131
2012-09-18 15:58:06 +00:00
Ted Kremenek 97c5a1e735 Per discussion on cfe-dev, remove -Wunique-enums entirely. There
is no compelling argument that this is a generally useful warning,
and imposes a strong stylistic argument on code beyond what it was
intended to find warnings in.

llvm-svn: 164083
2012-09-18 00:41:42 +00:00
Fariborz Jahanian cfb00a4137 objective-C: don't warn about class extension property's
missing 'assign' attribute as it is determined by its
overridden property in primary class. // rdar://12214070 

llvm-svn: 164080
2012-09-17 23:57:35 +00:00
Fariborz Jahanian b14a3b24b1 objective-C: peroform property attribute consistency
checking on property declared in class extension.
// rdar://12214070

llvm-svn: 164053
2012-09-17 20:57:19 +00:00
Jordan Rose 67e887c9b5 -Warc-retain-cycles: look through [^{...} copy] and Block_copy(^{...})
Retain cycles happen in the case where a block is persisted past its
life on the stack, and the way that occurs is by copying the block.
We should thus look through any explicit copies we see.

Note that Block_copy is actually a type-safe wrapper for _Block_copy,
which does all the real work.

<rdar://problem/12219663>

llvm-svn: 164039
2012-09-17 17:54:30 +00:00
Axel Naumann ef010f2e7e Don't write uninitialized values even if nobody ever asks for it.
llvm-svn: 164033
2012-09-17 14:26:53 +00:00
Richard Smith e00921a0a4 const _Atomic(T) is not an atomic type, so do not allow it as the type 'A' in
C11 7.17's atomic operations. GNU's __atomic_* builtins do allow const-qualified
atomics, though (!!) so don't restrict those.

llvm-svn: 163964
2012-09-15 06:09:58 +00:00
Jordan Rose fa9e4badce -Warc-retain-cycles: warn at variable initialization as well as assignment.
Specifically, this should warn:

  __block block_t a = ^{ a(); };

Furthermore, this case which previously warned now does not, since the value
of 'b' is captured before the assignment occurs:

  block_t b; // not __block
  b = ^{ b(); };

(This will of course warn under -Wuninitialized, as before.)

<rdar://problem/11015883>

llvm-svn: 163962
2012-09-15 02:48:31 +00:00
Richard Smith da83703ed4 Fix some dead stores which the static analyzer warned about. No functionality
change (the problematic cases in ParseDecl.cpp are currently impossible).

llvm-svn: 163920
2012-09-14 18:27:01 +00:00
Richard Smith 21f06f0fcb When diagnosing multiple mem-initializers in a delegating ctor, point to the delegating initializer, not to the first initializer. For good measure, also highlight the other initializer.
llvm-svn: 163919
2012-09-14 18:21:10 +00:00
Fariborz Jahanian 35227ea365 objective-C arc: remove -Warc-abi in its entirety.
// rdar://10554025

llvm-svn: 163917
2012-09-14 17:48:35 +00:00
Douglas Gregor 5c65f62a1e Fix warning on qualified typedef with 'unused' attribute, from Jason Haslam!
llvm-svn: 163874
2012-09-14 05:10:40 +00:00
Douglas Gregor 0064c5968f In debugger mode, allow comparisons between pointers and integers
without a cast. Fixes <rdar://problem/11830912>.

llvm-svn: 163873
2012-09-14 04:35:37 +00:00
Douglas Gregor 6d149412c8 As we do with base and member initializers in a dependent class, delay
type checking for non-static data member initializers in a dependent
class, because our ASTs lose too much information to when
type-checking an initializer. Fixes <rdar://problem/11974632>,
although the result is still rather unsatisfactory.

llvm-svn: 163871
2012-09-14 04:20:37 +00:00
Douglas Gregor c7203ba19c When computing the decltype of an expression, consider Objective-C
ivar and property references as member accesses and produce the actual
type of the declaration. Fixes <rdar://problem/12031582>.

llvm-svn: 163858
2012-09-13 23:40:46 +00:00
Douglas Gregor 1af8ad49fd Actually rebuild function types properly when adjusting the function
type of an instantiation.

llvm-svn: 163848
2012-09-13 22:01:49 +00:00
Richard Smith ca24ed473b Revert r163829. The world (or libstdc++, at least) is not ready.
llvm-svn: 163846
2012-09-13 22:00:12 +00:00
Douglas Gregor 89f593a14c When we substitute into the type of a function based on the
TypeSourceInfo, we may have lost some adjustments made to the type of
that function due to declaration merging. Adjust the resulting type
correspondingly. Fixes PR12948 / <rdar://problem/11552434>.

llvm-svn: 163845
2012-09-13 21:56:43 +00:00
Richard Smith b9c5a60045 Implement C++11 [conv.prom]p4: an enumeration with a fixed underlying type has
integral promotions to both its underlying type and to its underlying type's
promoted type. This matters now that boolean conversions aren't permitted in
converted constant expressions (a la DR1407): an enumerator with a fixed
underlying type of bool still can be.

llvm-svn: 163841
2012-09-13 21:18:54 +00:00
Douglas Gregor c5c01a60c2 Don't perform template argument deduction against invalid templates;
it's likely to lead to a crash later on. Fixes PR12933 /
<rdar://problem/11525335>.

llvm-svn: 163838
2012-09-13 21:01:57 +00:00
Fariborz Jahanian a55f658a88 remove duplicate code.
llvm-svn: 163833
2012-09-13 20:26:40 +00:00
Douglas Gregor 43bc036e8a Promote the warning about extra qualification on a declaration from a
warning to an error. C++ bans it, and both GCC and EDG diagnose it as
an error. Microsoft allows it, so we still warn in Microsoft
mode. Fixes <rdar://problem/11135644>.

llvm-svn: 163831
2012-09-13 20:16:20 +00:00
Richard Smith b67ada6687 Remove speculative fix for C++ core issue 1407, since it was resolved as NAD.
llvm-svn: 163829
2012-09-13 19:55:13 +00:00
Fariborz Jahanian 1dfeacefbc Move back the stuff about missing ownership attribute warning
to SemaDeclObjC and apply some simplification per John's
comment. // rdar://12280826

llvm-svn: 163824
2012-09-13 18:53:14 +00:00
Fariborz Jahanian bf38d880d6 Move no explicit ownership warning to SemaType.cpp.
// rdar://12280826

llvm-svn: 163813
2012-09-13 17:29:07 +00:00
Ted Kremenek b47e6bc597 Conditionally parse documentation comments in system headers by
passing -fretain-comments-from-system-headers.  By default, the
compiler no longer parses such documentation comments, as they
can result in a noticeable compile time/PCH slowdown.

Fixes <rdar://problem/11860820>.

llvm-svn: 163778
2012-09-13 06:41:18 +00:00
Jordan Rose 4c266aa371 Format strings: offer a fixit for Darwin's %D/%U/%O to ISO %d/%u/%o.
<rdar://problem/12061922>

llvm-svn: 163772
2012-09-13 02:11:15 +00:00
Jordan Rose 510260c2bf Format strings: %D, %U, and %O are valid on Darwin (same as %d, %u, %o).
These will warn under -Wformat-non-iso, and will still be rejected
outright on other platforms.

<rdar://problem/12061922>

llvm-svn: 163771
2012-09-13 02:11:03 +00:00
Chad Rosier f83315fd4a Add a few FIXMEs.
llvm-svn: 163758
2012-09-13 00:20:37 +00:00
Chad Rosier b261a50b40 [ms-inline asm] Handle the enumeration of input and output expressions in a
more robust way to address a few FIXMEs.

The initial implementation, r163342, built the IR asm string and then tried to
patch things on the fly without enough context.  Specifically, it didn't skip
mnemonics nor did it track with assembly instruction an expression was related
to.  The new implementation patches the operands and then builds the final
IR string.

llvm-svn: 163756
2012-09-13 00:06:55 +00:00
Fariborz Jahanian 70b8bd8ad6 objective-C arc: don't issue no explicit ownership warning when
__autoreleasing is explicitely added to param type.
// rdar://12280826

llvm-svn: 163738
2012-09-12 20:34:47 +00:00
Chad Rosier 57cd91f683 [ms-inline asm] If we have a single asm operand that maps to multiple
MCOperands then iterate over all of then when computing clobbers, inputs and
outputs.

On x86 the 1-to-many mapping is a memory operand that includes a BaseReg(reg),
MemScale(imm), MemIndexReg(reg), an Expr(MCExpr or imm) and a MemSegReg(reg).
Invalid register (Op.getReg() == 0) are not considered when computing clobber.

llvm-svn: 163728
2012-09-12 18:14:25 +00:00
Dmitri Gribenko 00bcdd3192 Fix a couple of Doxygen issues pointed out by -Wdocumentation.
llvm-svn: 163722
2012-09-12 17:01:48 +00:00
Richard Smith b15fe3a5e4 PR13811: Add a FunctionParmPackExpr node to handle references to function
parameter packs where the reference is not being expanded but the pack has
been. Previously, Clang would segfault in such cases.

llvm-svn: 163672
2012-09-12 00:56:43 +00:00
Chad Rosier a4f52e16a5 [ms-inline asm] isDef/NumDefs in this context only refer to register definitions, not memory definitions.
llvm-svn: 163666
2012-09-11 23:53:48 +00:00
Chad Rosier 911d50fe4e [ms-inline asm] As of r163657 this check is unnecessary.
llvm-svn: 163665
2012-09-11 23:48:00 +00:00
Chad Rosier ee94a2ebd5 [ms-inline asm] Don't consider tokens or immediates when computing clobbers, inputs and outputs.
llvm-svn: 163657
2012-09-11 23:13:15 +00:00
DeLesley Hutchins 93cddf3cdc Fix warning from r163642
llvm-svn: 163643
2012-09-11 18:32:12 +00:00
DeLesley Hutchins 781fe380c3 Thread safety analysis: fix bug related to lock_returned attribute
on templates.

llvm-svn: 163642
2012-09-11 18:27:46 +00:00
Chad Rosier bd7fdadb90 [ms-inline asm] Add $$ before numeric constants in the IR.
llvm-svn: 163581
2012-09-11 00:51:28 +00:00
David Blaikie 6154ef97a3 Fix PR13784: instantiation of an abstract class in a conditional operator.
A couple of missing "RequireNonAbstractType" calls in conditional operator
handling. I looked for opportunities to tie this check in to all relevant
callers of PerformCopyInitialization (couldn't be all callers since this is
called for base subobject copying too, where it's acceptable to copy abstract
types) but the callers varied too much & in many cases had substantial code
or conditionals on the RequireNonAbstractType call, the
PerformCopyInitialization call, or the code between the two calls.

llvm-svn: 163555
2012-09-10 22:05:41 +00:00
Argyrios Kyrtzidis 54b102985d Move the null check outside of the loop, no functionality change.
llvm-svn: 163553
2012-09-10 22:04:26 +00:00
Dmitri Gribenko 76bb5cabfa Remove redundant semicolons which are null statements.
llvm-svn: 163546
2012-09-10 21:20:09 +00:00
DeLesley Hutchins 5ff1644e62 Thread-safety analysis: differentiate between two forms of analysis; a precise
analysis that may give false positives because it is confused by aliasing, and
a less precise analysis that has fewer false positives, but may have false
negatives.  The more precise warnings are enabled by -Wthread-safety-precise.
An additional note clarify the warnings in the precise case.

llvm-svn: 163537
2012-09-10 19:58:23 +00:00
Fariborz Jahanian d6876b20e7 More tweaking and test cases for call to super
annotations. // rdar://6386358

llvm-svn: 163525
2012-09-10 18:04:25 +00:00
Fariborz Jahanian b05417e1e1 objective-C: Improving diagnostocs for missing call to
super's annotated methods. // rdar://6386358

llvm-svn: 163517
2012-09-10 16:51:09 +00:00
Douglas Gregor c5c5734d19 Allow vector types in pseudo-destructor expressions. Fixes PR13798.
llvm-svn: 163514
2012-09-10 14:57:06 +00:00
Jordan Rose 2f9cc04251 Format strings: suggest %lld instead of %qd and %Ld with -Wformat-non-iso.
As a corollary to the previous commit, even when an extension is
available, we can still offer a fixit to the standard modifier.

llvm-svn: 163453
2012-09-08 04:00:12 +00:00
Jordan Rose 92303592c3 Format strings: %Ld isn't available on Darwin or Windows.
This seems to be a GNU libc extension; we offer a fixit to %lld on
these platforms.

<rdar://problem/11518237>

llvm-svn: 163452
2012-09-08 04:00:03 +00:00
Fariborz Jahanian 566fff0dac objective-C: introduce __attribute((objc_requires_super)) on method
in classes. Use it to flag those method implementations which don't
contain call to 'super' if they have 'super' class and it has the method
with this attribute set. This is wip. // rdar://6386358

llvm-svn: 163434
2012-09-07 23:46:23 +00:00
DeLesley Hutchins a5a00e830a Thread-safety analysis: Add support for selectively turning off warnings
within part of a particular method.

llvm-svn: 163397
2012-09-07 17:34:53 +00:00
Richard Smith 1fde8ece37 PR9023: A template template parameter whose template parameter list contains an
unexpanded parameter pack is a pack expansion. Thus, as with a non-type template
parameter which is a pack expansion, it needs to be expanded early into a fixed
list of template parameters.

Since the expanded list of template parameters is not itself a parameter pack,
it is permitted to appear before the end of the template parameter list, so also
remove that restriction (for both template template parameter pack expansions and
non-type template parameter pack expansions).

llvm-svn: 163369
2012-09-07 02:06:42 +00:00
Sam Panzer 22a3fe1b9c Clarified diagnostics for range-based for loops with invalid ranges
llvm-svn: 163350
2012-09-06 21:50:08 +00:00
Chad Rosier 46b0a0adbe [ms-inline asm] Output empty asm statements for the directives we don't
handle.  Otherwise, the AsmParser will explode if we try to generate an
object files.

llvm-svn: 163345
2012-09-06 19:56:25 +00:00
Chad Rosier c05d2c908d [ms-inline asm] The IR representation of inline assembly enumerates the input
and output expressions much like that in GNU-style inline assembly. Output
expressions are first.  Do this for MS-style inline asms.

llvm-svn: 163342
2012-09-06 19:35:00 +00:00
Fariborz Jahanian 979780f68f refactoring + objective-C specific test for my last patch.
// rdar://12233989

llvm-svn: 163338
2012-09-06 18:38:58 +00:00
Richard Smith 09b031fbc0 Don't try to check override control for invalid member functions. Fixes a crash in a corner case. Patch by Olivier Goffart!
llvm-svn: 163337
2012-09-06 18:32:18 +00:00
Fariborz Jahanian 66c93f443d c: make __attribute__((unused)) transitive.
Don't warn if annotated decl is used inside another
   unused. // rdar://12233989

llvm-svn: 163329
2012-09-06 16:43:18 +00:00
Roman Divacky 6d6c3110b5 Remove unused typedefs. Found by gcc48.
llvm-svn: 163327
2012-09-06 16:14:37 +00:00
Roman Divacky e637711ae0 Dont cast away const needlessly. Found by gcc48 -Wcast-qual.
llvm-svn: 163325
2012-09-06 15:59:27 +00:00
Richard Smith aa31b4b816 PR13775: When checking for a tag type being shadowed by some other declaration,
don't trample over the caller's LookupResult in the case where the check fails.

llvm-svn: 163281
2012-09-06 01:37:56 +00:00
Jordan Rose 91f7840651 Continue including temporary destructors in the CFG used for warnings.
...and hopefully unbreak buildbots. My apologies!

llvm-svn: 163267
2012-09-05 23:11:06 +00:00
Jordan Rose aee3438195 Format strings: suggest casts for NS(U)Integer and [SU]Int32 on Darwin.
These types are defined differently on 32-bit and 64-bit platforms, and
trying to offer a fixit for one platform would only mess up the format
string for the other. The Apple-recommended solution is to cast to a type
that is known to be large enough and always use that to print the value.

This should only have an impact on compile time if the format string is
incorrect; in cases where the format string matches the definition on the
current platform, no warning will be emitted.

<rdar://problem/9135072&12164284>

llvm-svn: 163266
2012-09-05 22:56:26 +00:00
Jordan Rose 22b7471f43 Format string checking: change long if-statement to early returns.
No functionality change.

llvm-svn: 163265
2012-09-05 22:56:19 +00:00
Fariborz Jahanian aaf376b4dd c error recovery. treat an invalid redeclaration
of a c-function for what it is. Otherwise, this func
is treated as an overloadable c-function resulting in
a crash much later. // rdar://11743706

llvm-svn: 163224
2012-09-05 17:52:12 +00:00
Abramo Bagnara 8843f9f3d4 Do not add using directives to a function decl context when instantiating.
llvm-svn: 163208
2012-09-05 09:55:10 +00:00
Abramo Bagnara 02b9553bdb Fixed lexical decl context of out of line class template instantiations.
llvm-svn: 163206
2012-09-05 09:05:18 +00:00
Chad Rosier 87b3d03cc2 Update for r163187.
llvm-svn: 163188
2012-09-05 01:16:06 +00:00
Joao Matos 566359c0bf Revert r163083 per chandlerc's request.
llvm-svn: 163149
2012-09-04 17:49:35 +00:00
Joao Matos e30771fdbd Revert r163078 per chandlerc's request.
llvm-svn: 163145
2012-09-04 17:18:12 +00:00
Chad Rosier dea7964ddb [ms-inline asm] The MCInstrDesc only tracks register definitions. For now,
assume that if the 1st operands is an expression and the instruction mayStore,
then it is a memory definition.

llvm-svn: 163144
2012-09-04 16:39:38 +00:00
Chad Rosier 5c8822d3ff Fix 80-column violation.
llvm-svn: 163142
2012-09-04 15:58:44 +00:00
Chad Rosier 93380f63c9 [ms-inline asm] Use the new GetMCInstOperandNum() interface in the front-end.
llvm-svn: 163126
2012-09-03 20:40:52 +00:00
Chad Rosier fd648a0320 Removed unused argument.
llvm-svn: 163105
2012-09-03 03:16:15 +00:00
Chad Rosier 30c0cb2f30 [ms-inline asm] Update for the MatchInstruction API change in r163101.
llvm-svn: 163102
2012-09-03 02:30:13 +00:00
Joao Matos c32a7e4d8e Implemented parsing and AST support for the MS __leave exception statement. Also a minor fix to __except printing in StmtPrinter.cpp. Thanks to Aaron Ballman for review.
llvm-svn: 163083
2012-09-02 03:45:41 +00:00
Joao Matos 26b2095401 Added a diagnostic for mismatched MS inheritance attributes. Also fixed the incomplete type member pointer size calculation under the MS ABI.
llvm-svn: 163078
2012-09-02 00:13:48 +00:00
Joao Matos a5c42e9f2a Changed the remaining dead asserts to llvm_unreachable.
llvm-svn: 163039
2012-09-01 00:13:24 +00:00
Chris Lattner 6dc7e57d6a don't warn about unused values when the unused value is a statement expression expanded from a macro. This is of dubious utility in general, but is specifically a major issue for the linux kernel. This resolves PR13747.
llvm-svn: 163034
2012-08-31 22:39:21 +00:00
Joao Matos e9a3ed4d71 Normalize line endings of r163013 (part 2).
llvm-svn: 163032
2012-08-31 22:18:20 +00:00
DeLesley Hutchins 3c3d57bc16 Thread-safety analysis: fix handling of string constants in mutex
expressions, which should be ignored right now.

llvm-svn: 163026
2012-08-31 21:57:32 +00:00
Fariborz Jahanian 0e337543dc objective-C ARC; detect and warn on retain cycle when
property-dot syntax is used on an object whose
capture causes retain cycle. // rdar://11702054

llvm-svn: 163017
2012-08-31 20:04:47 +00:00
Joao Matos dc86f94f62 Improved MSVC __interface support by adding first class support for it, instead of aliasing to "struct" which had some incorrect behaviour. Patch by David Robins.
llvm-svn: 163013
2012-08-31 18:45:21 +00:00
Fariborz Jahanian 6ce25c09ed objective-C: underline name of the missing method
in the diagnbostic. // rdar://11303469

llvm-svn: 163003
2012-08-31 17:03:18 +00:00
Eli Friedman 34866c7719 Change the representation of builtin functions in the AST
(__builtin_* etc.) so that it isn't possible to take their address.
Specifically, introduce a new type to represent a reference to a builtin
function, and a new cast kind to convert it to a function pointer in the
operand of a call.  Fixes PR13195.

llvm-svn: 162962
2012-08-31 00:14:07 +00:00
Fariborz Jahanian cd278ffa28 objective-C ARC: under -Wexplicit-ownership-type diagnose those
method parameter types which are reference to an objective-C
pointer to object with no explicit ownership. // rdar://10907090

llvm-svn: 162959
2012-08-30 23:56:02 +00:00
Douglas Gregor a3d3fe9be6 The presence of a user-*declared* constructor makes the default
constructor not user provided (and, therefore, non-trivial). Fixes
<rdar://problem/11736429>.

llvm-svn: 162947
2012-08-30 21:47:37 +00:00
Richard Trieu 73e306e548 Add -Wduplicate-enum warning. Clang will emit this warning when an implicitly
initiated enum constant has the same value as another enum constant.

For instance:
enum test { A, B, C = -1, D, E = 1 };
Clang will warn that:
 A and D both have value 0
 B and E both have value 1

A few exceptions are made to keep the noise down.  Enum constants which are
initialized to another enum constant, or an enum constant plus or minus 1 will
not trigger this warning.  Also, anonymous enums are not checked.

llvm-svn: 162938
2012-08-30 20:32:24 +00:00
Fariborz Jahanian f257857443 objective-C: clang must implicitly convert
__objc_yes/__objc_no to (BOOL)1/(BOOL)0 when
BOOL is declared; otherwise it resorts to
default of 'signed char'. This is important to
selecting the correct Numeric API numberWithBool:
Can't have a clang test for this. Will checkin and
executable llvm test. // rdar://12156616

llvm-svn: 162922
2012-08-30 18:49:41 +00:00
Richard Smith b3afa6c483 PR13652: Don't assume the parameter array on a FunctionTypeLoc for a lambda will
be filled in; they won't if the lambda's declarator has an invalid type. Instead
take the parameters from the declarator directly.

llvm-svn: 162904
2012-08-30 13:13:20 +00:00
Ted Kremenek 7712eef0d7 Fix serious regression introduced in r157780 where __attribute__((NSObject))
could not be attached to a CFTypeRef.

Fixes <rdar://problem/12197822>

llvm-svn: 162872
2012-08-29 22:54:47 +00:00
Fariborz Jahanian f07bcc527a objective-C: make -Widiomatic-parentheses work
when assignment expression in conditional invloves
property reference. // rdar://11066598

llvm-svn: 162846
2012-08-29 17:17:11 +00:00
Aaron Ballman d5a176dbad Reversing the logic since C99 mode is actually not an extension. Also, changing the group to the singular to match the diagnostic better.
llvm-svn: 162838
2012-08-29 12:35:14 +00:00
Alexander Kornienko 8b3f623582 Keep history of macro definitions and #undefs
Summary:
Summary: Keep history of macro definitions and #undefs with corresponding source locations, so that we can later find out all macros active in a specified source location. We don't save the history in PCH (no need currently). Memory overhead is about sizeof(void*)*3*<number of macro definitions and #undefs>+<in-memory size of all #undef'd macros>

I've run a test on a file composed of 109 .h files from boost 1.49 on x86-64 linux.
Stats before this patch:
*** Preprocessor Stats:
73222 directives found:
  19171 #define.
  4345 #undef.
  #include/#include_next/#import:
    5233 source files entered.
    27 max include stack depth
  19210 #if/#ifndef/#ifdef.
  2384 #else/#elif.
  6891 #endif.
  408 #pragma.
14466 #if/#ifndef#ifdef regions skipped
80023/451669/1270 obj/fn/builtin macros expanded, 85724 on the fast path.
127145 token paste (##) operations performed, 11008 on the fast path.

Preprocessor Memory: 5874615B total
  BumpPtr: 4399104
  Macro Expanded Tokens: 417768
  Predefines Buffer: 8135
  Macros: 1048576
  #pragma push_macro Info: 0
  Poison Reasons: 1024
  Comment Handlers: 8

Stats with this patch:
...
Preprocessor Memory: 7541687B total
  BumpPtr: 6066176
  Macro Expanded Tokens: 417768
  Predefines Buffer: 8135
  Macros: 1048576
  #pragma push_macro Info: 0
  Poison Reasons: 1024
  Comment Handlers: 8

In my test increase in memory usage is about 1.7Mb, which is ~28% of initial preprocessor's memory usage and about 0.8% of clang's total VMM allocation.

As for CPU overhead, it should only be noticeable when iterating over all macros, and should mostly consist of couple extra dereferences and one comparison per macro + skipping of #undef'd macros. It's less trivial to measure, though, as the preprocessor consumes a very small fraction of compilation time.


Reviewers: doug.gregor, klimek, rsmith, djasper

Reviewed By: doug.gregor

CC: cfe-commits, chandlerc

Differential Revision: http://llvm-reviews.chandlerc.com/D28

llvm-svn: 162810
2012-08-29 00:20:03 +00:00
Fariborz Jahanian 272b7dc8ae objective-C arc: ns_returns_retained is a type attribute in ARC,
and when used in property type declaration, is handled as type
attribute. Do not issue the warning when declaraing the property. 
// rdar://12173491

llvm-svn: 162801
2012-08-28 22:26:21 +00:00
Chad Rosier 6f0a9a2e2f Revert r162424 now that the scoping issue has been fixed in r162444.
llvm-svn: 162797
2012-08-28 22:08:58 +00:00
Aaron Ballman 3731b33009 Splitting the duplicated decl spec extension warning into two: one is an ExtWarn and the other a vanilla warning. This addresses PR13705, where const char const * wouldn't warn unless -pedantic was specified under the right conditions.
llvm-svn: 162793
2012-08-28 20:55:40 +00:00
Peter Collingbourne c6b0857e95 CUDA: give static storage class to __shared__ and __constant__
variables without a storage class within a function, to implement
CUDA B.2.5: "__shared__ and __constant__ variables have implied static
storage [duration]."

llvm-svn: 162788
2012-08-28 20:37:50 +00:00
Chad Rosier 7ae6360758 Tidy up.
llvm-svn: 162786
2012-08-28 20:35:06 +00:00
Chad Rosier 3dd7bf2c86 [ms-inline asm] Add constraints to MSAsmStmt. We don't currently compute
the constraints, so in the interim we speculatively assume a 'r' constraint.
This is expected to work for most cases on x86.

llvm-svn: 162784
2012-08-28 20:28:20 +00:00
Hans Wennborg f4ad232921 Warn about suspicious implicit conversions from floating point to bool
This warns in two specific situations:

1) For potentially swapped function arguments, e.g.

     void foo(bool, float);
     foo(1.7, false);

2) Misplaced brackets around function call arguments, e.g.

     bool InRange = fabs(a - b < delta);

   Where the last argument in a function call is implicitly converted
   from bool to float, and the function returns a float which gets
   implicitly converted to bool.

Patch by Andreas Eckleder!

llvm-svn: 162763
2012-08-28 15:44:30 +00:00
Rafael Espindola 3dd531dbd4 Fix for assertion when solving unresolved templates.
Patch by Magee, Josh.

llvm-svn: 162737
2012-08-28 04:13:54 +00:00
Chad Rosier d9fb09a91b [ms-inline asm] Rename getClobber to getClobberStringLiteral. No functional
change intended.

llvm-svn: 162710
2012-08-27 23:28:41 +00:00
Simon Atanasyan 8f06f2fbbf Support MIPS DSP Rev2 intrinsics.
The patch reviewed by Akira Hatanaka.

llvm-svn: 162669
2012-08-27 12:29:20 +00:00
John McCall a5f46fbcf9 Fix the CC-matching logic for instance methods in the MS ABI.
Patch by Timur Iskhodzhanov!

llvm-svn: 162639
2012-08-25 02:00:03 +00:00
Chad Rosier de70e0ef45 [ms-inline asm] As part of a larger refactoring, rename AsmStmt to GCCAsmStmt.
No functional change intended.

llvm-svn: 162632
2012-08-25 00:11:56 +00:00
Richard Smith a6a03369da Remove RequireCompleteType call which was made redundant by r162586.
llvm-svn: 162630
2012-08-24 23:51:39 +00:00
Fariborz Jahanian 1cfbe7a240 objective-C: Do not warn if align attribute on method
declaration is not provided. It is only necessary on
the method implementation. // rdar://11593375

llvm-svn: 162628
2012-08-24 23:50:13 +00:00
John McCall e91aec7a57 When computing the effective context for access control,
make sure we walk up the DC chain for the current context,
rather than allowing ourselves to get switched over to the
canonical DC chain.  Fixes PR13642.

llvm-svn: 162616
2012-08-24 22:54:02 +00:00
Chad Rosier 175ea24e38 [ms-inline asm] Change the -fenable-experimental-ms-inline-asm option from a
CodeGen option to a LangOpt option.  In turn, hoist the guard into the parser 
so that we avoid the new (and fairly unstable) Sema/AST/CodeGen logic.  This
should restore the behavior of clang to that prior to r158325.
<rdar://problem/12163681>

llvm-svn: 162602
2012-08-24 21:42:51 +00:00
Benjamin Kramer c5d00f61b6 Remove unnecessary calls to c_str.
llvm-svn: 162590
2012-08-24 20:43:21 +00:00
John McCall 7d8b041999 Instantiate class template specializations during ADL.
llvm-svn: 162586
2012-08-24 20:38:34 +00:00
Fariborz Jahanian fd5cf6cf26 objective-C: When checking for valid overriden property
in class extension, assume default is rewdwrite and don't
issue any diagnostics, privided other ownership models
are ok.

llvm-svn: 162583
2012-08-24 20:10:53 +00:00
Chad Rosier 1e17cf9c22 [ms-inline asm] Generate the Input/Output expressions using
Sema::ActOnIdExpression().

llvm-svn: 162564
2012-08-24 16:38:58 +00:00
Chad Rosier ab24b6e24e Fix 80-column violation.
llvm-svn: 162560
2012-08-24 15:51:10 +00:00
Benjamin Kramer c215e76f78 Push ArrayRef through the Expr hierarchy.
No functionality change.

llvm-svn: 162552
2012-08-24 11:54:20 +00:00
Chad Rosier fe31e626ca [ms-inline asm] Add the basic APIs for Exprs to the MSAsmStmt AST. Next we need
generate the Input/Output expressions using Sema::ActOnIdExpression().

llvm-svn: 162509
2012-08-24 00:07:09 +00:00
Dmitri Gribenko dd28e7930c Fix a few -Wdocumentation warnings.
llvm-svn: 162506
2012-08-24 00:01:24 +00:00
Benjamin Kramer cc4c49dd63 Now that ASTMultiPtr is nothing more than a array reference, make it a MutableArrayRef.
This required changing all get() calls to data() and using the simpler constructors.

llvm-svn: 162501
2012-08-23 23:38:35 +00:00
Benjamin Kramer f062343889 Remove ASTOwningVector, it doesn't own anything and provides no value over SmallVector.
llvm-svn: 162492
2012-08-23 22:51:59 +00:00
Benjamin Kramer 62b95d88dc Rip out remnants of move semantic emulation and smart pointers in Sema.
These were nops for quite a while and only lead to confusion. ASTMultiPtr
now behaves like a proper dumb array reference.

llvm-svn: 162475
2012-08-23 21:35:17 +00:00
Dmitri Gribenko adba9be7c5 Fix a bunch of -Wdocumentation warnings.
llvm-svn: 162452
2012-08-23 17:58:28 +00:00
Chad Rosier 8e0744312b [ms-inline asm] Rename a few induction variables to avoid confusion and silence
a gcc warning.

llvm-svn: 162444
2012-08-23 15:44:35 +00:00
Richard Smith 802c4b7015 Fix undefined behavior: member function calls where 'this' is a null pointer.
llvm-svn: 162430
2012-08-23 06:16:52 +00:00
Richard Smith 9db4b0020c Fix undefined behavior: don't call ObjCInterfaceDecl::isArcWeakrefUnavailable
on a null pointer. (This function happens to work for a null 'this' pointer, so
no test.)

llvm-svn: 162427
2012-08-23 04:53:18 +00:00
Matt Beaumont-Gay 1e774bc835 Don't recycle loop variables (to keep GCC happy).
llvm-svn: 162424
2012-08-23 01:51:18 +00:00
Chad Rosier 0cf0615571 Fix 80-column violation.
llvm-svn: 162416
2012-08-23 00:12:51 +00:00
Chad Rosier f4958d1f10 [ms-inline asm] Compute the inputs and outputs. No test case (yet) as this
requires codegen support.

llvm-svn: 162410
2012-08-22 23:42:09 +00:00
Chad Rosier dc5311aab6 [ms-inline asm] Refactor code so that we can begin computing the Inputs/Outputs.
No functional change intended.

llvm-svn: 162403
2012-08-22 22:10:51 +00:00
Chad Rosier eb7deb2851 [ms-inline asm] Add comments.
llvm-svn: 162396
2012-08-22 21:12:19 +00:00
Chad Rosier 53d79d9905 [ms-inline asm] Add comments.
llvm-svn: 162394
2012-08-22 21:08:06 +00:00
Chad Rosier bb365caf80 [ms-inline asm] Add helper function. No functional change intended.
llvm-svn: 162393
2012-08-22 21:04:07 +00:00
Chad Rosier 6b6a8a363b [ms-inline asm] Simplify logic. No functional change intended.
llvm-svn: 162392
2012-08-22 20:57:07 +00:00
Chad Rosier 060c0ea89a [ms-inline asm] Compute the token range for each instruction within the asm.
Eventually, we'll need a way of mapping tokens (and their IdentifierInfo*) to
the operands computed by buildMSAsmPieces().

llvm-svn: 162388
2012-08-22 20:30:58 +00:00
Chad Rosier a766697f4e [ms-inline asm] Simplify logic. No functional change intended.
llvm-svn: 162385
2012-08-22 19:50:28 +00:00
Chad Rosier d997bd1422 [ms-inline asm] Start sending non-simple inline asms to the AsmParser.
The parser still can't handle all cases, so fall back to emitting a simple
MSAsmStmt if we get into trouble.

llvm-svn: 162382
2012-08-22 19:18:30 +00:00
Benjamin Kramer fc6eb7d383 Reduce duplicated hash map lookups.
llvm-svn: 162361
2012-08-22 15:37:55 +00:00