cprover
ansi_c_typecheck.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: ANSI-C Language Type Checking
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #include "ansi_c_typecheck.h"
13 
14 #include "ansi_c_parse_tree.h"
15 
17 {
19 
20  for(auto &item : parse_tree.items)
22 }
23 
25  ansi_c_parse_treet &ansi_c_parse_tree,
26  symbol_tablet &symbol_table,
27  const std::string &module,
28  message_handlert &message_handler)
29 {
31  ansi_c_parse_tree, symbol_table, module, message_handler);
32  return ansi_c_typecheck.typecheck_main();
33 }
34 
36  exprt &expr,
37  message_handlert &message_handler,
38  const namespacet &ns)
39 {
40  const unsigned errors_before=
41  message_handler.get_message_count(messaget::M_ERROR);
42 
43  symbol_tablet symbol_table;
44  ansi_c_parse_treet ansi_c_parse_tree;
45 
47  ansi_c_parse_tree, symbol_table,
48  ns.get_symbol_table(), "", message_handler);
49 
50  try
51  {
52  ansi_c_typecheck.typecheck_expr(expr);
53  }
54 
55  catch(int)
56  {
57  ansi_c_typecheck.error();
58  }
59 
60  catch(const char *e)
61  {
62  ansi_c_typecheck.error() << e << messaget::eom;
63  }
64 
65  catch(const std::string &e)
66  {
67  ansi_c_typecheck.error() << e << messaget::eom;
68  }
69 
70  return message_handler.get_message_count(messaget::M_ERROR)!=errors_before;
71 }
bool ansi_c_typecheck(ansi_c_parse_treet &ansi_c_parse_tree, symbol_tablet &symbol_table, const std::string &module, message_handlert &message_handler)
ANSI-C Language Type Checking.
ansi_c_parse_treet & parse_tree
virtual void typecheck()
void typecheck_declaration(ansi_c_declarationt &)
virtual void start_typecheck_code()
Base class for all expressions.
Definition: expr.h:54
std::size_t get_message_count(unsigned level) const
Definition: message.h:56
@ M_ERROR
Definition: message.h:170
static eomt eom
Definition: message.h:297
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:91
const symbol_table_baset & get_symbol_table() const
Return first symbol table registered with the namespace.
Definition: namespace.h:123
The symbol table.
Definition: symbol_table.h:14