diff --git a/clang/include/clang/StaticAnalyzer/Core/Checker.h b/clang/include/clang/StaticAnalyzer/Core/Checker.h --- a/clang/include/clang/StaticAnalyzer/Core/Checker.h +++ b/clang/include/clang/StaticAnalyzer/Core/Checker.h @@ -563,18 +563,6 @@ static int Tag; }; -/// A helper class which wraps a boolean value set to false by default. -/// -/// This class should behave exactly like 'bool' except that it doesn't need to -/// be explicitly initialized. -struct DefaultBool { - bool val; - DefaultBool() : val(false) {} - /*implicit*/ operator bool&() { return val; } - /*implicit*/ operator const bool&() const { return val; } - DefaultBool &operator=(bool b) { val = b; return *this; } -}; - } // end ento namespace } // end clang namespace diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -88,11 +88,11 @@ /// The filter is used to filter out the diagnostics which are not enabled by /// the user. struct CStringChecksFilter { - DefaultBool CheckCStringNullArg; - DefaultBool CheckCStringOutOfBounds; - DefaultBool CheckCStringBufferOverlap; - DefaultBool CheckCStringNotNullTerm; - DefaultBool CheckCStringUninitializedRead; + bool CheckCStringNullArg = false; + bool CheckCStringOutOfBounds = false; + bool CheckCStringBufferOverlap = false; + bool CheckCStringNotNullTerm = false; + bool CheckCStringUninitializedRead = false; CheckerNameRef CheckNameCStringNullArg; CheckerNameRef CheckNameCStringOutOfBounds; @@ -2493,4 +2493,4 @@ REGISTER_CHECKER(CStringOutOfBounds) REGISTER_CHECKER(CStringBufferOverlap) REGISTER_CHECKER(CStringNotNullTerm) -REGISTER_CHECKER(CStringUninitializedRead) \ No newline at end of file +REGISTER_CHECKER(CStringUninitializedRead) diff --git a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp @@ -73,7 +73,7 @@ CK_NumCheckKinds }; - DefaultBool ChecksEnabled[CK_NumCheckKinds]; + bool ChecksEnabled[CK_NumCheckKinds] = {false}; // The original core.CallAndMessage checker name. This should rather be an // array, as seen in MallocChecker and CStringChecker. CheckerNameRef OriginalName; diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp --- a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp @@ -36,20 +36,20 @@ namespace { struct ChecksFilter { - DefaultBool check_bcmp; - DefaultBool check_bcopy; - DefaultBool check_bzero; - DefaultBool check_gets; - DefaultBool check_getpw; - DefaultBool check_mktemp; - DefaultBool check_mkstemp; - DefaultBool check_strcpy; - DefaultBool check_DeprecatedOrUnsafeBufferHandling; - DefaultBool check_rand; - DefaultBool check_vfork; - DefaultBool check_FloatLoopCounter; - DefaultBool check_UncheckedReturn; - DefaultBool check_decodeValueOfObjCType; + bool check_bcmp = false; + bool check_bcopy = false; + bool check_bzero = false; + bool check_gets = false; + bool check_getpw = false; + bool check_mktemp = false; + bool check_mkstemp = false; + bool check_strcpy = false; + bool check_DeprecatedOrUnsafeBufferHandling = false; + bool check_rand = false; + bool check_vfork = false; + bool check_FloatLoopCounter = false; + bool check_UncheckedReturn = false; + bool check_decodeValueOfObjCType = false; CheckerNameRef checkName_bcmp; CheckerNameRef checkName_bcopy; diff --git a/clang/lib/StaticAnalyzer/Checkers/CloneChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/CloneChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/CloneChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/CloneChecker.cpp @@ -30,7 +30,7 @@ public: // Checker options. int MinComplexity; - bool ReportNormalClones; + bool ReportNormalClones = false; StringRef IgnoredFilesPattern; private: diff --git a/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp b/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp --- a/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp @@ -108,7 +108,7 @@ void checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const; /// This value is set to true, when the Generics checker is turned on. - DefaultBool CheckGenerics; + bool CheckGenerics = false; CheckerNameRef GenericCheckName; }; diff --git a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp @@ -44,9 +44,9 @@ namespace { struct ChecksFilter { /// Check for missing invalidation method declarations. - DefaultBool check_MissingInvalidationMethod; + bool check_MissingInvalidationMethod = false; /// Check that all ivars are invalidated. - DefaultBool check_InstanceVariableInvalidation; + bool check_InstanceVariableInvalidation = false; CheckerNameRef checkName_MissingInvalidationMethod; CheckerNameRef checkName_InstanceVariableInvalidation; diff --git a/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp @@ -92,7 +92,7 @@ // When this parameter is set to true, the checker assumes all // methods that return NSStrings are unlocalized. Thus, more false // positives will be reported. - DefaultBool IsAggressive; + bool IsAggressive = false; void checkPreObjCMessage(const ObjCMethodCall &msg, CheckerContext &C) const; void checkPostObjCMessage(const ObjCMethodCall &msg, CheckerContext &C) const; diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp @@ -306,9 +306,9 @@ /// functions might free the memory. /// In optimistic mode, the checker assumes that all user-defined functions /// which might free a pointer are annotated. - DefaultBool ShouldIncludeOwnershipAnnotatedFunctions; + bool ShouldIncludeOwnershipAnnotatedFunctions = false; - DefaultBool ShouldRegisterNoOwnershipChangeVisitor; + bool ShouldRegisterNoOwnershipChangeVisitor = false; /// Many checkers are essentially built into this one, so enabling them will /// make MallocChecker perform additional modeling and reporting. @@ -326,7 +326,7 @@ using LeakInfo = std::pair; - DefaultBool ChecksEnabled[CK_NumCheckKinds]; + bool ChecksEnabled[CK_NumCheckKinds] = {false}; CheckerNameRef CheckNames[CK_NumCheckKinds]; void checkPreCall(const CallEvent &Call, CheckerContext &C) const; diff --git a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp @@ -166,7 +166,7 @@ mutable std::unique_ptr NSBT; mutable std::unique_ptr CFBT; public: - DefaultBool ShouldCheckNSError, ShouldCheckCFError; + bool ShouldCheckNSError = false, ShouldCheckCFError = false; CheckerNameRef NSErrorName, CFErrorName; NSOrCFErrorDerefChecker() : NSErrorII(nullptr), CFErrorII(nullptr) {} diff --git a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp @@ -90,7 +90,7 @@ // find warnings about nullability annotations that they have explicitly // added themselves higher priority to fix than warnings on calls to system // libraries. - DefaultBool NoDiagnoseCallsToSystemHeaders; + bool NoDiagnoseCallsToSystemHeaders = false; void checkBind(SVal L, SVal V, const Stmt *S, CheckerContext &C) const; void checkPostStmt(const ExplicitCastExpr *CE, CheckerContext &C) const; @@ -115,7 +115,7 @@ CK_NumCheckKinds }; - DefaultBool ChecksEnabled[CK_NumCheckKinds]; + bool ChecksEnabled[CK_NumCheckKinds] = {false}; CheckerNameRef CheckNames[CK_NumCheckKinds]; mutable std::unique_ptr BTs[CK_NumCheckKinds]; @@ -130,7 +130,7 @@ // NullabilityMap. It is possible to catch errors like passing a null pointer // to a callee that expects nonnull argument without the information that is // stroed in the NullabilityMap. This is an optimization. - DefaultBool NeedTracking; + bool NeedTracking = false; private: class NullabilityBugVisitor : public BugReporterVisitor { diff --git a/clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -78,7 +78,7 @@ CK_C11LockChecker, CK_NumCheckKinds }; - DefaultBool ChecksEnabled[CK_NumCheckKinds]; + bool ChecksEnabled[CK_NumCheckKinds] = {false}; CheckerNameRef CheckNames[CK_NumCheckKinds]; private: diff --git a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp --- a/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp @@ -48,7 +48,7 @@ public: // Whether the checker should model for null dereferences of smart pointers. - DefaultBool ModelSmartPtrDereference; + bool ModelSmartPtrDereference = false; bool evalCall(const CallEvent &Call, CheckerContext &C) const; void checkPreCall(const CallEvent &Call, CheckerContext &C) const; void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const; diff --git a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp @@ -42,7 +42,7 @@ CK_NumCheckKinds }; - DefaultBool ChecksEnabled[CK_NumCheckKinds]; + bool ChecksEnabled[CK_NumCheckKinds] = {false}; CheckerNameRef CheckNames[CK_NumCheckKinds]; void checkPreCall(const CallEvent &Call, CheckerContext &C) const; diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -563,7 +563,7 @@ CK_StdCLibraryFunctionsTesterChecker, CK_NumCheckKinds }; - DefaultBool ChecksEnabled[CK_NumCheckKinds]; + bool ChecksEnabled[CK_NumCheckKinds] = {false}; CheckerNameRef CheckNames[CK_NumCheckKinds]; bool DisplayLoadedSummaries = false; diff --git a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp @@ -43,7 +43,7 @@ mutable Optional Val_O_CREAT; public: - DefaultBool CheckMisuse, CheckPortability; + bool CheckMisuse = false, CheckPortability = false; void checkPreStmt(const CallExpr *CE, CheckerContext &C) const; diff --git a/clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/ValistChecker.cpp @@ -46,7 +46,7 @@ CK_NumCheckKinds }; - DefaultBool ChecksEnabled[CK_NumCheckKinds]; + bool ChecksEnabled[CK_NumCheckKinds] = {false}; CheckerNameRef CheckNames[CK_NumCheckKinds]; void checkPreStmt(const VAArgExpr *VAA, CheckerContext &C) const;