In C++0x mode, suggest nullptr as the initializer for an uninitialized
pointer variable. Patch by David Blaikie!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138687 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index 51b04a7..6c07418 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -508,8 +508,10 @@
else if (VariableTy->isEnumeralType())
return;
else if (VariableTy->isPointerType() || VariableTy->isMemberPointerType()) {
+ if (S.Context.getLangOptions().CPlusPlus0x)
+ initialization = " = nullptr";
// Check if 'NULL' is defined.
- if (S.PP.getMacroInfo(&S.getASTContext().Idents.get("NULL")))
+ else if (S.PP.getMacroInfo(&S.getASTContext().Idents.get("NULL")))
initialization = " = NULL";
else
initialization = " = 0";