本文整理汇总了C++中ObjCMethodDecl::isOverriding方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjCMethodDecl::isOverriding方法的具体用法?C++ ObjCMethodDecl::isOverriding怎么用?C++ ObjCMethodDecl::isOverriding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjCMethodDecl
的用法示例。
在下文中一共展示了ObjCMethodDecl::isOverriding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: canBeOverridenInSubclass
bool ObjCMethodCall::canBeOverridenInSubclass(ObjCInterfaceDecl *IDecl,
Selector Sel) const {
assert(IDecl);
const SourceManager &SM =
getState()->getStateManager().getContext().getSourceManager();
// If the class interface is declared inside the main file, assume it is not
// subcassed.
// TODO: It could actually be subclassed if the subclass is private as well.
// This is probably very rare.
SourceLocation InterfLoc = IDecl->getEndOfDefinitionLoc();
if (InterfLoc.isValid() && SM.isFromMainFile(InterfLoc))
return false;
// Assume that property accessors are not overridden.
if (getMessageKind() == OCM_PropertyAccess)
return false;
// We assume that if the method is public (declared outside of main file) or
// has a parent which publicly declares the method, the method could be
// overridden in a subclass.
// Find the first declaration in the class hierarchy that declares
// the selector.
ObjCMethodDecl *D = 0;
while (true) {
D = IDecl->lookupMethod(Sel, true);
// Cannot find a public definition.
if (!D)
return false;
// If outside the main file,
if (D->getLocation().isValid() && !SM.isFromMainFile(D->getLocation()))
return true;
if (D->isOverriding()) {
// Search in the superclass on the next iteration.
IDecl = D->getClassInterface();
if (!IDecl)
return false;
IDecl = IDecl->getSuperClass();
if (!IDecl)
return false;
continue;
}
return false;
};
llvm_unreachable("The while loop should always terminate.");
}