[clang] [clang-format] Treat new expressions as simple functions (PR #105168)

kadir çetinkaya via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 22 02:03:09 PDT 2024


================
@@ -848,6 +848,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
   const auto IsSimpleFunction = [&](const FormatToken &Tok) {
     if (!Tok.FakeLParens.empty() && Tok.FakeLParens.back() > prec::Unknown)
       return false;
+    if (Tok.is(tok::kw_new))
+      return true;
----------------
kadircet wrote:

> Should we leave a simple comment?

Added some, LMK if you want something else mentioned.

> I spent a bit of time here wondering if it should return true or skip to the next argument, I'm in two minds but I think this is ok.

I am wary of this as we can have cases like `new Foo::Bar();`, added some test cases.

https://github.com/llvm/llvm-project/pull/105168


More information about the cfe-commits mailing list