/// top cv-qualifiers change.
FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY = 1 << 13,
- /// A diff node in this category is a function parameter type which
+ /// A diff node in this category has a function parameter type with a
/// cv-qualifiers change.
FN_PARM_TYPE_CV_CHANGE_CATEGORY = 1 << 14,
+ /// A diff node in this category is a function return type with a
+ /// cv-qualifier change.
+ FN_RETURN_TYPE_CV_CHANGE_CATEGORY = 1 << 15,
+
/// A special enumerator that is the logical 'or' all the
/// enumerators above.
///
| CLASS_DECL_ONLY_DEF_CHANGE_CATEGORY
| FN_PARM_TYPE_TOP_CV_CHANGE_CATEGORY
| FN_PARM_TYPE_CV_CHANGE_CATEGORY
+ | FN_RETURN_TYPE_CV_CHANGE_CATEGORY
}; // enum diff_category
diff_category
return false;
}
-/// Test if an @ref fn_parm_diff node has a cv qualifier change on the
-/// type of the function parameter. That is, we are looking for
-/// changes like 'const char*' to 'char*'.
+/// Test if a type diff only carries a CV qualifier-only change.
///
-/// @param diff the diff node to consider. It should be a @ref
-/// fn_parm_diff, otherwise the function returns 'false' directly.
+/// @param type_dif the type dif to consider.
///
-/// @return true iff @p diff is a @ref fn_parm_diff node that has a
-/// cv qualifier change on the type of the function parameter.
+/// @return true iff the type_diff carries a CV qualifier only change.
static bool
-has_fn_parm_type_cv_qual_change(const diff* dif)
+type_diff_has_cv_qual_change_only(const diff *type_dif)
{
- // is diff a "function parameter diff node?
- const fn_parm_diff* parm_diff = is_fn_parm_diff(dif);
-
- if (!parm_diff || !parm_diff->has_changes())
- // diff either carries no change or is not a function parameter
- // diff node. So bail out.
+ if (!is_type_diff(type_dif))
return false;
- const diff *type_dif = parm_diff->type_diff().get();
if (is_pointer_diff(type_dif))
type_dif = peel_pointer_diff(type_dif);
else if (is_reference_diff(type_dif))
const type_base *s = 0;
if (const distinct_diff *d = is_distinct_diff(type_dif))
{
- if (is_qualified_type(d->first()) != is_qualified_type(d->second()))
+ if (is_qualified_type(d->first()) == is_qualified_type(d->second()))
+ return false;
+ else
{
f = is_type(d->first()).get();
s = is_type(d->second()).get();
}
- else
- return false;
}
else if (const qualified_type_diff *d = is_qualified_type_diff(type_dif))
{
return *f == *s;
}
+/// Test if an @ref fn_parm_diff node has a cv qualifier change on the
+/// type of the function parameter. That is, we are looking for
+/// changes like 'const char*' to 'char*'.
+///
+/// @param diff the diff node to consider. It should be a @ref
+/// fn_parm_diff, otherwise the function returns 'false' directly.
+///
+/// @return true iff @p diff is a @ref fn_parm_diff node that has a
+/// cv qualifier change on the type of the function parameter.
+static bool
+has_fn_parm_type_cv_qual_change(const diff* dif)
+{
+ // is diff a "function parameter diff node?
+ const fn_parm_diff* parm_diff = is_fn_parm_diff(dif);
+
+ if (!parm_diff || !parm_diff->has_changes())
+ // diff either carries no change or is not a function parameter
+ // diff node. So bail out.
+ return false;
+
+ const diff *type_dif = parm_diff->type_diff().get();
+ return type_diff_has_cv_qual_change_only(type_dif);
+}
+
+/// Test if a function type or decl diff node carries a CV
+/// qualifier-only change on its return type.
+///
+/// @param the dif to consider. Note that if this is neither a
+/// function type nor decl diff node, the function returns false.
+///
+/// @return true iff @p dif is a function decl or type diff node which
+/// carries a CV qualifier-only change on its return type.
+static bool
+has_fn_return_type_cv_qual_change(const diff* dif)
+{
+ const function_type_diff* fn_type_diff = is_function_type_diff(dif);
+ if (!fn_type_diff)
+ if (const function_decl_diff* fn_decl_diff = is_function_decl_diff(dif))
+ fn_type_diff = fn_decl_diff->type_diff().get();
+
+ if (!fn_type_diff)
+ return false;
+
+ const diff* return_type_diff = fn_type_diff->return_type_diff().get();
+ return type_diff_has_cv_qual_change_only(return_type_diff);
+}
+
/// Detect if the changes carried by a given diff node are deemed
/// harmless and do categorize the diff node accordingly.
///
if (has_fn_parm_type_cv_qual_change(d))
category |= FN_PARM_TYPE_CV_CHANGE_CATEGORY;
+ if (has_fn_return_type_cv_qual_change(d))
+ category |= FN_RETURN_TYPE_CV_CHANGE_CATEGORY;
+
if (category)
{
d->add_to_local_and_inherited_categories(category);