Skip to content

Commit 6128bcd

Browse files
committed
[clang-tidy] Fix crash in --dump-config
Fixes a crash in dump-config when checks emit warnings trying to read the config Fixes #50876 Co-authored-by: Piotr Zegar <[email protected]> Reviewed By: PiotrZSL Differential Revision: https://reviews.llvm.org/D148436
1 parent ac1b6d4 commit 6128bcd

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

clang-tools-extra/clang-tidy/ClangTidy.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,11 @@ getCheckOptions(const ClangTidyOptions &Options,
498498
std::make_unique<DefaultOptionsProvider>(ClangTidyGlobalOptions(),
499499
Options),
500500
AllowEnablingAnalyzerAlphaCheckers);
501+
ClangTidyDiagnosticConsumer DiagConsumer(Context);
502+
DiagnosticsEngine DE(llvm::makeIntrusiveRefCnt<DiagnosticIDs>(),
503+
llvm::makeIntrusiveRefCnt<DiagnosticOptions>(),
504+
&DiagConsumer, /*ShouldOwnClient=*/false);
505+
Context.setDiagnosticsEngine(&DE);
501506
ClangTidyASTConsumerFactory Factory(Context);
502507
return Factory.getCheckOptions();
503508
}

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ Improvements to clang-tidy
101101
- Support specifying `Checks` as a YAML list in the `.clang-tidy` configuration
102102
file.
103103

104+
- Fix a potential crash when using the `--dump-config` option.
105+
104106
New checks
105107
^^^^^^^^^^
106108

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: clang-tidy --checks="-*,modernize-make-shared" \
2+
// RUN: --config="CheckOptions: [{ \
3+
// RUN: key: modernize-make-shared.IncludeStyle, value: '0' }]" \
4+
// RUN: --dump-config -- | FileCheck %s
5+
6+
// CHECK: modernize-make-shared.IncludeStyle: llvm

0 commit comments

Comments
 (0)