[PATCH] D116577: [clang-tidy] Added "boost-use-range-based-for-loop" check

Richard via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 4 09:21:55 PST 2022


LegalizeAdulthood added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/boost/UseRangeBasedForLoopCheck.h:28
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+    return LangOpts.CPlusPlus11;
+  }
----------------
LegalizeAdulthood wrote:
> This is an implicit conversion from `unsigned` to `bool`,
> an explicit comparison against `!= 0` would be preferable IMO.
> 
> However, my bigger question is what happens when someone
> runs this check with `-std=c++14` or some other later version of C++?
> 
> I looked at the header for `LangOptions` and it isn't clear whether
> the bits are set to indicate supported portions of the standard or
> if they simply reflect the command-line options used when invoking
> the compiler.
When you specify a standard on the command-line, the front end
sets all the relevant bits, so if you say `-std=c++14` then C++11 is
also set (but not C++17, C++20, etc.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116577



More information about the cfe-commits mailing list