File tree 2 files changed +24
-23
lines changed
Sources/Build/BuildDescription
2 files changed +24
-23
lines changed Original file line number Diff line number Diff line change @@ -363,21 +363,18 @@ public final class ClangModuleBuildDescription {
363
363
364
364
// suppress warnings if the package is remote
365
365
if self . package . isRemote {
366
- args += [ " -w " ]
367
366
// `-w` (suppress warnings) and the other warning control flags are mutually exclusive
368
- for index in args. indices. reversed ( ) {
369
- let arg = args [ index]
370
- if arg. starts ( with: " -W " ) , arg. count > 2 {
371
- // we consider the following flags:
372
- // -Wxxxx
373
- // -Wno-xxxx
374
- // -Werror
375
- // -Werror=xxxx
376
- // -Wno-error
377
- // -Wno-error=xxxx
378
- args. remove ( at: index)
379
- }
367
+ args = args. filter { arg in
368
+ // we consider the following flags:
369
+ // -Wxxxx
370
+ // -Wno-xxxx
371
+ // -Werror
372
+ // -Werror=xxxx
373
+ // -Wno-error
374
+ // -Wno-error=xxxx
375
+ arg. count <= 2 || !arg. starts ( with: " -W " )
380
376
}
377
+ args += [ " -w " ]
381
378
}
382
379
383
380
return args
Original file line number Diff line number Diff line change @@ -621,23 +621,27 @@ public final class SwiftModuleBuildDescription {
621
621
622
622
// suppress warnings if the package is remote
623
623
if self . package . isRemote {
624
- args += [ " -suppress-warnings " ]
625
624
// suppress-warnings and the other warning control flags are mutually exclusive
626
- for index in args. indices. reversed ( ) {
627
- let arg = args [ index]
625
+ var removeNextArg = false
626
+ args = args. filter { arg in
627
+ if removeNextArg {
628
+ removeNextArg = false
629
+ return false
630
+ }
628
631
switch arg {
629
632
case " -warnings-as-errors " , " -no-warnings-as-errors " :
630
- args . remove ( at : index )
633
+ return false
631
634
case " -Wwarning " , " -Werror " :
632
- guard args. indices. contains ( index + 1 ) else {
633
- throw InternalError ( " Unexpected ' \( arg) ' at the end of args " )
634
- }
635
- args. remove ( at: index + 1 )
636
- args. remove ( at: index)
635
+ removeNextArg = true
636
+ return false
637
637
default :
638
- break
638
+ return true
639
639
}
640
640
}
641
+ guard !removeNextArg else {
642
+ throw InternalError ( " Unexpected '-Wwarning' or '-Werror' at the end of args " )
643
+ }
644
+ args += [ " -suppress-warnings " ]
641
645
}
642
646
643
647
// Pass `-user-module-version` for versioned packages that aren't pre-releases.
You can’t perform that action at this time.
0 commit comments