diff --git a/clang/include/clang/AST/Redeclarable.h b/clang/include/clang/AST/Redeclarable.h --- a/clang/include/clang/AST/Redeclarable.h +++ b/clang/include/clang/AST/Redeclarable.h @@ -262,7 +262,7 @@ // should never happen. if (Current->isFirstDecl()) { if (PassedFirst) { - assert(0 && "Passed first decl twice, invalid redecl chain!"); + llvm_unreachable("Passed first decl twice, invalid redecl chain!"); Current = nullptr; return *this; } diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h @@ -598,7 +598,7 @@ } assert(isa(FD)); - assert(false && "Getting the type of ObjCMethod is not supported yet"); + llvm_unreachable("Getting the type of ObjCMethod is not supported yet"); // TODO: We might want to return a different type here (ex: id (*ty)(...)) // depending on how it is used. diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -9973,7 +9973,7 @@ } } else { - assert(0 && "CompleteDecl called on a Decl that can't be completed"); + llvm_unreachable("CompleteDecl called on a Decl that can't be completed"); } } diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -7559,7 +7559,7 @@ if (!Source) return Error(E); if (Source == E) { - assert(0 && "OpaqueValueExpr recursively refers to itself"); + llvm_unreachable("OpaqueValueExpr recursively refers to itself"); return Error(E); } return StmtVisitorTy::Visit(Source); diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -134,7 +134,7 @@ return discard(SubExpr); default: - assert(false && "Cast not implemented"); + llvm_unreachable("Cast not implemented"); } llvm_unreachable("Unhandled clang::CastKind enum"); } @@ -595,14 +595,14 @@ if (!this->emitInitElem(*T, ElementIndex, Init)) return false; } else { - assert(false && "Unhandled type in array initializer initlist"); + llvm_unreachable("Unhandled type in array initializer initlist"); } ++ElementIndex; } } else { - assert(false && "Unknown expression for array initialization"); + llvm_unreachable("Unknown expression for array initialization"); } return true; @@ -754,11 +754,11 @@ return this->emitCall(*T, Func, E); return this->emitCallVoid(Func, E); } else { - assert(false && "Can't classify function return type"); + llvm_unreachable("Can't classify function return type"); } } else { - assert(false && "We don't support non-FunctionDecl callees right now."); + llvm_unreachable("We don't support non-FunctionDecl callees right now."); } return false; @@ -831,7 +831,7 @@ case UO_Imag: // __imag x case UO_Extension: case UO_Coawait: - assert(false && "Unhandled opcode"); + llvm_unreachable("Unhandled opcode"); } return false; diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -1043,7 +1043,7 @@ case UO_LNot: return llvm::APInt(Context->getTypeSize(Context->IntTy), !Value); default: - assert(false && "Unexpected unary operator!"); + llvm_unreachable("Unexpected unary operator!"); return llvm::None; } } diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -60,7 +60,7 @@ /// this content cache. This is used for performance analysis. llvm::MemoryBuffer::BufferKind ContentCache::getMemoryBufferKind() const { if (Buffer == nullptr) { - assert(0 && "Buffer should never be null"); + llvm_unreachable("Buffer should never be null"); return llvm::MemoryBuffer::MemoryBuffer_Malloc; } return Buffer->getBufferKind(); @@ -861,7 +861,7 @@ /// local one. FileID SourceManager::getFileIDLoaded(SourceLocation::UIntTy SLocOffset) const { if (SLocOffset < CurrentLoadedOffset) { - assert(0 && "Invalid SLocOffset or bad function choice"); + llvm_unreachable("Invalid SLocOffset or bad function choice"); return FileID(); } @@ -908,7 +908,7 @@ if (E.getOffset() > SLocOffset) { if (GreaterIndex == MiddleIndex) { - assert(0 && "binary search missed the entry"); + llvm_unreachable("binary search missed the entry"); return FileID(); } GreaterIndex = MiddleIndex; @@ -923,7 +923,7 @@ } if (LessIndex == MiddleIndex) { - assert(0 && "binary search missed the entry"); + llvm_unreachable("binary search missed the entry"); return FileID(); } LessIndex = MiddleIndex; diff --git a/clang/lib/Basic/Targets/NVPTX.cpp b/clang/lib/Basic/Targets/NVPTX.cpp --- a/clang/lib/Basic/Targets/NVPTX.cpp +++ b/clang/lib/Basic/Targets/NVPTX.cpp @@ -210,7 +210,7 @@ break; case CudaArch::UNUSED: case CudaArch::UNKNOWN: - assert(false && "No GPU arch when compiling CUDA device code."); + llvm_unreachable("No GPU arch when compiling CUDA device code."); return ""; case CudaArch::SM_20: return "200"; diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp b/clang/lib/CodeGen/CGHLSLRuntime.cpp --- a/clang/lib/CodeGen/CGHLSLRuntime.cpp +++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp @@ -86,7 +86,7 @@ ResourceMD = CGM.getModule().getOrInsertNamedMetadata("hlsl.uavs"); break; default: - assert(false && "Unsupported buffer type!"); + llvm_unreachable("Unsupported buffer type!"); return; } @@ -125,7 +125,7 @@ CGM.getIntrinsic(Intrinsic::dx_flattened_thread_id_in_group); return B.CreateCall(FunctionCallee(DxGroupIndex)); } - assert(false && "Unhandled parameter attribute"); + llvm_unreachable("Unhandled parameter attribute"); return nullptr; } diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -3703,7 +3703,8 @@ Options.emplace_back(cast(Func), Architecture, Feature); } } else { - assert(0 && "Expected a target or target_clones multiversion function"); + llvm_unreachable( + "Expected a target or target_clones multiversion function"); continue; } diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp --- a/clang/lib/Driver/Multilib.cpp +++ b/clang/lib/Driver/Multilib.cpp @@ -277,7 +277,7 @@ } // TODO: We should consider returning llvm::Error rather than aborting. - assert(false && "More than one multilib with the same priority"); + llvm_unreachable("More than one multilib with the same priority"); return false; } diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -112,12 +112,12 @@ } else if (JA.getType() == types::TY_PP_Asm) { CmdArgs.push_back("-S"); } else { - assert(false && "Unexpected output type!"); + llvm_unreachable("Unexpected output type!"); } } else if (isa(JA)) { CmdArgs.push_back("-emit-obj"); } else { - assert(false && "Unexpected action class for Flang tool."); + llvm_unreachable("Unexpected action class for Flang tool."); } const InputInfo &Input = Inputs[0]; diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -2476,7 +2476,7 @@ // for the release version. if (Err) { llvm::errs() << llvm::toString(std::move(Err)) << "\n"; - assert(false && "Fixes must not conflict!"); + llvm_unreachable("Fixes must not conflict!"); } Idx = End + 1; } diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp --- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -3646,7 +3646,7 @@ else if (RD->isUnion()) Result += "\n\tunion "; else - assert(false && "class not allowed as an ivar type"); + llvm_unreachable("class not allowed as an ivar type"); Result += RD->getName(); if (GlobalDefinedTags.count(RD)) { @@ -4580,7 +4580,7 @@ = dyn_cast(BlockExp)) { CPT = POE->getType()->castAs(); } else { - assert(false && "RewriteBlockClass: Bad type"); + llvm_unreachable("RewriteBlockClass: Bad type"); } assert(CPT && "RewriteBlockClass: Bad type"); const FunctionType *FT = CPT->getPointeeType()->getAs(); diff --git a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp --- a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -3747,7 +3747,7 @@ = dyn_cast(BlockExp)) { CPT = POE->getType()->castAs(); } else { - assert(false && "RewriteBlockClass: Bad type"); + llvm_unreachable("RewriteBlockClass: Bad type"); } assert(CPT && "RewriteBlockClass: Bad type"); const FunctionType *FT = CPT->getPointeeType()->getAs(); diff --git a/clang/lib/Frontend/SARIFDiagnostic.cpp b/clang/lib/Frontend/SARIFDiagnostic.cpp --- a/clang/lib/Frontend/SARIFDiagnostic.cpp +++ b/clang/lib/Frontend/SARIFDiagnostic.cpp @@ -155,7 +155,7 @@ Config = Config.setLevel(SarifResultLevel::Error).setRank(100); break; case DiagnosticsEngine::Ignored: - assert(false && "Invalid diagnostic type"); + llvm_unreachable("Invalid diagnostic type"); } return Rule.setDefaultConfiguration(Config); @@ -205,21 +205,21 @@ void SARIFDiagnostic::emitDiagnosticLoc(FullSourceLoc Loc, PresumedLoc PLoc, DiagnosticsEngine::Level Level, ArrayRef Ranges) { - assert(false && "Not implemented in SARIF mode"); + llvm_unreachable("Not implemented in SARIF mode"); } void SARIFDiagnostic::emitIncludeLocation(FullSourceLoc Loc, PresumedLoc PLoc) { - assert(false && "Not implemented in SARIF mode"); + llvm_unreachable("Not implemented in SARIF mode"); } void SARIFDiagnostic::emitImportLocation(FullSourceLoc Loc, PresumedLoc PLoc, StringRef ModuleName) { - assert(false && "Not implemented in SARIF mode"); + llvm_unreachable("Not implemented in SARIF mode"); } void SARIFDiagnostic::emitBuildingModuleLocation(FullSourceLoc Loc, PresumedLoc PLoc, StringRef ModuleName) { - assert(false && "Not implemented in SARIF mode"); + llvm_unreachable("Not implemented in SARIF mode"); } } // namespace clang diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -3486,7 +3486,7 @@ Callbacks->Elifndef(ElifToken.getLocation(), ConditionRange, CI.IfLoc); break; default: - assert(false && "unexpected directive kind"); + llvm_unreachable("unexpected directive kind"); break; } } diff --git a/clang/lib/Lex/PreprocessingRecord.cpp b/clang/lib/Lex/PreprocessingRecord.cpp --- a/clang/lib/Lex/PreprocessingRecord.cpp +++ b/clang/lib/Lex/PreprocessingRecord.cpp @@ -102,7 +102,7 @@ int Pos = std::distance(iterator(this, 0), PPEI); if (Pos < 0) { if (unsigned(-Pos-1) >= LoadedPreprocessedEntities.size()) { - assert(0 && "Out-of bounds loaded preprocessed entity"); + llvm_unreachable("Out-of bounds loaded preprocessed entity"); return false; } assert(ExternalSource && "No external source to load from"); @@ -125,7 +125,7 @@ } if (unsigned(Pos) >= PreprocessedEntities.size()) { - assert(0 && "Out-of bounds local preprocessed entity"); + llvm_unreachable("Out-of bounds local preprocessed entity"); return false; } return isPreprocessedEntityIfInFileID(PreprocessedEntities[Pos], diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -3558,7 +3558,7 @@ // Eat the parens and everything between them. BalancedDelimiterTracker T(*this, tok::l_paren); if (T.consumeOpen()) { - assert(false && "Not a left paren?"); + llvm_unreachable("Not a left paren?"); return; } T.skipToEnd(); diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -8110,7 +8110,7 @@ TheCall->setType(Context.LongLongTy); return false; } - assert(false && "Unhandled ARM MTE intrinsic"); + llvm_unreachable("Unhandled ARM MTE intrinsic"); return true; } diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -548,7 +548,7 @@ case tok::kw___imag: return QualType(); default: - assert(false && "unhandled unary op"); + llvm_unreachable("unhandled unary op"); return QualType(); } } diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -7464,7 +7464,7 @@ unsigned Index = ID - NUM_PREDEF_DECL_IDS; if (Index >= DeclsLoaded.size()) { - assert(0 && "declaration ID out-of-range for AST file"); + llvm_unreachable("declaration ID out-of-range for AST file"); Error("declaration ID out-of-range for AST file"); return nullptr; } @@ -7479,7 +7479,7 @@ unsigned Index = ID - NUM_PREDEF_DECL_IDS; if (Index >= DeclsLoaded.size()) { - assert(0 && "declaration ID out-of-range for AST file"); + llvm_unreachable("declaration ID out-of-range for AST file"); Error("declaration ID out-of-range for AST file"); return nullptr; } diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -2438,7 +2438,7 @@ MacroID ID = MacroInfosToEmit[I].ID; if (ID < FirstMacroID) { - assert(0 && "Loaded MacroInfo entered MacroInfosToEmit ?"); + llvm_unreachable("Loaded MacroInfo entered MacroInfosToEmit ?"); continue; } @@ -5381,7 +5381,8 @@ TypeIdx &Idx = TypeIdxs[T]; if (Idx.getIndex() == 0) { if (DoneWritingDeclsAndTypes) { - assert(0 && "New type seen after serializing all the types to emit!"); + llvm_unreachable( + "New type seen after serializing all the types to emit!"); return TypeIdx(); } @@ -5427,7 +5428,8 @@ DeclID &ID = DeclIDs[D]; if (ID == 0) { if (DoneWritingDeclsAndTypes) { - assert(0 && "New decl seen after serializing all the decls to emit!"); + llvm_unreachable( + "New decl seen after serializing all the decls to emit!"); return 0; } diff --git a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp --- a/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp @@ -192,7 +192,7 @@ break; case ProgramPoint::BlockExitKind: - assert(false && "BlockExit location never occur in forward analysis."); + llvm_unreachable("BlockExit location never occur in forward analysis."); break; case ProgramPoint::CallEnterKind: diff --git a/clang/lib/StaticAnalyzer/Core/SVals.cpp b/clang/lib/StaticAnalyzer/Core/SVals.cpp --- a/clang/lib/StaticAnalyzer/Core/SVals.cpp +++ b/clang/lib/StaticAnalyzer/Core/SVals.cpp @@ -355,7 +355,7 @@ break; } default: - assert(false && "Pretty-printed not implemented for this NonLoc."); + llvm_unreachable("Pretty-printed not implemented for this NonLoc."); break; } } diff --git a/clang/tools/clang-refactor/TestSupport.cpp b/clang/tools/clang-refactor/TestSupport.cpp --- a/clang/tools/clang-refactor/TestSupport.cpp +++ b/clang/tools/clang-refactor/TestSupport.cpp @@ -348,7 +348,7 @@ if (!Matches[2].empty()) { // Don't forget to drop the '+'! if (Matches[2].drop_front().getAsInteger(10, ColumnOffset)) - assert(false && "regex should have produced a number"); + llvm_unreachable("regex should have produced a number"); } Offset = addColumnOffset(Source, Offset, ColumnOffset); unsigned EndOffset; @@ -365,7 +365,7 @@ unsigned EndLineOffset = 0, EndColumn = 0; if (EndLocMatches[1].drop_front().getAsInteger(10, EndLineOffset) || EndLocMatches[2].getAsInteger(10, EndColumn)) - assert(false && "regex should have produced a number"); + llvm_unreachable("regex should have produced a number"); EndOffset = addEndLineOffsetAndEndColumn(Source, Offset, EndLineOffset, EndColumn); } else {