Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marked all 4146 warnings. Many fixed. Some are not proper solutions b… #7171

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alsepkow
Copy link
Contributor

@alsepkow alsepkow commented Mar 1, 2025

…ut this will help them all show up in a PR for discussion

…ut this will help them all show up in a PR for discussion
Copy link
Contributor

github-actions bot commented Mar 1, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 0a1143572d107c8b6980df092b84a79190ec1fbd 901e583383ace8a06297edd45d6e4d9f9a102a6c -- include/llvm/ADT/StringExtras.h include/llvm/CodeGen/SelectionDAGNodes.h include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h include/llvm/Support/BlockFrequency.h include/llvm/Support/LEB128.h lib/Analysis/BasicAliasAnalysis.cpp lib/Analysis/ConstantFolding.cpp lib/Analysis/InstructionSimplify.cpp lib/Analysis/LoopAccessAnalysis.cpp lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Writer/BitcodeWriter.cpp lib/DXIL/DxilUtil.cpp lib/Support/APFloat.cpp lib/Support/APInt.cpp lib/Support/DataExtractor.cpp lib/Support/StringRef.cpp lib/Support/TimeValue.cpp lib/Support/raw_ostream.cpp lib/Transforms/IPO/DeadArgumentElimination.cpp lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp lib/Transforms/InstCombine/InstructionCombining.cpp lib/Transforms/Scalar/LoadCombine.cpp lib/Transforms/Scalar/LoopStrengthReduce.cpp tools/clang/include/clang/AST/Expr.h tools/clang/lib/AST/Expr.cpp tools/clang/lib/AST/ExprConstant.cpp tools/clang/lib/AST/MicrosoftMangle.cpp tools/clang/lib/AST/SelectorLocationsKind.cpp tools/clang/lib/CodeGen/CGExprScalar.cpp tools/clang/lib/CodeGen/CoverageMappingGen.cpp tools/clang/lib/CodeGen/ItaniumCXXABI.cpp tools/clang/lib/CodeGen/TargetInfo.cpp tools/clang/lib/Format/Format.cpp tools/clang/lib/Lex/Lexer.cpp tools/clang/lib/Lex/LiteralSupport.cpp tools/clang/lib/Rewrite/Rewriter.cpp tools/clang/lib/Sema/SemaDecl.cpp tools/clang/lib/Sema/SemaExpr.cpp tools/clang/lib/Sema/SemaType.cpp utils/TableGen/FixedLenDecoderEmitter.cpp
View the diff from clang-format here.
diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h
index e53ff8b93..27a57f5cc 100644
--- a/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -879,7 +879,8 @@ inline SDValue::SDValue(SDNode *node, unsigned resno)
     : Node(node), ResNo(resno) {
   assert((!Node || ResNo < Node->getNumValues()) &&
          "Invalid result number for the given node!");
-  assert(ResNo < static_cast<unsigned int>(-2) && "Cannot use result numbers reserved for DenseMaps.");
+  assert(ResNo < static_cast<unsigned int>(-2) &&
+         "Cannot use result numbers reserved for DenseMaps.");
 }
 
 inline unsigned SDValue::getOpcode() const {
diff --git a/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h b/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
index 464f1a0d6..916384c14 100644
--- a/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
+++ b/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
@@ -34,7 +34,7 @@ private:
   struct Range {
     explicit Range(uint64_t LowPC = UINT64_MAX, uint64_t HighPC = UINT64_MAX,
                    uint32_t CUOffset = UINT32_MAX)
-      : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {}
+        : LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {}
 
     void setHighPC(uint64_t HighPC) {
       if (HighPC == UINT64_MAX || HighPC <= LowPC)
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index d3908494b..2855c3f59 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1118,7 +1118,7 @@ AliasResult BasicAliasAnalysis::aliasGEP(
       if (V1Size != MemoryLocation::UnknownSize &&
           V2Size != MemoryLocation::UnknownSize) {
         const int64_t GEP1BaseOffsetNeg = -GEP1BaseOffset;
-        if (static_cast<uint64_t>(GEP1BaseOffsetNeg)< V1Size)
+        if (static_cast<uint64_t>(GEP1BaseOffsetNeg) < V1Size)
           return PartialAlias;
         return NoAlias;
       }
diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp
index 8bf9cb4a8..fdeb11cf7 100644
--- a/lib/Support/APFloat.cpp
+++ b/lib/Support/APFloat.cpp
@@ -446,11 +446,11 @@ ulpsFromBoundary(const integerPart *parts, unsigned int bits, bool isNearest)
       if (~parts[count])
         return ~(integerPart) 0; /* A lot.  */
 
-    // Compiler warning 4146 'unary minus operator applied to unsigned type, result still unsigned'
-    // for original statement: "return -parts[0]". 
-    // This warning is now being enforced as an error for MSVC builds.
-    // This explicit cast and unary minus operator mitigates the warning while 
-    // preserving the original logic.
+    // Compiler warning 4146 'unary minus operator applied to unsigned type,
+    // result still unsigned' for original statement: "return -parts[0]". This
+    // warning is now being enforced as an error for MSVC builds. This explicit
+    // cast and unary minus operator mitigates the warning while preserving the
+    // original logic.
     int64_t parts0 = -static_cast<int64_t>(parts[0]);
     return parts0;
   }
diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp
index c59c7ca01..df7dcbc46 100644
--- a/lib/Support/APInt.cpp
+++ b/lib/Support/APInt.cpp
@@ -2193,9 +2193,9 @@ void APInt::toString(SmallVectorImpl<char> &Str, unsigned Radix,
       } else {
         Str.push_back('-');
 
-        // std::abs(INT64_MIN) is undefined on 2's complement systems because 
-        // abs(INT64_MIN) can be 1 greater than INT64_MAX. Add 1 to make 'I' 
-        // larger so std::abs(I) is defined. 'N' is unsigned so we can safely 
+        // std::abs(INT64_MIN) is undefined on 2's complement systems because
+        // abs(INT64_MIN) can be 1 greater than INT64_MAX. Add 1 to make 'I'
+        // larger so std::abs(I) is defined. 'N' is unsigned so we can safely
         // add that 1 back to get the true absolute value.
         N = std::abs(I + 1) + 1;
       }
diff --git a/lib/Support/TimeValue.cpp b/lib/Support/TimeValue.cpp
index 264699142..3a80442e5 100644
--- a/lib/Support/TimeValue.cpp
+++ b/lib/Support/TimeValue.cpp
@@ -19,8 +19,7 @@ using namespace sys;
 
 const TimeValue::SecondsType
   TimeValue::PosixZeroTimeSeconds = -946684800;
-const TimeValue::SecondsType
-  TimeValue::Win32ZeroTimeSeconds = -12591158400;
+const TimeValue::SecondsType TimeValue::Win32ZeroTimeSeconds = -12591158400;
 
 void
 TimeValue::normalize( void ) {
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp
index 29798d11b..0a508ee06 100644
--- a/lib/Support/raw_ostream.cpp
+++ b/lib/Support/raw_ostream.cpp
@@ -134,15 +134,15 @@ raw_ostream &raw_ostream::operator<<(unsigned long N) {
 }
 
 raw_ostream &raw_ostream::operator<<(long N) {
-  // A positive signed long has the same value when casted to its unsigned 
+  // A positive signed long has the same value when casted to its unsigned
   // counterpart.
   unsigned long UN = static_cast<unsigned long>(N);
   if (N < 0 && writeBase == 10) {
     *this << '-';
 
-    // std::abs(LONG_MIN) is undefined on 2's complement systems because 
-    // abs(LONG_MIN) can be 1 greater than LONG_MAX. Add 1 to make it 
-    // larger so std::abs is defined. 'UN' is unsigned so we can safely 
+    // std::abs(LONG_MIN) is undefined on 2's complement systems because
+    // abs(LONG_MIN) can be 1 greater than LONG_MAX. Add 1 to make it
+    // larger so std::abs is defined. 'UN' is unsigned so we can safely
     // add that 1 back to get the true absolute value.
     UN = std::abs(N + 1) + 1;
   }
@@ -176,15 +176,15 @@ raw_ostream &raw_ostream::operator<<(unsigned long long N) {
 }
 
 raw_ostream &raw_ostream::operator<<(long long N) {
-  // A positive signed long long has the same value when casted to its unsigned 
+  // A positive signed long long has the same value when casted to its unsigned
   // counterpart.
   unsigned long long UN = static_cast<unsigned long long>(N);
   if (N < 0 && writeBase == 10) {
     *this << '-';
 
-    // std::abs(LLONG_MIN) is undefined on 2's complement systems because 
-    // abs(LLONG_MIN) can be 1 greater than LONG_MAX. Add 1 to make it 
-    // larger so std::abs is defined. 'UN' is unsigned so we can safely 
+    // std::abs(LLONG_MIN) is undefined on 2's complement systems because
+    // abs(LLONG_MIN) can be 1 greater than LONG_MAX. Add 1 to make it
+    // larger so std::abs is defined. 'UN' is unsigned so we can safely
     // add that 1 back to get the true absolute value.
     UN = std::abs(N + 1) + 1;
   }
@@ -484,13 +484,14 @@ raw_ostream &raw_ostream::operator<<(const FormattedNumber &FN) {
     char *EndPtr = NumberBuffer+sizeof(NumberBuffer);
     char *CurPtr = EndPtr;
     bool Neg = (FN.DecValue < 0);
-    
-    // We use "std::abs(FN.DecValue + 1) + 1" to safely handle the case when 
-    // FN.DecValue == INT64_MIN because the absolute value of INT64_MIN is 
-    // undefined on 2's complement systems. Adding 1 to the negative value 
-    // puts it back into a safe range for std::abs. And then we adjust to the 
+
+    // We use "std::abs(FN.DecValue + 1) + 1" to safely handle the case when
+    // FN.DecValue == INT64_MIN because the absolute value of INT64_MIN is
+    // undefined on 2's complement systems. Adding 1 to the negative value
+    // puts it back into a safe range for std::abs. And then we adjust to the
     // correct value by adding 1 again to the positive value.
-    uint64_t N = Neg ? static_cast<uint64_t>(std::abs(FN.DecValue + 1) + 1) : FN.DecValue;
+    uint64_t N = Neg ? static_cast<uint64_t>(std::abs(FN.DecValue + 1) + 1)
+                     : FN.DecValue;
     while (N) {
       *--CurPtr = '0' + char(N % 10);
       N /= 10;
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 287c9d01a..147d52f27 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -3756,8 +3756,7 @@ void LSRInstance::GenerateCrossUseConstantOffsets() {
       if (F.ScaledReg == OrigReg) {
         int64_t Offset = (uint64_t)F.BaseOffset + Imm * (uint64_t)F.Scale;
         // Don't create 50 + reg(-50).
-        if (F.referencesReg(SE.getSCEV(
-                   ConstantInt::get(IntTy, -Offset))))
+        if (F.referencesReg(SE.getSCEV(ConstantInt::get(IntTy, -Offset))))
           continue;
         Formula NewF = F;
         NewF.BaseOffset = Offset;
@@ -4610,8 +4609,8 @@ Value *LSRInstance::Expand(const LSRFixup &LF, const Formula &F,
       assert((F.Scale == 0 || F.Scale == 1) &&
              "ICmp does not support folding a global value and "
              "a scale at the same time!");
-      Constant *C = ConstantInt::getSigned(SE.getEffectiveSCEVType(OpTy),
-                                           -Offset);
+      Constant *C =
+          ConstantInt::getSigned(SE.getEffectiveSCEVType(OpTy), -Offset);
       if (C->getType() != OpTy)
         C = ConstantExpr::getCast(CastInst::getCastOpcode(C, false,
                                                           OpTy, false),
diff --git a/tools/clang/lib/AST/Expr.cpp b/tools/clang/lib/AST/Expr.cpp
index d2f8278b7..2bbb1ea37 100644
--- a/tools/clang/lib/AST/Expr.cpp
+++ b/tools/clang/lib/AST/Expr.cpp
@@ -3879,25 +3879,20 @@ GenericSelectionExpr::GenericSelectionExpr(const ASTContext &Context,
   std::copy(AssocExprs.begin(), AssocExprs.end(), SubExprs+END_EXPR);
 }
 
-GenericSelectionExpr::GenericSelectionExpr(const ASTContext &Context,
-                               SourceLocation GenericLoc, Expr *ControllingExpr,
-                               ArrayRef<TypeSourceInfo*> AssocTypes,
-                               ArrayRef<Expr*> AssocExprs,
-                               SourceLocation DefaultLoc,
-                               SourceLocation RParenLoc,
-                               bool ContainsUnexpandedParameterPack)
-  : Expr(GenericSelectionExprClass,
-         Context.DependentTy,
-         VK_RValue,
-         OK_Ordinary,
-         /*isTypeDependent=*/true,
-         /*isValueDependent=*/true,
-         /*isInstantiationDependent=*/true,
-         ContainsUnexpandedParameterPack),
-    AssocTypes(new (Context) TypeSourceInfo*[AssocTypes.size()]),
-    SubExprs(new (Context) Stmt*[END_EXPR+AssocExprs.size()]),
-    NumAssocs(AssocExprs.size()), ResultIndex(UINT_MAX), GenericLoc(GenericLoc),
-    DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
+GenericSelectionExpr::GenericSelectionExpr(
+    const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr,
+    ArrayRef<TypeSourceInfo *> AssocTypes, ArrayRef<Expr *> AssocExprs,
+    SourceLocation DefaultLoc, SourceLocation RParenLoc,
+    bool ContainsUnexpandedParameterPack)
+    : Expr(GenericSelectionExprClass, Context.DependentTy, VK_RValue,
+           OK_Ordinary,
+           /*isTypeDependent=*/true,
+           /*isValueDependent=*/true,
+           /*isInstantiationDependent=*/true, ContainsUnexpandedParameterPack),
+      AssocTypes(new(Context) TypeSourceInfo *[AssocTypes.size()]),
+      SubExprs(new(Context) Stmt *[END_EXPR + AssocExprs.size()]),
+      NumAssocs(AssocExprs.size()), ResultIndex(UINT_MAX),
+      GenericLoc(GenericLoc), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
   SubExprs[CONTROLLING] = ControllingExpr;
   assert(AssocTypes.size() == AssocExprs.size());
   std::copy(AssocTypes.begin(), AssocTypes.end(), this->AssocTypes);
diff --git a/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp b/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 0a298f2d4..f39ec6d49 100644
--- a/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -639,7 +639,7 @@ llvm::Constant *
 ItaniumCXXABI::EmitNullMemberPointer(const MemberPointerType *MPT) {
   // Itanium C++ ABI 2.3:
   //   A NULL pointer is represented as -1.
-  if (MPT->isMemberDataPointer()) 
+  if (MPT->isMemberDataPointer())
     return llvm::ConstantInt::get(CGM.PtrDiffTy, -1LL, /*isSigned=*/true);
 
   llvm::Constant *Zero = llvm::ConstantInt::get(CGM.PtrDiffTy, 0);
diff --git a/tools/clang/lib/CodeGen/TargetInfo.cpp b/tools/clang/lib/CodeGen/TargetInfo.cpp
index 26f31cdd7..fdab1673f 100644
--- a/tools/clang/lib/CodeGen/TargetInfo.cpp
+++ b/tools/clang/lib/CodeGen/TargetInfo.cpp
@@ -1283,7 +1283,8 @@ llvm::Value *X86_32ABIInfo::EmitVAArg(llvm::Value *VAListAddr, QualType Ty,
     Addr = CGF.Builder.CreateGEP(Addr, Offset);
     llvm::Value *AsInt = CGF.Builder.CreatePtrToInt(Addr,
                                                     CGF.Int32Ty);
-    llvm::Value *Mask = llvm::ConstantInt::get(CGF.Int32Ty, -static_cast<int>(Align));
+    llvm::Value *Mask =
+        llvm::ConstantInt::get(CGF.Int32Ty, -static_cast<int>(Align));
     Addr = CGF.Builder.CreateIntToPtr(CGF.Builder.CreateAnd(AsInt, Mask),
                                       Addr->getType(),
                                       "ap.cur.aligned");
@@ -2849,7 +2850,8 @@ static llvm::Value *EmitVAArgFromMemory(llvm::Value *VAListAddr,
     overflow_arg_area = CGF.Builder.CreateGEP(overflow_arg_area, Offset);
     llvm::Value *AsInt = CGF.Builder.CreatePtrToInt(overflow_arg_area,
                                                     CGF.Int64Ty);
-    llvm::Value *Mask = llvm::ConstantInt::get(CGF.Int64Ty, -static_cast<int>(Align));
+    llvm::Value *Mask =
+        llvm::ConstantInt::get(CGF.Int64Ty, -static_cast<int>(Align));
     overflow_arg_area =
       CGF.Builder.CreateIntToPtr(CGF.Builder.CreateAnd(AsInt, Mask),
                                  overflow_arg_area->getType(),
diff --git a/tools/clang/lib/Format/Format.cpp b/tools/clang/lib/Format/Format.cpp
index 2cff5e964..ad8ad87b6 100644
--- a/tools/clang/lib/Format/Format.cpp
+++ b/tools/clang/lib/Format/Format.cpp
@@ -1049,7 +1049,8 @@ private:
     FormatTok = new (Allocator.Allocate()) FormatToken;
     readRawToken(*FormatTok);
     SourceLocation WhitespaceStart =
-        FormatTok->Tok.getLocation().getLocWithOffset(-static_cast<int>(TrailingWhitespace));
+        FormatTok->Tok.getLocation().getLocWithOffset(
+            -static_cast<int>(TrailingWhitespace));
     FormatTok->IsFirst = IsFirstToken;
     IsFirstToken = false;
 
diff --git a/tools/clang/lib/Lex/Lexer.cpp b/tools/clang/lib/Lex/Lexer.cpp
index aa1ae8100..6eeef2d7e 100644
--- a/tools/clang/lib/Lex/Lexer.cpp
+++ b/tools/clang/lib/Lex/Lexer.cpp
@@ -480,7 +480,8 @@ static SourceLocation getBeginningOfFileToken(SourceLocation Loc,
   }
   
   // Create a lexer starting at the beginning of this token.
-  SourceLocation LexerStartLoc = Loc.getLocWithOffset(-static_cast<int>(LocInfo.second));
+  SourceLocation LexerStartLoc =
+      Loc.getLocWithOffset(-static_cast<int>(LocInfo.second));
   Lexer TheLexer(LexerStartLoc, LangOpts, BufStart, LexStart, Buffer.end());
   TheLexer.SetCommentRetentionState(true);
   
diff --git a/tools/clang/lib/Lex/LiteralSupport.cpp b/tools/clang/lib/Lex/LiteralSupport.cpp
index 20aceeb66..cee7a8d6b 100644
--- a/tools/clang/lib/Lex/LiteralSupport.cpp
+++ b/tools/clang/lib/Lex/LiteralSupport.cpp
@@ -142,7 +142,8 @@ static unsigned ProcessCharEscape(const char *ThisTokBegin,
     bool Overflow = false;
     for (; ThisTokBuf != ThisTokEnd; ++ThisTokBuf) {
       int CharVal = llvm::hexDigitValue(ThisTokBuf[0]);
-      if (CharVal == UINT_MAX) break;
+      if (CharVal == UINT_MAX)
+        break;
       // About to shift out a digit?
       if (ResultChar & 0xF0000000)
         Overflow = true;
@@ -279,7 +280,8 @@ static bool ProcessUCNEscape(const char *ThisTokBegin, const char *&ThisTokBuf,
   unsigned short UcnLenSave = UcnLen;
   for (; ThisTokBuf != ThisTokEnd && UcnLenSave; ++ThisTokBuf, UcnLenSave--) {
     int CharVal = llvm::hexDigitValue(ThisTokBuf[0]);
-    if (CharVal == UINT_MAX) break;
+    if (CharVal == UINT_MAX)
+      break;
     UcnVal <<= 4;
     UcnVal |= CharVal;
   }
diff --git a/tools/clang/lib/Rewrite/Rewriter.cpp b/tools/clang/lib/Rewrite/Rewriter.cpp
index aabe94e23..e7fda1fa8 100644
--- a/tools/clang/lib/Rewrite/Rewriter.cpp
+++ b/tools/clang/lib/Rewrite/Rewriter.cpp
@@ -86,7 +86,8 @@ void RewriteBuffer::RemoveText(unsigned OrigOffset, unsigned Size,
     }
     if (posI != end() && *posI == '\n') {
       Buffer.erase(curLineStartOffs, lineSize + 1/* + '\n'*/);
-      AddReplaceDelta(curLineStartOffs, -static_cast<int>((lineSize + 1/* + '\n'*/)));
+      AddReplaceDelta(curLineStartOffs,
+                      -static_cast<int>((lineSize + 1 /* + '\n'*/)));
     }
   }
 }
diff --git a/utils/TableGen/FixedLenDecoderEmitter.cpp b/utils/TableGen/FixedLenDecoderEmitter.cpp
index b96e05bbc..7d8c9a5d2 100644
--- a/utils/TableGen/FixedLenDecoderEmitter.cpp
+++ b/utils/TableGen/FixedLenDecoderEmitter.cpp
@@ -547,10 +547,10 @@ void Filter::recurse() {
 
     // Delegates to an inferior filter chooser for further processing on this
     // group of instructions whose segment values are variable.
-    FilterChooserMap.insert(
-        std::make_pair(UINT_MAX, llvm::make_unique<FilterChooser>(
-                                Owner->AllInstructions, VariableInstructions,
-                                Owner->Operands, BitValueArray, *Owner)));
+    FilterChooserMap.insert(std::make_pair(
+        UINT_MAX, llvm::make_unique<FilterChooser>(
+                      Owner->AllInstructions, VariableInstructions,
+                      Owner->Operands, BitValueArray, *Owner)));
   }
 
   // No need to recurse for a singleton filtered instruction.
  • Check this box to apply formatting changes to this branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

Successfully merging this pull request may close these issues.

1 participant