Skip to content

Commit

Permalink
[NFC][CLANG] Fix static code analyzer concerns
Browse files Browse the repository at this point in the history
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
  • Loading branch information
smanna12 committed May 26, 2023
1 parent c9ee631 commit c3e7c6e
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c3e7c6e

Please sign in to comment.