mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[interop][SwiftToCxx] Annotate emitted declarations with Clang's external_source_symbol attribute
Each emitted declaration is annotated with the external_source_symbol with its own USR, to allow Clang's indexer to recognize this declaration as a Swift declaration with a specific USR
This commit is contained in:
@@ -905,6 +905,9 @@ ClangRepresentation DeclAndTypeClangFunctionPrinter::printFunctionSignature(
|
||||
os << " const";
|
||||
if (modifiers.isNoexcept)
|
||||
os << " noexcept";
|
||||
if (modifiers.hasSymbolUSR)
|
||||
ClangSyntaxPrinter(os).printSymbolUSRAttribute(
|
||||
modifiers.symbolUSROverride ? modifiers.symbolUSROverride : FD);
|
||||
return resultingRepresentation;
|
||||
}
|
||||
|
||||
@@ -1311,6 +1314,7 @@ void DeclAndTypeClangFunctionPrinter::printCxxMethod(
|
||||
isa<FuncDecl>(FD) ? cast<FuncDecl>(FD)->isMutating() : false;
|
||||
modifiers.isConst =
|
||||
!isa<ClassDecl>(typeDeclContext) && !isMutating && !isConstructor;
|
||||
modifiers.hasSymbolUSR = !isDefinition;
|
||||
auto result = printFunctionSignature(
|
||||
FD, signature,
|
||||
isConstructor ? getConstructorName(FD)
|
||||
@@ -1375,6 +1379,8 @@ void DeclAndTypeClangFunctionPrinter::printCxxPropertyAccessorMethod(
|
||||
modifiers.isInline = true;
|
||||
modifiers.isConst =
|
||||
!isStatic && accessor->isGetter() && !isa<ClassDecl>(typeDeclContext);
|
||||
modifiers.hasSymbolUSR = !isDefinition;
|
||||
modifiers.symbolUSROverride = accessor->getStorage();
|
||||
auto result = printFunctionSignature(
|
||||
accessor, signature, remapPropertyName(accessor, resultTy), resultTy,
|
||||
FunctionSignatureKind::CxxInlineThunk, modifiers);
|
||||
|
||||
Reference in New Issue
Block a user