[clang] [clang-format] Allow specifying the language for `.h` files (PR #128122)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 21 13:16:36 PST 2025


================
@@ -4782,7 +4782,13 @@ the configuration (without a prefix: ``Auto``).
 .. _Language:
 
 **Language** (``LanguageKind``) :versionbadge:`clang-format 3.5` :ref:`ΒΆ <Language>`
-  Language, this format style is targeted at.
+  The language that this format style targets.
+
+  .. note::
+
+   You can also specify the language (``Cpp`` or ``ObjC``) for ``.h`` files
+   by adding a ``// clang-format Language:`` line before the first
+   non-comment and non-empty line, e.g. ``// clang-format Language: ObjC``.
----------------
owenca wrote:

```suggestion
   non-comment line, e.g. ``// clang-format Language: ObjC``.
```

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


More information about the cfe-commits mailing list