[clang] c3e7c6e - [NFC][CLANG] Fix static code analyzer concerns
via cfe-commits
cfe-commits at lists.llvm.org
Thu May 25 20:05:04 PDT 2023
Author: Manna, Soumi
Date: 2023-05-25T20:00:24-07:00
New Revision: c3e7c6e9e0809e2626253af584c7d7acfc4ce60b
URL: https://github.com/llvm/llvm-project/commit/c3e7c6e9e0809e2626253af584c7d7acfc4ce60b
DIFF: https://github.com/llvm/llvm-project/commit/c3e7c6e9e0809e2626253af584c7d7acfc4ce60b.diff
LOG: [NFC][CLANG] Fix static code analyzer concerns
Reported by Static Code Analyzer Tool:
Inside "CGExprConstant.cpp" file, VisitObjCEncodeExpr() returns null value which is dereferenced without checking.
This patch adds an assert.
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D151280
Added:
Modified:
clang/lib/CodeGen/CGExprConstant.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 2fb9722ecc7e..b0dd59871584 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1340,6 +1340,7 @@ class ConstExprEmitter :
std::string Str;
CGM.getContext().getObjCEncodingForType(E->getEncodedType(), Str);
const ConstantArrayType *CAT = CGM.getContext().getAsConstantArrayType(T);
+ assert(CAT && "String data not of constant array type!");
// Resize the string to the right size, adding zeros at the end, or
// truncating as needed.
More information about the cfe-commits
mailing list