[clang] 5e12f5a - [CLANG] Fix uninitialized scalar field issues
via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 22 12:10:15 PDT 2023
Author: Manna, Soumi
Date: 2023-06-22T12:09:14-07:00
New Revision: 5e12f5ab2df101cbdd6942678f26dcdd221c6e18
URL: https://github.com/llvm/llvm-project/commit/5e12f5ab2df101cbdd6942678f26dcdd221c6e18
DIFF: https://github.com/llvm/llvm-project/commit/5e12f5ab2df101cbdd6942678f26dcdd221c6e18.diff
LOG: [CLANG] Fix uninitialized scalar field issues
Reviewed By: erichkeane, steakhal, tahonermann, shafik
Differential Revision: https://reviews.llvm.org/D150744
Added:
Modified:
clang/include/clang/Analysis/Analyses/Consumed.h
clang/include/clang/Parse/Parser.h
clang/lib/AST/ExprConstant.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/ConstantEmitter.h
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Analysis/Analyses/Consumed.h b/clang/include/clang/Analysis/Analyses/Consumed.h
index 7da4f75ecc027..3e2788cac3c9c 100644
--- a/clang/include/clang/Analysis/Analyses/Consumed.h
+++ b/clang/include/clang/Analysis/Analyses/Consumed.h
@@ -244,7 +244,7 @@ namespace consumed {
ConsumedBlockInfo BlockInfo;
std::unique_ptr<ConsumedStateMap> CurrStates;
- ConsumedState ExpectedReturnState;
+ ConsumedState ExpectedReturnState = CS_None;
void determineExpectedReturnState(AnalysisDeclContext &AC,
const FunctionDecl *D);
diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h
index 84669e68a696a..c706482aec983 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1188,7 +1188,7 @@ class Parser : public CodeCompletionHandler {
/// RAII object used to modify the scope flags for the current scope.
class ParseScopeFlags {
Scope *CurScope;
- unsigned OldFlags;
+ unsigned OldFlags = 0;
ParseScopeFlags(const ParseScopeFlags &) = delete;
void operator=(const ParseScopeFlags &) = delete;
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 8b1e59f13d1f3..d108a58a2ed66 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -1294,7 +1294,7 @@ namespace {
class SpeculativeEvaluationRAII {
EvalInfo *Info = nullptr;
Expr::EvalStatus OldStatus;
- unsigned OldSpeculativeEvaluationDepth;
+ unsigned OldSpeculativeEvaluationDepth = 0;
void moveFromAndCancel(SpeculativeEvaluationRAII &&Other) {
Info = Other.Info;
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.h b/clang/lib/CodeGen/CGOpenMPRuntime.h
index bd27642867719..b1164dc3f7290 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -232,7 +232,7 @@ class CGOpenMPRuntime {
/// as those marked as `omp declare target`.
class DisableAutoDeclareTargetRAII {
CodeGenModule &CGM;
- bool SavedShouldMarkAsGlobal;
+ bool SavedShouldMarkAsGlobal = false;
public:
DisableAutoDeclareTargetRAII(CodeGenModule &CGM);
diff --git a/clang/lib/CodeGen/ConstantEmitter.h b/clang/lib/CodeGen/ConstantEmitter.h
index 1a7a181ca7f03..a55da0dcad792 100644
--- a/clang/lib/CodeGen/ConstantEmitter.h
+++ b/clang/lib/CodeGen/ConstantEmitter.h
@@ -42,7 +42,7 @@ class ConstantEmitter {
/// The AST address space where this (non-abstract) initializer is going.
/// Used for generating appropriate placeholders.
- LangAS DestAddressSpace;
+ LangAS DestAddressSpace = LangAS::Default;
llvm::SmallVector<std::pair<llvm::Constant *, llvm::GlobalVariable*>, 4>
PlaceholderAddresses;
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 2c1c43dad1603..2f052a5817a6f 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -89,7 +89,7 @@ namespace clang {
using RecordData = ASTReader::RecordData;
TypeID DeferredTypeID = 0;
- unsigned AnonymousDeclNumber;
+ unsigned AnonymousDeclNumber = 0;
GlobalDeclID NamedDeclForTagDecl = 0;
IdentifierInfo *TypedefNameForLinkage = nullptr;
diff --git a/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
index c8ddf3b2c14f1..ada802394758d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
@@ -184,7 +184,7 @@ class MoveChecker
bool Found;
};
- AggressivenessKind Aggressiveness;
+ AggressivenessKind Aggressiveness = AK_KnownsAndLocals;
public:
void setAggressiveness(StringRef Str, CheckerManager &Mgr) {
diff --git a/clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
index e9d5d306cc06b..788f2875863c3 100644
--- a/clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
@@ -61,7 +61,7 @@ class STLAlgorithmModeling : public Checker<eval::Call> {
public:
STLAlgorithmModeling() = default;
- bool AggressiveStdFindModeling;
+ bool AggressiveStdFindModeling = false;
bool evalCall(const CallEvent &Call, CheckerContext &C) const;
}; //
More information about the cfe-commits
mailing list