[SR-1971] Importing error convention for specific non-zero constant
| Previous ID | SR-1971 |
| Radar | None |
| Original Reporter | @jadengeller |
| Type | Improvement |
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Improvement, ClangImporter |
| Assignee | None |
| Priority | Medium |
md5: 9f4d6f9166adf63d783d5ddbd2c6b5de
Issue Description:
Currently, the importer supports converting a variety of Objective-C error [conventions](https://github.com/apple/swift-clang/blob/stable/include/clang/Basic/AttrDocs.td#L1808) into throwing Swift functions, but it is missing the convention in which some constant value is returned to indicate failure. This is important for functions that return a integer value and zero is a valid result. Usually, such functions will declare a constant (e.g. `ABCInvalidInput`) that's equal to the maximum possible integer value and return that to indicate failure. Such API cannot be converted to throwing Swift functions though.
Introduction of a `swift_error(CONSTANT_VALUE)` attribute, whose argument is either an integer literal or a constant integer, would allow such functions to be annotated and imported into Swift.