Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Fix/abigen variants #399

Merged
merged 2 commits into from
Feb 1, 2019
Merged
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: 1 addition & 1 deletion tools/abigen/eosio-abigen.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ class abigen : public generation_utils {
void add_variant( const clang::QualType& t ) {
abi_variant var;
auto pt = llvm::dyn_cast<clang::ElaboratedType>(t.getTypePtr());
auto tst = llvm::dyn_cast<clang::TemplateSpecializationType>(pt->desugar().getTypePtr());
auto tst = llvm::dyn_cast<clang::TemplateSpecializationType>(pt ? pt->desugar().getTypePtr() : t.getTypePtr());
var.name = get_type(t);
for (int i=0; i < tst->getNumArgs(); ++i)
var.types.push_back(translate_type(get_template_argument( t, i ).getAsType()));
Expand Down
14 changes: 6 additions & 8 deletions tools/include/eosio/gen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,14 +489,12 @@ struct generation_utils {
std::string ret = tst->getTemplateName().getAsTemplateDecl()->getName().str()+"_";
for (int i=0; i < tst->getNumArgs(); ++i) {
auto arg = get_template_argument(type,i);
if (arg.getAsExpr()) {
auto ce = llvm::dyn_cast<clang::CastExpr>(arg.getAsExpr());
if (ce) {
auto il = llvm::dyn_cast<clang::IntegerLiteral>(ce->getSubExpr());
ret += std::to_string(il->getValue().getLimitedValue());
if ( i < tst->getNumArgs()-1 )
ret += "_";
}
if (auto ce = arg.getKind() == clang::TemplateArgument::ArgKind::Expression
? llvm::dyn_cast<clang::CastExpr>(arg.getAsExpr()) : nullptr) {
auto il = llvm::dyn_cast<clang::IntegerLiteral>(ce->getSubExpr());
ret += std::to_string(il->getValue().getLimitedValue());
if ( i < tst->getNumArgs()-1 )
ret += "_";
}
else {
ret += translate_type(get_template_argument( type, i ).getAsType());
Expand Down