[cfe-commits] r134302 - /cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp

Jordy Rose jediknil at belkadan.com
Fri Jul 1 18:06:59 PDT 2011


Just to be silly, if we're in an ObjC context and 'NULL' is defined, but 'nil' isn't, is 'NULL' preferable to 0? Or is that a contrived situation we don't care about?

(Also, do we care about 'Nil', the null value for ObjC 'Class' type, and 'false' for C99 _Bool?)

Jordy


On Jul 1, 2011, at 17:59, Douglas Gregor wrote:

> Author: dgregor
> Date: Fri Jul  1 19:59:18 2011
> New Revision: 134302
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=134302&view=rev
> Log:
> When producing -Wuninitialized Fix-Its for pointers, prefer " = NULL"
> over "= 0". Fixes <rdar://problem/9714386>.
> 
> Modified:
>    cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
> 
> Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=134302&r1=134301&r2=134302&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
> +++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Fri Jul  1 19:59:18 2011
> @@ -486,7 +486,8 @@
>   const char *initialization = 0;
>   QualType VariableTy = VD->getType().getCanonicalType();
> 
> -  if (VariableTy->getAs<ObjCObjectPointerType>()) {
> +  if (VariableTy->isObjCObjectPointerType() ||
> +      VariableTy->isBlockPointerType()) {
>     // Check if 'nil' is defined.
>     if (S.PP.getMacroInfo(&S.getASTContext().Idents.get("nil")))
>       initialization = " = nil";
> @@ -499,6 +500,13 @@
>     initialization = " = false";
>   else if (VariableTy->isEnumeralType())
>     return;
> +  else if (VariableTy->isPointerType() || VariableTy->isMemberPointerType()) {
> +    // Check if 'NULL' is defined.
> +    if (S.PP.getMacroInfo(&S.getASTContext().Idents.get("NULL")))
> +      initialization = " = NULL";
> +    else
> +      initialization = " = 0";
> +  }
>   else if (VariableTy->isScalarType())
>     initialization = " = 0";
> 
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits





More information about the cfe-commits mailing list