diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index d6f72182f144..795797af9a0f 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -728,10 +728,12 @@ class CXXRecordDecl : public RecordDecl { bool isEosioContract() const { return hasAttr(); } bool isEosioAction() const { return hasAttr(); } bool isEosioTable() const { return hasAttr(); } + bool isEosioEvent() const { return hasAttr(); } bool isEosioIgnore() const { return hasAttr(); } bool hasEosioRicardian() const { return hasAttr(); } EosioActionAttr* getEosioActionAttr() const { return getAttr(); } EosioTableAttr* getEosioTableAttr() const { return getAttr(); } + EosioEventAttr* getEosioEventAttr() const { return getAttr(); } EosioContractAttr* getEosioContractAttr() const { return getAttr(); } EosioRicardianAttr* getEosioRicardianAttr() const { return getAttr(); } diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index cdc2b22020b8..37dbf69f2538 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -1005,6 +1005,14 @@ def EosioTable : InheritableAttr { let Documentation = [EosioTableDocs]; } +def EosioEvent : InheritableAttr { + let Spellings = [CXX11<"eosio", "event">, GNU<"eosio_event">]; + let Args = [StringArgument<"name", 1>]; + let Subjects = SubjectList<[CXXRecord]>; + let MeaningfulToClassTemplateDefinition = 1; + let Documentation = [EosioEventDocs]; +} + def CXX11NoReturn : InheritableAttr { let Spellings = [CXX11<"", "noreturn", 200809>]; let Subjects = SubjectList<[Function], ErrorDiag>; diff --git a/include/clang/Basic/AttrDocs.td b/include/clang/Basic/AttrDocs.td index c4b76127681a..05a07423daf8 100644 --- a/include/clang/Basic/AttrDocs.td +++ b/include/clang/Basic/AttrDocs.td @@ -894,6 +894,13 @@ The ``eosio::table`` attribute marks a record as being an eosio table. }]; } +def EosioEventDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +The ``eosio::event`` attribute marks a record as being an eosio event. + }]; +} + def NoSplitStackDocs : Documentation { let Category = DocCatFunction; let Content = [{ diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 86e0ba28e9f3..0269b861ca25 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -481,6 +481,18 @@ static void handleEosioTableAttribute(Sema &S, Decl *D, const AttributeList &AL) AL.getAttributeSpellingListIndex())); } +static void handleEosioEventAttribute(Sema &S, Decl *D, const AttributeList &AL) { + // Handle the cases where the attribute has a text message. + StringRef Str, Replacement; + if (AL.isArgExpr(0) && AL.getArgAsExpr(0) && + !S.checkStringLiteralArgumentAttr(AL, 0, Str)) + return; + + D->addAttr(::new (S.Context) + EosioEventAttr(AL.getRange(), S.Context, Str, + AL.getAttributeSpellingListIndex())); +} + /// Applies the given attribute to the Decl without performing any /// additional semantic checking. template @@ -5931,6 +5943,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, case AttributeList::AT_EosioTable: handleEosioTableAttribute(S, D, AL); break; + case AttributeList::AT_EosioEvent: + handleEosioEventAttribute(S, D, AL); + break; case AttributeList::AT_EosioWasmABI: handleEosioABIAttribute(S, D, AL); break;