[llvm-branch-commits] [clang] release/19.x: [clang-format] Fix a bug in annotating CastRParen (#102261) (PR #102419)

2024-08-08 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/102419
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/19.x: [clang-format] Fix a serious bug in `git clang-format -f` (#102629) (PR #102770)

2024-08-12 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/102770
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] PR for llvm/llvm-project#78892 (PR #80259)

2024-02-05 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.

As stated in the discussion, it is an absolutely must to merge it in the 
release. In my opinion we can't just drop an option, for the next release.

https://github.com/llvm/llvm-project/pull/80259
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/18.x: [clang-format] Don't remove parentheses in macro definitions (#81444) (PR #81566)

2024-02-13 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/81566
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] [polly] release/18.x: [clang-format] Correctly annotate braces of empty ctors/dtors (#82097) (PR #87735)

2024-04-05 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/87735
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[clang] release/18.x: [clang-format] Fix a regression in annotating BK_Braced… (PR #89489)

2024-04-23 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/89489
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[clang] [polly] release/18.x: [clang-format] Correctly annotate braces in macros (#87… (PR #89491)

2024-04-23 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/89491
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/18.x: [clang-format] Fix a regression in annotating TrailingReturnArrow (#86624) (PR #89415)

2024-04-25 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/89415
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/18.x: [clang-format] Fix a regression in ContinuationIndenter (#88414) (PR #89412)

2024-04-25 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/89412
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/18.x: [clang-format] Fix a crash with AlignArrayOfStructures option (#86420) (PR #91049)

2024-05-11 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/91049
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[clang] [clang-format] Revert "[clang-format][NFC] Delete TT_LambdaArrow (#70… (PR #106482)

2024-08-30 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/106482
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 6cb2887 - [clang-format] [NFC] Use some constexpr StringRef

2021-01-25 Thread Björn Schäpers via llvm-branch-commits

Author: Björn Schäpers
Date: 2021-01-25T21:02:40+01:00
New Revision: 6cb288797122ad931aba91e05030c24984e1031c

URL: 
https://github.com/llvm/llvm-project/commit/6cb288797122ad931aba91e05030c24984e1031c
DIFF: 
https://github.com/llvm/llvm-project/commit/6cb288797122ad931aba91e05030c24984e1031c.diff

LOG: [clang-format] [NFC] Use some constexpr StringRef

Instead of const char*.

Differential Revision: https://reviews.llvm.org/D95078

Added: 


Modified: 
clang/lib/Format/BreakableToken.cpp

Removed: 




diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index c5edc670393c..d5167c01dc23 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -25,7 +25,7 @@
 namespace clang {
 namespace format {
 
-static const char *const Blanks = " \t\v\f\r";
+static constexpr StringRef Blanks = " \t\v\f\r";
 static bool IsBlank(char C) {
   switch (C) {
   case ' ':
@@ -41,11 +41,11 @@ static bool IsBlank(char C) {
 
 static StringRef getLineCommentIndentPrefix(StringRef Comment,
 const FormatStyle &Style) {
-  static const char *const KnownCStylePrefixes[] = {"///<", "//!<", "///",
-"//",   "//!",  "//:"};
-  static const char *const KnownTextProtoPrefixes[] = {"//", "#", "##", "###",
-   ""};
-  ArrayRef KnownPrefixes(KnownCStylePrefixes);
+  static constexpr StringRef KnownCStylePrefixes[] = {"///<", "//!<", "///",
+  "//",   "//!",  "//:"};
+  static constexpr StringRef KnownTextProtoPrefixes[] = {"//", "#", "##", 
"###",
+ ""};
+  ArrayRef KnownPrefixes(KnownCStylePrefixes);
   if (Style.Language == FormatStyle::LK_TextProto)
 KnownPrefixes = KnownTextProtoPrefixes;
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 7c8b9c1 - [clang-format] [NFC] Restructure getLineCommentIndentPrefix

2021-01-25 Thread Björn Schäpers via llvm-branch-commits

Author: Björn Schäpers
Date: 2021-01-25T21:02:40+01:00
New Revision: 7c8b9c102f38a4d29ac56ef7bd1da003f03900d0

URL: 
https://github.com/llvm/llvm-project/commit/7c8b9c102f38a4d29ac56ef7bd1da003f03900d0
DIFF: 
https://github.com/llvm/llvm-project/commit/7c8b9c102f38a4d29ac56ef7bd1da003f03900d0.diff

LOG: [clang-format] [NFC] Restructure getLineCommentIndentPrefix

When sorting the known prefixes after length the if in the loop will hit
at most once, so we can return from there.

Also replace the inner loop with an algorithm, that makes it more
readable.

Differential Revision: https://reviews.llvm.org/D95081

Added: 


Modified: 
clang/lib/Format/BreakableToken.cpp

Removed: 




diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index d5167c01dc23..0ec00e039f33 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -42,24 +42,26 @@ static bool IsBlank(char C) {
 static StringRef getLineCommentIndentPrefix(StringRef Comment,
 const FormatStyle &Style) {
   static constexpr StringRef KnownCStylePrefixes[] = {"///<", "//!<", "///",
-  "//",   "//!",  "//:"};
-  static constexpr StringRef KnownTextProtoPrefixes[] = {"//", "#", "##", 
"###",
- ""};
+  "//!",  "//:",  "//"};
+  static constexpr StringRef KnownTextProtoPrefixes[] = {"", "###", "##",
+ "//", "#"};
   ArrayRef KnownPrefixes(KnownCStylePrefixes);
   if (Style.Language == FormatStyle::LK_TextProto)
 KnownPrefixes = KnownTextProtoPrefixes;
 
-  StringRef LongestPrefix;
+  assert(std::is_sorted(KnownPrefixes.begin(), KnownPrefixes.end(),
+[](StringRef Lhs, StringRef Rhs) noexcept {
+  return Lhs.size() > Rhs.size();
+}));
+
   for (StringRef KnownPrefix : KnownPrefixes) {
 if (Comment.startswith(KnownPrefix)) {
-  size_t PrefixLength = KnownPrefix.size();
-  while (PrefixLength < Comment.size() && Comment[PrefixLength] == ' ')
-++PrefixLength;
-  if (PrefixLength > LongestPrefix.size())
-LongestPrefix = Comment.substr(0, PrefixLength);
+  const auto PrefixLength =
+  Comment.find_first_not_of(' ', KnownPrefix.size());
+  return Comment.substr(0, PrefixLength);
 }
   }
-  return LongestPrefix;
+  return {};
 }
 
 static BreakableToken::Split



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 9aa38a0 - [clang-format] [NFC] Remove unsued arguments

2021-01-25 Thread Björn Schäpers via llvm-branch-commits

Author: Björn Schäpers
Date: 2021-01-25T21:02:41+01:00
New Revision: 9aa38a0615119a7a9f3bee33a2b8915c45f1cab9

URL: 
https://github.com/llvm/llvm-project/commit/9aa38a0615119a7a9f3bee33a2b8915c45f1cab9
DIFF: 
https://github.com/llvm/llvm-project/commit/9aa38a0615119a7a9f3bee33a2b8915c45f1cab9.diff

LOG: [clang-format] [NFC] Remove unsued arguments

Added: 


Modified: 
clang/lib/Format/BreakableToken.cpp
clang/lib/Format/BreakableToken.h
clang/lib/Format/ContinuationIndenter.cpp

Removed: 




diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index 0ec00e039f33..f179ac64de17 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -751,8 +751,7 @@ bool BreakableBlockComment::mayReflow(
 }
 
 BreakableLineCommentSection::BreakableLineCommentSection(
-const FormatToken &Token, unsigned StartColumn,
-unsigned OriginalStartColumn, bool FirstInLine, bool InPPDirective,
+const FormatToken &Token, unsigned StartColumn, bool InPPDirective,
 encoding::Encoding Encoding, const FormatStyle &Style)
 : BreakableComment(Token, StartColumn, InPPDirective, Encoding, Style) {
   assert(Tok.is(TT_LineComment) &&

diff  --git a/clang/lib/Format/BreakableToken.h 
b/clang/lib/Format/BreakableToken.h
index a6691300de3b..41b19f82e9df 100644
--- a/clang/lib/Format/BreakableToken.h
+++ b/clang/lib/Format/BreakableToken.h
@@ -436,7 +436,6 @@ class BreakableBlockComment : public BreakableComment {
 class BreakableLineCommentSection : public BreakableComment {
 public:
   BreakableLineCommentSection(const FormatToken &Token, unsigned StartColumn,
-  unsigned OriginalStartColumn, bool FirstInLine,
   bool InPPDirective, encoding::Encoding Encoding,
   const FormatStyle &Style);
 

diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 9db42b6c4a70..7198671901f3 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1974,8 +1974,7 @@ ContinuationIndenter::createBreakableToken(const 
FormatToken &Current,
 switchesFormatting(Current))
   return nullptr;
 return std::make_unique(
-Current, StartColumn, Current.OriginalColumn, !Current.Previous,
-/*InPPDirective=*/false, Encoding, Style);
+Current, StartColumn, /*InPPDirective=*/false, Encoding, Style);
   }
   return nullptr;
 }



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] f02eca0 - [clang-format] [NFC] Rerun dump_format_style.py

2021-01-25 Thread Björn Schäpers via llvm-branch-commits

Author: Björn Schäpers
Date: 2021-01-25T21:02:41+01:00
New Revision: f02eca0f3feffc5e1afb92eeb4cfc23b9f28aa25

URL: 
https://github.com/llvm/llvm-project/commit/f02eca0f3feffc5e1afb92eeb4cfc23b9f28aa25
DIFF: 
https://github.com/llvm/llvm-project/commit/f02eca0f3feffc5e1afb92eeb4cfc23b9f28aa25.diff

LOG: [clang-format] [NFC] Rerun dump_format_style.py

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index f6ff57156177..c12ecf4d907f 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -2360,14 +2360,15 @@ the configuration (without a prefix: ``Auto``).
   When ``true``, includes are sorted in an alphabetical
   fashion with case used as a tie-breaker.
 
+
   .. code-block:: c++
 
- false:   true:
- #include "A/B.h"   vs.   #include "A/B.h"
- #include "A/b.h" #include "A/b.h"
- #include "B/A.h" #include "a/b.h"
- #include "B/a.h" #include "B/A.h"
- #include "a/b.h" #include "B/a.h"
+false:   true:
+#include "A/B.h"   vs.   #include "A/B.h"
+#include "A/b.h" #include "A/b.h"
+#include "B/A.h" #include "a/b.h"
+#include "B/a.h" #include "B/A.h"
+#include "a/b.h" #include "B/a.h"
 
   This option is off by default.
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 60bf582 - [clang-format] PR16518 Add flag to suppress empty line insertion before access modifier

2021-01-25 Thread Björn Schäpers via llvm-branch-commits

Author: Albertas Vyšniauskas
Date: 2021-01-25T21:02:41+01:00
New Revision: 60bf5826cfd3629b5200a8ab743d701c90f66af0

URL: 
https://github.com/llvm/llvm-project/commit/60bf5826cfd3629b5200a8ab743d701c90f66af0
DIFF: 
https://github.com/llvm/llvm-project/commit/60bf5826cfd3629b5200a8ab743d701c90f66af0.diff

LOG: [clang-format] PR16518 Add flag to suppress empty line insertion before 
access modifier

Add new option called InsertEmptyLineBeforeAccessModifier. Empty line
before access modifier is inerted if this option is set to true (which
is the default value, because clang-format always inserts empty lines
before access modifiers), otherwise empty lines are removed.

Fixes issue #16518.

Differential Revision: https://reviews.llvm.org/D93846

Added: 
clang/test/Format/access-modifiers.cpp

Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index d5ce1b7b2e8e..f6ff57156177 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -2119,6 +2119,75 @@ the configuration (without a prefix: ``Auto``).
 **DisableFormat** (``bool``)
   Disables formatting completely.
 
+**EmptyLineBeforeAccessModifier** (``EmptyLineBeforeAccessModifierStyle``)
+  Defines in which cases to put empty line before access modifiers.
+
+  Possible values:
+
+  * ``ELBAMS_Never`` (in configuration: ``Never``)
+Remove all empty lines before access modifiers.
+
+.. code-block:: c++
+
+  struct foo {
+  private:
+int i;
+  protected:
+int j;
+/* comment */
+  public:
+foo() {}
+  private:
+  protected:
+  };
+
+  * ``ELBAMS_Leave`` (in configuration: ``Leave``)
+Keep existing empty lines before access modifiers.
+
+  * ``ELBAMS_LogicalBlock`` (in configuration: ``LogicalBlock``)
+Add empty line only when access modifier starts a new logical block.
+Logical block is a group of one or more member fields or functions.
+
+.. code-block:: c++
+
+  struct foo {
+  private:
+int i;
+
+  protected:
+int j;
+/* comment */
+  public:
+foo() {}
+
+  private:
+  protected:
+  };
+
+  * ``ELBAMS_Always`` (in configuration: ``Always``)
+Always add empty line before access modifiers unless access modifier
+is at the start of struct or class definition.
+
+.. code-block:: c++
+
+  struct foo {
+  private:
+int i;
+
+  protected:
+int j;
+/* comment */
+
+  public:
+foo() {}
+
+  private:
+
+  protected:
+  };
+
+
+
 **ExperimentalAutoDetectBinPacking** (``bool``)
   If ``true``, clang-format detects whether function calls and
   definitions are formatted with one parameter per line.

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index fcc38e25542f..96c2a74e97db 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -1885,6 +1885,68 @@ struct FormatStyle {
   /// Disables formatting completely.
   bool DisableFormat;
 
+  /// Different styles for empty line before access modifiers.
+  enum EmptyLineBeforeAccessModifierStyle : unsigned char {
+/// Remove all empty lines before access modifiers.
+/// \code
+///   struct foo {
+///   private:
+/// int i;
+///   protected:
+/// int j;
+/// /* comment */
+///   public:
+/// foo() {}
+///   private:
+///   protected:
+///   };
+/// \endcode
+ELBAMS_Never,
+/// Keep existing empty lines before access modifiers.
+ELBAMS_Leave,
+/// Add empty line only when access modifier starts a new logical block.
+/// Logical block is a group of one or more member fields or functions.
+/// \code
+///   struct foo {
+///   private:
+/// int i;
+///
+///   protected:
+/// int j;
+/// /* comment */
+///   public:
+/// foo() {}
+///
+///   private:
+///   protected:
+///   };
+/// \endcode
+ELBAMS_LogicalBlock,
+/// Always add empty line before access modifiers unless access modifier
+/// is at the start of struct or class definition.
+/// \code
+///   struct foo {
+///   private:
+/// int i;
+///
+///   protected:
+/// int j;
+/// /* comment */
+///
+///   public:
+/// foo() {}
+///
+///   private:
+///
+///   protected:
+///   };
+/// \endcode
+ELBAMS_Always,
+  };
+
+  /// Defines in which cases to put empty line before access modifiers.
+  EmptyLineBeforeAccessModifierStyle Emp

[llvm-branch-commits] [clang] bcc1dee - [clang-format] Add StatementAttributeLikeMacros option

2021-01-17 Thread Björn Schäpers via llvm-branch-commits

Author: Björn Schäpers
Date: 2021-01-18T06:54:31+01:00
New Revision: bcc1dee60019f3a488a04dc7f701f7a692040fed

URL: 
https://github.com/llvm/llvm-project/commit/bcc1dee60019f3a488a04dc7f701f7a692040fed
DIFF: 
https://github.com/llvm/llvm-project/commit/bcc1dee60019f3a488a04dc7f701f7a692040fed.diff

LOG: [clang-format] Add StatementAttributeLikeMacros option

This allows to ignore for example Qts emit when
AlignConsecutiveDeclarations is set, otherwise it is parsed as a type
and it results in some misformating:

unsigned char MyChar = 'x';
emit  signal(MyChar);

Differential Revision: https://reviews.llvm.org/D93776

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/FormatToken.h
clang/lib/Format/FormatTokenLexer.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 8eee6187d0c6..928d136ef9ff 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3074,6 +3074,20 @@ the configuration (without a prefix: ``Auto``).
 
 
 
+**StatementAttributeLikeMacros** (``std::vector``)
+  Macros which are ignored in front of a statement, as if they were an
+  attribute. So that they are not parsed as identifier, for example for Qts
+  emit. \code
+AlignConsecutiveDeclarations: true
+StatementAttributeLikeMacros: []
+unsigned char data = 'x';
+emit  signal(data); // This is parsed as variable declaration.
+
+AlignConsecutiveDeclarations: true
+StatementAttributeLikeMacros: [emit]
+unsigned char data = 'x';
+emit signal(data); // Now it's fine again.
+
 **StatementMacros** (``std::vector``)
   A vector of macros that should be interpreted as complete
   statements.

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 76d4b6bb5acd..7fcae5bce164 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -296,6 +296,10 @@ clang-format
 - Option ``SpaceBeforeCaseColon`` has been added to add a space before the
   colon in a case or default statement.
 
+- Option ``StatementAttributeLikeMacros`` has been added to declare
+  macros which are not parsed as a type in front of a statement. See
+  the documentation for an example.
+
 
 libclang
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 6b3fb8164a28..943a33cee4fd 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2676,6 +2676,21 @@ struct FormatStyle {
   /// \endcode
   LanguageStandard Standard;
 
+  /// Macros which are ignored in front of a statement, as if they were an
+  /// attribute. So that they are not parsed as identifier, for example for Qts
+  /// emit. \code
+  ///   AlignConsecutiveDeclarations: true
+  ///   StatementAttributeLikeMacros: []
+  ///   unsigned char data = 'x';
+  ///   emit  signal(data); // This is parsed as variable declaration.
+  ///
+  ///   AlignConsecutiveDeclarations: true
+  ///   StatementAttributeLikeMacros: [emit]
+  ///   unsigned char data = 'x';
+  ///   emit signal(data); // Now it's fine again.
+  /// \endcode
+  std::vector StatementAttributeLikeMacros;
+
   /// The number of columns used for tab stops.
   unsigned TabWidth;
 
@@ -2825,9 +2840,11 @@ struct FormatStyle {
SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
SpaceBeforeSquareBrackets == R.SpaceBeforeSquareBrackets &&
BitFieldColonSpacing == R.BitFieldColonSpacing &&
-   Standard == R.Standard && TabWidth == R.TabWidth &&
-   StatementMacros == R.StatementMacros && UseTab == R.UseTab &&
-   UseCRLF == R.UseCRLF && TypenameMacros == R.TypenameMacros;
+   Standard == R.Standard &&
+   StatementAttributeLikeMacros == R.StatementAttributeLikeMacros &&
+   StatementMacros == R.StatementMacros && TabWidth == R.TabWidth &&
+   UseTab == R.UseTab && UseCRLF == R.UseCRLF &&
+   TypenameMacros == R.TypenameMacros;
   }
 
   llvm::Optional GetLanguageStyle(LanguageKind Language) const;

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 1207ac2dcc2b..9f007819326c 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -549,6 +549,8 @@ template <> struct MappingTraits {
Style.ExperimentalAutoDetectBinPacking);
 IO.mapOptional("FixNamespaceComments", Style.FixNamespaceComments);
 IO.mapOptional("ForEachMacros", Style.ForEachMacros);
+IO.mapOptional("StatementAttributeLikeMacros",
+   Style.StatementAttributeLikeMacros);
 IO.m

[llvm-branch-commits] [clang] b43075e - [clang-format] Fix documentation of bcc1dee600

2021-01-18 Thread Björn Schäpers via llvm-branch-commits

Author: Björn Schäpers
Date: 2021-01-18T11:03:13+01:00
New Revision: b43075e34a598460fe1590d950862a26449e8d10

URL: 
https://github.com/llvm/llvm-project/commit/b43075e34a598460fe1590d950862a26449e8d10
DIFF: 
https://github.com/llvm/llvm-project/commit/b43075e34a598460fe1590d950862a26449e8d10.diff

LOG: [clang-format] Fix documentation of bcc1dee600

That was an oversight.

Differential Revision: https://reviews.llvm.org/D93776

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 928d136ef9ff..27dcee83a538 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3077,7 +3077,10 @@ the configuration (without a prefix: ``Auto``).
 **StatementAttributeLikeMacros** (``std::vector``)
   Macros which are ignored in front of a statement, as if they were an
   attribute. So that they are not parsed as identifier, for example for Qts
-  emit. \code
+  emit.
+
+  .. code-block:: c++
+
 AlignConsecutiveDeclarations: true
 StatementAttributeLikeMacros: []
 unsigned char data = 'x';

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 943a33cee4fd..385803700d58 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2678,7 +2678,8 @@ struct FormatStyle {
 
   /// Macros which are ignored in front of a statement, as if they were an
   /// attribute. So that they are not parsed as identifier, for example for Qts
-  /// emit. \code
+  /// emit.
+  /// \code
   ///   AlignConsecutiveDeclarations: true
   ///   StatementAttributeLikeMacros: []
   ///   unsigned char data = 'x';



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] cbdde49 - [clang-format] Apply Allman style to lambdas

2021-01-19 Thread Björn Schäpers via llvm-branch-commits

Author: Björn Schäpers
Date: 2021-01-19T18:17:01+01:00
New Revision: cbdde495ba28915d52b561e44aaba12db4cf724f

URL: 
https://github.com/llvm/llvm-project/commit/cbdde495ba28915d52b561e44aaba12db4cf724f
DIFF: 
https://github.com/llvm/llvm-project/commit/cbdde495ba28915d52b561e44aaba12db4cf724f.diff

LOG: [clang-format] Apply Allman style to lambdas

Differential Revision: https://reviews.llvm.org/D94906

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 9f007819326c..110e1a726f55 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -801,6 +801,7 @@ static FormatStyle expandPresets(const FormatStyle &Style) {
 Expanded.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
 Expanded.BraceWrapping.BeforeCatch = true;
 Expanded.BraceWrapping.BeforeElse = true;
+Expanded.BraceWrapping.BeforeLambdaBody = true;
 break;
   case FormatStyle::BS_Whitesmiths:
 Expanded.BraceWrapping.AfterCaseLabel = true;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index ae8bfc60f6d9..1565016802f9 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -13481,6 +13481,58 @@ TEST_F(FormatTest, AllmanBraceBreaking) {
"#endif",
AllmanBraceStyle);
 
+  EXPECT_EQ(AllmanBraceStyle.AllowShortLambdasOnASingleLine,
+FormatStyle::SLS_All);
+
+  verifyFormat("[](int i) { return i + 2; };\n"
+   "[](int i, int j)\n"
+   "{\n"
+   "  auto x = i + j;\n"
+   "  auto y = i * j;\n"
+   "  return x ^ y;\n"
+   "};\n"
+   "void foo()\n"
+   "{\n"
+   "  auto shortLambda = [](int i) { return i + 2; };\n"
+   "  auto longLambda = [](int i, int j)\n"
+   "  {\n"
+   "auto x = i + j;\n"
+   "auto y = i * j;\n"
+   "return x ^ y;\n"
+   "  };\n"
+   "}",
+   AllmanBraceStyle);
+
+  AllmanBraceStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None;
+
+  verifyFormat("[](int i)\n"
+   "{\n"
+   "  return i + 2;\n"
+   "};\n"
+   "[](int i, int j)\n"
+   "{\n"
+   "  auto x = i + j;\n"
+   "  auto y = i * j;\n"
+   "  return x ^ y;\n"
+   "};\n"
+   "void foo()\n"
+   "{\n"
+   "  auto shortLambda = [](int i)\n"
+   "  {\n"
+   "return i + 2;\n"
+   "  };\n"
+   "  auto longLambda = [](int i, int j)\n"
+   "  {\n"
+   "auto x = i + j;\n"
+   "auto y = i * j;\n"
+   "return x ^ y;\n"
+   "  };\n"
+   "}",
+   AllmanBraceStyle);
+
+  // Reset
+  AllmanBraceStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_All;
+
   // This shouldn't affect ObjC blocks..
   verifyFormat("[self doSomeThingWithACompletionHandler:^{\n"
"  // ...\n"



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 5e5ef53 - [clang-format][NFC] Expand BreakBeforeBraces examples

2020-12-18 Thread Björn Schäpers via llvm-branch-commits

Author: Björn Schäpers
Date: 2020-12-18T19:08:03+01:00
New Revision: 5e5ef5359742c3feb6f41058a356a28c7ab3ea6d

URL: 
https://github.com/llvm/llvm-project/commit/5e5ef5359742c3feb6f41058a356a28c7ab3ea6d
DIFF: 
https://github.com/llvm/llvm-project/commit/5e5ef5359742c3feb6f41058a356a28c7ab3ea6d.diff

LOG: [clang-format][NFC] Expand BreakBeforeBraces examples

Differential Revision: https://reviews.llvm.org/D93170

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index f63ed168f099..32942648378b 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1205,16 +1205,47 @@ the configuration (without a prefix: ``Auto``).
 
 .. code-block:: c++
 
-  try {
-foo();
-  } catch () {
+  namespace N {
+  enum E {
+E1,
+E2,
+  };
+
+  class C {
+  public:
+C();
+  };
+
+  bool baz(int i) {
+try {
+  do {
+switch (i) {
+case 1: {
+  foobar();
+  break;
+}
+default: {
+  break;
+}
+}
+  } while (--i);
+  return true;
+} catch (...) {
+  handleError();
+  return false;
+}
   }
-  void foo() { bar(); }
-  class foo {};
-  if (foo()) {
-  } else {
+
+  void foo(bool b) {
+if (b) {
+  baz(2);
+} else {
+  baz(5);
+}
   }
-  enum X : int { A, B };
+
+  void bar() { foo(true); }
+  } // namespace N
 
   * ``BS_Linux`` (in configuration: ``Linux``)
 Like ``Attach``, but break before braces on function, namespace and
@@ -1222,18 +1253,51 @@ the configuration (without a prefix: ``Auto``).
 
 .. code-block:: c++
 
-  try {
-foo();
-  } catch () {
-  }
-  void foo() { bar(); }
-  class foo
+  namespace N
   {
+  enum E {
+E1,
+E2,
   };
-  if (foo()) {
-  } else {
+
+  class C
+  {
+  public:
+C();
+  };
+
+  bool baz(int i)
+  {
+try {
+  do {
+switch (i) {
+case 1: {
+  foobar();
+  break;
+}
+default: {
+  break;
+}
+}
+  } while (--i);
+  return true;
+} catch (...) {
+  handleError();
+  return false;
+}
   }
-  enum X : int { A, B };
+
+  void foo(bool b)
+  {
+if (b) {
+  baz(2);
+} else {
+  baz(5);
+}
+  }
+
+  void bar() { foo(true); }
+  } // namespace N
 
   * ``BS_Mozilla`` (in configuration: ``Mozilla``)
 Like ``Attach``, but break before braces on enum, function, and record
@@ -1241,18 +1305,51 @@ the configuration (without a prefix: ``Auto``).
 
 .. code-block:: c++
 
-  try {
-foo();
-  } catch () {
-  }
-  void foo() { bar(); }
-  class foo
+  namespace N {
+  enum E
   {
+E1,
+E2,
   };
-  if (foo()) {
-  } else {
+
+  class C
+  {
+  public:
+C();
+  };
+
+  bool baz(int i)
+  {
+try {
+  do {
+switch (i) {
+case 1: {
+  foobar();
+  break;
+}
+default: {
+  break;
+}
+}
+  } while (--i);
+  return true;
+} catch (...) {
+  handleError();
+  return false;
+}
   }
-  enum X : int { A, B };
+
+  void foo(bool b)
+  {
+if (b) {
+  baz(2);
+} else {
+  baz(5);
+}
+  }
+
+  void bar() { foo(true); }
+  } // namespace N
 
   * ``BS_Stroustrup`` (in configuration: ``Stroustrup``)
 Like ``Attach``, but break before function definitions, ``catch``, and
@@ -1260,75 +1357,175 @@ the configuration (without a prefix: ``Auto``).
 
 .. code-block:: c++
 
-  try {
-foo();
-  }
-  catch () {
-  }
-  void foo() { bar(); }
-  class foo {
+  namespace N {
+  enum E {
+E1,
+E2,
   };
-  if (foo()) {
+
+  class C {
+  public:
+C();
+  };
+
+  bool baz(int i)
+  {
+try {
+  do {
+switch (i) {
+case 1: {
+  foobar();
+  break;
+}
+default: {
+  break;
+}
+}
+  } while (--i);
+  return true;
+}
+catch (...) {
+  handleError();
+  return false;
+}
   }
-  else {
+

[llvm-branch-commits] [clang] 374f1d8 - [clang-format] Fix handling of TextProto comments

2020-12-23 Thread Björn Schäpers via llvm-branch-commits

Author: Björn Schäpers
Date: 2020-12-23T22:07:13+01:00
New Revision: 374f1d81febf8143e8e633296a42c2311699c5b3

URL: 
https://github.com/llvm/llvm-project/commit/374f1d81febf8143e8e633296a42c2311699c5b3
DIFF: 
https://github.com/llvm/llvm-project/commit/374f1d81febf8143e8e633296a42c2311699c5b3.diff

LOG: [clang-format] Fix handling of TextProto comments

Differential Revision: https://reviews.llvm.org/D93163

Added: 


Modified: 
clang/lib/Format/BreakableToken.cpp
clang/unittests/Format/FormatTestTextProto.cpp

Removed: 




diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index 6a240fdec8b9..c5edc670393c 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -789,9 +789,14 @@ BreakableLineCommentSection::BreakableLineCommentSection(
   Prefix[i] = "///< ";
 else if (Prefix[i] == "//!<")
   Prefix[i] = "//!< ";
-else if (Prefix[i] == "#" &&
- Style.Language == FormatStyle::LK_TextProto)
+else if (Prefix[i] == "#")
   Prefix[i] = "# ";
+else if (Prefix[i] == "##")
+  Prefix[i] = "## ";
+else if (Prefix[i] == "###")
+  Prefix[i] = "### ";
+else if (Prefix[i] == "")
+  Prefix[i] = " ";
   }
 
   Tokens[i] = LineTok;

diff  --git a/clang/unittests/Format/FormatTestTextProto.cpp 
b/clang/unittests/Format/FormatTestTextProto.cpp
index 3ae13d172865..1e2594893841 100644
--- a/clang/unittests/Format/FormatTestTextProto.cpp
+++ b/clang/unittests/Format/FormatTestTextProto.cpp
@@ -380,25 +380,29 @@ TEST_F(FormatTestTextProto, KeepsCommentsIndentedInList) {
": 3849");
 }
 
-TEST_F(FormatTestTextProto, UnderstandsHashHashComments) {
+TEST_F(FormatTestTextProto, UnderstandsHashComments) {
   FormatStyle Style = getGoogleStyle(FormatStyle::LK_TextProto);
   Style.ColumnLimit = 60; // To make writing tests easier.
   EXPECT_EQ("aaa: 100\n"
-"##this is a double-hash comment.\n"
+"## this is a double-hash comment.\n"
 "bb: 100\n"
 "## another double-hash comment.\n"
 "### a triple-hash comment\n"
 "cc: 200\n"
+"### another triple-hash comment\n"
 " a quadriple-hash comment\n"
-"dd: 100\n",
+"dd: 100\n"
+" another quadriple-hash comment\n",
 format("aaa: 100\n"
"##this is a double-hash comment.\n"
"bb: 100\n"
"## another double-hash comment.\n"
-   "### a triple-hash comment\n"
+   "###a triple-hash comment\n"
"cc: 200\n"
-   " a quadriple-hash comment\n"
-   "dd: 100\n",
+   "### another triple-hash comment\n"
+   "a quadriple-hash comment\n"
+   "dd: 100\n"
+   " another quadriple-hash comment\n",
Style));
 }
 



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 47877c9 - [clang-format] Add SpaceBeforeCaseColon option

2020-12-23 Thread Björn Schäpers via llvm-branch-commits

Author: Björn Schäpers
Date: 2020-12-23T22:07:14+01:00
New Revision: 47877c9079c27f19a954b660201ea47717c82fec

URL: 
https://github.com/llvm/llvm-project/commit/47877c9079c27f19a954b660201ea47717c82fec
DIFF: 
https://github.com/llvm/llvm-project/commit/47877c9079c27f19a954b660201ea47717c82fec.diff

LOG: [clang-format] Add SpaceBeforeCaseColon option

With which you can add a space before the colon of a case or default
statement.

Differential Revision: https://reviews.llvm.org/D93240

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 32942648378b..c58bb1af7ae6 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -2839,6 +2839,16 @@ the configuration (without a prefix: ``Auto``).
  int a = 5; vs. int a= 5;
  a += 42;   a+= 42;
 
+**SpaceBeforeCaseColon** (``bool``)
+  If ``false``, spaces will be removed before case colon.
+
+  .. code-block:: c++
+
+true:   false
+switch (x) {vs. switch (x) {
+  case 1 : break; case 1: break;
+}   }
+
 **SpaceBeforeCpp11BracedList** (``bool``)
   If ``true``, a space will be inserted before a C++11 braced list
   used to initialize an object (after the preceding identifier or type).

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index dd4de2d2015f..76d4b6bb5acd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -293,6 +293,9 @@ clang-format
 
 - Option ``IndentPragmas`` has been added to allow #pragma to indented with 
the current scope level. This is especially useful when using #pragma to mark 
OpenMP sections of code.
 
+- Option ``SpaceBeforeCaseColon`` has been added to add a space before the
+  colon in a case or default statement.
+
 
 libclang
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 9b8309213261..c6a9818a8940 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2438,6 +2438,15 @@ struct FormatStyle {
   /// \endcode
   bool SpaceBeforeAssignmentOperators;
 
+  /// If ``false``, spaces will be removed before case colon.
+  /// \code
+  ///   true:   false
+  ///   switch (x) {vs. switch (x) {
+  /// case 1 : break; case 1: break;
+  ///   }   }
+  /// \endcode
+  bool SpaceBeforeCaseColon;
+
   /// If ``true``, a space will be inserted before a C++11 braced list
   /// used to initialize an object (after the preceding identifier or type).
   /// \code
@@ -2820,6 +2829,7 @@ struct FormatStyle {
SpaceAfterLogicalNot == R.SpaceAfterLogicalNot &&
SpaceAfterTemplateKeyword == R.SpaceAfterTemplateKeyword &&
SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators 
&&
+   SpaceBeforeCaseColon == R.SpaceBeforeCaseColon &&
SpaceBeforeCpp11BracedList == R.SpaceBeforeCpp11BracedList &&
SpaceBeforeCtorInitializerColon ==
R.SpaceBeforeCtorInitializerColon &&

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 55abc12c61c4..54424ae190e2 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -608,6 +608,7 @@ template <> struct MappingTraits {
Style.SpaceAfterTemplateKeyword);
 IO.mapOptional("SpaceBeforeAssignmentOperators",
Style.SpaceBeforeAssignmentOperators);
+IO.mapOptional("SpaceBeforeCaseColon", Style.SpaceBeforeCaseColon);
 IO.mapOptional("SpaceBeforeCpp11BracedList",
Style.SpaceBeforeCpp11BracedList);
 IO.mapOptional("SpaceBeforeCtorInitializerColon",
@@ -958,6 +959,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.SpaceAfterLogicalNot = false;
   LLVMStyle.SpaceAfterTemplateKeyword = true;
   LLVMStyle.SpaceAroundPointerQualifiers = FormatStyle::SAPQ_Default;
+  LLVMStyle.SpaceBeforeCaseColon = false;
   LLVMStyle.SpaceBeforeCtorInitializerColon = true;
   LLVMStyle.SpaceBeforeInheritanceColon = true;
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index a0cb86cfcebf..1588f7d08184 100755
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -896,7 +896,8 @@ class AnnotatingP

[llvm-branch-commits] [clang] 3630640 - [clang-format] Remove double trim

2020-12-13 Thread Björn Schäpers via llvm-branch-commits

Author: Björn Schäpers
Date: 2020-12-13T14:16:54+01:00
New Revision: 36306403d492d4a4b54c72c6c4c511021584243b

URL: 
https://github.com/llvm/llvm-project/commit/36306403d492d4a4b54c72c6c4c511021584243b
DIFF: 
https://github.com/llvm/llvm-project/commit/36306403d492d4a4b54c72c6c4c511021584243b.diff

LOG: [clang-format] Remove double trim

Lines[i] is already trimmed 3 lines before

Differential Revision: https://reviews.llvm.org/D91996

Added: 


Modified: 
clang/lib/Format/BreakableToken.cpp

Removed: 




diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index 4975c89164a4..ea5cc31af07a 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -773,10 +773,7 @@ BreakableLineCommentSection::BreakableLineCommentSection(
 OriginalPrefix.resize(Lines.size());
 for (size_t i = FirstLineIndex, e = Lines.size(); i < e; ++i) {
   Lines[i] = Lines[i].ltrim(Blanks);
-  // We need to trim the blanks in case this is not the first line in a
-  // multiline comment. Then the indent is included in Lines[i].
-  StringRef IndentPrefix =
-  getLineCommentIndentPrefix(Lines[i].ltrim(Blanks), Style);
+  StringRef IndentPrefix = getLineCommentIndentPrefix(Lines[i], Style);
   assert((TokenText.startswith("//") || TokenText.startswith("#")) &&
  "unsupported line comment prefix, '//' and '#' are supported");
   OriginalPrefix[i] = Prefix[i] = IndentPrefix;



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/19.x: [clang-format] Fix a regression in parsing `switch` in macro call (#114506) (PR #114640)

2024-11-02 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/114640
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/19.x: [clang-format] Fix idempotent format of hash in macro body (#118513) (PR #119503)

2024-12-18 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/119503
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang-format] Handle C-style cast of member function pointer type (#126340) (PR #126479)

2025-02-11 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/126479
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang-format] Keep the space between `not` and a unary operator (#135035) (PR #135118)

2025-04-10 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/135118
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang-format] Fix mismatched break in BlockIndent (#124998) (PR #136238)

2025-04-18 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/136238
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang-format] Correctly annotate kw_operator in using decls (#136545) (PR #136808)

2025-04-23 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/136808
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[clang] release/20.x: [clang-format] RemoveParentheses shouldn't remove empty… (PR #138380)

2025-05-03 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/138380
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang-format] Don't remove parentheses separated from ellipsis by comma (#130471) (PR #130702)

2025-03-11 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/130702
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang-format] Allow `Language: Cpp` for C files (#133033) (PR #133216)

2025-03-27 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/133216
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang-format] Handle Java text blocks (#141334) (PR #141433)

2025-05-26 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/141433
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang-format] Correctly annotate token-pasted function decl names (#142337) (PR #142482)

2025-06-02 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/142482
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/20.x: [clang-format] Handle token-pasted function decl names (#142251) (PR #142282)

2025-05-31 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/142282
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] release/21.x: [clang-format] Fix a regression of annotating PointerOrReference (#149039) (PR #149451)

2025-07-18 Thread Björn Schäpers via llvm-branch-commits

https://github.com/HazardyKnusperkeks approved this pull request.


https://github.com/llvm/llvm-project/pull/149451
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits