Commit Graph

9448 Commits

Author SHA1 Message Date
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
Rafael Espindola 0c6c405e23 Merge existing attributes before processing pragmas in friend template
declarations.
Fixes pr13662.

llvm-svn: 162360
2012-08-22 14:52:14 +00:00
Chad Rosier bbdd467895 [ms-inline asm] Remove the patchMSAsmStrings function. After some discussion
between Bob, Jim, Eric and I, we've decided to take a slightly different
approach.

llvm-svn: 162327
2012-08-21 23:09:21 +00:00
Chad Rosier b958037958 [ms-inline asm] Have buildMSAsmString build a vector of unmodified AsmStrings.
Add a new static function, buildMSAsmPieces, that will break these strings down
into mnemonic and operands.  Upon a match failure, the idea is to use the
ErrorInfo from MatchInstructionImpl to inspect the mnemonic/operand and 
decide a course of action.  Unfortunately, there's no easy way to test this at
the moment.

llvm-svn: 162321
2012-08-21 21:56:39 +00:00
Fariborz Jahanian ea262f7936 change function name in my last patch.
// rdar://12103400

llvm-svn: 162320
2012-08-21 21:52:02 +00:00
Fariborz Jahanian 8d1ca5a142 objective-C: Change rules for overriding properties in
class extensions a little. clang now allows readonly property 
with no ownership rule (assign, unsafe_unretained, weak, retain, 
strong, or copy) with a readwrite property with an ownership rule.
// rdar://12103400 

llvm-svn: 162319
2012-08-21 21:45:58 +00:00
Chad Rosier 5111f8650d [ms-inline asm] Do not report a Parser error when matching inline assembly.
llvm-svn: 162307
2012-08-21 19:37:55 +00:00
Chad Rosier 19160b6e39 [ms-inline asm] Expose the ErrorInfo from the MatchInstructionImpl. In general,
this is the index of the operand that failed to match.

llvm-svn: 162296
2012-08-21 18:15:08 +00:00
Chad Rosier 5e80ced3f6 [ms-inline asm] Append identifier for better debugging.
llvm-svn: 162289
2012-08-21 17:02:27 +00:00
Chad Rosier b84cc6cfa3 [ms-inline asm] Remove this test case and the associated special case code.
llvm-svn: 162288
2012-08-21 17:01:26 +00:00
John McCall 3deb1ad40c Screw around with ObjCRuntime some more, changing the
diagnostics for bad deployment targets and adding a few
more predicates.  Includes a patch by Jonathan Schleifer
to enable ARC for ObjFW.

llvm-svn: 162252
2012-08-21 02:47:43 +00:00
Sam Panzer 0f38443616 Better diagnostics for range-based for loops with bad range types.
The old error message stating that 'begin' was an undeclared identifier
is replaced with a new message explaining that the error is in the range
expression, along with which of the begin() and end() functions was
problematic if relevant.

Additionally, if the range was a pointer type or defines operator*,
attempt to dereference the range, and offer a FixIt if the modified range
works.

llvm-svn: 162248
2012-08-21 00:52:01 +00:00
John McCall d8561f058d Fix a pair of bugs relating to properties in ARC.
First, when synthesizing an explicitly strong/retain/copy property
of Class type, don't pretend during compatibility checking that the
property is actually assign.  Instead, resolve incompatibilities
by secretly changing the type of *implicitly* __unsafe_unretained
Class ivars to be strong.  This is moderately evil but better than
what we were doing.

Second, when synthesizing the setter for a strong property of
non-retainable type, be sure to use objc_setProperty.  This is
possible when the property is decorated with the NSObject
attribute.  This is an ugly, ugly corner of the language, and
we probably ought to deprecate it.

The first is rdar://problem/12039404;  the second was noticed by
inspection while fixing the first.

llvm-svn: 162244
2012-08-20 23:36:59 +00:00
Jordan Rose 53cb2f327a Code-complete 'weak' for properties under ARC-with-weak-references (or GC)
Also, suggest 'readonly' even if the property has been given an ownership
attribute ('strong', 'weak', etc). This is used when properties are declared
readonly in the public interface but readwrite in a class extension.

<rdar://problem/11500004&11932285>

