Add FixItHint for -Wnull-conversion to initialize with an appropriate literal.
Reviewed by Doug Gregor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155839 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 6b18c98..ac28221 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -5090,12 +5090,14 @@
(RD->isEmpty() || RD->hasUserProvidedDefaultConstructor()))
Diag(C.Loc, diag::note_empty_parens_default_ctor)
<< FixItHint::CreateRemoval(ParenRange);
- else if (const char *Init = getFixItZeroInitializerForType(T))
- Diag(C.Loc, diag::note_empty_parens_zero_initialize)
- << FixItHint::CreateReplacement(ParenRange, Init);
- else if (LangOpts.CPlusPlus0x)
- Diag(C.Loc, diag::note_empty_parens_zero_initialize)
- << FixItHint::CreateReplacement(ParenRange, "{}");
+ else {
+ std::string Init = getFixItZeroInitializerForType(T);
+ if (Init.empty() && LangOpts.CPlusPlus0x)
+ Init = "{}";
+ if (!Init.empty())
+ Diag(C.Loc, diag::note_empty_parens_zero_initialize)
+ << FixItHint::CreateReplacement(ParenRange, Init);
+ }
}
}