Sema: Abstracted service for @cdecl style attributes

This commit is contained in:
Alexis Laferrière
2025-04-04 15:20:09 -07:00
parent 2647a8e150
commit 732918d5a5
2 changed files with 14 additions and 0 deletions

View File

@@ -8172,6 +8172,11 @@ public:
/// instance method. /// instance method.
bool isObjCInstanceMethod() const; bool isObjCInstanceMethod() const;
/// Get the foreign language targeted by a @cdecl-style attribute, if any.
/// Used to abstract away the change in meaning of @cdecl vs @_cdecl while
/// formalizing the attribute.
std::optional<ForeignLanguage> getCDeclKind() const;
/// Determine whether the name of an argument is an API name by default /// Determine whether the name of an argument is an API name by default
/// depending on the function context. /// depending on the function context.
bool argumentNameIsAPIByDefault() const; bool argumentNameIsAPIByDefault() const;

View File

@@ -10615,6 +10615,15 @@ bool AbstractFunctionDecl::isObjCInstanceMethod() const {
return isInstanceMember() || isa<ConstructorDecl>(this); return isInstanceMember() || isa<ConstructorDecl>(this);
} }
std::optional<ForeignLanguage> AbstractFunctionDecl::getCDeclKind() const {
auto attr = getAttrs().getAttribute<CDeclAttr>();
if (!attr)
return std::nullopt;
return attr->Underscored ? ForeignLanguage::ObjectiveC
: ForeignLanguage::C;
}
bool AbstractFunctionDecl::needsNewVTableEntry() const { bool AbstractFunctionDecl::needsNewVTableEntry() const {
auto &ctx = getASTContext(); auto &ctx = getASTContext();
return evaluateOrDefault( return evaluateOrDefault(