[clang] [clang-format] Option to ignore PP directives (PR #70338)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 14 11:29:07 PST 2023


================
@@ -1355,8 +1355,11 @@ unsigned UnwrappedLineFormatter::format(
     bool FixIndentation = (FixBadIndentation || ContinueFormatting) &&
                           Indent != TheLine.First->OriginalColumn;
     bool ShouldFormat = TheLine.Affected || FixIndentation;
-    if (Style.IgnorePPDefinitions && TheLine.Type == LT_PreprocessorDirective)
+    if (Style.IgnorePPDefinitions && TheLine.Type == LT_PreprocessorDirective &&
+        TheLine.getFirstNonComment()->Next->is(tok::pp_define)) {
----------------
HazardyKnusperkeks wrote:

Does `Next` always exist? Is just `#` marked as `LT_PreprocessorDirective`?

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


More information about the cfe-commits mailing list