[clang] d8b540c - Cleanup sema checking for buitlin_memcpy_inline
Guillaume Chatelet via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 7 02:50:07 PDT 2022
Author: Guillaume Chatelet
Date: 2022-06-07T09:49:36Z
New Revision: d8b540cd312cf924b1904047b56cf8a1cea333f9
URL: https://github.com/llvm/llvm-project/commit/d8b540cd312cf924b1904047b56cf8a1cea333f9
DIFF: https://github.com/llvm/llvm-project/commit/d8b540cd312cf924b1904047b56cf8a1cea333f9.diff
LOG: Cleanup sema checking for buitlin_memcpy_inline
Added:
Modified:
clang/include/clang/Basic/Builtins.def
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/builtins-memcpy-inline.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/Builtins.def b/clang/include/clang/Basic/Builtins.def
index f47e8de806e21..173431ce39884 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -555,7 +555,7 @@ BUILTIN(__builtin_malloc, "v*z", "nF")
BUILTIN(__builtin_memchr, "v*vC*iz", "nF")
BUILTIN(__builtin_memcmp, "ivC*vC*z", "nF")
BUILTIN(__builtin_memcpy, "v*v*vC*z", "nF")
-BUILTIN(__builtin_memcpy_inline, "vv*vC*Iz", "nt")
+BUILTIN(__builtin_memcpy_inline, "vv*vC*Iz", "n")
BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")
BUILTIN(__builtin_mempcpy, "v*v*vC*z", "nF")
BUILTIN(__builtin_memset, "v*v*iz", "nF")
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 453364c3ac3d9..657238eabd9dc 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2265,19 +2265,6 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
case Builtin::BI__builtin_nontemporal_store:
return SemaBuiltinNontemporalOverloaded(TheCallResult);
case Builtin::BI__builtin_memcpy_inline: {
- if (checkArgCount(*this, TheCall, 3))
- return ExprError();
- auto ArgArrayConversionFailed = [&](unsigned Arg) {
- ExprResult ArgExpr =
- DefaultFunctionArrayLvalueConversion(TheCall->getArg(Arg));
- if (ArgExpr.isInvalid())
- return true;
- TheCall->setArg(Arg, ArgExpr.get());
- return false;
- };
-
- if (ArgArrayConversionFailed(0) || ArgArrayConversionFailed(1))
- return true;
clang::Expr *SizeOp = TheCall->getArg(2);
// We warn about copying to or from `nullptr` pointers when `size` is
// greater than 0. When `size` is value dependent we cannot evaluate its
diff --git a/clang/test/Sema/builtins-memcpy-inline.cpp b/clang/test/Sema/builtins-memcpy-inline.cpp
index ab0a8700a6c98..9d905a9335c4e 100644
--- a/clang/test/Sema/builtins-memcpy-inline.cpp
+++ b/clang/test/Sema/builtins-memcpy-inline.cpp
@@ -7,6 +7,10 @@
// expected-warning at -1 {{defined as expected}}
#endif
+void test_memcpy_inline_invalid_arg_types() {
+ __builtin_memcpy_inline(1, 2, 3); // expected-error {{cannot initialize a parameter of type 'void *' with an rvalue of type 'int'}}
+}
+
void test_memcpy_inline_null_src(void *ptr) {
__builtin_memcpy_inline(ptr, NULL, 4); // expected-warning {{null passed to a callee that requires a non-null argument}}
}
More information about the cfe-commits
mailing list