From: Rui Ueyama Date: Tue, 14 Feb 2017 23:28:01 +0000 (+0000) Subject: Use zero-initialization instead of memset. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3afdebfea9d06af2e99f25e9025d8ff8396e193a;p=llvm Use zero-initialization instead of memset. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295119 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/WinCOFFObjectWriter.cpp b/lib/MC/WinCOFFObjectWriter.cpp index 86d76fbceb5..d364951f87e 100644 --- a/lib/MC/WinCOFFObjectWriter.cpp +++ b/lib/MC/WinCOFFObjectWriter.cpp @@ -72,7 +72,7 @@ class COFFSection; class COFFSymbol { public: - COFF::symbol Data; + COFF::symbol Data = {}; typedef SmallVector AuxiliarySymbols; @@ -84,7 +84,7 @@ public: int Relocations = 0; const MCSymbol *MC = nullptr; - COFFSymbol(StringRef name); + COFFSymbol(StringRef Name) : Name(Name) {} void set_name_offset(uint32_t Offset); @@ -110,7 +110,7 @@ typedef std::vector relocations; class COFFSection { public: - COFF::section Header; + COFF::section Header = {}; std::string Name; int Number; @@ -118,7 +118,7 @@ public: COFFSymbol *Symbol = nullptr; relocations Relocations; - COFFSection(StringRef name); + COFFSection(StringRef Name) : Name(Name) {} }; class WinCOFFObjectWriter : public MCObjectWriter { @@ -132,7 +132,7 @@ public: std::unique_ptr TargetObjectWriter; // Root level file contents. - COFF::header Header; + COFF::header Header = {}; sections Sections; symbols Symbols; StringTableBuilder Strings{StringTableBuilder::WinCOFF}; @@ -212,10 +212,6 @@ static inline void write_uint32_le(void *Data, uint32_t Value) { //------------------------------------------------------------------------------ // Symbol class implementation -COFFSymbol::COFFSymbol(StringRef name) : Name(name.begin(), name.end()) { - memset(&Data, 0, sizeof(Data)); -} - // In the case that the name does not fit within 8 bytes, the offset // into the string table is stored in the last 4 bytes instead, leaving // the first 4 bytes as 0. @@ -224,21 +220,12 @@ void COFFSymbol::set_name_offset(uint32_t Offset) { write_uint32_le(Data.Name + 4, Offset); } -//------------------------------------------------------------------------------ -// Section class implementation - -COFFSection::COFFSection(StringRef name) : Name(name) { - memset(&Header, 0, sizeof(Header)); -} - //------------------------------------------------------------------------------ // WinCOFFObjectWriter class implementation WinCOFFObjectWriter::WinCOFFObjectWriter(MCWinCOFFObjectTargetWriter *MOTW, raw_pwrite_stream &OS) : MCObjectWriter(OS, true), TargetObjectWriter(MOTW) { - memset(&Header, 0, sizeof(Header)); - Header.Machine = TargetObjectWriter->getMachine(); }