<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 16, 2019 at 9:56 PM Adam Nemet <<a href="mailto:anemet@apple.com">anemet@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><br><div><br><blockquote type="cite"><div>On Aug 16, 2019, at 8:17 PM, Paul Kirth <<a href="mailto:paulkirth@google.com" target="_blank">paulkirth@google.com</a>> wrote:</div><br><div><div dir="ltr"><div>I'm trying to get some insight into why source locations in a warning resolve differently when remarks are enabled in a cc1 invocation. </div><div><br></div><div>In a diagnostic handler I have two diagnostics being emitted(one warning and one remark), but the accuracy of the source location changes dramatically if I request remarks to be emitted through '-R<remark>'. Note that I don't mean the specific remark I'm emitting, I mean *any* remark.</div><div><br></div><div>More concretely, when I enable the warning and request no remarks, I get a source location that is the beginning of the function. However, if I enable any remarks(such as for the inliner pass), the source location becomes fully accurate for the warning(i.e. pointing to a branch location in the function body).</div></div></div></blockquote><div><br></div><div>Requesting remarks implies -gline-tables-only.</div><div><br></div></div></div></blockquote><div><br></div><div>Thanks for the clarification, that makes more sense. </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div><div></div><div>Adam</div><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>The invocations only differ in a small way:</div><div><br></div><div>clang -cc1 source.ll -Wmisexpect <... rest of invocation></div><div><br></div><div>vs.</div><div><br></div><div>clang -cc1 source.ll -Wmisexpect -R<anything> <... rest of invocation> </div><div><br></div><div>I ran into this when working on some tests in <a href="https://reviews.llvm.org/D66324" target="_blank">https://reviews.llvm.org/D66324</a>, and I'm having trouble understanding why this is happening. The same source location is passed to both diagnostics. This behavior also doesn't seem to appear if I don't use cc1 directly, but I would still like to understand this behavior.<br><br>Can someone explain why enabling remarks here has an effect on the accuracy of the source locations? Do they cause a delay in the source location resolution, or is there an important piece of infrastructure that the remarks framework enables that I've missed?<br><div></div></div><div><br></div><div>For reference my backend diagnostic handler looks something like the following snippet where the source location is passed to both the warning and remark:</div><div><br></div><div><div>```<br><div>void BackendConsumer::MisExpectDiagHandler(<br>    const llvm::DiagnosticInfoMisExpect &D) {<br>  StringRef Filename;<br>  unsigned Line, Column;<br>  bool BadDebugInfo = false;<br>  FullSourceLoc Loc =<br>      getBestLocationFromDebugLoc(D, BadDebugInfo, Filename, Line, Column);<br><br>  Diags.Report(Loc, diag::warn_misexpect) << D.getMsg().str();<br>  Diags.Report(Loc, diag::remark_misexpect) << D.getMsg().str();<br> </div><div>  // ...<br>}</div><div>```<br><div><br></div><div><br></div>-- <br><div dir="ltr"><div dir="ltr">Paul Kirth</div></div></div></div></div></div>
</div></blockquote></div><br></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Paul Kirth</div></div></div>