brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 46e22fb Raw
37 lines · c
1// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py2// RUN: %clang_cc1 -x c   -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s3// RUN: %clang_cc1 -x c   -fsanitize=pointer-overflow -fno-sanitize-recover=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s4 5// RUN: %clang_cc1 -x c++ -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s6// RUN: %clang_cc1 -x c++ -fsanitize=pointer-overflow -fno-sanitize-recover=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s7 8#include <stdint.h>9 10#ifdef __cplusplus11extern "C" {12#endif13 14struct S {15  int x, y;16};17 18// CHECK-LABEL: @get_offset_of_y_naively(19// CHECK-NEXT:  entry:20// CHECK-NEXT:    ret i64 ptrtoint (ptr getelementptr ([[STRUCT_S:%.*]], ptr null, i32 0, i32 1) to i64)21//22uintptr_t get_offset_of_y_naively(void) {23  return ((uintptr_t)(&(((struct S *)0)->y)));24}25 26// CHECK-LABEL: @get_offset_of_y_via_builtin(27// CHECK-NEXT:  entry:28// CHECK-NEXT:    ret i64 429//30uintptr_t get_offset_of_y_via_builtin(void) {31  return __builtin_offsetof(struct S, y);32}33 34#ifdef __cplusplus35}36#endif37