llvm/clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp

//===--- TooSmallLoopVariableCheck.cpp - clang-tidy -----------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "TooSmallLoopVariableCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"

usingnamespaceclang::ast_matchers;

namespace clang::tidy::bugprone {

static constexpr llvm::StringLiteral LoopName =;
static constexpr llvm::StringLiteral LoopVarName =;
static constexpr llvm::StringLiteral LoopVarCastName =;
static constexpr llvm::StringLiteral LoopUpperBoundName =;
static constexpr llvm::StringLiteral LoopIncrementName =;

namespace {

struct MagnitudeBits {};

} // namespace

TooSmallLoopVariableCheck::TooSmallLoopVariableCheck(StringRef Name,
                                                     ClangTidyContext *Context)
    :{}

void TooSmallLoopVariableCheck::storeOptions(
    ClangTidyOptions::OptionMap &Opts) {}

/// The matcher for loops with suspicious integer loop variable.
///
/// In this general example, assuming 'j' and 'k' are of integral type:
/// \code
///   for (...; j < 3 + 2; ++k) { ... }
/// \endcode
/// The following string identifiers are bound to these parts of the AST:
///   LoopVarName: 'j' (as a VarDecl)
///   LoopVarCastName: 'j' (after implicit conversion)
///   LoopUpperBoundName: '3 + 2' (as an Expr)
///   LoopIncrementName: 'k' (as an Expr)
///   LoopName: The entire for loop (as a ForStmt)
///
void TooSmallLoopVariableCheck::registerMatchers(MatchFinder *Finder) {}

/// Returns the magnitude bits of an integer type.
static MagnitudeBits calcMagnitudeBits(const ASTContext &Context,
                                       const QualType &IntExprType,
                                       const Expr *IntExpr) {}

/// Calculate the upper bound expression's magnitude bits, but ignore
/// constant like values to reduce false positives.
static MagnitudeBits
calcUpperBoundMagnitudeBits(const ASTContext &Context, const Expr *UpperBound,
                            const QualType &UpperBoundType) {}

static std::string formatIntegralType(const QualType &Type,
                                      const MagnitudeBits &Info) {}

void TooSmallLoopVariableCheck::check(const MatchFinder::MatchResult &Result) {}

} // namespace clang::tidy::bugprone