]> granicus.if.org Git - clang/commitdiff
Switch assert(0/false) llvm_unreachable.
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 23 Sep 2011 05:06:16 +0000 (05:06 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 23 Sep 2011 05:06:16 +0000 (05:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140367 91177308-0d34-0410-b5e6-96231b3b80d8

117 files changed:
include/clang/AST/Attr.h
include/clang/AST/DeclTemplate.h
include/clang/AST/DeclVisitor.h
include/clang/AST/Mangle.h
include/clang/AST/RecursiveASTVisitor.h
include/clang/AST/Stmt.h
include/clang/AST/StmtVisitor.h
include/clang/AST/Type.h
include/clang/AST/TypeVisitor.h
include/clang/Analysis/Visitors/CFGRecStmtDeclVisitor.h
include/clang/Analysis/Visitors/CFGRecStmtVisitor.h
include/clang/Sema/DeclSpec.h
lib/AST/APValue.cpp
lib/AST/ASTContext.cpp
lib/AST/ASTDiagnostic.cpp
lib/AST/ASTImporter.cpp
lib/AST/Decl.cpp
lib/AST/DeclBase.cpp
lib/AST/DeclCXX.cpp
lib/AST/DeclObjC.cpp
lib/AST/DeclPrinter.cpp
lib/AST/DeclarationName.cpp
lib/AST/Expr.cpp
lib/AST/ExprConstant.cpp
lib/AST/ItaniumMangle.cpp
lib/AST/MicrosoftMangle.cpp
lib/AST/StmtDumper.cpp
lib/AST/StmtPrinter.cpp
lib/AST/TemplateBase.cpp
lib/Analysis/CFG.cpp
lib/Analysis/FormatString.cpp
lib/Analysis/PrintfFormatString.cpp
lib/Basic/DiagnosticIDs.cpp
lib/Basic/TargetInfo.cpp
lib/Basic/Targets.cpp
lib/CodeGen/CGBuiltin.cpp
lib/CodeGen/CGCall.cpp
lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGDecl.cpp
lib/CodeGen/CGExpr.cpp
lib/CodeGen/CGExprAgg.cpp
lib/CodeGen/CGExprComplex.cpp
lib/CodeGen/CGExprConstant.cpp
lib/CodeGen/CGExprScalar.cpp
lib/CodeGen/CGObjCGNU.cpp
lib/CodeGen/CGObjCMac.cpp
lib/CodeGen/CGObjCRuntime.h
lib/CodeGen/CGRTTI.cpp
lib/CodeGen/CGStmt.cpp
lib/CodeGen/CGVTables.cpp
lib/CodeGen/CodeGenAction.cpp
lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/CodeGenTypes.cpp
lib/CodeGen/TargetInfo.cpp
lib/Driver/Action.cpp
lib/Driver/Driver.cpp
lib/Driver/OptTable.cpp
lib/Driver/Option.cpp
lib/Driver/Phases.cpp
lib/Driver/ToolChains.cpp
lib/Driver/Tools.cpp
lib/Frontend/ASTConsumers.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Frontend/TextDiagnosticBuffer.cpp
lib/Frontend/TextDiagnosticPrinter.cpp
lib/Index/ASTLocation.cpp
lib/Lex/LiteralSupport.cpp
lib/Lex/PPExpressions.cpp
lib/Lex/PPMacroExpansion.cpp
lib/Lex/Pragma.cpp
lib/Parse/ParseExpr.cpp
lib/Parse/ParseExprCXX.cpp
lib/Parse/ParseObjc.cpp
lib/Rewrite/RewriteObjC.cpp
lib/Sema/DeclSpec.cpp
lib/Sema/IdentifierResolver.cpp
lib/Sema/SemaAttr.cpp
lib/Sema/SemaCXXScopeSpec.cpp
lib/Sema/SemaChecking.cpp
lib/Sema/SemaCodeComplete.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclAttr.cpp
lib/Sema/SemaDeclCXX.cpp
lib/Sema/SemaDeclObjC.cpp
lib/Sema/SemaExceptionSpec.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaInit.cpp
lib/Sema/SemaOverload.cpp
lib/Sema/SemaStmt.cpp
lib/Sema/SemaTemplate.cpp
lib/Sema/SemaTemplateDeduction.cpp
lib/Sema/SemaTemplateInstantiateDecl.cpp
lib/Sema/SemaType.cpp
lib/Sema/TreeTransform.h
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriter.cpp
lib/Serialization/ASTWriterDecl.cpp
lib/Serialization/ASTWriterStmt.cpp
lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
lib/StaticAnalyzer/Core/AggExprVisitor.cpp
lib/StaticAnalyzer/Core/BugReporter.cpp
lib/StaticAnalyzer/Core/CoreEngine.cpp
lib/StaticAnalyzer/Core/ExprEngine.cpp
lib/StaticAnalyzer/Core/ExprEngineC.cpp
lib/StaticAnalyzer/Core/RegionStore.cpp
lib/StaticAnalyzer/Core/SVals.cpp
lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
lib/StaticAnalyzer/Core/Store.cpp
lib/StaticAnalyzer/Core/SymbolManager.cpp
lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
tools/libclang/CIndex.cpp
tools/libclang/CIndexDiagnostic.cpp
tools/libclang/CIndexUSRs.cpp
tools/libclang/CIndexer.cpp

index 2f0eafa5c1d67c35198a91e901f31cfddf25a356..67975e4f9c81783c390ac47a21cb7fac1919f239 100644 (file)
@@ -66,11 +66,11 @@ protected:
   virtual ~Attr();
   
   void* operator new(size_t bytes) throw() {
-    assert(0 && "Attrs cannot be allocated with regular 'new'.");
+    llvm_unreachable("Attrs cannot be allocated with regular 'new'.");
     return 0;
   }
   void operator delete(void* data) throw() {
-    assert(0 && "Attrs cannot be released with regular 'delete'.");
+    llvm_unreachable("Attrs cannot be released with regular 'delete'.");
   }
 
 public:
index 04c6674426a327fd20cb033fd9a0494c9fecd7ce..138e47d1a96d4f8def6c0377d5154fe1663a9935 100644 (file)
@@ -908,7 +908,7 @@ protected:
   // FIXME: This should probably never be called, but it's here as
   TemplateParmPosition()
     : Depth(0), Position(0)
-  { /* assert(0 && "Cannot create positionless template parameter"); */ }
+  { /* llvm_unreachable("Cannot create positionless template parameter"); */ }
 
   TemplateParmPosition(unsigned D, unsigned P)
     : Depth(D), Position(P)
index aee1998028eba7c8d7bd80e4db42ad740f2a342a..b5b6bd42ddb151b72fc321cfd1073e6a108cb6f1 100644 (file)
@@ -30,7 +30,7 @@ class DeclVisitor {
 public:
   RetTy Visit(Decl *D) {
     switch (D->getKind()) {
-      default: assert(false && "Decl that isn't part of DeclNodes.inc!");
+      default: llvm_unreachable("Decl that isn't part of DeclNodes.inc!");
 #define DECL(DERIVED, BASE) \
       case Decl::DERIVED: DISPATCH(DERIVED##Decl, DERIVED##Decl);
 #define ABSTRACT_DECL(DECL)
index d40e101b2b3e695e12a41b0b2ac6197aa7d1a6d3..fcb7ebdba54becff5318a37e2cbc069d53c1679d 100644 (file)
@@ -135,7 +135,7 @@ public:
   // This is pretty lame.
   virtual void mangleItaniumGuardVariable(const VarDecl *D,
                                           raw_ostream &) {
-    assert(0 && "Target does not support mangling guard variables");
+    llvm_unreachable("Target does not support mangling guard variables");
   }
   /// @}
 };
index f4c8bae7d14fbe310e2b074f948e4999ea249151..36add6c457595a25cb3836c51b3e0cd813907ac7 100644 (file)
@@ -1322,7 +1322,7 @@ bool RecursiveASTVisitor<Derived>::TraverseFunctionInstantiations(
     case TSK_ExplicitSpecialization:
       break;
     default:
-      assert(false && "Unknown specialization kind.");
+      llvm_unreachable("Unknown specialization kind.");
     }
   }
 
index 34b8a12f40e98e918b8eb619b35366e48faa2e31..c186b4896e473a6577ae716dcee236822a7e4e3d 100644 (file)
@@ -107,11 +107,11 @@ public:
   // Make vanilla 'new' and 'delete' illegal for Stmts.
 protected:
   void* operator new(size_t bytes) throw() {
-    assert(0 && "Stmts cannot be allocated with regular 'new'.");
+    llvm_unreachable("Stmts cannot be allocated with regular 'new'.");
     return 0;
   }
   void operator delete(void* data) throw() {
-    assert(0 && "Stmts cannot be released with regular 'delete'.");
+    llvm_unreachable("Stmts cannot be released with regular 'delete'.");
   }
 
   class StmtBitfields {
index 29d234754645ec9163ca9f412cf80e5906cbeeca..48a0123608c9c78387ac50b77d073a756688387d 100644 (file)
@@ -42,7 +42,7 @@ public:
     // below.
     if (PTR(BinaryOperator) BinOp = dyn_cast<BinaryOperator>(S)) {
       switch (BinOp->getOpcode()) {
-      default: assert(0 && "Unknown binary operator!");
+      default: llvm_unreachable("Unknown binary operator!");
       case BO_PtrMemD:   DISPATCH(BinPtrMemD,   BinaryOperator);
       case BO_PtrMemI:   DISPATCH(BinPtrMemI,   BinaryOperator);
       case BO_Mul:       DISPATCH(BinMul,       BinaryOperator);
@@ -80,7 +80,7 @@ public:
       }
     } else if (PTR(UnaryOperator) UnOp = dyn_cast<UnaryOperator>(S)) {
       switch (UnOp->getOpcode()) {
-      default: assert(0 && "Unknown unary operator!");
+      default: llvm_unreachable("Unknown unary operator!");
       case UO_PostInc:   DISPATCH(UnaryPostInc,   UnaryOperator);
       case UO_PostDec:   DISPATCH(UnaryPostDec,   UnaryOperator);
       case UO_PreInc:    DISPATCH(UnaryPreInc,    UnaryOperator);
@@ -99,7 +99,7 @@ public:
 
     // Top switch stmt: dispatch to VisitFooStmt for each FooStmt.
     switch (S->getStmtClass()) {
-    default: assert(0 && "Unknown stmt kind!");
+    default: llvm_unreachable("Unknown stmt kind!");
 #define ABSTRACT_STMT(STMT)
 #define STMT(CLASS, PARENT)                              \
     case Stmt::CLASS ## Class: DISPATCH(CLASS, CLASS);
index e68d206f21dabeb5514024fce0b7eb72c63c7a1e..ad7ab2796885a21764eb2127ccf01e6d8e198122 100644 (file)
@@ -2252,7 +2252,7 @@ public:
   friend class StmtIteratorBase;
 
   void Profile(llvm::FoldingSetNodeID &ID) {
-    assert(0 && "Cannot unique VariableArrayTypes.");
+    llvm_unreachable("Cannot unique VariableArrayTypes.");
   }
 };
 
index c52926b1fc31d6cc720471f130c40c5331800bd0..9eebc4b9ea070aaa4a268c3ed7dedf7ca0b19b58 100644 (file)
@@ -28,7 +28,7 @@ public:
   RetTy Visit(const Type *T) {
     // Top switch stmt: dispatch to VisitFooType for each FooType.
     switch (T->getTypeClass()) {
-    default: assert(0 && "Unknown type class!");
+    default: llvm_unreachable("Unknown type class!");
 #define ABSTRACT_TYPE(CLASS, PARENT)
 #define TYPE(CLASS, PARENT) case Type::CLASS: DISPATCH(CLASS##Type);
 #include "clang/AST/TypeNodes.def"
index 9d7f8107dbdba2ef489c28a991a1e76bca2d8772..5c5ec2d7afd8f8b314549479fd2100005ddb0f90 100644 (file)
@@ -69,7 +69,7 @@ public:
         DISPATCH_CASE(UsingDirective)
         DISPATCH_CASE(Using)
       default:
-        assert(false && "Subtype of ScopedDecl not handled.");
+        llvm_unreachable("Subtype of ScopedDecl not handled.");
     }
   }
 
index 55212b463e81b19f0b5fa9becd873c1c5e7154dd..4d1cabfc5c0b317c890579dc781c8bf39a49897f 100644 (file)
@@ -45,7 +45,7 @@ break;
         CONDVAR_CASE(WhileStmt)
 #undef CONDVAR_CASE
       default:
-        assert(false && "Infeasible");
+        llvm_unreachable("Infeasible");
     }    
     static_cast<ImplClass*>(this)->Visit(CondVar->getInit());
   }
index 177de65a34fe047a126cd79522c40d1da5e209ba..392284f8d598fc598eaf605f343fa0dea9df529d 100644 (file)
@@ -1226,7 +1226,7 @@ struct DeclaratorChunk {
 
   void destroy() {
     switch (Kind) {
-    default: assert(0 && "Unknown decl type!");
+    default: llvm_unreachable("Unknown decl type!");
     case DeclaratorChunk::Function:      return Fun.destroy();
     case DeclaratorChunk::Pointer:       return Ptr.destroy();
     case DeclaratorChunk::BlockPointer:  return Cls.destroy();
index 27d9234d761f1aacfd300a239228f63c9fa14414..7a74c97048995d2c091b209492d8f863b3dfa727 100644 (file)
@@ -93,7 +93,7 @@ static double GetApproxValue(const llvm::APFloat &F) {
 
 void APValue::print(raw_ostream &OS) const {
   switch (getKind()) {
-  default: assert(0 && "Unknown APValue kind!");
+  default: llvm_unreachable("Unknown APValue kind!");
   case Uninitialized:
     OS << "Uninitialized";
     return;
@@ -123,7 +123,7 @@ void APValue::print(raw_ostream &OS) const {
 static void WriteShortAPValueToStream(raw_ostream& Out,
                                       const APValue& V) {
   switch (V.getKind()) {
-  default: assert(0 && "Unknown APValue kind!");
+  default: llvm_unreachable("Unknown APValue kind!");
   case APValue::Uninitialized:
     Out << "Uninitialized";
     break;
index 50a3942cc1ba5e4e9db9040e04df33d2c9479f84..de77cb66cf04f5c4a72b8b2360d0ceda73f40b07 100644 (file)
@@ -682,7 +682,7 @@ const llvm::fltSemantics &ASTContext::getFloatTypeSemantics(QualType T) const {
   const BuiltinType *BT = T->getAs<BuiltinType>();
   assert(BT && "Not a floating point type!");
   switch (BT->getKind()) {
-  default: assert(0 && "Not a floating point type!");
+  default: llvm_unreachable("Not a floating point type!");
   case BuiltinType::Float:      return Target->getFloatFormat();
   case BuiltinType::Double:     return Target->getDoubleFormat();
   case BuiltinType::LongDouble: return Target->getLongDoubleFormat();
@@ -849,7 +849,7 @@ ASTContext::getTypeInfo(const Type *T) const {
 
   case Type::Builtin:
     switch (cast<BuiltinType>(T)->getKind()) {
-    default: assert(0 && "Unknown builtin type!");
+    default: llvm_unreachable("Unknown builtin type!");
     case BuiltinType::Void:
       // GCC extension: alignof(void) = 8 bits.
       Width = 0;
@@ -3218,7 +3218,7 @@ ASTContext::getCanonicalTemplateArgument(const TemplateArgument &Arg) const {
   }
 
   // Silence GCC warning
-  assert(false && "Unhandled template argument kind");
+  llvm_unreachable("Unhandled template argument kind");
   return TemplateArgument();
 }
 
@@ -3432,7 +3432,7 @@ static FloatingRank getFloatingRank(QualType T) {
 
   assert(T->getAs<BuiltinType>() && "getFloatingRank(): not a floating type");
   switch (T->getAs<BuiltinType>()->getKind()) {
-  default: assert(0 && "getFloatingRank(): not a floating type");
+  default: llvm_unreachable("getFloatingRank(): not a floating type");
   case BuiltinType::Float:      return FloatRank;
   case BuiltinType::Double:     return DoubleRank;
   case BuiltinType::LongDouble: return LongDoubleRank;
@@ -3448,7 +3448,7 @@ QualType ASTContext::getFloatingTypeOfSizeWithinDomain(QualType Size,
   FloatingRank EltRank = getFloatingRank(Size);
   if (Domain->isComplexType()) {
     switch (EltRank) {
-    default: assert(0 && "getFloatingRank(): illegal value for rank");
+    default: llvm_unreachable("getFloatingRank(): illegal value for rank");
     case FloatRank:      return FloatComplexTy;
     case DoubleRank:     return DoubleComplexTy;
     case LongDoubleRank: return LongDoubleComplexTy;
@@ -3457,7 +3457,7 @@ QualType ASTContext::getFloatingTypeOfSizeWithinDomain(QualType Size,
 
   assert(Domain->isRealFloatingType() && "Unknown domain!");
   switch (EltRank) {
-  default: assert(0 && "getFloatingRank(): illegal value for rank");
+  default: llvm_unreachable("getFloatingRank(): illegal value for rank");
   case FloatRank:      return FloatTy;
   case DoubleRank:     return DoubleTy;
   case LongDoubleRank: return LongDoubleTy;
@@ -3498,7 +3498,7 @@ unsigned ASTContext::getIntegerRank(const Type *T) const {
     T = getFromTargetType(Target->getChar32Type()).getTypePtr();
 
   switch (cast<BuiltinType>(T)->getKind()) {
-  default: assert(0 && "getIntegerRank(): not a built-in integer");
+  default: llvm_unreachable("getIntegerRank(): not a built-in integer");
   case BuiltinType::Bool:
     return 1 + (getIntWidth(BoolTy) << 3);
   case BuiltinType::Char_S:
@@ -4177,7 +4177,7 @@ void ASTContext::getObjCEncodingForType(QualType T, std::string& S,
 
 static char ObjCEncodingForPrimitiveKind(const ASTContext *C, QualType T) {
     switch (T->getAs<BuiltinType>()->getKind()) {
-    default: assert(0 && "Unhandled builtin type kind");
+    default: llvm_unreachable("Unhandled builtin type kind");
     case BuiltinType::Void:       return 'v';
     case BuiltinType::Bool:       return 'B';
     case BuiltinType::Char_U:
@@ -4536,7 +4536,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
     return;
   }
   
-  assert(0 && "@encode for type not implemented!");
+  llvm_unreachable("@encode for type not implemented!");
 }
 
 void ASTContext::getObjCEncodingForStructureImpl(RecordDecl *RDecl,
@@ -4918,7 +4918,7 @@ CanQualType ASTContext::getFromTargetType(unsigned Type) const {
   case TargetInfo::UnsignedLongLong: return UnsignedLongLongTy;
   }
 
-  assert(false && "Unhandled TargetInfo::IntType value");
+  llvm_unreachable("Unhandled TargetInfo::IntType value");
   return CanQualType();
 }
 
@@ -5748,13 +5748,13 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
 #include "clang/AST/TypeNodes.def"
-    assert(false && "Non-canonical and dependent types shouldn't get here");
+    llvm_unreachable("Non-canonical and dependent types shouldn't get here");
     return QualType();
 
   case Type::LValueReference:
   case Type::RValueReference:
   case Type::MemberPointer:
-    assert(false && "C++ should never be in mergeTypes");
+    llvm_unreachable("C++ should never be in mergeTypes");
     return QualType();
 
   case Type::ObjCInterface:
@@ -5762,7 +5762,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
   case Type::VariableArray:
   case Type::FunctionProto:
   case Type::ExtVector:
-    assert(false && "Types are eliminated above");
+    llvm_unreachable("Types are eliminated above");
     return QualType();
 
   case Type::Pointer:
@@ -6014,7 +6014,7 @@ QualType ASTContext::getCorrespondingUnsignedType(QualType T) {
   case BuiltinType::Int128:
     return UnsignedInt128Ty;
   default:
-    assert(0 && "Unexpected signed integer type");
+    llvm_unreachable("Unexpected signed integer type");
     return QualType();
   }
 }
@@ -6072,7 +6072,7 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
 
   // Read the base type.
   switch (*Str++) {
-  default: assert(0 && "Unknown builtin type letter!");
+  default: llvm_unreachable("Unknown builtin type letter!");
   case 'v':
     assert(HowLong == 0 && !Signed && !Unsigned &&
            "Bad modifiers used with 'v'!");
@@ -6475,7 +6475,7 @@ MangleContext *ASTContext::createMangleContext() {
   case CXXABI_Microsoft:
     return createMicrosoftMangleContext(*this, getDiagnostics());
   }
-  assert(0 && "Unsupported ABI");
+  llvm_unreachable("Unsupported ABI");
   return 0;
 }
 
index e6de54c907df1d1c0d95470e4d61558788850a10..f9100c0110805763fd1a863fb35ef535f97913f8 100644 (file)
@@ -235,7 +235,7 @@ void clang::FormatASTNodeDiagnosticArgument(
   bool NeedQuotes = true;
   
   switch (Kind) {
-    default: assert(0 && "unknown ArgumentKind");
+    default: llvm_unreachable("unknown ArgumentKind");
     case Diagnostic::ak_qualtype: {
       assert(ModLen == 0 && ArgLen == 0 &&
              "Invalid modifier for QualType argument");
index c791ba1a58a1788bc30755c3b148e5ec62c8f727..55610cbc6334771618bb019b0883d7ce079a3ced 100644 (file)
@@ -1803,7 +1803,7 @@ ASTNodeImporter::ImportDeclarationNameLoc(const DeclarationNameInfo &From,
     To.setNamedTypeInfo(Importer.Import(FromTInfo));
     return;
   }
-    assert(0 && "Unknown name kind.");
+    llvm_unreachable("Unknown name kind.");
   }
 }
 
index 57f9995fcea221288bbf4be076f7e19056bf1fe1..2fdb9654b0a4a83d6e2f8ee88eb2e6b433200a1c 100644 (file)
@@ -1890,7 +1890,7 @@ FunctionDecl::TemplatedKind FunctionDecl::getTemplatedKind() const {
                                <DependentFunctionTemplateSpecializationInfo*>())
     return TK_DependentFunctionTemplateSpecialization;
 
-  assert(false && "Did we miss a TemplateOrSpecialization type?");
+  llvm_unreachable("Did we miss a TemplateOrSpecialization type?");
   return TK_NonTemplate;
 }
 
@@ -2114,7 +2114,7 @@ FunctionDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK,
         MSInfo->getPointOfInstantiation().isInvalid())
       MSInfo->setPointOfInstantiation(PointOfInstantiation);
   } else
-    assert(false && "Function cannot have a template specialization kind");
+    llvm_unreachable("Function cannot have a template specialization kind");
 }
 
 SourceLocation FunctionDecl::getPointOfInstantiation() const {
index 68cf82edc4fa3215d7afc5b77e22fa3f9a4c2d0a..d1f8b1c7fd8a192b875786bc4c3f800c541ca4a9 100644 (file)
@@ -43,7 +43,7 @@ static bool StatSwitch = false;
 
 const char *Decl::getDeclKindName() const {
   switch (DeclKind) {
-  default: assert(0 && "Declaration not in DeclNodes.inc!");
+  default: llvm_unreachable("Declaration not in DeclNodes.inc!");
 #define DECL(DERIVED, BASE) case DERIVED: return #DERIVED;
 #define ABSTRACT_DECL(DECL)
 #include "clang/AST/DeclNodes.inc"
@@ -62,7 +62,7 @@ void Decl::setInvalidDecl(bool Invalid) {
 
 const char *DeclContext::getDeclKindName() const {
   switch (DeclKind) {
-  default: assert(0 && "Declaration context not in DeclNodes.inc!");
+  default: llvm_unreachable("Declaration context not in DeclNodes.inc!");
 #define DECL(DERIVED, BASE) case Decl::DERIVED: return #DERIVED;
 #define ABSTRACT_DECL(DECL)
 #include "clang/AST/DeclNodes.inc"
@@ -100,7 +100,7 @@ void Decl::PrintStats() {
 
 void Decl::add(Kind k) {
   switch (k) {
-  default: assert(0 && "Declaration not in DeclNodes.inc!");
+  default: llvm_unreachable("Declaration not in DeclNodes.inc!");
 #define DECL(DERIVED, BASE) case DERIVED: ++n##DERIVED##s; break;
 #define ABSTRACT_DECL(DECL)
 #include "clang/AST/DeclNodes.inc"
@@ -571,7 +571,7 @@ Decl *Decl::castFromDeclContext (const DeclContext *D) {
       if (DK >= first##NAME && DK <= last##NAME) \
         return static_cast<NAME##Decl*>(const_cast<DeclContext*>(D));
 #include "clang/AST/DeclNodes.inc"
-      assert(false && "a decl that inherits DeclContext isn't handled");
+      llvm_unreachable("a decl that inherits DeclContext isn't handled");
       return 0;
   }
 }
@@ -591,7 +591,7 @@ DeclContext *Decl::castToDeclContext(const Decl *D) {
       if (DK >= first##NAME && DK <= last##NAME)                  \
         return static_cast<NAME##Decl*>(const_cast<Decl*>(D));
 #include "clang/AST/DeclNodes.inc"
-      assert(false && "a decl that inherits DeclContext isn't handled");
+      llvm_unreachable("a decl that inherits DeclContext isn't handled");
       return 0;
   }
 }
index 89051152d7c312042e048d3d02a1f9bbbcc4c8f9..b9af8e3a1f11125315f8b044bfd79935df71a365 100644 (file)
@@ -671,7 +671,7 @@ NotASpecialMember:;
     case AS_private:    data().HasPrivateFields = true;   break;
     case AS_protected:  data().HasProtectedFields = true; break;
     case AS_public:     data().HasPublicFields = true;    break;
-    case AS_none:       assert(0 && "Invalid access specifier");
+    case AS_none:       llvm_unreachable("Invalid access specifier");
     };
     if ((data().HasPrivateFields + data().HasProtectedFields +
          data().HasPublicFields) > 1)
@@ -1053,7 +1053,7 @@ CXXRecordDecl::setTemplateSpecializationKind(TemplateSpecializationKind TSK) {
     return;
   }
   
-  assert(false && "Not a class template or member class specialization");
+  llvm_unreachable("Not a class template or member class specialization");
 }
 
 CXXDestructorDecl *CXXRecordDecl::getDestructor() const {
@@ -1693,7 +1693,7 @@ static const char *getAccessName(AccessSpecifier AS) {
   switch (AS) {
     default:
     case AS_none:
-      assert(0 && "Invalid access specifier!");
+      llvm_unreachable("Invalid access specifier!");
       return 0;
     case AS_public:
       return "public";
index 45e34811eab39a398243403a785d70fa76ad6136..68177de70d47f07024cb65224f4fa22a73aec678 100644 (file)
@@ -549,7 +549,7 @@ ObjCInterfaceDecl *ObjCMethodDecl::getClassInterface() {
     return IMD->getClassInterface();
 
   assert(!isa<ObjCProtocolDecl>(getDeclContext()) && "It's a protocol method");
-  assert(false && "unknown method context");
+  llvm_unreachable("unknown method context");
   return 0;
 }
 
@@ -781,7 +781,7 @@ const ObjCInterfaceDecl *ObjCIvarDecl::getContainingInterface() const {
   default:
   case ObjCCategoryImpl:
   case ObjCProtocol:
-    assert(0 && "invalid ivar container!");
+    llvm_unreachable("invalid ivar container!");
     return 0;
 
     // Ivars can only appear in class extension categories.
index 866153db111b90f61e648ef1dc82a33d1bf63789..a17e14053cbf34b8c6083236b2c29684c595a8c1 100644 (file)
@@ -114,7 +114,7 @@ static QualType GetBaseType(QualType T) {
     else if (const VectorType *VTy = BaseType->getAs<VectorType>())
       BaseType = VTy->getElementType();
     else
-      assert(0 && "Unknown declarator!");
+      llvm_unreachable("Unknown declarator!");
   }
   return BaseType;
 }
@@ -192,7 +192,7 @@ void DeclPrinter::ProcessDeclGroup(SmallVectorImpl<Decl*>& Decls) {
 
 void DeclPrinter::Print(AccessSpecifier AS) {
   switch(AS) {
-  case AS_none:      assert(0 && "No access specifier!"); break;
+  case AS_none:      llvm_unreachable("No access specifier!"); break;
   case AS_public:    Out << "public"; break;
   case AS_protected: Out << "protected"; break;
   case AS_private:   Out << "private"; break;
index a3ba94195fc400c14693d2ffef5b7fb6441bdeb0..84d4ca94c3dac339b212b01b1e3599134d8d698e 100644 (file)
@@ -193,7 +193,7 @@ DeclarationName::NameKind DeclarationName::getNameKind() const {
   }
 
   // Can't actually get here.
-  assert(0 && "This should be unreachable!");
+  llvm_unreachable("This should be unreachable!");
   return Identifier;
 }
 
@@ -276,7 +276,7 @@ void DeclarationName::printName(raw_ostream &OS) const {
     return;
   }
 
-  assert(false && "Unexpected declaration name kind");
+  llvm_unreachable("Unexpected declaration name kind");
 }
 
 QualType DeclarationName::getCXXNameType() const {
@@ -338,7 +338,7 @@ void *DeclarationName::getFETokenInfoAsVoid() const {
     return getCXXLiteralIdentifier()->getFETokenInfo<void>();
 
   default:
-    assert(false && "Declaration name has no FETokenInfo");
+    llvm_unreachable("Declaration name has no FETokenInfo");
   }
   return 0;
 }
@@ -364,7 +364,7 @@ void DeclarationName::setFETokenInfo(void *T) {
     break;
 
   default:
-    assert(false && "Declaration name has no FETokenInfo");
+    llvm_unreachable("Declaration name has no FETokenInfo");
   }
 }
 
@@ -588,7 +588,7 @@ void DeclarationNameInfo::printName(raw_ostream &OS) const {
       Name.printName(OS);
     return;
   }
-  assert(false && "Unexpected declaration name kind");
+  llvm_unreachable("Unexpected declaration name kind");
 }
 
 SourceLocation DeclarationNameInfo::getEndLoc() const {
@@ -621,6 +621,6 @@ SourceLocation DeclarationNameInfo::getEndLoc() const {
   case DeclarationName::CXXUsingDirective:
     return NameLoc;
   }
-  assert(false && "Unexpected declaration name kind");
+  llvm_unreachable("Unexpected declaration name kind");
   return SourceLocation();
 }
index 374c1a03a780818175ed7d86c9cd46040c2e4ab8..a358693a52c72b307c1604795a1d6866f7e2b270 100644 (file)
@@ -595,7 +595,7 @@ getLocationOfByte(unsigned ByteNo, const SourceManager &SM,
 /// corresponds to, e.g. "sizeof" or "[pre]++".
 const char *UnaryOperator::getOpcodeStr(Opcode Op) {
   switch (Op) {
-  default: assert(0 && "Unknown unary operator");
+  default: llvm_unreachable("Unknown unary operator");
   case UO_PostInc: return "++";
   case UO_PostDec: return "--";
   case UO_PreInc:  return "++";
@@ -615,7 +615,7 @@ const char *UnaryOperator::getOpcodeStr(Opcode Op) {
 UnaryOperatorKind
 UnaryOperator::getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix) {
   switch (OO) {
-  default: assert(false && "No unary operator for overloaded function");
+  default: llvm_unreachable("No unary operator for overloaded function");
   case OO_PlusPlus:   return Postfix ? UO_PostInc : UO_PreInc;
   case OO_MinusMinus: return Postfix ? UO_PostDec : UO_PreDec;
   case OO_Amp:        return UO_AddrOf;
@@ -1289,7 +1289,7 @@ const char *BinaryOperator::getOpcodeStr(Opcode Op) {
 BinaryOperatorKind
 BinaryOperator::getOverloadedOpcode(OverloadedOperatorKind OO) {
   switch (OO) {
-  default: assert(false && "Not an overloadable binary operator");
+  default: llvm_unreachable("Not an overloadable binary operator");
   case OO_Plus: return BO_Add;
   case OO_Minus: return BO_Sub;
   case OO_Star: return BO_Mul;
@@ -2495,7 +2495,7 @@ Expr::isNullPointerConstant(ASTContext &Ctx,
   if (isValueDependent()) {
     switch (NPC) {
     case NPC_NeverValueDependent:
-      assert(false && "Unexpected value dependent expression!");
+      llvm_unreachable("Unexpected value dependent expression!");
       // If the unthinkable happens, fall through to the safest alternative.
         
     case NPC_ValueDependentIsNull:
index 97786053be1833120360896b1d9620f0ccfb6daa..2d4b07021c2058b86c64689047a5e458da0dcd60 100644 (file)
@@ -388,7 +388,7 @@ public:
   ExprEvaluatorBase(EvalInfo &Info) : Info(Info) {}
 
   RetTy VisitStmt(const Stmt *) {
-    assert(0 && "Expression evaluator should not be called on stmts");
+    llvm_unreachable("Expression evaluator should not be called on stmts");
     return DerivedError(0);
   }
   RetTy VisitExpr(const Expr *E) {
@@ -1218,7 +1218,7 @@ static int EvaluateBuiltinClassifyType(const CallExpr *E) {
   else if (ArgTy->isUnionType())
     return union_type_class;
   else  // FIXME: offset_type_class, method_type_class, & lang_type_class?
-    assert(0 && "CallExpr::isBuiltinClassifyType(): unimplemented type");
+    llvm_unreachable("CallExpr::isBuiltinClassifyType(): unimplemented type");
   return -1;
 }
 
@@ -1427,7 +1427,7 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
 
     switch (E->getOpcode()) {
     default:
-      assert(0 && "Invalid binary operator!");
+      llvm_unreachable("Invalid binary operator!");
     case BO_LT:
       return Success(CR == APFloat::cmpLessThan, E);
     case BO_GT:
index 296bad535c81031ec0e4a0cf762da61dd9f54e82..ab6ec4e6a1032ed05652030b5571796f06d172fc 100644 (file)
@@ -1069,7 +1069,7 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
   case DeclarationName::ObjCZeroArgSelector:
   case DeclarationName::ObjCOneArgSelector:
   case DeclarationName::ObjCMultiArgSelector:
-    assert(false && "Can't mangle Objective-C selector names here!");
+    llvm_unreachable("Can't mangle Objective-C selector names here!");
     break;
 
   case DeclarationName::CXXConstructorName:
@@ -1124,7 +1124,7 @@ void CXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
     break;
 
   case DeclarationName::CXXUsingDirective:
-    assert(false && "Can't mangle a using directive name!");
+    llvm_unreachable("Can't mangle a using directive name!");
     break;
   }
 }
@@ -1512,7 +1512,7 @@ CXXNameMangler::mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity) {
 
   case OO_None:
   case NUM_OVERLOADED_OPERATORS:
-    assert(false && "Not an overloaded operator");
+    llvm_unreachable("Not an overloaded operator");
     break;
   }
 }
index 14a1d6662da6507bef56bfe75e328ffff033ed14..fd90883bdf113665e192ed8f54ec967de2114859 100644 (file)
@@ -332,15 +332,15 @@ MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
     case DeclarationName::ObjCZeroArgSelector:
     case DeclarationName::ObjCOneArgSelector:
     case DeclarationName::ObjCMultiArgSelector:
-      assert(false && "Can't mangle Objective-C selector names here!");
+      llvm_unreachable("Can't mangle Objective-C selector names here!");
       break;
       
     case DeclarationName::CXXConstructorName:
-      assert(false && "Can't mangle constructors yet!");
+      llvm_unreachable("Can't mangle constructors yet!");
       break;
       
     case DeclarationName::CXXDestructorName:
-      assert(false && "Can't mangle destructors yet!");
+      llvm_unreachable("Can't mangle destructors yet!");
       break;
       
     case DeclarationName::CXXConversionFunctionName:
@@ -355,11 +355,11 @@ MicrosoftCXXNameMangler::mangleUnqualifiedName(const NamedDecl *ND,
       
     case DeclarationName::CXXLiteralOperatorName:
       // FIXME: Was this added in VS2010? Does MS even know how to mangle this?
-      assert(false && "Don't know how to mangle literal operators yet!");
+      llvm_unreachable("Don't know how to mangle literal operators yet!");
       break;
       
     case DeclarationName::CXXUsingDirective:
-      assert(false && "Can't mangle a using directive name!");
+      llvm_unreachable("Can't mangle a using directive name!");
       break;
   }
 }
@@ -513,12 +513,12 @@ void MicrosoftCXXNameMangler::mangleOperatorName(OverloadedOperatorKind OO) {
   case OO_Array_Delete: Out << "?_V"; break;
     
   case OO_Conditional:
-    assert(false && "Don't know how to mangle ?:");
+    llvm_unreachable("Don't know how to mangle ?:");
     break;
     
   case OO_None:
   case NUM_OVERLOADED_OPERATORS:
-    assert(false && "Not an overloaded operator");
+    llvm_unreachable("Not an overloaded operator");
     break;
   }
 }
@@ -712,7 +712,7 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T) {
   case BuiltinType::Dependent:
   case BuiltinType::UnknownAny:
   case BuiltinType::BoundMember:
-    assert(false &&
+    llvm_unreachable(
            "Overloaded and dependent types shouldn't get to name mangling");
     break;
   case BuiltinType::ObjCId: Out << "PAUobjc_object@@"; break;
@@ -722,7 +722,7 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T) {
   case BuiltinType::Char16:
   case BuiltinType::Char32:
   case BuiltinType::NullPtr:
-    assert(false && "Don't know how to mangle this type");
+    llvm_unreachable("Don't know how to mangle this type");
     break;
   }
 }
@@ -869,7 +869,7 @@ void MicrosoftCXXNameMangler::mangleCallingConvention(const FunctionType *T,
     CC = IsInstMethod ? getASTContext().getDefaultMethodCallConv() : CC_C;
   switch (CC) {
     default:
-      assert(0 && "Unsupported CC for mangling");
+      llvm_unreachable("Unsupported CC for mangling");
     case CC_Default:
     case CC_C: Out << 'A'; break;
     case CC_X86Pascal: Out << 'C'; break;
@@ -890,7 +890,7 @@ void MicrosoftCXXNameMangler::mangleThrowSpecification(
 }
 
 void MicrosoftCXXNameMangler::mangleType(const UnresolvedUsingType *T) {
-  assert(false && "Don't know how to mangle UnresolvedUsingTypes yet!");
+  llvm_unreachable("Don't know how to mangle UnresolvedUsingTypes yet!");
 }
 
 // <type>        ::= <union-type> | <struct-type> | <class-type> | <enum-type>
@@ -962,10 +962,10 @@ void MicrosoftCXXNameMangler::mangleExtraDimensions(QualType ElementTy) {
       Dimensions.push_back(CAT->getSize());
       ElementTy = CAT->getElementType();
     } else if (ElementTy->isVariableArrayType()) {
-      assert(false && "Don't know how to mangle VLAs!");
+      llvm_unreachable("Don't know how to mangle VLAs!");
     } else if (ElementTy->isDependentSizedArrayType()) {
       // The dependent expression has to be folded into a constant (TODO).
-      assert(false && "Don't know how to mangle dependent-sized arrays!");
+      llvm_unreachable("Don't know how to mangle dependent-sized arrays!");
     } else if (ElementTy->isIncompleteArrayType()) continue;
     else break;
   }
@@ -999,12 +999,12 @@ void MicrosoftCXXNameMangler::mangleType(const MemberPointerType *T) {
 }
 
 void MicrosoftCXXNameMangler::mangleType(const TemplateTypeParmType *T) {
-  assert(false && "Don't know how to mangle TemplateTypeParmTypes yet!");
+  llvm_unreachable("Don't know how to mangle TemplateTypeParmTypes yet!");
 }
 
 void MicrosoftCXXNameMangler::mangleType(
                                        const SubstTemplateTypeParmPackType *T) {
-  assert(false && 
+  llvm_unreachable(
          "Don't know how to mangle SubstTemplateTypeParmPackTypes yet!");
 }
 
@@ -1045,21 +1045,22 @@ void MicrosoftCXXNameMangler::mangleType(const LValueReferenceType *T) {
 }
 
 void MicrosoftCXXNameMangler::mangleType(const RValueReferenceType *T) {
-  assert(false && "Don't know how to mangle RValueReferenceTypes yet!");
+  llvm_unreachable("Don't know how to mangle RValueReferenceTypes yet!");
 }
 
 void MicrosoftCXXNameMangler::mangleType(const ComplexType *T) {
-  assert(false && "Don't know how to mangle ComplexTypes yet!");
+  llvm_unreachable("Don't know how to mangle ComplexTypes yet!");
 }
 
 void MicrosoftCXXNameMangler::mangleType(const VectorType *T) {
-  assert(false && "Don't know how to mangle VectorTypes yet!");
+  llvm_unreachable("Don't know how to mangle VectorTypes yet!");
 }
 void MicrosoftCXXNameMangler::mangleType(const ExtVectorType *T) {
-  assert(false && "Don't know how to mangle ExtVectorTypes yet!");
+  llvm_unreachable("Don't know how to mangle ExtVectorTypes yet!");
 }
 void MicrosoftCXXNameMangler::mangleType(const DependentSizedExtVectorType *T) {
-  assert(false && "Don't know how to mangle DependentSizedExtVectorTypes yet!");
+  llvm_unreachable(
+                  "Don't know how to mangle DependentSizedExtVectorTypes yet!");
 }
 
 void MicrosoftCXXNameMangler::mangleType(const ObjCInterfaceType *T) {
@@ -1080,45 +1081,45 @@ void MicrosoftCXXNameMangler::mangleType(const BlockPointerType *T) {
 }
 
 void MicrosoftCXXNameMangler::mangleType(const InjectedClassNameType *T) {
-  assert(false && "Don't know how to mangle InjectedClassNameTypes yet!");
+  llvm_unreachable("Don't know how to mangle InjectedClassNameTypes yet!");
 }
 
 void MicrosoftCXXNameMangler::mangleType(const TemplateSpecializationType *T) {
-  assert(false && "Don't know how to mangle TemplateSpecializationTypes yet!");
+  llvm_unreachable("Don't know how to mangle TemplateSpecializationTypes yet!");
 }
 
 void MicrosoftCXXNameMangler::mangleType(const DependentNameType *T) {
-  assert(false && "Don't know how to mangle DependentNameTypes yet!");
+  llvm_unreachable("Don't know how to mangle DependentNameTypes yet!");
 }
 
 void MicrosoftCXXNameMangler::mangleType(
                                  const DependentTemplateSpecializationType *T) {
-  assert(false &&
+  llvm_unreachable(
          "Don't know how to mangle DependentTemplateSpecializationTypes yet!");
 }
 
 void MicrosoftCXXNameMangler::mangleType(const PackExpansionType *T) {
-  assert(false && "Don't know how to mangle PackExpansionTypes yet!");
+  llvm_unreachable("Don't know how to mangle PackExpansionTypes yet!");
 }
 
 void MicrosoftCXXNameMangler::mangleType(const TypeOfType *T) {
-  assert(false && "Don't know how to mangle TypeOfTypes yet!");
+  llvm_unreachable("Don't know how to mangle TypeOfTypes yet!");
 }
 
 void MicrosoftCXXNameMangler::mangleType(const TypeOfExprType *T) {
-  assert(false && "Don't know how to mangle TypeOfExprTypes yet!");
+  llvm_unreachable("Don't know how to mangle TypeOfExprTypes yet!");
 }
 
 void MicrosoftCXXNameMangler::mangleType(const DecltypeType *T) {
-  assert(false && "Don't know how to mangle DecltypeTypes yet!");
+  llvm_unreachable("Don't know how to mangle DecltypeTypes yet!");
 }
 
 void MicrosoftCXXNameMangler::mangleType(const UnaryTransformType *T) {
-  assert(false && "Don't know how to mangle UnaryTransformationTypes yet!");
+  llvm_unreachable("Don't know how to mangle UnaryTransformationTypes yet!");
 }
 
 void MicrosoftCXXNameMangler::mangleType(const AutoType *T) {
-  assert(false && "Don't know how to mangle AutoTypes yet!");
+  llvm_unreachable("Don't know how to mangle AutoTypes yet!");
 }
 
 void MicrosoftMangleContext::mangleName(const NamedDecl *D,
@@ -1138,17 +1139,17 @@ void MicrosoftMangleContext::mangleName(const NamedDecl *D,
 void MicrosoftMangleContext::mangleThunk(const CXXMethodDecl *MD,
                                          const ThunkInfo &Thunk,
                                          raw_ostream &) {
-  assert(false && "Can't yet mangle thunks!");
+  llvm_unreachable("Can't yet mangle thunks!");
 }
 void MicrosoftMangleContext::mangleCXXDtorThunk(const CXXDestructorDecl *DD,
                                                 CXXDtorType Type,
                                                 const ThisAdjustment &,
                                                 raw_ostream &) {
-  assert(false && "Can't yet mangle destructor thunks!");
+  llvm_unreachable("Can't yet mangle destructor thunks!");
 }
 void MicrosoftMangleContext::mangleCXXVTable(const CXXRecordDecl *RD,
                                              raw_ostream &) {
-  assert(false && "Can't yet mangle virtual tables!");
+  llvm_unreachable("Can't yet mangle virtual tables!");
 }
 void MicrosoftMangleContext::mangleCXXVTT(const CXXRecordDecl *RD,
                                           raw_ostream &) {
@@ -1162,25 +1163,25 @@ void MicrosoftMangleContext::mangleCXXCtorVTable(const CXXRecordDecl *RD,
 }
 void MicrosoftMangleContext::mangleCXXRTTI(QualType T,
                                            raw_ostream &) {
-  assert(false && "Can't yet mangle RTTI!");
+  llvm_unreachable("Can't yet mangle RTTI!");
 }
 void MicrosoftMangleContext::mangleCXXRTTIName(QualType T,
                                                raw_ostream &) {
-  assert(false && "Can't yet mangle RTTI names!");
+  llvm_unreachable("Can't yet mangle RTTI names!");
 }
 void MicrosoftMangleContext::mangleCXXCtor(const CXXConstructorDecl *D,
                                            CXXCtorType Type,
                                            raw_ostream &) {
-  assert(false && "Can't yet mangle constructors!");
+  llvm_unreachable("Can't yet mangle constructors!");
 }
 void MicrosoftMangleContext::mangleCXXDtor(const CXXDestructorDecl *D,
                                            CXXDtorType Type,
                                            raw_ostream &) {
-  assert(false && "Can't yet mangle destructors!");
+  llvm_unreachable("Can't yet mangle destructors!");
 }
 void MicrosoftMangleContext::mangleReferenceTemporary(const clang::VarDecl *,
                                                       raw_ostream &) {
-  assert(false && "Can't yet mangle reference temporaries!");
+  llvm_unreachable("Can't yet mangle reference temporaries!");
 }
 
 MangleContext *clang::createMicrosoftMangleContext(ASTContext &Context,
index 473837b330bb221da36ba02f6fd9d95284fedc9f..9357d9be67d5bdf6f96fd212d8b34ccbae707bcc 100644 (file)
@@ -294,7 +294,7 @@ void StmtDumper::DumpDeclarator(Decl *D) {
     DumpSubTree(SAD->getMessage());
     OS << ");\"";
   } else {
-    assert(0 && "Unexpected decl");
+    llvm_unreachable("Unexpected decl");
   }
 }
 
@@ -416,7 +416,7 @@ void StmtDumper::VisitObjCIvarRefExpr(ObjCIvarRefExpr *Node) {
 void StmtDumper::VisitPredefinedExpr(PredefinedExpr *Node) {
   DumpExpr(Node);
   switch (Node->getIdentType()) {
-  default: assert(0 && "unknown case");
+  default: llvm_unreachable("unknown case");
   case PredefinedExpr::Func:           OS <<  " __func__"; break;
   case PredefinedExpr::Function:       OS <<  " __FUNCTION__"; break;
   case PredefinedExpr::PrettyFunction: OS <<  " __PRETTY_FUNCTION__";break;
index 79f14bc6581df45cbb9c0c66d8749d3078598602..57a3e61e543569b08d052048dbbb598e4e83f3f7 100644 (file)
@@ -584,7 +584,7 @@ void StmtPrinter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *Node) {
 void StmtPrinter::VisitPredefinedExpr(PredefinedExpr *Node) {
   switch (Node->getIdentType()) {
     default:
-      assert(0 && "unknown case");
+      llvm_unreachable("unknown case");
     case PredefinedExpr::Func:
       OS << "__func__";
       break;
@@ -658,7 +658,7 @@ void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
 
   // Emit suffixes.  Integer literals are always a builtin integer type.
   switch (Node->getType()->getAs<BuiltinType>()->getKind()) {
-  default: assert(0 && "Unexpected type for integer literal!");
+  default: llvm_unreachable("Unexpected type for integer literal!");
   case BuiltinType::Int:       break; // no suffix.
   case BuiltinType::UInt:      OS << 'U'; break;
   case BuiltinType::Long:      OS << 'L'; break;
@@ -1051,7 +1051,7 @@ void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) {
     OS << ' ' << OpStrings[Kind] << ' ';
     PrintExpr(Node->getArg(1));
   } else {
-    assert(false && "unknown overloaded operator");
+    llvm_unreachable("unknown overloaded operator");
   }
 }
 
index b963cec42c5bf3feb9a21b762d8579866b931941..b780012557f17a467bab59633077fa78944d1755 100644 (file)
@@ -68,7 +68,7 @@ TemplateArgument TemplateArgument::CreatePackCopy(ASTContext &Context,
 bool TemplateArgument::isDependent() const {
   switch (getKind()) {
   case Null:
-    assert(false && "Should not have a NULL template argument");
+    llvm_unreachable("Should not have a NULL template argument");
     return false;
 
   case Type:
@@ -107,7 +107,7 @@ bool TemplateArgument::isDependent() const {
 bool TemplateArgument::isInstantiationDependent() const {
   switch (getKind()) {
   case Null:
-    assert(false && "Should not have a NULL template argument");
+    llvm_unreachable("Should not have a NULL template argument");
     return false;
     
   case Type:
index 0775dcfb79edd5e723a2d4aee9cb217a2ccda294..0b2577dec45e1d4f07f9053176327963d02f3fa0 100644 (file)
@@ -3373,7 +3373,7 @@ public:
         OS << " && ...";
         return;
       default:
-        assert(false && "Invalid logical operator.");
+        llvm_unreachable("Invalid logical operator.");
     }
   }
 
@@ -3521,7 +3521,7 @@ static void print_block(raw_ostream &OS, const CFG* cfg,
       OS << ")";
 
     } else
-      assert(false && "Invalid label statement in CFGBlock.");
+      llvm_unreachable("Invalid label statement in CFGBlock.");
 
     OS << ":\n";
   }
index 3550a5415cb7d9fa47c996aa58e7303f74ffadac..3848c2c38f203a4936a460e5c9d7ba767ba7f34a 100644 (file)
@@ -209,7 +209,7 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS,
 bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
   switch (K) {
     case InvalidTy:
-      assert(false && "ArgTypeResult must be valid");
+      llvm_unreachable("ArgTypeResult must be valid");
       return true;
 
     case UnknownTy:
@@ -312,7 +312,7 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
 QualType ArgTypeResult::getRepresentativeType(ASTContext &C) const {
   switch (K) {
     case InvalidTy:
-      assert(false && "No representative type for Invalid ArgTypeResult");
+      llvm_unreachable("No representative type for Invalid ArgTypeResult");
       // Fall-through.
     case UnknownTy:
       return QualType();
index eb018f1eb5fac817ea2f016a0de922e29dd365cf..770cd37e9cec9062996708fd1cc44dbb219c13f2 100644 (file)
@@ -461,7 +461,7 @@ bool PrintfSpecifier::fixType(QualType QT) {
     HasAlternativeForm = 0;
     HasPlusPrefix = 0;
   } else {
-    assert(0 && "Unexpected type");
+    llvm_unreachable("Unexpected type");
   }
 
   return true;
index ace92aceb4673c55723ce2d5ad180dd4944b18a8..f7d147025c62a23f5a30acef4adf751201060762 100644 (file)
@@ -494,7 +494,7 @@ DiagnosticIDs::getDiagnosticLevel(unsigned DiagID, unsigned DiagClass,
   bool ShouldEmitInSystemHeader = false;
 
   switch (MappingInfo & 7) {
-  default: assert(0 && "Unknown mapping!");
+  default: llvm_unreachable("Unknown mapping!");
   case diag::MAP_IGNORE:
     if (Diag.EnableAllWarnings) {
       // Leave the warning disabled if it was explicitly ignored.
index 32a152292877129e285eb5e3010cb3396ec8e1a5..7a7515f08f6491cccd9dac30b1b88b4559ba51f5 100644 (file)
@@ -87,7 +87,7 @@ TargetInfo::~TargetInfo() {}
 /// For example, SignedShort -> "short".
 const char *TargetInfo::getTypeName(IntType T) {
   switch (T) {
-  default: assert(0 && "not an integer!");
+  default: llvm_unreachable("not an integer!");
   case SignedShort:      return "short";
   case UnsignedShort:    return "unsigned short";
   case SignedInt:        return "int";
@@ -103,7 +103,7 @@ const char *TargetInfo::getTypeName(IntType T) {
 /// integer type enum. For example, SignedLong -> "L".
 const char *TargetInfo::getTypeConstantSuffix(IntType T) {
   switch (T) {
-  default: assert(0 && "not an integer!");
+  default: llvm_unreachable("not an integer!");
   case SignedShort:
   case SignedInt:        return "";
   case SignedLong:       return "L";
@@ -119,7 +119,7 @@ const char *TargetInfo::getTypeConstantSuffix(IntType T) {
 /// enum. For example, SignedInt -> getIntWidth().
 unsigned TargetInfo::getTypeWidth(IntType T) const {
   switch (T) {
-  default: assert(0 && "not an integer!");
+  default: llvm_unreachable("not an integer!");
   case SignedShort:
   case UnsignedShort:    return getShortWidth();
   case SignedInt:
@@ -135,7 +135,7 @@ unsigned TargetInfo::getTypeWidth(IntType T) const {
 /// enum. For example, SignedInt -> getIntAlign().
 unsigned TargetInfo::getTypeAlign(IntType T) const {
   switch (T) {
-  default: assert(0 && "not an integer!");
+  default: llvm_unreachable("not an integer!");
   case SignedShort:
   case UnsignedShort:    return getShortAlign();
   case SignedInt:
@@ -151,7 +151,7 @@ unsigned TargetInfo::getTypeAlign(IntType T) const {
 /// the type is signed; false otherwise.
 bool TargetInfo::isTypeSigned(IntType T) {
   switch (T) {
-  default: assert(0 && "not an integer!");
+  default: llvm_unreachable("not an integer!");
   case SignedShort:
   case SignedInt:
   case SignedLong:
index 5e25f69f41ef8f3bd86e546633e4662301bd8539..abfd0a762534ecea822f55b83ddcf3d145ea88f0 100644 (file)
@@ -2795,7 +2795,7 @@ public:
     else if (ABI == "eabi")
       Builder.defineMacro("__mips_eabi");
     else
-      assert(false && "Invalid ABI for Mips32.");
+      llvm_unreachable("Invalid ABI for Mips32.");
   }
   virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
                                 unsigned &NumAliases) const {
@@ -2897,7 +2897,7 @@ public:
       Builder.defineMacro("_MIPS_SIM", "_ABI64");
     }
     else
-      assert(false && "Invalid ABI for Mips64.");
+      llvm_unreachable("Invalid ABI for Mips64.");
   }
   virtual void getGCCRegAliases(const GCCRegAlias *&Aliases,
                                 unsigned &NumAliases) const {
index bdf30881127f2dbccf5f0ab5e31fee6eec42b00d..8972b2f43d3be865f7cc1ece18a0fbc888158f23 100644 (file)
@@ -152,7 +152,7 @@ static Value *EmitFAbs(CodeGenFunction &CGF, Value *V, QualType ValTy) {
   
   StringRef FnName;
   switch (ValTyP->getKind()) {
-  default: assert(0 && "Isn't a scalar fp type!");
+  default: llvm_unreachable("Isn't a scalar fp type!");
   case BuiltinType::Float:      FnName = "fabsf"; break;
   case BuiltinType::Double:     FnName = "fabs"; break;
   case BuiltinType::LongDouble: FnName = "fabsl"; break;
@@ -396,7 +396,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
     Value *RHS = EmitScalarExpr(E->getArg(1));
 
     switch (BuiltinID) {
-    default: assert(0 && "Unknown ordered comparison");
+    default: llvm_unreachable("Unknown ordered comparison");
     case Builtin::BI__builtin_isgreater:
       LHS = Builder.CreateFCmpOGT(LHS, RHS, "cmp");
       break;
@@ -775,7 +775,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
   case Builtin::BI__sync_lock_test_and_set:
   case Builtin::BI__sync_lock_release:
   case Builtin::BI__sync_swap:
-    assert(0 && "Shouldn't make it through sema");
+    llvm_unreachable("Shouldn't make it through sema");
   case Builtin::BI__sync_fetch_and_add_1:
   case Builtin::BI__sync_fetch_and_add_2:
   case Builtin::BI__sync_fetch_and_add_4:
@@ -1541,7 +1541,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
       case ARM::BI__builtin_neon_vld4_dup_v:
         Int = Intrinsic::arm_neon_vld2; 
         break;
-      default: assert(0 && "unknown vld_dup intrinsic?");
+      default: llvm_unreachable("unknown vld_dup intrinsic?");
       }
       Function *F = CGM.getIntrinsic(Int, Ty);
       Value *Align = GetPointeeAlignment(*this, E->getArg(1));
@@ -1560,7 +1560,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
     case ARM::BI__builtin_neon_vld4_dup_v:
       Int = Intrinsic::arm_neon_vld2lane; 
       break;
-    default: assert(0 && "unknown vld_dup intrinsic?");
+    default: llvm_unreachable("unknown vld_dup intrinsic?");
     }
     Function *F = CGM.getIntrinsic(Int, Ty);
     llvm::StructType *STy = cast<llvm::StructType>(F->getReturnType());
@@ -2013,7 +2013,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
     Intrinsic::ID ID = Intrinsic::not_intrinsic;
 
     switch (BuiltinID) {
-    default: assert(0 && "Unsupported shift intrinsic!");
+    default: llvm_unreachable("Unsupported shift intrinsic!");
     case X86::BI__builtin_ia32_pslldi128:
       name = "pslldi";
       ID = Intrinsic::x86_sse2_psll_d;
@@ -2073,7 +2073,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
     Intrinsic::ID ID = Intrinsic::not_intrinsic;
 
     switch (BuiltinID) {
-    default: assert(0 && "Unsupported shift intrinsic!");
+    default: llvm_unreachable("Unsupported shift intrinsic!");
     case X86::BI__builtin_ia32_pslldi:
       name = "pslldi";
       ID = Intrinsic::x86_mmx_psll_d;
@@ -2398,7 +2398,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
     Ops.pop_back();
 
     switch (BuiltinID) {
-    default: assert(0 && "Unsupported ld/lvsl/lvsr intrinsic!");
+    default: llvm_unreachable("Unsupported ld/lvsl/lvsr intrinsic!");
     case PPC::BI__builtin_altivec_lvx:
       ID = Intrinsic::ppc_altivec_lvx;
       break;
@@ -2437,7 +2437,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
     Ops.pop_back();
 
     switch (BuiltinID) {
-    default: assert(0 && "Unsupported st intrinsic!");
+    default: llvm_unreachable("Unsupported st intrinsic!");
     case PPC::BI__builtin_altivec_stvx:
       ID = Intrinsic::ppc_altivec_stvx;
       break;
index 6e2954309336f5e165124dce7a347d7f34e8637a..c246c3cb359ac3bbd6eacea18f8e1c71b1cafb9f 100644 (file)
@@ -783,7 +783,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI,
     break;
 
   case ABIArgInfo::Expand:
-    assert(0 && "Invalid ABI kind for return argument");
+    llvm_unreachable("Invalid ABI kind for return argument");
   }
 
   if (RetAttrs)
@@ -1243,7 +1243,7 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI) {
     break;
 
   case ABIArgInfo::Expand:
-    assert(0 && "Invalid ABI kind for return argument");
+    llvm_unreachable("Invalid ABI kind for return argument");
   }
 
   llvm::Instruction *Ret = RV ? Builder.CreateRet(RV) : Builder.CreateRetVoid();
@@ -1860,10 +1860,10 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
   }
 
   case ABIArgInfo::Expand:
-    assert(0 && "Invalid ABI kind for return argument");
+    llvm_unreachable("Invalid ABI kind for return argument");
   }
 
-  assert(0 && "Unhandled ABIArgInfo::Kind");
+  llvm_unreachable("Unhandled ABIArgInfo::Kind");
   return RValue::get(0);
 }
 
index 89e14bafd0baee82519cc86ed9f7054c7680955b..04bf996acde0ab156f8f292285faa277e5a89b3e 100644 (file)
@@ -290,16 +290,16 @@ llvm::DIType CGDebugInfo::CreateType(const BuiltinType *BT) {
   const char *BTName = NULL;
   switch (BT->getKind()) {
   case BuiltinType::Dependent:
-    assert(0 && "Unexpected builtin type Dependent");
+    llvm_unreachable("Unexpected builtin type Dependent");
     return llvm::DIType();
   case BuiltinType::Overload:
-    assert(0 && "Unexpected builtin type Overload");
+    llvm_unreachable("Unexpected builtin type Overload");
     return llvm::DIType();
   case BuiltinType::BoundMember:
-    assert(0 && "Unexpected builtin type BoundMember");
+    llvm_unreachable("Unexpected builtin type BoundMember");
     return llvm::DIType();
   case BuiltinType::UnknownAny:
-    assert(0 && "Unexpected builtin type UnknownAny");
+    llvm_unreachable("Unexpected builtin type UnknownAny");
     return llvm::DIType();
   case BuiltinType::NullPtr:
     return DBuilder.
@@ -1543,7 +1543,7 @@ llvm::DIType CGDebugInfo::CreateTypeNode(QualType Ty,
 #define NON_CANONICAL_TYPE(Class, Base)
 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
 #include "clang/AST/TypeNodes.def"
-    assert(false && "Dependent types cannot show up in debug information");
+    llvm_unreachable("Dependent types cannot show up in debug information");
 
   case Type::ExtVector:
   case Type::Vector:
index 46f3f6b1778d6453a00d7f3883b3fbb6d0d982af..b43ef4e5db597231784fe96e2bf24fbbb1eda92a 100644 (file)
@@ -72,7 +72,7 @@ void CodeGenFunction::EmitDecl(const Decl &D) {
   case Decl::FriendTemplate:
   case Decl::Block:
   case Decl::ClassScopeFunctionSpecialization:
-    assert(0 && "Declaration should not be in declstmts!");
+    llvm_unreachable("Declaration should not be in declstmts!");
   case Decl::Function:  // void X();
   case Decl::Record:    // struct/union/class X;
   case Decl::Enum:      // enum X;
@@ -136,7 +136,7 @@ void CodeGenFunction::EmitVarDecl(const VarDecl &D) {
     return CGM.getOpenCLRuntime().EmitWorkGroupLocalVarDecl(*this, D);
   }
 
-  assert(0 && "Unknown storage class");
+  llvm_unreachable("Unknown storage class");
 }
 
 static std::string GetStaticDeclName(CodeGenFunction &CGF, const VarDecl &D,
@@ -158,14 +158,14 @@ static std::string GetStaticDeclName(CodeGenFunction &CGF, const VarDecl &D,
       ContextName = Name.getString();
     }
     else
-      assert(0 && "Unknown context for block static var decl");
+      llvm_unreachable("Unknown context for block static var decl");
   } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(CGF.CurFuncDecl)) {
     StringRef Name = CGM.getMangledName(FD);
     ContextName = Name.str();
   } else if (isa<ObjCMethodDecl>(CGF.CurFuncDecl))
     ContextName = CGF.CurFn->getName();
   else
-    assert(0 && "Unknown context for static var decl");
+    llvm_unreachable("Unknown context for static var decl");
 
   return ContextName + Separator + D.getNameAsString();
 }
index 62be62b79eda5c6520fa17bb16d278af6ec2d7c8..f3996c9659d1f128e9dfaf5e1096bb0d4d7b9da9 100644 (file)
@@ -474,7 +474,8 @@ CodeGenFunction::EmitReferenceBindingToExpr(const Expr *E,
   else {
     switch (ObjCARCReferenceLifetimeType.getObjCLifetime()) {
     case Qualifiers::OCL_None:
-      assert(0 && "Not a reference temporary that needs to be deallocated");
+      llvm_unreachable(
+                      "Not a reference temporary that needs to be deallocated");
     case Qualifiers::OCL_ExplicitNone:
     case Qualifiers::OCL_Autoreleasing:
       // Nothing to do.
@@ -1196,7 +1197,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
       Vec = Builder.CreateShuffleVector(Vec, ExtSrcVal, MaskV, "tmp");
     } else {
       // We should never shorten the vector
-      assert(0 && "unexpected shorten vector length");
+      llvm_unreachable("unexpected shorten vector length");
     }
   } else {
     // If the Src is a scalar (not a vector) it must be updating one element.
@@ -1387,7 +1388,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
   if (const FunctionDecl *fn = dyn_cast<FunctionDecl>(ND))
     return EmitFunctionDeclLValue(*this, E, fn);
 
-  assert(false && "Unhandled DeclRefExpr");
+  llvm_unreachable("Unhandled DeclRefExpr");
   
   // an invalid LValue, but the assert will
   // ensure that this point is never reached.
@@ -1407,7 +1408,7 @@ LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) {
 
   QualType ExprTy = getContext().getCanonicalType(E->getSubExpr()->getType());
   switch (E->getOpcode()) {
-  default: assert(0 && "Unknown unary operator lvalue!");
+  default: llvm_unreachable("Unknown unary operator lvalue!");
   case UO_Deref: {
     QualType T = E->getSubExpr()->getType()->getPointeeType();
     assert(!T.isNull() && "CodeGenFunction::EmitUnaryOpLValue: Illegal type");
@@ -1483,7 +1484,7 @@ LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) {
     std::string GlobalVarName;
 
     switch (Type) {
-    default: assert(0 && "Invalid type");
+    default: llvm_unreachable("Invalid type");
     case PredefinedExpr::Func:
       GlobalVarName = "__func__.";
       break;
@@ -1793,7 +1794,7 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(ND))
     return EmitFunctionDeclLValue(*this, E, FD);
 
-  assert(false && "Unhandled member declaration!");
+  llvm_unreachable("Unhandled member declaration!");
   return LValue();
 }
 
index 856378b34f0d9de2ef1e03e04003219d2bcce63d..c321faffcfd30312355df2c27a7c80e295f87a14 100644 (file)
@@ -318,7 +318,7 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
   case CK_DerivedToBase:
   case CK_BaseToDerived:
   case CK_UncheckedDerivedToBase: {
-    assert(0 && "cannot perform hierarchy conversion in EmitAggExpr: "
+    llvm_unreachable("cannot perform hierarchy conversion in EmitAggExpr: "
                 "should have been unpacked before we got here");
     break;
   }
index a92a7ad33e8bd8272e9b144ad8a95a827a683c08..13c96d4fae565240f19c8965163e69c0ed13c93a 100644 (file)
@@ -103,7 +103,7 @@ public:
     
   ComplexPairTy VisitStmt(Stmt *S) {
     S->dump(CGF.getContext().getSourceManager());
-    assert(0 && "Stmt can't have complex result type!");
+    llvm_unreachable("Stmt can't have complex result type!");
     return ComplexPairTy();
   }
   ComplexPairTy VisitExpr(Expr *S);
index d7dfa253ada5a97327df08e8ad2e11d9948ccb0c..2de13a4090d5f3197e8c1089a617da519a50f770 100644 (file)
@@ -780,7 +780,7 @@ public:
     if (ILE->getType()->isVectorType())
       return 0;
 
-    assert(0 && "Unable to handle InitListExpr");
+    llvm_unreachable("Unable to handle InitListExpr");
     // Get rid of control reaches end of void function warning.
     // Not reached.
     return 0;
@@ -966,7 +966,7 @@ llvm::Constant *CodeGenModule::EmitConstantExpr(const Expr *E,
   if (Success && !Result.HasSideEffects) {
     switch (Result.Val.getKind()) {
     case APValue::Uninitialized:
-      assert(0 && "Constant expressions should be initialized.");
+      llvm_unreachable("Constant expressions should be initialized.");
       return 0;
     case APValue::LValue: {
       llvm::Type *DestTy = getTypes().ConvertTypeForMem(DestType);
index 01acd42a063f6dae870a641ee3d0b2df11791498..90e123271565c90981b100372f73eb3cb4704f11 100644 (file)
@@ -153,7 +153,7 @@ public:
     
   Value *VisitStmt(Stmt *S) {
     S->dump(CGF.getContext().getSourceManager());
-    assert(0 && "Stmt can't have complex result type!");
+    llvm_unreachable("Stmt can't have complex result type!");
     return 0;
   }
   Value *VisitExpr(Expr *S);
@@ -1266,7 +1266,7 @@ EmitAddConsiderOverflowBehavior(const UnaryOperator *E,
     return EmitOverflowCheckedBinOp(BinOp);
     break;
   }
-  assert(false && "Unknown SignedOverflowBehaviorTy");
+  llvm_unreachable("Unknown SignedOverflowBehaviorTy");
   return 0;
 }
 
@@ -1780,7 +1780,7 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) {
     IID = llvm::Intrinsic::smul_with_overflow;
     break;
   default:
-    assert(false && "Unsupported operation for overflow detection");
+    llvm_unreachable("Unsupported operation for overflow detection");
     IID = 0;
   }
   OpID <<= 1;
@@ -2076,7 +2076,7 @@ enum IntrinsicType { VCMPEQ, VCMPGT };
 static llvm::Intrinsic::ID GetIntrinsic(IntrinsicType IT,
                                         BuiltinType::Kind ElemKind) {
   switch (ElemKind) {
-  default: assert(0 && "unexpected element type");
+  default: llvm_unreachable("unexpected element type");
   case BuiltinType::Char_U:
   case BuiltinType::UChar:
     return (IT == VCMPEQ) ? llvm::Intrinsic::ppc_altivec_vcmpequb_p :
@@ -2146,7 +2146,7 @@ Value *ScalarExprEmitter::EmitCompare(const BinaryOperator *E,unsigned UICmpOpc,
       BuiltinType::Kind ElementKind = BTy->getKind();
 
       switch(E->getOpcode()) {
-      default: assert(0 && "is not a comparison operation");
+      default: llvm_unreachable("is not a comparison operation");
       case BO_EQ:
         CR6 = CR6_LT;
         ID = GetIntrinsic(VCMPEQ, ElementKind);
@@ -2755,7 +2755,7 @@ LValue CodeGenFunction::EmitCompoundAssignmentLValue(
   case BO_LOr:
   case BO_Assign:
   case BO_Comma:
-    assert(false && "Not valid compound assignment operators");
+    llvm_unreachable("Not valid compound assignment operators");
     break;
   }
    
index b7855c85a2ba87832c57faebbffe04e84bc82c47..bdc11d2ce7c7d03ce08d33827367784aeb0f0dbd 100644 (file)
@@ -2333,7 +2333,7 @@ void CGObjCGNU::EmitObjCGlobalAssign(CodeGenFunction &CGF,
     B.CreateCall2(GlobalAssignFn, src, dst);
   else
     // FIXME. Add threadloca assign API
-    assert(false && "EmitObjCGlobalAssign - Threal Local API NYI");
+    llvm_unreachable("EmitObjCGlobalAssign - Threal Local API NYI");
 }
 
 void CGObjCGNU::EmitObjCIvarAssign(CodeGenFunction &CGF,
index 665b7f97c248c89e0738ae7c805d2fa8cc4b3e75..be574b3efeb2f4bded123ceeb96e6b99fd5a23c2 100644 (file)
@@ -1060,7 +1060,7 @@ public:
   /// GetClassGlobal - Return the global variable for the Objective-C
   /// class of the given name.
   virtual llvm::GlobalVariable *GetClassGlobal(const std::string &Name) {
-    assert(false && "CGObjCMac::GetClassGlobal");
+    llvm_unreachable("CGObjCMac::GetClassGlobal");
     return 0;
   }
 };
index 7accc70c9623e6cb45d0c84f3b7e40dccd498390..4fa47a740aafb771070b5bb1ef7b3aee41f4d538 100644 (file)
@@ -208,8 +208,7 @@ public:
   
   
   virtual llvm::Value *EmitNSAutoreleasePoolClassRef(CGBuilderTy &Builder) {
-    assert(false &&"autoreleasepool unsupported in this ABI");
-    return 0;
+    llvm_unreachable("autoreleasepool unsupported in this ABI");
   }
   
   /// EnumerationMutationFunction - Return the function that's called by the
index 2e3d966ab44f7c70c185ac51a5ae5e89f99c3b0b..1ce69d60932c63867db5dad894f3752c335fc144 100644 (file)
@@ -203,7 +203,7 @@ static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) {
     case BuiltinType::ObjCId:
     case BuiltinType::ObjCClass:
     case BuiltinType::ObjCSel:
-      assert(false && "FIXME: Objective-C types are unsupported!");
+      llvm_unreachable("FIXME: Objective-C types are unsupported!");
   }
   
   // Silent gcc.
@@ -393,11 +393,11 @@ void RTTIBuilder::BuildVTablePointer(const Type *Ty) {
 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
 #include "clang/AST/TypeNodes.def"
-    assert(false && "Non-canonical and dependent types shouldn't get here");
+    llvm_unreachable("Non-canonical and dependent types shouldn't get here");
 
   case Type::LValueReference:
   case Type::RValueReference:
-    assert(false && "References shouldn't get here");
+    llvm_unreachable("References shouldn't get here");
 
   case Type::Builtin:
   // GCC treats vector and complex types as fundamental types.
@@ -590,7 +590,7 @@ llvm::Constant *RTTIBuilder::BuildTypeInfo(QualType Ty, bool Force) {
 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
 #include "clang/AST/TypeNodes.def"
-    assert(false && "Non-canonical and dependent types shouldn't get here");
+    llvm_unreachable("Non-canonical and dependent types shouldn't get here");
 
   // GCC treats vector types as fundamental types.
   case Type::Builtin:
@@ -604,7 +604,7 @@ llvm::Constant *RTTIBuilder::BuildTypeInfo(QualType Ty, bool Force) {
 
   case Type::LValueReference:
   case Type::RValueReference:
-    assert(false && "References shouldn't get here");
+    llvm_unreachable("References shouldn't get here");
 
   case Type::ConstantArray:
   case Type::IncompleteArray:
index 461a173f53d146b3dbb401c2fcb51db9d6500fb1..3f986bd1cd65097be0d298cfb0684237586f7976 100644 (file)
@@ -137,10 +137,12 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
     EmitObjCAtTryStmt(cast<ObjCAtTryStmt>(*S));
     break;
   case Stmt::ObjCAtCatchStmtClass:
-    assert(0 && "@catch statements should be handled by EmitObjCAtTryStmt");
+    llvm_unreachable(
+                    "@catch statements should be handled by EmitObjCAtTryStmt");
     break;
   case Stmt::ObjCAtFinallyStmtClass:
-    assert(0 && "@finally statements should be handled by EmitObjCAtTryStmt");
+    llvm_unreachable(
+                  "@finally statements should be handled by EmitObjCAtTryStmt");
     break;
   case Stmt::ObjCAtThrowStmtClass:
     EmitObjCAtThrowStmt(cast<ObjCAtThrowStmt>(*S));
index 4743d579375b135f9b9a8c42eac7d5f0400ffea5..1a210faa33f9005cb6eae5f1995f1ea9a8344306 100644 (file)
@@ -263,7 +263,7 @@ static BaseOffset ComputeBaseOffset(ASTContext &Context,
   
   if (!const_cast<CXXRecordDecl *>(DerivedRD)->
       isDerivedFrom(const_cast<CXXRecordDecl *>(BaseRD), Paths)) {
-    assert(false && "Class must be derived from the passed in base class!");
+    llvm_unreachable("Class must be derived from the passed in base class!");
     return BaseOffset();
   }
 
@@ -303,7 +303,7 @@ ComputeReturnAdjustmentBaseOffset(ASTContext &Context,
     CanBaseReturnType = 
       CanBaseReturnType->getAs<PointerType>()->getPointeeType();
   } else {
-    assert(false && "Unexpected return type!");
+    llvm_unreachable("Unexpected return type!");
   }
   
   // We need to compare unqualified types here; consider
@@ -700,7 +700,7 @@ CharUnits VCallOffsetMap::getVCallOffsetOffset(const CXXMethodDecl *MD) {
       return Offsets[I].second;
   }
   
-  assert(false && "Should always find a vcall offset offset!");
+  llvm_unreachable("Should always find a vcall offset offset!");
   return CharUnits::Zero();
 }
 
@@ -1361,7 +1361,7 @@ VTableBuilder::ComputeThisAdjustmentBaseOffset(BaseSubobject Base,
 
   if (!const_cast<CXXRecordDecl *>(DerivedRD)->
       isDerivedFrom(const_cast<CXXRecordDecl *>(BaseRD), Paths)) {
-    assert(false && "Class must be derived from the passed in base class!");
+    llvm_unreachable("Class must be derived from the passed in base class!");
     return BaseOffset();
   }
 
@@ -1553,7 +1553,7 @@ VTableBuilder::IsOverriderUsed(const CXXMethodDecl *Overrider,
     }
     
     if (!PrimaryBases.insert(PrimaryBase))
-      assert(false && "Found a duplicate primary base!");
+      llvm_unreachable("Found a duplicate primary base!");
 
     RD = PrimaryBase;
   }
@@ -1627,7 +1627,7 @@ VTableBuilder::AddMethods(BaseSubobject Base, CharUnits BaseOffsetInLayoutClass,
                FirstBaseOffsetInLayoutClass, PrimaryBases);
     
     if (!PrimaryBases.insert(PrimaryBase))
-      assert(false && "Found a duplicate primary base!");
+      llvm_unreachable("Found a duplicate primary base!");
   }
 
   // Now go through all virtual member functions and add them.
@@ -2316,7 +2316,7 @@ CollectPrimaryBases(const CXXRecordDecl *RD, ASTContext &Context,
   CollectPrimaryBases(PrimaryBase, Context, PrimaryBases);
 
   if (!PrimaryBases.insert(PrimaryBase))
-    assert(false && "Found a duplicate primary base!");
+    llvm_unreachable("Found a duplicate primary base!");
 }
 
 void CodeGenVTables::ComputeMethodVTableIndices(const CXXRecordDecl *RD) {
index 54d3cb643fa851f52afc30c816e5c03847d57b1c..3251b76742544c5832cb368e1fa21bc2c4ad81aa 100644 (file)
@@ -275,7 +275,7 @@ static raw_ostream *GetOutputStream(CompilerInstance &CI,
     return CI.createDefaultOutputFile(true, InFile, "o");
   }
 
-  assert(0 && "Invalid action!");
+  llvm_unreachable("Invalid action!");
   return 0;
 }
 
index 1943a744c980ed6aceed8ae55937951600da2b33..e4633f9a74981f95a3fb675ad652c93a8bdd2d2e 100644 (file)
@@ -850,7 +850,7 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) {
   if (const VarDecl *VD = dyn_cast<VarDecl>(D))
     return EmitGlobalVarDefinition(VD);
   
-  assert(0 && "Invalid argument to EmitGlobalDefinition()");
+  llvm_unreachable("Invalid argument to EmitGlobalDefinition()");
 }
 
 /// GetOrCreateLLVMFunction - If the specified mangled name is not in the
index c96a7f3a515953cdc21bf39192a0a25c1681e3fb..8742f5999b9c81d6bcf27009fcc03317902e0c67 100644 (file)
@@ -273,7 +273,7 @@ static llvm::Type *getTypeForFormat(llvm::LLVMContext &VMContext,
     return llvm::Type::getPPC_FP128Ty(VMContext);
   if (&format == &llvm::APFloat::x87DoubleExtended)
     return llvm::Type::getX86_FP80Ty(VMContext);
-  assert(0 && "Unknown float format!");
+  llvm_unreachable("Unknown float format!");
   return 0;
 }
 
index bad8a1d928a9adf643331cadd9991aff8473bd6a..02e6a3be38cde22a716899fabafc0f128f01256d 100644 (file)
@@ -1706,7 +1706,7 @@ classifyReturnType(QualType RetTy) const {
 
   case SSEUp:
   case X87Up:
-    assert(0 && "Invalid classification for lo word.");
+    llvm_unreachable("Invalid classification for lo word.");
 
     // AMD64-ABI 3.2.3p4: Rule 2. Types of class memory are returned via
     // hidden argument.
@@ -1760,7 +1760,7 @@ classifyReturnType(QualType RetTy) const {
     // never occur as a hi class.
   case Memory:
   case X87:
-    assert(0 && "Invalid classification for hi word.");
+    llvm_unreachable("Invalid classification for hi word.");
 
   case ComplexX87: // Previously handled.
   case NoClass:
@@ -1848,7 +1848,7 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType(QualType Ty, unsigned &neededInt,
 
   case SSEUp:
   case X87Up:
-    assert(0 && "Invalid classification for lo word.");
+    llvm_unreachable("Invalid classification for lo word.");
 
     // AMD64-ABI 3.2.3p3: Rule 2. If the class is INTEGER, the next
     // available register of the sequence %rdi, %rsi, %rdx, %rcx, %r8
@@ -1892,7 +1892,7 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType(QualType Ty, unsigned &neededInt,
   case Memory:
   case X87:
   case ComplexX87:
-    assert(0 && "Invalid classification for hi word.");
+    llvm_unreachable("Invalid classification for hi word.");
     break;
 
   case NoClass: break;
index ac95446e5bb37591b6ab259910e203a0bb4880e4..65faa4ecee08db6db28bc5d9309dc4207fc2364d 100644 (file)
@@ -34,7 +34,7 @@ const char *Action::getClassName(ActionClass AC) {
   case VerifyJobClass: return "verify";
   }
 
-  assert(0 && "invalid class");
+  llvm_unreachable("invalid class");
   return 0;
 }
 
index d77ae9229c18b909bb7920af3464556a33cff8f2..d82c93a8859ff39cdb8cb5b585c7a7efb8e57917 100644 (file)
@@ -1076,7 +1076,7 @@ Action *Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase,
   llvm::PrettyStackTraceString CrashInfo("Constructing phase actions");
   // Build the appropriate action.
   switch (Phase) {
-  case phases::Link: assert(0 && "link action invalid here.");
+  case phases::Link: llvm_unreachable("link action invalid here.");
   case phases::Preprocess: {
     types::ID OutputTy;
     // -{M, MM} alter the output type.
@@ -1112,7 +1112,7 @@ Action *Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase,
     return new AssembleJobAction(Input, types::TY_Object);
   }
 
-  assert(0 && "invalid phase in ConstructPhaseAction");
+  llvm_unreachable("invalid phase in ConstructPhaseAction");
   return 0;
 }
 
index 780ea564dba6cfbb0596fa085bba71571192f93b..81e2022c0fd92b19e6a3be0d1aeb2214433237d4 100644 (file)
@@ -116,7 +116,7 @@ OptTable::OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos)
     if (!(getInfo(i) < getInfo(i + 1))) {
       getOption(i)->dump();
       getOption(i + 1)->dump();
-      assert(0 && "Options are not in order!");
+      llvm_unreachable("Options are not in order!");
     }
   }
 #endif
@@ -268,10 +268,10 @@ static std::string getOptionHelpName(const OptTable &Opts, OptSpecifier Id) {
   // Add metavar, if used.
   switch (Opts.getOptionKind(Id)) {
   case Option::GroupClass: case Option::InputClass: case Option::UnknownClass:
-    assert(0 && "Invalid option with help text.");
+    llvm_unreachable("Invalid option with help text.");
 
   case Option::MultiArgClass:
-    assert(0 && "Cannot print metavar for this kind of option.");
+    llvm_unreachable("Cannot print metavar for this kind of option.");
 
   case Option::FlagClass:
     break;
index 90d21a3d0b17aaad9caf1433a4c10bb43dc2d86e..f1ef7ab175be5a1796761d2d6ffc34f3df5c4f82 100644 (file)
@@ -61,7 +61,7 @@ void Option::dump() const {
   llvm::errs() << "<";
   switch (Kind) {
   default:
-    assert(0 && "Invalid kind");
+    llvm_unreachable("Invalid kind");
 #define P(N) case N: llvm::errs() << #N; break
     P(GroupClass);
     P(InputClass);
@@ -114,7 +114,7 @@ OptionGroup::OptionGroup(OptSpecifier ID, const char *Name,
 }
 
 Arg *OptionGroup::accept(const ArgList &Args, unsigned &Index) const {
-  assert(0 && "accept() should never be called on an OptionGroup");
+  llvm_unreachable("accept() should never be called on an OptionGroup");
   return 0;
 }
 
@@ -123,7 +123,7 @@ InputOption::InputOption(OptSpecifier ID)
 }
 
 Arg *InputOption::accept(const ArgList &Args, unsigned &Index) const {
-  assert(0 && "accept() should never be called on an InputOption");
+  llvm_unreachable("accept() should never be called on an InputOption");
   return 0;
 }
 
@@ -132,7 +132,7 @@ UnknownOption::UnknownOption(OptSpecifier ID)
 }
 
 Arg *UnknownOption::accept(const ArgList &Args, unsigned &Index) const {
-  assert(0 && "accept() should never be called on an UnknownOption");
+  llvm_unreachable("accept() should never be called on an UnknownOption");
   return 0;
 }
 
index f36000214ab0dd68f69466277e9c94e0e9269a9f..d7f6ab94474beb93ea125afc0a1fde18b9af0b66 100644 (file)
@@ -22,6 +22,6 @@ const char *phases::getPhaseName(ID Id) {
   case Link: return "linker";
   }
 
-  assert(0 && "Invalid phase id.");
+  llvm_unreachable("Invalid phase id.");
   return 0;
 }
index 92c3ec9539ba30bf3384e18285cbd22da2f82c27..b11fc89aa6af4a26eb3355e6662085be7cfb23fe 100644 (file)
@@ -243,7 +243,7 @@ Tool &Darwin::SelectTool(const Compilation &C, const JobAction &JA,
     switch (Key) {
     case Action::InputClass:
     case Action::BindArchClass:
-      assert(0 && "Invalid tool kind.");
+      llvm_unreachable("Invalid tool kind.");
     case Action::PreprocessJobClass:
       T = new tools::darwin::Preprocess(*this); break;
     case Action::AnalyzeJobClass:
@@ -323,7 +323,7 @@ void DarwinClang::AddLinkSearchPathArgs(const ArgList &Args,
   P.appendComponent("gcc");
   switch (getTriple().getArch()) {
   default:
-    assert(0 && "Invalid Darwin arch!");
+    llvm_unreachable("Invalid Darwin arch!");
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
     P.appendComponent("i686-apple-darwin10");
@@ -1002,7 +1002,7 @@ Tool &Generic_GCC::SelectTool(const Compilation &C,
     switch (Key) {
     case Action::InputClass:
     case Action::BindArchClass:
-      assert(0 && "Invalid tool kind.");
+      llvm_unreachable("Invalid tool kind.");
     case Action::PreprocessJobClass:
       T = new tools::gcc::Preprocess(*this); break;
     case Action::PrecompileJobClass:
@@ -1093,7 +1093,7 @@ Tool &TCEToolChain::SelectTool(const Compilation &C,
     case Action::AnalyzeJobClass:
       T = new tools::Clang(*this); break;
     default:
-     assert(false && "Unsupported action for TCE target.");
+     llvm_unreachable("Unsupported action for TCE target.");
     }
   }
   return *T;
@@ -1805,7 +1805,7 @@ Tool &Windows::SelectTool(const Compilation &C, const JobAction &JA,
     case Action::LipoJobClass:
     case Action::DsymutilJobClass:
     case Action::VerifyJobClass:
-      assert(0 && "Invalid tool kind.");
+      llvm_unreachable("Invalid tool kind.");
     case Action::PreprocessJobClass:
     case Action::PrecompileJobClass:
     case Action::AnalyzeJobClass:
index c3c07f412f803a2ca88440cd6d3c270201dc92ae..dba4c22d7dd1703d1975750993b2fe23ae9d26aa 100644 (file)
@@ -2477,7 +2477,7 @@ void gcc::Link::RenderExtraToolArgs(const JobAction &JA,
 const char *darwin::CC1::getCC1Name(types::ID Type) const {
   switch (Type) {
   default:
-    assert(0 && "Unexpected type for Darwin CC1 tool.");
+    llvm_unreachable("Unexpected type for Darwin CC1 tool.");
   case types::TY_Asm:
   case types::TY_C: case types::TY_CHeader:
   case types::TY_PP_C: case types::TY_PP_CHeader:
index 6412727cd74bd7afe45b07232290bf259199ca1d..70baf7454512f0a4ae823c5072057807db715e41 100644 (file)
@@ -286,7 +286,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
   }
 
   default:
-    assert(0 && "a decl that inherits DeclContext isn't handled");
+    llvm_unreachable("a decl that inherits DeclContext isn't handled");
   }
 
   Out << "\n";
@@ -392,7 +392,7 @@ void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
     }
     default:
       Out << "DeclKind: " << DK << '"' << *I << "\"\n";
-      assert(0 && "decl unhandled");
+      llvm_unreachable("decl unhandled");
     }
   }
 }
index e69926137918a881428e786861bad859a0f9229d..03d06e63d3d0b4aaf00322446d9576f7ed68133f 100644 (file)
@@ -1164,7 +1164,7 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
   if (const Arg *A = Args.getLastArg(OPT_Action_Group)) {
     switch (A->getOption().getID()) {
     default:
-      assert(0 && "Invalid option in group!");
+      llvm_unreachable("Invalid option in group!");
     case OPT_ast_dump:
       Opts.ProgramAction = frontend::ASTDump; break;
     case OPT_ast_dump_xml:
@@ -1457,7 +1457,7 @@ void CompilerInvocation::setLangDefaults(LangOptions &Opts, InputKind IK,
     case IK_None:
     case IK_AST:
     case IK_LLVM_IR:
-      assert(0 && "Invalid input kind!");
+      llvm_unreachable("Invalid input kind!");
     case IK_OpenCL:
       LangStd = LangStandard::lang_opencl;
       break;
index 069c86de137f66b2f92f6661b89e299d3990a9b8..c03ac54411216182084731a54d89ab5e75ec0b6a 100644 (file)
@@ -26,7 +26,8 @@ void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level,
   llvm::SmallString<100> Buf;
   Info.FormatDiagnostic(Buf);
   switch (Level) {
-  default: assert(0 && "Diagnostic not handled during diagnostic buffering!");
+  default: llvm_unreachable(
+                         "Diagnostic not handled during diagnostic buffering!");
   case Diagnostic::Note:
     Notes.push_back(std::make_pair(Info.getLocation(), Buf.str()));
     break;
index 4fc694978ccb96bb416ea74a665acf516c39e4a2..762a7c528c1e19168195cb3af9c316b41468e2c7 100644 (file)
@@ -1083,7 +1083,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
   if (DiagOpts->ShowColors) {
     // Print diagnostic category in bold and color
     switch (Level) {
-    case Diagnostic::Ignored: assert(0 && "Invalid diagnostic type");
+    case Diagnostic::Ignored: llvm_unreachable("Invalid diagnostic type");
     case Diagnostic::Note:    OS.changeColor(noteColor, true); break;
     case Diagnostic::Warning: OS.changeColor(warningColor, true); break;
     case Diagnostic::Error:   OS.changeColor(errorColor, true); break;
@@ -1092,7 +1092,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level,
   }
 
   switch (Level) {
-  case Diagnostic::Ignored: assert(0 && "Invalid diagnostic type");
+  case Diagnostic::Ignored: llvm_unreachable("Invalid diagnostic type");
   case Diagnostic::Note:    OS << "note: "; break;
   case Diagnostic::Warning: OS << "warning: "; break;
   case Diagnostic::Error:   OS << "error: "; break;
index 8ea49c16f858c35f2e8216d13d0c09a3710fdbac..6746004bc78107e8a5bf5ae08e473dc9f600f071 100644 (file)
@@ -41,7 +41,7 @@ Decl *ASTLocation::getReferencedDecl() {
     return 0;
 
   switch (getKind()) {
-  default: assert(0 && "Invalid Kind");
+  default: llvm_unreachable("Invalid Kind");
   case N_Type:
     return 0;
   case N_Decl:
@@ -60,7 +60,7 @@ SourceRange ASTLocation::getSourceRange() const {
     return SourceRange();
 
   switch (getKind()) {
-  default: assert(0 && "Invalid Kind");
+  default: llvm_unreachable("Invalid Kind");
     return SourceRange();
   case N_Decl:
     return D->getSourceRange();
index 986a08a3ce7bb7a69f3f241711c1126155bee0d7..4496834defd4fe6fc868e872632c53375f2500b1 100644 (file)
@@ -30,7 +30,7 @@ static int HexDigitValue(char C) {
 
 static unsigned getCharWidth(tok::TokenKind kind, const TargetInfo &Target) {
   switch (kind) {
-  default: assert(0 && "Unknown token type!");
+  default: llvm_unreachable("Unknown token type!");
   case tok::char_constant:
   case tok::string_literal:
   case tok::utf8_string_literal:
index 2f810973b1ab62127e26d1091aed92625f8fe0f5..120b2ca034f7698900e3911b7083c3cda09e1b56 100644 (file)
@@ -535,7 +535,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
 
     bool Overflow = false;
     switch (Operator) {
-    default: assert(0 && "Unknown operator token!");
+    default: llvm_unreachable("Unknown operator token!");
     case tok::percent:
       if (RHS.Val != 0)
         Res = LHS.Val % RHS.Val;
index 9a16d584ab052cfea02bbb0a04ae7b57cbcbcead..ce4c1ed7dfcb56449718b0a558aa92c9700632df 100644 (file)
@@ -1015,7 +1015,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
     OS << (int)Value;
     Tok.setKind(tok::numeric_constant);
   } else {
-    assert(0 && "Unknown identifier!");
+    llvm_unreachable("Unknown identifier!");
   }
   CreateString(OS.str().data(), OS.str().size(), Tok, Tok.getLocation());
 }
index 5a2f5cbaded69381f6ce7e145de35e5e93b57dd0..d855baf9e2907b31ae46670603601463d226954f 100644 (file)
@@ -804,7 +804,7 @@ struct PragmaDebugHandler : public PragmaHandler {
     IdentifierInfo *II = Tok.getIdentifierInfo();
 
     if (II->isStr("assert")) {
-      assert(0 && "This is an assertion!");
+      llvm_unreachable("This is an assertion!");
     } else if (II->isStr("crash")) {
       *(volatile int*) 0x11 = 0;
     } else if (II->isStr("llvm_fatal_error")) {
index f1c6d1256d4c17e067e28a6094cdbc2ecd404713..738040103f5b41e089d792303e2f0213f2d8c201 100644 (file)
@@ -1585,7 +1585,7 @@ ExprResult Parser::ParseBuiltinPrimaryExpression() {
   // TODO: Build AST.
 
   switch (T) {
-  default: assert(0 && "Not a builtin primary expression!");
+  default: llvm_unreachable("Not a builtin primary expression!");
   case tok::kw___builtin_va_arg: {
     ExprResult Expr(ParseAssignmentExpression());
 
index baec6fdd7304c24c27226f2762d5f6586e721a14..c575507c554be41f13b837790273021ec346d8c9 100644 (file)
@@ -29,7 +29,7 @@ static int SelectDigraphErrorMessage(tok::TokenKind Kind) {
     case tok::kw_reinterpret_cast: return 3;
     case tok::kw_static_cast:      return 4;
     default:
-      assert(0 && "Unknown type for digraph error message.");
+      llvm_unreachable("Unknown type for digraph error message.");
       return -1;
   }
 }
@@ -784,7 +784,7 @@ ExprResult Parser::ParseCXXCasts() {
   const char *CastName = 0;     // For error messages
 
   switch (Kind) {
-  default: assert(0 && "Unknown C++ cast!"); abort();
+  default: llvm_unreachable("Unknown C++ cast!"); abort();
   case tok::kw_const_cast:       CastName = "const_cast";       break;
   case tok::kw_dynamic_cast:     CastName = "dynamic_cast";     break;
   case tok::kw_reinterpret_cast: CastName = "reinterpret_cast"; break;
@@ -1289,9 +1289,9 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
   switch (Tok.getKind()) {
   case tok::identifier:   // foo::bar
   case tok::coloncolon:   // ::foo::bar
-    assert(0 && "Annotation token should already be formed!");
+    llvm_unreachable("Annotation token should already be formed!");
   default:
-    assert(0 && "Not a simple-type-specifier token!");
+    llvm_unreachable("Not a simple-type-specifier token!");
     abort();
 
   // type-name
@@ -2200,7 +2200,7 @@ Parser::ParseCXXDeleteExpression(bool UseGlobal, SourceLocation Start) {
 
 static UnaryTypeTrait UnaryTypeTraitFromTokKind(tok::TokenKind kind) {
   switch(kind) {
-  default: assert(false && "Not a known unary type trait.");
+  default: llvm_unreachable("Not a known unary type trait.");
   case tok::kw___has_nothrow_assign:      return UTT_HasNothrowAssign;
   case tok::kw___has_nothrow_constructor: return UTT_HasNothrowConstructor;
   case tok::kw___has_nothrow_copy:           return UTT_HasNothrowCopy;
@@ -2268,7 +2268,7 @@ static ArrayTypeTrait ArrayTypeTraitFromTokKind(tok::TokenKind kind) {
 
 static ExpressionTrait ExpressionTraitFromTokKind(tok::TokenKind kind) {
   switch(kind) {
-  default: assert(false && "Not a known unary expression trait.");
+  default: llvm_unreachable("Not a known unary expression trait.");
   case tok::kw___is_lvalue_expr:             return ET_IsLValueExpr;
   case tok::kw___is_rvalue_expr:             return ET_IsRValueExpr;
   }
index a8bf422766e6e5cb587b65aa85230cf46ce5e5e4..a9c2a755f9261077ea6a257f3d2d740d4d6da191 100644 (file)
@@ -761,7 +761,7 @@ void Parser::ParseObjCTypeQualifierList(ObjCDeclSpec &DS,
 
       ObjCDeclSpec::ObjCDeclQualifier Qual;
       switch (i) {
-      default: assert(0 && "Unknown decl qualifier");
+      default: llvm_unreachable("Unknown decl qualifier");
       case objc_in:     Qual = ObjCDeclSpec::DQ_In; break;
       case objc_out:    Qual = ObjCDeclSpec::DQ_Out; break;
       case objc_inout:  Qual = ObjCDeclSpec::DQ_Inout; break;
index fa287fd53496d8e6caacba0241edcab93feb9363..4f9c1748ce8a8c061f32c1d484f0bbf64f4a9626 100644 (file)
@@ -1066,7 +1066,7 @@ void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
 void RewriteObjC::RewriteForwardProtocolDecl(ObjCForwardProtocolDecl *PDecl) {
   SourceLocation LocStart = PDecl->getLocation();
   if (LocStart.isInvalid())
-    assert(false && "Invalid SourceLocation");
+    llvm_unreachable("Invalid SourceLocation");
   // FIXME: handle forward protocol that are declared across multiple lines.
   ReplaceText(LocStart, 0, "// ");
 }
@@ -2063,7 +2063,7 @@ Stmt *RewriteObjC::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
       // declares the @catch parameter).
       ReplaceText(rParenLoc, bodyBuf-rParenBuf+1, " = _caught;");
     } else {
-      assert(false && "@catch rewrite bug");
+      llvm_unreachable("@catch rewrite bug");
     }
   }
   // Complete the catch list...
@@ -3434,7 +3434,7 @@ void RewriteObjC::SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl,
   }
   // Mark this struct as having been generated.
   if (!ObjCSynthesizedStructs.insert(CDecl))
-    assert(false && "struct already synthesize- SynthesizeObjCInternalStruct");
+    llvm_unreachable("struct already synthesize- SynthesizeObjCInternalStruct");
 }
 
 // RewriteObjCMethodsMetaData - Rewrite methods metadata for instance or
@@ -3655,7 +3655,7 @@ RewriteObjCProtocolMetaData(ObjCProtocolDecl *PDecl, StringRef prefix,
 
   // Mark this protocol as having been generated.
   if (!ObjCSynthesizedProtocols.insert(PDecl))
-    assert(false && "protocol already synthesized");
+    llvm_unreachable("protocol already synthesized");
 
 }
 
@@ -5048,7 +5048,7 @@ void RewriteObjC::RewriteBlockPointerDecl(NamedDecl *ND) {
   else if (FieldDecl *FD = dyn_cast<FieldDecl>(ND))
     DeclT = FD->getType();
   else
-    assert(0 && "RewriteBlockPointerDecl(): Decl type not yet handled");
+    llvm_unreachable("RewriteBlockPointerDecl(): Decl type not yet handled");
 
   const char *startBuf = SM->getCharacterData(DeclLoc);
   const char *endBuf = startBuf;
@@ -5966,7 +5966,7 @@ void RewriteObjC::HandleDeclInMainFile(Decl *D) {
   else if (ObjCCategoryImplDecl *CI = dyn_cast<ObjCCategoryImplDecl>(D))
     CategoryImplementation.push_back(CI);
   else if (isa<ObjCClassDecl>(D))
-    assert(false && "RewriteObjC::HandleDeclInMainFile - ObjCClassDecl");
+    llvm_unreachable("RewriteObjC::HandleDeclInMainFile - ObjCClassDecl");
   else if (VarDecl *VD = dyn_cast<VarDecl>(D)) {
     RewriteObjCQualifiedInterfaceTypes(VD);
     if (isTopLevelBlockPointerType(VD->getType()))
index fad1199613ed7471fc981e09bfed35f3e9c100d8..7e2f4ad281f7fb219681cc7da9d3e4110c4a5e21 100644 (file)
@@ -650,7 +650,7 @@ bool DeclSpec::SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec,
   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 @@ bool VirtSpecifiers::SetSpecifier(Specifier VS, SourceLocation Loc,
   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 @@ bool VirtSpecifiers::SetSpecifier(Specifier VS, SourceLocation Loc,
 
 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";
   }
index 95420a316ad07b0969e53555d9431c4e0c76d425..a6432670856a772b22299b4d4f36ec5b7de34dbe 100644 (file)
@@ -73,7 +73,7 @@ void IdentifierResolver::IdDeclInfo::RemoveDecl(NamedDecl *D) {
     }
   }
 
-  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
index 1c498925b71291f9868692791e2eec96872f2f71..cd03069ec854409a807ee3901af1cefaad9d879f 100644 (file)
@@ -265,7 +265,7 @@ void Sema::ActOnPragmaPack(PragmaPackKind Kind, IdentifierInfo *Name,
     break;
 
   default:
-    assert(0 && "Invalid #pragma pack kind.");
+    llvm_unreachable("Invalid #pragma pack kind.");
   }
 }
 
index a2cef9cf931e6b9896c2e1b7e246ef4d9bfb40aa..90fd7cdc40910cd2051e6550d430eaab55ece1b0 100644 (file)
@@ -137,7 +137,7 @@ DeclContext *Sema::computeDeclContext(const CXXScopeSpec &SS,
 
   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:
index cda4d92d2f5adda313e3ddb1df6340abf1d7e0e5..052ef3bef2b74d2973a0429917117856d3ec6b91 100644 (file)
@@ -548,7 +548,7 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) {
   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;
index 5b4484142834c1d6403ceec57049f097eaab2134..166e165d6912e62e6633e49601fbaea6af8dcaa6 100644 (file)
@@ -3400,7 +3400,7 @@ void Sema::CodeCompleteTag(Scope *S, unsigned TagSpec) {
     break;
     
   default:
-    assert(false && "Unknown type specifier kind in CodeCompleteTag");
+    llvm_unreachable("Unknown type specifier kind in CodeCompleteTag");
     return;
   }
   
index 0e817658ae0656a871ccd69924686155639a2dc0..3878341ca7a4c454f86ef21a52a4eb099717a22b 100644 (file)
@@ -2935,7 +2935,7 @@ Sema::GetNameFromUnqualifiedId(const UnqualifiedId &Name) {
 
   } // switch (Name.getKind())
 
-  assert(false && "Unknown name kind");
+  llvm_unreachable("Unknown name kind");
   return DeclarationNameInfo();
 }
 
@@ -4360,7 +4360,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
   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 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) {
         }
       }
 
-      assert(0 && "found no user-declared constructors");
+      llvm_unreachable("found no user-declared constructors");
       return;
     }
     break;
@@ -8458,7 +8458,7 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) {
   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 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) {
     }
   }
 
-  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 @@ void Sema::DiagnoseNontrivial(const RecordType* T, CXXSpecialMember member) {
 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;
index 48f2f9675a5fd0851af8c4b41d66fea9e209d274..34eb49888dd4d805af951de08cda0a4e566d322b 100644 (file)
@@ -3205,7 +3205,7 @@ static void handleNSReturnsRetainedAttr(Sema &S, Decl *D,
 
   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(),
index 616f798594e57c1e3544c90c1d9c4993660c4284..ef8719c48e5d6f14fbc862454386b92a152e80a4 100644 (file)
@@ -9977,7 +9977,7 @@ void Sema::SetDeclDefaulted(Decl *Dcl, SourceLocation DefaultLoc) {
     }
 
     case CXXInvalid:
-      assert(false && "Invalid special member.");
+      llvm_unreachable("Invalid special member.");
       break;
     }
   } else {
index 94de7992ba1a935d15a345737c305ee5a56b3293..5a1ce281936dd64daf6fae072da10764af7a4461 100644 (file)
@@ -1664,7 +1664,7 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
       DiagnoseUnimplementedProperties(S, IMPDecl, CDecl, InsMap);      
     } 
   } else
-    assert(false && "invalid ObjCContainerDecl type.");
+    llvm_unreachable("invalid ObjCContainerDecl type.");
 }
 
 /// ActOnForwardClassDeclaration -
index 65bed3a205e100ec428c8e6c3410d65291095657..aba7b34977347cb94013aa832248c6b74cf2227d 100644 (file)
@@ -223,7 +223,7 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New) {
       break;
 
     default:
-      assert(false && "This spec type is compatible with none.");
+      llvm_unreachable("This spec type is compatible with none.");
     }
     OS.flush();
 
index 7106ab2d1623d42410a1d89673c2d80fd2341ac9..582f153299be7f2120e243f94a0e322dcfb3edad 100644 (file)
@@ -2390,7 +2390,7 @@ ExprResult Sema::ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind) {
   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 @@ Sema::ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
                           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 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
       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 @@ static QualType CheckAddressOfOperand(Sema &S, Expr *OrigOp,
         }
       }
     } 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 @@ static inline BinaryOperatorKind ConvertTokenKindToBinaryOpcode(
   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 @@ static inline UnaryOperatorKind ConvertTokenKindToUnaryOpcode(
   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 @@ ExprResult Sema::ActOnGNUNullExpr(SourceLocation TokenLoc) {
   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 Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
   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;
index 140fd9003daabaa1ee40165a0ccfb3f480f68fc7..3beb51c865ebda9111b3d188a2df7fc3b5bbc1bd 100644 (file)
@@ -1525,7 +1525,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range,
     return true;
   }
   }
-  assert(false && "Unreachable, bad result from BestViableFunction");
+  llvm_unreachable("Unreachable, bad result from BestViableFunction");
   return true;
 }
 
@@ -2068,7 +2068,7 @@ static ExprResult BuildCXXCastArgument(Sema &S,
                                        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 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
      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 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
     break;
 
   default:
-    assert(false && "Improper first standard conversion");
+    llvm_unreachable("Improper first standard conversion");
     break;
   }
 
@@ -2524,7 +2524,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
   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 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
     }
 
   default:
-    assert(false && "Improper third standard conversion");
+    llvm_unreachable("Improper third standard conversion");
     break;
   }
 
@@ -3560,7 +3560,7 @@ static bool FindConditionalOverload(Sema &Self, ExprResult &LHS, ExprResult &RHS
       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;
index 43477b266d3b7bdd9d34b8abd95cb08d36919319..f710380720d00d1530723cd608935ea4807605ec 100644 (file)
@@ -512,7 +512,7 @@ void InitListChecker::CheckImplicitInitList(const InitializedEntity &Entity,
   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 @@ void InitListChecker::CheckListElementTypes(const InitializedEntity &Entity,
                      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;
index 806fd39fee3b260878f391ad8bea4f1738b7cf62..7f42fb7178058f7b3b324297091465c9c4b5b995 100644 (file)
@@ -4657,7 +4657,7 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion,
     break;
 
   default:
-    assert(false &&
+    llvm_unreachable(
            "Can only end up with a standard conversion sequence or failure");
   }
 }
@@ -5039,7 +5039,7 @@ BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
       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 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
   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 @@ Sema::AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
   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 @@ static unsigned
 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 @@ Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE,
     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");
index 274c74c7b6c474e215d2f8f01802de046f1b8bc1..c75e337fdb7cd6cb1f61c5ce84beaae4031f65e1 100644 (file)
@@ -1387,7 +1387,7 @@ Sema::BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation ColonLoc,
       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();
       }
 
index 43fdcb6d4ae39f02bf67fbcf180c6515540036e6..4f90a72ea2fdf21dc2f0d8d3d74f019393eb00a2 100644 (file)
@@ -2323,7 +2323,8 @@ TemplateNameKind Sema::ActOnDependentTemplateName(Scope *S,
     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 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param,
 
     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 @@ bool Sema::CheckTemplateArgument(NamedDecl *Param,
 
   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 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
   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 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
     break;
   }
 
-  assert(false && "Missing specialization/instantiation case?");
+  llvm_unreachable("Missing specialization/instantiation case?");
 
   return false;
 }
index add8e10831ba3d0e6dde7ef0725dc257844bd835..283cc575ad60cd269f4df7198adafadb0c789fcd 100644 (file)
@@ -1539,7 +1539,7 @@ DeduceTemplateArguments(Sema &S,
 
   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 @@ static bool isSameTemplateArg(ASTContext &Context,
 
   switch (X.getKind()) {
     case TemplateArgument::Null:
-      assert(false && "Comparing NULL template argument");
+      llvm_unreachable("Comparing NULL template argument");
       break;
 
     case TemplateArgument::Type:
index ffd7955fdf6b0097e594a728742ec8b88ac7121b..d4406240d0e259041eb5ab1063f84d2097d9efd0 100644 (file)
@@ -96,7 +96,7 @@ void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
 
 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 @@ TemplateDeclInstantiator::VisitLabelDecl(LabelDecl *D) {
 
 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::VisitEnumDecl(EnumDecl *D) {
 }
 
 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 @@ void Sema::PerformPendingInstantiations(bool LocalOnly) {
     // 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.
index 6b98ed872175200624d12837b3148d27646a06cd..2b4a509f11193e544170bcb5398232dbf7b07e0b 100644 (file)
@@ -1750,7 +1750,7 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state,
 
     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 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state,
       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 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
     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 @@ ParsedType Sema::CreateParsedType(QualType T, TypeSourceInfo *TInfo) {
 
 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");
 }
index 27376816ec17c26bbcce57c282e3436353d1db3b..0c22c61b66256790efe3946b05c935082c62b130 100644 (file)
@@ -1728,7 +1728,7 @@ public:
                                                    SubExpr, RParenLoc);
 
     default:
-      assert(false && "Invalid C++ named cast");
+      llvm_unreachable("Invalid C++ named cast");
       break;
     }
 
@@ -2681,7 +2681,7 @@ TreeTransform<Derived>
   }
   }
 
-  assert(0 && "Unknown name kind.");
+  llvm_unreachable("Unknown name kind.");
   return DeclarationNameInfo();
 }
 
@@ -8049,7 +8049,7 @@ TreeTransform<Derived>::TransformBlockDeclRefExpr(BlockDeclRefExpr *E) {
 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);
 }
   
index f83f709ebef455928b3d662c36a6bb53950dcbf4..4d92e314bc7d8dc98813703eb2f4dca6da715a01 100644 (file)
@@ -4993,7 +4993,7 @@ ASTReader::ReadTemplateName(Module &F, const RecordData &Record,
   }
   }
 
-  assert(0 && "Unhandled template name kind!");
+  llvm_unreachable("Unhandled template name kind!");
   return TemplateName();
 }
 
@@ -5033,7 +5033,7 @@ ASTReader::ReadTemplateArgument(Module &F,
   }
   }
 
-  assert(0 && "Unhandled template argument kind!");
+  llvm_unreachable("Unhandled template argument kind!");
   return TemplateArgument();
 }
 
index 01b635ef97b543f50f85907c43973d61d0551b8d..38f5f49734e944f93df51362e40df1a3839f65c3 100644 (file)
@@ -345,7 +345,7 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
   ReadDeclarationNameLoc(FD->DNLoc, FD->getDeclName(), Record, Idx);
   FD->IdentifierNamespace = Record[Idx++];
   switch ((FunctionDecl::TemplatedKind)Record[Idx++]) {
-  default: assert(false && "Unhandled TemplatedKind!");
+  default: llvm_unreachable("Unhandled TemplatedKind!");
     break;
   case FunctionDecl::TK_NonTemplate:
     break;
@@ -955,7 +955,7 @@ void ASTDeclReader::VisitCXXRecordDecl(CXXRecordDecl *D) {
   };
   switch ((CXXRecKind)Record[Idx++]) {
   default:
-    assert(false && "Out of sync with ASTDeclWriter::VisitCXXRecordDecl?");
+    llvm_unreachable("Out of sync with ASTDeclWriter::VisitCXXRecordDecl?");
   case CXXRecNotTemplate:
     break;
   case CXXRecTemplate:
@@ -1306,8 +1306,8 @@ void ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) {
   RedeclKind Kind = (RedeclKind)Record[Idx++];
   switch (Kind) {
   default:
-    assert(0 && "Out of sync with ASTDeclWriter::VisitRedeclarable or messed up"
-                " reading");
+    llvm_unreachable("Out of sync with ASTDeclWriter::VisitRedeclarable or"
+                     " messed up reading");
   case NoRedeclaration:
     break;
   case PointsToPrevious: {
@@ -1480,7 +1480,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
   switch ((DeclCode)DeclsCursor.ReadRecord(Code, Record)) {
   case DECL_CONTEXT_LEXICAL:
   case DECL_CONTEXT_VISIBLE:
-    assert(false && "Record cannot be de-serialized with ReadDeclRecord");
+    llvm_unreachable("Record cannot be de-serialized with ReadDeclRecord");
     break;
   case DECL_TYPEDEF:
     D = TypedefDecl::Create(Context, 0, SourceLocation(), SourceLocation(),
index 3286a177794057ca8ee12effc3703d999fb99861..494f4aa354673bbc280e01ee8e1162d9eb1348db 100644 (file)
@@ -91,7 +91,7 @@ namespace {
 }
 
 void ASTTypeWriter::VisitBuiltinType(const BuiltinType *T) {
-  assert(false && "Built-in types are never serialized");
+  llvm_unreachable("Built-in types are never serialized");
 }
 
 void ASTTypeWriter::VisitComplexType(const ComplexType *T) {
@@ -305,7 +305,7 @@ void
 ASTTypeWriter::VisitDependentSizedExtVectorType(
                                         const DependentSizedExtVectorType *T) {
   // FIXME: Serialize this type (C++ only)
-  assert(false && "Cannot serialize dependent sized extended vector types");
+  llvm_unreachable("Cannot serialize dependent sized extended vector types");
 }
 
 void
index a7468a77a337684cba73a87bd3c6231d4b46f6ca..5a5963c5ecdeea50cf43911e4f56aceae1a2acbf 100644 (file)
@@ -295,7 +295,7 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
   Record.push_back(D->getIdentifierNamespace());
   Record.push_back(D->getTemplatedKind());
   switch (D->getTemplatedKind()) {
-  default: assert(false && "Unhandled TemplatedKind!");
+  default: llvm_unreachable("Unhandled TemplatedKind!");
     break;
   case FunctionDecl::TK_NonTemplate:
     break;
index 5f1e4de7405ef959902f63e701f68cf124896714..a8c02a557f021b600e2d1d2b3f3fce095c47e833 100644 (file)
@@ -1440,7 +1440,7 @@ void ASTWriter::WriteSubStmt(Stmt *S) {
     SourceManager &SrcMgr
       = DeclIDs.begin()->first->getASTContext().getSourceManager();
     S->dump(SrcMgr);
-    assert(0 && "Unhandled sub statement writing AST file");
+    llvm_unreachable("Unhandled sub statement writing AST file");
   }
 #endif
 
index c63603ae6908f8f855aa943e0167d8e26310bc97..66943fddef1b370f0ee79bb9beeabc06174ac546 100644 (file)
@@ -82,7 +82,7 @@ SourceRange StackAddrEscapeChecker::GenName(raw_ostream &os,
     range = TOR->getExpr()->getSourceRange();
   }
   else {
-    assert(false && "Invalid region in ReturnStackAddressChecker.");
+    llvm_unreachable("Invalid region in ReturnStackAddressChecker.");
   } 
   
   return range;
index 901190d901dde7acb61ab4864a81b52308966b16..0936d61784ac6ec8c8616839a4c3c95809d3cba3 100644 (file)
@@ -46,7 +46,7 @@ public:
 void AggExprVisitor::VisitCastExpr(CastExpr *E) {
   switch (E->getCastKind()) {
   default: 
-    assert(0 && "Unhandled cast kind");
+    llvm_unreachable("Unhandled cast kind");
   case CK_NoOp:
   case CK_ConstructorConversion:
   case CK_UserDefinedConversion:
index 3936d561c5729890332a64aa7e30058d9d0e5621..b87c9eba185fdd597f910d87c02855adcd2471da 100644 (file)
@@ -1742,7 +1742,7 @@ FindReportInEquivalenceClass(BugReportEquivClass& EQ,
     if (!errorNode)
       continue;
     if (errorNode->isSink()) {
-      assert(false &&
+      llvm_unreachable(
            "BugType::isSuppressSink() should not be 'true' for sink end nodes");
       return 0;
     }
index 06c3af1c0ae83d818f3cff3a8e4eebde9f30fabc..6a860428d64d1472167d35692537f3df4fb7b608 100644 (file)
@@ -326,7 +326,7 @@ void CoreEngine::HandleBlockExit(const CFGBlock * B, ExplodedNode *Pred) {
   if (const Stmt *Term = B->getTerminator()) {
     switch (Term->getStmtClass()) {
       default:
-        assert(false && "Analysis for this terminator not implemented.");
+        llvm_unreachable("Analysis for this terminator not implemented.");
         break;
 
       case Stmt::BinaryOperatorClass: // '&&' and '||'
@@ -547,7 +547,7 @@ static ProgramPoint GetProgramPoint(const Stmt *S, ProgramPoint::Kind K,
                                     const ProgramPointTag *tag){
   switch (K) {
     default:
-      assert(false && "Unhandled ProgramPoint kind");    
+      llvm_unreachable("Unhandled ProgramPoint kind");    
     case ProgramPoint::PreStmtKind:
       return PreStmt(S, LC, tag);
     case ProgramPoint::PostStmtKind:
index 37362d37cb6eb629cc3c92dc184e597bcf73f326..5e38f2f244accb1eaf7b8998e2ddfccbd98aee61 100644 (file)
@@ -1030,7 +1030,7 @@ void ExprEngine::processIndirectGoto(IndirectGotoNodeBuilder &builder) {
       }
     }
 
-    assert(false && "No block with label.");
+    llvm_unreachable("No block with label.");
     return;
   }
 
index 0daa252eccebac627b680d4d7e3d825ddfa75fa2..955684f92deeb0e1ea74229d09806dbbbed36a39 100644 (file)
@@ -74,7 +74,7 @@ void ExprEngine::VisitBinaryOperator(const BinaryOperator* B,
     
     switch (Op) {
       default:
-        assert(0 && "Invalid opcode for compound assignment.");
+        llvm_unreachable("Invalid opcode for compound assignment.");
       case BO_MulAssign: Op = BO_Mul; break;
       case BO_DivAssign: Op = BO_Div; break;
       case BO_RemAssign: Op = BO_Rem; break;
@@ -203,9 +203,9 @@ void ExprEngine::VisitCast(const CastExpr *CastE, const Expr *Ex,
     
     switch (CastE->getCastKind()) {
       case CK_LValueToRValue:
-        assert(false && "LValueToRValue casts handled earlier.");
+        llvm_unreachable("LValueToRValue casts handled earlier.");
       case CK_GetObjCProperty:
-        assert(false && "GetObjCProperty casts handled earlier.");
+        llvm_unreachable("GetObjCProperty casts handled earlier.");
       case CK_ToVoid:
         Dst.Add(Pred);
         continue;
@@ -625,7 +625,7 @@ void ExprEngine::VisitUnaryOperator(const UnaryOperator* U,
         
         switch (U->getOpcode()) {
           default:
-            assert(false && "Invalid Opcode.");
+            llvm_unreachable("Invalid Opcode.");
             break;
             
           case UO_Not:
index 04c274d319e263ef93d8f6237199f0fcb92de7ad..18fbf831ec9fd6e4208822eb2815b93f88c5d951 100644 (file)
@@ -891,7 +891,7 @@ SVal RegionStoreManager::Retrieve(Store store, Loc L, QualType T) {
   }
 
   if (isa<CodeTextRegion>(MR)) {
-    assert(0 && "Why load from a code text region?");
+    llvm_unreachable("Why load from a code text region?");
     return UnknownVal();
   }
 
@@ -1130,7 +1130,7 @@ RegionStoreManager::RetrieveDerivedDefaultValue(RegionBindings B,
     if (isa<nonloc::LazyCompoundVal>(val))
       return Optional<SVal>();
 
-    assert(0 && "Unknown default value");
+    llvm_unreachable("Unknown default value");
   }
 
   return Optional<SVal>();
index 8eb65baa89f4c94b3e51d0d87a083a7a1fd9986c..e32a3b0f539748e32420c9b85365e25043b5c107 100644 (file)
@@ -171,7 +171,7 @@ void SVal::symbol_iterator::expand() {
     return;
   }
 
-  assert(false && "unhandled expansion case");
+  llvm_unreachable("unhandled expansion case");
 }
 
 const void *nonloc::LazyCompoundVal::getStore() const {
@@ -369,7 +369,7 @@ void Loc::dumpToStream(raw_ostream &os) const {
       break;
     }
     default:
-      assert(false && "Pretty-printing not implemented for this Loc.");
+      llvm_unreachable("Pretty-printing not implemented for this Loc.");
       break;
   }
 }
index 73b4d78ebaacfbddfdd95d825f9fb7393a958016..79d8b8bf9de38a2ce6757c895fcd1626569ed435 100644 (file)
@@ -125,7 +125,7 @@ static BinaryOperator::Opcode NegateComparison(BinaryOperator::Opcode op) {
   // the only place it's used. (This code was copied from SimpleSValBuilder.cpp.)
   switch (op) {
   default:
-    assert(false && "Invalid opcode.");
+    llvm_unreachable("Invalid opcode.");
   case BO_LT: return BO_GE;
   case BO_GT: return BO_LE;
   case BO_LE: return BO_GT;
@@ -152,7 +152,7 @@ const ProgramState *SimpleConstraintManager::assumeAux(const ProgramState *state
 
   switch (Cond.getSubKind()) {
   default:
-    assert(false && "'Assume' not implemented for this NonLoc");
+    llvm_unreachable("'Assume' not implemented for this NonLoc");
 
   case nonloc::SymbolValKind: {
     nonloc::SymbolVal& SV = cast<nonloc::SymbolVal>(Cond);
index 787aa055e67b8a6d97990de43161f31968906019..830d70e888b404e6e18f480dc50d1149eb2ea22f 100644 (file)
@@ -171,7 +171,7 @@ SVal SimpleSValBuilder::evalComplement(NonLoc X) {
 static BinaryOperator::Opcode NegateComparison(BinaryOperator::Opcode op) {
   switch (op) {
   default:
-    assert(false && "Invalid opcode.");
+    llvm_unreachable("Invalid opcode.");
   case BO_LT: return BO_GE;
   case BO_GT: return BO_LE;
   case BO_LE: return BO_GT;
@@ -184,7 +184,7 @@ static BinaryOperator::Opcode NegateComparison(BinaryOperator::Opcode op) {
 static BinaryOperator::Opcode ReverseComparison(BinaryOperator::Opcode op) {
   switch (op) {
   default:
-    assert(false && "Invalid opcode.");
+    llvm_unreachable("Invalid opcode.");
   case BO_LT: return BO_GT;
   case BO_GT: return BO_LT;
   case BO_LE: return BO_GE;
@@ -347,7 +347,7 @@ SVal SimpleSValBuilder::evalBinOpNN(const ProgramState *state,
           break;
         case BO_LAnd:
         case BO_LOr:
-          assert(false && "Logical operators handled by branching logic.");
+          llvm_unreachable("Logical operators handled by branching logic.");
           return UnknownVal();
         case BO_Assign:
         case BO_MulAssign:
@@ -361,11 +361,11 @@ SVal SimpleSValBuilder::evalBinOpNN(const ProgramState *state,
         case BO_XorAssign:
         case BO_OrAssign:
         case BO_Comma:
-          assert(false && "'=' and ',' operators handled by ExprEngine.");
+          llvm_unreachable("'=' and ',' operators handled by ExprEngine.");
           return UnknownVal();
         case BO_PtrMemD:
         case BO_PtrMemI:
-          assert(false && "Pointer arithmetic not handled here.");
+          llvm_unreachable("Pointer arithmetic not handled here.");
           return UnknownVal();
         case BO_LT:
         case BO_GT:
@@ -556,7 +556,7 @@ SVal SimpleSValBuilder::evalBinOpLL(const ProgramState *state,
   if (lhs == rhs) {
     switch (op) {
     default:
-      assert(false && "Unimplemented operation for two identical values");
+      llvm_unreachable("Unimplemented operation for two identical values");
       return UnknownVal();
     case BO_Sub:
       return makeZeroVal(resultTy);
@@ -573,7 +573,7 @@ SVal SimpleSValBuilder::evalBinOpLL(const ProgramState *state,
 
   switch (lhs.getSubKind()) {
   default:
-    assert(false && "Ordering not implemented for this Loc.");
+    llvm_unreachable("Ordering not implemented for this Loc.");
     return UnknownVal();
 
   case loc::GotoLabelKind:
@@ -827,7 +827,7 @@ SVal SimpleSValBuilder::evalBinOpLL(const ProgramState *state,
           return makeTruthVal(!leftFirst, resultTy);
       }
 
-      assert(false && "Fields not found in parent record's definition");
+      llvm_unreachable("Fields not found in parent record's definition");
     }
 
     // If we get here, we have no way of comparing the regions.
index 127d583b22939f77da4b3c4ace04320e98c4a7ee..63550d47f137d43152c1265b1a2b59df366de84f 100644 (file)
@@ -103,7 +103,7 @@ const MemRegion *StoreManager::castRegion(const MemRegion *R, QualType CastToTy)
     case MemRegion::UnknownSpaceRegionKind:
     case MemRegion::NonStaticGlobalSpaceRegionKind:
     case MemRegion::StaticGlobalSpaceRegionKind: {
-      assert(0 && "Invalid region cast");
+      llvm_unreachable("Invalid region cast");
       break;
     }
 
@@ -203,7 +203,7 @@ const MemRegion *StoreManager::castRegion(const MemRegion *R, QualType CastToTy)
     }
   }
 
-  assert(0 && "unreachable");
+  llvm_unreachable("unreachable");
   return 0;
 }
 
@@ -261,7 +261,7 @@ SVal StoreManager::getLValueFieldOrIvar(const Decl *D, SVal Base) {
     return Base;
 
   default:
-    assert(0 && "Unhandled Base.");
+    llvm_unreachable("Unhandled Base.");
     return Base;
   }
 
index 255b91498552e40cb58bd0a4d1dff6032fd9816f..32ad5819de2cf2fe955f271eaa9e6cf0c415e1ae 100644 (file)
@@ -28,7 +28,7 @@ void SymExpr::dump() const {
 static void print(raw_ostream &os, BinaryOperator::Opcode Op) {
   switch (Op) {
     default:
-      assert(false && "operator printing not implemented");
+      llvm_unreachable("operator printing not implemented");
       break;
     case BO_Mul: os << '*'  ; break;
     case BO_Div: os << '/'  ; break;
index 76ca4777948c29f9bc3cf464cf2a5d341e38db29..c4619e369d548859031f6b29a16e4d760217e47c 100644 (file)
@@ -102,7 +102,7 @@ public:
     // Create the analyzer component creators.
     switch (Opts.AnalysisStoreOpt) {
     default:
-      assert(0 && "Unknown store manager.");
+      llvm_unreachable("Unknown store manager.");
 #define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATEFN)           \
       case NAME##Model: CreateStoreMgr = CREATEFN; break;
 #include "clang/Frontend/Analyses.def"
@@ -110,7 +110,7 @@ public:
 
     switch (Opts.AnalysisConstraintsOpt) {
     default:
-      assert(0 && "Unknown store manager.");
+      llvm_unreachable("Unknown store manager.");
 #define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATEFN)     \
       case NAME##Model: CreateConstraintMgr = CREATEFN; break;
 #include "clang/Frontend/Analyses.def"
index a5332b9464de35598a73734ad3da5059f23ccb23..aa4b12b18a0bf08ec36563ab5c1f0ec07aa12591 100644 (file)
@@ -4730,7 +4730,7 @@ AnnotateTokensWorker::Visit(CXCursor cursor, CXCursor parent) {
       SourceLocation TokLoc = GetTokenLoc(I);
       switch (LocationCompare(SrcMgr, TokLoc, cursorRange)) {
       case RangeBefore:
-        assert(0 && "Infeasible");
+        llvm_unreachable("Infeasible");
       case RangeAfter:
         break;
       case RangeOverlap:
index d9b515b1465f9e1fa5f6dd225f124350792e73e5..cfebbfce52003eaaaf2a335b099b425215100577 100644 (file)
@@ -106,7 +106,7 @@ CXString clang_formatDiagnostic(CXDiagnostic Diagnostic, unsigned Options) {
 
   /* Print warning/error/etc. */
   switch (Severity) {
-  case CXDiagnostic_Ignored: assert(0 && "impossible"); break;
+  case CXDiagnostic_Ignored: llvm_unreachable("impossible"); break;
   case CXDiagnostic_Note: Out << "note: "; break;
   case CXDiagnostic_Warning: Out << "warning: "; break;
   case CXDiagnostic_Error: Out << "error: "; break;
index 464dbb0ac7dff97d594ba7bcc7e17d15f18d73ca..f32063cfe328ff75c8c12de3376dc7b7b571d586 100644 (file)
@@ -320,7 +320,7 @@ void USRGenerator::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) {
 void USRGenerator::VisitObjCContainerDecl(ObjCContainerDecl *D) {
   switch (D->getKind()) {
     default:
-      assert(false && "Invalid ObjC container.");
+      llvm_unreachable("Invalid ObjC container.");
     case Decl::ObjCInterface:
     case Decl::ObjCImplementation:
       GenObjCClass(D->getName());
index 56974b9e999bb87f7b07395747f418cc3f33e0fe..995a8febb088636803ca39bddb35d47a2e36ff78 100644 (file)
@@ -74,7 +74,7 @@ std::string CIndexer::getClangResourcesPath() {
   // This silly cast below avoids a C++ warning.
   Dl_info info;
   if (dladdr((void *)(uintptr_t)clang_createTranslationUnit, &info) == 0)
-    assert(0 && "Call to dladdr() failed");
+    llvm_unreachable("Call to dladdr() failed");
   
   llvm::sys::Path LibClangPath(info.dli_fname);