swift
3a555bd2 - Fix effective context construction for NS_OPTIONS in linkage spec

Commit
2 years ago
Fix effective context construction for NS_OPTIONS in linkage spec When the ClangImporter imports a name, it associates it with a an EffectiveClangContext. An EffectiveClangContext can be thought of as the Clang scope the declaration will reside in, as far as importing into Swift is concerned. This helps API notes and NS_SWIFT_NAME to manipulate the SDK interface presented to Swift users. When a entry is added to the Swift lookup table, it is associated with a context. This context is a type and a name, used to effectively namespace entries in the table. This context is derived from the EffectiveClangContext associated with the name. This translation is handled by SwiftLookupTable::translateContextDecl among other machinery. This method in particular, understands only how to translate a set of Clang nodes, and fails to create a context in other cases. Prior to this patch, the EffectiveClangContext of declarations annotated with UIKIT_EXTERN, with cxx-interop turned on, was a LinkageSpecDecl. This results in context translation failure, and warnings produced in SwiftLookupTable::finalizeLookupTable. This patch corrects name import behavior to skip over the LinkageSpecDecl, and use the enclosing TranslationUnit instead. This is appropriate and performed by `determineEffectiveContext` as a LinkageSpecDecl is a so called "transparent" context. That is its members are semantically declared and accessible outside the context without additional qualification. This patch tests using API notes, as that is the method UIKit uses. The issue could just as easily be surface with a NS_SWIFT_NAME annotation. Even without any annotation at all, the we would still fail to translate, though there would likely be no corresponding warnings.
Author
Committer
Parents
Loading