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

Douglas Gregor dgregor at apple.com
Fri Jul 1 17:59:18 PDT 2011


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";
 





More information about the cfe-commits mailing list