Support Bitwise OR for qualified_type_def::CV better

* src/abg-ir.h (qualified_type_def::CV_RESTRICT): New enumerator
	for the qualified_type_def::CV enum.
	(operator|(qualified_type_def::CV, qualified_type_def::CV)): New
	declaration.
	* src/abg-ir.cc (operator|(qualified_type_def::CV,
	qualified_type_def::CV)): New definition.
	* src/abg-reader.cc (build_qualified_type_decl): No need for
	casting the result of bitwise or between instances of
	qualified_type_def::CV.
This commit is contained in:
Dodji Seketeli 2013-06-21 09:39:13 +02:00 committed by Dodji Seketeli
parent c243aac0a4
commit 157529b027
3 changed files with 17 additions and 5 deletions

View File

@ -785,6 +785,16 @@ qualified_type_def::get_underlying_type() const
return m_underlying_type;
}
/// Overloaded bitwise OR operator for cv qualifiers.
qualified_type_def::CV
operator| (qualified_type_def::CV lhs,
qualified_type_def::CV rhs)
{
return static_cast<qualified_type_def::CV>
(static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs));
}
/// Hash function for instances of qualified_type_def.
size_t
qualified_type_def_hash::operator()(const qualified_type_def& t) const
{

View File

@ -525,7 +525,8 @@ public:
{
CV_NONE = 0,
CV_CONST = 1,
CV_VOLATILE = 1 << 1
CV_VOLATILE = 1 << 1,
CV_RESTRICT = 1 << 2
};
qualified_type_def(shared_ptr<type_base> underlying_type,
@ -551,6 +552,9 @@ private:
shared_ptr<type_base> m_underlying_type;
};//end class qualified_type_def
qualified_type_def::CV operator| (qualified_type_def::CV,
qualified_type_def::CV);
/// A Hasher for instances of qualified_type_def
struct qualified_type_def_hash
{

View File

@ -1299,11 +1299,9 @@ build_qualified_type_decl(read_context& ctxt,
qualified_type_def::CV cv = qualified_type_def::CV_NONE;
if (const_cv)
cv =
static_cast<qualified_type_def::CV>(cv | qualified_type_def::CV_CONST);
cv = cv | qualified_type_def::CV_CONST;
if (volatile_cv)
cv =
static_cast<qualified_type_def::CV>(cv | qualified_type_def::CV_VOLATILE);
cv = cv | qualified_type_def::CV_VOLATILE;
location loc;
read_location(ctxt, node, loc);