[clang] [clang-format] Add SpaceBeforeUnderscoreParens option for GNU gettext… (PR #159925)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 21 13:26:01 PDT 2025


================
@@ -4901,6 +4901,12 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
     // Handle builtins like identifiers.
     if (Line.Type != LT_PreprocessorDirective &&
         (Left.Tok.getIdentifierInfo() || Left.is(tok::r_paren))) {
+      // Check for special case: single underscore token (gettext macro)
+      if (Left.Tok.getIdentifierInfo() && !Style.SpaceBeforeUnderscoreParens) {
+        StringRef TokenText = Left.TokenText;
+        if (TokenText == "_")
----------------
HazardyKnusperkeks wrote:

```suggestion
      if (Left.Tok.getIdentifierInfo() && !Style.SpaceBeforeUnderscoreParens && Left.TokenText == "_")
```
I'd merge that.

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


More information about the cfe-commits mailing list