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.


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to