@@ -479,7 +479,7 @@ namespace {
479
479
// / not have the deduced type set. Instead, we have to go to the appropriate
480
480
// / DeclaratorDecl/FunctionDecl and work our back to the AutoType that does have
481
481
// / a deduced type set. The AST should be improved to simplify this scenario.
482
- class DeducedTypeVisitor : public RecursiveASTVisitor <DeducedTypeVisitor> {
482
+ class DeducedTypeVisitor : public ConstRecursiveASTVisitor <DeducedTypeVisitor> {
483
483
SourceLocation SearchedLocation;
484
484
const HeuristicResolver *Resolver;
485
485
@@ -493,7 +493,7 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
493
493
// - decltype(auto) i = 1;
494
494
// - auto& i = 1;
495
495
// - auto* i = &a;
496
- bool VisitDeclaratorDecl (DeclaratorDecl *D) {
496
+ bool VisitDeclaratorDecl (const DeclaratorDecl *D) {
497
497
if (!D->getTypeSourceInfo () ||
498
498
!D->getTypeSourceInfo ()->getTypeLoc ().getContainedAutoTypeLoc () ||
499
499
D->getTypeSourceInfo ()
@@ -522,7 +522,7 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
522
522
// - auto foo() -> int {}
523
523
// - auto foo() -> decltype(1+1) {}
524
524
// - operator auto() const { return 10; }
525
- bool VisitFunctionDecl (FunctionDecl *D) {
525
+ bool VisitFunctionDecl (const FunctionDecl *D) {
526
526
if (!D->getTypeSourceInfo ())
527
527
return true ;
528
528
// Loc of auto in return type (c++14).
@@ -553,7 +553,7 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
553
553
// Handle non-auto decltype, e.g.:
554
554
// - auto foo() -> decltype(expr) {}
555
555
// - decltype(expr);
556
- bool VisitDecltypeTypeLoc (DecltypeTypeLoc TL) {
556
+ bool VisitDecltypeTypeLoc (const DecltypeTypeLoc TL) {
557
557
if (TL.getBeginLoc () != SearchedLocation)
558
558
return true ;
559
559
@@ -571,7 +571,7 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
571
571
572
572
// Handle functions/lambdas with `auto` typed parameters.
573
573
// We deduce the type if there's exactly one instantiation visible.
574
- bool VisitParmVarDecl (ParmVarDecl *PVD) {
574
+ bool VisitParmVarDecl (const ParmVarDecl *PVD) {
575
575
if (!PVD->getType ()->isDependentType ())
576
576
return true ;
577
577
// 'auto' here does not name an AutoType, but an implicit template param.
@@ -606,7 +606,7 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
606
606
return true ;
607
607
}
608
608
609
- static int paramIndex (const TemplateDecl &TD, NamedDecl &Param) {
609
+ static int paramIndex (const TemplateDecl &TD, const NamedDecl &Param) {
610
610
unsigned I = 0 ;
611
611
for (auto *ND : *TD.getTemplateParameters ()) {
612
612
if (&Param == ND)
@@ -620,7 +620,7 @@ class DeducedTypeVisitor : public RecursiveASTVisitor<DeducedTypeVisitor> {
620
620
};
621
621
} // namespace
622
622
623
- std::optional<QualType> getDeducedType (ASTContext &ASTCtx,
623
+ std::optional<QualType> getDeducedType (const ASTContext &ASTCtx,
624
624
const HeuristicResolver *Resolver,
625
625
SourceLocation Loc) {
626
626
if (!Loc.isValid ())
@@ -659,7 +659,7 @@ static NamedDecl *getOnlyInstantiationImpl(TemplateDeclTy *TD) {
659
659
return Only;
660
660
}
661
661
662
- NamedDecl *getOnlyInstantiation (NamedDecl *TemplatedDecl) {
662
+ NamedDecl *getOnlyInstantiation (const NamedDecl *TemplatedDecl) {
663
663
if (TemplateDecl *TD = TemplatedDecl->getDescribedTemplate ()) {
664
664
if (auto *CTD = llvm::dyn_cast<ClassTemplateDecl>(TD))
665
665
return getOnlyInstantiationImpl (CTD);
0 commit comments