#include "UnnecessaryCopyInitialization.h"
#include "../utils/DeclRefExprUtils.h"
#include "../utils/FixItHintUtils.h"
#include "../utils/LexerUtils.h"
#include "../utils/Matchers.h"
#include "../utils/OptionsUtils.h"
#include "clang/AST/Decl.h"
#include "clang/Basic/Diagnostic.h"
#include <optional>
#include <utility>
namespace clang::tidy::performance {
namespace {
usingnamespace::clang::ast_matchers;
StringRef;
allDeclRefExprs;
isOnlyUsedAsConst;
static constexpr StringRef ObjectArgId = …;
static constexpr StringRef InitFunctionCallId = …;
static constexpr StringRef MethodDeclId = …;
static constexpr StringRef FunctionDeclId = …;
static constexpr StringRef OldVarDeclId = …;
void recordFixes(const VarDecl &Var, ASTContext &Context,
DiagnosticBuilder &Diagnostic) { … }
std::optional<SourceLocation> firstLocAfterNewLine(SourceLocation Loc,
SourceManager &SM) { … }
void recordRemoval(const DeclStmt &Stmt, ASTContext &Context,
DiagnosticBuilder &Diagnostic) { … }
AST_MATCHER_FUNCTION_P(StatementMatcher,
isRefReturningMethodCallWithConstOverloads,
std::vector<StringRef>, ExcludedContainerTypes) { … }
AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningFunctionCall) { … }
AST_MATCHER_FUNCTION_P(StatementMatcher, initializerReturnsReferenceToConst,
std::vector<StringRef>, ExcludedContainerTypes) { … }
static bool isInitializingVariableImmutable(
const VarDecl &InitializingVar, const Stmt &BlockStmt, ASTContext &Context,
const std::vector<StringRef> &ExcludedContainerTypes) { … }
bool isVariableUnused(const VarDecl &Var, const Stmt &BlockStmt,
ASTContext &Context) { … }
const SubstTemplateTypeParmType *getSubstitutedType(const QualType &Type,
ASTContext &Context) { … }
bool differentReplacedTemplateParams(const QualType &VarType,
const QualType &InitializerType,
ASTContext &Context) { … }
QualType constructorArgumentType(const VarDecl *OldVar,
const BoundNodes &Nodes) { … }
}
UnnecessaryCopyInitialization::UnnecessaryCopyInitialization(
StringRef Name, ClangTidyContext *Context)
: … { … }
void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) { … }
void UnnecessaryCopyInitialization::check(
const MatchFinder::MatchResult &Result) { … }
void UnnecessaryCopyInitialization::handleCopyFromMethodReturn(
const CheckContext &Ctx, const VarDecl *ObjectArg) { … }
void UnnecessaryCopyInitialization::handleCopyFromLocalVar(
const CheckContext &Ctx, const VarDecl &OldVar) { … }
void UnnecessaryCopyInitialization::diagnoseCopyFromMethodReturn(
const CheckContext &Ctx) { … }
void UnnecessaryCopyInitialization::diagnoseCopyFromLocalVar(
const CheckContext &Ctx, const VarDecl &OldVar) { … }
void UnnecessaryCopyInitialization::maybeIssueFixes(
const CheckContext &Ctx, DiagnosticBuilder &Diagnostic) { … }
void UnnecessaryCopyInitialization::storeOptions(
ClangTidyOptions::OptionMap &Opts) { … }
}