From 2b8ef3ca77383775f17234240d97622eb466ddee Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Sun, 31 Mar 2019 13:14:20 +0000 Subject: [PATCH] Handle ID_cpp_name in expr2cppt While typechecking is still in progress, tags may still be cpp names. For debugging purposes it's useful to print their underlying names. --- src/cpp/expr2cpp.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/cpp/expr2cpp.cpp b/src/cpp/expr2cpp.cpp index 89ca1ae0590..1fc04960bd6 100644 --- a/src/cpp/expr2cpp.cpp +++ b/src/cpp/expr2cpp.cpp @@ -21,6 +21,8 @@ Author: Daniel Kroening, kroening@cs.cmu.edu #include #include +#include "cpp_name.h" + class expr2cppt:public expr2ct { public: @@ -169,6 +171,51 @@ std::string expr2cppt::convert_rec( return dest; } + else if(src.id() == ID_struct_tag) + { + const struct_typet &struct_type = ns.follow_tag(to_struct_tag_type(src)); + + std::string dest = q; + + if(src.get_bool(ID_C_class)) + dest += "class"; + else if(src.get_bool(ID_C_interface)) + dest += "__interface"; // MS-specific + else + dest += "struct"; + + const irept &tag = struct_type.find(ID_tag); + if(!tag.id().empty()) + { + if(tag.id() == ID_cpp_name) + dest += " " + to_cpp_name(tag).to_string(); + else + dest += id2string(tag.id()); + } + + dest += d; + + return dest; + } + else if(src.id() == ID_union_tag) + { + const union_typet &union_type = ns.follow_tag(to_union_tag_type(src)); + + std::string dest = q + "union"; + + const irept &tag = union_type.find(ID_tag); + if(!tag.id().empty()) + { + if(tag.id() == ID_cpp_name) + dest += " " + to_cpp_name(tag).to_string(); + else + dest += id2string(tag.id()); + } + + dest += d; + + return dest; + } else if(src.id()==ID_constructor) { return "constructor ";