-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Remove workarounds for CF_OPTIONS
default arguments
#79890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci please test |
@swift-ci please test Windows |
1 similar comment
@swift-ci please test Windows |
lib/ClangImporter/ImportEnumInfo.h
Outdated
@@ -163,6 +163,11 @@ StringRef getCommonPluralPrefix(StringRef singular, StringRef plural); | |||
/// Returns the underlying integer type of an enum. If clang treats the type as | |||
/// an elaborated type, an unwrapped type is returned. | |||
const clang::Type *getUnderlyingType(const clang::EnumDecl *decl); | |||
|
|||
inline bool isCFOptionsMacro(StringRef macroName) { | |||
return macroName == "CF_OPTIONS" || macroName == "NS_OPTIONS"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: could use LLVM's StringSwitch (https://llvm.org/doxygen/classllvm_1_1StringSwitch.html). But this is just two strings so maybe it does not make a difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks!
ClangImporter has logic that infers default arguments of certain C/C++ types, such as the types declared via `CF_OPTIONS`/`NS_OPTIONS` macros. There were some workarounds in place which triggered for C++ interop mode specifically. The workarounds were applying a heuristic based on the name of the type, which tried to match the behavior to non-C++ interop mode for certain types from the OS SDK. That was not working well for user-defined types, causing source compatibility breakages when enabling C++ interop. This change replaces the name-based heuristic with a more robust criteria. See also 3791ccb. rdar://142961112
249e3ee
to
5b7c595
Compare
@swift-ci please smoke test |
ClangImporter has logic that infers default arguments of certain C/C++ types, such as the types declared via
CF_OPTIONS
/NS_OPTIONS
macros.There were some workarounds in place which triggered for C++ interop mode specifically. The workarounds were applying a heuristic based on the name of the type, which tried to match the behavior to non-C++ interop mode for certain types from the OS SDK. That was not working well for user-defined types, causing source compatibility breakages when enabling C++ interop.
This change replaces the name-based heuristic with a more robust criteria.
See also 3791ccb.
rdar://142961112