[cfe-commits] r124263 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp test/Analysis/self-init.m

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Jan 25 17:26:41 PST 2011


Author: akirtzidis
Date: Tue Jan 25 19:26:41 2011
New Revision: 124263

URL: http://llvm.org/viewvc/llvm-project?rev=124263&view=rev
Log:
[analyzer] Improve the diagnostic for the self-init checker. Suggestion by Ted!

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
    cfe/trunk/test/Analysis/self-init.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp?rev=124263&r1=124262&r2=124263&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp Tue Jan 25 19:26:41 2011
@@ -102,8 +102,8 @@
 class InitSelfBug : public BugType {
   const std::string desc;
 public:
-  InitSelfBug() : BugType("missing \"self = [{initializer}]\"",
-                          "missing \"self = [{initializer}]\"") {}
+  InitSelfBug() : BugType("missing \"self = [(super or self) init...]\"",
+                          "missing \"self = [(super or self) init...]\"") {}
 };
 
 } // end anonymous namespace
@@ -209,7 +209,8 @@
     return;
 
   checkForInvalidSelf(E->getBase(), C,
-         "Using an ivar before setting 'self' to the result of an initializer");
+    "Instance variable used before setting 'self' to the result of "
+                                                 "'[(super or self) init...]'");
 }
 
 void ObjCSelfInitChecker::PreVisitReturnStmt(CheckerContext &C,
@@ -220,7 +221,8 @@
     return;
 
   checkForInvalidSelf(S->getRetValue(), C,
-          "Returning 'self' before setting it to the result of an initializer");
+    "Returning 'self' before setting it to the result of "
+                                                 "'[(super or self) init...]'");
 }
 
 // When a call receives a reference to 'self', [Pre/Post]VisitGenericCall pass

Modified: cfe/trunk/test/Analysis/self-init.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/self-init.m?rev=124263&r1=124262&r2=124263&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/self-init.m (original)
+++ cfe/trunk/test/Analysis/self-init.m Tue Jan 25 19:26:41 2011
@@ -97,7 +97,7 @@
 }
 
 -(id)init6 {
-  [NSBundle loadNibNamed:@"Window" owner:myivar]; // expected-warning {{Using an ivar}}
+  [NSBundle loadNibNamed:@"Window" owner:myivar]; // expected-warning {{Instance variable used}}
   return [self initWithSomething:0];
 }
 
@@ -121,7 +121,7 @@
 }
 
 -(id)init10 {
-	myivar = 0; // expected-warning {{Using an ivar}}
+	myivar = 0; // expected-warning {{Instance variable used}}
     return self;
 }
 
@@ -136,7 +136,7 @@
 
 -(id)init13 {
 	if ((self == [super init])) {
-	  myivar = 0; // expected-warning {{Using an ivar}}
+	  myivar = 0; // expected-warning {{Instance variable used}}
 	}
 	return self; // expected-warning {{Returning 'self'}}
 }





More information about the cfe-commits mailing list