mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Selector splitting: the first parameter name is always relevant.
Swift SVN r15923
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "swift/Basic/Range.h"
|
||||
#include "swift/Basic/StringExtras.h"
|
||||
|
||||
#include "clang/Basic/CharInfo.h"
|
||||
#include "clang/AST/DeclObjC.h"
|
||||
@@ -2209,6 +2210,17 @@ StringRef FuncDecl::getObjCSelector(SmallVectorImpl<char> &buffer) const {
|
||||
return out.str();
|
||||
|
||||
// Otherwise, it's at least a unary selector.
|
||||
|
||||
// If the first tuple element has a name, uppercase and emit it.
|
||||
if (tuple && getASTContext().LangOpts.SplitPrepositions) {
|
||||
llvm::SmallString<16> scratch;
|
||||
if (auto named = dyn_cast<NamedPattern>(
|
||||
tuple->getFields()[0].getPattern()
|
||||
->getSemanticsProvidingPattern())) {
|
||||
out << camel_case::toSentencecase(named->getBoundName().str(), scratch);
|
||||
}
|
||||
}
|
||||
|
||||
out << ':';
|
||||
|
||||
// If it's a unary selector, we're done.
|
||||
|
||||
13
test/IRGen/objc_methods_split.swift
Normal file
13
test/IRGen/objc_methods_split.swift
Normal file
@@ -0,0 +1,13 @@
|
||||
// RUN: rm -rf %t/clang-module-cache
|
||||
// RUN: %swift -split-objc-selectors -target x86_64-apple-darwin10 %s -emit-ir | FileCheck %s
|
||||
|
||||
// CHECK: @"\01L_selector_data(bazInt:)" = internal constant [8 x i8] c"bazInt:\00", section "__TEXT,__objc_methname,cstring_literals", align 1
|
||||
// CHECK: @"\01L_selector_data(fooWithInt:)" = internal constant [12 x i8] c"fooWithInt:\00", section "__TEXT,__objc_methname,cstring_literals", align 1
|
||||
|
||||
class Foo {
|
||||
@objc func baz(int: Int) {}
|
||||
|
||||
@objc(fooWithInt:) func foo(int: Int) {}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user