mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
e3f07a58f5
When a diagnostic belongs to a group that has a parent group (`GROUP_LINK` in `DiagnosticGroups.def`), display the full inheritance chain in the diagnostic output, including documentation hyperlinks and footnotes for each. For example, a diagnostic in `ExistentialType` (child of `PerformanceHints`) now renders as: ``` warning: ... [#PerformanceHints::ExistentialType] ``` Groups without parents continue to display as before (`[#DeprecatedDeclaration]`). Resolves rdar://170805800
40 lines
2.3 KiB
Swift
40 lines
2.3 KiB
Swift
// RUN: %empty-directory(%t)
|
|
|
|
// Ensure ignored by-default
|
|
// RUN: %target-swift-frontend -typecheck %s -diagnostic-style llvm -verify
|
|
|
|
// Ensure enabled with '-Wwarning'
|
|
// RUN: %target-swift-frontend -typecheck %s -diagnostic-style llvm -Wwarning PerformanceHints &> %t/output_warn.txt
|
|
// RUN: cat %t/output_warn.txt | %FileCheck %s -check-prefix CHECK-WARN
|
|
// RUN: %target-swift-frontend -typecheck %s -diagnostic-style llvm -Wwarning ReturnTypeImplicitCopy &> %t/output_warn.txt
|
|
// RUN: cat %t/output_warn.txt | %FileCheck %s -check-prefix CHECK-WARN
|
|
|
|
// Ensure enabled with '-Werror' for the broad category and downgraded to warning for the subgroup with '-Wwarning'
|
|
// RUN: %target-swift-frontend -typecheck %s -diagnostic-style llvm -Werror PerformanceHints -Wwarning ReturnTypeImplicitCopy &> %t/output_warn.txt
|
|
// RUN: cat %t/output_warn.txt | %FileCheck %s -check-prefix CHECK-WARN
|
|
|
|
// Ensure enabled with '-Wwarning' for the broad category and downgraded to warning for the subgroup with '-Werror'
|
|
// RUN: not %target-swift-frontend -typecheck %s -diagnostic-style llvm -Wwarning PerformanceHints -Werror ReturnTypeImplicitCopy &> %t/output_err.txt
|
|
// RUN: cat %t/output_err.txt | %FileCheck %s -check-prefix CHECK-ERR
|
|
|
|
// Ensure escalated with '-Werror'
|
|
// RUN: not %target-swift-frontend -typecheck %s -diagnostic-style llvm -Werror ReturnTypeImplicitCopy &> %t/output_err.txt
|
|
// RUN: cat %t/output_err.txt | %FileCheck %s -check-prefix CHECK-ERR
|
|
|
|
// CHECK-ERR: error: Performance: 'foo()' returns an array, leading to implicit copies. Consider using an 'inout' parameter instead. [#PerformanceHints::ReturnTypeImplicitCopy]
|
|
// CHECK-ERR: error: Performance: closure returns an array, leading to implicit copies. Consider using an 'inout' parameter instead. [#PerformanceHints::ReturnTypeImplicitCopy]
|
|
|
|
// CHECK-WARN: warning: Performance: 'foo()' returns an array, leading to implicit copies. Consider using an 'inout' parameter instead. [#PerformanceHints::ReturnTypeImplicitCopy]
|
|
// CHECK-WARN: warning: Performance: closure returns an array, leading to implicit copies. Consider using an 'inout' parameter instead. [#PerformanceHints::ReturnTypeImplicitCopy]
|
|
|
|
func foo() -> [Int] {
|
|
return [1,2,3,4,5,6]
|
|
}
|
|
|
|
func bar() -> Int {
|
|
let myCoolArray = { () -> [Int] in
|
|
return [1, 2]
|
|
}
|
|
return myCoolArray().count
|
|
}
|