Pure,
Regparm,
Section,
+ Sentinel,
StdCall,
TransparentUnion,
Unavailable,
static bool classof(const FormatAttr *A) { return true; }
};
+class SentinelAttr : public Attr {
+ int sentinel, NullPos;
+public:
+ SentinelAttr(int sentinel_val, int nullPos) : Attr(Sentinel),
+ sentinel(sentinel_val), NullPos(nullPos) {}
+ int getSentinel() const { return sentinel; }
+ int getNullPos() const { return NullPos; }
+
+ virtual Attr *clone(ASTContext &C) const {
+ return ::new (C) SentinelAttr(sentinel, NullPos);
+ }
+
+ // Implement isa/cast/dyncast/etc.
+ static bool classof(const Attr *A) { return A->getKind() == Sentinel; }
+ static bool classof(const SentinelAttr *A) { return true; }
+};
+
class VisibilityAttr : public Attr {
public:
/// @brief An enumeration for the kinds of visibility of symbols.
New = ::new (*Context) FormatAttr(Type, FormatIdx, FirstArg);
break;
}
+
+ case Attr::Sentinel: {
+ int sentinel = Record[Idx++];
+ int nullPos = Record[Idx++];
+ New = ::new (*Context) SentinelAttr(sentinel, nullPos);
+ break;
+ }
SIMPLE_ATTR(GNUInline);
break;
}
+ case Attr::Sentinel : {
+ const SentinelAttr *Sentinel = cast<SentinelAttr>(Attr);
+ Record.push_back(Sentinel->getSentinel());
+ Record.push_back(Sentinel->getNullPos());
+ break;
+ }
+
case Attr::GNUInline:
case Attr::IBOutletKind:
case Attr::NoReturn:
bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,
ObjCMethodDecl *Getter,
SourceLocation Loc);
+ void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
+ Expr **Args, unsigned NumArgs);
// Primary Expressions.
virtual SourceRange getExprRange(ExprTy *E) const;
return false;
}
+/// DiagnoseSentinelCalls - This routine checks on method dispatch calls
+/// (and other functions in future), which have been declared with sentinel
+/// attribute. It warns if call does not have the sentinel argument.
+///
+void Sema::DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
+ Expr **Args, unsigned NumArgs)
+{
+}
+
SourceRange Sema::getExprRange(ExprTy *E) const {
Expr *Ex = (Expr *)E;
return Ex? Ex->getSourceRange() : SourceRange();
return true;
}
+ if (Method)
+ DiagnoseSentinelCalls(Method, receiverLoc, ArgExprs, NumArgs);
if (CheckMessageArgumentTypes(ArgExprs, NumArgs, Sel, Method, false,
lbrac, rbrac, returnType))
return true;