Commit Graph

812 Commits

Author SHA1 Message Date
Benjamin Kramer 259294aa92 Use arrays or initializer lists to feed ArrayRefs instead of SmallVector where possible.
No functionality change intended

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274432 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-02 11:41:41 +00:00
David Majnemer ba5c7ce848 Use more ArrayRefs
No functional change is intended, just a small refactoring.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273647 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 04:05:48 +00:00
Saleem Abdulrasool 2f7ebc1937 CodeGen: convert some const char * to StringRef
Convert some use of const char * to StringRef.  NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@269630 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-16 05:06:49 +00:00
Manman Ren 1a520f8d32 ObjC Class Property: don't emit class properties on old deployment targets.
For old deployment targets, emit nil for all class property lists.

rdar://25616128


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@266800 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-19 19:05:03 +00:00
Saleem Abdulrasool fdc51a5580 revert SVN r265702, r265640
Revert the two changes to thread CodeGenOptions into the TargetInfo allocation
and to fix the layering violation by moving CodeGenOptions into Basic.
Code Generation is arguably not particularly "basic".  This addresses Richard's
post-commit review comments.  This change purely does the mechanical revert and
will be followed up with an alternate approach to thread the desired information
into TargetInfo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265806 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 16:52:00 +00:00
Saleem Abdulrasool 8cca4d7cdf Basic: move CodeGenOptions from Frontend
This is a mechanical move of CodeGenOptions from libFrontend to libBasic.  This
fixes the layering violation introduced earlier by threading CodeGenOptions into
TargetInfo.  It should also fix the modules based self-hosting builds.  NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265702 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 17:49:44 +00:00
Douglas Gregor cf7bc8edf8 [Objective-C] Introduce objc_runtime_visible attribute.
The objc_runtime_visible attribute deals with an odd corner case where
a particular Objective-C class is known to the Objective-C runtime
(and, therefore, accessible by name) but its symbol has been hidden
for some reason. For such classes, teach CodeGen to use
objc_lookUpClass to retrieve the Class object, rather than referencing
the class symbol directly.

Classes annotated with objc_runtime_visible have two major limitations
that fall out from places where Objective-C metadata needs to refer to
the class (or metaclass) symbol directly:

* One cannot implement a subclass of an objc_runtime_visible class.
* One cannot implement a category on an objc_runtime_visible class.

Implements rdar://problem/25494092.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265201 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 23:23:52 +00:00
John McCall 5af0763ee0 Preserve ExtParameterInfos into CGFunctionInfo.
As part of this, make the function-arrangement interfaces
a little simpler and more semantic.

NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263191 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-11 04:30:31 +00:00
Manman Ren 2124f0a0d1 Objective-C: Add a size field to non-fragile category metadata.
This is mainly for extensibility. Note that fragile category metadata,
metadata for classes and protocols all have a size field.

Initial patch was provided by Greg Parker.

rdar://problem/24804226


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261756 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-24 17:49:50 +00:00
Manman Ren c0dfefdf0b Class Property: Fix a crash with old ABI when generating metadata in classes.
rdar://23891898


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261466 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-21 05:31:05 +00:00
Benjamin Kramer c143b1047e Reduce the number of implicit StringRef->std::string conversions by threading StringRef through more APIs.
No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260815 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-13 13:42:54 +00:00
Akira Hatanaka 2f720ab5ab [Objective-c] Stop attaching section "datacoal_nt" to global variables.
The current macho linker just copies symbols in section datacoal_nt to
section data, so it doesn't really matter whether or not section
"datacoal_nt" is attached to the global variable.

This is a follow-up to r250370, which made changes in llvm to stop
putting functions and data in the *coal* sections.

rdar://problem/24528611


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260496 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-11 06:36:35 +00:00
Eugene Zelenko b9b46f780d Fix some Clang-tidy readability-redundant-control-flow warnings; other minor fixes.
Differential revision: http://reviews.llvm.org/D17060


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260414 91177308-0d34-0410-b5e6-96231b3b80d8
2016-02-10 19:11:58 +00:00
Manman Ren d2986bb509 Class Property: generate metadata for class properties in protocols.
The list of class properties is saved in
Old ABI: protocol->ext->class_properties (protocol->ext->size will be updated)
New ABI: protocol->class_properties (protocol->size will be updated)

