From: Nico Weber Date: Tue, 3 Jul 2012 02:03:06 +0000 (+0000) Subject: Rename -Wself-assign-memvar to -Wself-assign-field to improve local consistency a... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c81b43bef441960e921e0eb72d249369b7dd96c;p=clang Rename -Wself-assign-memvar to -Wself-assign-field to improve local consistency a bit. (cf -Wunused-private-field and several other existing -field diagnostics.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159633 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index ab2cd1b08b..8753589bfb 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -169,8 +169,8 @@ def ReturnTypeCLinkage : DiagGroup<"return-type-c-linkage">; 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">; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 66ae44fb28..d691169381 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -5283,9 +5283,9 @@ def warn_stringcompare : Warning< "unspecified (use strncmp instead)">, InGroup>; -def warn_identity_memvar_assign : Warning< - "assigning %select{member variable|instance variable}0 to itself">, - InGroup; +def warn_identity_field_assign : Warning< + "assigning %select{field|instance variable}0 to itself">, + InGroup; // Generic selections. def err_assoc_type_incomplete : Error< diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 1f2850f6ec..cfc55e5715 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -7558,25 +7558,25 @@ static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S) { 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(LHSExpr); MemberExpr *MR = dyn_cast(RHSExpr); if (ML && MR && ML->getMemberDecl() == MR->getMemberDecl()) { if (isa(ML->getBase()) && isa(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(LHSExpr); ObjCIvarRefExpr *OR = dyn_cast(RHSExpr); if (OL && OR && OL->getDecl() == OR->getDecl()) { DeclRefExpr *RL = dyn_cast(OL->getBase()->IgnoreImpCasts()); DeclRefExpr *RR = dyn_cast(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 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, if (CompoundType.isNull()) { Expr *RHSCheck = RHS.get(); - CheckIdentityMemvarAssignment(LHSExpr, RHSCheck, Loc, *this); + CheckIdentityFieldAssignment(LHSExpr, RHSCheck, Loc, *this); QualType LHSTy(LHSType); ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS); diff --git a/test/Sema/warn-self-assign-memvar.mm b/test/Sema/warn-self-assign-field.mm similarity index 86% rename from test/Sema/warn-self-assign-memvar.mm rename to test/Sema/warn-self-assign-field.mm index 8c6fb0a5a0..ad0ff3e694 100644 --- a/test/Sema/warn-self-assign-memvar.mm +++ b/test/Sema/warn-self-assign-field.mm @@ -4,10 +4,10 @@ class S { 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. }