Index: include/clang/AST/Redeclarable.h =================================================================== --- include/clang/AST/Redeclarable.h +++ include/clang/AST/Redeclarable.h @@ -255,7 +255,7 @@ // Sanity check to avoid infinite loop on invalid redecl chain. 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; } Index: lib/AST/ExprConstant.cpp =================================================================== --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -4574,7 +4574,7 @@ if (!Source) return Error(E); if (Source == E) { // sanity checking. - assert(0 && "OpaqueValueExpr recursively refers to itself"); + llvm_unreachable("OpaqueValueExpr recursively refers to itself"); return Error(E); } return StmtVisitorTy::Visit(Source); Index: lib/Basic/SourceManager.cpp =================================================================== --- lib/Basic/SourceManager.cpp +++ lib/Basic/SourceManager.cpp @@ -69,7 +69,7 @@ void ContentCache::replaceBuffer(llvm::MemoryBuffer *B, bool DoNotFree) { if (B && B == Buffer.getPointer()) { - assert(0 && "Replacing with the same buffer"); + llvm_unreachable("Replacing with the same buffer"); Buffer.setInt(DoNotFree? DoNotFreeFlag : 0); return; } @@ -781,7 +781,7 @@ FileID SourceManager::getFileIDLoaded(unsigned SLocOffset) const { // Sanity checking, otherwise a bug may lead to hanging in release build. if (SLocOffset < CurrentLoadedOffset) { - assert(0 && "Invalid SLocOffset or bad function choice"); + llvm_unreachable("Invalid SLocOffset or bad function choice"); return FileID(); } @@ -828,7 +828,7 @@ if (E.getOffset() > SLocOffset) { // Sanity checking, otherwise a bug may lead to hanging in release build. if (GreaterIndex == MiddleIndex) { - assert(0 && "binary search missed the entry"); + llvm_unreachable("binary search missed the entry"); return FileID(); } GreaterIndex = MiddleIndex; @@ -845,7 +845,7 @@ // Sanity checking, otherwise a bug may lead to hanging in release build. if (LessIndex == MiddleIndex) { - assert(0 && "binary search missed the entry"); + llvm_unreachable("binary search missed the entry"); return FileID(); } LessIndex = MiddleIndex; Index: lib/Lex/PreprocessingRecord.cpp =================================================================== --- lib/Lex/PreprocessingRecord.cpp +++ lib/Lex/PreprocessingRecord.cpp @@ -86,7 +86,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"); @@ -109,7 +109,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], Index: lib/Sema/SemaType.cpp =================================================================== --- lib/Sema/SemaType.cpp +++ lib/Sema/SemaType.cpp @@ -6775,7 +6775,7 @@ break; #include "clang/Basic/OpenCLImageTypes.def" default: - assert(0 && "Unable to find corresponding image type."); + llvm_unreachable("Unable to find corresponding image type."); } S.Diag(TypedefTy->getDecl()->getLocStart(), Index: lib/Serialization/ASTReader.cpp =================================================================== --- lib/Serialization/ASTReader.cpp +++ lib/Serialization/ASTReader.cpp @@ -7032,7 +7032,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; } @@ -7047,7 +7047,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; } Index: lib/Serialization/ASTWriter.cpp =================================================================== --- lib/Serialization/ASTWriter.cpp +++ lib/Serialization/ASTWriter.cpp @@ -2492,7 +2492,7 @@ MacroID ID = MacroInfosToEmit[I].ID; if (ID < FirstMacroID) { - assert(0 && "Loaded MacroInfo entered MacroInfosToEmit ?"); + llvm_unreachable("Loaded MacroInfo entered MacroInfosToEmit ?"); continue; } @@ -5328,7 +5328,7 @@ 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(); } @@ -5374,7 +5374,7 @@ 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; } Index: tools/c-index-test/c-index-test.c =================================================================== --- tools/c-index-test/c-index-test.c +++ tools/c-index-test/c-index-test.c @@ -3114,7 +3114,7 @@ case CXIdxEntity_CXXTypeAlias: return "type-alias"; case CXIdxEntity_CXXInterface: return "c++-__interface"; } - assert(0 && "Garbage entity kind"); + llvm_unreachable("Garbage entity kind"); return 0; } @@ -3126,7 +3126,7 @@ return "-template-partial-spec"; case CXIdxEntity_TemplateSpecialization: return "-template-spec"; } - assert(0 && "Garbage entity kind"); + llvm_unreachable("Garbage entity kind"); return 0; } @@ -3138,7 +3138,7 @@ case CXIdxEntityLang_CXX: return "C++"; case CXIdxEntityLang_Swift: return "Swift"; } - assert(0 && "Garbage language kind"); + llvm_unreachable("Garbage language kind"); return 0; } Index: tools/libclang/CXCursor.cpp =================================================================== --- tools/libclang/CXCursor.cpp +++ tools/libclang/CXCursor.cpp @@ -1280,12 +1280,12 @@ TemplateArgument TA; if (clang_Cursor_getTemplateArgument(C, I, &TA) != CXGetTemplateArgumentStatus_Success) { - assert(0 && "Unable to retrieve TemplateArgument"); + llvm_unreachable("Unable to retrieve TemplateArgument"); return 0; } if (TA.getKind() != TemplateArgument::Integral) { - assert(0 && "Passed template argument is not Integral"); + llvm_unreachable("Passed template argument is not Integral"); return 0; } @@ -1297,12 +1297,12 @@ TemplateArgument TA; if (clang_Cursor_getTemplateArgument(C, I, &TA) != CXGetTemplateArgumentStatus_Success) { - assert(0 && "Unable to retrieve TemplateArgument"); + llvm_unreachable("Unable to retrieve TemplateArgument"); return 0; } if (TA.getKind() != TemplateArgument::Integral) { - assert(0 && "Passed template argument is not Integral"); + llvm_unreachable("Passed template argument is not Integral"); return 0; }