本文整理汇总了C++中typet::location方法的典型用法代码示例。如果您正苦于以下问题:C++ typet::location方法的具体用法?C++ typet::location怎么用?C++ typet::location使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typet
的用法示例。
在下文中一共展示了typet::location方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read
void ansi_c_convert_typet::read(const typet &type)
{
clear();
location = type.location();
read_rec(type);
}
示例2: typecheck_enum_type
void cpp_typecheckt::typecheck_enum_type(typet &type)
{
// first save qualifiers
c_qualifierst qualifiers;
qualifiers.read(type);
// these behave like special struct types
// replace by type symbol
cpp_enum_typet &enum_type=to_cpp_enum_type(type);
bool anonymous=!enum_type.has_tag();
irep_idt base_name;
if(anonymous)
{
// we fabricate a tag based on the enum constants contained
base_name=enum_type.generate_anon_tag();
}
else
{
const cpp_namet &tag=enum_type.tag();
if(tag.is_simple_name())
base_name=tag.get_base_name();
else
{
err_location(type);
throw "enum tag is expected to be a simple name";
}
}
bool has_body=enum_type.has_body();
bool tag_only_declaration=enum_type.get_tag_only_declaration();
cpp_scopet &dest_scope=
tag_scope(base_name, has_body, tag_only_declaration);
const irep_idt symbol_name=
dest_scope.prefix+"tag."+id2string(base_name);
// check if we have it
symbol_tablet::symbolst::iterator previous_symbol=
symbol_table.symbols.find(symbol_name);
if(previous_symbol!=symbol_table.symbols.end())
{
// we do!
symbolt &symbol=previous_symbol->second;
if(has_body)
{
err_location(type);
str << "error: enum symbol `" << base_name
<< "' declared previously" << std::endl;
str << "location of previous definition: "
<< symbol.location << std::endl;
throw 0;
}
}
else if(has_body)
{
std::string pretty_name=
cpp_scopes.current_scope().prefix+id2string(base_name);
symbolt symbol;
symbol.name=symbol_name;
symbol.base_name=base_name;
symbol.value.make_nil();
symbol.location=type.location();
symbol.mode=ID_cpp;
symbol.module=module;
symbol.type.swap(type);
symbol.is_type=true;
symbol.is_macro=false;
symbol.pretty_name=pretty_name;
// move early, must be visible before doing body
symbolt *new_symbol;
if(symbol_table.move(symbol, new_symbol))
throw "cpp_typecheckt::typecheck_enum_type: symbol_table.move() failed";
// put into scope
cpp_idt &scope_identifier=
cpp_scopes.put_into_scope(*new_symbol, dest_scope);
scope_identifier.id_class=cpp_idt::CLASS;
typecheck_enum_body(*new_symbol);
}
else
{
err_location(type);
str << "use of enum `" << base_name
<< "' without previous declaration";
throw 0;
}
//.........这里部分代码省略.........