r199663 - Making some minor improvements to r199626.
Aaron Ballman
aaron at aaronballman.com
Mon Jan 20 06:19:44 PST 2014
Author: aaronballman
Date: Mon Jan 20 08:19:44 2014
New Revision: 199663
URL: http://llvm.org/viewvc/llvm-project?rev=199663&view=rev
Log:
Making some minor improvements to r199626.
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/Sema/nonnull.c
Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=199663&r1=199662&r2=199663&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Mon Jan 20 08:19:44 2014
@@ -696,7 +696,7 @@ def NonNull : InheritableAttr {
}
def ReturnsNonNull : InheritableAttr {
- let Spellings = [GNU<"returns_nonnull">];
+ let Spellings = [GNU<"returns_nonnull">, CXX11<"gnu", "returns_nonnull">];
let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag,
"ExpectedFunctionOrMethod">;
}
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=199663&r1=199662&r2=199663&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Mon Jan 20 08:19:44 2014
@@ -1235,12 +1235,7 @@ static void handleNonNullAttr(Sema &S, D
static void handleReturnsNonNullAttr(Sema &S, Decl *D,
const AttributeList &Attr) {
- QualType ResultType;
- if (const FunctionType *Ty = D->getFunctionType())
- ResultType = Ty->getResultType();
- else if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
- ResultType = MD->getResultType();
-
+ QualType ResultType = getFunctionOrMethodResultType(D);
if (!attrNonNullArgCheck(S, ResultType, Attr, Attr.getRange(),
/* isReturnValue */ true))
return;
@@ -3997,9 +3992,8 @@ static void ProcessDeclAttribute(Sema &S
else
handleNonNullAttr(S, D, Attr);
break;
- case AttributeList::AT_ReturnsNonNull:
- handleReturnsNonNullAttr(S, D, Attr);
- break;
+ case AttributeList::AT_ReturnsNonNull:
+ handleReturnsNonNullAttr(S, D, Attr); break;
case AttributeList::AT_Overloadable:
handleSimpleAttribute<OverloadableAttr>(S, D, Attr); break;
case AttributeList::AT_Ownership: handleOwnershipAttr (S, D, Attr); break;
Modified: cfe/trunk/test/Sema/nonnull.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/nonnull.c?rev=199663&r1=199662&r2=199663&view=diff
==============================================================================
--- cfe/trunk/test/Sema/nonnull.c (original)
+++ cfe/trunk/test/Sema/nonnull.c Mon Jan 20 08:19:44 2014
@@ -32,10 +32,10 @@ void test_baz() {
baz3(0); // no-warning
}
-void test_void_returns_nonnull() __attribute__((returns_nonnull)); // expected-warning {{'returns_nonnull' attribute only applies to return values that are pointers}}
-int test_int_returns_nonnull() __attribute__((returns_nonnull)); // expected-warning {{'returns_nonnull' attribute only applies to return values that are pointers}}
-void *test_ptr_returns_nonnull() __attribute__((returns_nonnull)); // no-warning
+void test_void_returns_nonnull(void) __attribute__((returns_nonnull)); // expected-warning {{'returns_nonnull' attribute only applies to return values that are pointers}}
+int test_int_returns_nonnull(void) __attribute__((returns_nonnull)); // expected-warning {{'returns_nonnull' attribute only applies to return values that are pointers}}
+void *test_ptr_returns_nonnull(void) __attribute__((returns_nonnull)); // no-warning
int i __attribute__((nonnull)); // expected-warning {{'nonnull' attribute only applies to functions, methods, and parameters}}
int j __attribute__((returns_nonnull)); // expected-warning {{'returns_nonnull' attribute only applies to functions and methods}}
-
+void *test_no_fn_proto() __attribute__((returns_nonnull)); // expected-warning {{'returns_nonnull' attribute only applies to functions and methods}}
More information about the cfe-commits
mailing list