[llvm-bugs] [Bug 48891] New: [clang-format] Different formatted output can be produced from varying whitespace

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 26 13:21:45 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=48891

            Bug ID: 48891
           Summary: [clang-format] Different formatted output can be
                    produced from varying whitespace
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: leonardchan at google.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

As of https://reviews.llvm.org/D93839, clang-format can produce different
formatted files depending on amount of whitespace. For example, given (A):

```
#include <stdint.h>
namespace fuzzing {}
```

`clang-format` with this patch would produced (B):

```
#include <stdint.h>
namespace fuzzing {
}
```

but given (C):

```
#include <stdint.h>
namespace fuzzing {


}
```

would be formatted to (D):

```
#include <stdint.h>
namespace fuzzing {

}
```

The invocation specifically is `clang-format --style=google file`. Prior to
this patch, both inputs (A/C) would give the same output:

```
#include <stdint.h>
namespace fuzzing {}
```

This seems to be unintended behavior that should be fixed. This doesn't seem to
occur if `#include "stdint.h"` is used.

-- 
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/20210126/55a1ef17/attachment.html>


More information about the llvm-bugs mailing list