rsmith added a comment.

I'm uncomfortable about `clang-format` performing this transformation at all. 
Generally, clang-format only makes changes that are guaranteed to preserve the 
meaning of the source program, and does not make changes that are only 
heuristically likely to be semantics-preserving. But this transformation is not 
behavior-preserving in a variety of cases, such as:

  #define INTPTR int *
  const INTPTR a;
  // INTPTR const a; means something else

I also don't think this is something that a user would *want* in 
`clang-format`: changing the location of `const`s is something that would 
likely be done rarely (probably only once) when migrating to a different coding 
style, rather than being done on the fly after each edit to a source file.

Fundamentally, I don't think this transformation is simply reformatting, and I 
don't think it can be done sufficiently-correctly with only a 
largely-context-free, heuristic-driven C++ parser. As such, I think this 
belongs in `clang-tidy`, not in `clang-format`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69764/new/

https://reviews.llvm.org/D69764



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to