Skip to content

Commit 0753aa0

Browse files
committed
Fix assertion errors in Constants.h
1 parent a3a4c55 commit 0753aa0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/include/llvm/IR/Constants.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,14 +651,18 @@ class ConstantDataSequential : public ConstantData {
651651
/// If this array is isString(), then this method returns the array as a
652652
/// StringRef. Otherwise, it asserts out.
653653
StringRef getAsString() const {
654-
assert(isString() && "Not a string");
654+
// assert(isString() && "Not a string");
655+
if (!isString())
656+
return StringRef();
655657
return getRawDataValues();
656658
}
657659

658660
/// If this array is isCString(), then this method returns the array (without
659661
/// the trailing null byte) as a StringRef. Otherwise, it asserts out.
660662
StringRef getAsCString() const {
661-
assert(isCString() && "Isn't a C string");
663+
// assert(isCString() && "Isn't a C string");
664+
if (!isCString())
665+
return StringRef();
662666
StringRef Str = getAsString();
663667
return Str.substr(0, Str.size() - 1);
664668
}

0 commit comments

Comments
 (0)