[cfe-commits] r135970 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/FixIt/fixit-static-object-decl.m

Douglas Gregor dgregor at apple.com
Mon Jul 25 16:50:17 PDT 2011


On Jul 25, 2011, at 2:12 PM, Fariborz Jahanian wrote:

> Author: fjahanian
> Date: Mon Jul 25 16:12:27 2011
> New Revision: 135970
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=135970&view=rev
> Log:
> objective-c: Provide a 'fixit' when class was used
> to declare a static object. // rdar://9603056
> 
> Added:
>    cfe/trunk/test/FixIt/fixit-static-object-decl.m
> Modified:
>    cfe/trunk/lib/Sema/SemaDecl.cpp
> 
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=135970&r1=135969&r2=135970&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jul 25 16:12:27 2011
> @@ -3937,7 +3937,8 @@
>   QualType T = NewVD->getType();
> 
>   if (T->isObjCObjectType()) {
> -    Diag(NewVD->getLocation(), diag::err_statically_allocated_object);
> +    Diag(NewVD->getLocation(), diag::err_statically_allocated_object)
> +      << FixItHint::CreateInsertion(NewVD->getLocation(), "*");
>     return NewVD->setInvalidDecl();
>   }

Whenever we emit a Fix-It, the compiler needs to recover as if the user has written the code we suggest. In this case, that means fixing up the type of NewVD to be a pointer to 'T' without marking the declaration invalid or returning.

	- Doug



More information about the cfe-commits mailing list