From d2a3214bba3fcb27da3163bc84644ef3110e9930 Mon Sep 17 00:00:00 2001 From: Quentin Bourgerie Date: Wed, 8 Sep 2021 11:39:48 +0200 Subject: [PATCH] clean(compiler): Return nullptr when conversion fails (should not happens but more safe in release mode) and remove dead code --- .../include/zamalang/Conversion/MidLFHEToLowLFHE/Patterns.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/include/zamalang/Conversion/MidLFHEToLowLFHE/Patterns.h b/compiler/include/zamalang/Conversion/MidLFHEToLowLFHE/Patterns.h index a27c5df49..78e2b1356 100644 --- a/compiler/include/zamalang/Conversion/MidLFHEToLowLFHE/Patterns.h +++ b/compiler/include/zamalang/Conversion/MidLFHEToLowLFHE/Patterns.h @@ -27,6 +27,7 @@ LweCiphertextType convertTypeToLWE(mlir::MLIRContext *context, return lwe; } assert(false && "expect glwe or lwe"); + return nullptr; } template @@ -50,6 +51,7 @@ PlaintextType convertPlaintextTypeFromType(mlir::MLIRContext *context, return convertPlaintextTypeFromPType(context, lwe); } assert(false && "expect glwe or lwe"); + return nullptr; } template @@ -73,6 +75,7 @@ CleartextType convertCleartextTypeFromType(mlir::MLIRContext *context, return convertCleartextTypeFromPType(context, lwe); } assert(false && "expect glwe or lwe"); + return nullptr; } mlir::Value createZeroLWEOpFromMidLFHE(mlir::PatternRewriter rewriter, @@ -113,7 +116,6 @@ mlir::Value createAddPlainLweCiphertextWithGlwe( .create(loc, encoded_type, arg1) .plaintext(); // convert result type - GLWECipherTextType glwe_type = result.getType().cast(); LweCiphertextType lwe_type = convertTypeToLWE(rewriter.getContext(), result.getType()); // replace op using the encoded plaintext instead of int