[clang] eec7f8f - [WebAssembly] Add missing default cases in switch statements
Thomas Lively via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 3 13:15:32 PST 2021
Author: Soumi Manna
Date: 2021-03-03T13:15:23-08:00
New Revision: eec7f8f7b1226be422a76542cb403d02538f453a
URL: https://github.com/llvm/llvm-project/commit/eec7f8f7b1226be422a76542cb403d02538f453a
DIFF: https://github.com/llvm/llvm-project/commit/eec7f8f7b1226be422a76542cb403d02538f453a.diff
LOG: [WebAssembly] Add missing default cases in switch statements
unsigned variable 'IntNo' has been declared but not been defined inside function
EmitWebAssemblyBuiltinExpr().
static code analysis tool complains about uninitialized variable "IntNo" since
this enters to default branch without setting any intrinsics and calls Function
*Callee = CGM.getIntrinsic(IntNo).
This patch fixes the problem by adding default cases in switch statements.
Added:
Modified:
clang/lib/CodeGen/CGBuiltin.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 1a5dfdedc037..6b3d385c411e 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17365,6 +17365,8 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
case WebAssembly::BI__builtin_wasm_widen_high_u_i32x4_i64x2:
IntNo = Intrinsic::wasm_widen_high_unsigned;
break;
+ default:
+ llvm_unreachable("unexpected builtin ID");
}
Function *Callee = CGM.getIntrinsic(IntNo);
return Builder.CreateCall(Callee, Vec);
@@ -17383,6 +17385,8 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
case WebAssembly::BI__builtin_wasm_widen_u_i8x16_i32x4:
IntNo = Intrinsic::wasm_widen_unsigned;
break;
+ default:
+ llvm_unreachable("unexpected builtin ID");
}
Function *Callee = CGM.getIntrinsic(IntNo);
return Builder.CreateCall(Callee, {Vec, SubVec});
@@ -17398,6 +17402,8 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
case WebAssembly::BI__builtin_wasm_convert_low_u_i32x4_f64x2:
IntNo = Intrinsic::wasm_convert_low_unsigned;
break;
+ default:
+ llvm_unreachable("unexpected builtin ID");
}
Function *Callee = CGM.getIntrinsic(IntNo);
return Builder.CreateCall(Callee, Vec);
@@ -17413,6 +17419,8 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
case WebAssembly::BI__builtin_wasm_trunc_saturate_zero_u_f64x2_i32x4:
IntNo = Intrinsic::wasm_trunc_saturate_zero_unsigned;
break;
+ default:
+ llvm_unreachable("unexpected builtin ID");
}
Function *Callee = CGM.getIntrinsic(IntNo);
return Builder.CreateCall(Callee, Vec);
More information about the cfe-commits
mailing list