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

Cherry picked fixes release 1.6.x #681

Merged
merged 8 commits into from
Sep 27, 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
9 changes: 5 additions & 4 deletions libraries/eosiolib/eosiolib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ namespace eosio {
}

std::vector<name> get_active_producers() {
auto prod_cnt = get_active_producers(nullptr, 0)/8;
std::vector<name> active_prods(prod_cnt);
get_active_producers((uint64_t*)active_prods.data(), active_prods.size());
return active_prods;
const auto buffer_size = get_active_producers(nullptr, 0);
const auto prod_cnt = buffer_size / sizeof(name);
std::vector<name> active_prods(prod_cnt);
get_active_producers((uint64_t*)active_prods.data(), buffer_size);
return active_prods;
}

// powers.hpp
Expand Down
24 changes: 13 additions & 11 deletions tools/include/compiler_options.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,8 @@ static Options CreateOptions(bool add_defaults=true) {
for ( auto input_filename : input_filename_opt ) {
#ifdef ONLY_LD
ldopts.push_back(input_filename);
#else
inputs.push_back(input_filename);
#endif
inputs.push_back(input_filename);
}

#ifdef ONLY_LD
Expand Down Expand Up @@ -751,25 +750,23 @@ static Options CreateOptions(bool add_defaults=true) {
#ifndef ONLY_LD
if (inputs.size() == 1) {
llvm::SmallString<256> fn = llvm::sys::path::filename(inputs[0]);
llvm::SmallString<256> fn2 = fn;
llvm::sys::path::replace_extension(fn, ".wasm");
llvm::sys::path::replace_extension(fn, fnative_opt ? "" : ".wasm");
output_fn = fn.str();
llvm::SmallString<256> res;
llvm::sys::path::system_temp_directory(true, res);
ldopts.emplace_back(std::string(std::string(res.str())+"/"+std::string(fn2.str())+".o"));
} else {
ldopts.emplace_back("a.out");
}
#endif
#else
if (inputs.size() == 1) {
llvm::SmallString<256> fn = llvm::sys::path::filename(inputs[0]);
llvm::sys::path::replace_extension(fn, ".wasm");
ldopts.emplace_back("-o "+output_fn);
llvm::sys::path::replace_extension(fn, "");
llvm::sys::path::replace_extension(fn, fnative_opt ? "" : ".wasm");
output_fn = fn.str();
ldopts.emplace_back("-o "+output_fn);
} else {
ldopts.emplace_back("-o a.out");
output_fn = "a.out";
ldopts.emplace_back("-o "+output_fn);
}
#endif
}
else {
ldopts.emplace_back("-o "+o_opt);
Expand Down Expand Up @@ -834,5 +831,10 @@ static Options CreateOptions(bool add_defaults=true) {
if (fuse_main_opt)
ldopts.emplace_back("-fuse-main");
#endif

#ifndef ONLY_LD
return {output_fn, inputs, link, abigen, pp_dir, abigen_output, abigen_contract, copts, ldopts, agopts, agresources, debug, fnative_opt};
#else
return {output_fn, {}, link, abigen, pp_dir, abigen_output, abigen_contract, copts, ldopts, agopts, agresources, debug, fnative_opt};
#endif
}
12 changes: 11 additions & 1 deletion tools/include/eosio/abigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ namespace eosio { namespace cdt {

void add_tuple(const clang::QualType& type) {
auto pt = llvm::dyn_cast<clang::ElaboratedType>(type.getTypePtr());
auto tst = llvm::dyn_cast<clang::TemplateSpecializationType>(pt->desugar().getTypePtr());
auto tst = llvm::dyn_cast<clang::TemplateSpecializationType>((pt) ? pt->desugar().getTypePtr() : type.getTypePtr());
if (!tst)
throw abigen_ex;
abi_struct tup;
Expand Down Expand Up @@ -247,6 +247,9 @@ namespace eosio { namespace cdt {
}

void add_type( const clang::QualType& t ) {
if (evaluated.count(t.getTypePtr()))
return;
evaluated.insert(t.getTypePtr());
auto type = get_ignored_type(t);
if (!is_builtin_type(translate_type(type))) {
if (is_aliasing(type))
Expand Down Expand Up @@ -433,6 +436,12 @@ namespace eosio { namespace cdt {
if (as.base == td.new_type_name)
return true;
}
for ( auto v : _abi.variants ) {
for ( auto vt : v.types ) {
if ( remove_suffix(vt) == td.new_type_name )
return true;
}
}
for ( auto t : _abi.tables )
if ( t.type == td.new_type_name )
return true;
Expand Down Expand Up @@ -479,5 +488,6 @@ namespace eosio { namespace cdt {
std::set<const clang::CXXRecordDecl*> tables;
std::set<abi_table> ctables;
std::map<std::string, std::string> rcs;
std::set<const clang::Type*> evaluated;
};
}} // ns eosio::cdt
4 changes: 4 additions & 0 deletions tools/include/eosio/gen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,16 @@ struct generation_utils {
inline std::string get_type_alias_string( const clang::QualType& t ) {
if (auto dt = llvm::dyn_cast<clang::TypedefType>(t.getTypePtr()))
return get_type(dt->desugar());
else if (auto dt = llvm::dyn_cast<clang::ElaboratedType>(t.getTypePtr()))
return get_type_alias_string(dt->desugar());
return get_type(t);
}

inline std::vector<clang::QualType> get_type_alias( const clang::QualType& t ) {
if (auto dt = llvm::dyn_cast<clang::TypedefType>(t.getTypePtr()))
return {dt->desugar()};
else if (auto dt = llvm::dyn_cast<clang::ElaboratedType>(t.getTypePtr()))
return get_type_alias(dt->desugar());
return {};
}

Expand Down