Provide -Wuninitialized-experimental fixits
for floats, and also check if 'nil' is declared
when suggesting it for initializing ObjC pointers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124004 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index 91f95a7..38284f6 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -421,12 +421,19 @@
// Suggest possible initialization (if any).
const char *initialization = 0;
- QualType vdTy = vd->getType();
+ QualType vdTy = vd->getType().getCanonicalType();
if (vdTy->getAs<ObjCObjectPointerType>()) {
- initialization = " = nil";
+ // Check if 'nil' is defined.
+ if (S.PP.getMacroInfo(&S.getASTContext().Idents.get("nil")))
+ initialization = " = nil";
+ else
+ initialization = " = 0";
}
- else if (vdTy->getAs<PointerType>()) {
+ else if (vdTy->isRealFloatingType()) {
+ initialization = " = 0.0";
+ }
+ else if (vdTy->isScalarType()) {
initialization = " = 0";
}