On Oct 16, 2011, at 3:48 AM, Benjamin Kramer wrote: > Author: d0k > Date: Sun Oct 16 05:48:28 2011 > New Revision: 142131 > > URL: http://llvm.org/viewvc/llvm-project?rev=142131&view=rev > Log: > Convert inline asm source ranges into clang SourceRanges and print them with > the instantiated note. > > t.c:2:7: error: invalid operand for instruction > asm("movl 0(%rax), 0(%edx)"); > ^ > <inline asm>:1:16: note: instantiated into assembly here > movl 0(%rax), 0(%edx) > ^~~~~~~ > 1 error generated.
Very nice!! -Chris > > Modified: > cfe/trunk/lib/CodeGen/CodeGenAction.cpp > > Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=142131&r1=142130&r2=142131&view=diff > ============================================================================== > --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original) > +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Sun Oct 16 05:48:28 2011 > @@ -215,8 +215,17 @@ > if (LocCookie.isValid()) { > Diags.Report(LocCookie, diag::err_fe_inline_asm).AddString(Message); > > - if (D.getLoc().isValid()) > - Diags.Report(Loc, diag::note_fe_inline_asm_here); > + if (D.getLoc().isValid()) { > + DiagnosticBuilder B = Diags.Report(Loc, diag::note_fe_inline_asm_here); > + // Convert the SMDiagnostic ranges into SourceRange and attach them > + // to the diagnostic. > + for (unsigned i = 0, e = D.getRanges().size(); i != e; ++i) { > + std::pair<unsigned, unsigned> Range = D.getRanges()[i]; > + unsigned Column = D.getColumnNo(); > + B << SourceRange(Loc.getLocWithOffset(Range.first - Column), > + Loc.getLocWithOffset(Range.second - Column)); > + } > + } > return; > } > > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