llvm-svn: 162220
2012-08-20 20:01:13 +00:00
Chad Rosier d4e55b8e35 [ms-inline asm] Remove old cruft now that MS-style asms their own code path.
llvm-svn: 162210
2012-08-20 17:11:53 +00:00
Hans Wennborg d799a2b3b9 Better wording for reference self-initialization warning.
llvm-svn: 162198
2012-08-20 08:52:22 +00:00
Richard Smith 4f605aff7f PR41111, PR5925, PR13210: Teach tentative parsing to annotate identifiers and
nested names as id-expressions, using the annot_primary_expr annotation, where
possible. This removes some redundant lookups, and also allows us to
typo-correct within tentative parsing, and to carry on disambiguating past an
identifier which we can determine will fail lookup as both a type and as a
non-type, allowing us to disambiguate more declarations (and thus offer
improved error recovery for such cases).

This also introduces to the parser the notion of a tentatively-declared name,
which is an identifier which we *might* have seen a declaration for in a
tentative parse (but only if we end up disambiguating the tokens as a
declaration). This is necessary to correctly disambiguate cases where a
variable is used within its own initializer.

llvm-svn: 162159
2012-08-18 00:55:03 +00:00
Douglas Gregor c459b5178c When code completion is enabled, don't do any work in
Sema::ActOnEndOfTranslationUnit(). This is a (minor) optimization.

llvm-svn: 162144
2012-08-17 22:17:36 +00:00
Fariborz Jahanian f85f338634 c: privide deprecated warning when __private_extern__ storage
specifier is unsed in a declaration; as it may not make the symbol
local to linkage unit as intended. Suggest using "hidden" visibility 
attribute instead. // rdar://7703982

llvm-svn: 162138
2012-08-17 21:44:55 +00:00
Chad Rosier 571c5e91c4 [ms-inline asm] Update comment.
llvm-svn: 162134
2012-08-17 21:27:25 +00:00
Chad Rosier 0731affaca [ms-inline asm] Extract AsmStmt handling into a separate file, so as to not
pollute SemaStmt with extraneous asm handling logic.

llvm-svn: 162132
2012-08-17 21:19:40 +00:00
Fariborz Jahanian 91f548b04b c: implement gcc's -Wbad-function-cast which warns
on unsafe cast of a c-function call. This is
a C-only option.

llvm-svn: 162109
2012-08-17 17:22:34 +00:00
Chad Rosier 2da9d6d6cf [ms-inline asm] Instantiate the MCStreamer as a NullStream. We're parsing
instruction, not emitting them, so a NullStream is fine.

llvm-svn: 162105
2012-08-17 16:38:04 +00:00
Hans Wennborg e1fdb059c6 Warn about self-initialization of references.
Initializing a reference with itself, e.g. "int &a = a;" seems like a
very bad idea.

llvm-svn: 162093
2012-08-17 10:12:33 +00:00
Douglas Gregor e3eb777415 Make the spacing of the code completion result for NSDictionary
literals match the spacing introduced by the ObjC modernizer. Fixes
the rest of <rdar://problem/11889572>.

llvm-svn: 162084
2012-08-17 05:40:05 +00:00
Douglas Gregor 5d944dbf1a Don't do jump-scope checking when code completion is enabled. It's
both a waste of time, and prone to crash due to the use of the
error-recovery path in parser. Fixes <rdar://problem/12103608>, which
has been driving me nuts.

llvm-svn: 162081
2012-08-17 05:12:08 +00:00
Richard Smith 034b94a557 Don't forget to apply #pragma pack to partial and explicit specializations of
class templates. This fixes misalignment issues in llvm/Support/Endian.h when
built by Clang.

llvm-svn: 162074
2012-08-17 03:20:55 +00:00
Richard Smith 80b3c5a00e Don't form a null reference when checking for validity of an anonymous
elaborated type specifier in template instantiation: such a specifier is always
valid because it must be specified within the definition of the type.

llvm-svn: 162068
2012-08-17 00:12:27 +00:00
Dmitri Gribenko e4a5a90e8d Add support for "type safety" attributes that allow checking that 'void *'
function arguments and arguments for variadic functions are of a particular
type which is determined by some other argument to the same function call.

Usecases include:
* MPI library implementations, where these attributes enable checking that
  buffer type matches the passed MPI_Datatype;
* for HDF5 library there is a similar usecase as MPI;
* checking types of variadic functions' arguments for functions like
  fcntl() and ioctl().

llvm-svn: 162067
2012-08-17 00:08:38 +00:00
Eric Christopher ae6b9d2de3 Random string removal.
llvm-svn: 162063
2012-08-16 23:50:37 +00:00
Chad Rosier b899c1b417 [ms-inline asm] Comment.
llvm-svn: 162055
2012-08-16 22:47:10 +00:00
Chad Rosier bf17e01fe5 [ms-inline asm] Extract a helper function, getSpelling(). Also use this on
tokens we don't know how to handle; this should aid when debugging.

