<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Aug 16, 2019, at 8:17 PM, Paul Kirth <<a href="mailto:paulkirth@google.com" class="">paulkirth@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">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 class=""></div><div>Requesting remarks implies -gline-tables-only.</div><div><br class=""></div><div>Adam</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">The invocations only differ in a small way:</div><div class=""><br class=""></div><div class="">clang -cc1 source.ll -Wmisexpect <... rest of invocation></div><div class=""><br class=""></div><div class="">vs.</div><div class=""><br class=""></div><div class="">clang -cc1 source.ll -Wmisexpect -R<anything> <... rest of invocation> </div><div class=""><br class=""></div><div class="">I ran into this when working on some tests in <a href="https://reviews.llvm.org/D66324" class="">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 class=""><br class="">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 class=""><div class=""></div></div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class=""><div class="">```<br class=""><div class="">void BackendConsumer::MisExpectDiagHandler(<br class=""> const llvm::DiagnosticInfoMisExpect &D) {<br class=""> StringRef Filename;<br class=""> unsigned Line, Column;<br class=""> bool BadDebugInfo = false;<br class=""> FullSourceLoc Loc =<br class=""> getBestLocationFromDebugLoc(D, BadDebugInfo, Filename, Line, Column);<br class=""><br class=""> Diags.Report(Loc, diag::warn_misexpect) << D.getMsg().str();<br class=""> Diags.Report(Loc, diag::remark_misexpect) << D.getMsg().str();<br class=""> </div><div class=""> // ...<br class="">}</div><div class="">```<br class=""><div class=""><br class=""></div><div class=""><br class=""></div>-- <br class=""><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class="">Paul Kirth</div></div></div></div></div></div>
</div></blockquote></div><br class=""></body></html>