diff options
Diffstat (limited to 'clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h')
-rw-r--r-- | clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h index 2fda54e3488..5290b4752ef 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h @@ -197,14 +197,39 @@ private: /// \brief The information needed to describe a valid convertible usage /// of an array index or iterator. struct Usage { + enum UsageKind { + // Regular usages of the loop index (the ones not specified below). Some + // examples: + // \code + // int X = 8 * Arr[i]; + // ^~~~~~ + // f(param1, param2, *It); + // ^~~ + // if (Vec[i].SomeBool) {} + // ^~~~~~ + // \endcode + UK_Default, + // Indicates whether this is an access to a member through the arrow + // operator on pointers or iterators. + UK_MemberThroughArrow, + // If the variable is being captured by a lambda, indicates whether the + // capture was done by value or by reference. + UK_CaptureByCopy, + UK_CaptureByRef + }; + // The expression that is going to be converted. Null in case of lambda + // captures. const Expr *Expression; - bool IsArrow; + + UsageKind Kind; + + // Range that covers this usage. SourceRange Range; explicit Usage(const Expr *E) - : Expression(E), IsArrow(false), Range(Expression->getSourceRange()) {} - Usage(const Expr *E, bool IsArrow, SourceRange Range) - : Expression(E), IsArrow(IsArrow), Range(std::move(Range)) {} + : Expression(E), Kind(UK_Default), Range(Expression->getSourceRange()) {} + Usage(const Expr *E, UsageKind Kind, SourceRange Range) + : Expression(E), Kind(Kind), Range(std::move(Range)) {} }; /// \brief A class to encapsulate lowering of the tool's confidence level. |