brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.8 KiB · 66dbc50 Raw
99 lines · cpp
1// RUN: %clang_cc1 %s -ast-print | FileCheck %s2// RUN: %clang_cc1 -emit-pch -o %t.ast %s3// RUN: %clang_cc1 %t.ast -ast-print | FileCheck %s4 5// CHECK: void *aa() __attribute__((assume_aligned(64)));6void *aa() __attribute__((assume_aligned(64)));7 8// CHECK: void *aa2() __attribute__((assume_aligned(64, 8)));9void *aa2() __attribute__((assume_aligned(64, 8)));10 11// CHECK: void xla(int a) __attribute__((xray_log_args(1)));12void xla(int a) __attribute__((xray_log_args(1)));13 14// CHECK: void *as2(int, int) __attribute__((alloc_size(1, 2)));15void *as2(int, int) __attribute__((alloc_size(1, 2)));16// CHECK: void *as1(void *, int) __attribute__((alloc_size(2)));17void *as1(void *, int) __attribute__((alloc_size(2)));18 19// CHECK: void fmt(int, const char *, ...) __attribute__((format(printf, 2, 3)));20void fmt(int, const char *, ...) __attribute__((format(printf, 2, 3)));21 22// CHECK: char *fmta(int, const char *) __attribute__((format_arg(2)));23char *fmta(int, const char *) __attribute__((format_arg(2)));24 25// CHECK: void nn(int *, int *) __attribute__((nonnull(1, 2)));26void nn(int *, int *) __attribute__((nonnull(1, 2)));27 28// CHECK: int *aa(int i) __attribute__((alloc_align(1)));29int *aa(int i) __attribute__((alloc_align(1)));30 31// CHECK: void ownt(int *, int *) __attribute__((ownership_takes(foo, 1, 2)));32void ownt(int *, int *) __attribute__((ownership_takes(foo, 1, 2)));33// CHECK: void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));34void ownh(int *, int *) __attribute__((ownership_holds(foo, 1, 2)));35// CHECK: void *ownr(int) __attribute__((ownership_returns(foo, 1)));36void *ownr(int) __attribute__((ownership_returns(foo, 1)));37 38// CHECK: void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 3, 2)));39void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 3, 2)));40// CHECK: void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 1, 2)));41void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 1, 2)));42 43class C {44  // CHECK: void xla(int a) __attribute__((xray_log_args(2)));45  void xla(int a) __attribute__((xray_log_args(2)));46 47  // CHECK: void *as2(int, int) __attribute__((alloc_size(2, 3)));48  void *as2(int, int) __attribute__((alloc_size(2, 3)));49  // CHECK: void *as1(void *, int) __attribute__((alloc_size(3)));50  void *as1(void *, int) __attribute__((alloc_size(3)));51 52  // CHECK: void fmt(int, const char *, ...) __attribute__((format(printf, 3, 4)));53  void fmt(int, const char *, ...) __attribute__((format(printf, 3, 4)));54 55  // CHECK: char *fmta(int, const char *) __attribute__((format_arg(3)));56  char *fmta(int, const char *) __attribute__((format_arg(3)));57 58  // CHECK: void nn(int *, int *) __attribute__((nonnull(2, 3)));59  void nn(int *, int *) __attribute__((nonnull(2, 3)));60 61  // CHECK: int *aa(int i) __attribute__((alloc_align(2)));62  int *aa(int i) __attribute__((alloc_align(2)));63 64  // CHECK: void ownt(int *, int *) __attribute__((ownership_takes(foo, 2, 3)));65  void ownt(int *, int *) __attribute__((ownership_takes(foo, 2, 3)));66  // CHECK: void ownh(int *, int *) __attribute__((ownership_holds(foo, 2, 3)));67  void ownh(int *, int *) __attribute__((ownership_holds(foo, 2, 3)));68  // CHECK: void *ownr(int) __attribute__((ownership_returns(foo, 2)));69  void *ownr(int) __attribute__((ownership_returns(foo, 2)));70 71  // CHECK: void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 4, 3)));72  void awtt(int, int, ...) __attribute__((argument_with_type_tag(foo, 4, 3)));73  // CHECK: void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 2, 3)));74  void pwtt(void *, int) __attribute__((pointer_with_type_tag(foo, 2, 3)));75};76 77#define ANNOTATE_ATTR __attribute__((annotate("Annotated")))78ANNOTATE_ATTR int annotated_attr ANNOTATE_ATTR = 0;79// CHECK: __attribute__((annotate("Annotated"))) int annotated_attr __attribute__((annotate("Annotated"))) = 0;80 81void increment() { [[clang::annotate("Annotated")]] annotated_attr++; }82// CHECK: {{\[\[}}clang::annotate("Annotated")]] annotated_attr++;83 84// FIXME: We do not print the attribute as written after the type specifier.85int ANNOTATE_ATTR annotated_attr_fixme = 0;86// CHECK: __attribute__((annotate("Annotated"))) int annotated_attr_fixme = 0;87 88#define NONNULL_ATTR  __attribute__((nonnull(1)))89ANNOTATE_ATTR NONNULL_ATTR void fn_non_null_annotated_attr(int *) __attribute__((annotate("AnnotatedRHS")));90// CHECK:__attribute__((annotate("Annotated"))) __attribute__((nonnull(1))) void fn_non_null_annotated_attr(int *) __attribute__((annotate("AnnotatedRHS")));91 92[[gnu::nonnull(1)]] [[gnu::always_inline]] void cxx11_attr(int*) ANNOTATE_ATTR;93// CHECK: {{\[\[}}gnu::nonnull(1)]] {{\[\[}}gnu::always_inline]] void cxx11_attr(int *) __attribute__((annotate("Annotated")));94 95struct Foo;96 97// CHECK: void as_member_fn_ptr(int *(Foo::*member)(int) __attribute__((alloc_size(1))));98void as_member_fn_ptr(int* (Foo::*member)(int)  __attribute__((alloc_size(1))));99