[cfe-commits] r135685 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp test/FixIt/fixit-missing-method-return-type.m

Fariborz Jahanian fjahanian at apple.com
Thu Jul 21 10:38:14 PDT 2011


Author: fjahanian
Date: Thu Jul 21 12:38:14 2011
New Revision: 135685

URL: http://llvm.org/viewvc/llvm-project?rev=135685&view=rev
Log:
Add FixIt hint for missing 'id' type.
// rdar://9615045

Added:
    cfe/trunk/test/FixIt/fixit-missing-method-return-type.m
Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=135685&r1=135684&r2=135685&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Jul 21 12:38:14 2011
@@ -2300,7 +2300,8 @@
     }    
   } else { // get the type for "id".
     resultDeclType = Context.getObjCIdType();
-    Diag(MethodLoc, diag::warn_missing_method_return_type);
+    Diag(MethodLoc, diag::warn_missing_method_return_type)
+      << FixItHint::CreateInsertion(SelectorStartLoc, "(id)");
   }
 
   ObjCMethodDecl* ObjCMethod =

Added: cfe/trunk/test/FixIt/fixit-missing-method-return-type.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit-missing-method-return-type.m?rev=135685&view=auto
==============================================================================
--- cfe/trunk/test/FixIt/fixit-missing-method-return-type.m (added)
+++ cfe/trunk/test/FixIt/fixit-missing-method-return-type.m Thu Jul 21 12:38:14 2011
@@ -0,0 +1,24 @@
+// Objective-C recovery
+// RUN: cp %s %t
+// RUN: %clang_cc1 -Wmissing-method-return-type -fixit -x objective-c %t || true
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wmissing-method-return-type -Werror -x objective-c %t
+
+// Objective-C++ recovery
+// RUN: cp %s %t
+// RUN: %clang_cc1 -Wmissing-method-return-type -fixit -x objective-c++ %t || true
+// RUN: %clang_cc1 -fsyntax-only -pedantic -Wmissing-method-return-type -Werror -x objective-c++ %t
+// rdar://9615045
+
+ at interface I
+-  initWithFoo:(id)foo; // expected-warning {{method has no return type specified; defaults to 'id' [-Wmissing-method-return-type]}}
+- Meth;
+-Meth1;
+ at end
+
+ at implementation I
+- initWithFoo:(id)foo { return 0; } // expected-warning {{method has no return type specified; defaults to 'id' [-Wmissing-method-return-type]}}
+
+-Meth { return 0;}
+- Meth1 { return 0;}
+ at end
+





More information about the cfe-commits mailing list