Skip to content

Commit 9642627

Browse files
committed
csa/MallocChecker: turn llvm_unreachable into asserts
1 parent 3d362cf commit 9642627

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ void MallocChecker::checkCXXNewOrCXXDelete(const CallEvent &Call,
12931293
AF_CXXNewArray);
12941294
break;
12951295
default:
1296-
llvm_unreachable("not a new/delete operator");
1296+
assert(false && "not a new/delete operator");
12971297
}
12981298

12991299
C.addTransition(State);
@@ -1490,7 +1490,7 @@ ProgramStateRef MallocChecker::ProcessZeroAllocCheck(
14901490
return State;
14911491
}
14921492
} else
1493-
llvm_unreachable("not a CallExpr or CXXNewExpr");
1493+
assert(false && "not a CallExpr or CXXNewExpr");
14941494

14951495
assert(Arg);
14961496

@@ -1925,7 +1925,7 @@ static void printExpectedAllocName(raw_ostream &os, AllocationFamily Family) {
19251925
case AF_IfNameIndex: os << "'if_nameindex()'"; return;
19261926
case AF_InnerBuffer: os << "container-specific allocator"; return;
19271927
case AF_Alloca:
1928-
case AF_None: llvm_unreachable("not a deallocation expression");
1928+
case AF_None: assert(false && "not a deallocation expression");
19291929
}
19301930
}
19311931

@@ -1937,7 +1937,7 @@ static void printExpectedDeallocName(raw_ostream &os, AllocationFamily Family) {
19371937
case AF_IfNameIndex: os << "'if_freenameindex()'"; return;
19381938
case AF_InnerBuffer: os << "container-specific deallocator"; return;
19391939
case AF_Alloca:
1940-
case AF_None: llvm_unreachable("suspicious argument");
1940+
case AF_None: assert(false && "suspicious argument");
19411941
}
19421942
}
19431943

@@ -2145,10 +2145,10 @@ MallocChecker::getCheckIfTracked(AllocationFamily Family,
21452145
return std::nullopt;
21462146
}
21472147
case AF_None: {
2148-
llvm_unreachable("no family");
2148+
assert(false && "no family");
21492149
}
21502150
}
2151-
llvm_unreachable("unhandled family");
2151+
assert(false && "unhandled family");
21522152
}
21532153

21542154
std::optional<MallocChecker::CheckKind>
@@ -3528,7 +3528,7 @@ PathDiagnosticPieceRef MallocBugVisitor::VisitNode(const ExplodedNode *N,
35283528
break;
35293529
}
35303530
case AF_None:
3531-
llvm_unreachable("Unhandled allocation family!");
3531+
assert(false && "Unhandled allocation family!");
35323532
}
35333533

35343534
// See if we're releasing memory while inlining a destructor

0 commit comments

Comments
 (0)