llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

ParsedAttr plugins with AS_Microsoft spellings are never matched.

Open apache-hb opened this issue 1 year ago • 1 comments

this example plugin should match the provided sample code, but doesnt.

struct ExampleAttrInfo : public ParsedAttrInfo {
    ExampleAttrInfo() {
        static constexpr Spelling S[] = {
            {ParsedAttr::AS_Microsoft, "example"}
        };
        Spellings = S;
    }

    bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr, const Decl *D) const override {
        return true;
    }

    AttrHandling handleDeclAttribute(Sema &S, Decl *D, const ParsedAttr &Attr) const override {
        S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << "example";
        return AttributeApplied;
    }
};

static ParsedAttrInfoRegistry::Add<ExampleAttrInfo> Y("example", "");
[example]
class Hello {};

This appears to be because non-standard microsoft attributes are purposefully ignored but attributes registered via plugins are not handled by ParsedAttr::getParsedKind.

apache-hb avatar Mar 24 '24 06:03 apache-hb

@llvm/issue-subscribers-clang-frontend

Author: Elliot (apache-hb)

this example plugin should match the provided sample code, but doesnt. ```cpp struct ExampleAttrInfo : public ParsedAttrInfo { ExampleAttrInfo() { static constexpr Spelling S[] = { {ParsedAttr::AS_Microsoft, "example"} }; Spellings = S; }
bool diagAppertainsToDecl(Sema &amp;S, const ParsedAttr &amp;Attr, const Decl *D) const override {
    return true;
}

AttrHandling handleDeclAttribute(Sema &amp;S, Decl *D, const ParsedAttr &amp;Attr) const override {
    S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) &lt;&lt; "example";
    return AttributeApplied;
}

};

static ParsedAttrInfoRegistry::Add<ExampleAttrInfo> Y("example", "");

```cpp
[example]
class Hello {};

This appears to be because non-standard microsoft attributes are purposefully ignored but attributes registered via plugins are not handled by ParsedAttr::getParsedKind.

llvmbot avatar Mar 24 '24 13:03 llvmbot