[PATCH] D113898: [NFC][clangd] cleaning up llvm-qualified-auto

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 18 09:51:08 PST 2021


Quuxplusone added a comment.

In D113898#3140320 <https://reviews.llvm.org/D113898#3140320>, @kuhnel wrote:

> When trying to revert some of the changes, I just noticed there are a couple of `if (const auto* ...` in `CodeComplete.cpp` and `AST.cpp` (and maybe other files as well). So some folks seem to be using this right now. If we want to be consistent, we would have to remove these `const` as well.

Just in case it's news to anyone: (1) Theoretically, the compiler has enough information to tell you when it's deducing a cv-qualified type for a non-forwarding-reference `auto`; and personally I'd like such a warning and would go fix my code every time it fired. I like that `const auto *p` has the same "shape" as `const Widget *p`. That sometimes a non-const `auto` can secretly mean //`const`//`Widget` is //weird// and I don't like it.
(2) In template contexts, `const auto *` can be significant, because maybe in some instantiations the `const` doesn't matter and in others it does. https://quuxplusone.github.io/blog/2020/03/04/field-report-on-lifetime-extension/#true-positive-3-conditionally-redundant-lifetime-extension-in-template-code is related.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113898



More information about the cfe-commits mailing list