inclyc updated this revision to Diff 466539.
inclyc added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135551/new/

https://reviews.llvm.org/D135551

Files:
  clang/include/clang/AST/Redeclarable.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/Multilib.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Frontend/SARIFDiagnostic.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PreprocessingRecord.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/lib/StaticAnalyzer/Core/SVals.cpp
  clang/tools/clang-refactor/TestSupport.cpp

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

Reply via email to