Skip to content

Commit d8f492e

Browse files
committed
Squelch some warnings.
Fix up some dead code warnings as well as a warning for testing whether an unsigned number is non-negative (which it always is).
1 parent 12e7caf commit d8f492e

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

include/swift/Basic/OwnedString.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class OwnedString {
5252
void initialize(const char* Data, size_t Length, StringOwnership Ownership) {
5353
this->Length = Length;
5454
this->Ownership = Ownership;
55-
assert(Length >= 0 && "expected length to be non-negative");
5655
if (Ownership == StringOwnership::Copied && Data) {
5756
char *substring = static_cast<char *>(malloc(Length + 1));
5857
assert(substring && "expected successful malloc of copy");

lib/FrontendTool/FrontendTool.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,13 @@ class JSONFixitWriter
391391
// This is a separate function so that it shows up in stack traces.
392392
LLVM_ATTRIBUTE_NOINLINE
393393
static void debugFailWithAssertion() {
394-
// This assertion should always fail, per the user's request, and should
395-
// not be converted to llvm_unreachable.
396-
assert(0 && "This is an assertion!");
394+
// Per the user's request, this assertion should always fail in
395+
// builds with assertions enabled.
396+
397+
// This should not be converted to llvm_unreachable, as those are
398+
// treated as optimization hints in builds where they turn into
399+
// __builtin_unreachable().
400+
assert((0) && "This is an assertion!");
397401
}
398402

399403
// This is a separate function so that it shows up in stack traces.

lib/Sema/CSDiag.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7276,7 +7276,7 @@ bool FailureDiagnosis::visitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
72767276
case CC_SelfMismatch: // Self argument mismatches.
72777277
case CC_ArgumentNearMismatch: // Argument list mismatch.
72787278
case CC_ArgumentMismatch: // Argument list mismatch.
7279-
assert(0 && "These aren't produced by filterContextualMemberList");
7279+
llvm_unreachable("These aren't produced by filterContextualMemberList");
72807280
return false;
72817281

72827282
case CC_ExactMatch: { // This is a perfect match for the arguments.

lib/Sema/TypeCheckSwitchStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ namespace {
750750
break;
751751
case SpaceKind::Disjunct: {
752752
if (forDisplay) {
753-
assert(false && "Attempted to display disjunct to user!");
753+
llvm_unreachable("Attempted to display disjunct to user!");
754754
} else {
755755
buffer << "DISJOIN(";
756756
for (auto &sp : Spaces) {

0 commit comments

Comments
 (0)