Selector splitting: the first parameter name is always relevant.

Swift SVN r15923
This commit is contained in:
Doug Gregor
2014-04-04 04:14:34 +00:00
parent ba67a09362
commit 4bcc4daa3d
2 changed files with 25 additions and 0 deletions

View File

@@ -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.