[cfe-commits] r159633 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/Sema/warn-self-assign-field.mm test/Sema/warn-self-assign-memvar.mm
Nico Weber
nicolasweber at gmx.de
Mon Jul 2 19:03:06 PDT 2012
Author: nico
Date: Mon Jul 2 21:03:06 2012
New Revision: 159633
URL: http://llvm.org/viewvc/llvm-project?rev=159633&view=rev
Log:
Rename -Wself-assign-memvar to -Wself-assign-field to improve local consistency a bit.
(cf -Wunused-private-field and several other existing -field diagnostics.)
Added:
cfe/trunk/test/Sema/warn-self-assign-field.mm
- copied, changed from r159394, cfe/trunk/test/Sema/warn-self-assign-memvar.mm
Removed:
cfe/trunk/test/Sema/warn-self-assign-memvar.mm
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=159633&r1=159632&r2=159633&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Mon Jul 2 21:03:06 2012
@@ -169,8 +169,8 @@
def ReturnType : DiagGroup<"return-type", [ReturnTypeCLinkage]>;
def BindToTemporaryCopy : DiagGroup<"bind-to-temporary-copy",
[CXX98CompatBindToTemporaryCopy]>;
-def SelfAssignmentMemvar : DiagGroup<"self-assign-memvar">;
-def SelfAssignment : DiagGroup<"self-assign", [SelfAssignmentMemvar]>;
+def SelfAssignmentField : DiagGroup<"self-assign-field">;
+def SelfAssignment : DiagGroup<"self-assign", [SelfAssignmentField]>;
def SemiBeforeMethodBody : DiagGroup<"semicolon-before-method-body">;
def Sentinel : DiagGroup<"sentinel">;
def MissingMethodReturnType : DiagGroup<"missing-method-return-type">;
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=159633&r1=159632&r2=159633&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jul 2 21:03:06 2012
@@ -5283,9 +5283,9 @@
"unspecified (use strncmp instead)">,
InGroup<DiagGroup<"string-compare">>;
-def warn_identity_memvar_assign : Warning<
- "assigning %select{member variable|instance variable}0 to itself">,
- InGroup<SelfAssignmentMemvar>;
+def warn_identity_field_assign : Warning<
+ "assigning %select{field|instance variable}0 to itself">,
+ InGroup<SelfAssignmentField>;
// Generic selections.
def err_assoc_type_incomplete : Error<
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=159633&r1=159632&r2=159633&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jul 2 21:03:06 2012
@@ -7558,25 +7558,25 @@
return true;
}
-static void CheckIdentityMemvarAssignment(Expr *LHSExpr, Expr *RHSExpr,
- SourceLocation Loc,
- Sema &Sema) {
- // C / C++ memvars
+static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr,
+ SourceLocation Loc,
+ Sema &Sema) {
+ // C / C++ fields
MemberExpr *ML = dyn_cast<MemberExpr>(LHSExpr);
MemberExpr *MR = dyn_cast<MemberExpr>(RHSExpr);
if (ML && MR && ML->getMemberDecl() == MR->getMemberDecl()) {
if (isa<CXXThisExpr>(ML->getBase()) && isa<CXXThisExpr>(MR->getBase()))
- Sema.Diag(Loc, diag::warn_identity_memvar_assign) << 0;
+ Sema.Diag(Loc, diag::warn_identity_field_assign) << 0;
}
- // Objective-C memvars
+ // Objective-C instance variables
ObjCIvarRefExpr *OL = dyn_cast<ObjCIvarRefExpr>(LHSExpr);
ObjCIvarRefExpr *OR = dyn_cast<ObjCIvarRefExpr>(RHSExpr);
if (OL && OR && OL->getDecl() == OR->getDecl()) {
DeclRefExpr *RL = dyn_cast<DeclRefExpr>(OL->getBase()->IgnoreImpCasts());
DeclRefExpr *RR = dyn_cast<DeclRefExpr>(OR->getBase()->IgnoreImpCasts());
if (RL && RR && RL->getDecl() == RR->getDecl())
- Sema.Diag(Loc, diag::warn_identity_memvar_assign) << 1;
+ Sema.Diag(Loc, diag::warn_identity_field_assign) << 1;
}
}
@@ -7597,7 +7597,7 @@
if (CompoundType.isNull()) {
Expr *RHSCheck = RHS.get();
- CheckIdentityMemvarAssignment(LHSExpr, RHSCheck, Loc, *this);
+ CheckIdentityFieldAssignment(LHSExpr, RHSCheck, Loc, *this);
QualType LHSTy(LHSType);
ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
Copied: cfe/trunk/test/Sema/warn-self-assign-field.mm (from r159394, cfe/trunk/test/Sema/warn-self-assign-memvar.mm)
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-self-assign-field.mm?p2=cfe/trunk/test/Sema/warn-self-assign-field.mm&p1=cfe/trunk/test/Sema/warn-self-assign-memvar.mm&r1=159394&r2=159633&rev=159633&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-self-assign-memvar.mm (original)
+++ cfe/trunk/test/Sema/warn-self-assign-field.mm Mon Jul 2 21:03:06 2012
@@ -4,10 +4,10 @@
public:
int a_;
void s(int a) {
- a_ = a_; // expected-warning {{assigning member variable to itself}}
+ a_ = a_; // expected-warning {{assigning field to itself}}
// Don't really care about this one either way.
- this->a_ = a_; // expected-warning {{assigning member variable to itself}}
+ this->a_ = a_; // expected-warning {{assigning field to itself}}
a_ += a_; // Shouldn't warn.
}
Removed: cfe/trunk/test/Sema/warn-self-assign-memvar.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-self-assign-memvar.mm?rev=159632&view=auto
==============================================================================
--- cfe/trunk/test/Sema/warn-self-assign-memvar.mm (original)
+++ cfe/trunk/test/Sema/warn-self-assign-memvar.mm (removed)
@@ -1,66 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-
-class S {
- public:
- int a_;
- void s(int a) {
- a_ = a_; // expected-warning {{assigning member variable to itself}}
-
- // Don't really care about this one either way.
- this->a_ = a_; // expected-warning {{assigning member variable to itself}}
-
- a_ += a_; // Shouldn't warn.
- }
-};
-
-void f0(S* s) {
- // Would be nice to have, but not important.
- s->a_ = s->a_;
-}
-
-void f1(S* s, S* t) {
- // Shouldn't warn.
- t->a_ = s->a_;
-}
-
-struct T {
- S* s_;
-};
-
-void f2(T* t) {
- // Would be nice to have, but even less important.
- t->s_->a_ = t->s_->a_;
-}
-
-void f3(T* t, T* t2) {
- // Shouldn't warn.
- t2->s_->a_ = t->s_->a_;
-}
-
-void f4(int i) {
- // This is a common pattern to silence "parameter unused". Shouldn't warn.
- i = i;
-
- int j = 0;
- j = j; // Likewise.
-}
-
- at interface I {
- int a_;
-}
- at end
-
- at implementation I
-- (void)setA:(int)a {
- a_ = a_; // expected-warning {{assigning instance variable to itself}}
-}
-
-- (void)foo:(I*)i {
- // Don't care much about this warning.
- i->a_ = i->a_; // expected-warning {{assigning instance variable to itself}}
-
- // Shouldn't warn.
- a_ = i->a_;
- i->a_ = a_;
-}
- at end
More information about the cfe-commits
mailing list