leanil updated this revision to Diff 120597.
leanil added a comment.

> Make clang-diagnostic-* checks first-class citizens and take full control of 
> all diagnostics, i.e. disable all Clang diagnostics by default, and enable 
> the ones that correspond to the enabled clang-diagnostic checks.

(As @alexfh suggested.)

Collecting all the diagnostics seems to be possible from multiple sources, I've 
decided to make `DiagnosticIDs::getAllDiagnostics` static.
I also had to replace explicit -W arguments with the new checks in some of the 
tests.


https://reviews.llvm.org/D38171

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tidy/ClangTidyModule.h
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/tool/ClangTidyMain.cpp
  test/clang-tidy/cert-exp59-cpp.cpp
  test/clang-tidy/custom-diagnostics.cpp
  test/clang-tidy/diagnostic.cpp
  test/clang-tidy/list-clang-diagnostics.cpp
  test/clang-tidy/misc-suspicious-semicolon-fail.cpp
  test/clang-tidy/validate-check-names.cpp
  test/clang-tidy/warning-check-aliases.cpp
  test/clang-tidy/werrors-diagnostics.cpp

Index: test/clang-tidy/werrors-diagnostics.cpp
===================================================================
--- test/clang-tidy/werrors-diagnostics.cpp
+++ test/clang-tidy/werrors-diagnostics.cpp
@@ -1,11 +1,10 @@
-// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
-// RUN:   -- -Wunused-variable 2>&1 \
+// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic-unused-variable' -- 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-WARN -implicit-check-not='{{warning|error}}:'
-// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
-// RUN:   -warnings-as-errors='clang-diagnostic*' -- -Wunused-variable 2>&1 \
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic-unused-variable' \
+// RUN:   -warnings-as-errors='clang-diagnostic*' -- 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-WERR -implicit-check-not='{{warning|error}}:'
-// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
-// RUN:   -warnings-as-errors='clang-diagnostic*' -quiet -- -Wunused-variable 2>&1 \
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic-unused-variable' \
+// RUN:   -warnings-as-errors='clang-diagnostic*' -quiet -- 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-WERR-QUIET -implicit-check-not='{{warning|error}}:'
 
 void f() { int i; }
Index: test/clang-tidy/warning-check-aliases.cpp
===================================================================
--- /dev/null
+++ test/clang-tidy/warning-check-aliases.cpp
@@ -0,0 +1,21 @@
+// RUN: clang-tidy %s -checks='-*,clang-diagnostic-exceptions' -- 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy %s -checks='-*,cert-err54-cpp' -- 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK2 %s
+// RUN: clang-tidy %s -- 2>&1 | FileCheck -allow-empty -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK3 %s
+
+class B {};
+class D : public B {};
+
+void f() {
+  try {
+
+  } catch (B &X) {
+
+  } catch (D &Y) {
+  }
+}
+
+//CHECK: :13:12: warning: exception of type 'D &' will be caught by earlier handler [clang-diagnostic-exceptions]
+//CHECK: :11:12: note: for type 'B &'
+
+//CHECK2: :13:12: warning: exception of type 'D &' will be caught by earlier handler [cert-err54-cpp]
+//CHECK2: :11:12: note: for type 'B &'
Index: test/clang-tidy/validate-check-names.cpp
===================================================================
--- test/clang-tidy/validate-check-names.cpp
+++ test/clang-tidy/validate-check-names.cpp
@@ -1,2 +1,2 @@
 // Check names may only contain alphanumeric characters, '-', '_', and '.'.
-// RUN: clang-tidy -checks=* -list-checks | grep '^    ' | cut -b5- | not grep -v '^[a-zA-Z0-9_.\-]\+$'
+// RUN: clang-tidy -checks=*,-clang-diagnostic* -list-checks | grep '^    ' | cut -b5- | not grep -v '^[a-zA-Z0-9_.\-]\+$'
Index: test/clang-tidy/misc-suspicious-semicolon-fail.cpp
===================================================================
--- test/clang-tidy/misc-suspicious-semicolon-fail.cpp
+++ test/clang-tidy/misc-suspicious-semicolon-fail.cpp
@@ -1,8 +1,8 @@
 // RUN: clang-tidy %s -checks="-*,misc-suspicious-semicolon" -- -DERROR 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-ERROR \
 // RUN:       -implicit-check-not="{{warning|error}}:"
-// RUN: clang-tidy %s -checks="-*,misc-suspicious-semicolon,clang-diagnostic*" \
-// RUN:    -- -DWERROR -Wno-everything -Werror=unused-variable 2>&1 \
+// RUN: not clang-tidy %s -checks="-*,misc-suspicious-semicolon,clang-diagnostic-unused-variable" \
+// RUN:   -warnings-as-errors=clang-diagnostic-unused-variable -- -DWERROR 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-WERROR \
 // RUN:       -implicit-check-not="{{warning|error}}:"
 
@@ -19,7 +19,7 @@
   // CHECK-ERROR: :[[@LINE-1]]:8: error: expected ';' at end of declaration [clang-diagnostic-error]
 #elif WERROR
   int a;
-  // CHECK-WERROR: :[[@LINE-1]]:7: error: unused variable 'a' [clang-diagnostic-unused-variable]
+  // CHECK-WERROR: :[[@LINE-1]]:7: error: unused variable 'a' [clang-diagnostic-unused-variable,-warnings-as-errors]
 #else
 #error "One of ERROR or WERROR should be defined.
 #endif
