diff options
author | Jose Fonseca <jfonseca@vmware.com> | 2016-03-05 14:44:37 +0000 |
---|---|---|
committer | Jose Fonseca <jfonseca@vmware.com> | 2016-03-05 16:58:20 +0000 |
commit | 697391fa343a55b7d7330eb96e5d6fb2f40fd771 (patch) | |
tree | 78ebb9d0d3a9e4fa685e33e16f577da1a15d9c24 | |
parent | 9bb78a8f591edc1c9688d5ab1995a6d250b8ba4c (diff) |
common: clang-modernize.
-rw-r--r-- | common/highlight.cpp | 24 | ||||
-rw-r--r-- | common/trace_callset.cpp | 4 | ||||
-rw-r--r-- | common/trace_dump.cpp | 8 | ||||
-rw-r--r-- | common/trace_file_snappy.cpp | 18 | ||||
-rw-r--r-- | common/trace_file_zlib.cpp | 16 | ||||
-rw-r--r-- | common/trace_model.cpp | 12 | ||||
-rw-r--r-- | common/trace_model.hpp | 162 | ||||
-rw-r--r-- | common/trace_ostream_snappy.cpp | 4 | ||||
-rw-r--r-- | common/trace_ostream_zlib.cpp | 4 | ||||
-rw-r--r-- | common/trace_parser.cpp | 12 | ||||
-rw-r--r-- | common/trace_parser.hpp | 12 | ||||
-rw-r--r-- | common/trace_parser_loop.cpp | 12 | ||||
-rw-r--r-- | common/trace_writer_local.cpp | 4 | ||||
-rw-r--r-- | common/trace_writer_model.cpp | 38 |
14 files changed, 163 insertions, 167 deletions
diff --git a/common/highlight.cpp b/common/highlight.cpp index a03fcf76..f3555f3f 100644 --- a/common/highlight.cpp +++ b/common/highlight.cpp @@ -78,7 +78,7 @@ namespace highlight { class PlainAttribute : public Attribute { public: PlainAttribute(void) {} - virtual void apply(std::ostream &) const {} + virtual void apply(std::ostream &) const override {} }; static const PlainAttribute plainAttribute; @@ -87,11 +87,11 @@ static const PlainAttribute plainAttribute; class PlainHighlighter : public Highlighter { public: PlainHighlighter(void) {} - virtual const Attribute & normal(void) const { return plainAttribute; } - virtual const Attribute & bold(void) const { return plainAttribute; } - virtual const Attribute & italic(void) const { return plainAttribute; } - virtual const Attribute & strike(void) const { return plainAttribute; } - virtual const Attribute & color(Color) const { return plainAttribute; } + virtual const Attribute & normal(void) const override { return plainAttribute; } + virtual const Attribute & bold(void) const override { return plainAttribute; } + virtual const Attribute & italic(void) const override { return plainAttribute; } + virtual const Attribute & strike(void) const override { return plainAttribute; } + virtual const Attribute & color(Color) const override { return plainAttribute; } }; static const PlainHighlighter plainHighlighter; @@ -106,7 +106,7 @@ public: escape(_escape) {} - void apply(std::ostream& os) const { + void apply(std::ostream& os) const override { os << "\33[" << escape; } }; @@ -129,17 +129,17 @@ static const AnsiAttribute ansiGray("37m"); class AnsiHighlighter : public Highlighter { public: AnsiHighlighter(void) {} - virtual const Attribute & normal(void) const { return ansiNormal; } - virtual const Attribute & bold(void) const { return ansiBold; } - virtual const Attribute & italic(void) const { + virtual const Attribute & normal(void) const override { return ansiNormal; } + virtual const Attribute & bold(void) const override { return ansiBold; } + virtual const Attribute & italic(void) const override { /* Italic is not widely supported, or worse, implemented with a reverse */ if (0) return ansiItalic; else return plainAttribute; } - virtual const Attribute & strike(void) const { return ansiStrike; } - virtual const Attribute & color(Color c) const { + virtual const Attribute & strike(void) const override { return ansiStrike; } + virtual const Attribute & color(Color c) const override { switch (c) { case RED: return ansiRed; diff --git a/common/trace_callset.cpp b/common/trace_callset.cpp index 3722ea65..28cbf24c 100644 --- a/common/trace_callset.cpp +++ b/common/trace_callset.cpp @@ -182,7 +182,7 @@ public: lookahead = *buf; } - char consume() { + char consume() override { char c = lookahead; if (lookahead) { ++buf; @@ -210,7 +210,7 @@ public: stream.get(lookahead); } - char consume() { + char consume() override { char c = lookahead; if (stream.eof()) { lookahead = 0; diff --git a/common/trace_dump.cpp b/common/trace_dump.cpp index 70d9e430..6b73c930 100644 --- a/common/trace_dump.cpp +++ b/common/trace_dump.cpp @@ -222,9 +222,9 @@ void Dumper::visit(Array *array) { else { const char *sep = ""; os << "{"; - for (std::vector<Value *>::iterator it = array->values.begin(); it != array->values.end(); ++it) { + for (auto & value : array->values) { os << sep; - _visit(*it); + _visit(value); sep = ", "; } os << "}"; @@ -248,8 +248,8 @@ void Dumper::visit(StackFrame *frame) { } void Dumper::visit(Backtrace & backtrace) { - for (int i = 0; i < backtrace.size(); i ++) { - visit(backtrace[i]); + for (auto & frame : backtrace) { + visit(frame); os << "\n"; } } diff --git a/common/trace_file_snappy.cpp b/common/trace_file_snappy.cpp index 1154c68e..bb1eadf8 100644 --- a/common/trace_file_snappy.cpp +++ b/common/trace_file_snappy.cpp @@ -75,16 +75,16 @@ public: SnappyFile(const std::string &filename = std::string()); virtual ~SnappyFile(); - virtual bool supportsOffsets() const; - virtual File::Offset currentOffset(); - virtual void setCurrentOffset(const File::Offset &offset); + virtual bool supportsOffsets() const override; + virtual File::Offset currentOffset() override; + virtual void setCurrentOffset(const File::Offset &offset) override; protected: - virtual bool rawOpen(const std::string &filename); - virtual size_t rawRead(void *buffer, size_t length); - virtual int rawGetc(); - virtual void rawClose(); - virtual bool rawSkip(size_t length); - virtual int rawPercentRead(); + virtual bool rawOpen(const std::string &filename) override; + virtual size_t rawRead(void *buffer, size_t length) override; + virtual int rawGetc() override; + virtual void rawClose() override; + virtual bool rawSkip(size_t length) override; + virtual int rawPercentRead() override; private: inline size_t usedCacheSize() const diff --git a/common/trace_file_zlib.cpp b/common/trace_file_zlib.cpp index db54427e..71006438 100644 --- a/common/trace_file_zlib.cpp +++ b/common/trace_file_zlib.cpp @@ -54,15 +54,15 @@ public: virtual ~ZLibFile(); - virtual bool supportsOffsets() const; - virtual File::Offset currentOffset(); + virtual bool supportsOffsets() const override; + virtual File::Offset currentOffset() override; protected: - virtual bool rawOpen(const std::string &filename); - virtual size_t rawRead(void *buffer, size_t length); - virtual int rawGetc(); - virtual void rawClose(); - virtual bool rawSkip(size_t length); - virtual int rawPercentRead(); + virtual bool rawOpen(const std::string &filename) override; + virtual size_t rawRead(void *buffer, size_t length) override; + virtual int rawGetc() override; + virtual void rawClose() override; + virtual bool rawSkip(size_t length) override; + virtual int rawPercentRead() override; private: int fd; gzFile m_gzFile; diff --git a/common/trace_model.cpp b/common/trace_model.cpp index c91a9943..fbf3bdaa 100644 --- a/common/trace_model.cpp +++ b/common/trace_model.cpp @@ -37,8 +37,8 @@ static Null null; Call::~Call() { - for (unsigned i = 0; i < args.size(); ++i) { - delete args[i].value; + for (auto & arg : args) { + delete arg.value; } if (ret) { @@ -68,15 +68,15 @@ WString::~WString() { Struct::~Struct() { - for (std::vector<Value *>::iterator it = members.begin(); it != members.end(); ++it) { - delete *it; + for (auto & member : members) { + delete member; } } Array::~Array() { - for (std::vector<Value *>::iterator it = values.begin(); it != values.end(); ++it) { - delete *it; + for (auto & value : values) { + delete value; } } diff --git a/common/trace_model.hpp b/common/trace_model.hpp index 6456439c..6b224e76 100644 --- a/common/trace_model.hpp +++ b/common/trace_model.hpp @@ -133,19 +133,19 @@ public: class Null : public Value { public: - bool toBool(void) const; - signed long long toSInt(void) const; - unsigned long long toUInt(void) const; - virtual float toFloat(void) const; - virtual double toDouble(void) const; - void *toPointer(void) const; - void *toPointer(bool bind); - unsigned long long toUIntPtr(void) const; - const char *toString(void) const; - void visit(Visitor &visitor); - - const Null *toNull(void) const { return this; } - Null *toNull(void) { return this; } + bool toBool(void) const override; + signed long long toSInt(void) const override; + unsigned long long toUInt(void) const override; + virtual float toFloat(void) const override; + virtual double toDouble(void) const override; + void *toPointer(void) const override; + void *toPointer(bool bind) override; + unsigned long long toUIntPtr(void) const override; + const char *toString(void) const override; + void visit(Visitor &visitor) override; + + const Null *toNull(void) const override { return this; } + Null *toNull(void) override { return this; } }; @@ -154,12 +154,12 @@ class Bool : public Value public: Bool(bool _value) : value(_value) {} - bool toBool(void) const; - signed long long toSInt(void) const; - unsigned long long toUInt(void) const; - virtual float toFloat(void) const; - virtual double toDouble(void) const; - void visit(Visitor &visitor); + bool toBool(void) const override; + signed long long toSInt(void) const override; + unsigned long long toUInt(void) const override; + virtual float toFloat(void) const override; + virtual double toDouble(void) const override; + void visit(Visitor &visitor) override; bool value; }; @@ -170,12 +170,12 @@ class SInt : public Value public: SInt(signed long long _value) : value(_value) {} - bool toBool(void) const; - signed long long toSInt(void) const; - unsigned long long toUInt(void) const; - virtual float toFloat(void) const; - virtual double toDouble(void) const; - void visit(Visitor &visitor); + bool toBool(void) const override; + signed long long toSInt(void) const override; + unsigned long long toUInt(void) const override; + virtual float toFloat(void) const override; + virtual double toDouble(void) const override; + void visit(Visitor &visitor) override; signed long long value; }; @@ -186,12 +186,12 @@ class UInt : public Value public: UInt(unsigned long long _value) : value(_value) {} - bool toBool(void) const; - signed long long toSInt(void) const; - unsigned long long toUInt(void) const; - virtual float toFloat(void) const; - virtual double toDouble(void) const; - void visit(Visitor &visitor); + bool toBool(void) const override; + signed long long toSInt(void) const override; + unsigned long long toUInt(void) const override; + virtual float toFloat(void) const override; + virtual double toDouble(void) const override; + void visit(Visitor &visitor) override; unsigned long long value; }; @@ -202,12 +202,12 @@ class Float : public Value public: Float(float _value) : value(_value) {} - bool toBool(void) const; - signed long long toSInt(void) const; - unsigned long long toUInt(void) const; - virtual float toFloat(void) const; - virtual double toDouble(void) const; - void visit(Visitor &visitor); + bool toBool(void) const override; + signed long long toSInt(void) const override; + unsigned long long toUInt(void) const override; + virtual float toFloat(void) const override; + virtual double toDouble(void) const override; + void visit(Visitor &visitor) override; float value; }; @@ -218,12 +218,12 @@ class Double : public Value public: Double(double _value) : value(_value) {} - bool toBool(void) const; - signed long long toSInt(void) const; - unsigned long long toUInt(void) const; - virtual float toFloat(void) const; - virtual double toDouble(void) const; - void visit(Visitor &visitor); + bool toBool(void) const override; + signed long long toSInt(void) const override; + unsigned long long toUInt(void) const override; + virtual float toFloat(void) const override; + virtual double toDouble(void) const override; + void visit(Visitor &visitor) override; double value; }; @@ -235,9 +235,9 @@ public: String(const char * _value) : value(_value) {} ~String(); - bool toBool(void) const; - const char *toString(void) const; - void visit(Visitor &visitor); + bool toBool(void) const override; + const char *toString(void) const override; + void visit(Visitor &visitor) override; const char * value; }; @@ -249,8 +249,8 @@ public: WString(const wchar_t * _value) : value(_value) {} ~WString(); - bool toBool(void) const; - void visit(Visitor &visitor); + bool toBool(void) const override; + void visit(Visitor &visitor) override; const wchar_t * value; }; @@ -261,7 +261,7 @@ class Enum : public SInt public: Enum(const EnumSig *_sig, signed long long _value) : SInt(_value), sig(_sig) {} - void visit(Visitor &visitor); + void visit(Visitor &visitor) override; const EnumSig *sig; @@ -283,7 +283,7 @@ class Bitmask : public UInt public: Bitmask(const BitmaskSig *_sig, unsigned long long _value) : UInt(_value), sig(_sig) {} - void visit(Visitor &visitor); + void visit(Visitor &visitor) override; const BitmaskSig *sig; }; @@ -295,11 +295,11 @@ public: Struct(StructSig *_sig) : sig(_sig), members(_sig->num_members) { } ~Struct(); - bool toBool(void) const; - void visit(Visitor &visitor); + bool toBool(void) const override; + void visit(Visitor &visitor) override; - const Struct *toStruct(void) const { return this; } - Struct *toStruct(void) { return this; } + const Struct *toStruct(void) const override { return this; } + Struct *toStruct(void) override { return this; } const StructSig *sig; std::vector<Value *> members; @@ -312,11 +312,11 @@ public: Array(size_t len) : values(len) {} ~Array(); - bool toBool(void) const; - void visit(Visitor &visitor); + bool toBool(void) const override; + void visit(Visitor &visitor) override; - const Array *toArray(void) const { return this; } - Array *toArray(void) { return this; } + const Array *toArray(void) const override { return this; } + Array *toArray(void) override { return this; } std::vector<Value *> values; @@ -338,14 +338,14 @@ public: ~Blob(); - bool toBool(void) const; - void *toPointer(void) const; - void *toPointer(bool bind); + bool toBool(void) const override; + void *toPointer(void) const override; + void *toPointer(bool bind) override; - void visit(Visitor &visitor); + void visit(Visitor &visitor) override; - const Blob *toBlob(void) const { return this; } - Blob *toBlob(void) { return this; } + const Blob *toBlob(void) const override { return this; } + Blob *toBlob(void) override { return this; } size_t size; char *buf; @@ -358,11 +358,11 @@ class Pointer : public UInt public: Pointer(unsigned long long value) : UInt(value) {} - bool toBool(void) const; - void *toPointer(void) const; - void *toPointer(bool bind); - unsigned long long toUIntPtr(void) const; - void visit(Visitor &visitor); + bool toBool(void) const override; + void *toPointer(void) const override; + void *toPointer(bool bind) override; + unsigned long long toUIntPtr(void) const override; + void visit(Visitor &visitor) override; }; @@ -380,18 +380,18 @@ public: /** Machine-readible value */ Value *machineValue; - virtual bool toBool(void) const; - virtual signed long long toSInt(void) const; - virtual unsigned long long toUInt(void) const; - virtual float toFloat(void) const; - virtual double toDouble(void) const; - - virtual void *toPointer(void) const; - virtual void *toPointer(bool bind); - virtual unsigned long long toUIntPtr(void) const; - virtual const char *toString(void) const; - - void visit(Visitor &visitor); + virtual bool toBool(void) const override; + virtual signed long long toSInt(void) const override; + virtual unsigned long long toUInt(void) const override; + virtual float toFloat(void) const override; + virtual double toDouble(void) const override; + + virtual void *toPointer(void) const override; + virtual void *toPointer(bool bind) override; + virtual unsigned long long toUIntPtr(void) const override; + virtual const char *toString(void) const override; + + void visit(Visitor &visitor) override; }; struct RawStackFrame { diff --git a/common/trace_ostream_snappy.cpp b/common/trace_ostream_snappy.cpp index 239ce5f6..734020a5 100644 --- a/common/trace_ostream_snappy.cpp +++ b/common/trace_ostream_snappy.cpp @@ -50,8 +50,8 @@ public: ~SnappyOutStream(); SnappyOutStream(void); - bool write(const void *buffer, size_t length); - void flush(void); + bool write(const void *buffer, size_t length) override; + void flush(void) override; bool isOpen(void) { return m_stream.is_open(); } diff --git a/common/trace_ostream_zlib.cpp b/common/trace_ostream_zlib.cpp index bada79ef..9d939cfe 100644 --- a/common/trace_ostream_zlib.cpp +++ b/common/trace_ostream_zlib.cpp @@ -47,8 +47,8 @@ public: virtual ~ZLibOutStream(); protected: - virtual bool write(const void *buffer, size_t length); - virtual void flush(); + virtual bool write(const void *buffer, size_t length) override; + virtual void flush() override; private: gzFile m_gzFile; }; diff --git a/common/trace_parser.cpp b/common/trace_parser.cpp index 99fa5e83..7816aeb3 100644 --- a/common/trace_parser.cpp +++ b/common/trace_parser.cpp @@ -104,8 +104,7 @@ void Parser::close(void) { // Delete all signature data. Signatures are mere structures which don't // own their own memory, so we need to destroy all data we created here. - for (FunctionMap::iterator it = functions.begin(); it != functions.end(); ++it) { - FunctionSigState *sig = *it; + for (auto sig : functions) { if (sig) { delete [] sig->name; for (unsigned arg = 0; arg < sig->num_args; ++arg) { @@ -117,8 +116,7 @@ void Parser::close(void) { } functions.clear(); - for (StructMap::iterator it = structs.begin(); it != structs.end(); ++it) { - StructSigState *sig = *it; + for (auto sig : structs) { if (sig) { delete [] sig->name; for (unsigned member = 0; member < sig->num_members; ++member) { @@ -130,8 +128,7 @@ void Parser::close(void) { } structs.clear(); - for (EnumMap::iterator it = enums.begin(); it != enums.end(); ++it) { - EnumSigState *sig = *it; + for (auto sig : enums) { if (sig) { for (unsigned value = 0; value < sig->num_values; ++value) { delete [] sig->values[value].name; @@ -142,8 +139,7 @@ void Parser::close(void) { } enums.clear(); - for (BitmaskMap::iterator it = bitmasks.begin(); it != bitmasks.end(); ++it) { - BitmaskSigState *sig = *it; + for (auto sig : bitmasks) { if (sig) { for (unsigned flag = 0; flag < sig->num_flags; ++flag) { delete [] sig->flags[flag].name; diff --git a/common/trace_parser.hpp b/common/trace_parser.hpp index b638aa11..dad9f9cf 100644 --- a/common/trace_parser.hpp +++ b/common/trace_parser.hpp @@ -117,11 +117,11 @@ public: ~Parser(); - bool open(const char *filename); + bool open(const char *filename) override; - void close(void); + void close(void) override; - Call *parse_call(void) { + Call *parse_call(void) override { return parse_call(FULL); } @@ -130,11 +130,11 @@ public: return file->supportsOffsets(); } - void getBookmark(ParseBookmark &bookmark); + void getBookmark(ParseBookmark &bookmark) override; - void setBookmark(const ParseBookmark &bookmark); + void setBookmark(const ParseBookmark &bookmark) override; - unsigned long long getVersion(void) const { + unsigned long long getVersion(void) const override { return version; } diff --git a/common/trace_parser_loop.cpp b/common/trace_parser_loop.cpp index 45772210..04fbc135 100644 --- a/common/trace_parser_loop.cpp +++ b/common/trace_parser_loop.cpp @@ -42,14 +42,14 @@ public: delete parser; } - Call *parse_call(void); + Call *parse_call(void) override; // Delegate to Parser - void getBookmark(ParseBookmark &bookmark) { parser->getBookmark(bookmark); } - void setBookmark(const ParseBookmark &bookmark) { parser->setBookmark(bookmark); } - bool open(const char *filename); - void close(void) { parser->close(); } - unsigned long long getVersion(void) const { return parser->getVersion(); } + void getBookmark(ParseBookmark &bookmark) override { parser->getBookmark(bookmark); } + void setBookmark(const ParseBookmark &bookmark) override { parser->setBookmark(bookmark); } + bool open(const char *filename) override; + void close(void) override { parser->close(); } + unsigned long long getVersion(void) const override { return parser->getVersion(); } private: int loopCount; AbstractParser *parser; diff --git a/common/trace_writer_local.cpp b/common/trace_writer_local.cpp index 41f39c85..79ff962b 100644 --- a/common/trace_writer_local.cpp +++ b/common/trace_writer_local.cpp @@ -192,8 +192,8 @@ unsigned LocalWriter::beginEnter(const FunctionSig *sig, bool fake) { if (!fake && os::backtrace_is_needed(sig->name)) { std::vector<RawStackFrame> backtrace = os::get_backtrace(); beginBacktrace(backtrace.size()); - for (unsigned i = 0; i < backtrace.size(); ++i) { - writeStackFrame(&backtrace[i]); + for (auto & frame : backtrace) { + writeStackFrame(&frame); } endBacktrace(); } diff --git a/common/trace_writer_model.cpp b/common/trace_writer_model.cpp index af5a2b0c..d497e5b9 100644 --- a/common/trace_writer_model.cpp +++ b/common/trace_writer_model.cpp @@ -40,47 +40,47 @@ public: writer(_writer) { } - void visit(Null *) { + void visit(Null *) override { writer.writeNull(); } - void visit(Bool *node) { + void visit(Bool *node) override { writer.writeBool(node->value); } - void visit(SInt *node) { + void visit(SInt *node) override { writer.writeSInt(node->value); } - void visit(UInt *node) { + void visit(UInt *node) override { writer.writeUInt(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.writeDouble(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 { writer.writeEnum(node->sig, node->value); } - void visit(Bitmask *node) { + void visit(Bitmask *node) override { writer.writeBitmask(node->sig, node->value); } - void visit(Struct *node) { + void visit(Struct *node) override { writer.beginStruct(node->sig); for (unsigned i = 0; i < node->sig->num_members; ++i) { _visit(node->members[i]); @@ -88,23 +88,23 @@ public: writer.endStruct(); } - void visit(Array *node) { + void visit(Array *node) override { writer.beginArray(node->values.size()); - for (std::vector<Value *>::iterator it = node->values.begin(); it != node->values.end(); ++it) { - _visit(*it); + for (auto & value : node->values) { + _visit(value); } writer.endArray(); } - void visit(Blob *node) { + void visit(Blob *node) override { writer.writeBlob(node->buf, node->size); } - void visit(Pointer *node) { + void visit(Pointer *node) override { writer.writePointer(node->value); } - void visit(Repr *node) { + void visit(Repr *node) override { writer.beginRepr(); _visit(node->humanValue); _visit(node->machineValue); @@ -115,8 +115,8 @@ public: unsigned call_no = writer.beginEnter(call->sig, call->thread_id); if (call->backtrace != NULL) { writer.beginBacktrace(call->backtrace->size()); - for (unsigned i = 0; i < call->backtrace->size(); ++i) { - writer.writeStackFrame((*call->backtrace)[i]); + for (auto & frame : *call->backtrace) { + writer.writeStackFrame(frame); } writer.endBacktrace(); } |