Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding eosio::structure attribute #42

Open
wants to merge 1 commit into
base: transaction-sponsorship
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/clang/AST/DeclCXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -730,10 +730,12 @@ class CXXRecordDecl : public RecordDecl {
bool isEosioContract() const { return hasAttr<EosioContractAttr>(); }
bool isEosioAction() const { return hasAttr<EosioActionAttr>(); }
bool isEosioTable() const { return hasAttr<EosioTableAttr>(); }
bool isEosioStructure() const { return hasAttr<EosioStructureAttr>(); }
bool isEosioIgnore() const { return hasAttr<EosioIgnoreAttr>(); }
bool hasEosioRicardian() const { return hasAttr<EosioRicardianAttr>(); }
EosioActionAttr* getEosioActionAttr() const { return getAttr<EosioActionAttr>(); }
EosioTableAttr* getEosioTableAttr() const { return getAttr<EosioTableAttr>(); }
EosioStructureAttr* getEosioStructureAttr() const { return getAttr<EosioStructureAttr>(); }
EosioContractAttr* getEosioContractAttr() const { return getAttr<EosioContractAttr>(); }
EosioRicardianAttr* getEosioRicardianAttr() const { return getAttr<EosioRicardianAttr>(); }

Expand Down
8 changes: 8 additions & 0 deletions include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,14 @@ def EosioTable : InheritableAttr {
let Documentation = [EosioTableDocs];
}

def EosioStructure : InheritableAttr {
let Spellings = [CXX11<"eosio", "structure">, GNU<"eosio_structure">];
let Args = [StringArgument<"name", 1>];
let Subjects = SubjectList<[CXXRecord]>;
let MeaningfulToClassTemplateDefinition = 1;
let Documentation = [EosioStructureDocs];
}

def CXX11NoReturn : InheritableAttr {
let Spellings = [CXX11<"", "noreturn", 200809>];
let Subjects = SubjectList<[Function], ErrorDiag>;
Expand Down
9 changes: 8 additions & 1 deletion include/clang/Basic/AttrDocs.td
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,13 @@ The ``eosio::table`` attribute marks a record as being an eosio table.
}];
}

def EosioStructureDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
The ``eosio::structure`` attribute marks a struct as being an eosio structure.
}];
}

def NoSplitStackDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
Expand Down Expand Up @@ -4237,4 +4244,4 @@ be accessed on both device side and host side. It has external linkage and is
not initialized on device side. It has internal linkage and is initialized by
the initializer on host side.
}];
}
}
15 changes: 15 additions & 0 deletions lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,18 @@ static void handleEosioTableAttribute(Sema &S, Decl *D, const ParsedAttr &AL) {
AL.getAttributeSpellingListIndex()));
}

static void handleEosioStructureAttribute(Sema &S, Decl *D, const ParsedAttr &AL) {
// Handle the cases where the attribute has a text message.
StringRef Str;
if (AL.isArgExpr(0) && AL.getArgAsExpr(0) &&
!S.checkStringLiteralArgumentAttr(AL, 0, Str))
return;

D->addAttr(::new (S.Context)
EosioStructureAttr(AL.getRange(), S.Context, Str,
AL.getAttributeSpellingListIndex()));
}

/// Applies the given attribute to the Decl without performing any
/// additional semantic checking.
template <typename AttrType>
Expand Down Expand Up @@ -6746,6 +6758,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
case ParsedAttr::AT_EosioTable:
handleEosioTableAttribute(S, D, AL);
break;
case ParsedAttr::AT_EosioStructure:
handleEosioStructureAttribute(S, D, AL);
break;
case ParsedAttr::AT_EosioWasmABI:
handleEosioABIAttribute(S, D, AL);
break;
Expand Down