llvm-svn: 162053
2012-08-16 22:40:32 +00:00
Fariborz Jahanian 78f565b0a0 objective-C++: issue diagnostic when ivar type is
an abstract c++ class. // rdar://12095239

llvm-svn: 162052
2012-08-16 22:38:41 +00:00
Chad Rosier 50cf25c72d [ms-inline asm] If we don't know how to handle a token then assume this is not a
simple asm.

llvm-svn: 162051
2012-08-16 22:30:02 +00:00
Chad Rosier 3d4b98b4bc [ms-inline asm] Add a helper function, isMSAsmKeyword().
These require special handling, which we don't currently handle.  This is being
put in place to ensure we don't do invalid symbol table lookups or try to parse
invalid assembly.  The test cases just makes sure the latter isn't happening.

llvm-svn: 162050
2012-08-16 22:25:38 +00:00
Sam Panzer 2c4ca0fa7d Removed unused LParenLoc parameter to ActOnCXXForRangeStmt
llvm-svn: 162048
2012-08-16 21:47:25 +00:00
Chad Rosier efb2911664 [ms-inline asm] Perform symbol table lookup on variables. The idea is to use
this information to determine valid MC operands.  This will also be used for
semantic analysis.

llvm-svn: 162043
2012-08-16 19:52:25 +00:00
Fariborz Jahanian 5ad9659688 objective-C: deprecate casts of ObjC's SEL
expressions except to void, void * and their
qualified versions. // rdar://12107381

llvm-svn: 162036
2012-08-16 18:33:47 +00:00
Chad Rosier 592b90a476 [ms-inline asm] Start tracking which tokens are registers and which are
variables, function or label references.  The former is a potential clobber.
The latter is either an input or an output.  Unfortunately, it's difficult to
test this patch at the moment, but the added test case will eventually do so.

llvm-svn: 162026
2012-08-16 17:10:59 +00:00
Richard Smith 235341bc88 Store SourceManager pointer on PrintingPolicy in the case where we're dumping,
and remove ASTContext reference (which was frequently bound to a dereferenced
null pointer) from the recursive lump of printPretty functions. In so doing,
fix (at least) one case where we intended to use the 'dump' mode, but that
failed because a null ASTContext reference had been passed in.

llvm-svn: 162011
2012-08-16 03:56:14 +00:00
Sam Panzer 04390a63c8 Test commit: deleted whitespace on blank line
llvm-svn: 162006
2012-08-16 02:38:47 +00:00
Chad Rosier 7dbef3e035 [ms-inline asm] Add inputs and outputs to AST. No functional change.
llvm-svn: 162000
2012-08-16 00:06:53 +00:00
Chad Rosier b32f3d5230 [ms-inline asm] Use a set container to remove redundant clobbers.
llvm-svn: 161991
2012-08-15 21:55:19 +00:00
Chad Rosier 712faa2708 [ms-inline asm] Address a FIXME by computing the number of asm statements when
building the AsmString.

llvm-svn: 161988
2012-08-15 21:08:52 +00:00
Chad Rosier aa7c1cb5f8 [ms-inline asm] MSVC parses multiple __asm statements on a single line as one
statement.  For example,

  if (x)
    __asm out dx, ax  __asm out dx, ax

results in a single inline asm statement (i.e., both "out dx, ax" statements are
predicated on if(x)).

llvm-svn: 161986
2012-08-15 21:03:27 +00:00
Matt Beaumont-Gay 22be8d5ab8 Allow 'static' and type qualifiers in K&R parameter type lists.
llvm-svn: 161980
2012-08-15 19:53:19 +00:00
Chad Rosier ecf77b56dd [ms-inline asm] Don't emit newlines as these are ignored by the AsmParser
anyways.  Also, simplify some conditional logic.

llvm-svn: 161977
2012-08-15 19:12:42 +00:00
Fariborz Jahanian 05f4e7181a Patch to warn about __private_extern__ on tentative definitions
as it does something unexpected (but gcc compatible).
Suggest use of __attribute__((visibility("hidden")))
on declaration instead. // rdar://7703982

llvm-svn: 161972
2012-08-15 18:42:26 +00:00
Chad Rosier ad34aef449 [ms-inline asm] Capturing loop-scoped (std::string)Reg with a StringRef is bad.
llvm-svn: 161966
2012-08-15 18:09:18 +00:00
Chad Rosier b6f46c1af9 [ms-inline asm] Add the left brace source location and improve the pretty
printer.  Patch by Enea Zaffanella <zaffanella@cs.unipr.it>.

llvm-svn: 161958
2012-08-15 16:53:30 +00:00
Hans Wennborg 420052640f Check for improper use of 'static' and type qualifiers in array
declarators.

They are only allowed for function parameters, and then only on the
outermost array type derivation.

llvm-svn: 161934
2012-08-15 07:42:30 +00:00
NAKAMURA Takumi 19f29cfc14 clang/lib/Sema/SemaStmt.cpp: Include MCAsmLexer.h to appease msvc to define llvm::AsmToken.
llvm-svn: 161927
2012-08-15 04:19:08 +00:00
Chad Rosier 222ed4b53a [ms-inline asm] Have MC start parsing the asms.
llvm-svn: 161913
2012-08-15 00:42:47 +00:00
Richard Trieu b7ed89eb94 Check local static variables for self reference on initialization.
llvm-svn: 161909
2012-08-14 23:50:52 +00:00
Chad Rosier 767a7b9ed0 [ms-inline asm] Remove the last bits of LineEnds.
llvm-svn: 161904
2012-08-14 23:14:45 +00:00
Richard Smith 1226c60593 Remove trailing return flag from FunctionTypeLoc, since we now carry that
information on FunctionProtoType. (This also fixes one of *many* misalignment
problems in the TypeLoc hierarchy...)

llvm-svn: 161901
2012-08-14 22:51:13 +00:00
Chad Rosier a6e89aac91 [ms-inline asm] Simplify more logic by using the Token::hasLeadingSpace() and
Token::isAtStartOfLine() APIs.

llvm-svn: 161898
2012-08-14 22:11:17 +00:00
Chad Rosier bba12afe48 [ms-inline asm] Address a potential buffer overflow.
llvm-svn: 161896
2012-08-14 21:48:01 +00:00
Chad Rosier 25e8fe6ae0 [ms-inline asm] Simplify the logic in patchMSAsmString. We no longer need to
track the LineEnds now that single line asm statments aren't merged.

llvm-svn: 161893
2012-08-14 20:58:21 +00:00
Dmitri Gribenko b261088a61 Attaching comments to redeclarations: fix wrong assumptions
The reason for the recent fallout for "attaching comments to any redeclaration"
change are two false assumptions:
(1) a RawComment is attached to a single decl (not true for 'typedef struct X *Y'
    where we want the comment to be attached to both X and Y);
(2) the whole redeclaration chain has only a single comment (obviously false, the
    user can put a separate comment for each redeclaration).

To fix (1) I revert the part of the recent change where a 'Decl*' member was
introduced to RawComment.  Now ASTContext has a separate DenseMap for mapping
'Decl*' to 'FullComment*'.

To fix (2) I just removed the test with this assumption.  We might not parse
every comment in redecl chain if we already parsed at least one.

llvm-svn: 161878
2012-08-14 17:17:18 +00:00
Benjamin Kramer 25885f4657 Remove and simplify unused checking code.
This is already handled by CheckCallingConvAttr.

llvm-svn: 161865
2012-08-14 13:24:39 +00:00
Benjamin Kramer 833fb9f7e3 Fix horribly broken sema of __attribute__((pcs())).
llvm-svn: 161863
2012-08-14 13:13:47 +00:00
Eli Friedman 1d4c3cfb88 Make __is_convertible_to handle abstract types correctly. PR13591.
llvm-svn: 161828
2012-08-14 02:06:07 +00:00
Richard Smith 7d6d47b862 Fix undefined behavior (and wrong code, as far as I can tell) in NEON builtin
tablegen code, found by -fcatch-undefined-behavior. I would appreciate if
someone more familiar with the NEON code could point me in the direction of how
to write a test for this. We appear to have essentially no test coverage
whatsoever for these builtins.

llvm-svn: 161827
2012-08-14 01:28:02 +00:00
Chad Rosier 7459543795 [ms-inline asm] Add a helpful assert.
llvm-svn: 161796
2012-08-13 22:04:09 +00:00
Chad Rosier 162b14f326 [ms-inline asm] Address a potential buffer overflow.
llvm-svn: 161793
2012-08-13 21:35:47 +00:00
Chad Rosier 65a8e0b69f [ms-inline asm] Have patchMSAsmStrings() return a vector or AsmStrings.
The AsmParser expects a single asm instruction, but valid ms-style inline asm
statements may contain  multiple instructions.

