[llvm] 6621972 - [Coverity] Fix uninitialized scalar members in TableGen
Akshay Khadse via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 21 02:42:44 PDT 2023
Author: Akshay Khadse
Date: 2023-04-21T17:42:33+08:00
New Revision: 66219728e344626201e83ff9e1c7db3ede2b12fe
URL: https://github.com/llvm/llvm-project/commit/66219728e344626201e83ff9e1c7db3ede2b12fe
DIFF: https://github.com/llvm/llvm-project/commit/66219728e344626201e83ff9e1c7db3ede2b12fe.diff
LOG: [Coverity] Fix uninitialized scalar members in TableGen
This change fixes static code analysis warnings
Reviewed By: skan
Differential Revision: https://reviews.llvm.org/D148815
Added:
Modified:
llvm/utils/TableGen/AsmMatcherEmitter.cpp
llvm/utils/TableGen/CallingConvEmitter.cpp
llvm/utils/TableGen/CodeEmitterGen.cpp
llvm/utils/TableGen/CodeGenRegisters.h
llvm/utils/TableGen/DAGISelMatcher.h
llvm/utils/TableGen/DXILEmitter.cpp
llvm/utils/TableGen/OptParserEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
index 2fb35e712a758..8f3c98b4303f6 100644
--- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp
@@ -534,7 +534,7 @@ struct MatchableInfo {
std::string ConversionFnKind;
/// If this instruction is deprecated in some form.
- bool HasDeprecation;
+ bool HasDeprecation = false;
/// If this is an alias, this is use to determine whether or not to using
/// the conversion function defined by the instruction's AsmMatchConverter
diff --git a/llvm/utils/TableGen/CallingConvEmitter.cpp b/llvm/utils/TableGen/CallingConvEmitter.cpp
index 49d4f3196e664..2fd877f4d4aa4 100644
--- a/llvm/utils/TableGen/CallingConvEmitter.cpp
+++ b/llvm/utils/TableGen/CallingConvEmitter.cpp
@@ -20,9 +20,9 @@ using namespace llvm;
namespace {
class CallingConvEmitter {
RecordKeeper &Records;
- unsigned Counter;
+ unsigned Counter = 0u;
std::string CurrentAction;
- bool SwiftAction;
+ bool SwiftAction = false;
std::map<std::string, std::set<std::string>> AssignedRegsMap;
std::map<std::string, std::set<std::string>> AssignedSwiftRegsMap;
diff --git a/llvm/utils/TableGen/CodeEmitterGen.cpp b/llvm/utils/TableGen/CodeEmitterGen.cpp
index 66ef71a90a93d..cf42c3c4b0fd3 100644
--- a/llvm/utils/TableGen/CodeEmitterGen.cpp
+++ b/llvm/utils/TableGen/CodeEmitterGen.cpp
@@ -56,8 +56,8 @@ class CodeEmitterGen {
void emitInstructionBaseValues(
raw_ostream &o, ArrayRef<const CodeGenInstruction *> NumberedInstructions,
CodeGenTarget &Target, int HwMode = -1);
- unsigned BitWidth;
- bool UseAPInt;
+ unsigned BitWidth = 0u;
+ bool UseAPInt = false;
};
// If the VarBitInit at position 'bit' matches the specified variable then
diff --git a/llvm/utils/TableGen/CodeGenRegisters.h b/llvm/utils/TableGen/CodeGenRegisters.h
index 7638816811e8f..e0d401e51ebb4 100644
--- a/llvm/utils/TableGen/CodeGenRegisters.h
+++ b/llvm/utils/TableGen/CodeGenRegisters.h
@@ -154,10 +154,10 @@ namespace llvm {
Record *TheDef;
unsigned EnumValue;
std::vector<int64_t> CostPerUse;
- bool CoveredBySubRegs;
- bool HasDisjunctSubRegs;
- bool Artificial;
- bool Constant;
+ bool CoveredBySubRegs = true;
+ bool HasDisjunctSubRegs = false;
+ bool Artificial = true;
+ bool Constant = false;
// Map SubRegIndex -> Register.
typedef std::map<CodeGenSubRegIndex *, CodeGenRegister *,
diff --git a/llvm/utils/TableGen/DAGISelMatcher.h b/llvm/utils/TableGen/DAGISelMatcher.h
index 037e778140cfe..826080f2b3ed0 100644
--- a/llvm/utils/TableGen/DAGISelMatcher.h
+++ b/llvm/utils/TableGen/DAGISelMatcher.h
@@ -47,7 +47,7 @@ class Matcher {
// The next matcher node that is executed after this one. Null if this is the
// last stage of a match.
std::unique_ptr<Matcher> Next;
- size_t Size; // Size in bytes of matcher and all its children (if any).
+ size_t Size = 0; // Size in bytes of matcher and all its children (if any).
virtual void anchor();
public:
enum KindTy {
diff --git a/llvm/utils/TableGen/DXILEmitter.cpp b/llvm/utils/TableGen/DXILEmitter.cpp
index 51924ff76524b..b294c66007f84 100644
--- a/llvm/utils/TableGen/DXILEmitter.cpp
+++ b/llvm/utils/TableGen/DXILEmitter.cpp
@@ -26,8 +26,8 @@ using namespace llvm::dxil;
namespace {
struct DXILShaderModel {
- int Major;
- int Minor;
+ int Major = 0;
+ int Minor = 0;
};
struct DXILParam {
@@ -56,12 +56,13 @@ struct DXILOperationData {
// memory,ro=only reads from memory
StringRef Intrinsic; // The llvm intrinsic map to DXILOp. Default is "" which
// means no map exist
- bool IsDeriv; // whether this is some kind of derivative
- bool IsGradient; // whether this requires a gradient calculation
- bool IsFeedback; // whether this is a sampler feedback op
- bool IsWave; // whether this requires in-wave, cross-lane functionality
- bool RequiresUniformInputs; // whether this operation requires that all
- // of its inputs are uniform across the wave
+ bool IsDeriv = false; // whether this is some kind of derivative
+ bool IsGradient = false; // whether this requires a gradient calculation
+ bool IsFeedback = false; // whether this is a sampler feedback op
+ bool IsWave = false; // whether this requires in-wave, cross-lane functionality
+ bool RequiresUniformInputs = false; // whether this operation requires that
+ // all of its inputs are uniform across
+ // the wave
SmallVector<StringRef, 4>
ShaderStages; // shader stages to which this applies, empty for all.
DXILShaderModel ShaderModel; // minimum shader model required
diff --git a/llvm/utils/TableGen/OptParserEmitter.cpp b/llvm/utils/TableGen/OptParserEmitter.cpp
index 514346c843d1a..a04680b5d91e1 100644
--- a/llvm/utils/TableGen/OptParserEmitter.cpp
+++ b/llvm/utils/TableGen/OptParserEmitter.cpp
@@ -64,7 +64,7 @@ class MarshallingInfo {
public:
static constexpr const char *MacroName = "OPTION_WITH_MARSHALLING";
const Record &R;
- bool ShouldAlwaysEmit;
+ bool ShouldAlwaysEmit = false;
StringRef MacroPrefix;
StringRef KeyPath;
StringRef DefaultValue;
More information about the llvm-commits
mailing list