[clang-tools-extra] 857f532 - [clang-tidy][NFC] Fix clang-analyzer-optin.cplusplus.UninitializedObject findings

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 27 05:00:03 PDT 2023


Author: Piotr Zegar
Date: 2023-08-27T11:59:03Z
New Revision: 857f532fd5c9de92fe861374ad82e3a36beeb166

URL: https://github.com/llvm/llvm-project/commit/857f532fd5c9de92fe861374ad82e3a36beeb166
DIFF: https://github.com/llvm/llvm-project/commit/857f532fd5c9de92fe861374ad82e3a36beeb166.diff

LOG: [clang-tidy][NFC] Fix clang-analyzer-optin.cplusplus.UninitializedObject findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
index 815c02a15492d1..7a9d04bfa8ba1b 100644
--- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
@@ -75,9 +75,9 @@ static bool paramReferredExactlyOnce(const CXXConstructorDecl *Ctor,
     /// the
     /// given constructor.
     bool hasExactlyOneUsageIn(const CXXConstructorDecl *Ctor) {
-      Count = 0;
+      Count = 0U;
       TraverseDecl(const_cast<CXXConstructorDecl *>(Ctor));
-      return Count == 1;
+      return Count == 1U;
     }
 
   private:
@@ -88,7 +88,7 @@ static bool paramReferredExactlyOnce(const CXXConstructorDecl *Ctor,
       if (const ParmVarDecl *To = dyn_cast<ParmVarDecl>(D->getDecl())) {
         if (To == ParamDecl) {
           ++Count;
-          if (Count > 1) {
+          if (Count > 1U) {
             // No need to look further, used more than once.
             return false;
           }
@@ -98,7 +98,7 @@ static bool paramReferredExactlyOnce(const CXXConstructorDecl *Ctor,
     }
 
     const ParmVarDecl *ParamDecl;
-    unsigned Count;
+    unsigned Count = 0U;
   };
 
   return ExactlyOneUsageVisitor(ParamDecl).hasExactlyOneUsageIn(Ctor);


        


More information about the cfe-commits mailing list