diff options
author | Timm Baeder <tbaeder@redhat.com> | 2025-03-24 12:44:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-24 12:44:35 +0100 |
commit | 9ab3b6a006d8b5c831146eb8a7f0a8df616bd5ad (patch) | |
tree | 306779b76ca769d51a8a596e28e6683051cccf4c /clang/lib/AST/ByteCode/InterpBuiltin.cpp | |
parent | bf2d30e0927b6b137bf4cc7bf32cd74d8092b0ee (diff) | |
download | llvm-9ab3b6a006d8b5c831146eb8a7f0a8df616bd5ad.zip llvm-9ab3b6a006d8b5c831146eb8a7f0a8df616bd5ad.tar.gz llvm-9ab3b6a006d8b5c831146eb8a7f0a8df616bd5ad.tar.bz2 |
[clang][bytecode] Diagnose integral source/dest in memcpy (#132715)
Like the current interpreter does.
Diffstat (limited to 'clang/lib/AST/ByteCode/InterpBuiltin.cpp')
-rw-r--r-- | clang/lib/AST/ByteCode/InterpBuiltin.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 71fd25c..285ea71 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1792,6 +1792,17 @@ static bool interp__builtin_memcpy(InterpState &S, CodePtr OpPC, return false; } + // Diagnose integral src/dest pointers specially. + if (SrcPtr.isIntegralPointer() || DestPtr.isIntegralPointer()) { + std::string DiagVal = "(void *)"; + DiagVal += SrcPtr.isIntegralPointer() + ? std::to_string(SrcPtr.getIntegerRepresentation()) + : std::to_string(DestPtr.getIntegerRepresentation()); + S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_memcpy_null) + << Move << false << DestPtr.isIntegralPointer() << DiagVal; + return false; + } + // Can't read from dummy pointers. if (DestPtr.isDummy() || SrcPtr.isDummy()) return false; |