当前位置: 首页>>代码示例>>C++>>正文


C++ CHECK_NON_NULL函数代码示例

本文整理汇总了C++中CHECK_NON_NULL函数的典型用法代码示例。如果您正苦于以下问题:C++ CHECK_NON_NULL函数的具体用法?C++ CHECK_NON_NULL怎么用?C++ CHECK_NON_NULL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CHECK_NON_NULL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: verify_bottom_code

void
verify_bottom_code (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  typedef int (*fn_type) (double a, double b, double c,
			  double *r1, double *r2);

  CHECK_NON_NULL (result);

  fn_type test_quadratic =
    (fn_type)gcc_jit_result_get_code (result, "test_quadratic");
  CHECK_NON_NULL (test_quadratic);

  /* Verify that the code correctly solves quadratic equations.  */
  double r1, r2;

  /* This one has two solutions: */
  CHECK_VALUE (test_quadratic (1, 3, -4, &r1, &r2), 2);
  CHECK_VALUE (r1, 1);
  CHECK_VALUE (r2, -4);

  /* This one has one solution: */
  CHECK_VALUE (test_quadratic (4, 4, 1, &r1, &r2), 1);
  CHECK_VALUE (r1, -0.5);

  /* This one has no real solutions: */
  CHECK_VALUE (test_quadratic (4, 1, 1, &r1, &r2), 0);
}
开发者ID:AlexMioMio,项目名称:gcc,代码行数:27,代码来源:test-nested-contexts.c

示例2: verify_test_of_builtin_trig

static void
verify_test_of_builtin_trig (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  typedef double (*fn_type) (double);
  CHECK_NON_NULL (result);

  fn_type test_of_builtin_trig =
    (fn_type)gcc_jit_result_get_code (result, "test_of_builtin_trig");
  CHECK_NON_NULL (test_of_builtin_trig);

  /* Verify that it correctly computes
        sin (2 * theta)
     (perhaps calling sin and cos). */
  CHECK_DOUBLE_VALUE (test_of_builtin_trig (0.0         ),  0.0);
  CHECK_DOUBLE_VALUE (test_of_builtin_trig (M_PI_4      ),  1.0);
  CHECK_DOUBLE_VALUE (test_of_builtin_trig (M_PI_2      ),  0.0);
  CHECK_DOUBLE_VALUE (test_of_builtin_trig (M_PI_4 * 3.0), -1.0);
  CHECK_DOUBLE_VALUE (test_of_builtin_trig (M_PI        ),  0.0);

  /* PR jit/64020:
     The "sincos" pass merges sin/cos calls into the cexpi builtin.
     Verify that a dump of the "sincos" pass was provided, and that it
     shows a call to the cexpi builtin on a SSA name of "theta".  */
  CHECK_NON_NULL (trig_sincos_dump);
  CHECK_STRING_CONTAINS (trig_sincos_dump, " = __builtin_cexpi (theta_");
  free (trig_sincos_dump);

  /* Similarly, verify that the statistics dump was provided, and that
     it shows the sincos optimization.  */
  CHECK_NON_NULL (trig_statistics_dump);
  CHECK_STRING_CONTAINS (
    trig_statistics_dump,
    "sincos \"sincos statements inserted\" \"test_of_builtin_trig\" 1");
  free (trig_statistics_dump);
}
开发者ID:0day-ci,项目名称:gcc,代码行数:35,代码来源:test-functions.c

示例3: verify_code

extern void
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  typedef void (*fn_type) (const char *);
  CHECK_NON_NULL (result);
  fn_type hello_world =
    (fn_type)gcc_jit_result_get_code (result, "hello_world");
  CHECK_NON_NULL (hello_world);
  hello_world ("world");
  fflush (stdout);
}
开发者ID:0day-ci,项目名称:gcc,代码行数:11,代码来源:test-hello-world.c

示例4: verify_code

void
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  CHECK_NON_NULL (result);

  typedef int (*my_fn_type) (void);
  CHECK_NON_NULL (result);
  my_fn_type my_fn =
    (my_fn_type)gcc_jit_result_get_code (result, long_names.fn_name);
  CHECK_NON_NULL (my_fn);
  int val = my_fn ();
  CHECK_VALUE (val, 42);
}
开发者ID:0day-ci,项目名称:gcc,代码行数:13,代码来源:test-long-names.c

示例5: verify_void_return

static void
verify_void_return (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  typedef void (*fn_type) (int *);
  CHECK_NON_NULL (result);

  fn_type test_of_void_return =
    (fn_type)gcc_jit_result_get_code (result, "test_of_void_return");
  CHECK_NON_NULL (test_of_void_return);

  int i;
  test_of_void_return (&i);
  CHECK_VALUE (i, 1); /* ensure correct value was written back */
}
开发者ID:0day-ci,项目名称:gcc,代码行数:14,代码来源:test-functions.c

示例6: verify_test_of_builtin_strcmp

static void
verify_test_of_builtin_strcmp (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  typedef int (*fn_type) (const char *, const char *);
  CHECK_NON_NULL (result);

  fn_type test_of_builtin_strcmp =
    (fn_type)gcc_jit_result_get_code (result, "test_of_builtin_strcmp");
  CHECK_NON_NULL (test_of_builtin_strcmp);

  /* Verify that it correctly called strcmp.  */
  CHECK_VALUE (test_of_builtin_strcmp ("foo", "foo"), 0);
  CHECK (test_of_builtin_strcmp ("foo", "bar") > 0);
  CHECK (test_of_builtin_strcmp ("bar", "foo") < 0);
}
开发者ID:0day-ci,项目名称:gcc,代码行数:15,代码来源:test-functions.c

示例7: Z3_fpa_get_numeral_sign

 Z3_bool Z3_API Z3_fpa_get_numeral_sign(Z3_context c, Z3_ast t, int * sgn) {
     Z3_TRY;
     LOG_Z3_fpa_get_numeral_sign(c, t, sgn);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(t, 0);
     CHECK_VALID_AST(t, 0);
     if (sgn == nullptr) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         return 0;
     }
     ast_manager & m = mk_c(c)->m();
     mpf_manager & mpfm = mk_c(c)->fpautil().fm();
     family_id fid = mk_c(c)->get_fpa_fid();
     fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(fid);
     expr * e = to_expr(t);
     if (!is_app(e) || is_app_of(e, fid, OP_FPA_NAN) || !is_fp(c, t)) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         return 0;
     }
     scoped_mpf val(mpfm);
     bool r = plugin->is_numeral(to_expr(t), val);
     if (!r || mpfm.is_nan(val)) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         return 0;
     }
     *sgn = mpfm.sgn(val);
     return r;
     Z3_CATCH_RETURN(0);
 }
开发者ID:chadbrewbaker,项目名称:z3,代码行数:29,代码来源:api_fpa.cpp

示例8: Z3_get_model_func_entry_value

 Z3_ast Z3_API Z3_get_model_func_entry_value(Z3_context c,
         Z3_model m,
         unsigned i,
         unsigned j) {
     Z3_TRY;
     LOG_Z3_get_model_func_entry_value(c, m, i, j);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(m, 0);
     if (j >= get_model_func_num_entries_core(c, m, i)) {
         SET_ERROR_CODE(Z3_IOB);
         RETURN_Z3(0);
     }
     Z3_func_decl d = get_model_func_decl_core(c, m, i);
     if (d) {
         model * _m = to_model_ref(m);
         func_interp * g = _m->get_func_interp(to_func_decl(d));
         if (g && j < g->num_entries()) {
             func_entry const* e = g->get_entry(j);
             expr* a = e->get_result();
             mk_c(c)->save_ast_trail(a);
             RETURN_Z3(of_ast(a));
         }
         SET_ERROR_CODE(Z3_IOB);
         RETURN_Z3(0);
     }
     RETURN_Z3(0);
     Z3_CATCH_RETURN(0);
 }
开发者ID:kayceesrk,项目名称:Z3,代码行数:28,代码来源:api_model.cpp

示例9: Z3_fpa_get_numeral_sign_bv

 Z3_ast Z3_API Z3_fpa_get_numeral_sign_bv(Z3_context c, Z3_ast t) {
     Z3_TRY;
     LOG_Z3_fpa_get_numeral_sign_bv(c, t);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(t, nullptr);
     CHECK_VALID_AST(t, nullptr);
     ast_manager & m = mk_c(c)->m();
     mpf_manager & mpfm = mk_c(c)->fpautil().fm();
     family_id fid = mk_c(c)->get_fpa_fid();
     fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(fid);
     api::context * ctx = mk_c(c);
     expr * e = to_expr(t);
     if (!is_app(e) || is_app_of(e, fid, OP_FPA_NAN) || !is_fp(c, t)) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         RETURN_Z3(nullptr);
     }
     scoped_mpf val(mpfm);
     bool r = plugin->is_numeral(to_expr(t), val);
     if (!r || mpfm.is_nan(val)) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         return nullptr;
     }
     app * a;
     if (mpfm.is_pos(val))
         a = ctx->bvutil().mk_numeral(0, 1);
     else
         a = ctx->bvutil().mk_numeral(1, 1);
     mk_c(c)->save_ast_trail(a);
     RETURN_Z3(of_expr(a));
     Z3_CATCH_RETURN(nullptr);
 }
开发者ID:chadbrewbaker,项目名称:z3,代码行数:31,代码来源:api_fpa.cpp

