<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Sep 10, 2015 at 5:22 PM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron.ballman@gmail.com" target="_blank">aaron.ballman@gmail.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"><span class="">> ================<br>
> Comment at: clang-tidy/misc/SizeofContainerCheck.cpp:49<br>
> @@ +48,3 @@<br>
> +  SourceLocation SizeOfLoc = SizeOf->getLocStart();<br>
> +  auto Diag = diag(SizeOfLoc, "sizeof() doesn't return the size of the "<br>
> +                              "container. Did you mean .size()?");<br>
> ----------------<br>
> 1. Done.<br>
> 2. It's actually emitting the diagnostic. And I thought that the comment on line 52 below explains what happens in enough detail (`// Don't generate fixes for macros.`). If something is still unclear, can you explain what exactly?<br>
<br>
</span>It's not intuitive that creating the local variable actually emits the<br>
diagnostic, so it seems like you would be able to hoist the early<br>
return up above the local declaration when in fact that would remove<br>
the diagnostic entirely. The comment about generating fixes suggests<br>
an additional diagnostic, at least to me.<br></blockquote><div><br></div><div>This side effect of the diag() method is one of the core things in the clang-tidy API for checks. The same pattern is used with other Diag/diag methods in clang that produce various DiagnosticBuilders, and so far I didn't see problems with it being misleading. So it shouldn't need a comment at each usage, imho. May be a comment at the method definition needs to cover this aspect as well, if it doesn't. </div></div>
</div></div>