Skip to content
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
6 changes: 3 additions & 3 deletions src/cfg/Relooper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ static wasm::Expression* HandleFollowupMultiples(wasm::Expression* Ret, Shape* P

// Branch

Branch::Branch(wasm::Expression* ConditionInit, wasm::Expression* CodeInit) : Ancestor(nullptr), Condition(ConditionInit), Code(CodeInit) {}
Branch::Branch(wasm::Expression* ConditionInit, wasm::Expression* CodeInit) : Condition(ConditionInit), Code(CodeInit) {}

Branch::Branch(std::vector<wasm::Index>&& ValuesInit, wasm::Expression* CodeInit) : Ancestor(nullptr), Condition(nullptr), Code(CodeInit) {
Branch::Branch(std::vector<wasm::Index>&& ValuesInit, wasm::Expression* CodeInit) : Condition(nullptr), Code(CodeInit) {
if (ValuesInit.size() > 0) {
SwitchValues = wasm::make_unique<std::vector<wasm::Index>>(ValuesInit);
}
Expand All @@ -124,7 +124,7 @@ wasm::Expression* Branch::Render(RelooperBuilder& Builder, Block* Target, bool S

// Block

Block::Block(wasm::Expression* CodeInit, wasm::Expression* SwitchConditionInit) : Parent(nullptr), Id(-1), Code(CodeInit), SwitchCondition(SwitchConditionInit), IsCheckedMultipleEntry(false) {}
Block::Block(wasm::Expression* CodeInit, wasm::Expression* SwitchConditionInit) : Code(CodeInit), SwitchCondition(SwitchConditionInit), IsCheckedMultipleEntry(false) {}

Block::~Block() {
for (auto& iter : ProcessedBranchesOut) {
Expand Down
24 changes: 12 additions & 12 deletions src/cfg/Relooper.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct Branch {
Break = 1,
Continue = 2
};
Shape* Ancestor; // If not NULL, this shape is the relevant one for purposes of getting to the target block. We break or continue on it
Shape* Ancestor = nullptr; // If not NULL, this shape is the relevant one for purposes of getting to the target block. We break or continue on it
Branch::FlowType Type; // If Ancestor is not NULL, this says whether to break or continue

// A branch either has a condition expression if the block ends in ifs, or if the block ends in a switch, then a list of indexes, which
Expand Down Expand Up @@ -151,7 +151,7 @@ struct InsertOrderedSet

size_t count(const T& val) const { return Map.count(val); }

InsertOrderedSet() {}
InsertOrderedSet() = default;
InsertOrderedSet(const InsertOrderedSet& other) {
*this = other;
}
Expand Down Expand Up @@ -214,7 +214,7 @@ struct InsertOrderedMap
bool empty() const { return Map.empty(); }
size_t count(const Key& k) const { return Map.count(k); }

InsertOrderedMap() {}
InsertOrderedMap() = default;
InsertOrderedMap(InsertOrderedMap& other) {
abort(); // TODO, watch out for iterators
}
Expand Down Expand Up @@ -245,8 +245,8 @@ struct Block {
BlockSet BranchesIn;
BlockBranchMap ProcessedBranchesOut;
BlockSet ProcessedBranchesIn;
Shape* Parent; // The shape we are directly inside
int Id; // A unique identifier, defined when added to relooper
Shape* Parent = nullptr; // The shape we are directly inside
int Id = -1; // A unique identifier, defined when added to relooper
wasm::Expression* Code; // The code in this block. This can be arbitrary wasm code, including internal control flow, it should just not branch to the outside
wasm::Expression* SwitchCondition; // If nullptr, then this block ends in ifs (or nothing). otherwise, this block ends in a switch, done on this condition
bool IsCheckedMultipleEntry; // If true, we are a multiple entry, so reaching us requires setting the label variable
Expand Down Expand Up @@ -296,8 +296,8 @@ struct MultipleShape;
struct LoopShape;

struct Shape {
int Id; // A unique identifier. Used to identify loops, labels are Lx where x is the Id. Defined when added to relooper
Shape* Next; // The shape that will appear in the code right after this one
int Id = -1; // A unique identifier. Used to identify loops, labels are Lx where x is the Id. Defined when added to relooper
Shape* Next = nullptr; // The shape that will appear in the code right after this one
Shape* Natural; // The shape that control flow gets to naturally (if there is Next, then this is Next)

enum ShapeType {
Expand All @@ -307,7 +307,7 @@ struct Shape {
};
ShapeType Type;

Shape(ShapeType TypeInit) : Id(-1), Next(NULL), Type(TypeInit) {}
Shape(ShapeType TypeInit) : Type(TypeInit) {}
virtual ~Shape() = default;

virtual wasm::Expression* Render(RelooperBuilder& Builder, bool InLoop) = 0;
Expand All @@ -318,9 +318,9 @@ struct Shape {
};

struct SimpleShape : public Shape {
Block* Inner;
Block* Inner = nullptr;

SimpleShape() : Shape(Simple), Inner(NULL) {}
SimpleShape() : Shape(Simple) {}
wasm::Expression* Render(RelooperBuilder& Builder, bool InLoop) override;
};

Expand All @@ -335,11 +335,11 @@ struct MultipleShape : public Shape {
};

struct LoopShape : public Shape {
Shape* Inner;
Shape* Inner = nullptr;

BlockSet Entries; // we must visit at least one of these

LoopShape() : Shape(Loop), Inner(NULL) {}
LoopShape() : Shape(Loop) {}
wasm::Expression* Render(RelooperBuilder& Builder, bool InLoop) override;
};

Expand Down
6 changes: 3 additions & 3 deletions src/emscripten-optimizer/istring.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
namespace cashew {

struct IString {
const char *str;
const char *str = nullptr;

static size_t hash_c(const char *str) { // see http://www.cse.yorku.ca/~oz/hash.html
unsigned int hash = 5381;
Expand All @@ -59,7 +59,7 @@ struct IString {
}
};

IString() : str(nullptr) {}
IString() = default;
IString(const char *s, bool reuse=true) { // if reuse=true, then input is assumed to remain alive; not copied
assert(s);
set(s, reuse);
Expand Down Expand Up @@ -178,7 +178,7 @@ namespace cashew {
class IStringSet : public std::unordered_set<IString> {
std::vector<char> data;
public:
IStringSet() {}
IStringSet() = default;
IStringSet(const char *init) { // comma-delimited list
int size = strlen(init) + 1;
data.resize(size);
Expand Down
4 changes: 2 additions & 2 deletions src/emscripten-optimizer/optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ AsmType detectType(cashew::Ref node, AsmData *asmData=nullptr, bool inVarDef=fal

struct AsmData {
struct Local {
Local() {}
Local() = default;
Local(AsmType type, bool param) : type(type), param(param) {}
AsmType type;
bool param; // false if a var
Expand Down Expand Up @@ -92,7 +92,7 @@ struct AsmData {
return isLocal(name) && !locals[name].param;
}

AsmData() {} // if you want to fill in the data yourself
AsmData() = default; // if you want to fill in the data yourself
AsmData(cashew::Ref f); // if you want to read data from f, and modify it as you go (parallel to denormalize)

void denormalize();
Expand Down
6 changes: 3 additions & 3 deletions src/emscripten-optimizer/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,8 @@ class Parser {

// Debugging

char *allSource;
int allSize;
char *allSource = nullptr;
int allSize = 0;

static void dump(const char *where, char* curr) {
/*
Expand All @@ -938,7 +938,7 @@ class Parser {

public:

Parser() : allSource(nullptr), allSize(0) {
Parser() {
expressionPartsStack.resize(1);
}

Expand Down
9 changes: 5 additions & 4 deletions src/emscripten-optimizer/simple_ast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void dump(const char *str, Ref node, bool pretty) {
// Traversals

struct TraverseInfo {
TraverseInfo() {}
TraverseInfo() = default;
TraverseInfo(Ref node, ArrayStorage* arr) : node(node), arr(arr), index(0) {}
Ref node;
ArrayStorage* arr;
Expand All @@ -199,10 +199,11 @@ template<class T, int init>
struct StackedStack { // a stack, on the stack
T stackStorage[init];
T* storage;
int used, available; // used amount, available amount
bool alloced;
int used = 0;
int available = init; // used amount, available amount
bool alloced = false;

StackedStack() : used(0), available(init), alloced(false) {
StackedStack() {
storage = stackStorage;
}
~StackedStack() {
Expand Down
21 changes: 11 additions & 10 deletions src/emscripten-optimizer/simple_ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct Value {
AssignName_ = 7
};

Type type;
Type type = Null;

typedef std::unordered_map<IString, Ref> ObjectStorage;

Expand All @@ -131,14 +131,14 @@ struct Value {
};

// constructors all copy their input
Value() : type(Null), num(0) {}
explicit Value(const char *s) : type(Null) {
Value() {}
explicit Value(const char *s) {
setString(s);
}
explicit Value(double n) : type(Null) {
explicit Value(double n) {
setNumber(n);
}
explicit Value(ArrayStorage &a) : type(Null) {
explicit Value(ArrayStorage &a) {
setArray();
*arr = a;
}
Expand Down Expand Up @@ -544,15 +544,16 @@ void traverseFunctions(Ref ast, std::function<void (Ref)> visit);
struct JSPrinter {
bool pretty, finalize;

char *buffer;
size_t size, used;
char *buffer = nullptr;
size_t size = 0;
size_t used = 0;

int indent;
bool possibleSpace; // add a space to separate identifiers
int indent = 0;
bool possibleSpace = false; // add a space to separate identifiers

Ref ast;

JSPrinter(bool pretty_, bool finalize_, Ref ast_) : pretty(pretty_), finalize(finalize_), buffer(0), size(0), used(0), indent(0), possibleSpace(false), ast(ast_) {}
JSPrinter(bool pretty_, bool finalize_, Ref ast_) : pretty(pretty_), finalize(finalize_), ast(ast_) {}

~JSPrinter() {
free(buffer);
Expand Down
4 changes: 2 additions & 2 deletions src/ir/branch-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ struct BranchSeeker : public PostWalker<BranchSeeker> {
Name target;
bool named = true;

Index found;
Index found = 0;
Type valueType;

BranchSeeker(Name target) : target(target), found(0) {}
BranchSeeker(Name target) : target(target) {}

void noteFound(Expression* value) {
found++;
Expand Down
2 changes: 1 addition & 1 deletion src/ir/count.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace wasm {
struct GetLocalCounter : public PostWalker<GetLocalCounter> {
std::vector<Index> num;

GetLocalCounter() {}
GetLocalCounter() = default;
GetLocalCounter(Function* func) {
analyze(func, func->body);
}
Expand Down
6 changes: 3 additions & 3 deletions src/pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct PassRegistry {
struct PassInfo {
std::string description;
Creator create;
PassInfo() {}
PassInfo() = default;
PassInfo(std::string description, Creator create) : description(description), create(create) {}
};
std::map<std::string, PassInfo> passInfos;
Expand Down Expand Up @@ -253,8 +253,8 @@ class Pass {
std::string name;

protected:
Pass() {}
Pass(Pass &) {}
Pass() = default;
Pass(Pass &) = default;
Pass &operator=(const Pass&) = delete;
};

Expand Down
6 changes: 3 additions & 3 deletions src/passes/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ Pass *createPrinterPass() {

class MinifiedPrinter : public Printer {
public:
MinifiedPrinter() : Printer() {}
MinifiedPrinter() = default;
MinifiedPrinter(std::ostream* o) : Printer(o) {}

void run(PassRunner* runner, Module* module) override {
Expand All @@ -1368,7 +1368,7 @@ Pass *createMinifiedPrinterPass() {

class FullPrinter : public Printer {
public:
FullPrinter() : Printer() {}
FullPrinter() = default;
FullPrinter(std::ostream* o) : Printer(o) {}

void run(PassRunner* runner, Module* module) override {
Expand All @@ -1386,7 +1386,7 @@ Pass *createFullPrinterPass() {

class PrintStackIR : public Printer {
public:
PrintStackIR() : Printer() {}
PrintStackIR() = default;
PrintStackIR(std::ostream* o) : Printer(o) {}

void run(PassRunner* runner, Module* module) override {
Expand Down
2 changes: 1 addition & 1 deletion src/shell-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct ShellExternalInterface : ModuleInstance::ExternalInterface {
Memory& operator=(const Memory&) = delete;

public:
Memory() {}
Memory() = default;
void resize(size_t newSize) {
// Ensure the smallest allocation is large enough that most allocators
// will provide page-aligned storage. This hopefully allows the
Expand Down
2 changes: 1 addition & 1 deletion src/support/archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Archive {
Child child;
bool error = false; // TODO: use std::error_code instead?
public:
child_iterator() {}
child_iterator() = default;
explicit child_iterator(bool error) : error(error) {}
child_iterator(const Child& c) : child(c) {}
const Child* operator->() const { return &child; }
Expand Down
8 changes: 4 additions & 4 deletions src/support/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ typedef cashew::IString IString;
// Main value type
struct Value {
struct Ref : public std::shared_ptr<Value> {
Ref() : std::shared_ptr<Value>() {}
Ref() = default;
Ref(Value* value) : std::shared_ptr<Value>(value) {}

Ref& operator[](size_t x) {
Expand All @@ -67,7 +67,7 @@ struct Value {
Object = 5,
};

Type type;
Type type = Null;

typedef std::vector<Ref> ArrayStorage;
typedef std::unordered_map<IString, Ref> ObjectStorage;
Expand All @@ -79,15 +79,15 @@ struct Value {
#ifndef _MSC_VER
IString str;
#endif
double num;
double num = 0;
ArrayStorage *arr; // manually allocated/freed
bool boo;
ObjectStorage *obj; // manually allocated/freed
Ref ref;
};

// constructors all copy their input
Value() : type(Null), num(0) {}
Value() {}
explicit Value(const char *s) : type(Null) {
setString(s);
}
Expand Down
2 changes: 1 addition & 1 deletion src/support/sorted_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
namespace wasm {

struct SortedVector : public std::vector<Index> {
SortedVector() {}
SortedVector() = default;

SortedVector merge(const SortedVector& other) const {
SortedVector ret;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/wasm-metadce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ using namespace wasm;
struct DCENode {
Name name;
std::vector<Name> reaches; // the other nodes this one can reach
DCENode() {}
DCENode() = default;
DCENode(Name name) : name(name) {}
};

Expand Down
2 changes: 1 addition & 1 deletion src/tools/wasm-reduce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct ProgramResult {
std::string output;
double time;

ProgramResult() {}
ProgramResult() = default;
ProgramResult(std::string command) {
getFromExecution(command);
}
Expand Down
Loading