Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class StmtAncestorASTVisitor
/// Accessor for DeclParents.
const DeclParentMap &getDeclToParentStmtMap() { return DeclParents; }

friend class clang::RecursiveASTVisitor<StmtAncestorASTVisitor>;
friend class clang::RecursiveASTVisitorBase<StmtAncestorASTVisitor,
/*Const=*/false>;

private:
StmtParentMap StmtAncestors;
Expand All @@ -98,7 +99,8 @@ class ComponentFinderASTVisitor
/// Accessor for Components.
const ComponentVector &getComponents() { return Components; }

friend class clang::RecursiveASTVisitor<ComponentFinderASTVisitor>;
friend class clang::RecursiveASTVisitorBase<ComponentFinderASTVisitor,
/*Const=*/false>;

private:
ComponentVector Components;
Expand Down Expand Up @@ -155,7 +157,8 @@ class DependencyFinderASTVisitor
return DependsOnInsideVariable;
}

friend class clang::RecursiveASTVisitor<DependencyFinderASTVisitor>;
friend class clang::RecursiveASTVisitorBase<DependencyFinderASTVisitor,
/*Const=*/false>;

private:
const StmtParentMap *StmtParents;
Expand Down Expand Up @@ -188,7 +191,8 @@ class DeclFinderASTVisitor
return Found;
}

friend class clang::RecursiveASTVisitor<DeclFinderASTVisitor>;
friend class clang::RecursiveASTVisitorBase<DeclFinderASTVisitor,
/*Const=*/false>;

private:
std::string Name;
Expand Down Expand Up @@ -340,7 +344,7 @@ class ForLoopIndexUseVisitor
private:
/// Typedef used in CRTP functions.
using VisitorBase = RecursiveASTVisitor<ForLoopIndexUseVisitor>;
friend class RecursiveASTVisitor<ForLoopIndexUseVisitor>;
friend class RecursiveASTVisitorBase<ForLoopIndexUseVisitor, /*Const=*/false>;

/// Overriden methods for RecursiveASTVisitor's traversal.
bool TraverseArraySubscriptExpr(ArraySubscriptExpr *E);
Expand Down
3 changes: 2 additions & 1 deletion clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ static bool paramReferredExactlyOnce(const CXXConstructorDecl *Ctor,
/// \see ExactlyOneUsageVisitor::hasExactlyOneUsageIn()
class ExactlyOneUsageVisitor
: public RecursiveASTVisitor<ExactlyOneUsageVisitor> {
friend class RecursiveASTVisitor<ExactlyOneUsageVisitor>;
friend class RecursiveASTVisitorBase<ExactlyOneUsageVisitor,
/*Const=*/false>;

public:
ExactlyOneUsageVisitor(const ParmVarDecl *ParamDecl)
Expand Down
16 changes: 8 additions & 8 deletions clang-tools-extra/clangd/AST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ namespace {
/// not have the deduced type set. Instead, we have to go to the appropriate
/// DeclaratorDecl/FunctionDecl and work our back to the AutoType that does have
/// a deduced type set. The AST should be improved to simplify this scenario.
class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
class DeducedTypeVisitor : public ConstRecursiveASTVisitor<DeducedTypeVisitor> {
SourceLocation SearchedLocation;
const HeuristicResolver *Resolver;

Expand All @@ -493,7 +493,7 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
//- decltype(auto) i = 1;
//- auto& i = 1;
//- auto* i = &a;
bool VisitDeclaratorDecl(DeclaratorDecl *D) {
bool VisitDeclaratorDecl(const DeclaratorDecl *D) {
if (!D->getTypeSourceInfo() ||
!D->getTypeSourceInfo()->getTypeLoc().getContainedAutoTypeLoc() ||
D->getTypeSourceInfo()
Expand Down Expand Up @@ -522,7 +522,7 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
//- auto foo() -> int {}
//- auto foo() -> decltype(1+1) {}
//- operator auto() const { return 10; }
bool VisitFunctionDecl(FunctionDecl *D) {
bool VisitFunctionDecl(const FunctionDecl *D) {
if (!D->getTypeSourceInfo())
return true;
// Loc of auto in return type (c++14).
Expand Down Expand Up @@ -553,7 +553,7 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
// Handle non-auto decltype, e.g.:
// - auto foo() -> decltype(expr) {}
// - decltype(expr);
bool VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
bool VisitDecltypeTypeLoc(const DecltypeTypeLoc TL) {
if (TL.getBeginLoc() != SearchedLocation)
return true;

Expand All @@ -571,7 +571,7 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {

// Handle functions/lambdas with `auto` typed parameters.
// We deduce the type if there's exactly one instantiation visible.
bool VisitParmVarDecl(ParmVarDecl *PVD) {
bool VisitParmVarDecl(const ParmVarDecl *PVD) {
if (!PVD->getType()->isDependentType())
return true;
// 'auto' here does not name an AutoType, but an implicit template param.
Expand Down Expand Up @@ -606,7 +606,7 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
return true;
}

static int paramIndex(const TemplateDecl &TD, NamedDecl &Param) {
static int paramIndex(const TemplateDecl &TD, const NamedDecl &Param) {
unsigned I = 0;
for (auto *ND : *TD.getTemplateParameters()) {
if (&Param == ND)
Expand All @@ -620,7 +620,7 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
};
} // namespace

std::optional<QualType> getDeducedType(ASTContext &ASTCtx,
std::optional<QualType> getDeducedType(const ASTContext &ASTCtx,
const HeuristicResolver *Resolver,
SourceLocation Loc) {
if (!Loc.isValid())
Expand Down Expand Up @@ -659,7 +659,7 @@ static NamedDecl *getOnlyInstantiationImpl(TemplateDeclTy *TD) {
return Only;
}

NamedDecl *getOnlyInstantiation(NamedDecl *TemplatedDecl) {
NamedDecl *getOnlyInstantiation(const NamedDecl *TemplatedDecl) {
if (TemplateDecl *TD = TemplatedDecl->getDescribedTemplate()) {
if (auto *CTD = llvm::dyn_cast<ClassTemplateDecl>(TD))
return getOnlyInstantiationImpl(CTD);
Expand Down
5 changes: 3 additions & 2 deletions clang-tools-extra/clangd/AST.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ QualType declaredType(const TypeDecl *D);
/// Retrieves the deduced type at a given location (auto, decltype).
/// It will return the underlying type.
/// If the type is an undeduced auto, returns the type itself.
std::optional<QualType> getDeducedType(ASTContext &, const HeuristicResolver *,
std::optional<QualType> getDeducedType(const ASTContext &,
const HeuristicResolver *,
SourceLocation Loc);

// Find the abbreviated-function-template `auto` within a type, or returns null.
Expand All @@ -180,7 +181,7 @@ TemplateTypeParmTypeLoc getContainedAutoParamType(TypeLoc TL);

// If TemplatedDecl is the generic body of a template, and the template has
// exactly one visible instantiation, return the instantiated body.
NamedDecl *getOnlyInstantiation(NamedDecl *TemplatedDecl);
NamedDecl *getOnlyInstantiation(const NamedDecl *TemplatedDecl);

/// Return attributes attached directly to a node.
std::vector<const Attr *> getAttributes(const DynTypedNode &);
Expand Down
Loading
Loading