rdar://23891898


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259268 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-29 23:46:55 +00:00
Manman Ren 62758602d0 Class Property: generate metadata for class properties in categories.
The list of class properties is saved in
Old ABI: category->class_properties (category->size will be updated as well)
New ABI: category->class_properties (a flag in objc_image_info to indicate
         whether or not the list of class properties is present)

rdar://23891898


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259267 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-29 23:45:01 +00:00
Manman Ren e74c270bbc Class Property: generate metadata for class properties in classes.
The list of class properties is saved in
Old ABI: cls->isa->ext->properties
New ABI: cls->isa->ro->properties

rdar://23891898


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259229 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-29 19:22:54 +00:00
Eric Christopher eae9579a01 Use a consistent spelling for vtables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259137 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-29 01:35:53 +00:00
Manman Ren 00fef86c90 Use instance_properties instead of properties. NFC.
All current properties are instance properties.

This is the second patch in a series of patches to support class properties
in addition to instance properties in objective-c.

rdar://23891898


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258824 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26 18:05:23 +00:00
Manman Ren d8c3cb2784 Update comments to match the implementation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258735 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-25 22:37:47 +00:00
Rui Ueyama 9e83128d12 Update for LLVM function name change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257802 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-14 21:00:27 +00:00
Craig Topper c7be35d9e5 Use std::is_sorted instead of a manual loop. NFC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256717 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-03 19:43:20 +00:00
Vedant Kumar 0fa436f618 Reapply "[CodeGen] Fix assignments of inline layouts into the byref structure"
When using blocks, a byref structure is created to represent the
closure. The "byref.layout" field of this structure is an i8*. However,
some 'inline' layouts are represented as i64's, not i8*'s.

Prior to r246985 we cast the i64 'inline' layout to an i8* before
assigning it into the byref structure. This patch brings the cast back
and adds a regression test.

The original version of this patch was too invasive. This version only adds the
cast to BuildByrefLayout.

Differential Revision: http://reviews.llvm.org/D15674

rdar://23713871

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256190 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-21 20:21:15 +00:00
Vedant Kumar 3255684968 Revert "[CodeGen] Fix assignments of inline layouts into the byref structure"
This reverts commit r256185. It breaks CodeGenObjC/fragile-arc.m.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256186 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-21 19:43:25 +00:00
Vedant Kumar f6a69116df [CodeGen] Fix assignments of inline layouts into the byref structure
When using blocks, a byref structure is created to represent the
closure. The "byref.layout" field of this structure is an i8*. However,
some 'inline' layouts are represented as i64's, not i8*'s.

Prior to r246985 we cast the i64 'inline' layout to an i8* before
assigning it into the byref structure. This patch brings the cast back
and adds a regression test.

rdar://23713871

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256185 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-21 19:30:37 +00:00
Nico Weber 795ba448be Fix Objective-C metadata for properties from class extensions after r251874
After, properties from class extensions no longer show up in
ObjCInterfaceDecl::properties().  Make ObjCCommonMac::EmitPropertyList()
explicitly look for properties in class extensions before looking at
direct properties.

Also add a test that passes both with clang before r251874 and after this
patch (but fails with r251874 and without this patch).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254622 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-03 17:44:51 +00:00
Samuel Antao 0cb5f3abb0 Preserve exceptions information during calls code generation.
This patch changes the generation of CGFunctionInfo to contain 
the FunctionProtoType if it is available. This enables the code 
generation for call instructions to look into this type for 
exception information and therefore generate better quality 
IR - it will not create invoke instructions for functions that 
are know not to throw.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253926 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-23 22:04:44 +00:00
John McCall a0ee4770fa Fix the emission of ARC-style ivar layouts in the fragile runtime
to start at the offset of the first ivar instead of the rounded-up
end of the superclass.  The latter could include a large amount of
tail padding because of a highly-aligned ivar, and subclass ivars
can be laid out within that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253533 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-19 02:27:55 +00:00
Rafael Espindola 34886cc46e Update for llvm change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253440 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-18 06:54:13 +00:00
Tim Northover 9605ec4bd7 Watch and TV OS: wire up basic ABI choices
This sets the mostly expected Darwin default ABI options for these two
platforms. Active changes from these defaults for watchOS are in a later patch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251708 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-30 16:30:36 +00:00
John McCall c44656ede6 Initialize @catch variables correctly in fragile-runtime ARC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251677 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-30 00:56:02 +00:00
John McCall 9c87880c94 Fix the emission of ARC ivar layouts in the non-fragile Mac runtime.
My previous change in this area accidentally broke the rule when
InstanceBegin was not a multiple of the word size.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251666 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-29 23:36:14 +00:00
John McCall abdd82457f Define weak and __weak to mean ARC-style weak references, even in MRC.
Previously, __weak was silently accepted and ignored in MRC mode.
That makes this a potentially source-breaking change that we have to
roll out cautiously.  Accordingly, for the time being, actual support
for __weak references in MRC is experimental, and the compiler will
reject attempts to actually form such references.  The intent is to
eventually enable the feature by default in all non-GC modes.
(It is, of course, incompatible with ObjC GC's interpretation of
__weak.)

