[PATCH] D147875: [clang][Diagnostics] Show line numbers when printing code snippets
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 4 13:48:34 PDT 2023
aaron.ballman added a subscriber: clang-vendors.
aaron.ballman added a comment.
This should definitely have explicit documentation added to https://github.com/llvm/llvm-project/blob/main/clang/docs/UsersManual.rst?plain=1#L156 and a release note.
Adding clang-vendors because of the potential that this is a breaking change for some folks doing diagnostic scraping; perhaps we should also mention this under potentially breaking changes in the release notes?
================
Comment at: clang/include/clang/Driver/Options.td:2544
+defm diagnostics_show_line_numbers : BoolFOption<"diagnostics-show-line-numbers",
+ DiagnosticOpts<"ShowLineNumbers">, DefaultTrue,
+ NegFlag<SetFalse, [CC1Option], "Show line numbers in diagnostic code snippest">,
----------------
I'm hopeful that defaulting this to true (which matches the GCC behavior) is reasonable, but I'm a bit worried about how downstreams will react to this. Specifically, I'm wondering about things like clang-cl integration in MSVC or clang use in Xcode, where diagnostics are being displayed other than on the command line.
================
Comment at: clang/test/FixIt/fixit-function-call.cpp:1
-// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2> %t
+// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 1 -x c++ %s 2> %t
// RUN: FileCheck %s < %t
----------------
Just to double-check, parseable diagnostic output still works even if line numbers are shown, yes?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147875/new/
https://reviews.llvm.org/D147875
More information about the cfe-commits
mailing list