Skip to content

C++ front-end: Enable compilation with DEBUG defined [blocks: #1260] #4475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/cpp/cpp_declaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ Author: Daniel Kroening, [email protected]

void cpp_declarationt::output(std::ostream &out) const
{
out << "is_template: " << is_template() << "\n";
out << "storage: " << storage_spec().pretty() << "\n";
out << "template_type: " << template_type().pretty() << "\n";
out << "type: " << type().pretty() << "\n";
out << "is_template: " << is_template() << '\n';
out << "storage: " << storage_spec().pretty() << '\n';
out << "template_type: " << template_type().pretty() << '\n';
out << "type: " << type().pretty() << '\n';

out << "Declarators:" << "\n";
out << "Declarators:" << '\n';

for(const auto &it : declarators())
{
it.output(out);
out << "\n";
out << '\n';
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/cpp/cpp_declarator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ Author: Daniel Kroening, [email protected]

void cpp_declaratort::output(std::ostream &out) const
{
out << " name: " << name().pretty() << "\n";
out << " type: " << type().pretty() << "\n";
out << " value: " << value().pretty() << "\n";
out << " init_args: " << init_args().pretty() << "\n";
out << " method_qualifier: " << method_qualifier().pretty() << "\n";
out << " name: " << name().pretty() << '\n';
out << " type: " << type().pretty() << '\n';
out << " value: " << value().pretty() << '\n';
out << " init_args: " << init_args().pretty() << '\n';
out << " method_qualifier: " << method_qualifier().pretty() << '\n';
}

typet cpp_declaratort::merge_type(const typet &declaration_type) const
Expand Down
18 changes: 11 additions & 7 deletions src/cpp/cpp_declarator_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,20 +344,24 @@ void cpp_declarator_convertert::handle_initializer(
}
else
{
#if 0
cpp_typecheck.error().source_location=declarator.name());
#if 0
cpp_typecheck.error().source_location=source_location;

if(is_code)
cpp_typecheck.str << "body of function `"
{
cpp_typecheck.error() << "body of function `"
<< symbol.display_name()
<< "' has already been defined";
<< "' has already been defined" << messaget::eom;
}
else
cpp_typecheck.str << "symbol `"
{
cpp_typecheck.error() << "symbol `"
<< symbol.display_name()
<< "' already has an initializer";
<< "' already has an initializer" << messaget::eom;
}

throw 0;
#endif
#endif
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_namespace_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ Author: Daniel Kroening, [email protected]

void cpp_namespace_spect::output(std::ostream &out) const
{
out << " namespace: " << get_namespace() << "\n";
out << " namespace: " << get_namespace() << '\n';
}
2 changes: 1 addition & 1 deletion src/cpp/cpp_scopes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void cpp_scopest::print_current(std::ostream &out) const
do
{
scope->print_fields(out);
out << "\n";
out << '\n';
scope=&scope->get_parent();
}
while(!scope->is_root_scope());
Expand Down
7 changes: 5 additions & 2 deletions src/cpp/cpp_typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,11 @@ bool cpp_typecheckt::contains_cpp_name(const exprt &expr)
{
if(expr.id() == ID_cpp_name || expr.id() == ID_cpp_declaration)
return true;
forall_operands(it, expr)
if(contains_cpp_name(*it))

for(const exprt &op : expr.operands())
{
if(contains_cpp_name(op))
return true;
}
return false;
}
9 changes: 3 additions & 6 deletions src/cpp/cpp_typecheck_compound_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1325,12 +1325,9 @@ void cpp_typecheckt::typecheck_member_function(
if(symbol_table.move(symbol, new_symbol))
{
error().source_location=symbol.location;
error() << "failed to insert new method symbol: "
<< symbol.name << "\n"
<< "name of previous symbol: "
<< new_symbol->name << "\n"
<< "location of previous symbol: "
<< new_symbol->location << eom;
error() << "failed to insert new method symbol: " << symbol.name << '\n'
<< "name of previous symbol: " << new_symbol->name << '\n'
<< "location of previous symbol: " << new_symbol->location << eom;

throw 0;
}
Expand Down
1 change: 0 additions & 1 deletion src/cpp/cpp_typecheck_declaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Author: Daniel Kroening, [email protected]

\********************************************************************/


/// \file
/// C++ Language Type Checking

Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,7 @@ void cpp_typecheckt::typecheck_method_application(
static_cast<const cpp_template_args_tct &>(template_args));
add_method_body(&method_symbol);
#ifdef DEBUG
std::cout << "MAP for " << symbol << ":" << std::endl;
std::cout << "MAP for " << symbol << ":\n";
template_map.print(std::cout);
#endif
}
Expand Down
30 changes: 13 additions & 17 deletions src/cpp/cpp_typecheck_method_bodies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ void cpp_typecheckt::typecheck_method_bodies()
continue;

#ifdef DEBUG
std::cout << "convert_method_body: " << method_symbol.name << std::endl;
std::cout << " is_not_nil: " << body.is_not_nil() << std::endl;
std::cout << " !is_zero: " << (!body.is_zero()) << std::endl;
std::cout << "convert_method_body: " << method_symbol.name << '\n';
std::cout << " is_not_nil: " << body.is_not_nil() << '\n';
std::cout << " !is_zero: " << (!body.is_zero()) << '\n';
#endif
if(body.is_not_nil() && !body.is_zero())
convert_function(method_symbol);
Expand All @@ -51,22 +51,18 @@ void cpp_typecheckt::typecheck_method_bodies()
void cpp_typecheckt::add_method_body(symbolt *_method_symbol)
{
#ifdef DEBUG
std::cout << "add_method_body: " << _method_symbol->name << std::endl;
std::cout << "add_method_body: " << _method_symbol->name << '\n';
#endif

// We have to prevent the same method to be added multiple times
// otherwise we get duplicated symbol prefixes
if(methods_seen.find(_method_symbol->name) != methods_seen.end())
// Converting a method body might add method bodies for methods that we have
// already analyzed. Adding the same method more than once causes duplicated
// symbol prefixes, therefore we have to keep track.
if(methods_seen.insert(_method_symbol->name).second)
{
method_bodies.push_back(
method_bodyt(_method_symbol, template_map, instantiation_stack));
}
#ifdef DEBUG
std::cout << " already exists" << std::endl;
else
std::cout << " already exists\n";
#endif
return;
}
method_bodies.push_back(
method_bodyt(_method_symbol, template_map, instantiation_stack));

// Converting a method body might add method bodies for methods
// that we have already analyzed. Hence, we have to keep track.
methods_seen.insert(_method_symbol->name);
}
80 changes: 40 additions & 40 deletions src/cpp/cpp_typecheck_resolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ exprt cpp_typecheck_resolvet::convert_template_parameter(
const cpp_idt &identifier)
{
#ifdef DEBUG
std::cout << "RESOLVE MAP:" << std::endl;
std::cout << "RESOLVE MAP:\n";
cpp_typecheck.template_map.print(std::cout);
#endif

Expand Down Expand Up @@ -1183,8 +1183,8 @@ struct_tag_typet cpp_typecheck_resolvet::disambiguate_template_classes(
if(instance.type.id()!=ID_struct)
{
cpp_typecheck.error().source_location=source_location;
cpp_typecheck.str << "template `"
<< base_name << "' is not a class";
cpp_typecheck.error() << "template `"
<< base_name << "' is not a class" << messaget::eom;
throw 0;
}

Expand Down Expand Up @@ -1360,11 +1360,11 @@ exprt cpp_typecheck_resolvet::resolve(
resolve_scope(cpp_name, base_name, template_args);

#ifdef DEBUG
std::cout << "base name: " << base_name << std::endl;
std::cout << "template args: " << template_args.pretty() << std::endl;
std::cout << "original-scope: " << original_scope->prefix << std::endl;
std::cout << "scope: "
<< cpp_typecheck.cpp_scopes.current_scope().prefix << std::endl;
std::cout << "base name: " << base_name << '\n';
std::cout << "template args: " << template_args.pretty() << '\n';
std::cout << "original-scope: " << original_scope->prefix << '\n';
std::cout << "scope: " << cpp_typecheck.cpp_scopes.current_scope().prefix
<< '\n';
#endif

bool qualified=cpp_name.is_qualified();
Expand Down Expand Up @@ -1517,11 +1517,11 @@ exprt cpp_typecheck_resolvet::resolve(

filter(identifiers, want);

#if 0
std::cout << "P0 " << base_name << " " << identifiers.size() << "\n";
#ifdef DEBUG
std::cout << "P0 " << base_name << " " << identifiers.size() << '\n';
show_identifiers(base_name, identifiers, std::cout);
std::cout << "\n";
#endif
std::cout << '\n';
#endif

exprt result;

Expand All @@ -1530,20 +1530,20 @@ exprt cpp_typecheck_resolvet::resolve(

remove_templates(new_identifiers);

#if 0
std::cout << "P1 " << base_name << " " << new_identifiers.size() << "\n";
#ifdef DEBUG
std::cout << "P1 " << base_name << " " << new_identifiers.size() << '\n';
show_identifiers(base_name, new_identifiers, std::cout);
std::cout << "\n";
#endif
std::cout << '\n';
#endif

// we only want _exact_ matches, without templates!
exact_match_functions(new_identifiers, fargs);

#if 0
std::cout << "P2 " << base_name << " " << new_identifiers.size() << "\n";
#ifdef DEBUG
std::cout << "P2 " << base_name << " " << new_identifiers.size() << '\n';
show_identifiers(base_name, new_identifiers, std::cout);
std::cout << "\n";
#endif
std::cout << '\n';
#endif

// no exact matches? Try again with function template guessing.
if(new_identifiers.empty())
Expand All @@ -1560,20 +1560,20 @@ exprt cpp_typecheck_resolvet::resolve(

disambiguate_functions(new_identifiers, fargs);

#if 0
std::cout << "P3 " << base_name << " " << new_identifiers.size() << "\n";
#ifdef DEBUG
std::cout << "P3 " << base_name << " " << new_identifiers.size() << '\n';
show_identifiers(base_name, new_identifiers, std::cout);
std::cout << "\n";
#endif
std::cout << '\n';
#endif
}

remove_duplicates(new_identifiers);

#if 0
std::cout << "P4 " << base_name << " " << new_identifiers.size() << "\n";
#ifdef DEBUG
std::cout << "P4 " << base_name << " " << new_identifiers.size() << '\n';
show_identifiers(base_name, new_identifiers, std::cout);
std::cout << "\n";
#endif
std::cout << '\n';
#endif

if(new_identifiers.size()==1)
{
Expand Down Expand Up @@ -1601,20 +1601,20 @@ exprt cpp_typecheck_resolvet::resolve(
<< "' does not uniquely resolve:\n";
show_identifiers(base_name, new_identifiers, cpp_typecheck.error());

#if 0
#ifdef DEBUG
exprt e1=*new_identifiers.begin();
exprt e2=*(++new_identifiers.begin());
cpp_typecheck.str << "e1==e2: " << (e1==e2) << '\n';
cpp_typecheck.str << "e1.type==e2.type: " << (e1.type()==e2.type())
<< '\n';
cpp_typecheck.str << "e1.id()==e2.id(): " << (e1.id()==e2.id())
<< '\n';
cpp_typecheck.str << "e1.iden==e2.iden: "
<< (e1.get(ID_identifier)==e2.get(ID_identifier))
<< '\n';
cpp_typecheck.str << "e1.iden:: " << e1.get(ID_identifier) << '\n';
cpp_typecheck.str << "e2.iden:: " << e2.get(ID_identifier) << '\n';
#endif
cpp_typecheck.error() << "e1==e2: " << (e1 == e2) << '\n';
cpp_typecheck.error()
<< "e1.type==e2.type: " << (e1.type() == e2.type()) << '\n';
cpp_typecheck.error()
<< "e1.id()==e2.id(): " << (e1.id() == e2.id()) << '\n';
cpp_typecheck.error()
<< "e1.iden==e2.iden: "
<< (e1.get(ID_identifier) == e2.get(ID_identifier)) << '\n';
cpp_typecheck.error() << "e1.iden:: " << e1.get(ID_identifier) << '\n';
cpp_typecheck.error() << "e2.iden:: " << e2.get(ID_identifier) << '\n';
#endif
}

if(fargs.in_use)
Expand Down
Loading