When producing -Wuninitialized Fix-Its for pointers, prefer " = NULL"
over "= 0". Fixes <rdar://problem/9714386>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134302 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index 9efae61..e560ef8 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -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";