]> granicus.if.org Git - clang/commitdiff
Convert inline asm source ranges into clang SourceRanges and print them with the...
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 16 Oct 2011 10:48:28 +0000 (10:48 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 16 Oct 2011 10:48:28 +0000 (10:48 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142131 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenAction.cpp

index 68dd5c94dc01fa5ce758e4283d24597b9fd8c8d9..11d6075582fe8b630f14f147bac8dae5e0fd3cc4 100644 (file)
@@ -215,8 +215,17 @@ void BackendConsumer::InlineAsmDiagHandler2(const llvm::SMDiagnostic &D,
   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;
   }