Skip to content

Conversation

@tbaederr
Copy link
Contributor

@tbaederr tbaederr commented Jan 2, 2025

... elements.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jan 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 2, 2025

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

... elements.


Full diff: https://github.com/llvm/llvm-project/pull/121461.diff

2 Files Affected:

  • (modified) clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp (+1-1)
  • (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+10)
diff --git a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
index 0fc94e1694822a..57c1fab5d6ab43 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
@@ -110,7 +110,7 @@ static bool enumerateData(const Pointer &P, const Context &Ctx, Bits Offset,
   if (FieldDesc->isCompositeArray()) {
     QualType ElemType = FieldDesc->getElemQualType();
     Bits ElemSize = Bits(Ctx.getASTContext().getTypeSize(ElemType));
-    for (unsigned I = 0; I != FieldDesc->getNumElems(); ++I) {
+    for (unsigned I = P.getIndex(); I != FieldDesc->getNumElems(); ++I) {
       enumerateData(P.atIndex(I).narrow(), Ctx, Offset, BitsToRead, F);
       Offset += ElemSize;
       if (Offset >= BitsToRead)
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp
index b0f8ea2e55ee0b..0188e8297db528 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1253,6 +1253,16 @@ namespace BuiltinMemcpy {
   static_assert(test_memmove(2, 0, 12) == 4234); // both-error {{constant}} \
                                                  // both-note {{in call}}
 #endif
+
+  struct Trivial { char k; short s; constexpr bool ok() { return k == 3 && s == 4; } };
+  constexpr bool test_trivial() {
+    Trivial arr[3] = {{1, 2}, {3, 4}, {5, 6}};
+    __builtin_memcpy(arr, arr+1, sizeof(Trivial));
+    __builtin_memmove(arr+1, arr, 2 * sizeof(Trivial));
+
+    return arr[0].ok() && arr[1].ok() && arr[2].ok();
+  }
+  static_assert(test_trivial());
 }
 
 namespace Memcmp {

@tbaederr tbaederr merged commit d5c8af4 into llvm:main Jan 2, 2025
11 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 2, 2025

LLVM Buildbot has detected a new failure on builder fuchsia-x86_64-linux running on fuchsia-debian-64-us-central1-a-1 while building clang at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/11/builds/10389

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure)
...
[324/2768] Copying CXX header __algorithm/ranges_unique_copy.h
[325/2768] Copying CXX header __algorithm/ranges_upper_bound.h
[326/2768] Copying CXX header __algorithm/remove.h
[327/2768] Copying CXX header __algorithm/remove_copy.h
[328/2768] Copying CXX header __algorithm/remove_if.h
[329/2768] Copying CXX header __algorithm/replace.h
[330/2768] Generating header strings.h from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/strings.yaml and /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/include/strings.h.def
[331/2768] Generating header fenv.h from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/fenv.yaml and /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/include/fenv.h.def
[332/2768] Generating header time.h from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/time.yaml and /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/include/time.h.def
[333/2768] Building CXX object libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj
FAILED: libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-2wdibiw6/bin/clang++ --target=armv8.1m.main-none-eabi -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git -I/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc -isystem /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-2wdibiw6/include/armv8.1m.main-unknown-none-eabi --target=armv8.1m.main-none-eabi -Wno-atomic-alignment "-Dvfprintf(stream, format, vlist)=vprintf(format, vlist)" "-Dfprintf(stream, format, ...)=printf(format)" -D_LIBCPP_PRINT=1 -mthumb -mfloat-abi=hard -march=armv8.1-m.main+mve.fp+fp.dp -mcpu=cortex-m55 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -ffunction-sections -fdata-sections -ffile-prefix-map=/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-2wdibiw6/runtimes/runtimes-armv8.1m.main-none-eabi-bins=../../../../llvm-project -ffile-prefix-map=/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/= -no-canonical-prefixes -Os -DNDEBUG -std=gnu++17 --target=armv8.1m.main-none-eabi -DLIBC_QSORT_IMPL=LIBC_QSORT_HEAP_SORT -DLIBC_TYPES_TIME_T_IS_32_BIT -DLIBC_ADD_NULL_CHECKS "-DLIBC_MATH=(LIBC_MATH_SKIP_ACCURATE_PASS | LIBC_MATH_SMALL_TABLES)" -fpie -ffreestanding -DLIBC_FULL_BUILD -nostdlibinc -ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -MD -MT libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj -MF libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj.d -o libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj -c /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/strings/bcopy.cpp
In file included from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/strings/bcopy.cpp:12:
In file included from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/string/memory_utils/inline_memmove.h:32:
In file included from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/string/memory_utils/generic/byte_per_byte.h:17:
In file included from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/string/memory_utils/utils.h:15:
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:43:13: error: unknown type name 'uint8_t'
   43 | LIBC_INLINE uint8_t
      |             ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:44:48: error: use of undeclared identifier 'uint8_t'
   44 | Endian<__ORDER_LITTLE_ENDIAN__>::to_big_endian<uint8_t>(uint8_t v) {
      |                                                ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:44:48: error: use of undeclared identifier 'uint8_t'
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:44:57: error: unknown type name 'uint8_t'
   44 | Endian<__ORDER_LITTLE_ENDIAN__>::to_big_endian<uint8_t>(uint8_t v) {
      |                                                         ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:49:13: error: unknown type name 'uint8_t'
   49 | LIBC_INLINE uint8_t
      |             ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:50:51: error: use of undeclared identifier 'uint8_t'
   50 | Endian<__ORDER_LITTLE_ENDIAN__>::to_little_endian<uint8_t>(uint8_t v) {
      |                                                   ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:50:51: error: use of undeclared identifier 'uint8_t'
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:50:60: error: unknown type name 'uint8_t'
   50 | Endian<__ORDER_LITTLE_ENDIAN__>::to_little_endian<uint8_t>(uint8_t v) {
      |                                                            ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:55:13: error: unknown type name 'uint16_t'
   55 | LIBC_INLINE uint16_t
      |             ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:56:48: error: use of undeclared identifier 'uint16_t'
   56 | Endian<__ORDER_LITTLE_ENDIAN__>::to_big_endian<uint16_t>(uint16_t v) {
      |                                                ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:56:48: error: use of undeclared identifier 'uint16_t'
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:56:58: error: unknown type name 'uint16_t'
   56 | Endian<__ORDER_LITTLE_ENDIAN__>::to_big_endian<uint16_t>(uint16_t v) {
      |                                                          ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:61:13: error: unknown type name 'uint16_t'
   61 | LIBC_INLINE uint16_t
      |             ^
Step 6 (build) failure: build (failure)
...
[324/2768] Copying CXX header __algorithm/ranges_unique_copy.h
[325/2768] Copying CXX header __algorithm/ranges_upper_bound.h
[326/2768] Copying CXX header __algorithm/remove.h
[327/2768] Copying CXX header __algorithm/remove_copy.h
[328/2768] Copying CXX header __algorithm/remove_if.h
[329/2768] Copying CXX header __algorithm/replace.h
[330/2768] Generating header strings.h from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/strings.yaml and /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/include/strings.h.def
[331/2768] Generating header fenv.h from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/fenv.yaml and /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/include/fenv.h.def
[332/2768] Generating header time.h from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/runtimes/../libc/include/time.yaml and /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/include/time.h.def
[333/2768] Building CXX object libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj
FAILED: libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-2wdibiw6/bin/clang++ --target=armv8.1m.main-none-eabi -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git -I/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc -isystem /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-2wdibiw6/include/armv8.1m.main-unknown-none-eabi --target=armv8.1m.main-none-eabi -Wno-atomic-alignment "-Dvfprintf(stream, format, vlist)=vprintf(format, vlist)" "-Dfprintf(stream, format, ...)=printf(format)" -D_LIBCPP_PRINT=1 -mthumb -mfloat-abi=hard -march=armv8.1-m.main+mve.fp+fp.dp -mcpu=cortex-m55 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -ffunction-sections -fdata-sections -ffile-prefix-map=/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-2wdibiw6/runtimes/runtimes-armv8.1m.main-none-eabi-bins=../../../../llvm-project -ffile-prefix-map=/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/= -no-canonical-prefixes -Os -DNDEBUG -std=gnu++17 --target=armv8.1m.main-none-eabi -DLIBC_QSORT_IMPL=LIBC_QSORT_HEAP_SORT -DLIBC_TYPES_TIME_T_IS_32_BIT -DLIBC_ADD_NULL_CHECKS "-DLIBC_MATH=(LIBC_MATH_SKIP_ACCURATE_PASS | LIBC_MATH_SMALL_TABLES)" -fpie -ffreestanding -DLIBC_FULL_BUILD -nostdlibinc -ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -MD -MT libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj -MF libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj.d -o libc/src/strings/CMakeFiles/libc.src.strings.bcopy.dir/bcopy.cpp.obj -c /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/strings/bcopy.cpp
In file included from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/strings/bcopy.cpp:12:
In file included from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/string/memory_utils/inline_memmove.h:32:
In file included from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/string/memory_utils/generic/byte_per_byte.h:17:
In file included from /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/string/memory_utils/utils.h:15:
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:43:13: error: unknown type name 'uint8_t'
   43 | LIBC_INLINE uint8_t
      |             ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:44:48: error: use of undeclared identifier 'uint8_t'
   44 | Endian<__ORDER_LITTLE_ENDIAN__>::to_big_endian<uint8_t>(uint8_t v) {
      |                                                ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:44:48: error: use of undeclared identifier 'uint8_t'
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:44:57: error: unknown type name 'uint8_t'
   44 | Endian<__ORDER_LITTLE_ENDIAN__>::to_big_endian<uint8_t>(uint8_t v) {
      |                                                         ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:49:13: error: unknown type name 'uint8_t'
   49 | LIBC_INLINE uint8_t
      |             ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:50:51: error: use of undeclared identifier 'uint8_t'
   50 | Endian<__ORDER_LITTLE_ENDIAN__>::to_little_endian<uint8_t>(uint8_t v) {
      |                                                   ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:50:51: error: use of undeclared identifier 'uint8_t'
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:50:60: error: unknown type name 'uint8_t'
   50 | Endian<__ORDER_LITTLE_ENDIAN__>::to_little_endian<uint8_t>(uint8_t v) {
      |                                                            ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:55:13: error: unknown type name 'uint16_t'
   55 | LIBC_INLINE uint16_t
      |             ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:56:48: error: use of undeclared identifier 'uint16_t'
   56 | Endian<__ORDER_LITTLE_ENDIAN__>::to_big_endian<uint16_t>(uint16_t v) {
      |                                                ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:56:48: error: use of undeclared identifier 'uint16_t'
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:56:58: error: unknown type name 'uint16_t'
   56 | Endian<__ORDER_LITTLE_ENDIAN__>::to_big_endian<uint16_t>(uint16_t v) {
      |                                                          ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/__support/endian_internal.h:61:13: error: unknown type name 'uint16_t'
   61 | LIBC_INLINE uint16_t
      |             ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants