本文整理汇总了C++中typet::is_not_nil方法的典型用法代码示例。如果您正苦于以下问题:C++ typet::is_not_nil方法的具体用法?C++ typet::is_not_nil怎么用?C++ typet::is_not_nil使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typet
的用法示例。
在下文中一共展示了typet::is_not_nil方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: typecheck_type
void cpp_typecheckt::typecheck_type(typet &type)
{
assert(!type.id().empty());
assert(type.is_not_nil());
try
{
cpp_convert_plain_type(type);
}
catch(const char *err)
{
error().source_location=type.source_location();
error() << err << eom;
throw 0;
}
catch(const std::string &err)
{
error().source_location=type.source_location();
error() << err << eom;
throw 0;
}
if(type.id()==ID_cpp_name)
{
c_qualifierst qualifiers(type);
cpp_namet cpp_name;
cpp_name.swap(type);
exprt symbol_expr=resolve(
cpp_name,
cpp_typecheck_resolvet::wantt::TYPE,
cpp_typecheck_fargst());
if(symbol_expr.id()!=ID_type)
{
error().source_location=type.source_location();
error() << "error: expected type" << eom;
throw 0;
}
type=symbol_expr.type();
assert(type.is_not_nil());
if(type.get_bool(ID_C_constant))
qualifiers.is_constant = true;
qualifiers.write(type);
}
else if(type.id()==ID_struct ||
type.id()==ID_union)
{
typecheck_compound_type(to_struct_union_type(type));
}
else if(type.id()==ID_pointer)
{
// the pointer might have a qualifier, but do subtype first
typecheck_type(type.subtype());
// Check if it is a pointer-to-member
if(type.find("to-member").is_not_nil())
{
// these can point either to data members or member functions
// of a class
typet &class_object=static_cast<typet &>(type.add("to-member"));
if(class_object.id()==ID_cpp_name)
{
assert(class_object.get_sub().back().id()=="::");
class_object.get_sub().pop_back();
}
typecheck_type(class_object);
// there may be parameters if this is a pointer to member function
if(type.subtype().id()==ID_code)
{
irept::subt ¶meters=type.subtype().add(ID_parameters).get_sub();
if(parameters.empty() ||
parameters.front().get(ID_C_base_name)!=ID_this)
{
// Add 'this' to the parameters
exprt a0(ID_parameter);
a0.set(ID_C_base_name, ID_this);
a0.type().id(ID_pointer);
a0.type().subtype() = class_object;
parameters.insert(parameters.begin(), a0);
}
}
}
}
else if(type.id()==ID_array)
{
exprt &size_expr=to_array_type(type).size();
if(size_expr.is_not_nil())
//.........这里部分代码省略.........
示例2: typecheck_type
void cpp_typecheckt::typecheck_type(typet &type)
{
assert(type.id() != "");
assert(type.is_not_nil());
try
{
cpp_convert_plain_type(type);
}
catch(const char *error)
{
err_location(type);
str << error;
throw 0;
}
catch(const std::string &error)
{
err_location(type);
str << error;
throw 0;
}
if(type.id() == "cpp-name")
{
c_qualifierst qualifiers(type);
cpp_namet cpp_name;
cpp_name.swap(type);
exprt symbol_expr =
resolve(cpp_name, cpp_typecheck_resolvet::TYPE, cpp_typecheck_fargst());
if(symbol_expr.id() != "type")
{
err_location(type);
str << "error: expected type";
throw 0;
}
type = symbol_expr.type();
assert(type.is_not_nil());
if(type.cmt_constant())
qualifiers.is_constant = true;
qualifiers.write(type);
}
else if(type.id() == "struct" || type.id() == "union")
{
typecheck_compound_type(type);
}
else if(type.id() == "pointer")
{
// the pointer might have a qualifier, but do subtype first
typecheck_type(type.subtype());
// Check if it is a pointer-to-member
if(type.find("to-member").is_not_nil())
{
// these can point either to data members or member functions
// of a class
typet &class_object = static_cast<typet &>(type.add("to-member"));
if(class_object.id() == "cpp-name")
{
assert(class_object.get_sub().back().id() == "::");
class_object.get_sub().pop_back();
}
typecheck_type(class_object);
// there may be arguments if this is a pointer to member function
if(type.subtype().id() == "code")
{
irept::subt &args = type.subtype().add("arguments").get_sub();
if(args.empty() || args.front().cmt_base_name() != "this")
{
// Add 'this' to the arguments
exprt a0("argument");
a0.cmt_base_name("this");
a0.type().id("pointer");
a0.type().subtype() = class_object;
args.insert(args.begin(), a0);
}
}
}
// now do qualifier
if(type.find("#qualifier").is_not_nil())
{
typet &t = static_cast<typet &>(type.add("#qualifier"));
cpp_convert_plain_type(t);
c_qualifierst q(t);
q.write(type);
}
//.........这里部分代码省略.........