[llvm] 950e697 - [Coverity] Fix uninitialized scalar members
Akshay Khadse via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 20 20:44:15 PDT 2023
Author: Akshay Khadse
Date: 2023-04-21T11:43:53+08:00
New Revision: 950e6979216a99fbe42a72b69137eeda1d5f99fc
URL: https://github.com/llvm/llvm-project/commit/950e6979216a99fbe42a72b69137eeda1d5f99fc
DIFF: https://github.com/llvm/llvm-project/commit/950e6979216a99fbe42a72b69137eeda1d5f99fc.diff
LOG: [Coverity] Fix uninitialized scalar members
This change fixes static code analysis errors
Reviewed By: LuoYuanke
Differential Revision: https://reviews.llvm.org/D148813
Added:
Modified:
llvm/include/llvm/InterfaceStub/IFSStub.h
llvm/include/llvm/Object/ELFObjectFile.h
llvm/include/llvm/Object/WindowsResource.h
llvm/lib/ObjectYAML/XCOFFEmitter.cpp
llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/InterfaceStub/IFSStub.h b/llvm/include/llvm/InterfaceStub/IFSStub.h
index 1196691067333..cd7704146ab96 100644
--- a/llvm/include/llvm/InterfaceStub/IFSStub.h
+++ b/llvm/include/llvm/InterfaceStub/IFSStub.h
@@ -54,9 +54,9 @@ struct IFSSymbol {
explicit IFSSymbol(std::string SymbolName) : Name(std::move(SymbolName)) {}
std::string Name;
std::optional<uint64_t> Size;
- IFSSymbolType Type;
- bool Undefined;
- bool Weak;
+ IFSSymbolType Type = IFSSymbolType::NoType;
+ bool Undefined = false;
+ bool Weak = false;
std::optional<std::string> Warning;
bool operator<(const IFSSymbol &RHS) const { return Name < RHS.Name; }
};
diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h
index db2a80b77807e..d06aed0c25536 100644
--- a/llvm/include/llvm/Object/ELFObjectFile.h
+++ b/llvm/include/llvm/Object/ELFObjectFile.h
@@ -402,7 +402,7 @@ template <class ELFT> class ELFObjectFile : public ELFObjectFileBase {
// This flag is used for classof, to distinguish ELFObjectFile from
// its subclass. If more subclasses will be created, this flag will
// have to become an enum.
- bool isDyldELFObject;
+ bool isDyldELFObject = false;
public:
ELFObjectFile(ELFObjectFile<ELFT> &&Other);
diff --git a/llvm/include/llvm/Object/WindowsResource.h b/llvm/include/llvm/Object/WindowsResource.h
index acda9e2659b1b..ec390a4814cca 100644
--- a/llvm/include/llvm/Object/WindowsResource.h
+++ b/llvm/include/llvm/Object/WindowsResource.h
@@ -234,7 +234,7 @@ class WindowsResourceParser {
struct StringOrID {
bool IsString;
ArrayRef<UTF16> String;
- uint32_t ID;
+ uint32_t ID = ~0u;
StringOrID(uint32_t ID) : IsString(false), ID(ID) {}
StringOrID(ArrayRef<UTF16> String) : IsString(true), String(String) {}
diff --git a/llvm/lib/ObjectYAML/XCOFFEmitter.cpp b/llvm/lib/ObjectYAML/XCOFFEmitter.cpp
index 1ceac6c05893c..7ad878f04c883 100644
--- a/llvm/lib/ObjectYAML/XCOFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/XCOFFEmitter.cpp
@@ -70,7 +70,7 @@ class XCOFFWriter {
support::endian::Writer W;
yaml::ErrorHandler ErrHandler;
StringTableBuilder StrTblBuilder;
- uint64_t StartOffset;
+ uint64_t StartOffset = 0u;
// Map the section name to its corrresponding section index.
DenseMap<StringRef, int16_t> SectionIndexMap = {
{StringRef("N_DEBUG"), XCOFF::N_DEBUG},
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
index 1ee8c2fd5679d..f06b695823fad 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -127,7 +127,7 @@ class X86AsmBackend : public MCAsmBackend {
MCInst PrevInst;
MCBoundaryAlignFragment *PendingBA = nullptr;
std::pair<MCFragment *, size_t> PrevInstPosition;
- bool CanPadInst;
+ bool CanPadInst = false;
uint8_t determinePaddingPrefix(const MCInst &Inst) const;
bool isMacroFused(const MCInst &Cmp, const MCInst &Jcc) const;
More information about the llvm-commits
mailing list