Commit Graph

15 Commits

Author SHA1 Message Date
Max Moiseev
3a3984877a Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-15 15:43:34 -08:00
Maxim Moiseev
0e0191380a OptionSetType => OptionSet 2015-12-10 14:58:24 -08:00
Chris Lattner
ea813c6e12 assign some dead results to _. NFC.
Swift SVN r31414
2015-08-22 22:27:36 +00:00
Jordan Rose
bfd30db4c2 [ClangImporter] Be more careful about stripping 'k' from enum constants.
This condition was wrong and could occasionally produce enum constant
names that started with digits.

rdar://problem/21820628

Swift SVN r30549
2015-07-23 20:50:49 +00:00
Jordan Rose
d9ddc21f49 [ClangImporter] Fix underscore handling from r29673 to handle plurals.
The improvements there caused regressions in other enums. Thanks for catching this
Denis (and Xi)!

Fix-up to rdar://problem/20800204

Swift SVN r29829
2015-07-01 01:01:28 +00:00
Jordan Rose
e900823862 [ClangImporter] Tweak enum import rules to remove more underscores.
If the common prefix of the enum /elements/ had an underscore in the /middle/,
we previously had cases where we'd end up leaving that underscore in place.

rdar://problem/20800204

Swift SVN r29673
2015-06-25 17:32:28 +00:00
Dave Abrahams
d65f696344 Kill off [_]RawOptionSetType
Now that we are using OptionSetType for option sets, all the support for
doing things the old way can die.

Note: the fix-it that used to apply to RawOptionSetType, it seemed to me,
should still apply to OptionSetType, so I switched it over instead of
removing it.

Swift SVN r29066
2015-05-27 15:55:54 +00:00
Jordan Rose
b92e0c944d [ClangImporter] Implement NS_SWIFT_NAME for enumerators.
NS_SWIFT_NAME on enum constants has two effects: on top of renaming the
member, it also removes it from the prefix-matching logic.

Part of rdar://problem/19240897

Swift SVN r28927
2015-05-22 20:15:09 +00:00
Joe Groff
32fb006386 Clang Importer: Enable OptionSetType import.
Update the tests to match.

Swift SVN r28906
2015-05-22 05:47:37 +00:00
Jordan Rose
46b52576d3 Recognize imported enum case aliases in TypeCheckPattern.cpp.
...so that they can still be used with exhaustive switches.

This is a hack---groveling through the AST to see if it's in the particular
form of an imported enum case alias---but at least it's limited to imported
properties.

More rdar://problem/18662118

Swift SVN r28326
2015-05-08 21:01:52 +00:00
Jordan Rose
86203cad7e [ClangImporter] Import enum case aliases using static let properties.
I don't want to call this complete until
a) we handle using alias names in switch statements (right now they're
   straight-up rejected, not just non-complete), and
b) we prefer non-deprecated names over deprecated ones to be the "real"
   enum cases.
but this is a good start, and fixes them showing up poorly in the SDK
analyzer.

rdar://problem/18662118

Swift SVN r27130
2015-04-08 19:23:38 +00:00
Jordan Rose
7a6d8ea940 Revert "[ClangImporter] Add convert-inits for enums defined in terms of other enums."
This reverts r25401. After reviewing the issues this was intended to solve,
and then talking to Dave, I've decided that this doesn't actually solve
enough of the problems we wanted it to, and it creates added complexity,
so I'm taking it back out.

Originally rdar://problem/19667625.

Swift SVN r25489
2015-02-23 22:52:41 +00:00
Jordan Rose
eb1c542900 [test] Remove hardcoded LLVM register name in test/ClangModules/enum.swift.
Swift SVN r25402
2015-02-19 21:52:49 +00:00
Jordan Rose
83639ca702 [ClangImporter] Add convert-inits for enums defined in terms of other enums.
This pattern isn't too uncommon:

typedef CF_ENUM(CFIndex, CFFoo) {
  CFFooBar
};
typedef NS_ENUM(NSInteger, NSFoo) {
  NSFooBar = CFFooBar
};

NSFoo and CFFoo are distinct types, but sometimes you need to convert from
one to the other. Today the only way to do to that is via rawValue, which
is especially unpleasant if the raw types don't match.

This commit introduces a new converting initializer for NSFoo:

  init!(_ value: CFFoo) {
    self.init(rawValue: RawType(value.rawValue))
  }

It's failable by necessity because init(rawValue:) is failable for proper
enums. In practice an audit of our public headers found zero cases where
there are "more" cases in CFFoo than in NSFoo, i.e. cases where the
conversion would fail.

This also applies to option sets and opaque enums, but those use a
non-failable initializer because there's no way to check validity.

rdar://problem/19667625

Swift SVN r25401
2015-02-19 21:11:43 +00:00
Jordan Rose
229ddc0fe1 [test] Collapse three enum tests into one.
The next commit will add tests that mix different kinds of enums and the
division doesn't make too much sense at that point.

No functionality change.

Swift SVN r25400
2015-02-19 21:11:42 +00:00