[clang] 1189e87 - [CodeGen] Fix a warning

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 3 09:55:53 PDT 2024


Author: Kazu Hirata
Date: 2024-04-03T09:55:45-07:00
New Revision: 1189e87951e59a81ee097eae847c06008276fef1

URL: https://github.com/llvm/llvm-project/commit/1189e87951e59a81ee097eae847c06008276fef1
DIFF: https://github.com/llvm/llvm-project/commit/1189e87951e59a81ee097eae847c06008276fef1.diff

LOG: [CodeGen] Fix a warning

This patch fixes:

  clang/lib/CodeGen/CGExpr.cpp:5607:11: error: variable 'Result' is
  used uninitialized whenever 'if' condition is false
  [-Werror,-Wsometimes-uninitialized]

Added: 
    

Modified: 
    clang/lib/CodeGen/CGExpr.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index f70324d11a7562..0c7f48fe00603d 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -5601,7 +5601,7 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
       EmitNullabilityCheck(LV, RV.getScalarVal(), E->getExprLoc());
 
     if (LV.isBitField()) {
-      llvm::Value *Result;
+      llvm::Value *Result = nullptr;
       // If bitfield sanitizers are enabled we want to use the result
       // to check whether a truncation or sign change has occurred.
       if (SanOpts.has(SanitizerKind::ImplicitBitfieldConversion))


        


More information about the cfe-commits mailing list