diff options
Diffstat (limited to 'clang/lib')
25 files changed, 355 insertions, 84 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 5624758670b..a8732d729ca 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1877,8 +1877,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { return getTypeInfo(cast<SubstTemplateTypeParmType>(T)-> getReplacementType().getTypePtr()); - case Type::Auto: { - const AutoType *A = cast<AutoType>(T); + case Type::Auto: + case Type::DeducedTemplateSpecialization: { + const DeducedType *A = cast<DeducedType>(T); assert(!A->getDeducedType().isNull() && "cannot request the size of an undeduced or dependent auto type"); return getTypeInfo(A->getDeducedType().getTypePtr()); @@ -2765,6 +2766,7 @@ QualType ASTContext::getVariableArrayDecayedType(QualType type) const { case Type::TemplateTypeParm: case Type::SubstTemplateTypeParmPack: case Type::Auto: + case Type::DeducedTemplateSpecialization: case Type::PackExpansion: llvm_unreachable("type should never be variably-modified"); @@ -4435,6 +4437,28 @@ QualType ASTContext::getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, return QualType(AT, 0); } +/// Return the uniqued reference to the deduced template specialization type +/// which has been deduced to the given type, or to the canonical undeduced +/// such type, or the canonical deduced-but-dependent such type. +QualType ASTContext::getDeducedTemplateSpecializationType( + TemplateName Template, QualType DeducedType, bool IsDependent) const { + // Look in the folding set for an existing type. + void *InsertPos = nullptr; + llvm::FoldingSetNodeID ID; + DeducedTemplateSpecializationType::Profile(ID, Template, DeducedType, + IsDependent); + if (DeducedTemplateSpecializationType *DTST = + DeducedTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos)) + return QualType(DTST, 0); + + DeducedTemplateSpecializationType *DTST = new (*this, TypeAlignment) + DeducedTemplateSpecializationType(Template, DeducedType, IsDependent); + Types.push_back(DTST); + if (InsertPos) + DeducedTemplateSpecializationTypes.InsertNode(DTST, InsertPos); + return QualType(DTST, 0); +} + /// getAtomicType - Return the uniqued reference to the atomic type for /// the given value type. QualType ASTContext::getAtomicType(QualType T) const { @@ -6333,6 +6357,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, // We could see an undeduced auto type here during error recovery. // Just ignore it. case Type::Auto: + case Type::DeducedTemplateSpecialization: return; case Type::Pipe: @@ -8132,6 +8157,7 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS, llvm_unreachable("Non-canonical and dependent types shouldn't get here"); case Type::Auto: + case Type::DeducedTemplateSpecialization: case Type::LValueReference: case Type::RValueReference: case Type::MemberPointer: diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index c8397d458db..f80ce35df2b 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -883,6 +883,20 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, return false; break; + case Type::DeducedTemplateSpecialization: { + auto *DT1 = cast<DeducedTemplateSpecializationType>(T1); + auto *DT2 = cast<DeducedTemplateSpecializationType>(T2); + if (!IsStructurallyEquivalent(Context, + DT1->getTemplateName(), + DT2->getTemplateName())) + return false; + if (!IsStructurallyEquivalent(Context, + DT1->getDeducedType(), + DT2->getDeducedType())) + return false; + break; + } + case Type::Record: case Type::Enum: if (!IsStructurallyEquivalent(Context, diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 5fab58a5af9..92c81072517 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -7004,6 +7004,7 @@ static int EvaluateBuiltinClassifyType(const CallExpr *E, case Type::Vector: case Type::ExtVector: case Type::Auto: + case Type::DeducedTemplateSpecialization: case Type::ObjCObject: case Type::ObjCInterface: case Type::ObjCObjectPointer: diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index 41c057719b6..4c1beaab10b 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -1870,6 +1870,7 @@ bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(QualType Ty, case Type::Paren: case Type::Attributed: case Type::Auto: + case Type::DeducedTemplateSpecialization: case Type::PackExpansion: case Type::ObjCObject: case Type::ObjCInterface: @@ -3145,6 +3146,16 @@ void CXXNameMangler::mangleType(const AutoType *T) { mangleType(D); } +void CXXNameMangler::mangleType(const DeducedTemplateSpecializationType *T) { + // FIXME: This is not the right mangling. We also need to include a scope + // here in some cases. + QualType D = T->getDeducedType(); + if (D.isNull()) + mangleUnscopedTemplateName(T->getTemplateName(), nullptr); + else + mangleType(D); +} + void CXXNameMangler::mangleType(const AtomicType *T) { // <type> ::= U <source-name> <type> # vendor extended type qualifier // (Until there's a standardized mangling...) diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp index abe94786a35..a76d186747e 100644 --- a/clang/lib/AST/MicrosoftMangle.cpp +++ b/clang/lib/AST/MicrosoftMangle.cpp @@ -2474,6 +2474,17 @@ void MicrosoftCXXNameMangler::mangleType(const AutoType *T, Qualifiers, << Range; } +void MicrosoftCXXNameMangler::mangleType( + const DeducedTemplateSpecializationType *T, Qualifiers, SourceRange Range) { + assert(T->getDeducedType().isNull() && "expecting a dependent type!"); + + DiagnosticsEngine &Diags = Context.getDiags(); + unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error, + "cannot mangle this deduced class template specialization type yet"); + Diags.Report(Range.getBegin(), DiagID) + << Range; +} + void MicrosoftCXXNameMangler::mangleType(const AtomicType *T, Qualifiers, SourceRange Range) { QualType ValueType = T->getValueType(); diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index 8a93f7c5d1e..8f22a1b197a 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -1559,25 +1559,29 @@ TagDecl *Type::getAsTagDecl() const { } namespace { - class GetContainedAutoVisitor : - public TypeVisitor<GetContainedAutoVisitor, Type*> { + class GetContainedDeducedTypeVisitor : + public TypeVisitor<GetContainedDeducedTypeVisitor, Type*> { bool Syntactic; public: - GetContainedAutoVisitor(bool Syntactic = false) : Syntactic(Syntactic) {} + GetContainedDeducedTypeVisitor(bool Syntactic = false) + : Syntactic(Syntactic) {} - using TypeVisitor<GetContainedAutoVisitor, Type*>::Visit; + using TypeVisitor<GetContainedDeducedTypeVisitor, Type*>::Visit; Type *Visit(QualType T) { if (T.isNull()) return nullptr; return Visit(T.getTypePtr()); } - // The 'auto' type itself. - Type *VisitAutoType(const AutoType *AT) { - return const_cast<AutoType*>(AT); + // The deduced type itself. + Type *VisitDeducedType(const DeducedType *AT) { + return const_cast<DeducedType*>(AT); } // Only these types can contain the desired 'auto' type. + Type *VisitElaboratedType(const ElaboratedType *T) { + return Visit(T->getNamedType()); + } Type *VisitPointerType(const PointerType *T) { return Visit(T->getPointeeType()); } @@ -1620,13 +1624,14 @@ namespace { }; } -AutoType *Type::getContainedAutoType() const { - return cast_or_null<AutoType>(GetContainedAutoVisitor().Visit(this)); +DeducedType *Type::getContainedDeducedType() const { + return cast_or_null<DeducedType>( + GetContainedDeducedTypeVisitor().Visit(this)); } bool Type::hasAutoForTrailingReturnType() const { return dyn_cast_or_null<FunctionType>( - GetContainedAutoVisitor(true).Visit(this)); + GetContainedDeducedTypeVisitor(true).Visit(this)); } bool Type::hasIntegerRepresentation() const { @@ -3378,6 +3383,7 @@ static CachedProperties computeCachedProperties(const Type *T) { return CachedProperties(ExternalLinkage, false); case Type::Auto: + case Type::DeducedTemplateSpecialization: // Give non-deduced 'auto' types external linkage. We should only see them // here in error recovery. return CachedProperties(ExternalLinkage, false); @@ -3485,6 +3491,7 @@ static LinkageInfo computeLinkageInfo(const Type *T) { return LinkageInfo::external(); case Type::Auto: + case Type::DeducedTemplateSpecialization: return LinkageInfo::external(); case Type::Record: @@ -3621,7 +3628,8 @@ bool Type::canHaveNullability() const { // auto is considered dependent when it isn't deduced. case Type::Auto: - return !cast<AutoType>(type.getTypePtr())->isDeduced(); + case Type::DeducedTemplateSpecialization: + return !cast<DeducedType>(type.getTypePtr())->isDeduced(); case Type::Builtin: switch (cast<BuiltinType>(type.getTypePtr())->getKind()) { diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index cccc9087632..c4bc6a4ab54 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -189,6 +189,7 @@ bool TypePrinter::canPrefixQualifiers(const Type *T, case Type::Elaborated: case Type::TemplateTypeParm: case Type::SubstTemplateTypeParmPack: + case Type::DeducedTemplateSpecialization: case Type::TemplateSpecialization: case Type::InjectedClassName: case Type::DependentName: @@ -888,6 +889,24 @@ void TypePrinter::printAutoAfter(const AutoType *T, raw_ostream &OS) { printAfter(T->getDeducedType(), OS); } +void TypePrinter::printDeducedTemplateSpecializationBefore( + const DeducedTemplateSpecializationType *T, raw_ostream &OS) { + // If the type has been deduced, print the deduced type. + if (!T->getDeducedType().isNull()) { + printBefore(T->getDeducedType(), OS); + } else { + IncludeStrongLifetimeRAII Strong(Policy); + T->getTemplateName().print(OS, Policy); + spaceBeforePlaceHolder(OS); + } +} +void TypePrinter::printDeducedTemplateSpecializationAfter( + const DeducedTemplateSpecializationType *T, raw_ostream &OS) { + // If the type has been deduced, print the deduced type. + if (!T->getDeducedType().isNull()) + printAfter(T->getDeducedType(), OS); +} + void TypePrinter::printAtomicBefore(const AtomicType *T, raw_ostream &OS) { IncludeStrongLifetimeRAII Strong(Policy); diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index c3dd53f12e2..c177a241626 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2618,6 +2618,7 @@ llvm::DIType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile *Unit) { case Type::Attributed: case Type::Adjusted: case Type::Decayed: + case Type::DeducedTemplateSpecialization: case Type::Elaborated: case Type::Paren: case Type::SubstTemplateTypeParm: diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 798d5b48fa7..00bde1c5b28 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -200,7 +200,8 @@ TypeEvaluationKind CodeGenFunction::getEvaluationKind(QualType type) { llvm_unreachable("non-canonical or dependent type in IR-generation"); case Type::Auto: - llvm_unreachable("undeduced auto type in IR-generation"); + case Type::DeducedTemplateSpecialization: + llvm_unreachable("undeduced type in IR-generation"); // Various scalar types. case Type::Builtin: @@ -1899,6 +1900,7 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) { case Type::Typedef: case Type::Decltype: case Type::Auto: + case Type::DeducedTemplateSpecialization: // Stop walking: nothing to do. return; diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index b95b4fff573..d2baeb4ea1f 100644 --- a/clang/lib/CodeGen/CodeGenTypes.cpp +++ b/clang/lib/CodeGen/CodeGenTypes.cpp @@ -487,7 +487,8 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) { break; } case Type::Auto: - llvm_unreachable("Unexpected undeduced auto type!"); + case Type::DeducedTemplateSpecialization: + llvm_unreachable("Unexpected undeduced type!"); case Type::Complex: { llvm::Type *EltTy = ConvertType(cast<ComplexType>(Ty)->getElementType()); ResultType = llvm::StructType::get(EltTy, EltTy, nullptr); diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 490fadbd1c4..74aabeb253f 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -2815,7 +2815,8 @@ void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) { llvm_unreachable("References shouldn't get here"); case Type::Auto: - llvm_unreachable("Undeduced auto type shouldn't get here"); + case Type::DeducedTemplateSpecialization: + llvm_unreachable("Undeduced type shouldn't get here"); case Type::Pipe: llvm_unreachable("Pipe types shouldn't get here"); @@ -3045,7 +3046,8 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(QualType Ty, bool Force, llvm_unreachable("References shouldn't get here"); case Type::Auto: - llvm_unreachable("Undeduced auto type shouldn't get here"); + case Type::DeducedTemplateSpecialization: + llvm_unreachable("Undeduced type shouldn't get here"); case Type::Pipe: llvm_unreachable("Pipe type shouldn't get here"); diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 255f27dbfb2..6da61c689eb 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -2884,7 +2884,8 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, Actions.getTypeName(*Next.getIdentifierInfo(), Next.getLocation(), getCurScope(), &SS, false, false, nullptr, /*IsCtorOrDtorName=*/false, - /*NonTrivialSourceInfo=*/true); + /*WantNonTrivialSourceInfo=*/true, + isClassTemplateDeductionContext(DSContext)); // If the referenced identifier is not a type, then this declspec is // erroneous: We already checked about that it has no type specifier, and @@ -2998,9 +2999,10 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, continue; } - ParsedType TypeRep = - Actions.getTypeName(*Tok.getIdentifierInfo(), - Tok.getLocation(), getCurScope()); + ParsedType TypeRep = Actions.getTypeName( + *Tok.getIdentifierInfo(), Tok.getLocation(), getCurScope(), nullptr, + false, false, nullptr, false, false, + isClassTemplateDeductionContext(DSContext)); // If this is not a typedef name, don't parse it as part of the declspec, // it must be an implicit int or an error. diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index 3f1fe7e06fe..ca5a251b356 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -1144,10 +1144,11 @@ TypeResult Parser::ParseBaseTypeSpecifier(SourceLocation &BaseLoc, // We have an identifier; check whether it is actually a type. IdentifierInfo *CorrectedII = nullptr; - ParsedType Type = - Actions.getTypeName(*Id, IdLoc, getCurScope(), &SS, true, false, nullptr, - /*IsCtorOrDtorName=*/false, - /*NonTrivialTypeSourceInfo=*/true, &CorrectedII); + ParsedType Type = Actions.getTypeName( + *Id, IdLoc, getCurScope(), &SS, true, false, nullptr, + /*IsCtorOrDtorName=*/false, + /*NonTrivialTypeSourceInfo=*/true, + /*IsClassTemplateDeductionContext*/ false, &CorrectedII); if (!Type) { Diag(IdLoc, diag::err_expected_class_name); return true; diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index 383986470d5..cfda2cddec8 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -1639,9 +1639,10 @@ ExprResult Parser::ParseCXXThis() { /// typename-specifier '(' expression-list[opt] ')' /// [C++0x] typename-specifier braced-init-list /// +/// In C++1z onwards, the type specifier can also be a template-name. ExprResult Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) { - Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); + Declarator DeclaratorInfo(DS, Declarator::FunctionalCastContext); ParsedType TypeRep = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo).get(); assert((Tok.is(tok::l_paren) || diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 2f8ee0c068d..8713bb2c23f 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -1743,7 +1743,8 @@ bool Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(CXXScopeSpec &SS, *Tok.getIdentifierInfo(), Tok.getLocation(), getCurScope(), &SS, false, NextToken().is(tok::period), nullptr, /*IsCtorOrDtorName=*/false, - /*NonTrivialTypeSourceInfo*/ true)) { + /*NonTrivialTypeSourceInfo*/ true, + /*IsClassTemplateDeductionContext*/GreaterThanIsOperator)) { SourceLocation BeginLoc = Tok.getLocation(); if (SS.isNotEmpty()) // it was a C++ qualified type name. BeginLoc = SS.getBeginLoc(); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index c9cf86f43c4..3ed6ede53cf 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -60,6 +60,11 @@ Sema::DeclGroupPtrTy Sema::ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType) { return DeclGroupPtrTy::make(DeclGroupRef(Ptr)); } +static bool isTypeTemplate(NamedDecl *ND) { + return isa<ClassTemplateDecl>(ND) || isa<TypeAliasTemplateDecl>(ND) || + isa<TemplateTemplateParmDecl>(ND); +} + namespace { class TypeNameValidatorCCC : public CorrectionCandidateCallback { @@ -67,7 +72,7 @@ class TypeNameValidatorCCC : public CorrectionCandidateCallback { TypeNameValidatorCCC(bool AllowInvalid, bool WantClass=false, bool AllowTemplates=false) : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass), - AllowClassTemplates(AllowTemplates) { + AllowTemplates(AllowTemplates) { WantExpressionKeywords = false; WantCXXNamedCasts = false; WantRemainingKeywords = false; @@ -76,7 +81,7 @@ class TypeNameValidatorCCC : public CorrectionCandidateCallback { bool ValidateCandidate(const TypoCorrection &candidate) override { if (NamedDecl *ND = candidate.getCorrectionDecl()) { bool IsType = isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND); - bool AllowedTemplate = AllowClassTemplates && isa<ClassTemplateDecl>(ND); + bool AllowedTemplate = AllowTemplates && isTypeTemplate(ND); return (IsType || AllowedTemplate) && (AllowInvalidDecl || !ND->isInvalidDecl()); } @@ -86,7 +91,7 @@ class TypeNameValidatorCCC : public CorrectionCandidateCallback { private: bool AllowInvalidDecl; bool WantClassName; - bool AllowClassTemplates; + bool AllowTemplates; }; } // end anonymous namespace @@ -252,7 +257,13 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, ParsedType ObjectTypePtr, bool IsCtorOrDtorName, bool WantNontrivialTypeSourceInfo, + bool IsClassTemplateDeductionContext, IdentifierInfo **CorrectedII) { + // FIXME: Consider allowing this outside C++1z mode as an extension. + bool AllowDeducedTemplate = IsClassTemplateDeductionContext && + getLangOpts().CPlusPlus1z && !IsCtorOrDtorName && + !isClassName && !HasTrailingDot; + // Determine where we will perform name lookup. DeclContext *LookupCtx = nullptr; if (ObjectTypePtr) { @@ -334,10 +345,11 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, case LookupResult::NotFound: case LookupResult::NotFoundInCurrentInstantiation: if (CorrectedII) { - TypoCorrection Correction = CorrectTypo( - Result.getLookupNameInfo(), Kind, S, SS, - llvm::make_unique<TypeNameValidatorCCC>(true, isClassName), - CTK_ErrorRecovery); + TypoCorrection Correction = + CorrectTypo(Result.getLookupNameInfo(), Kind, S, SS, + llvm::make_unique<TypeNameValidatorCCC>( + true, isClassName, AllowDeducedTemplate), + CTK_ErrorRecovery); IdentifierInfo *NewII = Correction.getCorrectionAsIdentifierInfo(); TemplateTy Template; bool MemberOfUnknownSpecialization; @@ -359,7 +371,8 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, ParsedType Ty = getTypeName(*NewII, NameLoc, S, NewSSPtr, isClassName, HasTrailingDot, ObjectTypePtr, IsCtorOrDtorName, - WantNontrivialTypeSourceInfo); + WantNontrivialTypeSourceInfo, + IsClassTemplateDeductionContext); if (Ty) { diagnoseTypo(Correction, PDiag(diag::err_unknown_type_or_class_name_suggest) @@ -391,7 +404,8 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, // Look to see if we have a type anywhere in the list of results. for (LookupResult::iterator Res = Result.begin(), ResEnd = Result.end(); Res != ResEnd; ++Res) { - if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res)) { + if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res) || + (AllowDeducedTemplate && isTypeTemplate(*Res))) { if (!IIDecl || (*Res)->getLocation().getRawEncoding() < IIDecl->getLocation().getRawEncoding()) @@ -440,29 +454,13 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, T = Context.getTypeDeclType(TD); MarkAnyDeclReferenced(TD->getLocation(), TD, /*OdrUse=*/false); - - // NOTE: avoid constructing an ElaboratedType(Loc) if this is a - // constructor or destructor name (in such a case, the scope specifier - // will be attached to the enclosing Expr or Decl node). - if (SS && SS->isNotEmpty() && !IsCtorOrDtorName) { - if (WantNontrivialTypeSourceInfo) { - // Construct a type with type-source information. - TypeLocBuilder Builder; - Builder.pushTypeSpec(T).setNameLoc(NameLoc); - - T = getElaboratedType(ETK_None, *SS, T); - ElaboratedTypeLoc ElabTL = Builder.push<ElaboratedTypeLoc>(T); - ElabTL.setElaboratedKeywordLoc(SourceLocation()); - ElabTL.setQualifierLoc(SS->getWithLocInContext(Context)); - return CreateParsedType(T, Builder.getTypeSourceInfo(Context, T)); - } else { - T = getElaboratedType(ETK_None, *SS, T); - } - } } else if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(IIDecl)) { (void)DiagnoseUseOfDecl(IDecl, NameLoc); if (!HasTrailingDot) T = Context.getObjCInterfaceType(IDecl); + } else if (AllowDeducedTemplate && isTypeTemplate(IIDecl)) { + T = Context.getDeducedTemplateSpecializationType( + TemplateName(cast<TemplateDecl>(IIDecl)), QualType(), false); } if (T.isNull()) { @@ -470,6 +468,27 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Result.suppressDiagnostics(); return nullptr; } + + // NOTE: avoid constructing an ElaboratedType(Loc) if this is a + // constructor or destructor name (in such a case, the scope specifier + // will be attached to the enclosing Expr or Decl node). + if (SS && SS->isNotEmpty() && !IsCtorOrDtorName && + !isa<ObjCInterfaceDecl>(IIDecl)) { + if (WantNontrivialTypeSourceInfo) { + // Construct a type with type-source information. + TypeLocBuilder Builder; + Builder.pushTypeSpec(T).setNameLoc(NameLoc); + + T = getElaboratedType(ETK_None, *SS, T); + ElaboratedTypeLoc ElabTL = Builder.push<ElaboratedTypeLoc>(T); + ElabTL.setElaboratedKeywordLoc(SourceLocation()); + ElabTL.setQualifierLoc(SS->getWithLocInContext(Context)); + return CreateParsedType(T, Builder.getTypeSourceInfo(Context, T)); + } else { + T = getElaboratedType(ETK_None, *SS, T); + } + } + return ParsedType::make(T); } @@ -647,6 +666,7 @@ void Sema::DiagnoseUnknownTypeName(IdentifierInfo *&II, if (Corrected.getCorrectionSpecifier()) tmpSS.MakeTrivial(Context, Corrected.getCorrectionSpecifier(), SourceRange(IILoc)); + // FIXME: Support class template argument deduction here. SuggestedType = getTypeName(*Corrected.getCorrectionAsIdentifierInfo(), IILoc, S, tmpSS.isSet() ? &tmpSS : SS, false, false, nullptr, @@ -9740,6 +9760,14 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl, VarDeclOrName VN{VDecl, Name}; + DeducedType *Deduced = Type->getContainedDeducedType(); + assert(Deduced && "deduceVarTypeFromInitializer for non-deduced type"); + + if (isa<DeducedTemplateSpecializationType>(Deduced)) { + Diag(Init->getLocStart(), diag::err_deduced_class_template_not_supported); + return QualType(); + } + ArrayRef<Expr *> DeduceInits = Init; if (DirectInit) { if (auto *PL = dyn_cast<ParenListExpr>(Init)) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index be97e27ae6d..43242390597 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3976,7 +3976,8 @@ static void captureVariablyModifiedType(ASTContext &Context, QualType T, T = cast<DecltypeType>(Ty)->desugar(); break; case Type::Auto: - T = cast<AutoType>(Ty)->getDeducedType(); + case Type::DeducedTemplateSpecialization: + T = cast<DeducedType>(Ty)->getDeducedType(); break; case Type::TypeOfExpr: T = cast<TypeOfExprType>(Ty)->getUnderlyingExpr()->getType(); diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 2bf1c739395..f4df3caf72a 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1255,9 +1255,19 @@ Sema::BuildCXXTypeConstructExpr(TypeSourceInfo *TInfo, RParenLoc); } + // C++1z [expr.type.conv]p1: + // If the type is a placeholder for a deduced class type, [...perform class + // template argument deduction...] + DeducedType *Deduced = Ty->getContainedDeducedType(); + if (Deduced && isa<DeducedTemplateSpecializationType>(Deduced)) { + Diag(TyBeginLoc, diag::err_deduced_class_template_not_supported); + return ExprError(); + } + bool ListInitialization = LParenLoc.isInvalid(); - assert((!ListInitialization || (Exprs.size() == 1 && isa<InitListExpr>(Exprs[0]))) - && "List initialization must have initializer list as expression."); + assert((!ListInitialization || + (Exprs.size() == 1 && isa<InitListExpr>(Exprs[0]))) && + "List initialization must have initializer list as expression."); SourceRange FullRange = SourceRange(TyBeginLoc, ListInitialization ? Exprs[0]->getSourceRange().getEnd() : RParenLoc); @@ -1646,6 +1656,11 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal, // C++11 [dcl.spec.auto]p6. Deduce the type which 'auto' stands in for. if (AllocType->isUndeducedType()) { + if (isa<DeducedTemplateSpecializationType>( + AllocType->getContainedDeducedType())) + return ExprError(Diag(TypeRange.getBegin(), + diag::err_deduced_class_template_not_supported)); + if (initStyle == CXXNewExpr::NoInit || NumInits == 0) return ExprError(Diag(StartLoc, diag::err_auto_new_requires_ctor_arg) << AllocType << TypeRange); diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 2b35a3583e8..84dc7799b2d 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -2694,6 +2694,7 @@ addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType Ty) { // Non-deduced auto types only get here for error cases. case Type::Auto: + case Type::DeducedTemplateSpecialization: break; // If T is an Objective-C object or interface type, or a pointer to an diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 87764c36406..6a530095234 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -4439,6 +4439,11 @@ bool UnnamedLocalNoLinkageFinder::VisitAutoType(const AutoType *T) { return Visit(T->getDeducedType()); } +bool UnnamedLocalNoLinkageFinder::VisitDeducedTemplateSpecializationType( + const DeducedTemplateSpecializationType *T) { + return Visit(T->getDeducedType()); +} + bool UnnamedLocalNoLinkageFinder::VisitRecordType(const RecordType* T) { return VisitTagDecl(T->getDecl()); } @@ -8786,6 +8791,9 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword, Context.getTypeDeclType(Type)); } + // FIXME: Form a deduced template specialization type if we get a template + // declaration here. + DiagID = diag::err_typename_nested_not_type; Referenced = Result.getFoundDecl(); break; diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 3197647d8d8..688d6bb8e68 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -1723,6 +1723,7 @@ DeduceTemplateArgumentsByTypeMatch(Sema &S, case Type::Decltype: case Type::UnaryTransform: case Type::Auto: + case Type::DeducedTemplateSpecialization: case Type::DependentTemplateSpecialization: case Type::PackExpansion: case Type::Pipe: @@ -5152,8 +5153,9 @@ MarkUsedTemplateParameters(ASTContext &Ctx, QualType T, break; case Type::Auto: + case Type::DeducedTemplateSpecialization: MarkUsedTemplateParameters(Ctx, - cast<AutoType>(T)->getDeducedType(), + cast<DeducedType>(T)->getDeducedType(), OnlyDeduced, Depth, Used); // None of these types have any template parameters in them. diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 29b21426790..e4995bd2206 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -2778,12 +2778,20 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, distributeTypeAttrsFromDeclarator(state, T); // C++11 [dcl.spec.auto]p5: reject 'auto' if it is not in an allowed context. - if (D.getDeclSpec().containsPlaceholderType()) { + if (DeducedType *Deduced = T->getContainedDeducedType()) { + AutoType *Auto = dyn_cast<AutoType>(Deduced); int Error = -1; + // Is this a 'auto' or 'decltype(auto)' type (as opposed to __auto_type or + // class template argument deduction)? + bool IsCXXAutoType = + (Auto && Auto->getKeyword() != AutoTypeKeyword::GNUAutoType); + switch (D.getContext()) { case Declarator::LambdaExprContext: - llvm_unreachable("Can't specify a type specifier in lambda grammar"); + // Declared return type of a lambda-declarator is implicit and is always + // 'auto'. + break; case Declarator::ObjCParameterContext: case Declarator::ObjCResultContext: case Declarator::PrototypeContext: @@ -2791,8 +2799,8 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, break; case Declarator::LambdaExprParameterContext: // In C++14, generic lambdas allow 'auto' in their parameters. - if (!(SemaRef.getLangOpts().CPlusPlus14 - && D.getDeclSpec().getTypeSpecType() == DeclSpec::TST_auto)) + if (!SemaRef.getLangOpts().CPlusPlus14 || + !Auto || Auto->getKeyword() != AutoTypeKeyword::Auto) Error = 16; break; case Declarator::MemberContext: { @@ -2807,6 +2815,8 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, case TTK_Class: Error = 5; /* Class member */ break; case TTK_Interface: Error = 6; /* Interface member */ break; } + if (D.getDeclSpec().isFriendSpecified()) + Error = 20; // Friend type break; } case Declarator::CXXCatchContext: @@ -2814,8 +2824,10 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, Error = 7; // Exception declaration break; case Declarator::TemplateParamContext: - if (!SemaRef.getLangOpts().CPlusPlus1z) - Error = 8; // Template parameter + if (isa<DeducedTemplateSpecializationType>(Deduced)) + Error = 19; // Template parameter + else if (!SemaRef.getLangOpts().CPlusPlus1z) + Error = 8; // Template parameter (until C++1z) break; case Declarator::BlockLiteralContext: Error = 9; // Block literal @@ -2828,15 +2840,17 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, Error = 12; // Type alias break; case Declarator::TrailingReturnContext: - if (!SemaRef.getLangOpts().CPlusPlus14 || - D.getDeclSpec().getTypeSpecType() == DeclSpec::TST_auto_type) + if (!SemaRef.getLangOpts().CPlusPlus14 || !IsCXXAutoType) Error = 13; // Function return type break; case Declarator::ConversionIdContext: - if (!SemaRef.getLangOpts().CPlusPlus14 || - D.getDeclSpec().getTypeSpecType() == DeclSpec::TST_auto_type) + if (!SemaRef.getLangOpts().CPlusPlus14 || !IsCXXAutoType) Error = 14; // conversion-type-id break; + case Declarator::FunctionalCastContext: + if (isa<DeducedTemplateSpecializationType>(Deduced)) + break; + LLVM_FALLTHROUGH; case Declarator::TypeNameContext: Error = 15; // Generic break; @@ -2845,9 +2859,14 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, case Declarator::ForContext: case Declarator::InitStmtContext: case Declarator::ConditionContext: + // FIXME: P0091R3 (erroneously) does not permit class template argument + // deduction in conditions, for-init-statements, and other declarations + // that are not simple-declarations. break; case Declarator::CXXNewContext: - if (D.getDeclSpec().getTypeSpecType() == DeclSpec::TST_auto_type) + // FIXME: P0091R3 does not permit class template argument deduction here, + // but we follow GCC and allow it anyway. + if (!IsCXXAutoType && !isa<DeducedTemplateSpecializationType>(Deduced)) Error = 17; // 'new' type break; case Declarator::KNRTypeListContext: @@ -2861,8 +2880,7 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, // In Objective-C it is an error to use 'auto' on a function declarator // (and everywhere for '__auto_type'). if (D.isFunctionDeclarator() && - (!SemaRef.getLangOpts().CPlusPlus11 || - D.getDeclSpec().getTypeSpecType() == DeclSpec::TST_auto_type)) + (!SemaRef.getLangOpts().CPlusPlus11 || !IsCXXAutoType)) Error = 13; bool HaveTrailing = false; @@ -2872,8 +2890,8 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, // level. Check all declarator chunks (outermost first) anyway, to give // better diagnostics. // We don't support '__auto_type' with trailing return types. - if (SemaRef.getLangOpts().CPlusPlus11 && - D.getDeclSpec().getTypeSpecType() != DeclSpec::TST_auto_type) { + // FIXME: Should we only do this for 'auto' and not 'decltype(auto)'? + if (SemaRef.getLangOpts().CPlusPlus11 && IsCXXAutoType) { for (unsigned i = 0, e = D.getNumTypeObjects(); i != e; ++i) { unsigned chunkIndex = e - i - 1; state.setCurrentChunkIndex(chunkIndex); @@ -2894,15 +2912,28 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, AutoRange = D.getName().getSourceRange(); if (Error != -1) { - unsigned Keyword; - switch (D.getDeclSpec().getTypeSpecType()) { - case DeclSpec::TST_auto: Keyword = 0; break; - case DeclSpec::TST_decltype_auto: Keyword = 1; break; - case DeclSpec::TST_auto_type: Keyword = 2; break; - default: llvm_unreachable("unknown auto TypeSpecType"); + unsigned Kind; + if (Auto) { + switch (Auto->getKeyword()) { + case AutoTypeKeyword::Auto: Kind = 0; break; + case AutoTypeKeyword::DecltypeAuto: Kind = 1; break; + case AutoTypeKeyword::GNUAutoType: Kind = 2; break; + } + } else { + assert(isa<DeducedTemplateSpecializationType>(Deduced) && + "unknown auto type"); + Kind = 3; } + + auto *DTST = dyn_cast<DeducedTemplateSpecializationType>(Deduced); + TemplateName TN = DTST ? DTST->getTemplateName() : TemplateName(); + SemaRef.Diag(AutoRange.getBegin(), diag::err_auto_not_allowed) - << Keyword << Error << AutoRange; + << Kind << Error << (int)SemaRef.getTemplateNameKindForDiagnostics(TN) + << QualType(Deduced, 0) << AutoRange; + if (auto *TD = TN.getAsTemplateDecl()) + SemaRef.Diag(TD->getLocation(), diag::note_template_decl_here); + T = SemaRef.Context.IntTy; D.setInvalidType(true); } else if (!HaveTrailing) { @@ -2942,6 +2973,7 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state, DiagID = diag::err_type_defined_in_alias_template; break; case Declarator::TypeNameContext: + case Declarator::FunctionalCastContext: case Declarator::ConversionIdContext: case Declarator::TemplateParamContext: case Declarator::CXXNewContext: @@ -3623,17 +3655,32 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // If T is 'decltype(auto)', the only declarators we can have are parens // and at most one function declarator if this is a function declaration. - if (const AutoType *AT = T->getAs<AutoType>()) { - if (AT->isDecltypeAuto()) { + // If T is a deduced class template specialization type, we can have no + // declarator chunks at all. + if (auto *DT = T->getAs<DeducedType>()) { + const AutoType *AT = T->getAs<AutoType>(); + bool IsClassTemplateDeduction = isa<DeducedTemplateSpecializationType>(DT); + if ((AT && AT->isDecltypeAuto()) || IsClassTemplateDeduction) { for (unsigned I = 0, E = D.getNumTypeObjects(); I != E; ++I) { unsigned Index = E - I - 1; DeclaratorChunk &DeclChunk = D.getTypeObject(Index); - unsigned DiagId = diag::err_decltype_auto_compound_type; + unsigned DiagId = IsClassTemplateDeduction + ? diag::err_deduced_class_template_compound_type + : diag::err_decltype_auto_compound_type; unsigned DiagKind = 0; switch (DeclChunk.Kind) { case DeclaratorChunk::Paren: + // FIXME: Rejecting this is a little silly. + if (IsClassTemplateDeduction) { + DiagKind = 4; + break; + } continue; case DeclaratorChunk::Function: { + if (IsClassTemplateDeduction) { + DiagKind = 3; + break; + } unsigned FnIndex; if (D.isFunctionDeclarationContext() && D.isFunctionDeclarator(FnIndex) && FnIndex == Index) @@ -3834,6 +3881,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, case Declarator::TemplateParamContext: case Declarator::TemplateTypeArgContext: case Declarator::TypeNameContext: + case Declarator::FunctionalCastContext: // Don't infer in these contexts. break; } @@ -4713,6 +4761,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, case Declarator::ObjCParameterContext: // FIXME: special diagnostic here? case Declarator::ObjCResultContext: // FIXME: special diagnostic here? case Declarator::TypeNameContext: + case Declarator::FunctionalCastContext: case Declarator::CXXNewContext: case Declarator::AliasDeclContext: case Declarator::AliasTemplateContext: diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index 30d1b5b765f..d27cd770400 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -876,6 +876,14 @@ public: /*IsDependent*/ false); } + /// By default, builds a new DeducedTemplateSpecializationType with the given + /// deduced type. + QualType RebuildDeducedTemplateSpecializationType(TemplateName Template, + QualType Deduced) { + return SemaRef.Context.getDeducedTemplateSpecializationType( + Template, Deduced, /*IsDependent*/ false); + } + /// \brief Build a new template specialization type. /// /// By default, performs semantic analysis when building the template @@ -5346,6 +5354,37 @@ QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB, } template<typename Derived> +QualType TreeTransform<Derived>::TransformDeducedTemplateSpecializationType( + TypeLocBuilder &TLB, DeducedTemplateSpecializationTypeLoc TL) { + const DeducedTemplateSpecializationType *T = TL.getTypePtr(); + + CXXScopeSpec SS; + TemplateName TemplateName = getDerived().TransformTemplateName( + SS, T->getTemplateName(), TL.getTemplateNameLoc()); + if (TemplateName.isNull()) + return QualType(); + + QualType OldDeduced = T->getDeducedType(); + QualType NewDeduced; + if (!OldDeduced.isNull()) { + NewDeduced = getDerived().TransformType(OldDeduced); + if (NewDeduced.isNull()) + return QualType(); + } + + QualType Result = getDerived().RebuildDeducedTemplateSpecializationType( + TemplateName, NewDeduced); + if (Result.isNull()) + return QualType(); + + DeducedTemplateSpecializationTypeLoc NewTL = + TLB.push<DeducedTemplateSpecializationTypeLoc>(Result); + NewTL.setTemplateNameLoc(TL.getTemplateNameLoc()); + + return Result; +} + +template<typename Derived> QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB, RecordTypeLoc TL) { const RecordType *T = TL.getTypePtr(); diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index 25a9b1081c2..89d67df6e6f 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -5651,6 +5651,14 @@ QualType ASTReader::readTypeRecord(unsigned Index) { return Context.getAutoType(Deduced, Keyword, IsDependent); } + case TYPE_DEDUCED_TEMPLATE_SPECIALIZATION: { + TemplateName Name = ReadTemplateName(*Loc.F, Record, Idx); + QualType Deduced = readType(*Loc.F, Record, Idx); + bool IsDependent = Deduced.isNull() ? Record[Idx++] : false; + return Context.getDeducedTemplateSpecializationType(Name, Deduced, + IsDependent); + } + case TYPE_RECORD: { if (Record.size() != 2) { Error("incorrect encoding of record type"); @@ -6082,6 +6090,11 @@ void TypeLocReader::VisitAutoTypeLoc(AutoTypeLoc TL) { TL.setNameLoc(ReadSourceLocation()); } +void TypeLocReader::VisitDeducedTemplateSpecializationTypeLoc( + DeducedTemplateSpecializationTypeLoc TL) { + TL.setTemplateNameLoc(ReadSourceLocation()); +} + void TypeLocReader::VisitRecordTypeLoc(RecordTypeLoc TL) { TL.setNameLoc(ReadSourceLocation()); } diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index b2237a5fc19..9ba9d6ca709 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -349,6 +349,15 @@ void ASTTypeWriter::VisitAutoType(const AutoType *T) { Code = TYPE_AUTO; } +void ASTTypeWriter::VisitDeducedTemplateSpecializationType( + const DeducedTemplateSpecializationType *T) { + Record.AddTemplateName(T->getTemplateName()); + Record.AddTypeRef(T->getDeducedType()); + if (T->getDeducedType().isNull()) + Record.push_back(T->isDependentType()); + Code = TYPE_DEDUCED_TEMPLATE_SPECIALIZATION; +} + void ASTTypeWriter::VisitTagType(const TagType *T) { Record.push_back(T->isDependentType()); Record.AddDeclRef(T->getDecl()->getCanonicalDecl()); @@ -683,6 +692,11 @@ void TypeLocWriter::VisitAutoTypeLoc(AutoTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } +void TypeLocWriter::VisitDeducedTemplateSpecializationTypeLoc( + DeducedTemplateSpecializationTypeLoc TL) { + Record.AddSourceLocation(TL.getTemplateNameLoc()); +} + void TypeLocWriter::VisitRecordTypeLoc(RecordTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } |