Author: Nathan James Date: 2023-04-15T22:58:17+01:00 New Revision: 6128bcd02512eeb0e0bbb8b0a9c4d82f6f9427b2
URL: https://github.com/llvm/llvm-project/commit/6128bcd02512eeb0e0bbb8b0a9c4d82f6f9427b2 DIFF: https://github.com/llvm/llvm-project/commit/6128bcd02512eeb0e0bbb8b0a9c4d82f6f9427b2.diff LOG: [clang-tidy] Fix crash in --dump-config Fixes a crash in dump-config when checks emit warnings trying to read the config Fixes https://github.com/llvm/llvm-project/issues/50876 Co-authored-by: Piotr Zegar <m...@piotrzegar.pl> Reviewed By: PiotrZSL Differential Revision: https://reviews.llvm.org/D148436 Added: clang-tools-extra/test/clang-tidy/infrastructure/dump-config-invalid.cpp Modified: clang-tools-extra/clang-tidy/ClangTidy.cpp clang-tools-extra/docs/ReleaseNotes.rst Removed: ################################################################################ diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp index 7382bf4497b0..445d268cee5d 100644 --- a/clang-tools-extra/clang-tidy/ClangTidy.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp @@ -498,6 +498,11 @@ getCheckOptions(const ClangTidyOptions &Options, std::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(), Options), AllowEnablingAnalyzerAlphaCheckers); + ClangTidyDiagnosticConsumer DiagConsumer(Context); + DiagnosticsEngine DE(llvm::makeIntrusiveRefCnt<DiagnosticIDs>(), + llvm::makeIntrusiveRefCnt<DiagnosticOptions>(), + &DiagConsumer, /*ShouldOwnClient=*/false); + Context.setDiagnosticsEngine(&DE); ClangTidyASTConsumerFactory Factory(Context); return Factory.getCheckOptions(); } diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 55474e1d9bd7..c19636b95c55 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -101,6 +101,8 @@ Improvements to clang-tidy - Support specifying `Checks` as a YAML list in the `.clang-tidy` configuration file. +- Fix a potential crash when using the `--dump-config` option. + New checks ^^^^^^^^^^ diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/dump-config-invalid.cpp b/clang-tools-extra/test/clang-tidy/infrastructure/dump-config-invalid.cpp new file mode 100644 index 000000000000..eba40b8d6118 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/infrastructure/dump-config-invalid.cpp @@ -0,0 +1,6 @@ +// RUN: clang-tidy --checks="-*,modernize-make-shared" \ +// RUN: --config="CheckOptions: [{ \ +// RUN: key: modernize-make-shared.IncludeStyle, value: '0' }]" \ +// RUN: --dump-config -- | FileCheck %s + +// CHECK: modernize-make-shared.IncludeStyle: llvm _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits