[clang] cd1dc7f - [AST] Replace assert with llvm_unreachable to silence compiler warning

Mikael Holmen via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 5 02:19:30 PST 2020


Author: Mikael Holmen
Date: 2020-03-05T11:07:54+01:00
New Revision: cd1dc7f15d637b42067546e658574237cd0f0d46

URL: https://github.com/llvm/llvm-project/commit/cd1dc7f15d637b42067546e658574237cd0f0d46
DIFF: https://github.com/llvm/llvm-project/commit/cd1dc7f15d637b42067546e658574237cd0f0d46.diff

LOG: [AST] Replace assert with llvm_unreachable to silence compiler warning

New code added in ec3060c72de6 looked like

+  case TemplateName::NameKind::OverloadedTemplate:
+    assert(false && "overloaded templates shouldn't survive to here.");
+  default:

If compiling without asserts we then got a warning about unannotated
fallthrough from the case into the default.

Change the assert into an llvm_unreachable to silence the warning.

Added: 
    

Modified: 
    clang/lib/AST/TemplateName.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/TemplateName.cpp b/clang/lib/AST/TemplateName.cpp
index afabc575b164..3b8ae06c6339 100644
--- a/clang/lib/AST/TemplateName.cpp
+++ b/clang/lib/AST/TemplateName.cpp
@@ -185,7 +185,7 @@ TemplateNameDependence TemplateName::getDependence() const {
     D |= TemplateNameDependence::UnexpandedPack;
     break;
   case TemplateName::NameKind::OverloadedTemplate:
-    assert(false && "overloaded templates shouldn't survive to here.");
+    llvm_unreachable("overloaded templates shouldn't survive to here.");
   default:
     break;
   }


        


More information about the cfe-commits mailing list