Index: test/clang-tidy/list-clang-diagnostics.cpp
===================================================================
--- /dev/null
+++ test/clang-tidy/list-clang-diagnostics.cpp
@@ -0,0 +1,614 @@
+// RUN: clang-tidy -checks='-*,clang-diagnostic-*' -list-checks 2>&1 | FileCheck -match-full-lines -implicit-check-not='{{.}}' %s
+// CHECK: Enabled checks:
+// CHECK: clang-diagnostic-#pragma-messages
+// CHECK: clang-diagnostic-#warnings
+// CHECK: clang-diagnostic-CFString-literal
+// CHECK: clang-diagnostic-IndependentClass-attribute
+// CHECK: clang-diagnostic-NSObject-attribute
+// CHECK: clang-diagnostic-absolute-value
+// CHECK: clang-diagnostic-abstract-final-class
+// CHECK: clang-diagnostic-abstract-vbase-init
+// CHECK: clang-diagnostic-address-of-array-temporary
+// CHECK: clang-diagnostic-address-of-packed-member
+// CHECK: clang-diagnostic-address-of-temporary
+// CHECK: clang-diagnostic-aligned-allocation-unavailable
+// CHECK: clang-diagnostic-alloca-with-align-alignof
+// CHECK: clang-diagnostic-ambiguous-delete
+// CHECK: clang-diagnostic-ambiguous-ellipsis
+// CHECK: clang-diagnostic-ambiguous-macro
+// CHECK: clang-diagnostic-ambiguous-member-template
+// CHECK: clang-diagnostic-analyzer-incompatible-plugin
+// CHECK: clang-diagnostic-anonymous-pack-parens
+// CHECK: clang-diagnostic-arc-bridge-casts-disallowed-in-nonarc
+// CHECK: clang-diagnostic-arc-maybe-repeated-use-of-weak
+// CHECK: clang-diagnostic-arc-non-pod-memaccess
+// CHECK: clang-diagnostic-arc-performSelector-leaks
+// CHECK: clang-diagnostic-arc-repeated-use-of-weak
+// CHECK: clang-diagnostic-arc-retain-cycles
+// CHECK: clang-diagnostic-arc-unsafe-retained-assign
+// CHECK: clang-diagnostic-array-bounds
+// CHECK: clang-diagnostic-array-bounds-pointer-arithmetic
+// CHECK: clang-diagnostic-asm-ignored-qualifier
+// CHECK: clang-diagnostic-asm-operand-widths
+// CHECK: clang-diagnostic-assign-enum
+// CHECK: clang-diagnostic-assume
+// CHECK: clang-diagnostic-at-protocol
+// CHECK: clang-diagnostic-atomic-memory-ordering
+// CHECK: clang-diagnostic-atomic-property-with-user-defined-accessor
+// CHECK: clang-diagnostic-attribute-packed-for-bitfield
+// CHECK: clang-diagnostic-auto-disable-vptr-sanitizer
+// CHECK: clang-diagnostic-auto-import
+// CHECK: clang-diagnostic-auto-storage-class
+// CHECK: clang-diagnostic-auto-var-id
+// CHECK: clang-diagnostic-availability
+// CHECK: clang-diagnostic-backend-plugin
+// CHECK: clang-diagnostic-backslash-newline-escape
+// CHECK: clang-diagnostic-bad-function-cast
+// CHECK: clang-diagnostic-bind-to-temporary-copy
+// CHECK: clang-diagnostic-bitfield-constant-conversion
+// CHECK: clang-diagnostic-bitfield-enum-conversion
+// CHECK: clang-diagnostic-bitfield-width
+// CHECK: clang-diagnostic-bitwise-op-parentheses
+// CHECK: clang-diagnostic-block-capture-autoreleasing
+// CHECK: clang-diagnostic-bool-conversion
+// CHECK: clang-diagnostic-braced-scalar-init
+// CHECK: clang-diagnostic-bridge-cast
+// CHECK: clang-diagnostic-builtin-macro-redefined
+// CHECK: clang-diagnostic-builtin-memcpy-chk-size
+// CHECK: clang-diagnostic-builtin-requires-header
+// CHECK: clang-diagnostic-c++-compat
+// CHECK: clang-diagnostic-c++11-compat
+// CHECK: clang-diagnostic-c++11-compat-deprecated-writable-strings
+// CHECK: clang-diagnostic-c++11-compat-reserved-user-defined-literal
+// CHECK: clang-diagnostic-c++11-extensions
+// CHECK: clang-diagnostic-c++11-extra-semi
+// CHECK: clang-diagnostic-c++11-inline-namespace
+// CHECK: clang-diagnostic-c++11-long-long
+// CHECK: clang-diagnostic-c++11-narrowing
+// CHECK: clang-diagnostic-c++14-binary-literal
+// CHECK: clang-diagnostic-c++14-extensions
+// CHECK: clang-diagnostic-c++17-compat-mangling
+// CHECK: clang-diagnostic-c++17-extensions
+// CHECK: clang-diagnostic-c++2a-compat
+// CHECK: clang-diagnostic-c++2a-extensions
+// CHECK: clang-diagnostic-c++98-c++11-c++14-c++17-compat
+// CHECK: clang-diagnostic-c++98-c++11-c++14-c++17-compat-pedantic
+// CHECK: clang-diagnostic-c++98-c++11-c++14-compat
+// CHECK: clang-diagnostic-c++98-c++11-c++14-compat-pedantic
+// CHECK: clang-diagnostic-c++98-c++11-compat
+// CHECK: clang-diagnostic-c++98-c++11-compat-pedantic
+// CHECK: clang-diagnostic-c++98-compat
+// CHECK: clang-diagnostic-c++98-compat-bind-to-temporary-copy
+// CHECK: clang-diagnostic-c++98-compat-local-type-template-args
+// CHECK: clang-diagnostic-c++98-compat-pedantic
+// CHECK: clang-diagnostic-c++98-compat-unnamed-type-template-args
+// CHECK: clang-diagnostic-c11-extensions
+// CHECK: clang-diagnostic-c99-compat
+// CHECK: clang-diagnostic-c99-extensions
+// CHECK: clang-diagnostic-cast-align
+// CHECK: clang-diagnostic-cast-calling-convention
+// CHECK: clang-diagnostic-cast-of-sel-type
+// CHECK: clang-diagnostic-cast-qual
+// CHECK: clang-diagnostic-char-subscripts
+// CHECK: clang-diagnostic-clang-cl-pch
+// CHECK: clang-diagnostic-class-varargs
+// CHECK: clang-diagnostic-comma
+// CHECK: clang-diagnostic-comment
+// CHECK: clang-diagnostic-compare-distinct-pointer-types
+// CHECK: clang-diagnostic-complex-component-init
+// CHECK: clang-diagnostic-conditional-type-mismatch
+// CHECK: clang-diagnostic-conditional-uninitialized
+// CHECK: clang-diagnostic-config-macros
+// CHECK: clang-diagnostic-constant-conversion
+// CHECK: clang-diagnostic-constant-logical-operand
+// CHECK: clang-diagnostic-constexpr-not-const
+// CHECK: clang-diagnostic-consumed
+// CHECK: clang-diagnostic-conversion
+// CHECK: clang-diagnostic-coroutine-missing-unhandled-exception
+// CHECK: clang-diagnostic-covered-switch-default
+// CHECK: clang-diagnostic-cstring-format-directive
+// CHECK: clang-diagnostic-cuda-compat
+// CHECK: clang-diagnostic-custom-atomic-properties
+// CHECK: clang-diagnostic-dangling-else
+// CHECK: clang-diagnostic-dangling-field
+// CHECK: clang-diagnostic-dangling-initializer-list
+// CHECK: clang-diagnostic-date-time
+// CHECK: clang-diagnostic-dealloc-in-category
+// CHECK: clang-diagnostic-debug-compression-unavailable
+// CHECK: clang-diagnostic-declaration-after-statement
+// CHECK: clang-diagnostic-delegating-ctor-cycles
+// CHECK: clang-diagnostic-delete-incomplete
+// CHECK: clang-diagnostic-delete-non-virtual-dtor
+// CHECK: clang-diagnostic-deprecated
+// CHECK: clang-diagnostic-deprecated-attributes
+// CHECK: clang-diagnostic-deprecated-declarations
+// CHECK: clang-diagnostic-deprecated-dynamic-exception-spec
+// CHECK: clang-diagnostic-deprecated-implementations
+// CHECK: clang-diagnostic-deprecated-increment-bool
+// CHECK: clang-diagnostic-deprecated-objc-isa-usage
+// CHECK: clang-diagnostic-deprecated-objc-pointer-introspection
+// CHECK: clang-diagnostic-deprecated-objc-pointer-introspection-performSelector
+// CHECK: clang-diagnostic-deprecated-register
+// CHECK: clang-diagnostic-direct-ivar-access
+// CHECK: clang-diagnostic-disabled-macro-expansion
+// CHECK: clang-diagnostic-distributed-object-modifiers
+// CHECK: clang-diagnostic-division-by-zero
+// CHECK: clang-diagnostic-dll-attribute-on-redeclaration
+// CHECK: clang-diagnostic-dllexport-explicit-instantiation-decl
+// CHECK: clang-diagnostic-dllimport-static-field-def
+// CHECK: clang-diagnostic-documentation
+// CHECK: clang-diagnostic-documentation-deprecated-sync
+// CHECK: clang-diagnostic-documentation-html
+// CHECK: clang-diagnostic-documentation-pedantic
+// CHECK: clang-diagnostic-documentation-unknown-command
+// CHECK: clang-diagnostic-dollar-in-identifier-extension
+// CHECK: clang-diagnostic-double-promotion
+// CHECK: clang-diagnostic-duplicate-decl-specifier
+// CHECK: clang-diagnostic-duplicate-enum
+// CHECK: clang-diagnostic-duplicate-method-arg
+// CHECK: clang-diagnostic-duplicate-method-match
+// CHECK: clang-diagnostic-duplicate-protocol
+// CHECK: clang-diagnostic-dynamic-class-memaccess
+// CHECK: clang-diagnostic-dynamic-exception-spec
+// CHECK: clang-diagnostic-embedded-directive
+// CHECK: clang-diagnostic-empty-body
+// CHECK: clang-diagnostic-empty-decomposition
+// CHECK: clang-diagnostic-empty-translation-unit
+// CHECK: clang-diagnostic-encode-type
+// CHECK: clang-diagnostic-enum-compare
+// CHECK: clang-diagnostic-enum-compare-switch
+// CHECK: clang-diagnostic-enum-conversion
+// CHECK: clang-diagnostic-enum-too-large
+// CHECK: clang-diagnostic-exceptions
+// CHECK: clang-diagnostic-exit-time-destructors
+// CHECK: clang-diagnostic-expansion-to-defined
+// CHECK: clang-diagnostic-explicit-initialize-call
+// CHECK: clang-diagnostic-explicit-ownership-type
+// CHECK: clang-diagnostic-extended-offsetof
+// CHECK: clang-diagnostic-extern-c-compat
+// CHECK: clang-diagnostic-extern-initializer
+// CHECK: clang-diagnostic-extra
+// CHECK: clang-diagnostic-extra-qualification
+// CHECK: clang-diagnostic-extra-semi
+// CHECK: clang-diagnostic-extra-tokens
+// CHECK: clang-diagnostic-fallback
+// CHECK: clang-diagnostic-flag-enum
+// CHECK: clang-diagnostic-flexible-array-extensions
+// CHECK: clang-diagnostic-float-conversion
+// CHECK: clang-diagnostic-float-equal
+// CHECK: clang-diagnostic-float-overflow-conversion
+// CHECK: clang-diagnostic-float-zero-conversion
+// CHECK: clang-diagnostic-for-loop-analysis
+// CHECK: clang-diagnostic-format
+// CHECK: clang-diagnostic-format-extra-args
+// CHECK: clang-diagnostic-format-invalid-specifier
+// CHECK: clang-diagnostic-format-non-iso
+// CHECK: clang-diagnostic-format-nonliteral
+// CHECK: clang-diagnostic-format-pedantic
+// CHECK: clang-diagnostic-format-security
+// CHECK: clang-diagnostic-format-zero-length
+// CHECK: clang-diagnostic-four-char-constants
+// CHECK: clang-diagnostic-frame-larger-than=
+// CHECK: clang-diagnostic-function-def-in-objc-container
+// CHECK: clang-diagnostic-gcc-compat
+// CHECK: clang-diagnostic-global-constructors
+// CHECK: clang-diagnostic-gnu-alignof-expression
+// CHECK: clang-diagnostic-gnu-anonymous-struct
+// CHECK: clang-diagnostic-gnu-array-member-paren-init
+// CHECK: clang-diagnostic-gnu-auto-type
+// CHECK: clang-diagnostic-gnu-binary-literal
+// CHECK: clang-diagnostic-gnu-case-range
+// CHECK: clang-diagnostic-gnu-complex-integer
+// CHECK: clang-diagnostic-gnu-compound-literal-initializer
+// CHECK: clang-diagnostic-gnu-conditional-omitted-operand
+// CHECK: clang-diagnostic-gnu-designator
+// CHECK: clang-diagnostic-gnu-empty-initializer
+// CHECK: clang-diagnostic-gnu-empty-struct
+// CHECK: clang-diagnostic-gnu-flexible-array-initializer
+// CHECK: clang-diagnostic-gnu-flexible-array-union-member
+// CHECK: clang-diagnostic-gnu-folding-constant
+// CHECK: clang-diagnostic-gnu-imaginary-constant
+// CHECK: clang-diagnostic-gnu-include-next
+// CHECK: clang-diagnostic-gnu-label-as-value
+// CHECK: clang-diagnostic-gnu-redeclared-enum
+// CHECK: clang-diagnostic-gnu-statement-expression
+// CHECK: clang-diagnostic-gnu-static-float-init
+// CHECK: clang-diagnostic-gnu-string-literal-operator-template
+// CHECK: clang-diagnostic-gnu-union-cast
+// CHECK: clang-diagnostic-gnu-variable-sized-type-not-at-end
+// CHECK: clang-diagnostic-gnu-zero-line-directive
+// CHECK: clang-diagnostic-gnu-zero-variadic-macro-arguments
+// CHECK: clang-diagnostic-header-guard
+// CHECK: clang-diagnostic-header-hygiene
+// CHECK: clang-diagnostic-idiomatic-parentheses
+// CHECK: clang-diagnostic-ignored-attributes
+// CHECK: clang-diagnostic-ignored-optimization-argument
+// CHECK: clang-diagnostic-ignored-pragma-intrinsic
+// CHECK: clang-diagnostic-ignored-pragmas
+// CHECK: clang-diagnostic-ignored-qualifiers
+// CHECK: clang-diagnostic-implicit-atomic-properties
+// CHECK: clang-diagnostic-implicit-conversion-floating-point-to-bool
+// CHECK: clang-diagnostic-implicit-exception-spec-mismatch
+// CHECK: clang-diagnostic-implicit-fallthrough
+// CHECK: clang-diagnostic-implicit-fallthrough-per-function
+// CHECK: clang-diagnostic-implicit-function-declaration
+// CHECK: clang-diagnostic-implicit-int
+// CHECK: clang-diagnostic-implicit-retain-self
+// CHECK: clang-diagnostic-implicitly-unsigned-literal
+// CHECK: clang-diagnostic-import-preprocessor-directive-pedantic
+// CHECK: clang-diagnostic-inaccessible-base
+// CHECK: clang-diagnostic-include-next-absolute-path
+// CHECK: clang-diagnostic-include-next-outside-header
+// CHECK: clang-diagnostic-incompatible-exception-spec
+// CHECK: clang-diagnostic-incompatible-function-pointer-types
+// CHECK: clang-diagnostic-incompatible-library-redeclaration
+// CHECK: clang-diagnostic-incompatible-ms-struct
+// CHECK: clang-diagnostic-incompatible-pointer-types
+// CHECK: clang-diagnostic-incompatible-pointer-types-discards-qualifiers
+// CHECK: clang-diagnostic-incompatible-property-type
+// CHECK: clang-diagnostic-incompatible-sysroot
+// CHECK: clang-diagnostic-incomplete-implementation
+// CHECK: clang-diagnostic-incomplete-umbrella
+// CHECK: clang-diagnostic-inconsistent-dllimport
+// CHECK: clang-diagnostic-inconsistent-missing-destructor-override
+// CHECK: clang-diagnostic-inconsistent-missing-override
+// CHECK: clang-diagnostic-increment-bool
+// CHECK: clang-diagnostic-infinite-recursion
+// CHECK: clang-diagnostic-initializer-overrides
+// CHECK: clang-diagnostic-injected-class-name
+// CHECK: clang-diagnostic-inline-asm
+// CHECK: clang-diagnostic-inline-new-delete
+// CHECK: clang-diagnostic-instantiation-after-specialization
+// CHECK: clang-diagnostic-int-conversion
+// CHECK: clang-diagnostic-int-to-pointer-cast
+// CHECK: clang-diagnostic-int-to-void-pointer-cast
+// CHECK: clang-diagnostic-integer-overflow
+// CHECK: clang-diagnostic-invalid-command-line-argument
+// CHECK: clang-diagnostic-invalid-constexpr
+// CHECK: clang-diagnostic-invalid-iboutlet
+// CHECK: clang-diagnostic-invalid-initializer-from-system-header
+// CHECK: clang-diagnostic-invalid-ios-deployment-target
+// CHECK: clang-diagnostic-invalid-noreturn
+// CHECK: clang-diagnostic-invalid-offsetof
+// CHECK: clang-diagnostic-invalid-or-nonexistent-directory
+// CHECK: clang-diagnostic-invalid-partial-specialization
+// CHECK: clang-diagnostic-invalid-pp-token
+// CHECK: clang-diagnostic-invalid-source-encoding
+// CHECK: clang-diagnostic-invalid-token-paste
+// CHECK: clang-diagnostic-jump-seh-finally
+// CHECK: clang-diagnostic-keyword-compat
+// CHECK: clang-diagnostic-keyword-macro
+// CHECK: clang-diagnostic-knr-promoted-parameter
+// CHECK: clang-diagnostic-language-extension-token
+// CHECK: clang-diagnostic-large-by-value-copy
+// CHECK: clang-diagnostic-literal-conversion
+// CHECK: clang-diagnostic-literal-range
+// CHECK: clang-diagnostic-local-type-template-args
+// CHECK: clang-diagnostic-logical-not-parentheses
+// CHECK: clang-diagnostic-logical-op-parentheses
+// CHECK: clang-diagnostic-long-long
+// CHECK: clang-diagnostic-macro-redefined
+// CHECK: clang-diagnostic-main
+// CHECK: clang-diagnostic-main-return-type
+// CHECK: clang-diagnostic-malformed-warning-check
+// CHECK: clang-diagnostic-many-braces-around-scalar-init
+// CHECK: clang-diagnostic-max-unsigned-zero
+// CHECK: clang-diagnostic-memsize-comparison
+// CHECK: clang-diagnostic-method-signatures
+// CHECK: clang-diagnostic-microsoft-anon-tag
+// CHECK: clang-diagnostic-microsoft-cast
+// CHECK: clang-diagnostic-microsoft-charize
+// CHECK: clang-diagnostic-microsoft-comment-paste
+// CHECK: clang-diagnostic-microsoft-const-init
+// CHECK: clang-diagnostic-microsoft-cpp-macro
+// CHECK: clang-diagnostic-microsoft-default-arg-redefinition
+// CHECK: clang-diagnostic-microsoft-end-of-file
+// CHECK: clang-diagnostic-microsoft-enum-forward-reference
+// CHECK: clang-diagnostic-microsoft-enum-value
+// CHECK: clang-diagnostic-microsoft-exception-spec
+// CHECK: clang-diagnostic-microsoft-exists
+// CHECK: clang-diagnostic-microsoft-explicit-constructor-call
+// CHECK: clang-diagnostic-microsoft-extra-qualification
+// CHECK: clang-diagnostic-microsoft-fixed-enum
+// CHECK: clang-diagnostic-microsoft-flexible-array
+// CHECK: clang-diagnostic-microsoft-goto
+// CHECK: clang-diagnostic-microsoft-include
+// CHECK: clang-diagnostic-microsoft-mutable-reference
+// CHECK: clang-diagnostic-microsoft-pure-definition
+// CHECK: clang-diagnostic-microsoft-redeclare-static
+// CHECK: clang-diagnostic-microsoft-sealed
+// CHECK: clang-diagnostic-microsoft-template
+// CHECK: clang-diagnostic-microsoft-union-member-reference
+// CHECK: clang-diagnostic-microsoft-unqualified-friend
+// CHECK: clang-diagnostic-microsoft-using-decl
+// CHECK: clang-diagnostic-microsoft-void-pseudo-dtor
+// CHECK: clang-diagnostic-mismatched-new-delete
+// CHECK: clang-diagnostic-mismatched-parameter-types
+// CHECK: clang-diagnostic-mismatched-return-types
+// CHECK: clang-diagnostic-mismatched-tags
+// CHECK: clang-diagnostic-missing-braces
+// CHECK: clang-diagnostic-missing-declarations
+// CHECK: clang-diagnostic-missing-exception-spec
+// CHECK: clang-diagnostic-missing-field-initializers
+// CHECK: clang-diagnostic-missing-method-return-type
+// CHECK: clang-diagnostic-missing-noescape
+// CHECK: clang-diagnostic-missing-noreturn
+// CHECK: clang-diagnostic-missing-prototype-for-cc
+// CHECK: clang-diagnostic-missing-prototypes
+// CHECK: clang-diagnostic-missing-selector-name
+// CHECK: clang-diagnostic-missing-sysroot
+// CHECK: clang-diagnostic-missing-variable-declarations
+// CHECK: clang-diagnostic-module-conflict
+// CHECK: clang-diagnostic-module-file-config-mismatch
+// CHECK: clang-diagnostic-module-file-extension
+// CHECK: clang-diagnostic-module-import-in-extern-c
+// CHECK: clang-diagnostic-modules-ambiguous-internal-linkage
+// CHECK: clang-diagnostic-modules-import-nested-redundant
+// CHECK: clang-diagnostic-msvc-not-found
+// CHECK: clang-diagnostic-multichar
+// CHECK: clang-diagnostic-multiple-move-vbase
+// CHECK: clang-diagnostic-nested-anon-types
+// CHECK: clang-diagnostic-new-returns-null
+// CHECK: clang-diagnostic-newline-eof
+// CHECK: clang-diagnostic-non-literal-null-conversion
+// CHECK: clang-diagnostic-non-modular-include-in-framework-module
+// CHECK: clang-diagnostic-non-modular-include-in-module
+// CHECK: clang-diagnostic-non-pod-varargs
+// CHECK: clang-diagnostic-non-virtual-dtor
+// CHECK: clang-diagnostic-nonnull
+// CHECK: clang-diagnostic-nonportable-include-path
+// CHECK: clang-diagnostic-nonportable-system-include-path
+// CHECK: clang-diagnostic-nonportable-vector-initialization
+// CHECK: clang-diagnostic-nsconsumed-mismatch
+// CHECK: clang-diagnostic-nsreturns-mismatch
+// CHECK: clang-diagnostic-null-arithmetic
+// CHECK: clang-diagnostic-null-character
+// CHECK: clang-diagnostic-null-conversion
+// CHECK: clang-diagnostic-null-dereference
+// CHECK: clang-diagnostic-null-pointer-arithmetic
+// CHECK: clang-diagnostic-nullability
+// CHECK: clang-diagnostic-nullability-completeness
+// CHECK: clang-diagnostic-nullability-completeness-on-arrays
+// CHECK: clang-diagnostic-nullability-declspec
+// CHECK: clang-diagnostic-nullability-extension
+// CHECK: clang-diagnostic-nullability-inferred-on-nested-type
+// CHECK: clang-diagnostic-nullable-to-nonnull-conversion
+// CHECK: clang-diagnostic-objc-autosynthesis-property-ivar-name-match
+// CHECK: clang-diagnostic-objc-circular-container
+// CHECK: clang-diagnostic-objc-designated-initializers
+// CHECK: clang-diagnostic-objc-forward-class-redefinition
+// CHECK: clang-diagnostic-objc-interface-ivars
+// CHECK: clang-diagnostic-objc-literal-compare
+// CHECK: clang-diagnostic-objc-literal-conversion
+// CHECK: clang-diagnostic-objc-macro-redefinition
+// CHECK: clang-diagnostic-objc-messaging-id
+// CHECK: clang-diagnostic-objc-method-access
+// CHECK: clang-diagnostic-objc-missing-property-synthesis
+// CHECK: clang-diagnostic-objc-missing-super-calls
+// CHECK: clang-diagnostic-objc-multiple-method-names
+// CHECK: clang-diagnostic-objc-noncopy-retain-block-property
+// CHECK: clang-diagnostic-objc-nonunified-exceptions
+// CHECK: clang-diagnostic-objc-property-implementation
+// CHECK: clang-diagnostic-objc-property-implicit-mismatch
+// CHECK: clang-diagnostic-objc-property-matches-cocoa-ownership-rule
+// CHECK: clang-diagnostic-objc-property-no-attribute
+// CHECK: clang-diagnostic-objc-property-synthesis
+// CHECK: clang-diagnostic-objc-protocol-method-implementation
+// CHECK: clang-diagnostic-objc-protocol-property-synthesis
+// CHECK: clang-diagnostic-objc-protocol-qualifiers
+// CHECK: clang-diagnostic-objc-readonly-with-setter-property
+// CHECK: clang-diagnostic-objc-redundant-literal-use
+// CHECK: clang-diagnostic-objc-root-class
+// CHECK: clang-diagnostic-objc-string-compare
+// CHECK: clang-diagnostic-objc-string-concatenation
+// CHECK: clang-diagnostic-objc-unsafe-perform-selector
+// CHECK: clang-diagnostic-odr
+// CHECK: clang-diagnostic-old-style-cast
+// CHECK: clang-diagnostic-opencl-unsupported-rgba
+// CHECK: clang-diagnostic-openmp-clauses
+// CHECK: clang-diagnostic-openmp-loop-form
+// CHECK: clang-diagnostic-openmp-target
+// CHECK: clang-diagnostic-option-ignored
+// CHECK: clang-diagnostic-out-of-line-declaration
+// CHECK: clang-diagnostic-over-aligned
+// CHECK: clang-diagnostic-overlength-strings
+// CHECK: clang-diagnostic-overloaded-shift-op-parentheses
+// CHECK: clang-diagnostic-overloaded-virtual
+// CHECK: clang-diagnostic-override-module
+// CHECK: clang-diagnostic-overriding-method-mismatch
+// CHECK: clang-diagnostic-overriding-t-option
+// CHECK: clang-diagnostic-packed
+// CHECK: clang-diagnostic-padded
+// CHECK: clang-diagnostic-parentheses
+// CHECK: clang-diagnostic-parentheses-equality
+// CHECK: clang-diagnostic-pass-failed
+// CHECK: clang-diagnostic-pch-date-time
+// CHECK: clang-diagnostic-pedantic
+// CHECK: clang-diagnostic-pedantic-core-features
+// CHECK: clang-diagnostic-pessimizing-move
+// CHECK: clang-diagnostic-pointer-arith
+// CHECK: clang-diagnostic-pointer-bool-conversion
+// CHECK: clang-diagnostic-pointer-sign
+// CHECK: clang-diagnostic-pointer-type-mismatch
+// CHECK: clang-diagnostic-potentially-evaluated-expression
+// CHECK: clang-diagnostic-pragma-clang-attribute
+// CHECK: clang-diagnostic-pragma-once-outside-header
+// CHECK: clang-diagnostic-pragma-pack
+// CHECK: clang-diagnostic-pragma-pack-suspicious-include
+// CHECK: clang-diagnostic-pragma-system-header-outside-header
+// CHECK: clang-diagnostic-pragmas
+// CHECK: clang-diagnostic-predefined-identifier-outside-function
+// CHECK: clang-diagnostic-private-extern
+// CHECK: clang-diagnostic-private-header
+// CHECK: clang-diagnostic-private-module
+// CHECK: clang-diagnostic-profile-instr-missing
+// CHECK: clang-diagnostic-profile-instr-out-of-date
+// CHECK: clang-diagnostic-profile-instr-unprofiled
+// CHECK: clang-diagnostic-property-access-dot-syntax
+// CHECK: clang-diagnostic-property-attribute-mismatch
+// CHECK: clang-diagnostic-protocol
+// CHECK: clang-diagnostic-protocol-property-synthesis-ambiguity
+// CHECK: clang-diagnostic-qualified-void-return-type
+// CHECK: clang-diagnostic-range-loop-analysis
+// CHECK: clang-diagnostic-readonly-iboutlet-property
+// CHECK: clang-diagnostic-receiver-expr
+// CHECK: clang-diagnostic-receiver-forward-class
+// CHECK: clang-diagnostic-redeclared-class-member
+// CHECK: clang-diagnostic-redundant-move
+// CHECK: clang-diagnostic-register
+// CHECK: clang-diagnostic-reinterpret-base-class
+// CHECK: clang-diagnostic-reorder
+// CHECK: clang-diagnostic-requires-super-attribute
+// CHECK: clang-diagnostic-reserved-id-macro
+// CHECK: clang-diagnostic-reserved-user-defined-literal
+// CHECK: clang-diagnostic-retained-language-linkage
+// CHECK: clang-diagnostic-return-stack-address
+// CHECK: clang-diagnostic-return-type
+// CHECK: clang-diagnostic-return-type-c-linkage
+// CHECK: clang-diagnostic-rtti-for-exceptions
+// CHECK: clang-diagnostic-section
+// CHECK: clang-diagnostic-selector
+// CHECK: clang-diagnostic-selector-type-mismatch
+// CHECK: clang-diagnostic-self-assign
+// CHECK: clang-diagnostic-self-assign-field
+// CHECK: clang-diagnostic-self-move
+// CHECK: clang-diagnostic-semicolon-before-method-body
+// CHECK: clang-diagnostic-sentinel
+// CHECK: clang-diagnostic-serialized-diagnostics
+// CHECK: clang-diagnostic-shadow
+// CHECK: clang-diagnostic-shadow-field
+// CHECK: clang-diagnostic-shadow-field-in-constructor
+// CHECK: clang-diagnostic-shadow-field-in-constructor-modified
+// CHECK: clang-diagnostic-shadow-ivar
+// CHECK: clang-diagnostic-shadow-uncaptured-local
+// CHECK: clang-diagnostic-shift-count-negative
+// CHECK: clang-diagnostic-shift-count-overflow
+// CHECK: clang-diagnostic-shift-negative-value
+// CHECK: clang-diagnostic-shift-op-parentheses
+// CHECK: clang-diagnostic-shift-overflow
+// CHECK: clang-diagnostic-shift-sign-overflow
+// CHECK: clang-diagnostic-shorten-64-to-32
+// CHECK: clang-diagnostic-sign-compare
+// CHECK: clang-diagnostic-sign-conversion
+// CHECK: clang-diagnostic-signed-enum-bitfield
+// CHECK: clang-diagnostic-sizeof-array-argument
+// CHECK: clang-diagnostic-sizeof-array-decay
+// CHECK: clang-diagnostic-sizeof-pointer-memaccess
+// CHECK: clang-diagnostic-slash-u-filename
+// CHECK: clang-diagnostic-sometimes-uninitialized
+// CHECK: clang-diagnostic-source-uses-openmp
+// CHECK: clang-diagnostic-spir-compat
+// CHECK: clang-diagnostic-static-float-init
+// CHECK: clang-diagnostic-static-in-inline
+// CHECK: clang-diagnostic-static-inline-explicit-instantiation
+// CHECK: clang-diagnostic-static-local-in-inline
+// CHECK: clang-diagnostic-static-self-init
+// CHECK: clang-diagnostic-strict-prototypes
+// CHECK: clang-diagnostic-strict-selector-match
+// CHECK: clang-diagnostic-string-compare
+// CHECK: clang-diagnostic-string-conversion
+// CHECK: clang-diagnostic-string-plus-char
+// CHECK: clang-diagnostic-string-plus-int
+// CHECK: clang-diagnostic-strlcpy-strlcat-size
+// CHECK: clang-diagnostic-strncat-size
+// CHECK: clang-diagnostic-super-class-method-mismatch
+// CHECK: clang-diagnostic-switch
+// CHECK: clang-diagnostic-switch-bool
+// CHECK: clang-diagnostic-switch-enum
+// CHECK: clang-diagnostic-sync-fetch-and-nand-semantics-changed
+// CHECK: clang-diagnostic-tautological-compare
+// CHECK: clang-diagnostic-tautological-constant-out-of-range-compare
+// CHECK: clang-diagnostic-tautological-overlap-compare
+// CHECK: clang-diagnostic-tautological-pointer-compare
+// CHECK: clang-diagnostic-tautological-undefined-compare
+// CHECK: clang-diagnostic-tautological-unsigned-enum-zero-compare
+// CHECK: clang-diagnostic-tautological-unsigned-zero-compare
+// CHECK: clang-diagnostic-tentative-definition-incomplete-type
+// CHECK: clang-diagnostic-thread-safety-analysis
+// CHECK: clang-diagnostic-thread-safety-attributes
+// CHECK: clang-diagnostic-thread-safety-beta
+// CHECK: clang-diagnostic-thread-safety-negative
+// CHECK: clang-diagnostic-thread-safety-precise
+// CHECK: clang-diagnostic-thread-safety-reference
+// CHECK: clang-diagnostic-thread-safety-verbose
+// CHECK: clang-diagnostic-trigraphs
+// CHECK: clang-diagnostic-type-safety
+// CHECK: clang-diagnostic-typedef-redefinition
+// CHECK: clang-diagnostic-typename-missing
+// CHECK: clang-diagnostic-unable-to-open-stats-file
+// CHECK: clang-diagnostic-unavailable-declarations
+// CHECK: clang-diagnostic-undeclared-selector
+// CHECK: clang-diagnostic-undef
+// CHECK: clang-diagnostic-undefined-bool-conversion
+// CHECK: clang-diagnostic-undefined-func-template
+// CHECK: clang-diagnostic-undefined-inline
+// CHECK: clang-diagnostic-undefined-internal
+// CHECK: clang-diagnostic-undefined-internal-type
+// CHECK: clang-diagnostic-undefined-reinterpret-cast
+// CHECK: clang-diagnostic-undefined-var-template
+// CHECK: clang-diagnostic-unevaluated-expression
+// CHECK: clang-diagnostic-unguarded-availability
+// CHECK: clang-diagnostic-unguarded-availability-new
+// CHECK: clang-diagnostic-unicode
+// CHECK: clang-diagnostic-unicode-whitespace
+// CHECK: clang-diagnostic-uninitialized
+// CHECK: clang-diagnostic-unknown-argument
+// CHECK: clang-diagnostic-unknown-attributes
+// CHECK: clang-diagnostic-unknown-escape-sequence
+// CHECK: clang-diagnostic-unknown-pragmas
+// CHECK: clang-diagnostic-unknown-sanitizers
+// CHECK: clang-diagnostic-unknown-warning-option
+// CHECK: clang-diagnostic-unnamed-type-template-args
+// CHECK: clang-diagnostic-unneeded-internal-declaration
+// CHECK: clang-diagnostic-unneeded-member-function
+// CHECK: clang-diagnostic-unreachable-code
+// CHECK: clang-diagnostic-unreachable-code-break
+// CHECK: clang-diagnostic-unreachable-code-loop-increment
+// CHECK: clang-diagnostic-unreachable-code-return
+// CHECK: clang-diagnostic-unsequenced
+// CHECK: clang-diagnostic-unsupported-abs
+// CHECK: clang-diagnostic-unsupported-availability-guard
+// CHECK: clang-diagnostic-unsupported-cb
+// CHECK: clang-diagnostic-unsupported-dll-base-class-template
+// CHECK: clang-diagnostic-unsupported-friend
+// CHECK: clang-diagnostic-unsupported-gpopt
+// CHECK: clang-diagnostic-unsupported-nan
+// CHECK: clang-diagnostic-unsupported-visibility
+// CHECK: clang-diagnostic-unusable-partial-specialization
+// CHECK: clang-diagnostic-unused-command-line-argument
+// CHECK: clang-diagnostic-unused-comparison
+// CHECK: clang-diagnostic-unused-const-variable
+// CHECK: clang-diagnostic-unused-exception-parameter
+// CHECK: clang-diagnostic-unused-function
+// CHECK: clang-diagnostic-unused-getter-return-value
+// CHECK: clang-diagnostic-unused-label
+// CHECK: clang-diagnostic-unused-lambda-capture
+// CHECK: clang-diagnostic-unused-local-typedef
+// CHECK: clang-diagnostic-unused-macros
+// CHECK: clang-diagnostic-unused-member-function
+// CHECK: clang-diagnostic-unused-parameter
+// CHECK: clang-diagnostic-unused-private-field
+// CHECK: clang-diagnostic-unused-property-ivar
+// CHECK: clang-diagnostic-unused-result
+// CHECK: clang-diagnostic-unused-template
+// CHECK: clang-diagnostic-unused-value
+// CHECK: clang-diagnostic-unused-variable
+// CHECK: clang-diagnostic-unused-volatile-lvalue
+// CHECK: clang-diagnostic-used-but-marked-unused
+// CHECK: clang-diagnostic-user-defined-literals
+// CHECK: clang-diagnostic-user-defined-warnings
+// CHECK: clang-diagnostic-varargs
+// CHECK: clang-diagnostic-variadic-macros
+// CHECK: clang-diagnostic-vec-elem-size
+// CHECK: clang-diagnostic-vector-conversion
+// CHECK: clang-diagnostic-vexing-parse
+// CHECK: clang-diagnostic-visibility
+// CHECK: clang-diagnostic-vla
+// CHECK: clang-diagnostic-vla-extension
+// CHECK: clang-diagnostic-void-ptr-dereference
+// CHECK: clang-diagnostic-weak-template-vtables
+// CHECK: clang-diagnostic-weak-vtables
+// CHECK: clang-diagnostic-writable-strings
+// CHECK: clang-diagnostic-zero-as-null-pointer-constant
+// CHECK: clang-diagnostic-zero-length-array
+// CHECK-NOT: {{.}}
Index: test/clang-tidy/diagnostic.cpp
===================================================================
--- test/clang-tidy/diagnostic.cpp
+++ test/clang-tidy/diagnostic.cpp
@@ -1,40 +1,34 @@
 // RUN: clang-tidy -checks='-*,modernize-use-override' %s.nonexistent.cpp -- | FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
 //
 // Now repeat the tests and ensure no other errors appear on stderr:
 // RUN: clang-tidy -checks='-*,modernize-use-override' %s.nonexistent.cpp -- 2>&1 | FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE 2>&1 | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE 2>&1 | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
 //
 // Now create a directory with a compilation database file and ensure we don't
 // use it after failing to parse commands from the command line:
 //
 // RUN: mkdir -p %T/diagnostics/
 // RUN: echo '[{"directory": "%/T/diagnostics/","command": "clang++ -fan-option-from-compilation-database -c %/T/diagnostics/input.cpp", "file": "%/T/diagnostics/input.cpp"}]' > %T/diagnostics/compile_commands.json
 // RUN: cat %s > %T/diagnostics/input.cpp
 // RUN: clang-tidy -checks='-*,modernize-use-override' %T/diagnostics/nonexistent.cpp -- 2>&1 | FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %T/diagnostics/input.cpp -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %T/diagnostics/input.cpp -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %T/diagnostics/input.cpp -- -DMACRO_FROM_COMMAND_LINE 2>&1 | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning:|error:}}' %s
-// RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %T/diagnostics/input.cpp 2>&1 | FileCheck -check-prefix=CHECK5 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %T/diagnostics/input.cpp -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %T/diagnostics/input.cpp -- -DMACRO_FROM_COMMAND_LINE 2>&1 | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,clang-diagnostic-literal-conversion,google-explicit-constructor' %T/diagnostics/input.cpp 2>&1 | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning:|error:}}' %s
 
 // CHECK1: error: error reading '{{.*}}nonexistent.cpp' [clang-diagnostic-error]
 // CHECK2: error: unknown argument: '-fan-unknown-option' [clang-diagnostic-error]
-// CHECK3: error: unknown argument: '-fan-unknown-option' [clang-diagnostic-error]
-// CHECK5: error: unknown argument: '-fan-option-from-compilation-database' [clang-diagnostic-error]
+// CHECK4: error: unknown argument: '-fan-option-from-compilation-database' [clang-diagnostic-error]
 
-// CHECK2: :[[@LINE+3]]:9: warning: implicit conversion from 'double' to 'int' changes value from 1.5 to 1 [clang-diagnostic-literal-conversion]
-// CHECK3: :[[@LINE+2]]:9: warning: implicit conversion from 'double' to 'int' changes value
-// CHECK5: :[[@LINE+1]]:9: warning: implicit conversion from 'double' to 'int' changes value
+// CHECK2: :[[@LINE+2]]:9: warning: implicit conversion from 'double' to 'int' changes value from 1.5 to 1 [clang-diagnostic-literal-conversion]
+// CHECK4: :[[@LINE+1]]:9: warning: implicit conversion from 'double' to 'int' changes value
 int a = 1.5;
 
-// CHECK2: :[[@LINE+3]]:11: warning: single-argument constructors must be marked explicit
-// CHECK3: :[[@LINE+2]]:11: warning: single-argument constructors must be marked explicit
-// CHECK5: :[[@LINE+1]]:11: warning: single-argument constructors must be marked explicit
+// CHECK2: :[[@LINE+2]]:11: warning: single-argument constructors must be marked explicit
+// CHECK4: :[[@LINE+1]]:11: warning: single-argument constructors must be marked explicit
 class A { A(int) {} };
 
 #define MACRO_FROM_COMMAND_LINE
-// CHECK4: :[[@LINE-1]]:9: warning: 'MACRO_FROM_COMMAND_LINE' macro redefined
+// CHECK3: :[[@LINE-1]]:9: warning: 'MACRO_FROM_COMMAND_LINE' macro redefined
Index: test/clang-tidy/custom-diagnostics.cpp
===================================================================
--- test/clang-tidy/custom-diagnostics.cpp
+++ test/clang-tidy/custom-diagnostics.cpp
@@ -1,4 +1,9 @@
-// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow,clang-diagnostic-float-conversion' %s -- | count 0
+// RUN: clang-tidy -checks='-*,modernize-use-override' %s -- | count 0
+//
+// Clang-diagnostic checks completely override extra args:
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow,clang-diagnostic-float-conversion' \
+// RUN:   -config='{ExtraArgs: ["-Wno-shadow","-Wno-float-conversion","-Wunused-variable"], ExtraArgsBefore: ["-Wno-shadow","-Wno-float-conversion","-Wunused-variable"]}' %s -- \
+// RUN:   | FileCheck -implicit-check-not='{{warning:|error:}}' %s
 //
 // Enable warnings using -config:
 // RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow,clang-diagnostic-float-conversion' \
