LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 48891 - [clang-format] Different formatted output can be produced from varying whitespace
Summary: [clang-format] Different formatted output can be produced from varying whites...
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Formatter (show other bugs)
Version: trunk
Hardware: PC All
: P release blocker
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks: release-12.0.0
  Show dependency tree
 
Reported: 2021-01-26 13:21 PST by Leonard Chan
Modified: 2021-01-29 21:57 PST (History)
6 users (show)

See Also:
Fixed By Commit(s): e3713f156b8cb65a2b74f150afb824ce1e2a2fab 0a32d93bd95b


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leonard Chan 2021-01-26 13:21:45 PST
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.
Comment 2 Marek Kurdej 2021-01-27 23:56:49 PST
Reopening until it gets merged into 12.x.
Comment 3 Tom Stellard 2021-01-29 21:57:51 PST
Merged: 0a32d93bd95b