[PATCH] D109408: [libcxxabi] NFC: fix incorrect indentation of braces

Zhouyi Zhou via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 8 11:37:39 PDT 2021


Hi,

On Wed, Sep 8, 2021 at 10:01 AM zhouyizhou via Phabricator
<reviews at reviews.llvm.org> wrote:
>
> zhouyizhou added a comment.
>
> In D109408#2988417 <https://reviews.llvm.org/D109408#2988417>, @ldionne wrote:
>
> > FWIW, I dislike that we don't indent stuff at all inside namespaces -- often I find it useful to indent things inside short-lived namespaces. But let's go for simplicity and consistency.
> >
> > Did you look into clang-formatting other files in libc++abi? What would the diff look like?

I take a general view of .cpp(.h) files in libc++abi, they are
distributed in several directories. I do an experiment with
fuzz/cxa_demangle_fuzzer.cpp using clang-format, the result is as
follows:
--- cxa_demangle_fuzzer.cpp.orig    2021-09-09 02:19:17.117872938 +0800
+++ cxa_demangle_fuzzer.cpp    2021-09-09 02:19:34.845879852 +0800
@@ -1,15 +1,15 @@
-#include <stdint.h>
 #include <stddef.h>
-#include <string.h>
+#include <stdint.h>
 #include <stdlib.h>
-extern "C" char *
-__cxa_demangle(const char *mangled_name, char *buf, size_t *n, int *status);
+#include <string.h>
+extern "C" char *__cxa_demangle(const char *mangled_name, char *buf, size_t *n,
+                                int *status);

 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
-  char *str = new char[size+1];
+  char *str = new char[size + 1];
   memcpy(str, data, size);
   str[size] = 0;
   free(__cxa_demangle(str, 0, 0, 0));
-  delete [] str;
+  delete[] str;
   return 0;
 }

As a beginner of LLVM and C++, I guess clang-formatting is meaningful ;-)

I guess we can clang-format a set of files at a time, and step-by-step
clang-format all the .cpp(.h) files in libc++abi and fine-tune the
results as how Quuxplusone did it ,
what's your opinion? If it is OK, I am very honored and pleased to do
this work ;-)

Cheers
Zhouyi


>
> Thanks for reviewing,
> I will look into other files in libc++abi one by one, and report what I have found ;-)
> Thanks again
> Zhouyi
>
>
>
> ================
> Comment at: libcxxabi/src/cxa_exception_storage.cpp:102
>  }
>  }
> +} // namespace __cxxabiv1
> ----------------
> Quuxplusone wrote:
> > LGTM, FWIW.
> >
> > It's surprising that clang-format adds `} // namespace foo` closing comments, but doesn't add `} // extern "C"` closing comments: this lonely brace is a bit confusing and I think it //would// benefit from an `// extern "C"` comment.
> Thanks for reviewing,
> clang-format do behave a little strange to me. The result of invoking clang-format in git cloned directory is diffent from invoking clang-format in other directory ( for example /tmp).
> By the way, I have not write access to LLVM, so I need someone to commit for me.
>
> Thanks again ;-)
> Zhouyi
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D109408/new/
>
> https://reviews.llvm.org/D109408
>


More information about the cfe-commits mailing list