Author: Timm Baeder Date: 2025-03-22T08:05:28+01:00 New Revision: 6c8e9a6192a812237415d7d03d5ae234bc244c97
URL: https://github.com/llvm/llvm-project/commit/6c8e9a6192a812237415d7d03d5ae234bc244c97 DIFF: https://github.com/llvm/llvm-project/commit/6c8e9a6192a812237415d7d03d5ae234bc244c97.diff LOG: [clang][bytecode][NFC] Add assert to ptrauth_string_discriminator (#132527) As pointed out by @shafik, this confuses static analysis and most probably humans as well. Add an assertion to ensure the given array has at least one element. Added: Modified: clang/lib/AST/ByteCode/InterpBuiltin.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 57037b674feba..a6e1884404287 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1477,6 +1477,9 @@ static bool interp__builtin_ptrauth_string_discriminator( const auto &Ptr = S.Stk.peek<Pointer>(); assert(Ptr.getFieldDesc()->isPrimitiveArray()); + // This should be created for a StringLiteral, so should alway shold at least + // one array element. + assert(Ptr.getFieldDesc()->getNumElems() >= 1); StringRef R(&Ptr.deref<char>(), Ptr.getFieldDesc()->getNumElems() - 1); uint64_t Result = getPointerAuthStableSipHash(R); pushInteger(S, Result, Call->getType()); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits