[cfe-commits] r173315 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/attr-nonnull.cpp
Nick Lewycky
nicholas at mxc.ca
Wed Jan 23 18:03:09 PST 2013
Author: nicholas
Date: Wed Jan 23 20:03:08 2013
New Revision: 173315
URL: http://llvm.org/viewvc/llvm-project?rev=173315&view=rev
Log:
Start checking nonnull (as well as format and argument_with_type_tag) on
overloaded binary operators.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/attr-nonnull.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=173315&r1=173314&r2=173315&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Jan 23 20:03:08 2013
@@ -10336,6 +10336,13 @@
FnDecl))
return ExprError();
+ ArrayRef<const Expr *> ArgsArray(Args, 2);
+ // Cut off the implicit 'this'.
+ if (isa<CXXMethodDecl>(FnDecl))
+ ArgsArray = ArgsArray.slice(1);
+ checkCall(FnDecl, ArgsArray, 0, isa<CXXMethodDecl>(FnDecl), OpLoc,
+ TheCall->getSourceRange(), VariadicDoesNotApply);
+
return MaybeBindToTemporary(TheCall);
} else {
// We matched a built-in operator. Convert the arguments, then
Modified: cfe/trunk/test/SemaCXX/attr-nonnull.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-nonnull.cpp?rev=173315&r1=173314&r2=173315&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/attr-nonnull.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-nonnull.cpp Wed Jan 23 20:03:08 2013
@@ -40,3 +40,15 @@
f(static_cast<char*>(0)); // expected-warning{{null passed}}
}
}
+
+namespace test4 {
+struct X {
+ bool operator!=(const void *) const __attribute__((nonnull(2)));
+};
+bool operator==(const X&, const void *) __attribute__((nonnull(2)));
+
+void test(const X& x) {
+ (void)(x == 0); // expected-warning{{null passed}}
+ (void)(x != 0); // expected-warning{{null passed}}
+}
+}
More information about the cfe-commits
mailing list