Emit @objc classes using namespaced names under a new flag -enable-objc-mangling.

Centralize the logic for figuring out what name to use for a class or
protocol in the Objective-C runtime. When the flag is enabled (it's
still disabled by default), use mangled names for all Swift-defined
classes, including those that are @objc. Note that the naming is
determined in the AST, because we're also going to use this logic when
printing an Objective-C header for Clang's consumption. The mangled
names will always start with _Tt, so they're easy to recognize and
demangle in various tools or, eventually, in the Objective-C runtime.

The new test (test/IRGen/objc_mangling.sil) is the only test of this
behavior at the moment. The other test changes are due to the
centralized logic tweaking the names of internal constants (_DATA_*,
_CATEGORY_*, etc.).

This is the majority of <rdar://problem/15506580>.



Swift SVN r15588
This commit is contained in:
Doug Gregor
2014-03-28 23:00:08 +00:00
parent 095633f4ba
commit 9400e890d3
16 changed files with 196 additions and 46 deletions

View File

@@ -508,6 +508,12 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.EnableExperimentalPatterns = true;
}
if (const Arg *A = Args.getLastArg(OPT_enable_objc_mangling,
OPT_disable_objc_mangling)) {
Opts.MangleObjCClassProtocolNames
= A->getOption().matches(OPT_enable_objc_mangling);
}
if (Args.hasArg(OPT_debug_constraints)) {
Opts.DebugConstraintSolver = true;
}