Revision tags: llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4, llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7, llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, working, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init, llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4, llvmorg-14.0.3, llvmorg-14.0.2 |
|
#
c57f0341 |
| 18-Apr-2022 |
Alex Langford <apl@fb.com> |
[clang][Sema] Add flag to LookupName to force C/ObjC codepath
Motivation: The intent here is for use in Swift. When building a clang module for swift consumption, swift adds an extension block to th
[clang][Sema] Add flag to LookupName to force C/ObjC codepath
Motivation: The intent here is for use in Swift. When building a clang module for swift consumption, swift adds an extension block to the module for name lookup purposes. Swift calls this a SwiftLookupTable. One purpose that this serves is to handle conflicting names between ObjC classes and ObjC protocols. They exist in different namespaces in ObjC programs, but in Swift they would exist in the same namespace. Swift handles this by appending a suffix to a protocol name if it shares a name with a class. For example, if you have an ObjC class named "Foo" and a protocol with the same name, the protocol would be renamed to "FooProtocol" when imported into swift.
When constructing the previously mentioned SwiftLookupTable, we use Sema::LookupName to look up name conflicts for the previous problem. By this time, the Parser has long finished its job so the call to LookupName gets nullptr for its Scope (TUScope will be nullptr by this point). The C/ObjC path does not have this problem because it only uses the Scope in specific scenarios. The C++ codepath uses the Scope quite extensively and will fail early on if the Scope it gets is null. In our very specific case of looking up ObjC classes with a specific name, we want to force sema::LookupName to take the C/ObjC codepath even if C++ or ObjC++ is enabled.
show more ...
|