Index: test/clang-tidy/cert-exp59-cpp.cpp
===================================================================
--- /dev/null
+++ test/clang-tidy/cert-exp59-cpp.cpp
@@ -0,0 +1,16 @@
+// RUN: clang-tidy %s -checks='-*,clang-diagnostic-invalid-offsetof' -- 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy %s -checks='-*,cert-exp59-cpp' -- 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK2 %s
+// RUN: clang-tidy %s -- 2>&1 | FileCheck -allow-empty -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK3 %s
+
+#include <cstddef>
+
+struct D {
+    virtual void f() {}
+    int i;
+};
+
+void f() {
+    size_t Off = offsetof(D, i);
+    //CHECK: :[[@LINE-1]]:18: warning: offset of on non-POD type 'D' [clang-diagnostic-invalid-offsetof]
+    //CHECK2: :[[@LINE-2]]:18: warning: offset of on non-POD type 'D' [cert-exp59-cpp]
+}
Index: clang-tidy/tool/ClangTidyMain.cpp
===================================================================
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -51,7 +51,6 @@
 )");
 
 const char DefaultChecks[] = // Enable these checks by default:
-    "clang-diagnostic-*,"    //   * compiler diagnostics
     "clang-analyzer-*";      //   * Static Analyzer checks
 
 static cl::opt<std::string> Checks("checks", cl::desc(R"(
Index: clang-tidy/cert/CERTTidyModule.cpp
===================================================================
--- clang-tidy/cert/CERTTidyModule.cpp
+++ clang-tidy/cert/CERTTidyModule.cpp
@@ -73,6 +73,12 @@
     // MSC
     CheckFactories.registerCheck<LimitedRandomnessCheck>("cert-msc30-c");
   }
+
+  void addWarningCheckAliases(llvm::DenseMap<llvm::StringRef, llvm::StringRef>
+                                  &WarningCheckAliases) override {
+    WarningCheckAliases.try_emplace("exceptions", "cert-err54-cpp");
+    WarningCheckAliases.try_emplace("invalid-offsetof", "cert-exp59-cpp");
+  }
 };
 
 } // namespace cert
