From 5e12f5ab2df101cbdd6942678f26dcdd221c6e18 Mon Sep 17 00:00:00 2001 From: "Manna, Soumi" Date: Thu, 22 Jun 2023 12:05:30 -0700 Subject: [PATCH] [CLANG] Fix uninitialized scalar field issues Reviewed By: erichkeane, steakhal, tahonermann, shafik Differential Revision: https://reviews.llvm.org/D150744 --- clang/include/clang/Analysis/Analyses/Consumed.h | 2 +- clang/include/clang/Parse/Parser.h | 2 +- clang/lib/AST/ExprConstant.cpp | 2 +- clang/lib/CodeGen/CGOpenMPRuntime.h | 2 +- clang/lib/CodeGen/ConstantEmitter.h | 2 +- clang/lib/Serialization/ASTReaderDecl.cpp | 2 +- clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp | 2 +- clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/clang/include/clang/Analysis/Analyses/Consumed.h b/clang/include/clang/Analysis/Analyses/Consumed.h index 7da4f75..3e2788c 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 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 84669e6..c706482 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -1188,7 +1188,7 @@ private: /// 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 8b1e59f..d108a58 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 bd27642..b1164dc 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.h +++ b/clang/lib/CodeGen/CGOpenMPRuntime.h @@ -232,7 +232,7 @@ public: /// 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 1a7a181..a55da0d 100644 --- a/clang/lib/CodeGen/ConstantEmitter.h +++ b/clang/lib/CodeGen/ConstantEmitter.h @@ -42,7 +42,7 @@ private: /// The AST address space where this (non-abstract) initializer is going. /// Used for generating appropriate placeholders. - LangAS DestAddressSpace; + LangAS DestAddressSpace = LangAS::Default; llvm::SmallVector, 4> PlaceholderAddresses; diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 2c1c43d..2f052a5 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 c8ddf3b..ada8023 100644 --- a/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp @@ -184,7 +184,7 @@ private: 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 e9d5d306c..788f287 100644 --- a/clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp @@ -61,7 +61,7 @@ class STLAlgorithmModeling : public Checker { public: STLAlgorithmModeling() = default; - bool AggressiveStdFindModeling; + bool AggressiveStdFindModeling = false; bool evalCall(const CallEvent &Call, CheckerContext &C) const; }; // -- 2.7.4