[PATCH] D152473: [clang-format] Add test case for issue 63170

Paul Kirth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 8 15:05:37 PDT 2023


paulkirth created this revision.
paulkirth added a reviewer: owenpan.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, MyDeveloperDay.
paulkirth requested review of this revision.
Herald added a comment.

NOTE: Clang-Format Team Automated Review Comment

It looks like your clang-format review does not contain any unit tests, please try to ensure all code changes have a unit test (unless this is an `NFC` or refactoring, adding documentation etc..)

Add your unit tests in `clang/unittests/Format` and you can build with `ninja FormatTests`.  We recommend using the `verifyFormat(xxx)` format of unit tests rather than `EXPECT_EQ` as this will ensure you change is tolerant to random whitespace changes (see FormatTest.cpp as an example)

For situations where your change is altering the TokenAnnotator.cpp which can happen if you are trying to improve the annotation phase to ensure we are correctly identifying the type of a token, please add a token annotator test in `TokenAnnotatorTest.cpp`


After https://reviews.llvm.org/D151954 we've noticed some issues w/
clang-format behavior, as outlined in
https://github.com/llvm/llvm-project/issues/63170.

Valid C/C++ files, that were previously accepted, are now rejected by
clang-format, emitting the message:

"The new replacement overlaps with an existing replacement."

This test will fail, despite being a valid(if trivial) cpp file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152473

Files:
  clang/test/Format/overlapping-lines.cpp


Index: clang/test/Format/overlapping-lines.cpp
===================================================================
--- /dev/null
+++ clang/test/Format/overlapping-lines.cpp
@@ -0,0 +1,8 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format --style=Google 2>&1 | FileCheck %s 
+// CHECK-NOT: The new replacement overlaps with an existing replacement.
+
+#ifdef 
+    
+
+#else 
+#endif 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152473.529739.patch
Type: text/x-patch
Size: 386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230608/a7454761/attachment.bin>


More information about the cfe-commits mailing list