Index: clang-tidy/ClangTidyModule.h
===================================================================
--- clang-tidy/ClangTidyModule.h
+++ clang-tidy/ClangTidyModule.h
@@ -11,6 +11,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYMODULE_H
 
 #include "ClangTidy.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
 #include <functional>
 #include <map>
@@ -89,6 +90,11 @@
   /// belonging to this module.
   virtual void addCheckFactories(ClangTidyCheckFactories &CheckFactories) = 0;
 
+  /// \brief Implement this function in order to register all warning-check
+  /// aliases belonging to this module.
+  virtual void addWarningCheckAliases(
+      llvm::DenseMap<llvm::StringRef, llvm::StringRef> &WarningCheckAliases) {}
+
   /// \brief Gets default options for checks defined in this module.
   virtual ClangTidyOptions getModuleOptions();
 };
Index: clang-tidy/ClangTidyDiagnosticConsumer.h
===================================================================
--- clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -17,6 +17,7 @@
 #include "clang/Tooling/Refactoring.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/Timer.h"
 
@@ -186,6 +187,10 @@
     return CurrentBuildDirectory;
   }
 
+  std::vector<std::string> getEnabledClangDiagnostics();
+
+  llvm::DenseMap<llvm::StringRef, llvm::StringRef> WarningCheckAliases;
+
 private:
   // Calls setDiagnosticsEngine() and storeError().
   friend class ClangTidyDiagnosticConsumer;
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===================================================================
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -22,6 +22,7 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Frontend/DiagnosticRenderer.h"
 #include "llvm/ADT/SmallString.h"
