[PATCH] D56345: [clang-format] Assert that filenames are not empty

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 6 01:09:37 PST 2019


MyDeveloperDay updated this revision to Diff 228014.
MyDeveloperDay added a reviewer: mitchell-stellar.
MyDeveloperDay added a comment.

remove the asserts at least for now.

This fix is important for people using clang-format  integrated into some editor tools.


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

https://reviews.llvm.org/D56345

Files:
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===================================================================
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -390,6 +390,10 @@
   if (fillRanges(Code.get(), Ranges))
     return true;
   StringRef AssumedFileName = (FileName == "-") ? AssumeFileName : FileName;
+  if (AssumedFileName.empty()) {
+    llvm::errs() << "error: empty filenames are not allowed\n";
+    return true;
+  }
 
   llvm::Expected<FormatStyle> FormatStyle =
       getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56345.228014.patch
Type: text/x-patch
Size: 606 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191106/021894e1/attachment-0001.bin>


More information about the cfe-commits mailing list