[PATCH] D31501: [RFC] Integrate clang -cc1as diagnostics into DiagnosticsEngine

Sanne Wouda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 30 09:27:52 PDT 2017


sanwou01 created this revision.
Herald added a subscriber: aemerson.

Add initial support for printing assembly diagnostics using the
DiagnosticsEngine infrastructure.  Add support for -w (no warnings) and
-Werror (warnings are errors) and print a summary with the number of
errors and warnings. -fcolor-diagnostics handling is implemented as
well.

I am looking for feedback on the overall approach and suggestions for a
way to split it up into manageable pieces (if necessary).

---

The approach is to teach DiagnosticsEngine and underlying classes to
emit diagnostics using llvm::SMLocs.  Converting from llvm::SMLoc to
clang::SourceLocation (and the associated SourceManager and FileManager)
is quite infeasible.  With these changes in place, it will be relatively
easy to convert inline assembly diagnostics to this infrastructure as
well.

Unfortunately, there is still quite a lot of code duplication which I
hope to factor out (or leave as FIXMEs).  The plan is to leave the
emit*() functions as they are in this patch, but factor common bits into
private methods. Some of the diagnostics options handling has already
been factored out.

Currently missing is support for ranges and hits, but the assembly
diagnostics don't seem to generate many of those anyway.

Some examples with test.s:
	.thumb

    		ADD r0, r0, #0xFFFFF001
  		LDM r0, {r1, r0}

$ clang --target=arm-none-eabi -march=armv8-m.main -c test.s

test.s:2:12: error: invalid operand for instruction

  ADD r0,r0,#0xFFFFF001
            ^

test.s:3:14: warning: register list not in ascending order

  LDM r0, {r1, r0}
               ^

1 warning and 1 error generated.

$ clang --target=arm-none-eabi -march=armv8-m.main -c test.s -Werror

test.s:2:12: error: invalid operand for instruction

  ADD r0,r0,#0xFFFFF001
            ^

test.s:3:14: error: register list not in ascending order

  LDM r0, {r1, r0}
               ^

2 errors generated.

$ clang --target=arm-none-eabi -march=armv8-m.main -c test.s -w

test.s:2:12: error: invalid operand for instruction

  ADD r0,r0,#0xFFFFF001
            ^

1 error generated.


https://reviews.llvm.org/D31501

Files:
  include/clang/Basic/Diagnostic.h
  include/clang/Driver/Options.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CompilerInvocation.h
  include/clang/Frontend/DiagnosticRenderer.h
  include/clang/Frontend/TextDiagnostic.h
  lib/Driver/DriverOptions.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/DiagnosticRenderer.cpp
  lib/Frontend/TextDiagnostic.cpp
  lib/Frontend/TextDiagnosticPrinter.cpp
  tools/driver/cc1as_main.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31501.93493.patch
Type: text/x-patch
Size: 49756 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170330/24abdfc4/attachment-0001.bin>


More information about the cfe-commits mailing list