<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">In r<span style="font-family: Menlo; font-size: 11px;">222009 with minor caveat. I was forced to make Sema::</span><span style="color: rgb(49, 89, 93); font-family: Menlo; font-size: 11px;">CheckBoolLikeConversion</span><div><span style="font-family: Menlo; font-size: 11px;"><font color="#31595d">public because it is called from static function.</font></span></div><div><span style="font-family: Menlo; font-size: 11px;"><font color="#31595d"><br></font></span></div><div><span style="font-family: Menlo; font-size: 11px;"><font color="#31595d">- Fariborz</font></span></div><div><span style="font-family: Menlo; font-size: 11px;"><font color="#31595d"><br></font></span><br><div><div>On Nov 13, 2014, at 4:16 PM, Richard Trieu <<a href="mailto:rtrieu@google.com">rtrieu@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div>Looks good, just a few small changes. Good to commit after changes are made.</div><div> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto;">Index: include/clang/Sema/Sema.h<br>===================================================================<br>--- include/clang/Sema/Sema.h<span style="white-space:pre-wrap"> </span>(revision 221791)<br>+++ include/clang/Sema/Sema.h<span style="white-space:pre-wrap"> </span>(working copy)<br>@@ -2982,6 +2982,7 @@<br> return TypoCorrection();<br> }<br> <br>+ void CheckBoolLikeConversion(Expr *E, SourceLocation CC);<br></blockquote><div>Move this function declaration next to the declaration for CheckImplicitConversions </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto;"> public:<br> /// AddInstanceMethodToGlobalPool - All instance methods in a translation<br> /// unit are added to a global pool. This allows us to efficiently associate<br>Index: lib/Sema/SemaChecking.cpp<br>===================================================================<br>--- lib/Sema/SemaChecking.cpp<span style="white-space:pre-wrap"> </span>(revision 221791)<br>+++ lib/Sema/SemaChecking.cpp<span style="white-space:pre-wrap"> </span>(working copy)<br>@@ -6480,6 +6480,13 @@<br> E->getType(), CC, &Suspicious);<br> }<br> <br></blockquote><div>Add comment to what this function is checking. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">+static void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC) {<br>+ if (S.getLangOpts().Bool)<br>+ return;<br>+ CheckImplicitConversion(S, E->IgnoreParenImpCasts(),<br>+ S.Context.BoolTy, CC);</blockquote><div>This should all fit on one line. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">+}<br>+<br> /// AnalyzeImplicitConversions - Find and report any interesting<br> /// implicit conversions in the given expression. There are a couple<br> /// of competing diagnostics here, -Wconversion and -Wsign-compare.<br>@@ -6532,6 +6539,11 @@<br> // And with simple assignments.<br> if (BO->getOpcode() == BO_Assign)<br> return AnalyzeAssignment(S, BO);<br>+ <br>+ if (BO->isLogicalOp()) {<br>+ CheckBoolLikeConversion(S, BO->getLHS(), BO->getLHS()->getExprLoc());<br>+ CheckBoolLikeConversion(S, BO->getRHS(), BO->getRHS()->getExprLoc());<br>+ }<br></blockquote><div>Move this down next to the UnaryOperator check. BO exists down there, so "if (BO && BO->isLogicalOp())" will work. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> }<br> <br> // These break the otherwise-useful invariant below. Fortunately,<br>@@ -6559,6 +6571,9 @@<br> continue;<br> AnalyzeImplicitConversions(S, ChildExpr, CC);<br> }<br>+ if (const UnaryOperator *U = dyn_cast<UnaryOperator>(E))<br>+ if (U->getOpcode() == UO_LNot)<br>+ CheckBoolLikeConversion(S, U->getSubExpr(), CC);<br> }<br> <br> } // end anonymous namespace<br>@@ -6617,6 +6632,10 @@<br> return false;<br> }<br> <br>+void Sema::CheckBoolLikeConversion(Expr *E, SourceLocation CC) {<br>+ ::CheckBoolLikeConversion(*this, E, CC);<br>+}<br></blockquote><div>Move this function next to the other CheckBoolLikeConversion </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">+<br> /// \brief Diagnose pointers that are always non-null.<br> /// \param E the expression containing the pointer<br> /// \param NullKind NPCK_NotNull if E is a cast to bool, otherwise, E is<br>Index: lib/Sema/SemaExpr.cpp<br>===================================================================<br>--- lib/Sema/SemaExpr.cpp<span style="white-space:pre-wrap"> </span>(revision 221791)<br>+++ lib/Sema/SemaExpr.cpp<span style="white-space:pre-wrap"> </span>(working copy)<br>@@ -8413,7 +8413,7 @@<br> if (!LHS.get()->getType()->isScalarType() ||<br> !RHS.get()->getType()->isScalarType())<br> return InvalidOperands(Loc, LHS, RHS);<br>-<br>+ <br></blockquote><div>Remove whitespace change. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"> return Context.IntTy;<br> }<br> <br>@@ -12982,6 +12982,7 @@<br> << T << E->getSourceRange();<br> return ExprError();<br> }<br>+ CheckBoolLikeConversion(E, Loc);<br> }<br> <br> return E;</blockquote><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 13, 2014 at 8:12 AM, jahanian <span dir="ltr"><<a href="mailto:fjahanian@apple.com" target="_blank">fjahanian@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">- PING.<br>
Thanks, Fariborz<br>
<span><br>
On Nov 12, 2014, at 9:11 AM, jahanian <<a href="mailto:fjahanian@apple.com" target="_blank">fjahanian@apple.com</a>> wrote:<br>
<br>
><br>
> Revised patch per Richard T’s comments. Please review.<br>
> - Fariborz<br>
><br>
</span>> <patch.txt>_______________________________________________<br>
<div>> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br>
</div></blockquote></div><br></div></div>
</blockquote></div><br></div></body></html>