Can we link clang format into clangAnalysis?

In the Clang Static Analyzer, we would have a use case for using the clang format library for prettifying macro expansions.
In general, the Static Analyzer community was waiting for this feature and are unanimously supportive.
See the PR156046.

However, we wanted to reach out to the broader Clang frontend area team members to learn their opinion. @clang-area-team

We don’t plan to provide an escape hatch to avoid this link dependency, so everybody building the Clang would be affected. We plan to have a runtime flag to disable invoking the clang format parts (but this code path is anyways only reachable when the Static Analyzer is running, which is a tiny subset of the clang users).

Can we link against clangFormat?

1 Like

Clang itself has the same need when formatting fix-its. We currently just say “run clang-format” but it would be better if this was fully integrated into the compiler. Any interest in linking at a higher level than just CSA (e.g., so we can use it from clangParser and clangSema)?

The big question is: what does the library layering look like? clangFormat currently links against:

  clangBasic
  clangLex
  clangToolingCore
  clangToolingInclusions

so we’d have a circular dependency if we tried to do formatting from, say, clangLex.

CC @owenpan @mydeveloperday as clang-format maintainers.

1 Like

ping @AaronBallman @owenpan @mydeveloperday

I don’t have any problems with this.