1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2 // RUN: %clang_cc1 -x c -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
3 // RUN: %clang_cc1 -x c -fsanitize=pointer-overflow -fno-sanitize-recover=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
5 // RUN: %clang_cc1 -x c++ -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
6 // RUN: %clang_cc1 -x c++ -fsanitize=pointer-overflow -fno-sanitize-recover=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
18 // CHECK-LABEL: @get_offset_of_y_naively(
20 // CHECK-NEXT: ret i64 ptrtoint (ptr getelementptr inbounds nuw ([[STRUCT_S:%.*]], ptr null, i32 0, i32 1) to i64)
22 uintptr_t get_offset_of_y_naively(void) {
23 return ((uintptr_t)(&(((struct S
*)0)->y
)));
26 // CHECK-LABEL: @get_offset_of_y_via_builtin(
28 // CHECK-NEXT: ret i64 4
30 uintptr_t get_offset_of_y_via_builtin(void) {
31 return __builtin_offsetof(struct S
, y
);