This happens with asm blocks

__asm {
  mov ebx, eax
  mov ecx, ebx
}

or when multiple asm statements are adjacent to one another

__asm mov ebx, eax
__asm mov ecx, ebx

and

__asm mov ebx, eax __asm mov ecx, ebx

Currently, asm blocks are not properly handled.

llvm-svn: 161780
2012-08-13 20:32:07 +00:00
Richard Smith ef8bf4368e Factor out computation of whether a typeid's expression is potentially
evaluated into a CXXTypeid member function. No functionality change.

llvm-svn: 161779
2012-08-13 20:08:14 +00:00
Dmitri Gribenko a43ec186a4 Attaching comments to declarations: find comment attached to any redeclaration
Not only look for the comment near the declaration itself, but also walk the
redeclaration chain: the previous declaration might have had a documentation
comment.

llvm-svn: 161722
2012-08-11 00:51:43 +00:00
Chad Rosier f32302a7d9 [ms-inline asm] PatchMSAsmString() doesn't correctly patch non-simple asm
statements.  Therefore, we can't pass the PatchedAsmString to the AsmParser
and expect things to work.

llvm-svn: 161701
2012-08-10 21:27:11 +00:00
Chad Rosier d6ef704fe4 [ms-inline asm] Fix a memory leak introduced in r161686.
llvm-svn: 161698
2012-08-10 21:06:19 +00:00
Chad Rosier a7020aee00 [ms-inline asm] Add clobbers to AST representation.
llvm-svn: 161686
2012-08-10 19:13:14 +00:00
Chad Rosier 3674ebaa6b [ms-inline asm] Use asserts as these calls are now guarded by identical checks.
llvm-svn: 161676
2012-08-10 18:20:12 +00:00
Chad Rosier 02a8439730 Whitespace.
llvm-svn: 161673
2012-08-10 17:56:09 +00:00
John McCall a0a9689550 Check access to friend declarations. There's a number of different
things going on here that were problematic:
  - We were missing the actual access check, or rather, it was suppressed
    on account of being a redeclaration lookup.
  - The access check would naturally happen during delay, which isn't
    appropriate in this case.
  - We weren't actually emitting dependent diagnostics associated with
    class templates, which was unfortunate.
  - Access was being propagated incorrectly for friend method declarations
    that couldn't be matched at parse-time.

llvm-svn: 161652
2012-08-10 03:15:35 +00:00
David Blaikie f5697e5222 Provide isConst/Volatile on CXXMethodDecl.
This also provides isConst/Volatile/Restrict on FunctionTypes to coalesce
the implementation with other callers (& update those other callers).

Patch contributed by Sam Panzer (panzer@google.com).

llvm-svn: 161647
2012-08-10 00:55:35 +00:00
Benjamin Kramer be1bc3c824 CMake: Add the new dependency from libSema to LLVM's libs.
Should fix the failures seen on some linux builders.

llvm-svn: 161629
2012-08-09 22:33:50 +00:00
Chad Rosier d82f647dee [ms-inline asm] Fix comment.
llvm-svn: 161622
2012-08-09 21:28:05 +00:00
Chad Rosier 8640a2a0db [ms-inline asm] Use StringRef here, per Jordan's suggestion.
llvm-svn: 161619
2012-08-09 21:06:32 +00:00
Chad Rosier 543cb3e93a [ms-inline asm] Simplify logic for empty asm statements.
llvm-svn: 161615
2012-08-09 20:52:43 +00:00
Chad Rosier 11ede938e9 [ms-inline asm] Instantiate the various parts to the AsmParser.
llvm-svn: 161614
2012-08-09 20:47:38 +00:00
Chad Rosier d5c43a5f4b [ms-inline asm] Initialize targets and assembly printers/parsers.
llvm-svn: 161595
2012-08-09 17:33:11 +00:00
Fariborz Jahanian 18d0a5d509 objective-C: refactor/simplify parsing of delayed
method/c-funcs defined in objc class implementation.
No intended functionality change.

