Switch assert(0/false) llvm_unreachable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140367 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp
index fad1199..7e2f4ad 100644
--- a/lib/Sema/DeclSpec.cpp
+++ b/lib/Sema/DeclSpec.cpp
@@ -650,7 +650,7 @@
TypeQualifiers |= T;
switch (T) {
- default: assert(0 && "Unknown type qualifier!");
+ default: llvm_unreachable("Unknown type qualifier!");
case TQ_const: TQ_constLoc = Loc; break;
case TQ_restrict: TQ_restrictLoc = Loc; break;
case TQ_volatile: TQ_volatileLoc = Loc; break;
@@ -948,7 +948,7 @@
Specifiers |= VS;
switch (VS) {
- default: assert(0 && "Unknown specifier!");
+ default: llvm_unreachable("Unknown specifier!");
case VS_Override: VS_overrideLoc = Loc; break;
case VS_Final: VS_finalLoc = Loc; break;
}
@@ -958,7 +958,7 @@
const char *VirtSpecifiers::getSpecifierName(Specifier VS) {
switch (VS) {
- default: assert(0 && "Unknown specifier");
+ default: llvm_unreachable("Unknown specifier");
case VS_Override: return "override";
case VS_Final: return "final";
}
diff --git a/lib/Sema/IdentifierResolver.cpp b/lib/Sema/IdentifierResolver.cpp
index 95420a3..a643267 100644
--- a/lib/Sema/IdentifierResolver.cpp
+++ b/lib/Sema/IdentifierResolver.cpp
@@ -73,7 +73,7 @@
}
}
- assert(0 && "Didn't find this decl on its identifier's chain!");
+ llvm_unreachable("Didn't find this decl on its identifier's chain!");
}
bool
diff --git a/lib/Sema/SemaAttr.cpp b/lib/Sema/SemaAttr.cpp
index 1c49892..cd03069 100644
--- a/lib/Sema/SemaAttr.cpp
+++ b/lib/Sema/SemaAttr.cpp
@@ -265,7 +265,7 @@
break;
default:
- assert(0 && "Invalid #pragma pack kind.");
+ llvm_unreachable("Invalid #pragma pack kind.");
}
}
diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp
index a2cef9c..90fd7cd 100644
--- a/lib/Sema/SemaCXXScopeSpec.cpp
+++ b/lib/Sema/SemaCXXScopeSpec.cpp
@@ -137,7 +137,7 @@
switch (NNS->getKind()) {
case NestedNameSpecifier::Identifier:
- assert(false && "Dependent nested-name-specifier has no DeclContext");
+ llvm_unreachable("Dependent nested-name-specifier has no DeclContext");
break;
case NestedNameSpecifier::Namespace:
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index cda4d92..052ef3b 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -548,7 +548,7 @@
unsigned BuiltinID = FDecl->getBuiltinID();
unsigned BuiltinIndex, NumFixed = 1;
switch (BuiltinID) {
- default: assert(0 && "Unknown overloaded atomic builtin!");
+ default: llvm_unreachable("Unknown overloaded atomic builtin!");
case Builtin::BI__sync_fetch_and_add: BuiltinIndex = 0; break;
case Builtin::BI__sync_fetch_and_sub: BuiltinIndex = 1; break;
case Builtin::BI__sync_fetch_and_or: BuiltinIndex = 2; break;
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index 5b44841..166e165 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -3400,7 +3400,7 @@
break;
default:
- assert(false && "Unknown type specifier kind in CodeCompleteTag");
+ llvm_unreachable("Unknown type specifier kind in CodeCompleteTag");
return;
}
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 0e81765..3878341 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -2935,7 +2935,7 @@
} // switch (Name.getKind())
- assert(false && "Unknown name kind");
+ llvm_unreachable("Unknown name kind");
return DeclarationNameInfo();
}
@@ -4360,7 +4360,7 @@
DeclarationName Name = NameInfo.getName();
FunctionDecl::StorageClass SC = SC_None;
switch (D.getDeclSpec().getStorageClassSpec()) {
- default: assert(0 && "Unknown storage class!");
+ default: llvm_unreachable("Unknown storage class!");
case DeclSpec::SCS_auto:
case DeclSpec::SCS_register:
case DeclSpec::SCS_mutable:
@@ -8372,7 +8372,7 @@
}
}
- assert(0 && "found no user-declared constructors");
+ llvm_unreachable("found no user-declared constructors");
return;
}
break;
@@ -8458,7 +8458,7 @@
case CXXDestructor:
hasTrivial = &CXXRecordDecl::hasTrivialDestructor; break;
default:
- assert(0 && "unexpected special member"); return;
+ llvm_unreachable("unexpected special member"); return;
}
// Check for nontrivial bases (and recurse).
@@ -8506,7 +8506,7 @@
}
}
- assert(0 && "found no explanation for non-trivial member");
+ llvm_unreachable("found no explanation for non-trivial member");
}
/// TranslateIvarVisibility - Translate visibility from a token ID to an
@@ -8514,7 +8514,7 @@
static ObjCIvarDecl::AccessControl
TranslateIvarVisibility(tok::ObjCKeywordKind ivarVisibility) {
switch (ivarVisibility) {
- default: assert(0 && "Unknown visitibility kind");
+ default: llvm_unreachable("Unknown visitibility kind");
case tok::objc_private: return ObjCIvarDecl::Private;
case tok::objc_public: return ObjCIvarDecl::Public;
case tok::objc_protected: return ObjCIvarDecl::Protected;
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 48f2f96..34eb498 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -3205,7 +3205,7 @@
switch (Attr.getKind()) {
default:
- assert(0 && "invalid ownership attribute");
+ llvm_unreachable("invalid ownership attribute");
return;
case AttributeList::AT_ns_returns_autoreleased:
D->addAttr(::new (S.Context) NSReturnsAutoreleasedAttr(Attr.getRange(),
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 616f798..ef8719c 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -9977,7 +9977,7 @@
}
case CXXInvalid:
- assert(false && "Invalid special member.");
+ llvm_unreachable("Invalid special member.");
break;
}
} else {
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 94de799..5a1ce28 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -1664,7 +1664,7 @@
DiagnoseUnimplementedProperties(S, IMPDecl, CDecl, InsMap);
}
} else
- assert(false && "invalid ObjCContainerDecl type.");
+ llvm_unreachable("invalid ObjCContainerDecl type.");
}
/// ActOnForwardClassDeclaration -
diff --git a/lib/Sema/SemaExceptionSpec.cpp b/lib/Sema/SemaExceptionSpec.cpp
index 65bed3a..aba7b34 100644
--- a/lib/Sema/SemaExceptionSpec.cpp
+++ b/lib/Sema/SemaExceptionSpec.cpp
@@ -223,7 +223,7 @@
break;
default:
- assert(false && "This spec type is compatible with none.");
+ llvm_unreachable("This spec type is compatible with none.");
}
OS.flush();
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 7106ab2..582f153 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2390,7 +2390,7 @@
PredefinedExpr::IdentType IT;
switch (Kind) {
- default: assert(0 && "Unknown simple primary expr!");
+ default: llvm_unreachable("Unknown simple primary expr!");
case tok::kw___func__: IT = PredefinedExpr::Func; break; // [C99 6.4.2.2]
case tok::kw___FUNCTION__: IT = PredefinedExpr::Function; break;
case tok::kw___PRETTY_FUNCTION__: IT = PredefinedExpr::PrettyFunction; break;
@@ -2952,7 +2952,7 @@
tok::TokenKind Kind, Expr *Input) {
UnaryOperatorKind Opc;
switch (Kind) {
- default: assert(0 && "Unknown unary op!");
+ default: llvm_unreachable("Unknown unary op!");
case tok::plusplus: Opc = UO_PostInc; break;
case tok::minusminus: Opc = UO_PostDec; break;
}
@@ -6511,7 +6511,7 @@
case BO_GE: resultComparison = ") >= 0"; break;
case BO_EQ: resultComparison = ") == 0"; break;
case BO_NE: resultComparison = ") != 0"; break;
- default: assert(false && "Invalid comparison operator");
+ default: llvm_unreachable("Invalid comparison operator");
}
DiagRuntimeBehavior(Loc, 0,
@@ -7593,7 +7593,7 @@
}
}
} else if (!isa<FunctionDecl>(dcl) && !isa<NonTypeTemplateParmDecl>(dcl))
- assert(0 && "Unknown/unexpected decl type");
+ llvm_unreachable("Unknown/unexpected decl type");
}
if (AddressOfError != AO_No_Error) {
@@ -7669,7 +7669,7 @@
tok::TokenKind Kind) {
BinaryOperatorKind Opc;
switch (Kind) {
- default: assert(0 && "Unknown binop!");
+ default: llvm_unreachable("Unknown binop!");
case tok::periodstar: Opc = BO_PtrMemD; break;
case tok::arrowstar: Opc = BO_PtrMemI; break;
case tok::star: Opc = BO_Mul; break;
@@ -7710,7 +7710,7 @@
tok::TokenKind Kind) {
UnaryOperatorKind Opc;
switch (Kind) {
- default: assert(0 && "Unknown unary op!");
+ default: llvm_unreachable("Unknown unary op!");
case tok::plusplus: Opc = UO_PreInc; break;
case tok::minusminus: Opc = UO_PreDec; break;
case tok::amp: Opc = UO_AddrOf; break;
@@ -8941,7 +8941,7 @@
else if (pw == Context.getTargetInfo().getLongLongWidth())
Ty = Context.LongLongTy;
else {
- assert(0 && "I don't know size of pointer!");
+ llvm_unreachable("I don't know size of pointer!");
Ty = Context.IntTy;
}
@@ -8990,7 +8990,7 @@
bool MayHaveConvFixit = false;
switch (ConvTy) {
- default: assert(0 && "Unknown conversion type");
+ default: llvm_unreachable("Unknown conversion type");
case Compatible: return false;
case PointerToInt:
DiagKind = diag::ext_typecheck_convert_pointer_int;
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 140fd90..3beb51c 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -1525,7 +1525,7 @@
return true;
}
}
- assert(false && "Unreachable, bad result from BestViableFunction");
+ llvm_unreachable("Unreachable, bad result from BestViableFunction");
return true;
}
@@ -2068,7 +2068,7 @@
DeclAccessPair FoundDecl,
Expr *From) {
switch (Kind) {
- default: assert(0 && "Unhandled cast kind!");
+ default: llvm_unreachable("Unhandled cast kind!");
case CK_ConstructorConversion: {
ASTOwningVector<Expr*> ConstructorArgs(S);
@@ -2181,7 +2181,7 @@
return ExprError();
case ImplicitConversionSequence::EllipsisConversion:
- assert(false && "Cannot perform an ellipsis conversion");
+ llvm_unreachable("Cannot perform an ellipsis conversion");
return Owned(From);
case ImplicitConversionSequence::BadConversion:
@@ -2284,7 +2284,7 @@
break;
default:
- assert(false && "Improper first standard conversion");
+ llvm_unreachable("Improper first standard conversion");
break;
}
@@ -2524,7 +2524,7 @@
case ICK_Function_To_Pointer:
case ICK_Qualification:
case ICK_Num_Conversion_Kinds:
- assert(false && "Improper second standard conversion");
+ llvm_unreachable("Improper second standard conversion");
break;
}
@@ -2550,7 +2550,7 @@
}
default:
- assert(false && "Improper third standard conversion");
+ llvm_unreachable("Improper third standard conversion");
break;
}
@@ -3560,7 +3560,7 @@
break;
case OR_Deleted:
- assert(false && "Conditional operator has only built-in overloads");
+ llvm_unreachable("Conditional operator has only built-in overloads");
break;
}
return true;
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 43477b2..f710380 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -512,7 +512,7 @@
else if (T->isVectorType())
maxElements = T->getAs<VectorType>()->getNumElements();
else
- assert(0 && "CheckImplicitInitList(): Illegal type");
+ llvm_unreachable("CheckImplicitInitList(): Illegal type");
if (maxElements == 0) {
SemaRef.Diag(ParentIList->getInit(Index)->getLocStart(),
@@ -656,7 +656,7 @@
SubobjectIsDesignatorContext, Index,
StructuredList, StructuredIndex);
} else
- assert(0 && "Aggregate that isn't a structure or array?!");
+ llvm_unreachable("Aggregate that isn't a structure or array?!");
} else if (DeclType->isVoidType() || DeclType->isFunctionType()) {
// This type is invalid, issue a diagnostic.
++Index;
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 806fd39..7f42fb7 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -4657,7 +4657,7 @@
break;
default:
- assert(false &&
+ llvm_unreachable(
"Can only end up with a standard conversion sequence or failure");
}
}
@@ -5039,7 +5039,7 @@
buildObjCPtr = true;
}
else
- assert(false && "type was not a pointer type!");
+ llvm_unreachable("type was not a pointer type!");
}
else
PointeeTy = PointerTy->getPointeeType();
@@ -6333,7 +6333,7 @@
switch (Op) {
case OO_None:
case NUM_OVERLOADED_OPERATORS:
- assert(false && "Expected an overloaded operator");
+ llvm_unreachable("Expected an overloaded operator");
break;
case OO_New:
@@ -6341,7 +6341,8 @@
case OO_Array_New:
case OO_Array_Delete:
case OO_Call:
- assert(false && "Special operators don't use AddBuiltinOperatorCandidates");
+ llvm_unreachable(
+ "Special operators don't use AddBuiltinOperatorCandidates");
break;
case OO_Comma:
@@ -7310,7 +7311,7 @@
RankDeductionFailure(const OverloadCandidate::DeductionFailureInfo &DFI) {
switch ((Sema::TemplateDeductionResult)DFI.Result) {
case Sema::TDK_Success:
- assert(0 && "TDK_success while diagnosing bad deduction");
+ llvm_unreachable("TDK_success while diagnosing bad deduction");
case Sema::TDK_Incomplete:
return 1;
@@ -8368,7 +8369,7 @@
if (ULE->decls_begin() + 1 == ULE->decls_end() &&
(F = dyn_cast<FunctionDecl>(*ULE->decls_begin())) &&
F->getBuiltinID() && F->isImplicit())
- assert(0 && "performing ADL for builtin");
+ llvm_unreachable("performing ADL for builtin");
// We don't perform ADL in C.
assert(getLangOptions().CPlusPlus && "ADL enabled in C");
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index 274c74c..c75e337 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -1387,7 +1387,7 @@
else {
// Can't be a DependentSizedArrayType or an IncompleteArrayType since
// UnqAT is not incomplete and Range is not type-dependent.
- assert(0 && "Unexpected array type in for-range");
+ llvm_unreachable("Unexpected array type in for-range");
return StmtError();
}
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 43fdcb6..4f90a72 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -2323,7 +2323,8 @@
return TNK_Dependent_template_name;
case UnqualifiedId::IK_LiteralOperatorId:
- assert(false && "We don't support these; Parse shouldn't have allowed propagation");
+ llvm_unreachable(
+ "We don't support these; Parse shouldn't have allowed propagation");
default:
break;
@@ -2681,7 +2682,7 @@
switch (Arg.getArgument().getKind()) {
case TemplateArgument::Null:
- assert(false && "Should never see a NULL template argument here");
+ llvm_unreachable("Should never see a NULL template argument here");
return true;
case TemplateArgument::Expression: {
@@ -2804,7 +2805,7 @@
switch (Arg.getArgument().getKind()) {
case TemplateArgument::Null:
- assert(false && "Should never see a NULL template argument here");
+ llvm_unreachable("Should never see a NULL template argument here");
return true;
case TemplateArgument::Template:
@@ -5216,7 +5217,7 @@
switch (NewTSK) {
case TSK_Undeclared:
case TSK_ImplicitInstantiation:
- assert(false && "Don't check implicit instantiations here");
+ llvm_unreachable("Don't check implicit instantiations here");
return false;
case TSK_ExplicitSpecialization:
@@ -5349,7 +5350,7 @@
break;
}
- assert(false && "Missing specialization/instantiation case?");
+ llvm_unreachable("Missing specialization/instantiation case?");
return false;
}
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index add8e10..283cc57 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -1539,7 +1539,7 @@
switch (Param.getKind()) {
case TemplateArgument::Null:
- assert(false && "Null template argument in parameter list");
+ llvm_unreachable("Null template argument in parameter list");
break;
case TemplateArgument::Type:
@@ -1830,7 +1830,7 @@
switch (X.getKind()) {
case TemplateArgument::Null:
- assert(false && "Comparing NULL template argument");
+ llvm_unreachable("Comparing NULL template argument");
break;
case TemplateArgument::Type:
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp
index ffd7955..d440624 100644
--- a/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -96,7 +96,7 @@
Decl *
TemplateDeclInstantiator::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
- assert(false && "Translation units cannot be instantiated");
+ llvm_unreachable("Translation units cannot be instantiated");
return D;
}
@@ -110,7 +110,7 @@
Decl *
TemplateDeclInstantiator::VisitNamespaceDecl(NamespaceDecl *D) {
- assert(false && "Namespaces cannot be instantiated");
+ llvm_unreachable("Namespaces cannot be instantiated");
return D;
}
@@ -701,7 +701,7 @@
}
Decl *TemplateDeclInstantiator::VisitEnumConstantDecl(EnumConstantDecl *D) {
- assert(false && "EnumConstantDecls can only occur within EnumDecls.");
+ llvm_unreachable("EnumConstantDecls can only occur within EnumDecls.");
return 0;
}
@@ -3308,7 +3308,7 @@
// and removed the need for implicit instantiation.
switch (Var->getMostRecentDeclaration()->getTemplateSpecializationKind()) {
case TSK_Undeclared:
- assert(false && "Cannot instantitiate an undeclared specialization.");
+ llvm_unreachable("Cannot instantitiate an undeclared specialization.");
case TSK_ExplicitInstantiationDeclaration:
case TSK_ExplicitSpecialization:
continue; // No longer need to instantiate this type.
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 6b98ed8..2b4a509 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -1750,7 +1750,7 @@
switch (D.getContext()) {
case Declarator::KNRTypeListContext:
- assert(0 && "K&R type lists aren't allowed in C++");
+ llvm_unreachable("K&R type lists aren't allowed in C++");
break;
case Declarator::ObjCPrototypeContext:
case Declarator::PrototypeContext:
@@ -1760,7 +1760,7 @@
if (D.getDeclSpec().getStorageClassSpec() == DeclSpec::SCS_static)
break;
switch (cast<TagDecl>(SemaRef.CurContext)->getTagKind()) {
- case TTK_Enum: assert(0 && "unhandled tag kind"); break;
+ case TTK_Enum: llvm_unreachable("unhandled tag kind"); break;
case TTK_Struct: Error = 1; /* Struct member */ break;
case TTK_Union: Error = 2; /* Union member */ break;
case TTK_Class: Error = 3; /* Class member */ break;
@@ -1921,7 +1921,7 @@
state.setCurrentChunkIndex(chunkIndex);
DeclaratorChunk &DeclType = D.getTypeObject(chunkIndex);
switch (DeclType.Kind) {
- default: assert(0 && "Unknown decltype!");
+ default: llvm_unreachable("Unknown decltype!");
case DeclaratorChunk::Paren:
T = S.BuildParenType(T);
break;
@@ -3035,7 +3035,7 @@
void LocInfoType::getAsStringInternal(std::string &Str,
const PrintingPolicy &Policy) const {
- assert(false && "LocInfoType leaked into the type system; an opaque TypeTy*"
+ llvm_unreachable("LocInfoType leaked into the type system; an opaque TypeTy*"
" was used directly instead of getting the QualType through"
" GetTypeFromParser");
}
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 2737681..0c22c61 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -1728,7 +1728,7 @@
SubExpr, RParenLoc);
default:
- assert(false && "Invalid C++ named cast");
+ llvm_unreachable("Invalid C++ named cast");
break;
}
@@ -2681,7 +2681,7 @@
}
}
- assert(0 && "Unknown name kind.");
+ llvm_unreachable("Unknown name kind.");
return DeclarationNameInfo();
}
@@ -8049,7 +8049,7 @@
template<typename Derived>
ExprResult
TreeTransform<Derived>::TransformAsTypeExpr(AsTypeExpr *E) {
- assert(false && "Cannot transform asType expressions yet");
+ llvm_unreachable("Cannot transform asType expressions yet");
return SemaRef.Owned(E);
}