[all-commits] [llvm/llvm-project] 659f4b: [clang] Add an option for hiding line numbers in d...

Raphael Isemann via All-commits all-commits at lists.llvm.org
Thu Nov 5 07:11:19 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 659f4bd87efc7cae379aa128814e03fc8b006471
      https://github.com/llvm/llvm-project/commit/659f4bd87efc7cae379aa128814e03fc8b006471
  Author: Raphael Isemann <teemperor at gmail.com>
  Date:   2020-11-05 (Thu, 05 Nov 2020)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticOptions.def
    M clang/lib/Frontend/TextDiagnostic.cpp
    M clang/unittests/Frontend/CMakeLists.txt
    A clang/unittests/Frontend/TextDiagnosticTest.cpp

  Log Message:
  -----------
  [clang] Add an option for hiding line numbers in diagnostics

Clang offers a `-f[no]-show-column` flag for hiding the column numbers when
printing diagnostics but there is no option for doing the same with line
numbers.

In LLDB having this option would be useful, as LLDB sometimes only knows the
file name for a SourceLocation and just assigns it the dummy line/column `1:1`.
These fake line/column numbers are confusing to the user and LLDB should be able
to tell clang to hide *both* the column and the line number when rendering text
diagnostics.

This patch adds a flag for also hiding the line numbers. It's not exposed via
the command line flags as it's most likely not very useful for any user and can
lead to ambiguous output when the user decides to only hide either the line or
the column number (where `file:1: ...` could now refer to both line 1 or column
1 depending on the compiler flags). LLDB can just access the DiagnosticOptions
directly when constructing its internal Clang instance.

The effect doesn't apply to Vi/MSVC style diagnostics because it's not defined
how these diagnostic styles would show an omitted line number (MSVC doesn't have
such an option and Vi's line mode is theory only supporting line numbers if I
understand it correctly).

Reviewed By: thakis, MaskRay

Differential Revision: https://reviews.llvm.org/D83038




More information about the All-commits mailing list