Skip to content
Unverified Commit e9ed1aa9 authored by Emilia Kond's avatar Emilia Kond Committed by GitHub
Browse files

[clang-format] Correctly annotate designated initializer with PP if (#65409)

When encountering braces, such as those of a designated initializer,
clang-format scans ahead to see what is contained within the braces. If
it found a statement, like an if-statement of for-loop, it would deem
the braces as not an initializer, but as a block instead.

However, this heuristic incorrectly included a preprocessor `#if` line
as an if-statement. This manifested in strange results and discrepancies
between `#ifdef` and `#if defined`.

With this patch, `if` is now ignored if it is preceeded by `#`.

Fixes most of https://github.com/llvm/llvm-project/issues/56685
parent 80f0dc3a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment