CodeSonar C++ API
[For improved navigation, enable JavaScript.]
cs_point_set.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023, an unpublished work by CodeSecure, Inc.
3  * ALL RIGHTS RESERVED
4  *
5  * Copyright (c) 2013-2023, an unpublished work by GrammaTech, Inc.
6  * ALL RIGHTS RESERVED
7  *
8  * This software is furnished under a license and may be used and
9  * copied only in accordance with the terms of such license and the
10  * inclusion of the above copyright notice. This software or any
11  * other copies thereof may not be provided or otherwise made
12  * available to any other person. Title to and ownership of the
13  * software is retained by CodeSecure, Inc.
14  */
15 
16 #ifndef CS_POINT_SET_HPP
17 #define CS_POINT_SET_HPP
18 
19 #include "cs_point_set_decl.hpp"
20 #include "cs_scratchpad.hpp"
21 #include "cs_procedure_decl.hpp"
22 #include "cs_int_pair_set.hpp"
23 #include "cs_point_decl.hpp"
24 
27 namespace cs{
28  inline compunit_points_vector set_mixin<point_set>::categorize() const
29  {
30  typedef scratchpad<compunit_points> sp;
31  sp::to_vector_functor1_card<point_set, cs_pdg_vertex_set_categorize>
32  functor(unwrap());
33  return sp::to_vector(functor);
34  }
35 
36  inline compunit_points_pair_vector set_mixin<point_set>::categorize_by_file() const
37  {
38  typedef scratchpad<compunit_points_pair> sp;
39  sp::to_vector_functor1<point_set, cs_pdg_vertex_set_categorize_by_file>
40  functor(unwrap());
41  return sp::to_vector(functor);
42  }
43 
44  inline bool set_mixin<point_set>::intersects_procedure(procedure p) const
45  {
46  cs_boolean rv;
47  check(cs_pdg_vertex_set_intersects_pdg(
48  unwrap(), cglue<procedure>::unwrap(p), &rv));
49  return !!rv;
50  }
51 
52  inline std::vector<procedure> set_mixin<point_set>::procedures() const
53  {
54  typedef scratchpad<procedure> sp;
55  sp::to_vector_functor1<point_set, cs_pdg_vertex_set_pdgs>
56  functor(unwrap());
57  return sp::to_vector(functor);
58  }
59 
60  inline std::vector<point> set_mixin<point_set>::sort() const
61  {
62  typedef scratchpad<point> sp;
63  sp::to_vector_functor2<point_set, const char*, cs_pdg_vertex_set_sort>
64  functor(unwrap(), NULL);
65  return sp::to_vector(functor);
66  }
67 
68  inline std::vector<point> set_mixin<point_set>::sort(const std::string &file_name) const
69  {
70  typedef scratchpad<point> sp;
71  sp::to_vector_functor2<point_set, const char*, cs_pdg_vertex_set_sort>
72  functor(unwrap(), file_name.c_str());
73  return sp::to_vector(functor);
74  }
75 
76  inline int_pair_set set_mixin<point_set>::to_int_pair_set_in_sfileinst(sfileinst sfi) const
77  {
78  cs_int_pair_set rv;
79  check(cs_pdg_vertex_set_to_int_pair_set_in_sfid(
80  cglue<sfileinst>::unwrap(sfi),
81  unwrap(), &rv));
82  return cglue<int_pair_set>::wrap(rv, false);
83  }
84 
85  inline point_set cglue<point_set>::wrap(
86  const cs_pdg_vertex_set &c, bool frozen)
87  { return point_set(c, frozen); }
88 
89  inline cs_pdg_vertex_set cglue<point_set>::unwrap(const point_set &c)
90  { return c.unwrap(); }
91 
92  inline cs_ps_return_type set_mixin<point_set>::delegate_to_filter(cs_pdg_vertex v, void *_ctx)
93  {
94  delegate_to_filter_ctx *ctx =
95  static_cast<delegate_to_filter_ctx*>(_ctx);
96  /* This function is called by C code, which isn't going to
97  * unwind in reaction to a c++ exception properly.
98  * Unfortunately, this means we need to catch any exceptions
99  * here and now, and then re-raise them when everything
100  * finishes.
101  *
102  * Unfortunately, this means we need to know about every type
103  * of exception that could show up here.
104  */
105  if( ctx->res == result::SUCCESS )
106  {
107 #if !CS_CPP_NO_EXCEPTIONS
108  try{
109 #endif
110  return cglue<predsucc_filter_pair>::unwrap(
111  ctx->filter(point::));
112 #if! CS_CPP_NO_EXCEPTIONS
113  } catch(result &r) {
114  ctx->res = r;
115 #if defined(SWIG_BUILD)
116  } catch(Swig::DirectorException &) {
118 #endif
119  } catch(...) {
121  }
122 #endif
123  }
124  return cglue<predsucc_filter_pair>::unwrap(
125  predsucc_filter_pair(predsucc_filter_directive::STOP,
127  }
128 }
129 
130 #endif /* CS_POINT_SET_HPP */
Namespace for CodeSonar/CodeSurfer API.
Definition: cs_ast.hpp:33
static const result SUCCESS
The function was successful.
Definition: cs_result.hpp:22
static const predsucc_filter_directive STOP
Include: no, Continue: no.
Definition: cs_predsucc_filter_directive_decls.hpp:24
static const point_syntax_element NONE
All other program points.
Definition: cs_point_syntax_element_decls.hpp:21
std::vector< cs::compunit_points > compunit_points_vector
A std::vector of compunit_points.
Definition: cs_tplt_instantiations.hpp:354
static const result ERROR_FOREIGN_EXCEPTION
An exception occured in a non-native language.
Definition: cs_result.hpp:572
std::vector< cs::compunit_points_pair > compunit_points_pair_vector
A std::vector of compunit_points_pair.
Definition: cs_tplt_instantiations.hpp:347
static const result INTERNAL_ERROR_UNKNOWN
This error should never be seen by an API client, even when something is horribly wrong...
Definition: cs_result.hpp:1180