[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Headers / stdckdint.c
blob6b6d74a89d4c1116056deff765a123a57857e209
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 3
2 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c99 %s -o - | FileCheck %s
3 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c11 %s -o - | FileCheck %s
4 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c17 %s -o - | FileCheck %s
5 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c23 %s -o - | FileCheck %s
7 // expected-no-diagnostics
9 #include <stdbool.h>
10 #include <stdckdint.h>
12 // CHECK-LABEL: define dso_local zeroext i1 @test_ckd_add(
13 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
14 // CHECK-NEXT: entry:
15 // CHECK-NEXT: [[RESULT:%.*]] = alloca i32, align 4
16 // CHECK-NEXT: [[TMP0:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 -1073741826, i32 -1073741826)
17 // CHECK-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1
18 // CHECK-NEXT: [[TMP2:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0
19 // CHECK-NEXT: store i32 [[TMP2]], ptr [[RESULT]], align 4
20 // CHECK-NEXT: ret i1 [[TMP1]]
22 bool test_ckd_add() {
23 int result;
24 return ckd_add(&result, -1073741826, -1073741826);
27 // CHECK-LABEL: define dso_local zeroext i1 @test_ckd_sub(
28 // CHECK-SAME: ) #[[ATTR0]] {
29 // CHECK-NEXT: entry:
30 // CHECK-NEXT: [[RESULT:%.*]] = alloca i32, align 4
31 // CHECK-NEXT: [[TMP0:%.*]] = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 -1073741826, i32 1073741826)
32 // CHECK-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1
33 // CHECK-NEXT: [[TMP2:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0
34 // CHECK-NEXT: store i32 [[TMP2]], ptr [[RESULT]], align 4
35 // CHECK-NEXT: ret i1 [[TMP1]]
37 bool test_ckd_sub() {
38 int result;
39 return ckd_sub(&result, -1073741826, 1073741826);
42 // CHECK-LABEL: define dso_local zeroext i1 @test_ckd_mul(
43 // CHECK-SAME: ) #[[ATTR0]] {
44 // CHECK-NEXT: entry:
45 // CHECK-NEXT: [[RESULT:%.*]] = alloca i32, align 4
46 // CHECK-NEXT: [[TMP0:%.*]] = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 -1073741826, i32 2)
47 // CHECK-NEXT: [[TMP1:%.*]] = extractvalue { i32, i1 } [[TMP0]], 1
48 // CHECK-NEXT: [[TMP2:%.*]] = extractvalue { i32, i1 } [[TMP0]], 0
49 // CHECK-NEXT: store i32 [[TMP2]], ptr [[RESULT]], align 4
50 // CHECK-NEXT: ret i1 [[TMP1]]
52 bool test_ckd_mul() {
53 int result;
54 return ckd_mul(&result, -1073741826, 2);