If you like, you can enable this feature with
  -Xclang -fobjc-weak
but like any -Xclang option, this option may be removed at any point,
e.g. if/when it is eventually enabled by default.

This patch also enables the use of the ARC __unsafe_unretained qualifier
in MRC.  Unlike __weak, this is being enabled immediately.  Since
variables are essentially __unsafe_unretained by default in MRC,
the only practical uses are (1) communication and (2) changing the
default behavior of by-value block capture.

As an implementation matter, this means that the ObjC ownership
qualifiers may appear in any ObjC language mode, and so this patch
removes a number of checks for getLangOpts().ObjCAutoRefCount
that were guarding the processing of these qualifiers.  I don't
expect this to be a significant drain on performance; it may even
be faster to just check for these qualifiers directly on a type
(since it's probably in a register anyway) than to do N dependent
loads to grab the LangOptions.

rdar://9674298

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251041 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-22 18:38:17 +00:00
John McCall 553da6132e Enable ARC on the fragile runtime.
This is almost entirely a matter of just flipping a switch.  99% of
the runtime support is available all the way back to when it was
implemented in the non-fragile runtime, i.e. in Lion.  However,
fragile runtimes do not recognize ARC-style ivar layout strings,
which means that accessing __strong or __weak ivars reflectively
(e.g. via object_setIvar) will end up accessing the ivar as if it
were __unsafe_unretained.  Therefore, when using reflective
technologies like KVC, be sure that your paths always refer to a
property.

rdar://23209307

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250955 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-21 22:06:03 +00:00
John McCall 2dc2d5088d Fix and stylize the emission of GC/ARC ivar and GC block layout strings.
Specifically, handle under-aligned object references (by explicitly
ignoring them, because this just isn't representable in the format;
yes, this means that GC silently ignores such references), descend
into anonymous structs and unions, stop classifying fields of
pointer-to-strong/weak type as strong/weak in ARC mode, and emit
skips to cover the entirety of block layouts in GC mode.  As a
cleanup, extract this code into a helper class, avoid a number of
unnecessary copies and layout queries, generate skips implicitly
instead of explicitly tracking them, and clarify the bitmap-creation
logic.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250919 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-21 18:06:47 +00:00
Benjamin Kramer aa1247dbae [CodeGen] Remove dead code. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@250418 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-15 15:29:40 +00:00
Hans Wennborg 94faed6137 Fix Clang-tidy modernize-use-nullptr warnings in source directories; other minor cleanups
Patch by Eugene Zelenko!

Differential Revision: http://reviews.llvm.org/D13406

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249484 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-06 23:40:43 +00:00
Ahmed Bougacha 531d82b2e9 Don't nil check non-nil class receiver of AArch64 stret calls.
I randomly came across this difference between AArch64 and other targets:
on the latter, we don't emit nil checks for known non-nil class method
calls thanks to r247350, but we still do for AArch64 stret calls.

They use different code paths, because those are special, as they go
through the regular msgSend, not the msgSend*_stret variants.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249205 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-02 22:41:59 +00:00
John McCall 6d73f26899 Support noreturn in limited contexts on Objective-C message sends.
rdar://6198039

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247350 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-10 22:27:50 +00:00
John McCall f4ddf94ecb Compute and preserve alignment more faithfully in IR-generation.
Introduce an Address type to bundle a pointer value with an
alignment.  Introduce APIs on CGBuilderTy to work with Address
values.  Change core APIs on CGF/CGM to traffic in Address where
appropriate.  Require alignments to be non-zero.  Update a ton
of code to compute and propagate alignment information.

As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment
helper function to CGF and made use of it in a number of places in
the expression emitter.

The end result is that we should now be significantly more correct
when performing operations on objects that are locally known to
be under-aligned.  Since alignment is not reliably tracked in the
type system, there are inherent limits to this, but at least we
are no longer confused by standard operations like derived-to-base
conversions and array-to-pointer decay.  I've also fixed a large
number of bugs where we were applying the complete-object alignment
to a pointer instead of the non-virtual alignment, although most of
these were hidden by the very conservative approach we took with
member alignment.

Also, because IRGen now reliably asserts on zero alignments, we
should no longer be subject to an absurd but frustrating recurring
bug where an incomplete type would report a zero alignment and then
we'd naively do a alignmentAtOffset on it and emit code using an
alignment equal to the largest power-of-two factor of the offset.

We should also now be emitting much more aggressive alignment
attributes in the presence of over-alignment.  In particular,
field access now uses alignmentAtOffset instead of min.

Several times in this patch, I had to change the existing
code-generation pattern in order to more effectively use
the Address APIs.  For the most part, this seems to be a strict
improvement, like doing pointer arithmetic with GEPs instead of
ptrtoint.  That said, I've tried very hard to not change semantics,
but it is likely that I've failed in a few places, for which I
apologize.

ABIArgInfo now always carries the assumed alignment of indirect and
indirect byval arguments.  In order to cut down on what was already
a dauntingly large patch, I changed the code to never set align
attributes in the IR on non-byval indirect arguments.  That is,
we still generate code which assumes that indirect arguments have
the given alignment, but we don't express this information to the
backend except where it's semantically required (i.e. on byvals).
This is likely a minor regression for those targets that did provide
this information, but it'll be trivial to add it back in a later
patch.

I partially punted on applying this work to CGBuiltin.  Please
do not add more uses of the CreateDefaultAligned{Load,Store}
APIs; they will be going away eventually.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@246985 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-08 08:05:57 +00:00
David Blaikie 673861a3c6 Devirtualize EHScopeStack::Cleanup's dtor because it's never destroyed polymorphically
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245378 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-18 22:40:54 +00:00
Alexander Kornienko 8ca7705aa3 Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240353 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-22 23:07:51 +00:00
Alexander Kornienko ac58acc7f2 Fixed/added namespace ending comments using clang-tidy. NFC
The patch is generated using this command:

  $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \
      -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \
      work/llvm/tools/clang

To reduce churn, not touching namespaces spanning less than 10 lines.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240270 91177308-0d34-0410-b5e6-96231b3b80d8
2015-06-22 09:47:44 +00:00
Benjamin Kramer 33fe0182f3 Remove empty non-virtual destructors or mark them =default when non-public
These add no value but can make a class non-trivially copyable. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234689 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-11 15:58:30 +00:00
David Blaikie 4395699364 [opaque pointer type] More GEP API migrations
Looks like the VTable code in particular will need some work to pass
around the pointee type explicitly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234128 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-05 22:45:47 +00:00
David Blaikie 648f772a34 [opaque pointer type] Explicitly specify type to CreateGEP
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234032 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-03 17:47:16 +00:00
David Blaikie 3e02a7c92a [opaque pointer type] Update for GEP API changes in LLVM
Now the GEP constant utility functions require the type to be explicitly
passed (since eventually the pointer type will be opaque and not convey
the required type information). For now callers can still pass nullptr
(though none were needed here in Clang, which is nice) if
convenienc/necessary, but eventually that will be disallowed as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233937 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-02 18:55:21 +00:00
Fariborz Jahanian b967c01390 [Objective-C metadata patch]. Patch to allocate one more space for
Protocol objects in OBJC2. rdar://20286356


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233766 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-31 22:22:40 +00:00
Nico Weber 45bdc5d280 Wrap to 80 columns. No behavior change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230682 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-26 20:43:00 +00:00
Peter Collingbourne b58ba0b375 Implement the __builtin_call_with_static_chain GNU extension.
The extension has the following syntax:

  __builtin_call_with_static_chain(Call, Chain)
  where Call must be a function call expression and Chain must be of pointer type

This extension performs a function call Call with a static chain pointer
Chain passed to the callee in a designated register. This is useful for
calling foreign language functions whose ABI uses static chain pointers
(e.g. to implement closures).

Differential Revision: http://reviews.llvm.org/D6332

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224167 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-12 23:41:25 +00:00
Duncan P. N. Exon Smith c7376725b9 IR: Update clang for Metadata/Value split in r223802
Match LLVM API changes from r223802.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223803 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-09 18:39:32 +00:00
Reid Kleckner 491c76a771 Use nullptr to silence -Wsentinel when self-hosting on Windows
Richard rejected my Sema change to interpret an integer literal zero in
a varargs context as a null pointer, so -Wsentinel sees an integer
literal zero and fires off a warning. Only CodeGen currently knows that
it promotes integer literal zeroes in this context to pointer size on
Windows.  I didn't want to teach -Wsentinel about that compatibility
hack. Therefore, I'm migrating to C++11 nullptr.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223079 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-01 22:02:27 +00:00
David Blaikie f8fdd74444 Update for LLVM API change to make Small(Ptr)Set::insert return pair<iterator, bool> as per the C++ standard's associative container concept.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222335 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19 07:49:47 +00:00
Rafael Espindola 136e63d95b Don't manually insert L prefixes.
Simply marking the symbol private conveys the desire to hide them to LLVM.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221451 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-06 13:30:38 +00:00
Rafael Espindola 6588d9f885 Allow protocols to be just declared.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@217704 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-12 20:14:20 +00:00
Fariborz Jahanian 327ee9cfdf Objective-C IRGen. Fixes an assertion crash caused by inconsistent
linkage related to generation of OBJC_SELECTOR_REFERENCES symbol 
needed in generation of call to 'super' in a class method.
// rdar://18150301


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216676 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-28 17:05:17 +00:00
Craig Topper bbac840f3c Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or just letting them be implicitly created.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216528 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-27 06:28:36 +00:00
Tim Northover eb8c2c992e AArch64: update Clang for merged arm64/aarch64 triples.
The main subtlety here is that the Darwin tools still need to be given "-arch
arm64" rather than "-arch aarch64". Fortunately this already goes via a custom
function to handle weird edge-cases in other architectures, and it tested.

I removed a few arm64_be tests because that really isn't an interesting thing
to worry about. No-one using big-endian is also referring to the target as
arm64 (at least as far as toolchains go). Mostly they date from when arm64 was
a separate target and we *did* need a parallel name simply to test it at all.
Now aarch64_be is sufficient.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213744 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-23 12:32:58 +00:00
Fariborz Jahanian 29eea29d75 Objective-C. Introducing __attribute__((objc_runtime_name("runtimename"))
to be applied to class or protocols. This will direct IRGen
for Objective-C metadata to use the new name in various places
where class and protocol names are needed.
rdar:// 17631257


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213167 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-16 16:16:04 +00:00
Fariborz Jahanian 5f5ba3607b Objective-C IRGen. Fixes an inconsistant linkage of
ObC's metaclass metadata with its class metadata which
results in an assert. rdar://17633301



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213076 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-15 17:14:34 +00:00
Ben Langmuir 35bd5e0e85 Don't assume StringRef.data() is null-terminated
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212790 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-11 00:43:47 +00:00
Fariborz Jahanian 74532f2824 Objective-C IRGen. Patch to generate a weak symbol reference when
'super' dispatches a class method in category for OBJC_METACLASS.
This is when class is a weak_import class.
// rdar://16529125


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210547 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-10 17:08:04 +00:00
Alp Toker 6719dde6f3 Avoid dubious IdentifierInfo::getNameStart() uses
These cases in particular were incurring an extra strlen() when we already knew
the length. They appear to be leftovers from when the interfaces worked with C
strings that have continued to compile due to the implicit StringRef ctor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210403 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-07 23:30:53 +00:00
Tim Northover 8d681a2f93 AArch64/ARM64: rename ARM64 components to AArch64
This keeps Clang consistent with backend naming conventions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209579 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-24 12:52:07 +00:00
Craig Topper d1008e5c93 [C++11] Use 'nullptr'. CodeGen edition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209272 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-21 05:09:00 +00:00
Rafael Espindola ed2fa8cac4 Simplify the code a bit by using linkage predicates.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208382 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-09 00:43:37 +00:00
Tim Northover 4eff9acb0b ARM64: parametrise IVar offset type (long on ARM64, int elsewhere).
This is part of the ARM64 patch, but can only be tested properly when
the full codegen gets committed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205098 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-29 13:42:40 +00:00
Tim Northover 0ed153b0b4 ObjC: allow targets to decide when to use stret for blocks.
This was originally part of the ARM64 patch, but seems semantically
separate.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205097 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-29 13:28:05 +00:00
Rafael Espindola c78b67d6c5 Don't produce a L symbol in __DATA,__data.
The section __DATA,__data is atomized by the linker and cannot have L symbols.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204879 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-27 00:02:45 +00:00
Aaron Ballman 6440fd7553 [C++11] Replacing BlockDecl iterators capture_begin() and capture_end() with iterator_range captures(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203958 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-14 18:34:04 +00:00
Aaron Ballman 90f0e7122a [C++11] Replacing ObjCCategoryDecl iterators propimpl_begin() and propimpl_end() with iterator_range property_impls(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203930 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-14 15:02:45 +00:00
Aaron Ballman 58e3220f76 [C++11] Replacing ObjCCategoryDecl iterators protocol_begin() and protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203922 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-14 12:55:57 +00:00
Aaron Ballman 09c79d9b98 [C++11] Replacing ObjCProtocolDecl iterators protocol_begin() and protocol_end() with iterator_range protocols(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203863 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 22:58:06 +00:00
Aaron Ballman a2a1fef4c9 [C++11] Replacing ObjCInterfaceDecl iterators all_referenced_protocol_begin() and all_referenced_protocol_end() with iterator_range all_referenced_protocols(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203848 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 20:55:22 +00:00
Aaron Ballman ccd9de1bca [C++11] Replacing ObjCContainerDecl iterators classmeth_begin() and classmeth_end() with iterator_range class_methods(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203840 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 20:11:06 +00:00
Aaron Ballman 7d141621d4 [C++11] Replacing ObjCContainerDecl iterators instmeth_begin() and instmeth_end() with iterator_range instance_methods(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203839 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 19:50:17 +00:00
Aaron Ballman f5244d23c9 Renaming the recently-created (r203830) props() range API to properties() for clarity.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203835 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 19:11:50 +00:00
Aaron Ballman fc41e95ace [C++11] Replacing ObjCContainerDecl iterators prop_begin() and prop_end() with iterator_range props(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203830 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-13 18:47:37 +00:00
Craig Topper f7bc497ad1 [C++11] Add 'override' keyword to virtual methods that override their base class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203643 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-12 06:41:41 +00:00
Fariborz Jahanian c9a92c2a8d Objective-C IRGen. Fixes several regressions caused by changes made
to setting of ObjC linkages. //rdar://16206443



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203521 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-11 00:25:05 +00:00
Aaron Ballman 1b93ddc95b Reverting llvm::distance changes to use std::distance with iterators instead, per post-commit review feedback.
Replacing llvm::copy changes with SmallVector range-based construction which is a considerably cleaner approach.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203461 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-10 13:43:55 +00:00
Aaron Ballman 8328f6462b [C++11] Replacing RecordDecl iterators field_begin() and field_end() with iterator_range fields(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203355 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-08 20:12:42 +00:00
Aaron Ballman ecb8277062 [C++11] Replacing ObjCMethodDecl iterators param_begin() and param_end() with iterator_range params(). Updating all of the usages of the iterators with range-based for loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203255 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-07 17:50:17 +00:00
Rafael Espindola bb46ff589d Use llvm.compiler.used instead of llvm.used for objc symbols.
LLVM currently has a hack (shouldEmitUsedDirectiveFor) that causes it to not
print no_dead_strip for symbols starting with 'l' or 'L'. These are exactly the
ones that the clang's objc codegen is producing. The net result, is that it is
equivalent to llvm.compiler.used.

The need for putting the private symbol in llvm.compiler.used should be clear
(the objc runtime uses them). The reason for also putting the weak symbols in
it is for LTO: ld64 will not ask us to preserve the it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203172 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-06 22:15:10 +00:00
Rafael Espindola 62bfc977c8 Revert "Use private linkage for remaining GlobalVariables with private names."
This reverts commit r203059.

Revert while we discuss what does it mean to be private and weak.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203141 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-06 18:54:12 +00:00
Rafael Espindola 70e2f181f5 Use private linkage for remaining GlobalVariables with private names.
This patch changes the remaining GlobalVariables using "\01L" and
"\01l" prefixes to use private linkage. What is strange about them is
that they currently use WeakAnyLinkage. There is no comment stating
why and that is really odd since the symbols are completely hidden, so
it doesn't make sense for them to be weak.

Clang revisions like r63329, r63408, r63770, r65761 set the linkage to
weak, but don't say why. I suspect they were just copying llvm-gcc.

In llvm-gcc I found r58599 and r56322 that set DECL_WEAK, but they
were just syncing from the apple gcc. I am not exactly sure what that
means, since the last commit to
svn://gcc.gnu.org/svn/gcc/branches/apple was in 2006, 2 years earlier.

In summary, I have no idea why weak linkage was being used :-(

To quote John McCall, "Let’s try without it and see" :-)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203059 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-06 01:57:34 +00:00
Rafael Espindola c3404fd9b0 Construct GlobalValues with the correct linkage instead of using setLinkage.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203052 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-06 01:10:46 +00:00
Fariborz Jahanian 5ee6d5a29d Objective-C. Return 0 as class of methods in protocols.
This simplifies my last patch a bit. No change in
functionality.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202906 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-04 22:57:32 +00:00
Fariborz Jahanian ddd9310bab Objective-C IRGen. Fix up the hueristics for determining
if an ivar offset load is invariant iff inside an instance method
and ivar belongs to instance method's class and one of its super class.
// rdar://16095748


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202872 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-04 18:34:52 +00:00
Chandler Carruth 235e24a90e [Modules] Update to reflect the move of CallSite into the IR library in
LLVM r202816.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202817 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-04 11:02:08 +00:00
Fariborz Jahanian 06c0167a16 Objective-C. Fixes a regression when figuring out linkage
for metadata symbols for forward referenced protocols which 
are never defined.  // rdar://16203115


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202761 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-03 21:53:57 +00:00
Craig Topper caa4c61ee5 Switch all uses of LLVM_OVERRIDE to just use 'override' directly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202625 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-02 09:32:10 +00:00
Rui Ueyama 1b06b07468 Fix -Wunused-function in Release build.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202429 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-27 20:50:04 +00:00
Rafael Espindola 8bb3054559 Use private linkage for globals we already name with \01L and \01l.
In llvm the only semantic difference between internal and private is that llvm
tries to hide private globals my mangling them with a private prefix. Since
the globals changed by this patch already had the magic don't mangle marker,
there should be no change in the generated assembly.

A followup patch should then be able to drop the \01L and \01l prefixes and let
llvm mangle as appropriate.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202419 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-27 19:01:11 +00:00
Rafael Espindola f1489d6854 Assert that the name of some internal variables start with \01L or \01l.
No functionality change. This is just an intermediate patch for changing those
global variables to use private linkage.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202409 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-27 16:26:32 +00:00
Nick Lewycky a1648076d7 Fix -Wunused-variable in non-assert builds. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202330 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-27 00:36:00 +00:00
Rafael Espindola 98cafc6464 Refactor linkage computation in CGObjCMac.cpp.
Before this patch the globals were created with the wrong linkage and patched
afterwards. From the comments it looks like something would complain about
having an internal GV with no initializer. At least in clang the verifier will
only run way after we set the initializer, so that is not a problem.

This patch should be a nop. It just figures out the linkage earlier and
converts the old calls to setLinkage to asserts. The only case where that is
not possible is when we first see a weak import that is then implemented. In
that case we have to change the linkage, but that is the only setLinkage left.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202305 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-26 22:25:45 +00:00
Fariborz Jahanian e2e8ed2c17 Objective-C. Remove an assertion which asserts
on correctly handled block layout IRGen. 
// rdar://16111839


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202063 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-24 19:10:37 +00:00
Rafael Espindola 880cad25dc Remove really old "APPLE LOCAL" markers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201791 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-20 14:09:04 +00:00
Reid Kleckner e6a9903e83 [ms-cxxabi] Use x86_cdeclmethodcc for __cdecl methods on win32
This fixes PR15768, where the sret parameter and the 'this' parameter
are in the wrong order.

Instance methods compiled by MSVC never return records in registers,
they always return indirectly through an sret pointer.  That sret
pointer always comes after the 'this' parameter, for both __cdecl and
__thiscall methods.

Unfortunately, the same is true for other calling conventions, so we'll
have to change the overall approach here relatively soon.

Reviewers: rsmith

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200587 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-31 22:54:50 +00:00
Alp Toker 37545f747c Rename getResultType() on function and method declarations to getReturnType()
A return type is the declared or deduced part of the function type specified in
the declaration.

A result type is the (potentially adjusted) type of the value of an expression
that calls the function.

Rule of thumb:

  * Declarations have return types and parameters.
  * Expressions have result types and arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200082 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-25 16:55:45 +00:00