diff options
author | Jose Fonseca <jfonseca@vmware.com> | 2016-03-05 14:44:48 +0000 |
---|---|---|
committer | Jose Fonseca <jfonseca@vmware.com> | 2016-03-05 16:58:20 +0000 |
commit | 6ca9340d3c515a153d991050640d19dc28ffb176 (patch) | |
tree | 22aaf0c7d819b3531cd8b7e9b71fc7cecd7f9e1b /cli | |
parent | 697391fa343a55b7d7330eb96e5d6fb2f40fd771 (diff) |
cli: clang-modernize.
Diffstat (limited to 'cli')
-rw-r--r-- | cli/cli_dump.cpp | 4 | ||||
-rw-r--r-- | cli/cli_pickle.cpp | 34 | ||||
-rw-r--r-- | cli/cli_sed.cpp | 47 | ||||
-rw-r--r-- | cli/cli_trace.cpp | 6 |
4 files changed, 45 insertions, 46 deletions
diff --git a/cli/cli_dump.cpp b/cli/cli_dump.cpp index b26c08b2..62feef98 100644 --- a/cli/cli_dump.cpp +++ b/cli/cli_dump.cpp @@ -118,7 +118,7 @@ public: { } - void visit(trace::Blob *blob) { + void visit(trace::Blob *blob) override { std::string fileName = "blob_call" + std::to_string(callNo); if (blobNo) { fileName += "_"; @@ -136,7 +136,7 @@ public: ++blobNo; } - void visit(trace::Call *call) { + void visit(trace::Call *call) override { callNo = call->no; blobNo = 0; Dumper::visit(call); diff --git a/cli/cli_pickle.cpp b/cli/cli_pickle.cpp index 286716be..8e4c8bb3 100644 --- a/cli/cli_pickle.cpp +++ b/cli/cli_pickle.cpp @@ -55,39 +55,39 @@ public: symbolic(_symbolic) { } - void visit(Null *node) { + void visit(Null *node) override { writer.writeInt(0); } - void visit(Bool *node) { + void visit(Bool *node) override { writer.writeBool(node->value); } - void visit(SInt *node) { + void visit(SInt *node) override { writer.writeInt(node->value); } - void visit(UInt *node) { + void visit(UInt *node) override { writer.writeInt(node->value); } - void visit(Float *node) { + void visit(Float *node) override { writer.writeFloat(node->value); } - void visit(Double *node) { + void visit(Double *node) override { writer.writeFloat(node->value); } - void visit(String *node) { + void visit(String *node) override { writer.writeString(node->value); } - void visit(WString *node) { + void visit(WString *node) override { writer.writeWString(node->value); } - void visit(Enum *node) { + void visit(Enum *node) override { if (symbolic) { const EnumValue *it = node->lookup(); if (it) { @@ -98,7 +98,7 @@ public: writer.writeInt(node->value); } - void visit(Bitmask *node) { + void visit(Bitmask *node) override { if (symbolic) { unsigned long long value = node->value; const BitmaskSig *sig = node->sig; @@ -122,7 +122,7 @@ public: } } - void visit(Struct *node) { + void visit(Struct *node) override { if (true) { // Structures as dictionaries writer.beginDict(); @@ -143,23 +143,23 @@ public: } } - void visit(Array *node) { + void visit(Array *node) override { writer.beginList(); - for (std::vector<Value *>::iterator it = node->values.begin(); it != node->values.end(); ++it) { - _visit(*it); + for (auto & value : node->values) { + _visit(value); } writer.endList(); } - void visit(Blob *node) { + void visit(Blob *node) override { writer.writeByteArray(node->buf, node->size); } - void visit(Pointer *node) { + void visit(Pointer *node) override { writer.writePointer(node->value); } - void visit(Repr *r) { + void visit(Repr *r) override { if (symbolic) { _visit(r->humanValue); } else { diff --git a/cli/cli_sed.cpp b/cli/cli_sed.cpp index 401b7a63..0a39b397 100644 --- a/cli/cli_sed.cpp +++ b/cli/cli_sed.cpp @@ -88,25 +88,25 @@ public: ~Replacer() { } - void visit(Null *) { + void visit(Null *) override { } - void visit(Bool *node) { + void visit(Bool *node) override { } - void visit(SInt *node) { + void visit(SInt *node) override { } - void visit(UInt *node) { + void visit(UInt *node) override { } - void visit(Float *node) { + void visit(Float *node) override { } - void visit(Double *node) { + void visit(Double *node) override { } - void visit(String *node) { + void visit(String *node) override { if (!searchName.compare(node->value)) { size_t len = replaceName.length() + 1; delete [] node->value; @@ -116,10 +116,10 @@ public: } } - void visit(WString *node) { + void visit(WString *node) override { } - void visit(Enum *node) { + void visit(Enum *node) override { const EnumValue *it = node->lookup(); if (it) { if (searchName.compare(it->name) == 0) { @@ -134,36 +134,35 @@ public: } } - void visit(Bitmask *bitmask) { + void visit(Bitmask *bitmask) override { } - void visit(Struct *s) { - for (unsigned i = 0; i < s->members.size(); ++i) { - Value *memberValue = s->members[i]; + void visit(Struct *s) override { + for (auto memberValue : s->members) { _visit(memberValue); } } - void visit(Array *array) { - for (std::vector<Value *>::iterator it = array->values.begin(); it != array->values.end(); ++it) { - _visit(*it); + void visit(Array *array) override { + for (auto & value : array->values) { + _visit(value); } } - void visit(Blob *blob) { + void visit(Blob *blob) override { } - void visit(Pointer *p) { + void visit(Pointer *p) override { } - void visit(Repr *r) { + void visit(Repr *r) override { _visit(r->humanValue); } void visit(Call *call) { - for (unsigned i = 0; i < call->args.size(); ++i) { - if (call->args[i].value) { - _visit(call->args[i].value); + for (auto & arg : call->args) { + if (arg.value) { + _visit(arg.value); } } @@ -204,8 +203,8 @@ sed_trace(Replacements &replacements, const char *inFileName, std::string &outFi trace::Call *call; while ((call = p.parse_call())) { - for (Replacements::iterator it = replacements.begin(); it != replacements.end(); ++it) { - it->visit(call); + for (auto & replacement : replacements) { + replacement.visit(call); } writer.writeCall(call); diff --git a/cli/cli_trace.cpp b/cli/cli_trace.cpp index adca8af3..8b780f36 100644 --- a/cli/cli_trace.cpp +++ b/cli/cli_trace.cpp @@ -257,14 +257,14 @@ traceProgram(trace::API api, if (verbose) { const char *sep = ""; - for (unsigned i = 0; i < args.size(); ++i) { + for (auto & arg : args) { const char *quote; - if (strchr(args[i], ' ') != NULL) { + if (strchr(arg, ' ') != NULL) { quote = "\""; } else { quote = ""; } - std::cerr << sep << quote << args[i] << quote; + std::cerr << sep << quote << arg << quote; sep = " "; } std::cerr << "\n"; |