r184740 - [Sema] Call CheckParmForFunctionDef on ObjC method parameters

Reid Kleckner reid at kleckner.net
Mon Jun 24 07:38:26 PDT 2013


Author: rnk
Date: Mon Jun 24 09:38:26 2013
New Revision: 184740

URL: http://llvm.org/viewvc/llvm-project?rev=184740&view=rev
Log:
[Sema] Call CheckParmForFunctionDef on ObjC method parameters

CheckParmForFunctionDef performs standard checks for type completeness
and other things like a destructor check for the MSVC++ ABI.

Added:
    cfe/trunk/test/SemaObjCXX/microsoft-abi-byval.mm
Modified:
    cfe/trunk/include/clang/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/SemaObjC/method-bad-param.m

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=184740&r1=184739&r2=184740&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Jun 24 09:38:26 2013
@@ -2244,7 +2244,8 @@ public:
                            CallExpr *CE, FunctionDecl *FD);
 
   /// Helpers for dealing with blocks and functions.
-  bool CheckParmsForFunctionDef(ParmVarDecl **Param, ParmVarDecl **ParamEnd,
+  bool CheckParmsForFunctionDef(ParmVarDecl *const *Param,
+                                ParmVarDecl *const *ParamEnd,
                                 bool CheckParameterNames);
   void CheckCXXDefaultArguments(FunctionDecl *FD);
   void CheckExtraCXXDefaultArguments(Declarator &D);

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=184740&r1=184739&r2=184740&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Jun 24 09:38:26 2013
@@ -5758,7 +5758,8 @@ void Sema::CheckBitFieldInitialization(S
 /// takes care of any checks that cannot be performed on the
 /// declaration itself, e.g., that the types of each of the function
 /// parameters are complete.
-bool Sema::CheckParmsForFunctionDef(ParmVarDecl **P, ParmVarDecl **PEnd,
+bool Sema::CheckParmsForFunctionDef(ParmVarDecl *const *P,
+                                    ParmVarDecl *const *PEnd,
                                     bool CheckParameterNames) {
   bool HasInvalidParm = false;
   for (; P != PEnd; ++P) {

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=184740&r1=184739&r2=184740&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Mon Jun 24 09:38:26 2013
@@ -324,15 +324,15 @@ void Sema::ActOnStartOfObjCMethodDef(Sco
   PushOnScopeChains(MDecl->getSelfDecl(), FnBodyScope);
   PushOnScopeChains(MDecl->getCmdDecl(), FnBodyScope);
 
+  // The ObjC parser requires parameter names so there's no need to check.
+  CheckParmsForFunctionDef(MDecl->param_begin(), MDecl->param_end(),
+                           /*CheckParameterNames=*/false);
+
   // Introduce all of the other parameters into this scope.
   for (ObjCMethodDecl::param_iterator PI = MDecl->param_begin(),
        E = MDecl->param_end(); PI != E; ++PI) {
     ParmVarDecl *Param = (*PI);
     if (!Param->isInvalidDecl() &&
-        RequireCompleteType(Param->getLocation(), Param->getType(),
-                            diag::err_typecheck_decl_incomplete_type))
-          Param->setInvalidDecl();
-    if (!Param->isInvalidDecl() &&
         getLangOpts().ObjCAutoRefCount &&
         !HasExplicitOwnershipAttr(*this, Param))
       Diag(Param->getLocation(), diag::warn_arc_strong_pointer_objc_pointer) <<

Modified: cfe/trunk/test/SemaObjC/method-bad-param.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-bad-param.m?rev=184740&r1=184739&r2=184740&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/method-bad-param.m (original)
+++ cfe/trunk/test/SemaObjC/method-bad-param.m Mon Jun 24 09:38:26 2013
@@ -46,3 +46,13 @@ enum bogus; // expected-note {{forward d
 - (int[6])arrayRet; // expected-error {{function cannot return array type 'int [6]'}}
 - (int())funcRet; // expected-error {{function cannot return function type 'int ()'}}
 @end
+
+ at interface qux
+- (void) my_method: (int)arg; // expected-note {{method 'my_method:' declared here}}
+ at end
+
+// FIXME: The diagnostic and recovery here could probably be improved.
+ at implementation qux // expected-warning {{method definition for 'my_method:' not found}}
+- (void) my_method: (int) { // expected-error {{expected identifier}}
+}
+ at end

Added: cfe/trunk/test/SemaObjCXX/microsoft-abi-byval.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/microsoft-abi-byval.mm?rev=184740&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjCXX/microsoft-abi-byval.mm (added)
+++ cfe/trunk/test/SemaObjCXX/microsoft-abi-byval.mm Mon Jun 24 09:38:26 2013
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -cxx-abi microsoft -Wno-objc-root-class %s
+
+class Foo {
+  ~Foo(); // expected-note {{implicitly declared private here}}
+};
+
+ at interface bar
+- (void) my_method: (Foo)arg;
+ at end
+
+ at implementation bar
+- (void) my_method: (Foo)arg { // expected-error {{variable of type 'Foo' has private destructor}}
+}
+ at end





More information about the cfe-commits mailing list