llvm-svn: 161540
2012-08-08 23:41:08 +00:00
Richard Smith ac4e36d1af PR13558: Fix typo 'compatiblity'. Thinking of the children. Apparently.
llvm-svn: 161537
2012-08-08 23:32:13 +00:00
Eli Friedman 971bfa11c6 Unify the codepaths for emitting deprecation warnings. The test changes are just to account for us emitting notes more consistently.
llvm-svn: 161528
2012-08-08 21:52:41 +00:00
Anna Zaks 13b0857ad0 Address code review comments for Wstrncat-size warning (r161440).
llvm-svn: 161527
2012-08-08 21:42:23 +00:00
Chad Rosier 5d4d8b746b [ms-inline asm] Use more idiomatic logic. Thanks, Bill.
llvm-svn: 161526
2012-08-08 21:42:11 +00:00
Jordan Rose 742c6079e2 Implicitly annotate __CFStringMakeConstantString with format_arg(1).
We handled the builtin version of this function in r157968, but the builtin
isn't used when compiling as -fno-constant-cfstrings.

This should complete <rdar://problem/6157200>.

llvm-svn: 161525
2012-08-08 21:17:31 +00:00
Eli Friedman 0415f3e138 Don't add attributes for "#pragma pack" and friends to tag declarations which
are not definitions. This follows the behavior of both gcc and earlier
versions of clang. Regression from r156531.  <rdar://problem/12048621>.

llvm-svn: 161523
2012-08-08 21:08:34 +00:00
Chad Rosier b1886eb604 [ms-inline asm] Make sure IsSimple is correctly handled.
llvm-svn: 161522
2012-08-08 21:08:20 +00:00
Chad Rosier 66753b3835 Remove extraneous comment.
llvm-svn: 161521
2012-08-08 20:38:22 +00:00
Chad Rosier 83916498b8 [ms-inline asm] Add a very simple test case. Basically, we're only testing for
crashers at the moment (and coincidentally this case was causing a crash).

llvm-svn: 161520
2012-08-08 20:37:31 +00:00
Chad Rosier 3ed0bd9938 [ms-inline asm] Refactor the logic to generate the AsmString into Sema. No
functional change intended.

llvm-svn: 161518
2012-08-08 19:48:07 +00:00
Chad Rosier 1dcde96842 Whitespace.
llvm-svn: 161516
2012-08-08 18:46:20 +00:00
Chad Rosier d12b7a64dc [ms-inline asm] Add support for detecting simple ms-style inline asm. Simple
asm statements are those that don't reference variable names, function names,
and labels.

Add logic to generate a patched AsmString that will eventually be consumed by
the AsmParser.  No functional change at this point, so unfortunately no test
case.

llvm-svn: 161508
2012-08-08 18:22:06 +00:00
Chad Rosier d2ff32aa94 Add the IsSimple/IsVolatile parameters to the MSAsmStmt constructor.
llvm-svn: 161503
2012-08-08 17:35:36 +00:00
David Blaikie 1c7c8f7637 Implement warning for integral null pointer constants other than the literal 0.
This is effectively a warning for code that violates core issue 903 & thus will
become standard error in the future, hopefully. It catches strange null
pointers such as: '\0', 1 - 1, const int null = 0; etc...

There's currently a flaw in this warning (& the warning for 'false' as a null
pointer literal as well) where it doesn't trigger on comparisons (ptr == '\0'
for example). Fix to come in a future patch.

Also, due to this only being a warning, not an error, it triggers quite
frequently on gtest code which tests expressions for null-pointer-ness in a
SFINAE context (so it wouldn't be a problem if this was an error as in an
actual implementation of core issue 903). To workaround this for now, the
diagnostic does not fire in unevaluated contexts.

Review by Sean Silva and Richard Smith.

llvm-svn: 161501
2012-08-08 17:33:31 +00:00
Fariborz Jahanian a5063a6208 objc: Include all types when issuing warning under
-Wdirect-ivar-access.

llvm-svn: 161500
2012-08-08 16:41:04 +00:00
Benjamin Kramer 90653a1920 Remove unused variables.
llvm-svn: 161483
2012-08-08 09:26:28 +00:00
Richard Smith f2b084fc5a Implement final piece of DR963 and also DR587:
A conditional operator between glvalues of types cv1 T and cv2 T produces a
glvalue if the expressions are of the same value kind and one of cv1 and cv2
is a subset of the other.

A conditional operator between two null pointer constants is permitted if one
of them is of type std::nullptr_t.

llvm-svn: 161476
2012-08-08 06:13:49 +00:00
Eli Friedman ecffd83c85 Get rid of an early return in Sema::ActOnFields which doesn't make sense anymore.
Fixes a crash (<rdar://problem/11067144>), and generally seems to improve
recovery in other cases.

llvm-svn: 161474
2012-08-08 04:39:56 +00:00