[compiler-rt] 2fec886 - [sanitizer] Set IndentPPDirectives: AfterHash in .clang-format
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon May 3 13:49:45 PDT 2021
Author: Fangrui Song
Date: 2021-05-03T13:49:41-07:00
New Revision: 2fec8860d8aef7ba74064de622fe9ce29f3b19fb
URL: https://github.com/llvm/llvm-project/commit/2fec8860d8aef7ba74064de622fe9ce29f3b19fb
DIFF: https://github.com/llvm/llvm-project/commit/2fec8860d8aef7ba74064de622fe9ce29f3b19fb.diff
LOG: [sanitizer] Set IndentPPDirectives: AfterHash in .clang-format
Code patterns like this are common, `#` at the line beginning
(https://google.github.io/styleguide/cppguide.html#Preprocessor_Directives),
one space indentation for if/elif/else directives.
```
#if SANITIZER_LINUX
# if defined(__aarch64__)
# endif
#endif
```
However, currently clang-format wants to reformat the code to
```
#if SANITIZER_LINUX
#if defined(__aarch64__)
#endif
#endif
```
This significantly harms readability in my review. Use `IndentPPDirectives:
AfterHash` to defeat the diagnostic. clang-format will now suggest:
```
#if SANITIZER_LINUX
# if defined(__aarch64__)
# endif
#endif
```
Unfortunately there is no clang-format option using indent with 1 for
just preprocessor directives. However, this is still one step forward
from the current behavior.
Reviewed By: #sanitizers, vitalybuka
Differential Revision: https://reviews.llvm.org/D100238
Added:
Modified:
compiler-rt/lib/asan/.clang-format
compiler-rt/lib/dfsan/.clang-format
compiler-rt/lib/hwasan/.clang-format
compiler-rt/lib/interception/.clang-format
compiler-rt/lib/lsan/.clang-format
compiler-rt/lib/msan/.clang-format
compiler-rt/lib/safestack/.clang-format
compiler-rt/lib/sanitizer_common/.clang-format
compiler-rt/lib/tsan/.clang-format
compiler-rt/test/.clang-format
Removed:
################################################################################
diff --git a/compiler-rt/lib/asan/.clang-format b/compiler-rt/lib/asan/.clang-format
index 560308c91dee..1f2a97030379 100644
--- a/compiler-rt/lib/asan/.clang-format
+++ b/compiler-rt/lib/asan/.clang-format
@@ -1,2 +1,3 @@
BasedOnStyle: Google
AllowShortIfStatementsOnASingleLine: false
+IndentPPDirectives: AfterHash
diff --git a/compiler-rt/lib/dfsan/.clang-format b/compiler-rt/lib/dfsan/.clang-format
index 560308c91dee..1f2a97030379 100644
--- a/compiler-rt/lib/dfsan/.clang-format
+++ b/compiler-rt/lib/dfsan/.clang-format
@@ -1,2 +1,3 @@
BasedOnStyle: Google
AllowShortIfStatementsOnASingleLine: false
+IndentPPDirectives: AfterHash
diff --git a/compiler-rt/lib/hwasan/.clang-format b/compiler-rt/lib/hwasan/.clang-format
index 560308c91dee..1f2a97030379 100644
--- a/compiler-rt/lib/hwasan/.clang-format
+++ b/compiler-rt/lib/hwasan/.clang-format
@@ -1,2 +1,3 @@
BasedOnStyle: Google
AllowShortIfStatementsOnASingleLine: false
+IndentPPDirectives: AfterHash
diff --git a/compiler-rt/lib/interception/.clang-format b/compiler-rt/lib/interception/.clang-format
index 560308c91dee..1f2a97030379 100644
--- a/compiler-rt/lib/interception/.clang-format
+++ b/compiler-rt/lib/interception/.clang-format
@@ -1,2 +1,3 @@
BasedOnStyle: Google
AllowShortIfStatementsOnASingleLine: false
+IndentPPDirectives: AfterHash
diff --git a/compiler-rt/lib/lsan/.clang-format b/compiler-rt/lib/lsan/.clang-format
index 560308c91dee..1f2a97030379 100644
--- a/compiler-rt/lib/lsan/.clang-format
+++ b/compiler-rt/lib/lsan/.clang-format
@@ -1,2 +1,3 @@
BasedOnStyle: Google
AllowShortIfStatementsOnASingleLine: false
+IndentPPDirectives: AfterHash
diff --git a/compiler-rt/lib/msan/.clang-format b/compiler-rt/lib/msan/.clang-format
index 560308c91dee..1f2a97030379 100644
--- a/compiler-rt/lib/msan/.clang-format
+++ b/compiler-rt/lib/msan/.clang-format
@@ -1,2 +1,3 @@
BasedOnStyle: Google
AllowShortIfStatementsOnASingleLine: false
+IndentPPDirectives: AfterHash
diff --git a/compiler-rt/lib/safestack/.clang-format b/compiler-rt/lib/safestack/.clang-format
index 560308c91dee..1f2a97030379 100644
--- a/compiler-rt/lib/safestack/.clang-format
+++ b/compiler-rt/lib/safestack/.clang-format
@@ -1,2 +1,3 @@
BasedOnStyle: Google
AllowShortIfStatementsOnASingleLine: false
+IndentPPDirectives: AfterHash
diff --git a/compiler-rt/lib/sanitizer_common/.clang-format b/compiler-rt/lib/sanitizer_common/.clang-format
index 560308c91dee..1f2a97030379 100644
--- a/compiler-rt/lib/sanitizer_common/.clang-format
+++ b/compiler-rt/lib/sanitizer_common/.clang-format
@@ -1,2 +1,3 @@
BasedOnStyle: Google
AllowShortIfStatementsOnASingleLine: false
+IndentPPDirectives: AfterHash
diff --git a/compiler-rt/lib/tsan/.clang-format b/compiler-rt/lib/tsan/.clang-format
index 560308c91dee..1f2a97030379 100644
--- a/compiler-rt/lib/tsan/.clang-format
+++ b/compiler-rt/lib/tsan/.clang-format
@@ -1,2 +1,3 @@
BasedOnStyle: Google
AllowShortIfStatementsOnASingleLine: false
+IndentPPDirectives: AfterHash
diff --git a/compiler-rt/test/.clang-format b/compiler-rt/test/.clang-format
index 4799b66f3e9a..f236d1f6982a 100644
--- a/compiler-rt/test/.clang-format
+++ b/compiler-rt/test/.clang-format
@@ -1,2 +1,3 @@
BasedOnStyle: LLVM
ColumnLimit: 0
+IndentPPDirectives: AfterHash
More information about the llvm-commits
mailing list