示例10: Z3_fpa_get_numeral_significand_bv

 Z3_ast Z3_API Z3_fpa_get_numeral_significand_bv(Z3_context c, Z3_ast t) {
     Z3_TRY;
     LOG_Z3_fpa_get_numeral_significand_bv(c, t);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(t, nullptr);
     CHECK_VALID_AST(t, nullptr);
     ast_manager & m = mk_c(c)->m();
     mpf_manager & mpfm = mk_c(c)->fpautil().fm();
     unsynch_mpq_manager & mpqm = mpfm.mpq_manager();
     family_id fid = mk_c(c)->get_fpa_fid();
     fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(fid);
     SASSERT(plugin != 0);
     expr * e = to_expr(t);
     if (!is_app(e) || is_app_of(e, fid, OP_FPA_NAN) || !is_fp(c, t)) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         RETURN_Z3(nullptr);
     }
     scoped_mpf val(mpfm);
     bool r = plugin->is_numeral(e, val);
     if (!r || !(mpfm.is_normal(val) || mpfm.is_denormal(val) || mpfm.is_zero(val) || mpfm.is_inf(val))) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         RETURN_Z3(nullptr);
     }
     unsigned sbits = val.get().get_sbits();
     scoped_mpq q(mpqm);
     mpqm.set(q, mpfm.sig(val));
     if (mpfm.is_inf(val)) mpqm.set(q, 0);
     app * a = mk_c(c)->bvutil().mk_numeral(q.get(), sbits-1);
     mk_c(c)->save_ast_trail(a);
     RETURN_Z3(of_expr(a));
     Z3_CATCH_RETURN(nullptr);
 }
开发者ID:chadbrewbaker,项目名称:z3,代码行数:32,代码来源:api_fpa.cpp

示例11: Z3_model_has_interp

 bool Z3_API Z3_model_has_interp(Z3_context c, Z3_model m, Z3_func_decl a) {
     Z3_TRY;
     LOG_Z3_model_has_interp(c, m, a);
     CHECK_NON_NULL(m, 0);
     return to_model_ref(m)->has_interpretation(to_func_decl(a));
     Z3_CATCH_RETURN(false);
 }
开发者ID:NikolajBjorner,项目名称:z3,代码行数:7,代码来源:api_model.cpp

示例12: Z3_fpa_get_numeral_significand_string

 Z3_string Z3_API Z3_fpa_get_numeral_significand_string(Z3_context c, Z3_ast t) {
     Z3_TRY;
     LOG_Z3_fpa_get_numeral_significand_string(c, t);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(t, nullptr);
     CHECK_VALID_AST(t, nullptr);
     ast_manager & m = mk_c(c)->m();
     mpf_manager & mpfm = mk_c(c)->fpautil().fm();
     unsynch_mpq_manager & mpqm = mpfm.mpq_manager();
     family_id fid = mk_c(c)->get_fpa_fid();
     fpa_decl_plugin * plugin = (fpa_decl_plugin*)m.get_plugin(fid);
     SASSERT(plugin != 0);
     expr * e = to_expr(t);
     if (!is_app(e) || is_app_of(e, fid, OP_FPA_NAN) || !is_fp(c, t)) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         return "";
     }
     scoped_mpf val(mpfm);
     bool r = plugin->is_numeral(e, val);
     if (!r || !(mpfm.is_normal(val) || mpfm.is_denormal(val) || mpfm.is_zero(val) || mpfm.is_inf(val))) {
         SET_ERROR_CODE(Z3_INVALID_ARG);
         return "";
     }
     unsigned sbits = val.get().get_sbits();
     scoped_mpq q(mpqm);
     mpqm.set(q, mpfm.sig(val));
     if (!mpfm.is_denormal(val)) mpqm.add(q, mpfm.m_powers2(sbits - 1), q);
     mpqm.div(q, mpfm.m_powers2(sbits - 1), q);
     if (mpfm.is_inf(val)) mpqm.set(q, 0);
     std::stringstream ss;
     mpqm.display_decimal(ss, q, sbits);
     return mk_c(c)->mk_external_string(ss.str());
     Z3_CATCH_RETURN("");
 }
开发者ID:chadbrewbaker,项目名称:z3,代码行数:34,代码来源:api_fpa.cpp

示例13: verify_code

void
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  typedef double (*test_nested_loops_fn_type) (int n, double *a, double *b);
  CHECK_NON_NULL (result);

  test_nested_loops_fn_type test_nested_loops =
    (test_nested_loops_fn_type)gcc_jit_result_get_code (result,
						     "test_nested_loops");
  CHECK_NON_NULL (test_nested_loops);
  double test_a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9., 10.};
  double test_b[] = {5., 6., 7., 8., 9., 10., 1., 2., 3., 4.};
  double val = test_nested_loops (10, test_a, test_b);
  note ("test_nested_loops returned: %f", val);
  CHECK_VALUE (val, 3025.0);
}
开发者ID:0day-ci,项目名称:gcc,代码行数:16,代码来源:test-nested-loops.c

示例14: verify_code

void
verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
{
  CHECK_NON_NULL (result);
  /* We don't actually build any functions above;
     nothing more to verify.  */
}
开发者ID:0day-ci,项目名称:gcc,代码行数:7,代码来源:test-debug-strings.c

示例15: Z3_model_get_num_funcs

 unsigned Z3_API Z3_model_get_num_funcs(Z3_context c, Z3_model m) {
     Z3_TRY;
     LOG_Z3_model_get_num_funcs(c, m);
     RESET_ERROR_CODE();
     CHECK_NON_NULL(m, 0);
     return to_model_ref(m)->get_num_functions();
     Z3_CATCH_RETURN(0);
 }
开发者ID:NikolajBjorner,项目名称:z3,代码行数:8,代码来源:api_model.cpp


注:本文中的CHECK_NON_NULL函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。