brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.9 KiB · eeead34 Raw
273 lines · cpp
1// Test without serialization:2// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++11 -fcxx-exceptions -ast-dump %s \3// RUN: | FileCheck --strict-whitespace %s4 5// Test with serialization:6// RUN: %clang_cc1 -triple x86_64-pc-linux -emit-pch -fcxx-exceptions -o %t %s7// RUN: %clang_cc1 -x c++ -triple x86_64-pc-linux -include-pch %t -fcxx-exceptions -ast-dump-all /dev/null \8// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \9// RUN: | FileCheck --strict-whitespace %s10 11// CHECK-LABEL: FunctionDecl {{.*}} no_fpfeatures_func_01 'vector2float (vector2double)'12// CHECK:         CompoundStmt {{.*\>$}}13// CHECK:           ReturnStmt14// CHECK:             ConvertVectorExpr {{.*}} 'vector2float':'__attribute__((__vector_size__(2 * sizeof(float)))) float'{{$}}15 16typedef double vector2double __attribute__((__vector_size__(16)));17typedef float  vector2float  __attribute__((__vector_size__(8)));18vector2float no_fpfeatures_func_01(vector2double x) {19  return __builtin_convertvector(x, vector2float);20}21 22float func_01(float x);23 24template <typename T>25T func_02(T x) {26#pragma STDC FP_CONTRACT ON27  return func_01(x);28}29 30float func_03(float x) {31#pragma STDC FP_CONTRACT OFF32  return func_02(x);33}34 35// CHECK:      FunctionTemplateDecl {{.*}} func_0236// CHECK:        FunctionDecl {{.*}} func_02 'float (float)'37// CHECK-NEXT:     TemplateArgument type 'float'38// CHECK-NEXT:       BuiltinType {{.*}} 'float'39// CHECK-NEXT:     ParmVarDecl {{.*}} x 'float'40// CHECK-NEXT:     CompoundStmt41// CHECK-NEXT:       ReturnStmt42// CHECK-NEXT:         CallExpr {{.*}} FPContractMode=143 44// CHECK:      FunctionDecl {{.*}} func_03 'float (float)'45// CHECK-NEXT:   ParmVarDecl {{.*}} x 'float'46// CHECK-NEXT:     CompoundStmt47// CHECK-NEXT:       ReturnStmt48// CHECK-NEXT:         CallExpr {{.*}} FPContractMode=049 50int func_04(float x) {51#pragma STDC FP_CONTRACT ON52  return x;53}54 55// CHECK:      FunctionDecl {{.*}} func_04 'int (float)'56// CHECK-NEXT:   ParmVarDecl {{.*}} x 'float'57// CHECK-NEXT:   CompoundStmt58// CHECK-NEXT:     ReturnStmt59// CHECK-NEXT:       ImplicitCastExpr {{.*}} 'int' <FloatingToIntegral> FPContractMode=160 61float func_05(double x) {62#pragma STDC FP_CONTRACT ON63  return (float)x;64}65 66// CHECK:      FunctionDecl {{.*}} func_05 'float (double)'67// CHECK-NEXT:   ParmVarDecl {{.*}} x 'double'68// CHECK-NEXT:   CompoundStmt69// CHECK-NEXT:     ReturnStmt70// CHECK-NEXT:       CStyleCastExpr {{.*}} FPContractMode=171 72float func_06(double x) {73#pragma STDC FP_CONTRACT ON74  return float(x);75}76 77// CHECK:      FunctionDecl {{.*}} func_06 'float (double)'78// CHECK-NEXT:   ParmVarDecl {{.*}} x 'double'79// CHECK-NEXT:   CompoundStmt80// CHECK-NEXT:     ReturnStmt81// CHECK-NEXT:       CXXFunctionalCastExpr {{.*}} FPContractMode=182 83float func_07(double x) {84#pragma STDC FP_CONTRACT ON85  return static_cast<float>(x);86}87 88// CHECK:      FunctionDecl {{.*}} func_07 'float (double)'89// CHECK-NEXT:   ParmVarDecl {{.*}} x 'double'90// CHECK-NEXT:   CompoundStmt91// CHECK-NEXT:     ReturnStmt92// CHECK-NEXT:       CXXStaticCastExpr {{.*}} FPContractMode=193 94#pragma STDC FENV_ROUND FE_DOWNWARD95 96float func_10(float x, float y) {97  return x + y;98}99 100// CHECK-LABEL: FunctionDecl {{.*}} func_10 'float (float, float)'101// CHECK:         BinaryOperator {{.*}} 'float' '+' ConstRoundingMode=downward102 103float func_11(float x, float y) {104  if (x < 0) {105    #pragma STDC FENV_ROUND FE_UPWARD106    return x + y;107  }108  return x - y;109}110 111// CHECK-LABEL: FunctionDecl {{.*}} func_11 'float (float, float)'112// CHECK:         BinaryOperator {{.*}} 'float' '+' ConstRoundingMode=upward113// CHECK:         BinaryOperator {{.*}} 'float' '-' ConstRoundingMode=downward114 115 116#pragma STDC FENV_ROUND FE_DYNAMIC117 118float func_12(float x, float y) {119  return x + y;120}121 122// CHECK-LABEL: FunctionDecl {{.*}} func_12 'float (float, float)'123// CHECK:         BinaryOperator {{.*}} 'float' '+' ConstRoundingMode=dynamic124 125#pragma STDC FENV_ROUND FE_TONEAREST126 127float func_13(float x, float y) {128  return x + y;129}130 131// CHECK-LABEL: FunctionDecl {{.*}} func_13 'float (float, float)'132// CHECK:         BinaryOperator {{.*}} 'float' '+' ConstRoundingMode=tonearest133 134 135template <typename T>136T func_14(T x, T y) {137#pragma STDC FENV_ROUND FE_TOWARDZERO138  return x + y;139}140 141float func_15(float x, float y) {142#pragma STDC FENV_ROUND FE_DOWNWARD143  return func_14(x, y);144}145 146// CHECK-LABEL: FunctionTemplateDecl {{.*}} func_14147// CHECK:         FunctionDecl {{.*}} func_14 'T (T, T)'148// CHECK:           CompoundStmt149// CHECK-NEXT:        ReturnStmt150// CHECK-NEXT:          BinaryOperator {{.*}} '+' ConstRoundingMode=towardzero151// CHECK:         FunctionDecl {{.*}} func_14 'float (float, float)'152// CHECK:           CompoundStmt153// CHECK-NEXT:        ReturnStmt154// CHECK-NEXT:          BinaryOperator {{.*}} 'float' '+' ConstRoundingMode=towardzero155 156float func_16(float x, float y) {157#pragma STDC FENV_ROUND FE_TOWARDZERO158  if (x < 0) {159#pragma STDC FENV_ROUND FE_UPWARD160    return x - y;161  }162  return x + y;163}164 165// CHECK-LABEL: FunctionDecl {{.*}} func_16 'float (float, float)'166// CHECK:         CompoundStmt {{.*}} ConstRoundingMode=towardzero167// CHECK:           IfStmt168// CHECK:             CompoundStmt {{.*}} ConstRoundingMode=upward169// CHECK:               ReturnStmt170// CHECK:                 BinaryOperator {{.*}} ConstRoundingMode=upward171// CHECK:           ReturnStmt172// CHECK:             BinaryOperator {{.*}} ConstRoundingMode=towardzero173 174float func_17(float x, float y) {175#pragma STDC FENV_ROUND FE_TOWARDZERO176  if (x < 0) {177#pragma STDC FENV_ROUND FE_TOWARDZERO178    return x - y;179  }180  return x + y;181}182 183// CHECK-LABEL: FunctionDecl {{.*}} func_17 'float (float, float)'184// CHECK:         CompoundStmt {{.*}} ConstRoundingMode=towardzero185// CHECK:           IfStmt186// CHECK:             CompoundStmt {{.*}}187// CHECK:               ReturnStmt188// CHECK:                 BinaryOperator {{.*}} ConstRoundingMode=towardzero189// CHECK:           ReturnStmt190// CHECK:             BinaryOperator {{.*}} ConstRoundingMode=towardzero191 192#pragma STDC FENV_ROUND FE_DOWNWARD193float func_18(float x, float y) {194  return x + y;195}196 197// CHECK-LABEL: FunctionDecl {{.*}} func_18 'float (float, float)'198// CHECK:         CompoundStmt {{.*}} ConstRoundingMode=downward199// CHECK:           ReturnStmt200// CHECK:             BinaryOperator {{.*}} ConstRoundingMode=downward201 202#pragma float_control(precise, off)203 204__attribute__((optnone))205float func_19(float x, float y) {206  return x + y;207}208 209// CHECK-LABEL: FunctionDecl {{.*}} func_19 'float (float, float)'210// CHECK:         CompoundStmt {{.*}} MathErrno=1211// CHECK:           ReturnStmt212// CHECK:             BinaryOperator {{.*}} 'float' '+' FPContractMode=1 ConstRoundingMode=downward MathErrno=1213 214__attribute__((optnone))215float func_20(float x, float y) try {216  return x + y;217} catch (...) {218  return 1.0;219}220 221// CHECK-LABEL: FunctionDecl {{.*}} func_20 'float (float, float)'222// CHECK:         CompoundStmt {{.*}} ConstRoundingMode=downward MathErrno=1223// CHECK:           ReturnStmt224// CHECK:             BinaryOperator {{.*}} 'float' '+' FPContractMode=1 ConstRoundingMode=downward MathErrno=1225 226struct C21 {227  C21(float x, float y);228  __attribute__((optnone)) float a_method(float x, float y) {229    return x * y;230  }231  float member;232};233 234// CHECK-LABEL: CXXMethodDecl {{.*}} a_method 'float (float, float)'235// CHECK:         CompoundStmt {{.*}} FPContractMode=1 ConstRoundingMode=downward MathErrno=1236// CHECK:           ReturnStmt237// CHECK:             BinaryOperator {{.*}} 'float' '*' FPContractMode=1 ConstRoundingMode=downward MathErrno=1238 239__attribute__((optnone)) C21::C21(float x, float y) : member(x + y) {}240 241// CHECK-LABEL: CXXConstructorDecl {{.*}} C21 'void (float, float)'242// CHECK:         CXXCtorInitializer {{.*}} 'member' 'float'243// CHECK:           BinaryOperator {{.*}} 'float' '+' FPContractMode=1 ConstRoundingMode=downward MathErrno=1244 245template <typename T>246__attribute__((optnone)) T func_22(T x, T y) {247  return x + y;248}249 250// CHECK-LABEL: FunctionTemplateDecl {{.*}} func_22251// CHECK:         FunctionDecl {{.*}} func_22 'T (T, T)'252// CHECK:           CompoundStmt {{.*}} FPContractMode=1 ConstRoundingMode=downward MathErrno=1253// CHECK:             ReturnStmt254// CHECK:               BinaryOperator {{.*}} '+' FPContractMode=1 ConstRoundingMode=downward MathErrno=1255// CHECK:         FunctionDecl {{.*}} func_22 'float (float, float)'256// CHECK:           CompoundStmt {{.*}} FPContractMode=1 ConstRoundingMode=downward MathErrno=1257// CHECK:             ReturnStmt258// CHECK:               BinaryOperator {{.*}} 'float' '+' FPContractMode=1 ConstRoundingMode=downward MathErrno=1259 260float func_23(float x, float y) {261  return func_22(x, y);262}263 264// CHECK-LABEL: FunctionDecl {{.*}} func_24 'vector2float (vector2double)'265// CHECK:         CompoundStmt {{.*}} FPContractMode=2 ConstRoundingMode=towardzero266// CHECK:           ReturnStmt267// CHECK:             ConvertVectorExpr {{.*}} FPContractMode=2 ConstRoundingMode=towardzero268 269#pragma STDC FENV_ROUND FE_TOWARDZERO270vector2float func_24(vector2double x) {271  return __builtin_convertvector(x, vector2float);272}273