Hello Richard,<br><br>thank you very much for this, it looks really nice :)<br><br>I only have two tiny remarks:<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

--- cfe/trunk/include/clang/Sema/Sema.h (original)<br>
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jan 12 17:53:29 2012<br>
@@ -756,6 +756,9 @@<br>
<br>
   bool findMacroSpelling(SourceLocation &loc, StringRef name);<br>
<br>
+  /// \brief Get a string to suggest for zero-initialization of a type.<br>
+  const char *getFixItZeroInitializerForType(QualType T) const;<br>
+<br></blockquote><div><br>Why not use a StringRef here ?<br><br>It is meant to be passed to FixItHint::CreateInsertion anyway, which will perform the conversion, and won't even benefit from __builtin_strlen to deduce the length.<br>
<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)<br>
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Thu Jan 12 17:53:29 2012<br>
<br>[...]</blockquote><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
+  SourceLocation Loc = S.PP.getLocForEndOfToken(VD->getLocEnd());<br>
+  S.Diag(Loc, diag::note_var_fixit_add_initialization) << VD->getDeclName()<br>
+    << FixItHint::CreateInsertion(Loc, Init);<br>
+  return true;<br>
 }<br>
<br></blockquote><div> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
--- cfe/trunk/lib/Sema/SemaFixItUtils.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaFixItUtils.cpp Thu Jan 12 17:53:29 2012<br>
@@ -158,3 +158,31 @@<br>
<br>
   return false;<br>
 }<br>
+<br>
+const char *Sema::getFixItZeroInitializerForType(QualType T) const {<br>
+  // Suggest 'nil' if it's defined and appropriate.<br>
+  if ((T->isObjCObjectPointerType() || T->isBlockPointerType()) &&<br>
+      PP.getMacroInfo(&getASTContext().Idents.get("nil")))<br>
+    return " = nil";<br>
+  if (T->isRealFloatingType())<br>
+    return " = 0.0";<br>
+  if (T->isBooleanType() && LangOpts.CPlusPlus)<br>
+    return " = false";<br>
+  if (T->isPointerType() || T->isMemberPointerType()) {<br>
+    if (LangOpts.CPlusPlus0x)<br>
+      return " = nullptr";<br>
+    // Check if 'NULL' is defined.<br>
+    else if (PP.getMacroInfo(&getASTContext().Idents.get("NULL")))<br>
+      return " = NULL";<br></blockquote><div><br>Why not suggesting " = 0" here instead of letting the flow cascade ?<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

+  }<br>
+  if (T->isEnumeralType())<br>
+    return 0;<br>
+  if (T->isScalarType())<br>
+    return " = 0";<br>
+  const CXXRecordDecl *RD = T->getAsCXXRecordDecl();<br>
+  if (LangOpts.CPlusPlus0x && RD && !RD->hasUserProvidedDefaultConstructor())<br>
+    return "{}";<br>
+  if (T->isAggregateType())<br>
+    return " = {}";<br>
+  return 0;<br>
+}<br>
<br></blockquote></div><br>-- Matthieu<br>