]> granicus.if.org Git - clang/commit
Driver,CodeGen: introduce support for Swift CFString layout
authorSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 24 Oct 2018 23:28:28 +0000 (23:28 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 24 Oct 2018 23:28:28 +0000 (23:28 +0000)
commit925e04d232a6c9abaa949f19689b9b443e6beeba
tree90f9ee7e42217aa02f82a3b1324a81d183dfff27
parent22fe7cf15e0aafad091c7bbc1cdcf3dc5fb3a1ea
Driver,CodeGen: introduce support for Swift CFString layout

Add a new driver level flag `-fcf-runtime-abi=` that allows one to specify the
runtime ABI for CoreFoundation.  This controls the language interoperability.
In particular, this is relevant for generating the CFConstantString classes
(primarily through the `__builtin___CFStringMakeConstantString` builtin) which
construct a reference to the "CFObject"'s `isa` field.  This type differs
between swift 4.1 and 4.2+.

Valid values for the new option include:
  - objc [default behaviour] - enable ObjectiveC interoperability
  - swift-4.1 - enable interoperability with swift 4.1
  - swift-4.2 - enable interoperability with swift 4.2
  - swift-5.0 - enable interoperability with swift 5.0
  - swift [alias] - target the latest swift ABI

Furthermore, swift 4.2+ changed the layout for the CFString when building
CoreFoundation *without* ObjectiveC interoperability.  In such a case, a field
was added to the CFObject base type changing it from: <{ const int*, int }> to
<{ uintptr_t, uintptr_t, uint64_t }>.

In swift 5.0, the CFString type will be further adjusted to change the length
from a uint32_t on everything but BE LP64 targets to uint64_t.

Note that the default behaviour for clang remains unchanged and the new layout
must be explicitly opted into via `-fcf-runtime-abi=swift*`.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345222 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/DiagnosticDriverKinds.td
include/clang/Basic/LangOptions.h
include/clang/Driver/Options.td
lib/AST/ASTContext.cpp
lib/CodeGen/CodeGenModule.cpp
lib/Driver/ToolChains/Clang.cpp
lib/Frontend/CompilerInvocation.cpp
test/CodeGen/cf-runtime-abi.c [new file with mode: 0644]
test/Driver/cf-runtime-abi.c [new file with mode: 0644]