carlosgalvezp updated this revision to Diff 519633. carlosgalvezp edited the summary of this revision. carlosgalvezp added a comment.
Update commit message with Github issue. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D149899/new/ https://reviews.llvm.org/D149899 Files: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/test/clang-tidy/infrastructure/Inputs/system-headers/system_header.h clang-tools-extra/test/clang-tidy/infrastructure/system-headers.cpp clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp =================================================================== --- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp +++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp @@ -120,6 +120,7 @@ ExtraArgs: ['arg1', 'arg2'] ExtraArgsBefore: ['arg-before1', 'arg-before2'] UseColor: false + SystemHeaders: false )", "Options1")); ASSERT_TRUE(!!Options1); @@ -134,6 +135,7 @@ ExtraArgs: ['arg3', 'arg4'] ExtraArgsBefore: ['arg-before3', 'arg-before4'] UseColor: true + SystemHeaders: true )", "Options2")); ASSERT_TRUE(!!Options2); @@ -154,6 +156,9 @@ Options.ExtraArgsBefore->end(), ",")); ASSERT_TRUE(Options.UseColor.has_value()); EXPECT_TRUE(*Options.UseColor); + + ASSERT_TRUE(Options.SystemHeaders.has_value()); + EXPECT_TRUE(*Options.SystemHeaders); } namespace { @@ -249,6 +254,17 @@ DiagKind(llvm::SourceMgr::DK_Error), DiagPos(Options.range().Begin), DiagRange(Options.range())))); + + Options = llvm::Annotations(R"( + SystemHeaders: [[NotABool]] + )"); + ParsedOpt = ParseWithDiags(Options.code()); + EXPECT_TRUE(!ParsedOpt); + EXPECT_THAT(Collector.getDiags(), + testing::ElementsAre(AllOf(DiagMessage("invalid boolean"), + DiagKind(llvm::SourceMgr::DK_Error), + DiagPos(Options.range().Begin), + DiagRange(Options.range())))); } namespace { Index: clang-tools-extra/test/clang-tidy/infrastructure/system-headers.cpp =================================================================== --- /dev/null +++ clang-tools-extra/test/clang-tidy/infrastructure/system-headers.cpp @@ -0,0 +1,18 @@ +// RUN: clang-tidy -dump-config -system-headers=true | FileCheck -check-prefix=CHECK-CONFIG-SYSTEM-HEADERS %s +// RUN: clang-tidy -dump-config -system-headers=false | FileCheck -check-prefix=CHECK-CONFIG-NO-SYSTEM-HEADERS %s +// RUN: clang-tidy -config='SystemHeaders: true' -dump-config | FileCheck -check-prefix=CHECK-CONFIG-SYSTEM-HEADERS %s +// RUN: clang-tidy -config='SystemHeaders: false' -dump-config | FileCheck -check-prefix=CHECK-CONFIG-NO-SYSTEM-HEADERS %s +// RUN: clang-tidy -help | FileCheck -check-prefix=CHECK-OPT-PRESENT %s + +// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers=true %s -- -isystem %S/Inputs/system-headers 2>&1 | FileCheck -check-prefix=CHECK-SYSTEM-HEADERS %s +// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers=false %s -- -isystem %S/Inputs/system-headers 2>&1 | FileCheck -check-prefix=CHECK-NO-SYSTEM-HEADERS %s +// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -config='SystemHeaders: true' %s -- -isystem %S/Inputs/system-headers 2>&1 | FileCheck -check-prefix=CHECK-SYSTEM-HEADERS %s +// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -config='SystemHeaders: false' %s -- -isystem %S/Inputs/system-headers 2>&1 | FileCheck -check-prefix=CHECK-NO-SYSTEM-HEADERS %s + +#include <system_header.h> +// CHECK-SYSTEM-HEADERS: system_header.h:1:13: warning: single-argument constructors must be marked explicit +// CHECK-NO-SYSTEM-HEADERS-NOT: system_header.h:1:13: warning: single-argument constructors must be marked explicit + +// CHECK-CONFIG-NO-SYSTEM-HEADERS: SystemHeaders: false +// CHECK-CONFIG-SYSTEM-HEADERS: SystemHeaders: true +// CHECK-OPT-PRESENT: --system-headers Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/system-headers/system_header.h =================================================================== --- /dev/null +++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/system-headers/system_header.h @@ -0,0 +1 @@ +class Foo { Foo(int); }; Index: clang-tools-extra/docs/ReleaseNotes.rst =================================================================== --- clang-tools-extra/docs/ReleaseNotes.rst +++ clang-tools-extra/docs/ReleaseNotes.rst @@ -103,6 +103,9 @@ - Fix a potential crash when using the `--dump-config` option. +- Support specifying `SystemHeaders` in the `.clang-tidy` configuration file, + with the same functionality as the command-line option `--system-headers`. + New checks ^^^^^^^^^^ Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp =================================================================== --- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp +++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp @@ -172,6 +172,7 @@ IO.mapOptional("ExtraArgsBefore", Options.ExtraArgsBefore); IO.mapOptional("InheritParentConfig", Options.InheritParentConfig); IO.mapOptional("UseColor", Options.UseColor); + IO.mapOptional("SystemHeaders", Options.SystemHeaders); } };
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits