[llvm-bugs] [Bug 49491] New: clang-format removes newlines and indentation if a block is followed by doctest's TEST_CASE macro
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Mar 9 08:00:14 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=49491
Bug ID: 49491
Summary: clang-format removes newlines and indentation if a
block is followed by doctest's TEST_CASE macro
Product: clang
Version: unspecified
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: egor.suvorov at gmail.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
Created attachment 24608
--> https://bugs.llvm.org/attachment.cgi?id=24608&action=edit
The original example demonstrating the formatting issue
The following example:
TEST_CASE("Test 1") {
#ifndef MY_DEF
{
int b = 0;
}
#endif
}
TEST_CASE("Test 2") {
}
gets formatted by the default clang-format version 10.0.0 as follows:
TEST_CASE("Test 1"){
#ifndef MY_DEF
{int b = 0;
}
#endif
}
TEST_CASE("Test 2") {}
Note that block inside the `#ifdef` is ruined.
TEST_CASE is a special macro from https://github.com/onqtam/doctest which
creates and registers a test case with a specific name and body.
If I replace `TEST_CASE("Test 1")` with `void foo()`, the problem persists.
However, any of the following changes make the problem go away:
1. Remove #ifndef
2. Replace `TEST_CASE("Test 2")` with `void bar()`.
3. Add `int x;` on a separate line immediately before `TEST_CASE("Test 2")`
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210309/19f46953/attachment-0001.html>
More information about the llvm-bugs
mailing list