+#include <algorithm>
 #include <tuple>
 #include <vector>
 using namespace clang;
@@ -257,6 +258,22 @@
   return "";
 }
 
+std::vector<std::string> ClangTidyContext::getEnabledClangDiagnostics() {
+  llvm::SmallVector<unsigned, 5000> Diags;
+  DiagnosticIDs::getAllDiagnostics(diag::Flavor::WarningOrError, Diags);
+  std::vector<std::string> EnabledClangDiagnostics;
+  for (unsigned DiagID : Diags) {
+    auto Flag = DiagnosticIDs::getWarningOptionForDiag(DiagID).str();
+    if (!Flag.empty() && isCheckEnabled("clang-diagnostic-" + Flag))
+      EnabledClangDiagnostics.push_back(Flag);
+  }
+  std::sort(EnabledClangDiagnostics.begin(), EnabledClangDiagnostics.end());
+  EnabledClangDiagnostics.erase(std::unique(EnabledClangDiagnostics.begin(),
+                                            EnabledClangDiagnostics.end()),
+                                EnabledClangDiagnostics.end());
+  return EnabledClangDiagnostics;
+}
+
 ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(
     ClangTidyContext &Ctx, bool RemoveIncompatibleErrors)
     : Context(Ctx), RemoveIncompatibleErrors(RemoveIncompatibleErrors),
