[PATCH] D53974: [clang-tidy] new check: bugprone-too-small-loop-variable

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 6 01:20:09 PST 2018


lebedev.ri added inline comments.


================
Comment at: clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp:20
+
+static const char LoopName[] = "forLoopName";
+static const char loopVarName[] = "loopVar";
----------------
Szelethus wrote:
> JonasToth wrote:
> > JonasToth wrote:
> > > ztamas wrote:
> > > > JonasToth wrote:
> > > > > Please move these variable in the matcher function and make them `StringRef` instead of `const char[]`.
> > > > These variables are used not only inside the matcher function but also in the check() function.
> > > > 
> > > I didn't see that, but they should still be `StringRef` as type.
> > One more nit i forgot: these variables should be `static` for linkage and be CamelCase to match the naming conventions.
> Hmmm, `StringRef` actually has a `constexpr` constructor, we could make these `constexpr` too I guess.
You want `StringLiteral`:
```
static constexpr llvm::StringLiteral loopVarCastName = llvm::StringLiteral("loopVarCast");
static constexpr llvm::StringLiteral loopCondName = llvm::StringLiteral("loopCond");
static constexpr llvm::StringLiteral loopIncrementName = llvm::StringLiteral("loopIncrement");
```


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53974





More information about the cfe-commits mailing list