本文整理汇总了C++中Sema::CompareReferenceRelationship方法的典型用法代码示例。如果您正苦于以下问题:C++ Sema::CompareReferenceRelationship方法的具体用法?C++ Sema::CompareReferenceRelationship怎么用?C++ Sema::CompareReferenceRelationship使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sema
的用法示例。
在下文中一共展示了Sema::CompareReferenceRelationship方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/// Tests whether a conversion according to N2844 is valid.
TryStaticCastResult
TryLValueToRValueCast(Sema &Self, Expr *SrcExpr, QualType DestType,
const SourceRange &OpRange)
{
// N2844 5.2.9p3: An lvalue of type "cv1 T1" can be cast to type "rvalue
// reference to cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1".
const RValueReferenceType *R = DestType->getAsRValueReferenceType();
if (!R)
return TSC_NotApplicable;
if (SrcExpr->isLvalue(Self.Context) != Expr::LV_Valid)
return TSC_NotApplicable;
// Because we try the reference downcast before this function, from now on
// this is the only cast possibility, so we issue an error if we fail now.
bool DerivedToBase;
if (Self.CompareReferenceRelationship(SrcExpr->getType(), R->getPointeeType(),
DerivedToBase) <
Sema::Ref_Compatible_With_Added_Qualification) {
Self.Diag(OpRange.getBegin(), diag::err_bad_lvalue_to_rvalue_cast)
<< SrcExpr->getType() << R->getPointeeType() << OpRange;
return TSC_Failed;
}
// FIXME: Similar to CheckReferenceInit, we actually need more AST annotation
// than nothing.
return TSC_Success;
}