Enhance attribute 'nonnull' to be applicable to parameters directly (infix).

Press ? to show keyboard shortcuts.
Committed
kremenekJan 16 2014, 10:24 PM
Parents
rL199466: Add ArrayRef<> interface to get the parameters of a FunctionDecl/ObjCMethodDecl.
Branches
Unknown
Tags
Unknown
Subscribers
None
Description

Enhance attribute 'nonnull' to be applicable to parameters directly (infix).

This allows the following syntax:

void baz(__attribute__((nonnull)) const char *str);

instead of:

void baz(const char *str) __attribute__((nonnull(1)));

This also extends to Objective-C methods.

The checking logic in Sema is not as clean as I would like. Effectively
now we need to check both the FunctionDecl/ObjCMethodDecl and the parameters,
so the point of truth is spread in two places, but the logic isn't that
cumbersome.

Implements rdar://problem/14691443.

rL199467

cfe/trunk/include/clang/Basic/Attr.td

Loading...

cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Loading...

cfe/trunk/lib/Sema/SemaChecking.cpp

Loading...

cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Loading...

cfe/trunk/test/Sema/nonnull.c

Loading...

cfe/trunk/test/SemaObjC/nonnull.m

Loading...

Add Comment