Skip to content

Commit f536359

Browse files
committed
Swift AST: add var Decl.hasClangNode
1 parent e8fe5c3 commit f536359

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

SwiftCompilerSources/Sources/AST/Declarations.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public class Decl: CustomStringConvertible, Hashable {
2020

2121
public var description: String { String(taking: bridged.getDebugDescription()) }
2222

23+
// True if this declaration is imported from C/C++/ObjC.
24+
public var hasClangNode: Bool { bridged.hasClangNode() }
25+
2326
public static func ==(lhs: Decl, rhs: Decl) -> Bool { lhs === rhs }
2427

2528
public func hash(into hasher: inout Hasher) {

include/swift/AST/ASTBridging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ struct BridgedDeclObj {
333333
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef Type_getName() const;
334334
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef Value_getUserFacingName() const;
335335
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSourceLoc Value_getNameLoc() const;
336+
BRIDGED_INLINE bool hasClangNode() const;
336337
BRIDGED_INLINE bool Value_isObjC() const;
337338
BRIDGED_INLINE bool GenericType_isGenericAtAnyLevel() const;
338339
BRIDGED_INLINE bool NominalType_isGlobalActor() const;

include/swift/AST/ASTBridgingImpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ BridgedSourceLoc BridgedDeclObj::Value_getNameLoc() const {
158158
return BridgedSourceLoc(getAs<swift::ValueDecl>()->getNameLoc().getOpaquePointerValue());
159159
}
160160

161+
bool BridgedDeclObj::hasClangNode() const {
162+
return unbridged()->hasClangNode();
163+
}
164+
161165
bool BridgedDeclObj::Value_isObjC() const {
162166
return getAs<swift::ValueDecl>()->isObjC();
163167
}

0 commit comments

Comments
 (0)