summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorManna, Soumi <soumi.manna@intel.com>2023-05-27 07:15:24 -0700
committerManna, Soumi <soumi.manna@intel.com>2023-05-27 07:16:31 -0700
commitf59795b2b703d5a782e4c29c0e786ee01942f16a (patch)
tree646172d9a641306f57a2c0118e2a8facb597522d /clang/lib/CodeGen/CodeGenModule.cpp
parent0f8e0f4228805cbecce13dcfadef4c48a4f0f4cd (diff)
[NFC][CLANG] Fix nullptr dereference issue in CodeGenModule::GetConstantArrayFromStringLiteral()
This patch adds an assert. Reviewed By: erichkeane Differential Revision: https://reviews.llvm.org/D151480
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index d2a28b66cac9..49b670487749 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5888,6 +5888,7 @@ CodeGenModule::GetConstantArrayFromStringLiteral(const StringLiteral *E) {
// Resize the string to the right size, which is indicated by its type.
const ConstantArrayType *CAT = Context.getAsConstantArrayType(E->getType());
+ assert(CAT && "String literal not of constant array type!");
Str.resize(CAT->getSize().getZExtValue());
return llvm::ConstantDataArray::getString(VMContext, Str, false);
}