Commit d4e3ae0
committed
[clang-format]: Treat #pragma once as include guard for IndentPPDirectives
Summary:
This patch fixes the behavior of IndentPPDirectives so that `#pragma once`'s are treated as part of include guards, and therefore the `#define` in the guard will not be indented.
Sample:
```
#pragma once
#ifndef HEADER_H
#define HEADER_H
code();
#endif
```
Previous formatting behavior:
```
#pragma once
#ifndef HEADER_H
#define HEADER_H
code();
#endif
```
Patched behavior:
```
#pragma once
#ifndef HEADER_H
#define HEADER_H
code();
#endif
```
Details:
Previously, a `#ifndef`` could only start an include guard if all the lines above it were comments.
This patch changes this check to see if all the lines above the `#ifndef`` are comments OR `#pragma once``.1 parent 70627af commit d4e3ae0
File tree
2 files changed
+20
-3
lines changed- clang
- lib/Format
- unittests/Format
2 files changed
+20
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1102 | 1102 | | |
1103 | 1103 | | |
1104 | 1104 | | |
1105 | | - | |
| 1105 | + | |
1106 | 1106 | | |
1107 | 1107 | | |
1108 | 1108 | | |
1109 | | - | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
1110 | 1117 | | |
1111 | 1118 | | |
1112 | 1119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6223 | 6223 | | |
6224 | 6224 | | |
6225 | 6225 | | |
| 6226 | + | |
| 6227 | + | |
| 6228 | + | |
| 6229 | + | |
| 6230 | + | |
| 6231 | + | |
| 6232 | + | |
| 6233 | + | |
| 6234 | + | |
| 6235 | + | |
6226 | 6236 | | |
6227 | 6237 | | |
6228 | 6238 | | |
| |||
6239 | 6249 | | |
6240 | 6250 | | |
6241 | 6251 | | |
6242 | | - | |
| 6252 | + | |
6243 | 6253 | | |
6244 | 6254 | | |
6245 | 6255 | | |
| |||
0 commit comments