CodeSonar C++ API
[For improved navigation, enable JavaScript.]
cs_compunit.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_COMPUNIT_HPP
17 #define CS_COMPUNIT_HPP
18 
19 #include "cs_compunit_decl.hpp"
20 #include "cs_sfileinst_decl.hpp"
21 #include "cs_sfile_decl.hpp"
22 #include "cs_procedure_decl.hpp"
23 #include "cs_symbol_decl.hpp"
24 
27 namespace cs{
28  class compunit_procedure_iterator_policy{
29  public:
30  typedef cs_uid_pdgs_iter iterator_impl;
31  typedef procedure key;
32  typedef cs_uid ctype;
33 
34  static cs_result iter_first(
35  ctype container,
36  cglue<key>::ctype *val,
37  iterator_impl *it)
38  { return cs_uid_pdgs_iter_first( container, val, it ); }
39  static cs_result iter_next(
40  ctype container,
41  cglue<key>::ctype *val,
42  iterator_impl *it)
43  { return cs_uid_pdgs_iter_next( val, it ); }
44  static cs_result iter_close(iterator_impl *it)
45  { return cs_uid_pdgs_iter_close( it ); }
46  static const char *name()
47  { return "compunit_iterator"; }
48  };
49 
50  class compunit_global_iterator_policy{
51  public:
52  typedef cs_uid_nonlocals_iter iterator_impl;
53  typedef symbol key;
54  typedef cs_uid ctype;
55 
56  static cs_result iter_first(
57  ctype container,
58  cglue<key>::ctype *val,
59  iterator_impl *it)
60  { return cs_uid_nonlocals_iter_first( container, val, it ); }
61  static cs_result iter_next(
62  ctype container,
63  cglue<key>::ctype *val,
64  iterator_impl *it)
65  { return cs_uid_nonlocals_iter_next( val, it ); }
66  static cs_result iter_close(iterator_impl *it)
67  { return cs_uid_nonlocals_iter_close( it ); }
68  static const char *name()
69  { return "compunit_global_iterator"; }
70  };
71 
73  {
74  cs_sfid rv;
75  check(cs_file_uid_get_sfid(inner, &rv));
76  return sfileinst::;
77  }
78 
80  { return compunit_procedure_iterator(inner); }
81 
83  { return compunit_global_iterator(inner); }
84 
85  inline symbol compunit::lookup_symbol( const std::string &_name ) const
86  {
87  cs_abs_loc rv;
88  check(cs_abs_loc_lookup_in_uid(_name.c_str(), inner, &rv));
89  return symbol::;
90  }
91 
92 }
93 
94 #endif /* CS_COMPUNIT_HPP */
sfileinst get_sfileinst() const
Get the root source file instance of a compilation unit.
Definition: cs_compunit.hpp:72
Namespace for CodeSonar/CodeSurfer API.
Definition: cs_ast.hpp:33
cs::compunit_global_iterator_policy
Definition: cs_compunit.hpp:50
A function or variable.
Definition: cs_symbol_decl.hpp:243
Iterator over the procedures (procedure) in a compilation unit (compunit).
Definition: cs_tplt_instantiations.hpp:653
A single procedure/function/method.
Definition: cs_procedure_decl.hpp:173
compunit_procedure_iterator procedures() const
Get an iterator over the procedures (procedure) in a compilation unit.
Definition: cs_compunit.hpp:79
compunit_global_iterator global_symbols() const
Get an iterator over the global symbols (symbol) in a compilation unit.
Definition: cs_compunit.hpp:82
symbol lookup_symbol(const std::string &name) const
Get a symbol from the compilation unit by name.
Definition: cs_compunit.hpp:85
A source file instance.
Definition: cs_sfileinst_decl.hpp:302
Iterator over the global symbols (symbol) in a compilation unit (compunit).
Definition: cs_tplt_instantiations.hpp:619
cs::compunit_procedure_iterator_policy
Definition: cs_compunit.hpp:28