@@ -374,9 +391,15 @@
     StringRef WarningOption =
         Context.DiagEngine->getDiagnosticIDs()->getWarningOptionForDiag(
             Info.getID());
-    std::string CheckName = !WarningOption.empty()
-                                ? ("clang-diagnostic-" + WarningOption).str()
-                                : Context.getCheckName(Info.getID()).str();
+    auto Alias = Context.WarningCheckAliases.find(WarningOption);
+    std::string CheckName;
+    if (Alias != Context.WarningCheckAliases.end() &&
+        Context.isCheckEnabled(Alias->second))
+      CheckName = Alias->second;
+    else
+      CheckName = !WarningOption.empty()
+                      ? ("clang-diagnostic-" + WarningOption).str()
+                      : Context.getCheckName(Info.getID()).str();
 
     if (CheckName.empty()) {
       // This is a compiler diagnostic without a warning option. Assign check
Index: clang-tidy/ClangTidy.cpp
===================================================================
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -286,6 +286,7 @@
        I != E; ++I) {
     std::unique_ptr<ClangTidyModule> Module(I->instantiate());
     Module->addCheckFactories(*CheckFactories);
+    Module->addWarningCheckAliases(Context.WarningCheckAliases);
   }
 }
 
@@ -397,6 +398,13 @@
       CheckNames.push_back(CheckFactory.first);
   }
 
+  for (const auto &Alias : Context.WarningCheckAliases)
+    if (Context.isCheckEnabled(Alias.second))
+      CheckNames.push_back(Alias.second);
+
+  for (const auto &Diag : Context.getEnabledClangDiagnostics())
+    CheckNames.push_back("clang-diagnostic-" + Diag);
+
   for (const auto &AnalyzerCheck : getCheckersControlList(Context))
     CheckNames.push_back(AnalyzerCheckNamePrefix + AnalyzerCheck.first);
 
@@ -492,6 +500,15 @@
         if (Opts.ExtraArgs)
           AdjustedArgs.insert(AdjustedArgs.end(), Opts.ExtraArgs->begin(),
                               Opts.ExtraArgs->end());
+
+        AdjustedArgs.push_back("-Wno-everything");
+        for (const auto &Diag : Context.getEnabledClangDiagnostics())
+          AdjustedArgs.push_back("-W" + Diag);
+
+        for (const auto &Alias : Context.WarningCheckAliases)
+          if (Context.isCheckEnabled(Alias.second))
+            AdjustedArgs.push_back("-W" + Alias.first.str());
+
         return AdjustedArgs;
       };
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D38171: Implement... András Leitereg via Phabricator via cfe-commits

Reply via email to