Skip to content

Commit f5bdac9

Browse files
authored
Update Constants.cpp
1 parent f1b2506 commit f5bdac9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

llvm/lib/IR/Constants.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,6 +3128,29 @@ bool ConstantDataSequential::isCString() const {
31283128
return !Str.drop_back().contains(0);
31293129
}
31303130

3131+
bool ConstantDataSequential::isUnicodeString() const {
3132+
Type *CDSType = this->getElementType();
3133+
Type *GVType = IntegerType::getInt16Ty(this->getContext());
3134+
if (CDSType != GVType) {
3135+
return false;
3136+
}
3137+
3138+
StringRef RawDataValues = this->getRawDataValues();
3139+
unsigned int NumElements = this->getNumElements();
3140+
size_t Length = NumElements * sizeof(unsigned short);
3141+
3142+
if (RawDataValues[Length - 1] == 0 &&
3143+
RawDataValues[Length - sizeof(unsigned short)] == 0) {
3144+
for (unsigned int i = 0; i < Length - sizeof(unsigned short) - 1; ++i)
3145+
if (RawDataValues[i] == 0 && RawDataValues[i + 1] == 0)
3146+
return false;
3147+
3148+
return true;
3149+
}
3150+
3151+
return false;
3152+
}
3153+
31313154
bool ConstantDataVector::isSplatData() const {
31323155
const char *Base = getRawDataValues().data();
31333156

0 commit comments

Comments
 (0)