Commit Graph

8242 Commits

Author SHA1 Message Date
Benjamin Kramer 73faad6409 Directly store TypoResultsMaps in the TypoEditDistanceMap, getting rid of manual deletion.
llvm-svn: 154736
2012-04-14 08:26:28 +00:00
Richard Smith c202b2809a Add an AttributedStmt type to represent a statement with C++11 attributes
attached. Since we do not support any attributes which appertain to a statement
(yet), testing of this is necessarily quite minimal.

Patch by Alexander Kornienko!

llvm-svn: 154723
2012-04-14 00:33:13 +00:00
Benjamin Kramer ac9b31a404 Delete the TypoResultsMap when erasing the pointer to it.
This manual deleting is error-prone, but we can't just put an OwningPtr in a
std::map :(

llvm-svn: 154707
2012-04-13 23:09:10 +00:00
Douglas Gregor aa0df2d373 Make control flow more explicit for rebuilding property reference expressions without their OpaqueValueExprs
llvm-svn: 154669
2012-04-13 16:05:42 +00:00
Douglas Gregor eba02fecdd super and class property reference expressions don't need to be
rebuilt. Fixes <rdar://problem/11052352>. 

llvm-svn: 154667
2012-04-13 15:53:08 +00:00
Richard Smith d65cee9423 Implement __atomic_fetch_nand and __atomic_nand_fetch to complete our set of
GNU __atomic builtins.

llvm-svn: 154659
2012-04-13 06:31:38 +00:00
Richard Smith 822698412b PR12500: Improve the wording of the diagnostic for a redefinition of a name
in the wrong namespace scope. Patch by Jonathan Sauer!

llvm-svn: 154656
2012-04-13 04:07:40 +00:00
John McCall d239387098 When we're flagging a protected scope to prevent jumps into the
shadow of a block expression with non-trivial destructed cleanups,
we should flag that in the enclosing function, not in the block
that we're about to pop.

llvm-svn: 154646
2012-04-13 01:08:17 +00:00
David Blaikie 9455da0ea9 Warn on 64-to-32 for source value of x bits where 64 >= x > 32.
The codepath already only works for source bits > target bits, it's just that
it was testing for the source expr bits to be exactly 64. This meant simple
cases (int i = x_long / 2) were missed & ended up under the general
-Wconversion warning, which a user might not have enabled.

llvm-svn: 154626
2012-04-12 22:40:54 +00:00
Fariborz Jahanian e2b037d6ea objective-c literals: Issue warning and ignore
when BOOL is not of an intergal type when
boolean literals are used. // rdar://11231426

llvm-svn: 154619
2012-04-12 21:24:56 +00:00
Douglas Gregor f9e36cccb5 s/isAtomicConversion/tryAtomicConversion/g, per Jordy's suggestion.
llvm-svn: 154613
2012-04-12 20:48:09 +00:00
Douglas Gregor 298f43df14 Fix some i1/i8 confusion within _Atomic(bool) in IR generation, both
in general (such an atomic has boolean representation) and
specifically for IR generation of __c11_atomic_init. The latter also
means actually using initialization semantics for this initialization,
rather than just creating a store.

On a related note, make sure we actually put in non-atomic-to-atomic
conversions when performing an implicit conversion sequence. IR
generation is far too kind here, but we still want the ASTs to make
sense.

llvm-svn: 154612
2012-04-12 20:42:30 +00:00
Douglas Gregor c79862f017 Compute standard conversion sequences for conversions to atomic
types. The second and third conversions in the sequence are based on
the conversion for the underlying type, so that we get sensible
overloading behavior for, e.g., _Atomic(int) vs. _Atomic(float).

As part of this, actually implement the lvalue-to-rvalue conversion
for atomic types. There is probably a pile of code in SemaExpr that
can now be deleted, but I haven't tracked it down yet.

llvm-svn: 154596
2012-04-12 17:51:55 +00:00
Fariborz Jahanian 30c3de97a9 objective-c numeric literal: type of boolean is
that of typedef BOOL if found.
// rdar://11231426

llvm-svn: 154595
2012-04-12 17:49:18 +00:00
Richard Smith feea883de4 Implement support for 18 of the GNU-compatible __atomic builtins.
This is not quite sufficient for libstdc++'s <atomic>: we still need
__atomic_test_and_set and __atomic_clear, and may need a more complete
__atomic_is_lock_free implementation.

We are also missing an implementation of __atomic_always_lock_free,
__atomic_nand_fetch, and __atomic_fetch_nand, but those aren't needed
for libstdc++.

llvm-svn: 154579
2012-04-12 05:08:17 +00:00
Richard Smith b1e36c662b Provide, and document, a set of __c11_atomic_* intrinsics to implement C11's
<stdatomic.h> header.

In passing, fix LanguageExtensions to note that C11 and C++11 are no longer
"upcoming standards" but are now actually standardized.

llvm-svn: 154513
2012-04-11 17:55:32 +00:00
David Chisnall f6e07b9951 Clean up last commit as per dgregor's comments.
llvm-svn: 154501
2012-04-11 16:08:14 +00:00
David Chisnall 28397be059 Allow c++ initialisers to initialise _Atomic fields.
llvm-svn: 154499
2012-04-11 15:29:15 +00:00
Douglas Gregor 85f3423509 When we determine that an initialization sequence failed due to an
incomplete type, keep track of the actual type that was
incomplete. Otherwise, we might fail to produce a diagnostic. Fixes
PR12498.

llvm-svn: 154432
2012-04-10 20:43:46 +00:00
Douglas Gregor 350880c4d8 Improve diagnostics in C++11 when a non-type template argument for a
non-type template parameter of pointer type is not a constant expression.

llvm-svn: 154424
2012-04-10 19:03:30 +00:00
Douglas Gregor 2997914ed0 Include the Objective-C parameter- and return-passing qualifiers when
providing code completions for Objective-C method declarations. Fixes
<rdar://problem/11164498>.

llvm-svn: 154421
2012-04-10 18:35:07 +00:00
Douglas Gregor 9489cdf29f Don't include the ':' following code-completion suggestions for
'public', 'private', or 'protected', unless code completion patterns
are enabled. Fixes <rdar://problem/11189132>.

llvm-svn: 154413
2012-04-10 17:56:28 +00:00
Fariborz Jahanian ca5c597fd0 objective-c: remove IsConstProperty as it does not
seem to get called any more. Also add an assert in
isModifiableLvalue.

llvm-svn: 154410
2012-04-10 17:30:10 +00:00
Argyrios Kyrtzidis 9d7c0fef65 [code-complete] Introduce CodeCompletionTUInfo which will be used for caching
code-completion related strings specific to a translation unit (ASTContext and related data)

CodeCompletionAllocator does such limited caching, by caching the name assigned
to a DeclContext*, but that is not the appropriate place since that object has
a lifetime that can extend beyond that of an ASTContext.

Introduce CodeCompletionTUInfo which will be always tied to a translation unit
to do this kind of caching and move the caching of CodeCompletionAllocator into this
object, and propagate it to all the places where it will be needed.

The plan is to extend the caching where appropriate, using CodeCompletionTUInfo,
to avoid re-calculating code-completion strings.

Part of rdar://10796159.

llvm-svn: 154408
2012-04-10 17:23:48 +00:00
Douglas Gregor 20fdef32dd Rework implementation of null non-type template arguments based on
Richard's feedback, to properly catch non-constant expressions and
type mismatches. Finishes <rdar://problem/11193097>.

llvm-svn: 154407
2012-04-10 17:08:25 +00:00
Fariborz Jahanian e84595d618 objective-c: add an assertion for property
expression enterring IsConstProperty function.

llvm-svn: 154406
2012-04-10 16:44:52 +00:00
John McCall dd1eca34b5 My original patch missed the virtual-base case for destroying
base-class subojects.

Incidentally, thinking about virtual bases makes it clear to me that
we're not appropriately computing the access to the virtual base's
member because we're not computing the best possible access to the
virtual base at all;  in fact, we're basically assuming it's public.
I'll file a separate PR about that.

llvm-svn: 154346
2012-04-09 21:51:56 +00:00
John McCall d42742143c Fix the access check performed as part of the determination of whether
to define a special member function as deleted so that it properly
establishes an object context for the accesses to the base subobject
members.

llvm-svn: 154343
2012-04-09 20:53:23 +00:00
David Blaikie 80cdddc504 Fix bugs found by -Wconstant-conversion improvements currently under review.
Specifically, using a an integer outside [0, 1] as a boolean constant seems to
be an easy mistake to make with things like "x == a || b" where the author
intended "x == a || x == b".

The bug caused by calling SkipUntil with three token kinds was also identified
by a VC diagnostic & reported by Francois Pichet as review feedback for my
commit r154163. I've included test cases to verify the error recovery that was
broken/poorly implemented due to this bug.

The other fix (lib/Sema/SemaExpr.cpp) seems like that code was never actually
reached in any of Clang's tests & is related to Objective C features I'm not
familiar with, so I've not been able to construct a test case for it. Perhaps
someone else can.

llvm-svn: 154325
2012-04-09 16:37:11 +00:00
John McCall 5dadb65e07 Fix several problems with protected access control:
- The [class.protected] restriction is non-trivial for any instance
    member, even if the access lacks an object (for example, if it's
    a pointer-to-member constant).  In this case, it is equivalent to
    requiring the naming class to equal the context class.
  - The [class.protected] restriction applies to accesses to constructors
    and destructors.  A protected constructor or destructor can only be
    used to create or destroy a base subobject, as a direct result.
  - Several places were dropping or misapplying object information.

The standard could really be much clearer about what the object type is
supposed to be in some of these accesses.  Usually it's easy enough to
find a reasonable answer, but still, the standard makes a very confident
statement about accesses to instance members only being possible in
either pointer-to-member literals or member access expressions, which
just completely ignores concepts like constructor and destructor
calls, using declarations, unevaluated field references, etc.

llvm-svn: 154248
2012-04-07 03:04:20 +00:00
Douglas Gregor 31f55dced5 Implement support for null non-type template arguments for non-type
template parameters of pointer, pointer-to-member, or nullptr_t
type in C++11. Fixes PR9700 / <rdar://problem/11193097>.

llvm-svn: 154219
2012-04-06 22:40:38 +00:00
DeLesley Hutchins 481d5abf45 Thread safety analysis: downgraded requirement that mutex expressions refer to a lockable type from error to warning.
llvm-svn: 154198
2012-04-06 20:02:30 +00:00
John McCall ed7b27830d Fix a Sema invariant bug that I recently introduced involving
the template instantiation of statement-expressions.

I think it was jyasskin who had a crashing testcase in this area;
hopefully this fixes it and he can find his testcase and check it in.

llvm-svn: 154189
2012-04-06 18:20:53 +00:00
Patrick Beard acfbe9e1f2 Added a new attribute, objc_root_class, which informs the compiler when a root class is intentionally declared.
The warning this inhibits, -Wobjc-root-class, is opt-in for now. However, all clang unit tests that would trigger
the warning have been updated to use -Wno-objc-root-class. <rdar://problem/7446698>

llvm-svn: 154187
2012-04-06 18:12:22 +00:00
DeLesley Hutchins 6f86004cbc Fixed scoping error for late parsed attributes in nested classes.
llvm-svn: 154173
2012-04-06 15:10:17 +00:00
Richard Smith a974688d35 Point the caret at the error for the 'expected namespace name' diagnostic in
a namespace alias declaration.

llvm-svn: 154138
2012-04-05 23:13:23 +00:00
Eli Friedman c1f0d5b873 Implement C90 pedantic warning for duplicate declaration specifiers which are duplicated via a typedef. Patch by Tim Northover.
llvm-svn: 154136
2012-04-05 22:47:34 +00:00
Eli Friedman 57a75390fc Properly implement the C rules for composite types for qualified pointers in conditionals. Patch by Tim Northover.
llvm-svn: 154134
2012-04-05 22:30:04 +00:00
Fariborz Jahanian c806b90717 objective-c: Don't warn when a category does not implement a method
declared in its adopted protocol when another category declares it  
because that category will implement it. // rdar://11186449

llvm-svn: 154132
2012-04-05 22:14:12 +00:00
Richard Smith fa0a1f531f Improve diagnostics for invalid use of non-static members / this:
* s/nonstatic/non-static/ in the diagnostics, since the latter form outvoted
  the former by 28-2 in our diagnostics.
* Fix the "use of member in static member function" diagnostic to correctly
  detect this situation inside a block or lambda.
* Produce a more specific "invalid use of non-static member" diagnostic for
  the case where a nested class member refers to a member of a
  lexically-surrounding class.

llvm-svn: 154073
2012-04-05 01:13:04 +00:00
Douglas Gregor 0f5c1c0127 Allow a conversion from the empty initializer list {} to an
std::initializer_list<T> so long as <T> is known. This conversion has
identity rank.

llvm-svn: 154065
2012-04-04 23:09:20 +00:00
Richard Smith 9380e0ea23 Implement C++11 [temp.arg.nontype]'s permission to use the address of an object
or function with internal linkage as a non-type template argument.

llvm-svn: 154053
2012-04-04 21:11:30 +00:00
Fariborz Jahanian 6bd2226037 objc-arc: provide a warning when 'receiver' of a message is 'weak'
in arc mode and opted-in with -Wreceiver-is-weak flag.
// rdar://10225276

llvm-svn: 154042
2012-04-04 20:05:25 +00:00
Douglas Gregor b61e809b42 Move the computation of the lambda mangling information (mangling
number + context) to the point where we initially start defining the
lambda, so that the linkage won't change when that information is made
available. Fixes the assertion in <rdar://problem/11182962>.

Plus, actually mangle the context of lambdas properly.

llvm-svn: 154029
2012-04-04 17:40:10 +00:00
Richard Smith f016bbcc61 For PR11916: Add support for g++'s __int128 keyword. Unlike __int128_t, this is
a type specifier and can be combined with unsigned. This allows libstdc++4.7 to
be used with clang in c++98 mode.

Several other changes are still required for libstdc++4.7 to work with clang in
c++11 mode.

llvm-svn: 153999
2012-04-04 06:24:32 +00:00
Douglas Gregor 0e60cd78cc When performing template argument deduction for an initializer list,
be sure to perform the argument type adjustments in
[temp.deduct.call]p2, e.g., array decay.

And, when performing these deductions in the context of 'auto', make
sure that we're deducing the P' in std::initializer_list<P'> rather
than the whole initializer list.

Together, this makes code like

  for( auto s : {"Deferred", "New", "Open", "Review"}) { }

work properly.

llvm-svn: 153998
2012-04-04 05:10:53 +00:00
Douglas Gregor bf13895a4b Dependent-sequence initialization of a single element can be direct
list-initialization. Loosen an over-eager assertion to fix PR12453.

llvm-svn: 153995
2012-04-04 04:06:51 +00:00
John McCall b73bc9af60 When computing the conversion sequence in overload resolution
for converting an empty list to a scalar, be sure to initialize
the source and destination types so that comparison of conversion
sequences will work in case there are multiple viable candidates.

llvm-svn: 153993
2012-04-04 02:40:27 +00:00
Nick Lewycky a995a47e38 If something already instantiated is reinstantiated as an explicit definition,
keep the latter.

No test. This was noticed when poking around something else with GDB. I'm not
able to figure out a testcase that would break due to this bug. Sorry.

llvm-svn: 153992
2012-04-04 02:38:36 +00:00
John McCall 3abee49d1c Enter an expression evaluation context when parsing
statement-expressions.  Prevents cleanups and such from being
claimed by the first full-expression in the block.

llvm-svn: 153989
2012-04-04 01:27:53 +00:00