Skip to content

Commit d80e62c

Browse files
committed
Fast-path for single-byte chars
1 parent 9db49be commit d80e62c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

clang/lib/AST/ByteCode/Context.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ bool Context::evaluateStrlen(State &Parent, const Expr *E, uint64_t &Result) {
245245
return false;
246246

247247
unsigned N = Ptr.getNumElems();
248+
if (Ptr.elemSize() == 1) {
249+
Result = strnlen(reinterpret_cast<const char *>(Ptr.getRawAddress()), N);
250+
return Result != N;
251+
}
252+
248253
PrimType ElemT = FieldDesc->getPrimType();
249254
Result = 0;
250255
for (unsigned I = Ptr.getIndex(); I != N; ++I) {

0 commit comments

Comments
 (0)