本文整理汇总了C++中ASTContext::canAssignObjCInterfaces方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTContext::canAssignObjCInterfaces方法的具体用法?C++ ASTContext::canAssignObjCInterfaces怎么用?C++ ASTContext::canAssignObjCInterfaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTContext
的用法示例。
在下文中一共展示了ASTContext::canAssignObjCInterfaces方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
/// Inputs:
/// \param StaticLowerBound Static lower bound for a symbol. The dynamic lower
/// bound might be the subclass of this type.
/// \param StaticUpperBound A static upper bound for a symbol.
/// \p StaticLowerBound expected to be the subclass of \p StaticUpperBound.
/// \param Current The type that was inferred for a symbol in a previous
/// context. Might be null when this is the first time that inference happens.
/// Precondition:
/// \p StaticLowerBound or \p StaticUpperBound is specialized. If \p Current
/// is not null, it is specialized.
/// Possible cases:
/// (1) The \p Current is null and \p StaticLowerBound <: \p StaticUpperBound
/// (2) \p StaticLowerBound <: \p Current <: \p StaticUpperBound
/// (3) \p Current <: \p StaticLowerBound <: \p StaticUpperBound
/// (4) \p StaticLowerBound <: \p StaticUpperBound <: \p Current
/// Effect:
/// Use getMostInformativeDerivedClass with the upper and lower bound of the
/// set {\p StaticLowerBound, \p Current, \p StaticUpperBound}. The computed
/// lower bound must be specialized. If the result differs from \p Current or
/// \p Current is null, store the result.
static bool
storeWhenMoreInformative(ProgramStateRef &State, SymbolRef Sym,
const ObjCObjectPointerType *const *Current,
const ObjCObjectPointerType *StaticLowerBound,
const ObjCObjectPointerType *StaticUpperBound,
ASTContext &C) {
// TODO: The above 4 cases are not exhaustive. In particular, it is possible
// for Current to be incomparable with StaticLowerBound, StaticUpperBound,
// or both.
//
// For example, suppose Foo<T> and Bar<T> are unrelated types.
//
// Foo<T> *f = ...
// Bar<T> *b = ...
//
// id t1 = b;
// f = t1;
// id t2 = f; // StaticLowerBound is Foo<T>, Current is Bar<T>
//
// We should either constrain the callers of this function so that the stated
// preconditions hold (and assert it) or rewrite the function to expicitly
// handle the additional cases.
// Precondition
assert(StaticUpperBound->isSpecialized() ||
StaticLowerBound->isSpecialized());
assert(!Current || (*Current)->isSpecialized());
// Case (1)
if (!Current) {
if (StaticUpperBound->isUnspecialized()) {
State = State->set<MostSpecializedTypeArgsMap>(Sym, StaticLowerBound);
return true;
}
// Upper bound is specialized.
const ObjCObjectPointerType *WithMostInfo =
getMostInformativeDerivedClass(StaticUpperBound, StaticLowerBound, C);
State = State->set<MostSpecializedTypeArgsMap>(Sym, WithMostInfo);
return true;
}
// Case (3)
if (C.canAssignObjCInterfaces(StaticLowerBound, *Current)) {
return false;
}
// Case (4)
if (C.canAssignObjCInterfaces(*Current, StaticUpperBound)) {
// The type arguments might not be forwarded at any point of inheritance.
const ObjCObjectPointerType *WithMostInfo =
getMostInformativeDerivedClass(*Current, StaticUpperBound, C);
WithMostInfo =
getMostInformativeDerivedClass(WithMostInfo, StaticLowerBound, C);
if (WithMostInfo == *Current)
return false;
State = State->set<MostSpecializedTypeArgsMap>(Sym, WithMostInfo);
return true;
}
// Case (2)
const ObjCObjectPointerType *WithMostInfo =
getMostInformativeDerivedClass(*Current, StaticLowerBound, C);
if (WithMostInfo != *Current) {
State = State->set<MostSpecializedTypeArgsMap>(Sym, WithMostInfo);
return true;
}
return false;
}