[llvm] [SystemZ][z/OS] yaml2obj for header and end records (PR #73859)
James Henderson via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 30 00:46:57 PST 2023
================
@@ -0,0 +1,46 @@
+//===-- GOFFYAML.cpp - GOFF YAMLIO implementation ---------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines classes for handling the YAML representation of GOFF.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ObjectYAML/GOFFYAML.h"
+#include "llvm/BinaryFormat/GOFF.h"
+#include <string.h>
+
+namespace llvm {
+namespace GOFFYAML {
+
+Object::Object() { memset(&Header, 0, sizeof(Header)); }
----------------
jh7370 wrote:
I don't think this is an appropriate way to initialise `Header`. For starters, I doubt `std::optional` should be initialised like that. I'd probably be explicit in the struct and inline initialise everything to zero (you don't need to do that for the optional fields).
As an aside, you should prefer C++ versions of stdlib functions like `memset` (i.e. prefer `std::memset` and `<cstring>`.
https://github.com/llvm/llvm-project/pull/73859
More information about the llvm-commits
mailing list