diff options
-rw-r--r-- | include/clang/Basic/DiagnosticGroups.td | 4 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 6 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 16 | ||||
-rw-r--r-- | test/Sema/warn-self-assign-field.mm (renamed from test/Sema/warn-self-assign-memvar.mm) | 4 |
4 files changed, 15 insertions, 15 deletions
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<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< 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<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 @@ 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 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. } |