]> granicus.if.org Git - clang/commitdiff
Rename -Wself-assign-memvar to -Wself-assign-field to improve local consistency a...
authorNico Weber <nicolasweber@gmx.de>
Tue, 3 Jul 2012 02:03:06 +0000 (02:03 +0000)
committerNico Weber <nicolasweber@gmx.de>
Tue, 3 Jul 2012 02:03:06 +0000 (02:03 +0000)
(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

include/clang/Basic/DiagnosticGroups.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaExpr.cpp
test/Sema/warn-self-assign-field.mm [moved from test/Sema/warn-self-assign-memvar.mm with 86% similarity]

index ab2cd1b08be5c0b28c601b9c2ec502e41a0e17cc..8753589bfb3467f71014b4819d28e875334d9b7a 100644 (file)
@@ -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">;
index 66ae44fb28194568e72f3c8d365281a8d6dcfb7c..d691169381df14a78d5fb5d5d41a0345753bdea7 100644 (file)
@@ -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<
index 1f2850f6ecb08b9ade2481ed0a27991314cde95c..cfc55e5715c061e39613b9901902201274f6367a 100644 (file)
@@ -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);
similarity index 86%
rename from test/Sema/warn-self-assign-memvar.mm
rename to test/Sema/warn-self-assign-field.mm
index 8c6fb0a5a0b6d6e13b7553bc97091a276b786aad..ad0ff3e694b2722ca0388d56aceaa6af7ab521bb 100644 (file)
@@ -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.
   }