CodeSonar C++ API
[For improved navigation, enable JavaScript.]
csonar_visitor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023-2025, 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 CSONAR_VISITOR_H
17 #define CSONAR_VISITOR_H
18 
19 #include "csurf/src/api/cpp/cs_api.hpp"
20 #include "codesonar/src/progtrav/csonar_plugin.h"
21 
22 /* needed for step_path */
23 #include "codesonar/src/api/cpp/csonar_warningclass.hpp"
24 
25 #if !DOXYGEN_ONLY
26 #define DOX_ITER_TYPEDEF(gran, ...)
27 #endif
28 
29 #if defined(SWIGJAVA) || defined(SWIGCSHARP)
30 
31 /* Note that things like the JVM and .NET VM will more or less catch
32  * and semi-silently ignore uncaught exceptions. If you do not know
33  * where to look to see evidence that this has occurred, you might
34  * never realize it is happening. Worse yet, the C call stack may be
35  * unwound on the way to the enclosing catch, and the C code is not at
36  * all prepared for that, so we must prevent it from occurring.
37  */
38 
39 /* needed for std::cerr */
40 # ifndef SWIG
41 # include <iostream>
42 # endif
43 
44 # define CSONAR_VISITOR_TRY try
45 # define CSONAR_VISITOR_CATCH_NON_RESULT() \
46  catch( const std::exception &e ){ std::cerr << "Uncaught std::exception in " << __func__ << ": " << e.what() << std::endl; std::terminate(); } \
47  catch( ... ){ std::cerr << "Uncaught unknown exception in " << __func__ << std::endl; std::terminate(); }
48 
49 # define CSONAR_VISITOR_CATCH() \
50  catch( const result &r ){ std::cerr << "Uncaught cs::result in " << __func__ << ": " << r << std::endl; std::terminate(); } \
51  CSONAR_VISITOR_CATCH_NON_RESULT()
52 
53 #else
54 
55 # ifdef SWIG_BUILD
56 # define CSONAR_VISITOR_TRY try
57 # else
58 /* If not using SWIG, then there should be no catch blocks at all.
59  */
60 # define CSONAR_VISITOR_TRY
61 # endif
62 
63 /* If not using c# or java, there should be no enclosing try blocks
64  * higher up the call stack; any exception these would catch will be
65  * uncaught, which is better for diagnostics since we can see the
66  * location of the throw in the call stack.
67  */
68 # define CSONAR_VISITOR_CATCH_NON_RESULT()
69 # define CSONAR_VISITOR_CATCH()
70 
71 #endif
72 
80 namespace cs{
81  template <typename T>
82 
83 
185  class visitor{
186  bool registered;
187 
188  static void cs_visitor_delegate(typename T::ctype c, void *ctx)
189  {
190  visitor *self = static_cast<visitor*>(ctx);
191  CSONAR_VISITOR_TRY{
192  (*self)(T::);
193  }
194  SWIG_CATCH_DUMP_DIRECTOR_EXCEPTION(return)
195  CSONAR_VISITOR_CATCH()
196  }
197  public:
199  typedef T visitee;
200 #if defined(SWIG) && (defined(SWIGJAVA) || defined(SWIGCSHARP))
201  %rename(visit) operator();
202 #endif
203 
215  virtual void operator()(T) = 0;
216  friend class analysis;
217 
219  visitor(): registered(false){}
220 
222  visitor(const visitor &): registered(false){}
223  /* Once a visitor has been registered, it cannot be
224  * deleted.
225  */
226  virtual ~visitor()
227  {
228  if( registered )
229  check(CS_ERROR_IMMUTABLE_DATA_STRUCTURE);
230  }
231 
232  };
233 
234  /* specialize project because the C API doesn't have a project
235  * type.
236  */
237 
268  template <>
269  class visitor<project>{
270  bool registered;
271 
272  static void cs_visitor_delegate(void *ctx)
273  {
274  visitor *self = static_cast<visitor*>(ctx);
275  CSONAR_VISITOR_TRY{
276  (*self)(project::current());
277  }
278  SWIG_CATCH_DUMP_DIRECTOR_EXCEPTION(return)
279  CSONAR_VISITOR_CATCH()
280  }
281  public:
283  typedef project visitee;
284 
292  virtual void operator()(project p) = 0;
293 
295  visitor(): registered(false){}
296 
298  visitor(const visitor &): registered(false){}
299  /* Once a visitor has been registered, it cannot be
300  * deleted.
301  */
302  virtual ~visitor()
303  {
304  if( registered )
305  check(CS_ERROR_IMMUTABLE_DATA_STRUCTURE);
306  }
307 
308  friend class analysis;
309  };
312  /* If we discover we want other kinds of transformers, we can
313  * templatize later or create separate types.
314  */
315 #if defined(SWIG) && defined(SWIGPYTHON)
316 %rename(_listing_transformer) listing_transformer;
317 #endif
318 
319 
321  class listing_transformer{
322  bool registered;
323 
324  static cs_string cs_listing_transformer_delegate(
325  cs_sfid c1,
326  cs_line c2,
327  cs_const_string x,
328  void *ctx)
329  {
330  listing_transformer *self = static_cast<listing_transformer*>(ctx);
331  CSONAR_VISITOR_TRY{
332  std::string rv = (*self)(sfileinst::,
333  line_number::,
334  std::string(x));
335  size_t len = strlen( rv.c_str() ) + 1;
336  cs_string rv2 = csonar_allocate_listing_string( len );
337  memcpy( rv2, rv.c_str(), len );
338  return rv2;
339  }
340  SWIG_CATCH_DUMP_DIRECTOR_EXCEPTION(return NULL)
341  CSONAR_VISITOR_CATCH()
342  return NULL;
343  }
344  public:
345 #if defined(SWIG) && (defined(SWIGJAVA) || defined(SWIGCSHARP))
346  %rename(transform) operator();
347 #endif
348  virtual std::string operator()(sfileinst,line_number,std::string) = 0;
349  friend class analysis;
350  listing_transformer(): registered(false){}
351  listing_transformer(const listing_transformer &): registered(false){}
352  /* Once a transformer has been registered, it cannot be
353  * deleted.
354  */
355  virtual ~listing_transformer()
356  {
357  if( registered )
358  check(CS_ERROR_IMMUTABLE_DATA_STRUCTURE);
359  }
360  };
362 #if defined(SWIG) && defined(SWIGPYTHON)
363 %rename(_rpc_handler) rpc_handler;
364 #endif
365 
430  class rpc_handler{
431  bool registered;
432 
433  static cs_result cs_rpc_handler_delegate(
434  cs_const_string str,
435  cs_string *response,
436  void* ctx)
437  {
438  rpc_handler *self = static_cast<rpc_handler*>(ctx);
439  try{
440  std::string result = (*self)(std::string(str));
441  *response = csonar_rpc_response_alloc(result.size() + 1);
442  strncpy(*response, result.c_str(), result.size());
443  return CS_SUCCESS;
444  }
445  SWIG_CATCH_DUMP_DIRECTOR_EXCEPTION_AND_EXTRACT_CS_RESULT(return res)
446  catch (const result &r) {
447  return cglue<result>::unwrap(r);
448  }
449  CSONAR_VISITOR_CATCH_NON_RESULT();
450  }
451  public:
452 #if defined(SWIG) && defined(SWIGJAVA)
453  %javaexception("result") operator() { $action }
454 #endif
455 #if defined(SWIG) && (defined(SWIGJAVA) || defined(SWIGCSHARP))
456  %rename(handle) operator();
457 #endif
458 
470  virtual std::string operator()(std::string) = 0;
471  friend class analysis;
472 
474  rpc_handler(): registered(false){}
475 
477  rpc_handler(const rpc_handler &): registered(false){}
478  /* Once a handler has been registered, it cannot be
479  * deleted.
480  */
481  virtual ~rpc_handler()
482  {
483  if( registered )
484  check(CS_ERROR_IMMUTABLE_DATA_STRUCTURE);
485  }
486  };
487 
488 #if defined(SWIG) && defined(SWIGPYTHON)
489 %rename(_point_info_collector) point_info_collector;
490 %rename(_symbol_info_collector) symbol_info_collector;
491 #endif
492  CS_NODEFCTOR_TYPE(info_window_item_restriction);
493 
498  class info_window_item_restriction {
499  CS_ENUM_BOILERPLATE_NONAME(info_window_item_restriction, int,
500  (csuint64)_inner < (csuint64)3);
501 
507  std::string name() const
508  {
509  switch(inner)
510  {
511  case 0:
512  return std::string("ADD_ALWAYS");
513  case 1:
514  return std::string("ADD_NEW_TAG_KEY");
515  case 2:
516  return std::string("ADD_NEW_TAG");
517  }
518  return std::string();
519  }
523  static const info_window_item_restriction ADD_ALWAYS;
524 
528  static const info_window_item_restriction ADD_NEW_TAG_KEY;
529 
533  static const info_window_item_restriction ADD_NEW_TAG;
534  };
535  CS_ENUM_BOILERPLATE_FRIENDS(info_window_item_restriction,
536  ,
537  cs);
538 #ifdef CS_CPP_IMPL
539  const info_window_item_restriction info_window_item_restriction::ADD_ALWAYS = info_window_item_restriction(0);
540  const info_window_item_restriction info_window_item_restriction::ADD_NEW_TAG_KEY = info_window_item_restriction(1);
541  const info_window_item_restriction info_window_item_restriction::ADD_NEW_TAG = info_window_item_restriction(2);
542 #endif
543 
549  CS_NODEFCTOR_TYPE(info_window_item);
550 #ifdef SWIG
551  %feature("nodirector") info_window_item;
552 #endif
553 
562  class info_window_item {
563  /* No default constructor. */
564  info_window_item();
565  protected:
566  virtual cs_result add_item(cs_info_window_items_t info) = 0;
567 
574  std::string tag;
575 
593  std::string key;
594 
598  info_window_item_restriction restrict_add;
599 
600  info_window_item( std::string t,
601  std::string k,
602  info_window_item_restriction ra = info_window_item_restriction::ADD_ALWAYS )
603  : tag(t)
604  , key(k)
605  , restrict_add(ra) {};
606  public:
607  virtual ~info_window_item() {}
608 
609  friend class info_window;
610  friend class point_info_collector;
611  friend class symbol_info_collector;
612 
614  std::string as_string() const
615  {
616  std::stringstream out;
617  out << tag << ":" << restrict_add << ":" << key;
618  return out.str();
619  }
620 
622  std::string as_repr() const
623  { return CS_AS_REPR_FROM_STRING(info_window_item); }
624 
625  };
630  CS_NODEFCTOR_TYPE(info_window);
631 
636  class info_window {
637  /* info_window should never be constructed. Its entire
638  * interface is static.
639  */
640  info_window();
641 
646  class textfield : public info_window_item {
647  protected:
648  virtual cs_result add_item(cs_info_window_items_t info) {
649  cs_result rv = CS_SUCCESS;
650 
651  cs_const_string c_tag = this->tag.c_str();
652  cs_const_string c_key = this->key.c_str();
653  cs_const_string c_value = this->value.c_str();
654 
655  if ( this->restrict_add != info_window_item_restriction::ADD_ALWAYS ) {
656  // Test if tag or tag and key is present.
657  bool b = ( this->restrict_add == info_window_item_restriction::ADD_NEW_TAG_KEY );
658  rv = csonar_infowin_add_textfield( info, c_tag, b ? c_key : NULL, NULL );
659  }
660 
661  return ( rv == CS_ELEMENT_ALREADY_PRESENT ) ? rv :
662  csonar_infowin_add_textfield( info, c_tag, c_key, c_value );
663  }
665  std::string value;
666 
667  public:
678  textfield( std::string _tag,
679  std::string _key,
680  std::string _value,
681  info_window_item_restriction _ra = info_window_item_restriction::ADD_ALWAYS )
682  : info_window_item( _tag, _key, _ra )
683  , value(_value) {};
684  virtual ~textfield() {}
685  };
686 
694  class textbox : public info_window_item {
695  protected:
696  virtual cs_result add_item(cs_info_window_items_t info) {
697  cs_result rv = CS_SUCCESS;
698 
699  cs_const_string c_tag = this->tag.c_str();
700  cs_const_string c_key = this->key.c_str();
701  cs_const_string c_text = this->text.c_str();
702 
703  if ( this->restrict_add != info_window_item_restriction::ADD_ALWAYS ) {
704  // Test if tag or tag and key is present.
705  bool b = ( this->restrict_add == info_window_item_restriction::ADD_NEW_TAG_KEY );
706  rv = csonar_infowin_add_textbox( info, c_tag, b ? c_key : NULL, NULL );
707  }
708 
709  return ( rv == CS_ELEMENT_ALREADY_PRESENT ) ? rv :
710  csonar_infowin_add_textbox( info, c_tag, c_key, c_text );
711  }
712  std::string text;
713  public:
714  textbox( std::string _tag,
715  std::string _key,
716  std::string _text,
717  info_window_item_restriction _ra = info_window_item_restriction::ADD_ALWAYS )
718  : info_window_item( _tag, _key, _ra )
719  , text(_text) {};
720  virtual ~textbox() {}
721  };
722 
730  class button : public info_window_item {
731  protected:
732  virtual cs_result add_item(cs_info_window_items_t info) {
733  cs_result rv = CS_SUCCESS;
734 
735  cs_const_string c_tag = this->tag.c_str();
736  cs_const_string c_key = this->key.c_str();
737  cs_const_string c_rpc = this->rpc.c_str();
738 
739  if ( this->restrict_add != info_window_item_restriction::ADD_ALWAYS ) {
740  // Test if tag or tag and key is present.
741  bool b = ( this->restrict_add == info_window_item_restriction::ADD_NEW_TAG_KEY );
742  rv = csonar_infowin_add_button( info, c_tag, b ? c_key : NULL, NULL );
743  }
744 
745  return ( rv == CS_ELEMENT_ALREADY_PRESENT ) ? rv :
746  csonar_infowin_add_button( info, c_tag, c_key, c_rpc );
747  }
749  std::string rpc;
750 
751  public:
762  button( std::string _tag,
763  std::string _key,
764  std::string _rpc,
765  info_window_item_restriction _ra = info_window_item_restriction::ADD_ALWAYS )
766  : info_window_item( _tag, _key, _ra )
767  , rpc(_rpc) {};
768  virtual ~button() {}
769  };
770 
771  public:
772 
773 
798  static info_window_item*
799  create_textbox( std::string _tag,
800  std::string _key,
801  std::string _text,
802  info_window_item_restriction _ra = info_window_item_restriction::ADD_ALWAYS )
803  {
804  return new textbox( _tag, _key, _text, _ra );
805  }
806 
824  static info_window_item*
825  create_textfield( std::string _tag,
826  std::string _key,
827  std::string _value,
828  info_window_item_restriction _ra = info_window_item_restriction::ADD_ALWAYS )
829  {
830  return new textfield( _tag, _key, _value, _ra );
831  }
832 
855  static info_window_item*
856  create_button( std::string _tag,
857  std::string _key,
858  std::string _rpc,
859  info_window_item_restriction _ra = info_window_item_restriction::ADD_ALWAYS )
860  {
861  return new button( _tag, _key, _rpc, _ra );
862  }
863  };
865 #ifdef SWIG
866 }
867 %template(info_window_item_vector) std::vector<cs::info_window_item*>;
868 namespace cs{
869 #endif
870 
881  class point_info_collector{
882  bool registered;
883 
884  static void cs_point_info_collector_delegate(
885  cs_pdg_vertex v,
886  cs_sfid sf,
887  cs_line ln,
888  cs_info_window_items_t info,
889  void *ctx)
890  {
891  point_info_collector *self = static_cast<point_info_collector*>(ctx);
892  CSONAR_VISITOR_TRY{
893  std::vector<info_window_item*> vi = (*self)(point::,
894  sfileinst::,
895  line_number::);
896  for( std::vector<info_window_item*>::const_iterator it = vi.begin();
897  it != vi.end();
898  ++it )
899  {
900  cs_result rv = (*it)->add_item( info );
901  if( (*it)->restrict_add == info_window_item_restriction::ADD_ALWAYS ||
902  rv != CS_ELEMENT_ALREADY_PRESENT )
903  {
904  check( rv );
905  }
906  delete *it;
907  }
908  }
909  SWIG_CATCH_DUMP_DIRECTOR_EXCEPTION(return)
910  CSONAR_VISITOR_CATCH()
911  }
912  public:
913 #if defined(SWIG) && (defined(SWIGJAVA) || defined(SWIGCSHARP))
914  %rename(collect) operator();
915 #endif
916 
933  virtual std::vector<info_window_item*>
934  operator()(point p, sfileinst sfi, line_number ln) = 0;
935 
936  friend class analysis;
937 
939  point_info_collector(): registered(false){}
940 
942  point_info_collector(const point_info_collector &): registered(false){}
943  /* Once a collector has been registered, it cannot be
944  * deleted.
945  */
946  virtual ~point_info_collector()
947  {
948  if( registered )
949  check(CS_ERROR_IMMUTABLE_DATA_STRUCTURE);
950  }
951  };
969  class symbol_info_collector{
970  bool registered;
971 
972  static void cs_symbol_info_collector_delegate(
973  cs_abs_loc al,
974  cs_info_window_items_t info,
975  void *ctx)
976  {
977  symbol_info_collector *self = static_cast<symbol_info_collector*>(ctx);
978  CSONAR_VISITOR_TRY{
979  std::vector<info_window_item*> vi = (*self)(symbol::);
980  for( std::vector<info_window_item*>::iterator it = vi.begin();
981  it != vi.end();
982  ++it )
983  {
984  bool add_always = (*it)->restrict_add == info_window_item_restriction::ADD_ALWAYS;
985  cs_result rv = (*it)->add_item( info );
986  delete *it;
987  if(add_always || rv != CS_ELEMENT_ALREADY_PRESENT )
988  {
989  check( rv );
990  }
991  }
992  }
993  SWIG_CATCH_DUMP_DIRECTOR_EXCEPTION(return)
994  CSONAR_VISITOR_CATCH()
995  }
996  public:
997 #if defined(SWIG) && (defined(SWIGJAVA) || defined(SWIGCSHARP))
998  %rename(collect) operator();
999 #endif
1000 
1001 
1010  virtual std::vector<info_window_item*> operator()(symbol s) = 0;
1011 
1012 
1013  friend class analysis;
1014 
1015 
1017  symbol_info_collector(): registered(false){}
1018 
1019 
1021  symbol_info_collector(const symbol_info_collector &): registered(false){}
1022  /* Once a collector has been registered, it cannot be
1023  * deleted.
1024  */
1025  virtual ~symbol_info_collector()
1026  {
1027  if( registered )
1028  check(CS_ERROR_IMMUTABLE_DATA_STRUCTURE);
1029  }
1030  };
1045  CS_ENUM_BOILERPLATE_UB(xform_query_result, cs_xform_query_result,
1046  rv = csonar_xform_query_result_name(inner),
1047  csxqr_count);
1049  };
1050  CS_ENUM_BOILERPLATE_FRIENDS(xform_query_result,
1051  friend class step_xform;,
1053  );
1055 
1069  CS_ENUM_BOILERPLATE_UB(xform_operator, cs_xform_operator,
1070  rv = csonar_xform_operator_name(inner),
1071  csxfo_count);
1072 #include "cs_xform_operator_decls.hpp"
1073  };
1074  CS_ENUM_BOILERPLATE_FRIENDS(xform_operator,
1075  friend class step_xform;,
1077  );
1078 #include "cs_xform_operator_defs.hpp"
1079 
1080 
1124  CS_ENUM_BOILERPLATE_UB(xform_expr_mode, cs_xform_expr_mode,
1125  rv = csonar_xform_expr_mode_name(inner),
1126  csxem_count);
1128  };
1129  CS_ENUM_BOILERPLATE_FRIENDS(xform_expr_mode,
1130  friend class xform_expr;,
1132  );
1133 #include "cs_xform_expr_mode_defs.hpp"
1134 
1135 
1136  CS_CLASS_FDECL_NO_DCTOR(access_path);
1186  friend class cglue<access_path>;
1187  cs_access_path inner;
1189  access_path(cs_access_path_operator op,
1190  size_t offset = 0)
1191  {
1192  inner.kind = op;
1193  inner.variant.offset_in_bits = offset;
1194  }
1195 
1196  access_path();
1197 
1198  cs_access_path unwrap() const
1199  { return inner; }
1200  public:
1201 
1208  { return access_path(CSAPOP_ADDR); }
1209 
1216  { return access_path(CSAPOP_STAR); }
1217 
1218 
1226  static access_path offset_in_bits(size_t off)
1227  { return access_path(CSAPOP_OFFSET_IN_BITS, off); }
1228 
1230  std::string as_string() const
1231  {
1232  switch( inner.kind )
1233  {
1234  case CSAPOP_ADDR:
1235  return "&";
1236  case CSAPOP_STAR:
1237  return "*";
1238  case CSAPOP_OFFSET_IN_BITS:
1239  {
1240  std::stringstream out;
1241  out << "[";
1242  out << inner.variant.offset_in_bits;
1243  out << "]";
1244  return out.str();
1245  }
1246  default:
1247  check(CS_ERROR_INVALID_ARGUMENT);
1248  return "INVALID";
1249  }
1250  }
1251 
1253  std::string as_repr() const
1254  { return CS_AS_REPR_FROM_STRING(access_path); }
1255  };
1256 #ifdef SWIG
1257 }
1258 %template(access_path_vector) std::vector<cs::access_path>;
1259 namespace cs{
1260 #endif
1261 
1262  template<>
1263  class cglue<access_path>
1264  {
1265  friend class access_path;
1266  friend class step_xform;
1267  friend class xform_expr;
1268  cglue();
1269  public:
1270  typedef cs_access_path ctype;
1271  typedef access_path type;
1272  CS_CXX_API_CGLUE_ACCESS_MODIFIER:
1273 
1274  static ctype unwrap(const type &c)
1275  { return c.unwrap(); }
1276 
1277  static cs_access_path *unwrap(
1278  const std::vector<access_path> &ap)
1279  {
1280  if( !ap.size() )
1281  return NULL;
1282  cs_access_path *c_ap = new cs_access_path[ap.size() + 1];
1283  size_t i;
1284  for( i = 0; i < ap.size(); i++ )
1285  c_ap[i] = cglue<access_path>::unwrap(ap[i]);
1286  c_ap[i].kind = CSAPOP_TERMINATOR;
1287  return c_ap;
1288  }
1289  };
1290 
1294  friend class step_xform;
1295  bool m_has_upper, m_has_lower, m_feasible, m_modified;
1296  csint32 m_upper, m_lower;
1297  bool m_upper_suspect, m_lower_suspect;
1299  bool _has_upper, bool _has_lower, bool _feasible, bool _modified,
1300  csint32 _upper, bool _upper_suspect,
1301  csint32 _lower, bool _lower_suspect)
1302  : m_has_upper(_has_upper), m_has_lower(_has_lower),
1303  m_feasible(_feasible), m_modified(_modified),
1304  m_upper(_upper), m_lower(_lower),
1305  m_upper_suspect(_upper_suspect),
1306  m_lower_suspect(_lower_suspect)
1307  {}
1308 
1309  public:
1315  bool has_upper() const
1316  { return m_has_upper; }
1317 
1323  bool has_lower() const
1324  { return m_has_lower; }
1325 
1332  csint32 get_upper() const
1333  {
1334  if( !has_upper() )
1335  check(CS_NO_UPPER_BOUND);
1336  return m_upper;
1337  }
1338 
1344  bool get_upper_suspect() const
1345  {
1346  return m_upper_suspect;
1347  }
1348 
1355  csint32 get_lower() const
1356  {
1357  if( !has_lower() )
1358  check(CS_NO_LOWER_BOUND);
1359  return m_lower;
1360  }
1361 
1367  bool get_lower_suspect() const
1368  {
1369  return m_lower_suspect;
1370  }
1371 
1378  bool feasible() const
1379  { return m_feasible; }
1380 
1381 
1403  bool modified() const
1404  { return m_modified; }
1405 
1407  std::string as_string() const
1408  {
1409  std::stringstream out;
1410  if( feasible() )
1411  {
1412  if( modified() )
1413  {
1414  if( has_lower() )
1415  {
1416  out << "[";
1417  out << get_lower();
1418  if( get_lower_suspect() )
1419  out << "?";
1420  }
1421  else
1422  {
1423  out << "(-inf";
1424  }
1425  out << ", ";
1426  if( has_upper() )
1427  {
1428  out << get_upper();
1429  if( get_upper_suspect() )
1430  out << "?";
1431  out << "]";
1432  }
1433  else
1434  {
1435  out << "+inf)";
1436  }
1437  }
1438  else
1439  {
1440  out << "not modified";
1441  }
1442  }
1443  else
1444  {
1445  out << "infeasible";
1446  }
1447  return out.str();
1448  }
1449 
1451  std::string as_repr() const
1452  { return CS_AS_REPR_FROM_STRING(xform_query_bounds_result); }
1453  };
1454 
1455 
1466  class xform_expr{
1468  friend class cglue<xform_expr>;
1470  csint32 a, b, c;
1471  symbol *base;
1472  std::vector<access_path> ap;
1473  std::string attribute;
1474  xform_expr_mode mode;
1475 
1476  /* The returned value has lots of pointers into this.
1477  * Beware. */
1478  cs_xform_expr unwrap() const
1479  {
1480  cs_xform_expr rv;
1481  rv.a = a;
1482  rv.b = b;
1483  rv.c = c;
1484  rv.x_base = base ? cglue<symbol>::unwrap(*base) : CS_ABS_LOC_NULL;
1485  rv.x_ap = cglue<access_path>::unwrap(ap);
1486  rv.x_attribute = const_cast<char *>(attribute.size() ? attribute.c_str() : NULL);
1487  rv.x_mode = cglue<xform_expr_mode>::unwrap(mode);
1488  return rv;
1489  }
1490 
1491  void validate();
1492  public:
1493 
1494  typedef const cs_xform_expr *ctype;
1540  xform_expr(symbol _base,
1541  const std::vector<access_path> &_ap = std::vector<access_path>(),
1542  const std::string &_attribute = "",
1544  csint32 _a = 1, csint32 _b = 0, csint32 _c = 1)
1545  : a(_a), b(_b), c(_c)
1546  , base(new symbol(_base))
1547  , ap(_ap), attribute(_attribute)
1548  , mode(_mode)
1549  {
1550  validate();
1551  }
1552 
1577  xform_expr(csint32 _b, csint32 _c = 1)
1578  : a(0), b(_b), c(_c), base(NULL), mode(xform_expr_mode::PRE)
1579  {
1580  validate();
1581  }
1582 
1583  ~xform_expr()
1584  {
1585  if( base )
1586  delete base;
1587  }
1588 
1590  std::string as_string() const;
1591 
1593  std::string as_repr() const
1594  { return CS_AS_REPR_FROM_STRING(xform_expr); }
1595  };
1596 
1597  template<>
1598  class cglue<xform_expr>{
1599  friend class xform_expr;
1600  friend class step_xform;
1601  cglue();
1602  public:
1603  typedef cs_xform_expr ctype;
1604  typedef xform_expr type;
1605  CS_CXX_API_CGLUE_ACCESS_MODIFIER:
1606 
1607  static ctype unwrap(const type &c)
1608  { return c.unwrap(); }
1609 
1610  static void cleanup(ctype &c)
1611  {
1612  if( c.x_ap )
1613  delete[] c.x_ap;
1614  }
1615  };
1616 
1617  inline void xform_expr::validate()
1618  {
1619  cs_xform_expr cexpr = cglue<xform_expr>::unwrap(*this);
1620  cs_result r = csonar_xform_expr_validate( &cexpr );
1621  cglue<xform_expr>::cleanup(cexpr);
1622  if( r != CS_SUCCESS )
1623  {
1624  /* Do not call the dtor here because it will also do the
1625  * implicit destruction tasks (e.g., ap).
1626  */
1627  if( base )
1628  delete base;
1629  check(r);
1630  }
1631  }
1632 
1633  inline std::string xform_expr::as_string() const
1634  {
1635  cs_xform_expr cexpr = cglue<xform_expr>::unwrap(*this);
1636  string_scratchpad::
1637  to_string_functor1_limit<xform_expr, csonar_xform_expr_to_string>
1638  functor(&cexpr, -1);
1639  std::string rv = string_scratchpad::to_string(functor);
1640  cglue<xform_expr>::cleanup(cexpr);
1641  return rv;
1642  }
1643 
1649  class step_xform{
1651  friend class cglue<step_xform>;
1652  cs_step_csonar_xform_t inner;
1653  step_xform(cs_step_csonar_xform_t _inner): inner(_inner){}
1655  step_xform();
1656  cs_step_csonar_xform_t unwrap() const
1657  { return inner; }
1658 
1659  public:
1660  typedef cs_step_csonar_xform_t ctype;
1661 
1662  step_xform(const step_xform &other): inner(other.inner){}
1663 
1665  std::string as_repr() const
1666  { return CS_AS_REPR(step_xform, std::string("...")); }
1667 
1669  std::string as_string() const
1670  { return as_repr(); }
1671 
1680  xform_query_bounds_result query_bounds(
1681  const xform_expr &expr)
1682  {
1683  cs_xform_expr c_expr = cglue<xform_expr>::unwrap(expr);
1684  csint32 lb = 0, ub = 0;
1685  cs_boolean lb_suspect = cs_false, ub_suspect = cs_false;
1686  cs_result r = csonar_xform_query_bounds(
1687  inner, &c_expr,
1688  &lb, &lb_suspect, &ub, &ub_suspect );
1689  cglue<xform_expr>::cleanup(c_expr);
1690  bool u = false, l = false, f = false, m = false;
1691  switch( r )
1692  {
1693  case CS_SUCCESS:
1694  u = true;
1695  l = true;
1696  f = true;
1697  m = true;
1698  break;
1699  case CS_NO_LOWER_BOUND:
1700  u = true;
1701  l = false;
1702  f = true;
1703  m = true;
1704  break;
1705  case CS_NO_UPPER_BOUND:
1706  u = false;
1707  l = true;
1708  f = true;
1709  m = true;
1710  break;
1711  case CS_NO_BOUNDS:
1712  u = false;
1713  l = false;
1714  f = true;
1715  m = true;
1716  break;
1717  case CS_ELEMENT_NOT_PRESENT:
1718  u = false;
1719  l = false;
1720  f = true;
1721  m = false;
1722  break;
1723  case CS_PATH_INFEASIBLE:
1724  u = false;
1725  l = false;
1726  f = false;
1727  m = false;
1728  break;
1729  default:
1730  check(r);
1731  u = false;
1732  l = false;
1733  f = false;
1734  m = false;
1735  break;
1736  }
1738  u, l, f, m, ub, ub_suspect, lb, lb_suspect );
1739  }
1740 
1741 
1761  xform_query_result query(
1762  const xform_expr &lhs,
1763  xform_operator op,
1764  const xform_expr &rhs) const
1765  {
1766  cs_xform_expr c_lhs = cglue<xform_expr>::unwrap(lhs);
1767  cs_xform_expr c_rhs = cglue<xform_expr>::unwrap(rhs);
1768  cs_xform_query_result res;
1769  check(csonar_xform_query(
1770  inner,
1771  &c_lhs,
1772  cglue<xform_operator>::unwrap(op),
1773  &c_rhs,
1774  &res));
1775  cglue<xform_expr>::cleanup(c_rhs);
1776  cglue<xform_expr>::cleanup(c_lhs);
1777  return xform_query_result::;
1778  }
1779 
1781  CS_BOILERPLATE_HASH_TYPE hash() const
1782  { return static_cast<CS_BOILERPLATE_HASH_TYPE>(reinterpret_cast<uintptr_t>(inner)); }
1783  };
1784  CS_IR_BOILERPLATE_NONMEMBERS(step_xform, cs);
1785 
1786  template<>
1787  class cglue<step_xform>{
1788  friend class step_state;
1789  cglue();
1790  public:
1791  typedef cs_step_csonar_xform_t ctype;
1792  typedef step_xform type;
1793  CS_CXX_API_CGLUE_ACCESS_MODIFIER:
1794 
1795  static type wrap(const ctype &c)
1796  { return step_xform(c); }
1797  static ctype unwrap(const type &c)
1798  { return c.unwrap(); }
1799  };
1800 
1801 /* satisfy the one definiton rule by renaming some swig-generated stuff */
1802 #if defined(SWIGCSHARP)
1803 #define SwigDirector_step_state CSharp_SwigDirector_step_state
1804 #define SwigDirector_project_visitor CSharp_SwigDirector_project_visitor
1805 #define SwigDirector_compunit_visitor CSharp_SwigDirector_compunit_visitor
1806 #define SwigDirector_procedure_visitor CSharp_SwigDirector_procedure_visitor
1807 #define SwigDirector_point_visitor CSharp_SwigDirector_point_visitor
1808 #define SwigDirector_symbol_visitor CSharp_SwigDirector_symbol_visitor
1809 #define SwigDirector_sfileinst_visitor CSharp_SwigDirector_sfileinst_visitor
1810 #define SwigDirector_listing_transformer CSharp_SwigDirector_listing_transformer
1811 #define SwigDirector_rpc_handler CSharp_SwigDirector_rpc_handler
1812 #define SwigDirector_point_info_collector CSharp_SwigDirector_point_info_collector
1813 #define SwigDirector_symbol_info_collector CSharp_SwigDirector_symbol_info_collector
1814 #elif defined(SWIGJAVA)
1815 #define SwigDirector_step_state Java_SwigDirector_step_state
1816 #define SwigDirector_project_visitor Java_SwigDirector_project_visitor
1817 #define SwigDirector_compunit_visitor Java_SwigDirector_compunit_visitor
1818 #define SwigDirector_procedure_visitor Java_SwigDirector_procedure_visitor
1819 #define SwigDirector_point_visitor Java_SwigDirector_point_visitor
1820 #define SwigDirector_symbol_visitor Java_SwigDirector_symbol_visitor
1821 #define SwigDirector_sfileinst_visitor Java_SwigDirector_sfileinst_visitor
1822 #define SwigDirector_listing_transformer Java_SwigDirector_listing_transformer
1823 #define SwigDirector_rpc_handler Java_SwigDirector_rpc_handler
1824 #define SwigDirector_point_info_collector Java_SwigDirector_point_info_collector
1825 #define SwigDirector_symbol_info_collector Java_SwigDirector_symbol_info_collector
1826 #endif
1827 
1880  class step_state{
1881  friend class analysis;
1882  bool registered;
1883  static void *delegate_open( void *ctx )
1884  {
1885  step_state *init = static_cast<step_state*>(ctx);
1886  CSONAR_VISITOR_TRY{
1887  return init ? static_cast<void*>(init->copy()) : NULL;
1888  }
1889  SWIG_CATCH_DUMP_DIRECTOR_EXCEPTION(return NULL)
1890  CSONAR_VISITOR_CATCH()
1891  }
1892  static void *delegate_copy( void *_self, void *ctx )
1893  {
1894  step_state *self = static_cast<step_state*>(_self);
1895  CSONAR_VISITOR_TRY{
1896  return self ? static_cast<void*>(self->copy()) : NULL;
1897  }
1898  SWIG_CATCH_DUMP_DIRECTOR_EXCEPTION(return NULL)
1899  CSONAR_VISITOR_CATCH()
1900  }
1901  static void delegate_close( void *_self, void *ctx )
1902  {
1903  step_state *self = static_cast<step_state*>(_self);
1904  if( self )
1905  delete self;
1906  }
1907  static void *delegate_transition(
1908  cs_step_user_state_t _self,
1909  cs_pdg_vertex source,
1910  cs_edge_label label,
1911  cs_pdg_vertex destination,
1912  cs_step_csonar_xform_t since_entry,
1913  cs_step_csonar_xform_t this_edge,
1914  cs_step_path_t path,
1915  cs_visitor_ctx_t ctx)
1916  {
1917  step_state *self = static_cast<step_state*>(_self);
1918  if( !self )
1919  return NULL;
1920  CSONAR_VISITOR_TRY{
1921  self->transition(
1922  point::,
1923  edge_label::,
1924  point::,
1925  step_xform::ENTRY,
1926  step_xform::EDGE,
1927  step_path::);
1928  }
1929  SWIG_CATCH_DUMP_DIRECTOR_EXCEPTION(return NULL)
1930  CSONAR_VISITOR_CATCH()
1931  return _self;
1932  }
1933 
1934  static cs_step_visitor_dispatch_t *get_delegate()
1935  {
1936  static cs_step_visitor_dispatch_t delegate = {
1937  delegate_open,
1938  delegate_copy,
1939  delegate_close,
1940  delegate_transition
1941  };
1942  return &delegate;
1943  }
1944 
1945  public:
1946 
1948  virtual std::string as_repr() const
1949  { return CS_AS_REPR(step_state, std::string("...")); }
1950 
1952  virtual std::string as_string() const
1953  { return as_repr(); }
1954 
1962  step_state(): registered(false){}
1963 
1964 
1972  step_state(const step_state &): registered(false){}
1973 
1974 
2010  virtual step_state *copy() const = 0;
2011 
2012 
2020  virtual ~step_state()
2021  {
2022  if( registered )
2023  check(CS_ERROR_IMMUTABLE_DATA_STRUCTURE);
2024  }
2025 
2063  virtual void transition(
2064  point source,
2065  edge_label label,
2066  point destination,
2067  step_xform since_entry,
2068  step_xform this_edge,
2069  step_path path) = 0;
2070  };
2071 
2083  class analysis{
2084  analysis();
2085 
2086 #ifndef SWIG
2087  template <typename V,
2088  cs_result (*add_visitor)(
2089  cs_langs_t,
2090  void (*)(typename V::visitee::ctype, cs_visitor_ctx_t),
2091  cs_visitor_ctx_t) >
2092  class visitor_adder
2093  {
2094  public:
2095  template <size_t N>
2096  static void add(const language (&langs)[N],
2097  V *v)
2098  {
2099  cs_language *clangs = new cs_language[N+1];
2100  size_t i;
2101  for( i = 0; i < N; i++ )
2102  clangs[i] = cglue<language>::unwrap(langs[i]);
2103  clangs[i] = csl_null;
2104  cs_result r = add_visitor(clangs, V::cs_visitor_delegate,
2105  static_cast<void*>(v));
2106  delete[] clangs;
2107  check(r);
2108  v->registered = true;
2109  }
2110 
2111  static void add(const std::vector<language> &langs,
2112  V *v)
2113  {
2114  cs_language *clangs = new cs_language[langs.size()+1];
2115  size_t i;
2116  for( i = 0; i < langs.size(); i++ )
2117  clangs[i] = cglue<language>::unwrap(langs[i]);
2118  clangs[i] = csl_null;
2119  cs_result r = add_visitor(clangs, V::cs_visitor_delegate,
2120  static_cast<void*>(v));
2121  delete[] clangs;
2122  check(r);
2123  v->registered = true;
2124  }
2125  };
2126 
2127  template <typename V,
2128  cs_result (*add_visitor)(
2129  cs_langs_t,
2130  void (*)(cs_visitor_ctx_t),
2131  cs_visitor_ctx_t) >
2132  class thunk_visitor_adder
2133  {
2134  public:
2135  template <size_t N>
2136  static void add(const language (&langs)[N],
2137  V *v)
2138  {
2139  cs_language *clangs = new cs_language[N+1];
2140  size_t i;
2141  for( i = 0; i < N; i++ )
2142  clangs[i] = cglue<language>::unwrap(langs[i]);
2143  clangs[i] = csl_null;
2144  cs_result r = add_visitor(clangs, V::cs_visitor_delegate,
2145  static_cast<void*>(v));
2146  delete[] clangs;
2147  check(r);
2148  v->registered = true;
2149  }
2150 
2151  static void add(const std::vector<language> &langs,
2152  V *v)
2153  {
2154  cs_language *clangs = new cs_language[langs.size()+1];
2155  size_t i;
2156  for( i = 0; i < langs.size(); i++ )
2157  clangs[i] = cglue<language>::unwrap(langs[i]);
2158  clangs[i] = csl_null;
2159  cs_result r = add_visitor(clangs, V::cs_visitor_delegate,
2160  static_cast<void*>(v));
2161  delete[] clangs;
2162  check(r);
2163  v->registered = true;
2164  }
2165  };
2166 
2167  template <size_t N>
2168  static void add(const language (&langs)[N],
2169  listing_transformer *v)
2170  {
2171  cs_language *clangs = new cs_language[N+1];
2172  size_t i;
2173  for( i = 0; i < N; i++ )
2174  clangs[i] = cglue<language>::unwrap(langs[i]);
2175  clangs[i] = csl_null;
2176  cs_result r = csonar_add_listing_transformer(
2177  clangs,
2178  listing_transformer::cs_listing_transformer_delegate,
2179  static_cast<void*>(v));
2180  delete[] clangs;
2181  check(r);
2182  v->registered = true;
2183  }
2184 
2185  static void add(const std::vector<language> &langs,
2186  listing_transformer *v)
2187  {
2188  cs_language *clangs = new cs_language[langs.size()+1];
2189  size_t i;
2190  for( i = 0; i < langs.size(); i++ )
2191  clangs[i] = cglue<language>::unwrap(langs[i]);
2192  clangs[i] = csl_null;
2193  cs_result r = csonar_add_listing_transformer(
2194  clangs,
2195  listing_transformer::cs_listing_transformer_delegate,
2196  static_cast<void*>(v));
2197  delete[] clangs;
2198  check(r);
2199  v->registered = true;
2200  }
2201 
2202  template <size_t N>
2203  static void add(const language (&langs)[N],
2204  point_info_collector *v)
2205  {
2206  cs_language *clangs = new cs_language[N+1];
2207  size_t i;
2208  for( i = 0; i < N; i++ )
2209  clangs[i] = cglue<language>::unwrap(langs[i]);
2210  clangs[i] = csl_null;
2211  cs_result r = csonar_add_vinfo_collector(
2212  clangs,
2213  point_info_collector::cs_point_info_collector_delegate,
2214  static_cast<void*>(v));
2215  delete[] clangs;
2216  check(r);
2217  v->registered = true;
2218  }
2219 
2220  static void add(const std::vector<language> &langs,
2221  point_info_collector *v)
2222  {
2223  cs_language *clangs = new cs_language[langs.size()+1];
2224  size_t i;
2225  for( i = 0; i < langs.size(); i++ )
2226  clangs[i] = cglue<language>::unwrap(langs[i]);
2227  clangs[i] = csl_null;
2228  cs_result r = csonar_add_vinfo_collector(
2229  clangs,
2230  point_info_collector::cs_point_info_collector_delegate,
2231  static_cast<void*>(v));
2232  delete[] clangs;
2233  check(r);
2234  v->registered = true;
2235  }
2236 
2237  template <size_t N>
2238  static void add(const language (&langs)[N],
2239  symbol_info_collector *v)
2240  {
2241  cs_language *clangs = new cs_language[N+1];
2242  size_t i;
2243  for( i = 0; i < N; i++ )
2244  clangs[i] = cglue<language>::unwrap(langs[i]);
2245  clangs[i] = csl_null;
2246  cs_result r = csonar_add_alinfo_collector(
2247  clangs,
2248  symbol_info_collector::cs_symbol_info_collector_delegate,
2249  static_cast<void*>(v));
2250  delete[] clangs;
2251  check(r);
2252  v->registered = true;
2253  }
2254 
2255  static void add(const std::vector<language> &langs,
2256  symbol_info_collector *v)
2257  {
2258  cs_language *clangs = new cs_language[langs.size()+1];
2259  size_t i;
2260  for( i = 0; i < langs.size(); i++ )
2261  clangs[i] = cglue<language>::unwrap(langs[i]);
2262  clangs[i] = csl_null;
2263  cs_result r = csonar_add_alinfo_collector(
2264  clangs,
2265  symbol_info_collector::cs_symbol_info_collector_delegate,
2266  static_cast<void*>(v));
2267  delete[] clangs;
2268  check(r);
2269  v->registered = true;
2270  }
2271 
2272 #endif
2273  public:
2281  static analysis_mode get_mode()
2282  { return cglue<analysis_mode>::wrap(csonar_get_analysis_mode()); }
2283 
2284 
2295  static multiprocess_mode get_multiprocess_mode()
2296  { return cglue<multiprocess_mode>::wrap(csonar_get_multiprocess_mode()); }
2297 
2298  DISOWN_PARAMETER(visitor *v);
2299 
2300 
2301 
2316  template <size_t N>
2317  static void add_project_visitor(
2318  visitor<project> *v,
2319  const language (&langs)[N])
2320  {
2321  thunk_visitor_adder<visitor<project>, csonar_add_program_visitor>
2322  ::add(langs, v);
2323  }
2324 
2358  static void add_project_visitor(
2359  visitor<project> *v,
2360  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
2361  {
2362  thunk_visitor_adder<visitor<project>, csonar_add_program_visitor>
2363  ::add(langs, v);
2364  }
2365 
2366 
2381  template <size_t N>
2382  static void add_compunit_visitor(
2384  const language (&langs)[N])
2385  {
2386  visitor_adder<visitor<compunit>, csonar_add_uid_visitor>
2387  ::add(langs, v);
2388  }
2389 
2434  static void add_compunit_visitor(
2435  visitor<compunit> *v,
2436  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
2437  {
2438  visitor_adder<visitor<compunit>, csonar_add_uid_visitor>
2439  ::add(langs, v);
2440  }
2441 
2442 
2459  template <size_t N>
2460  static void add_procedure_visitor(
2461  visitor<procedure> *v,
2462  const language (&langs)[N])
2463  {
2464  visitor_adder<visitor<procedure>, csonar_add_pdg_visitor>
2465  ::add(langs, v);
2466  }
2467 
2520  static void add_procedure_visitor(
2521  visitor<procedure> *v,
2522  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
2523  {
2524  visitor_adder<visitor<procedure>, csonar_add_pdg_visitor>
2525  ::add(langs, v);
2526  }
2527 
2543  template <size_t N>
2544  static void add_symbol_visitor(
2546  const language (&langs)[N])
2547  {
2548  visitor_adder<visitor<symbol>, csonar_add_abs_loc_visitor>
2549  ::add(langs, v);
2550  }
2551 
2604  static void add_symbol_visitor(
2605  visitor<symbol> *v,
2606  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
2607  {
2608  visitor_adder<visitor<symbol>, csonar_add_abs_loc_visitor>
2609  ::add(langs, v);
2610  }
2611 
2612 
2628  template <size_t N>
2629  static void add_point_visitor(
2630  visitor<point> *v,
2631  const language (&langs)[N])
2632  {
2633  visitor_adder<visitor<point>, csonar_add_pdg_vertex_visitor>
2634  ::add(langs, v);
2635  }
2636 
2688  static void add_point_visitor(
2689  visitor<point> *v,
2690  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
2691  {
2692  visitor_adder<visitor<point>, csonar_add_pdg_vertex_visitor>
2693  ::add(langs, v);
2694  }
2695 
2696 
2712  template <size_t N>
2713  static void add_procedure_finish_visitor(
2714  visitor<procedure> *v,
2715  const language (&langs)[N])
2716  {
2717  visitor_adder<visitor<procedure>, csonar_add_pdg_finish_visitor>
2718  ::add(langs, v);
2719  }
2720 
2773  static void add_procedure_finish_visitor(
2774  visitor<procedure> *v,
2775  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
2776  {
2777  visitor_adder<visitor<procedure>, csonar_add_pdg_finish_visitor>
2778  ::add(langs, v);
2779  }
2780 
2781 
2797  template <size_t N>
2798  static void add_sfile_visitor(
2799  visitor<sfileinst> *v,
2800  const language (&langs)[N])
2801  {
2802  visitor_adder<visitor<sfileinst>, csonar_add_sf_visitor>
2803  ::add(langs, v);
2804  }
2805 
2880  static void add_sfile_visitor(
2881  visitor<sfileinst> *v,
2882  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
2883  {
2884  visitor_adder<visitor<sfileinst>, csonar_add_sf_visitor>
2885  ::add(langs, v);
2886  }
2887 
2888 
2904  template <size_t N>
2905  static void add_sfileinst_visitor(
2906  visitor<sfileinst> *v,
2907  const language (&langs)[N])
2908  {
2909  visitor_adder<visitor<sfileinst>, csonar_add_sfi_visitor>
2910  ::add(langs, v);
2911  }
2912 
2980  static void add_sfileinst_visitor(
2981  visitor<sfileinst> *v,
2982  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
2983  {
2984  visitor_adder<visitor<sfileinst>, csonar_add_sfi_visitor>
2985  ::add(langs, v);
2986  }
2987 
2988 
3010  template <size_t N>
3011  static void add_sfileinst_finish_visitor(
3012  visitor<sfileinst> *v,
3013  const language (&langs)[N])
3014  {
3015  visitor_adder<visitor<sfileinst>, csonar_add_sfi_finish_visitor>
3016  ::add(langs, v);
3017  }
3018 
3086  static void add_sfileinst_finish_visitor(
3087  visitor<sfileinst> *v,
3088  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
3089  {
3090  visitor_adder<visitor<sfileinst>, csonar_add_sfi_finish_visitor>
3091  ::add(langs, v);
3092  }
3093 
3094 
3110  template <size_t N>
3111  static void add_sfile_finish_visitor(
3112  visitor<sfileinst> *v,
3113  const language (&langs)[N])
3114  {
3115  visitor_adder<visitor<sfileinst>, csonar_add_sf_finish_visitor>
3116  ::add(langs, v);
3117  }
3118 
3192  static void add_sfile_finish_visitor(
3193  visitor<sfileinst> *v,
3194  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
3195  {
3196  visitor_adder<visitor<sfileinst>, csonar_add_sf_finish_visitor>
3197  ::add(langs, v);
3198  }
3199 
3200 
3217  template <size_t N>
3218  static void add_compunit_finish_visitor(
3219  visitor<compunit> *v,
3220  const language (&langs)[N])
3221  {
3222  visitor_adder<visitor<compunit>, csonar_add_uid_finish_visitor>
3223  ::add(langs, v);
3224  }
3225 
3271  static void add_compunit_finish_visitor(
3272  visitor<compunit> *v,
3273  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
3274  {
3275  visitor_adder<visitor<compunit>, csonar_add_uid_finish_visitor>
3276  ::add(langs, v);
3277  }
3278 
3279 
3293  template <size_t N>
3294  static void add_project_finish_visitor(
3295  visitor<project> *v,
3296  const language (&langs)[N])
3297  {
3298  thunk_visitor_adder<visitor<project>, csonar_add_program_finish_visitor>::add(langs, v);
3299  }
3300 
3301 
3336  static void add_project_finish_visitor(
3337  visitor<project> *v,
3338  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
3339  {
3340  thunk_visitor_adder<visitor<project>, csonar_add_program_finish_visitor>
3341  ::add(langs, v);
3342  }
3343 
3344 
3359  template <size_t N>
3360  static void add_project_parallel_visitor(
3362  const language (&langs)[N])
3363  {
3364  thunk_visitor_adder<visitor<project>, csonar_add_program_parallel_visitor>
3365  ::add(langs, v);
3366  }
3367 
3401  static void add_project_parallel_visitor(
3402  visitor<project> *v,
3403  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
3404  {
3405  thunk_visitor_adder<visitor<project>, csonar_add_program_parallel_visitor>
3406  ::add(langs, v);
3407  }
3408 
3409 
3424  template <size_t N>
3425  static void add_compunit_parallel_visitor(
3427  const language (&langs)[N])
3428  {
3429  visitor_adder<visitor<compunit>, csonar_add_uid_parallel_visitor>
3430  ::add(langs, v);
3431  }
3432 
3477  static void add_compunit_parallel_visitor(
3478  visitor<compunit> *v,
3479  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
3480  {
3481  visitor_adder<visitor<compunit>, csonar_add_uid_parallel_visitor>
3482  ::add(langs, v);
3483  }
3484 
3485 
3501  template <size_t N>
3502  static void add_procedure_parallel_visitor(
3503  visitor<procedure> *v,
3504  const language (&langs)[N])
3505  {
3506  visitor_adder<visitor<procedure>, csonar_add_pdg_parallel_visitor>
3507  ::add(langs, v);
3508  }
3509 
3562  static void add_procedure_parallel_visitor(
3563  visitor<procedure> *v,
3564  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
3565  {
3566  visitor_adder<visitor<procedure>, csonar_add_pdg_parallel_visitor>
3567  ::add(langs, v);
3568  }
3569 
3585  template <size_t N>
3586  static void add_symbol_parallel_visitor(
3588  const language (&langs)[N])
3589  {
3590  visitor_adder<visitor<symbol>, csonar_add_abs_loc_parallel_visitor>
3591  ::add(langs, v);
3592  }
3593 
3647  static void add_symbol_parallel_visitor(
3648  visitor<symbol> *v,
3649  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
3650  {
3651  visitor_adder<visitor<symbol>, csonar_add_abs_loc_parallel_visitor>
3652  ::add(langs, v);
3653  }
3654 
3655 
3671  template <size_t N>
3672  static void add_point_parallel_visitor(
3673  visitor<point> *v,
3674  const language (&langs)[N])
3675  {
3676  visitor_adder<visitor<point>, csonar_add_pdg_vertex_parallel_visitor>
3677  ::add(langs, v);
3678  }
3679 
3733  static void add_point_parallel_visitor(
3734  visitor<point> *v,
3735  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
3736  {
3737  visitor_adder<visitor<point>, csonar_add_pdg_vertex_parallel_visitor>
3738  ::add(langs, v);
3739  }
3740 
3741 
3757  template <size_t N>
3758  static void add_procedure_parallel_finish_visitor(
3759  visitor<procedure> *v,
3760  const language (&langs)[N])
3761  {
3762  visitor_adder<visitor<procedure>, csonar_add_pdg_parallel_finish_visitor>
3763  ::add(langs, v);
3764  }
3765 
3819  static void add_procedure_parallel_finish_visitor(
3820  visitor<procedure> *v,
3821  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
3822  {
3823  visitor_adder<visitor<procedure>, csonar_add_pdg_parallel_finish_visitor>
3824  ::add(langs, v);
3825  }
3826 
3827 
3843  template <size_t N>
3844  static void add_sfile_parallel_visitor(
3845  visitor<sfileinst> *v,
3846  const language (&langs)[N])
3847  {
3848  visitor_adder<visitor<sfileinst>, csonar_add_sf_parallel_visitor>
3849  ::add(langs, v);
3850  }
3851 
3927  static void add_sfile_parallel_visitor(
3928  visitor<sfileinst> *v,
3929  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
3930  {
3931  visitor_adder<visitor<sfileinst>, csonar_add_sf_parallel_visitor>
3932  ::add(langs, v);
3933  }
3934 
3935 
3951  template <size_t N>
3952  static void add_sfileinst_parallel_visitor(
3953  visitor<sfileinst> *v,
3954  const language (&langs)[N])
3955  {
3956  visitor_adder<visitor<sfileinst>, csonar_add_sfi_parallel_visitor>
3957  ::add(langs, v);
3958  }
3959 
4028  static void add_sfileinst_parallel_visitor(
4029  visitor<sfileinst> *v,
4030  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
4031  {
4032  visitor_adder<visitor<sfileinst>, csonar_add_sfi_parallel_visitor>
4033  ::add(langs, v);
4034  }
4035 
4036 
4052  template <size_t N>
4053  static void add_sfileinst_parallel_finish_visitor(
4054  visitor<sfileinst> *v,
4055  const language (&langs)[N])
4056  {
4057  visitor_adder<visitor<sfileinst>, csonar_add_sfi_parallel_finish_visitor>
4058  ::add(langs, v);
4059  }
4060 
4129  static void add_sfileinst_parallel_finish_visitor(
4130  visitor<sfileinst> *v,
4131  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
4132  {
4133  visitor_adder<visitor<sfileinst>, csonar_add_sfi_parallel_finish_visitor>
4134  ::add(langs, v);
4135  }
4136 
4137 
4153  template <size_t N>
4154  static void add_sfile_parallel_finish_visitor(
4155  visitor<sfileinst> *v,
4156  const language (&langs)[N])
4157  {
4158  visitor_adder<visitor<sfileinst>, csonar_add_sf_parallel_finish_visitor>
4159  ::add(langs, v);
4160  }
4161 
4236  static void add_sfile_parallel_finish_visitor(
4237  visitor<sfileinst> *v,
4238  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
4239  {
4240  visitor_adder<visitor<sfileinst>, csonar_add_sf_parallel_finish_visitor>
4241  ::add(langs, v);
4242  }
4243 
4244 
4261  template <size_t N>
4262  static void add_compunit_parallel_finish_visitor(
4263  visitor<compunit> *v,
4264  const language (&langs)[N])
4265  {
4266  visitor_adder<visitor<compunit>, csonar_add_uid_parallel_finish_visitor>
4267  ::add(langs, v);
4268  }
4269 
4315  static void add_compunit_parallel_finish_visitor(
4316  visitor<compunit> *v,
4317  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
4318  {
4319  visitor_adder<visitor<compunit>, csonar_add_uid_parallel_finish_visitor>
4320  ::add(langs, v);
4321  }
4322 
4323 
4337  template <size_t N>
4338  static void add_project_parallel_finish_visitor(
4339  visitor<project> *v,
4340  const language (&langs)[N])
4341  {
4342  thunk_visitor_adder<visitor<project>, csonar_add_program_parallel_finish_visitor>::add(langs, v);
4343  }
4344 
4345 
4382  static void add_project_parallel_finish_visitor(
4383  visitor<project> *v,
4384  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
4385  {
4386  thunk_visitor_adder<visitor<project>, csonar_add_program_parallel_finish_visitor>
4387  ::add(langs, v);
4388  }
4389 
4390 
4406  template <size_t N>
4407  static void add_project_bottom_up_visitor(
4408  visitor<project> *v,
4409  const language (&langs)[N])
4410  {
4411  thunk_visitor_adder<visitor<project>, csonar_add_program_bottom_up_visitor>
4412  ::add(langs, v);
4413  }
4414 
4448  static void add_project_bottom_up_visitor(
4449  visitor<project> *v,
4450  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
4451  {
4452  thunk_visitor_adder<visitor<project>, csonar_add_program_bottom_up_visitor>
4453  ::add(langs, v);
4454  }
4455 
4456 
4472  template <size_t N>
4473  static void add_procedure_bottom_up_visitor(
4474  visitor<procedure> *v,
4475  const language (&langs)[N])
4476  {
4477  visitor_adder<visitor<procedure>, csonar_add_pdg_bottom_up_visitor>
4478  ::add(langs, v);
4479  }
4480 
4533  static void add_procedure_bottom_up_visitor(
4534  visitor<procedure> *v,
4535  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
4536  {
4537  visitor_adder<visitor<procedure>, csonar_add_pdg_bottom_up_visitor>
4538  ::add(langs, v);
4539  }
4540 
4541 
4557  template <size_t N>
4558  static void add_point_bottom_up_visitor(
4559  visitor<point> *v,
4560  const language (&langs)[N])
4561  {
4562  visitor_adder<visitor<point>, csonar_add_pdg_vertex_bottom_up_visitor>
4563  ::add(langs, v);
4564  }
4565 
4616  static void add_point_bottom_up_visitor(
4617  visitor<point> *v,
4618  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
4619  {
4620  visitor_adder<visitor<point>, csonar_add_pdg_vertex_bottom_up_visitor>
4621  ::add(langs, v);
4622  }
4623 
4624 
4625  DISOWN_PARAMETER(step_state *v);
4641  template <size_t N>
4642  static void add_step_bottom_up_visitor(
4643  step_state *v,
4644  const language (&langs)[N])
4645  {
4646  cs_language *clangs = new cs_language[N+1];
4647  size_t i;
4648  for( i = 0; i < N; i++ )
4649  clangs[i] = cglue<language>::unwrap(langs[i]);
4650  clangs[i] = csl_null;
4651  check(csonar_add_step_bottom_up_visitor(
4652  clangs, step_state::get_delegate(),
4653  static_cast<void*>(v)));
4654  v->registered = true;
4655  delete[] clangs;
4656  }
4657 
4725  static void add_step_bottom_up_visitor(
4726  step_state *v,
4727  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
4728  {
4729  cs_language *clangs = new cs_language[langs.size()+1];
4730  size_t i;
4731  for( i = 0; i < langs.size(); i++ )
4732  clangs[i] = cglue<language>::unwrap(langs[i]);
4733  clangs[i] = csl_null;
4734  check(csonar_add_step_bottom_up_visitor(
4735  clangs, step_state::get_delegate(),
4736  static_cast<void*>(v)));
4737  v->registered = true;
4738  delete[] clangs;
4739  }
4740 
4741 
4757  template <size_t N>
4758  static void add_procedure_bottom_up_finish_visitor(
4759  visitor<procedure> *v,
4760  const language (&langs)[N])
4761  {
4762  visitor_adder<visitor<procedure>, csonar_add_pdg_bottom_up_finish_visitor>
4763  ::add(langs, v);
4764  }
4765 
4818  static void add_procedure_bottom_up_finish_visitor(
4819  visitor<procedure> *v,
4820  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
4821  {
4822  visitor_adder<visitor<procedure>, csonar_add_pdg_bottom_up_finish_visitor>
4823  ::add(langs, v);
4824  }
4825 
4826 
4840  template <size_t N>
4841  static void add_project_bottom_up_finish_visitor(
4842  visitor<project> *v,
4843  const language (&langs)[N])
4844  {
4845  thunk_visitor_adder<visitor<project>, csonar_add_program_bottom_up_finish_visitor>::add(langs, v);
4846  }
4847 
4848 
4883  static void add_project_bottom_up_finish_visitor(
4884  visitor<project> *v,
4885  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
4886  {
4887  thunk_visitor_adder<visitor<project>, csonar_add_program_bottom_up_finish_visitor>
4888  ::add(langs, v);
4889  }
4890 
4891 
4932  static void add_project_drop_visitor(
4933  visitor<project> *v)
4934  {
4935  check(csonar_add_program_drop_visitor(
4936  visitor<project>::cs_visitor_delegate,
4937  static_cast<void*>(v)));
4938  v->registered = true;
4939  }
4940 
4990  static void add_compunit_drop_visitor(
4991  visitor<compunit> *v)
4992  {
4993  check(csonar_add_uid_drop_visitor(
4994  visitor<compunit>::cs_visitor_delegate,
4995  static_cast<void*>(v)));
4996  v->registered = true;
4997  }
4998 
5047  static void add_procedure_drop_visitor(
5048  visitor<procedure> *v)
5049  {
5050  check(csonar_add_pdg_drop_visitor(
5051  visitor<procedure>::cs_visitor_delegate,
5052  static_cast<void*>(v)));
5053  v->registered = true;
5054  }
5055 
5096  static void add_global_symbol_drop_visitor(
5097  visitor<symbol> *v)
5098  {
5099  check(csonar_add_global_abs_loc_drop_visitor(
5100  visitor<symbol>::cs_visitor_delegate,
5101  static_cast<void*>(v)));
5102  v->registered = true;
5103  }
5104 
5105 
5145  static void add_project_drop_finish_visitor(
5146  visitor<project> *v)
5147  {
5148  check(csonar_add_program_drop_finish_visitor(
5149  visitor<project>::cs_visitor_delegate,
5150  static_cast<void*>(v)));
5151  v->registered = true;
5152  }
5153 
5154 
5168  static void add_cache_cleanup_visitor(
5169  visitor<project> *v)
5170  {
5171  check(csonar_add_cache_cleanup_visitor(
5173  static_cast<void*>(v)));
5174  v->registered = true;
5175  }
5176 
5177  DISOWN_PARAMETER(listing_transformer *v);
5178 
5179 
5199  template <size_t N>
5200  static void add_listing_transformer(
5201  listing_transformer *v,
5202  const language (&langs)[N])
5203  {
5204  add(langs, v);
5205  v->registered = true;
5206  }
5207 
5223  static void add_listing_transformer(
5224  listing_transformer *v,
5225  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
5226  {
5227  add(langs, v);
5228  v->registered = true;
5229  }
5233  DISOWN_PARAMETER(point_info_collector *v);
5234 
5235 
5256  template <size_t N>
5257  static void add_point_info_collector(
5258  point_info_collector *v,
5259  const language (&langs)[N])
5260  {
5261  add(langs, v);
5262  v->registered = true;
5263  }
5264 
5281  static void add_point_info_collector(
5282  point_info_collector *v,
5283  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
5284  {
5285  add(langs, v);
5286  v->registered = true;
5287  }
5291  DISOWN_PARAMETER(symbol_info_collector *v);
5292 
5311  template <size_t N>
5312  static void add_symbol_info_collector(
5313  symbol_info_collector *v,
5314  const language (&langs)[N])
5315  {
5316  add(langs, v);
5317  v->registered = true;
5318  }
5321  DISOWN_PARAMETER(rpc_handler *handler);
5322 
5337  static void add_hub_rpc_handler(std::string message_name, rpc_handler *handler)
5338  {
5339  check(csonar_register_rpc_handler(message_name.c_str(),
5340  rpc_handler::cs_rpc_handler_delegate,
5341  static_cast<void*>(handler)));
5342  handler->registered = true;
5343  }
5344 
5345 
5362  static void add_symbol_info_collector(
5363  symbol_info_collector *v,
5364  const std::vector<language> &langs = std::vector<language>(1, language::WILDCARD))
5365  {
5366  add(langs, v);
5367  v->registered = true;
5368  }
5372 #ifdef SWIG
5373  %clear visitor *v;
5374  %clear transformer *v;
5375  %clear collector *v;
5376 #endif
5377 
5394  static void increment_listing_marker_count( csuint32 amt )
5395  {
5396  check(csonar_increment_listing_marker_count( amt ));
5397  }
5407  static csuint32 get_listing_marker_count( void )
5408  {
5409  return csonar_get_listing_marker_count();
5410  }
5413  /* These warningclass creation/lookup functions are exposed
5414  * through analysis and not as constructors because the
5415  * destructor does not reverse what the constructor did.
5416  */
5465  static warningclass create_warningclass(
5466  const std::string &_name,
5467  const std::string &categories = "",
5468  double rank = 10.0,
5469  warningclass_flags flags = warningclass_flags::NONE,
5470  warning_significance significance = warning_significance::UNSPECIFIED)
5471  {
5472  return warningclass(_name, categories, rank, flags, significance);
5473  }
5474 
5488  static warningclass lookup_warningclass(
5489  const std::string &_name)
5490  {
5491  return warningclass(_name);
5492  }
5493 
5514  csuint32 id)
5515  {
5516  return warningclass(id);
5517  }
5518 
5539  static void point_info_register_point(
5540  sfileinst sfi, line_number ln, point pt )
5541  {
5542  check( csonar_vinfo_register_vertex(
5543  cglue<sfileinst>::unwrap(sfi),
5544  ln,
5545  cglue<point>::unwrap(pt) ) );
5546  }
5563  static std::string binary_backend_option(
5564  const std::string &key)
5565  {
5566  cs_const_string value;
5567  check(csonar_binary_backend_option(key.c_str(), &value));
5568  return std::string(value);
5569  }
5570  };
5571 
5572  /* Actually from the csurf API (sort of) */
5617  inline procedure point::adjusted_callee() const
5618  {
5619  cs_pdg rv;
5620  check(csonar_pdg_vertex_callee(
5621  inner, &rv));
5622  return procedure::;
5623  }
5624 
5661  inline procedure point::adjusted_callee_no_reroute() const
5662  {
5663  cs_pdg rv;
5664  check(csonar_pdg_vertex_callee_no_reroute(
5665  inner, &rv));
5666  return procedure::;
5667  }
5668 
5669 
5678  inline symbol_vector point::csonar_enum_used() const
5679  {
5680  typedef scratchpad<symbol> sp;
5681  sp::to_vector_functor1<point, csonar_pdg_vertex_enum_used>
5682  functor(inner);
5683  return sp::to_vector(functor);
5684  }
5685 
5695  {
5696  typedef scratchpad<symbol> sp;
5697  sp::to_vector_functor1<point, csonar_pdg_vertex_enum_killed>
5698  functor(inner);
5699  return sp::to_vector(functor);
5700  }
5701 
5711  {
5712  typedef scratchpad<symbol> sp;
5713  sp::to_vector_functor1<point, csonar_pdg_vertex_enum_referenced>
5714  functor(inner);
5715  return sp::to_vector(functor);
5716  }
5717 
5725  inline bool sfileinst::is_system_include() const
5726  {
5727  cs_boolean result;
5728  check(csonar_file_is_system_include(inner,&result));
5729  return !!result;
5730  }
5731 
5750  inline bool procedure::reachable() const
5751  {
5752  cs_boolean result;
5753  check(csonar_pdg_reachable(inner, &result));
5754  return !!result;
5755  }
5756 
5757  class procedure_adjusted_callers_iterator_policy{
5758  public:
5759  typedef csonar_pdg_callers_iter iterator_impl;
5760  typedef point key;
5761  typedef cs_pdg ctype;
5762 
5763  static cs_result iter_first(
5764  ctype container,
5765  cglue<key>::ctype *val,
5766  iterator_impl *it)
5767  { return csonar_pdg_callers_iter_first( container, val, it ); }
5768  static cs_result iter_next(
5769  ctype container,
5770  cglue<key>::ctype *val,
5771  iterator_impl *it)
5772  { return csonar_pdg_callers_iter_next( val, it ); }
5773  static cs_result iter_close(iterator_impl *it)
5774  { return csonar_pdg_callers_iter_close( it ); }
5775  static const char *name()
5776  { return "procedure_adjusted_callers_iterator"; }
5777  };
5778 
5779 
5780  class point_adjusted_callees_iterator_policy{
5781  public:
5782  typedef csonar_pdg_callees_iter iterator_impl;
5783  typedef procedure key;
5784  typedef cs_pdg_vertex ctype;
5785 
5786  static cs_result iter_first(
5787  ctype container,
5788  cglue<key>::ctype *val,
5789  iterator_impl *it)
5790  { return csonar_pdg_vertex_callees_iter_first( container, val, it ); }
5791  static cs_result iter_next(
5792  ctype container,
5793  cglue<key>::ctype *val,
5794  iterator_impl *it)
5795  { return csonar_pdg_vertex_callees_iter_next( val, it ); }
5796  static cs_result iter_close(iterator_impl *it)
5797  { return csonar_pdg_vertex_callees_iter_close( it ); }
5798  static const char *name()
5799  { return "point_adjusted_callees_iterator"; }
5800  };
5801 
5802 
5803  class point_adjusted_callees_no_reroute_iterator_policy{
5804  public:
5805  typedef csonar_pdg_callees_no_reroute_iter iterator_impl;
5806  typedef procedure key;
5807  typedef cs_pdg_vertex ctype;
5808 
5809  static cs_result iter_first(
5810  ctype container,
5811  cglue<key>::ctype *val,
5812  iterator_impl *it)
5813  { return csonar_pdg_vertex_callees_no_reroute_iter_first( container, val, it ); }
5814  static cs_result iter_next(
5815  ctype container,
5816  cglue<key>::ctype *val,
5817  iterator_impl *it)
5818  { return csonar_pdg_vertex_callees_no_reroute_iter_next( val, it ); }
5819  static cs_result iter_close(iterator_impl *it)
5820  { return csonar_pdg_vertex_callees_no_reroute_iter_close( it ); }
5821  static const char *name()
5822  { return "point_adjusted_callees_no_reroute_iterator"; }
5823  };
5824 
5825 #ifdef SWIG
5826 }
5827 
5828 #define CS_SWIG_ITER_TEMPLATES(elt) \
5829  %template(elt ## _iterator_mixin) cs::iterator_adapter_mixin<cs::elt ## _iterator_policy>; \
5830  %template(elt ## _iterator) cs::iterator_adapter<cs::elt ## _iterator_policy>
5831 
5832 CS_SWIG_ITER_TEMPLATES(procedure_adjusted_callers);
5833 CS_SWIG_ITER_TEMPLATES(point_adjusted_callees);
5834 CS_SWIG_ITER_TEMPLATES(point_adjusted_callees_no_reroute);
5835 
5836 #undef CS_SWIG_ITER_TEMPLATES
5837 
5838 namespace cs{
5839 #endif
5840 
5842  typedef iterator_adapter<procedure_adjusted_callers_iterator_policy>
5844 
5845  typedef iterator_adapter<point_adjusted_callees_iterator_policy>
5847 
5848  typedef iterator_adapter<point_adjusted_callees_no_reroute_iterator_policy>
5870  DOX_ITER_TYPEDEF(procedure_adjusted_callers_iterator)
5871 
5872 
5873 
5896  DOX_ITER_TYPEDEF(point_adjusted_callees_iterator)
5897 
5898 
5899 
5923 
5924 
5925 
5949  { return procedure_adjusted_callers_iterator(inner); }
5950 
5951 
5970  point::adjusted_callees() const
5971  { return point_adjusted_callees_iterator(inner); }
5972 
5973 
5993  inline point_adjusted_callees_no_reroute_iterator
5995  { return point_adjusted_callees_no_reroute_iterator(inner); }
5996 
5997 
6033  inline std::vector<procedure> sfile::procedures_on_line_fast(
6034  line_number ln,
6035  bool closest) const
6036  {
6037  typedef scratchpad<procedure> sp;
6038  sp::to_vector_functor4
6039  <sfile, cs_line, const cs_hash_t*, cs_boolean, csonar_sf_get_pdgs_for_procedure>
6040  functor(inner, ln, NULL, closest);
6041  return sp::to_vector(functor);
6042  }
6043 
6044 
6089  inline std::vector<procedure> sfile::procedures_on_line_fast(
6090  line_number ln,
6091 #ifdef SWIG
6092  csuint32
6093 #else
6094  cs_hash_t
6095 #endif
6096  friendly_name_hash,
6097  bool closest) const
6098  {
6099  typedef scratchpad<procedure> sp;
6100  cs_hash_t h = static_cast<cs_hash_t>(friendly_name_hash);
6101  sp::to_vector_functor4
6102  <sfile, cs_line, const cs_hash_t*, cs_boolean, csonar_sf_get_pdgs_for_procedure>
6103  functor(inner, ln, &h, closest);
6104  return sp::to_vector(functor);
6105  }
6106 }
6107 #undef DOX_ITER_TYPEDEF
6108 
6109 #endif /* CSONAR_VISITOR_H */
cs_line line_number
A line number in a source file (sfile) or source file instance (sfileinst).
Definition: cs_types.hpp:387
static access_path addr()
Get a new access path element corresponding to the address (&) operator.
Definition: csonar_visitor.hpp:1207
Handles remote procedure calls (RPCs).
Definition: csonar_visitor.hpp:430
A program state transform along a path in the CFG.
Definition: csonar_visitor.hpp:1664
Namespace for CodeSonar/CodeSurfer API.
Definition: cs_ast.hpp:33
iterator_adapter< point_adjusted_callees_no_reroute_iterator_policy > adjusted_callees_no_reroute() const
Get an iterator over the callee procedures (procedure) from a point, ignoring any translations incurr...
Definition: csonar_visitor.hpp:6088
bool is_system_include() const
Check: is a file instance (sfileinst) an instance of a system include file?
Definition: csonar_visitor.hpp:5750
Manages the warning classes (warningclass) and visitors (visitor) @PYSTART@ (see ...
Definition: csonar_visitor.hpp:2108
A function or variable.
Definition: cs_symbol_decl.hpp:243
std::string as_string() const
Get a simple string representation of a xform_expr object.
Definition: csonar_visitor.hpp:1648
An access path describes a memory location as a sequence of steps from some base symbol, with each step represented by a access_path object.
Definition: csonar_visitor.hpp:1184
virtual step_state * copy() const =0
Dynamically allocate and return a new copy of a step_state.
A single program point.
Definition: cs_point_decl.hpp:66
symbol_vector csonar_enum_killed() const
Get the list of killed symbols (symbol) for a point, computing the list on-demand.
Definition: csonar_visitor.hpp:5719
symbol_vector csonar_enum_referenced() const
Get the list of referenced symbols (symbol) for a point, computing the list on-demand.
Definition: csonar_visitor.hpp:5735
rpc_handler(const rpc_handler &)
Copy constructor.
Definition: csonar_visitor.hpp:477
A single procedure/function/method.
Definition: cs_procedure_decl.hpp:173
procedure adjusted_callee() const
Get the callee procedure of a call site point, taking into account any translations incurred by csona...
Definition: csonar_visitor.hpp:5642
static warningclass lookup_warningclass(const std::string &_name)
Get the warningclass with the specified name.
Definition: csonar_visitor.hpp:5513
An iterator over the direct and indirect call sites (point of kind point_kind::CALL_SITE or point_kin...
Definition: csonar_visitor.hpp:5918
Abstract base class for step visitors, as added with analysis::add_step_bottom_up_visitor(): subclass...
Definition: csonar_visitor.hpp:1900
static const warningclass_flags NONE
Empty set: contains no flags.
Definition: csonar_warningclass.hpp:274
rpc_handler()
Constructor.
Definition: csonar_visitor.hpp:474
virtual void operator()(T)=0
For each IR element of type T that is visited, CodeSonar will invoke this function on the element...
An iterator over the callee procedures (procedure) from a specific point, ignoring any translations i...
Definition: csonar_visitor.hpp:6016
static const language WILDCARD
Matches all languages.
Definition: cs_language.hpp:25
static const xform_expr_mode POST
The expression should be evaluated using values of variables at the end of the transformation.
Definition: csonar_visitor.hpp:35
procedure adjusted_callee_no_reroute() const
Get the callee procedure of a call site point, ignoring any translations incurred by csonar_replace_*...
Definition: csonar_visitor.hpp:5686
iterator_adapter< procedure_adjusted_callers_iterator_policy > adjusted_callers() const
Get an iterator over the call sites (point of kind point_kind::CALL_SITE or point_kind::INDIRECT_CALL...
Definition: csonar_visitor.hpp:6042
A source file.
Definition: cs_sfile_decl.hpp:98
visitor(const visitor &)
Copy constructor.
Definition: csonar_visitor.hpp:222
std::vector< symbol > symbol_vector
A std::vector of symbol .
Definition: cs_tplt_instantiations.hpp:246
The result of an API operation.
Definition: cs_result.hpp:50
Enumeration class: the evaluation mode for an xform_expr.
Definition: csonar_visitor.hpp:1123
Enumeration class: identifies the source language the compilation unit is in.
Definition: cs_language.hpp:15
Enumeration class: the possible outcomes of a transform query with step_xform::query().
Definition: csonar_visitor.hpp:1044
static const warning_significance UNSPECIFIED
No significance value was specified.
Definition: csonar_warningclass.hpp:22
A source file instance.
Definition: cs_sfileinst_decl.hpp:302
cs::iterator_adapter< procedure_adjusted_callers_iterator_policy >
iterator_adapter< point_adjusted_callees_iterator_policy > adjusted_callees() const
Get an iterator over the callee procedures (procedure) from a point, taking into account any translat...
Definition: csonar_visitor.hpp:6064
cs::procedure_adjusted_callers_iterator_policy
Definition: csonar_visitor.hpp:5782
Abstract base class for visitors: functors that carry out actions on elements of the internal represe...
Definition: cs_types.hpp:372
The return type of step_xform::query_bounds()
Definition: csonar_visitor.hpp:1298
static project current()
Get the currently-loaded project.
Definition: cs_project.hpp:447
static const xform_expr_mode PRE
The expression should be evaluated using values of variables at the beginning of the transformation...
Definition: cs_xform_expr_mode_decls.hpp:27
static access_path offset_in_bits(size_t off)
Get a new access path element corresponding to the offset ([]) operator, with offset as specified...
Definition: csonar_visitor.hpp:1226
static access_path star()
Get a new access path element corresponding to the star (*) operator.
Definition: csonar_visitor.hpp:1215
Enumeration class: an operator that can be used in a transform query with step_xform::query().
Definition: csonar_visitor.hpp:1068
bool reachable() const
Check: is a procedure reachable from the reachability roots specified with configuration file paramet...
Definition: csonar_visitor.hpp:5775
An iterator over the callee procedures (procedure) from a specific point, taking into account any tra...
Definition: csonar_visitor.hpp:5967
std::vector< procedure > procedures_on_line_fast(line_number ln, bool closest) const
Get all procedures defined on the specified line of a source file.
Definition: csonar_visitor.hpp:6127
T visitee
The type of IR element to which the visitor is applied.
Definition: csonar_visitor.hpp:199
symbol_vector csonar_enum_used() const
Get the list of used symbols (symbol) for a point, computing the list on-demand.
Definition: csonar_visitor.hpp:5703
Specifies parts of a query expression for step_xform::query() or step_xform::query_bounds().
Definition: csonar_visitor.hpp:1476
A warning class.
Definition: csonar_warningclass.hpp:1353
visitor()
Constructor.
Definition: csonar_visitor.hpp:219