[cfe-commits] r160541 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/ARCMT/cxx-rewrite.mm.result test/SemaCXX/warn-unused-private-field.cpp
Nico Weber
nicolasweber at gmx.de
Thu Jul 19 20:39:05 PDT 2012
Author: nico
Date: Thu Jul 19 22:39:05 2012
New Revision: 160541
URL: http://llvm.org/viewvc/llvm-project?rev=160541&view=rev
Log:
Let Expr::HasSideEffects() return false for NULL, bool literals, this, and nullptr.
Fixes PR13413, -Wunused-private-field now warns on unused fields initialized to NULL.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/ARCMT/cxx-rewrite.mm.result
cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=160541&r1=160540&r2=160541&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Jul 19 22:39:05 2012
@@ -2340,6 +2340,12 @@
return Visit(E->getSubExpr());
}
bool VisitUnaryOperator(const UnaryOperator *E) { return Visit(E->getSubExpr()); }
+ bool VisitGNUNullExpr(const GNUNullExpr *E) { return false; }
+ bool VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) { return false; }
+ bool VisitCXXThisExpr(const CXXThisExpr *E) { return false; }
+ bool VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E) {
+ return false;
+ }
// Has side effects if any element does.
bool VisitInitListExpr(const InitListExpr *E) {
Modified: cfe/trunk/test/ARCMT/cxx-rewrite.mm.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/cxx-rewrite.mm.result?rev=160541&r1=160540&r2=160541&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/cxx-rewrite.mm.result (original)
+++ cfe/trunk/test/ARCMT/cxx-rewrite.mm.result Thu Jul 19 22:39:05 2012
@@ -16,7 +16,7 @@
[NSString string];
}
}
- ~foo(){ s; }
+ ~foo(){ }
private:
foo(foo const &);
foo &operator=(foo const &);
Modified: cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp?rev=160541&r1=160540&r2=160541&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-private-field.cpp Thu Jul 19 22:39:05 2012
@@ -209,3 +209,13 @@
unsigned char Data[8];
};
} // namespace anonymous_structs_unions
+
+namespace pr13413 {
+class A {
+ A() : p_(__null), b_(false), a_(this), p2_(nullptr) {}
+ void* p_; // expected-warning{{private field 'p_' is not used}}
+ bool b_; // expected-warning{{private field 'b_' is not used}}
+ A* a_; // expected-warning{{private field 'a_' is not used}}
+ void* p2_; // expected-warning{{private field 'p2_' is not used}}
+};
+}
More information about the cfe-commits
mailing list