[clang] 1f818f6 - [clang-format] assert(false) -> llvm_unreachable

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 15 05:11:53 PST 2023


Author: Benjamin Kramer
Date: 2023-02-15T14:10:09+01:00
New Revision: 1f818f63b829f3038a9fd605bf90348ba58cd981

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

LOG: [clang-format] assert(false) -> llvm_unreachable

Avoids warnings in -asserts builds.

FormatTokenSource.h:240:3: error: non-void function does not return a value [-Werror,-Wreturn-type]
  }
  ^

Added: 
    

Modified: 
    clang/lib/Format/FormatTokenSource.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/FormatTokenSource.h b/clang/lib/Format/FormatTokenSource.h
index 8bf7e6932c89..0be46287f6b7 100644
--- a/clang/lib/Format/FormatTokenSource.h
+++ b/clang/lib/Format/FormatTokenSource.h
@@ -236,7 +236,7 @@ class ScopedMacroState : public FormatTokenSource {
   }
 
   FormatToken *insertTokens(ArrayRef<FormatToken *> Tokens) override {
-    assert(false && "Cannot insert tokens while parsing a macro.");
+    llvm_unreachable("Cannot insert tokens while parsing a macro.");
   }
 
 private:


        


More information about the cfe-commits mailing list