diff options
36 files changed, 833 insertions, 536 deletions
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 0029f183a7..591640d30c 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -746,9 +746,9 @@ public: /// Specifies when this declaration reference expression has a record of /// a NamedDecl (different from the referenced ValueDecl) which was found /// during name lookup and/or overload resolution. -/// DeclRefExprBits.HasExplicitTemplateArgs: +/// DeclRefExprBits.HasTemplateKWAndArgsInfo: /// Specifies when this declaration reference expression has an explicit -/// C++ template argument list. +/// C++ template keyword and/or template argument list. class DeclRefExpr : public Expr { /// \brief The declaration that we are referencing. ValueDecl *D; @@ -791,6 +791,7 @@ class DeclRefExpr : public Expr { } DeclRefExpr(NestedNameSpecifierLoc QualifierLoc, + SourceLocation TemplateKWLoc, ValueDecl *D, const DeclarationNameInfo &NameInfo, NamedDecl *FoundD, const TemplateArgumentListInfo *TemplateArgs, @@ -810,7 +811,7 @@ public: : Expr(DeclRefExprClass, T, VK, OK_Ordinary, false, false, false, false), D(D), Loc(L), DNLoc(LocInfo) { DeclRefExprBits.HasQualifier = 0; - DeclRefExprBits.HasExplicitTemplateArgs = 0; + DeclRefExprBits.HasTemplateKWAndArgsInfo = 0; DeclRefExprBits.HasFoundDecl = 0; DeclRefExprBits.HadMultipleCandidates = 0; computeDependence(); @@ -818,6 +819,7 @@ public: static DeclRefExpr *Create(ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, + SourceLocation TemplateKWLoc, ValueDecl *D, SourceLocation NameLoc, QualType T, ExprValueKind VK, @@ -826,6 +828,7 @@ public: static DeclRefExpr *Create(ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, + SourceLocation TemplateKWLoc, ValueDecl *D, const DeclarationNameInfo &NameInfo, QualType T, ExprValueKind VK, @@ -836,7 +839,7 @@ public: static DeclRefExpr *CreateEmpty(ASTContext &Context, bool HasQualifier, bool HasFoundDecl, - bool HasExplicitTemplateArgs, + bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs); ValueDecl *getDecl() { return D; } @@ -888,25 +891,65 @@ public: return hasFoundDecl() ? getInternalFoundDecl() : D; } - /// \brief Determines whether this declaration reference was followed by an - /// explict template argument list. - bool hasExplicitTemplateArgs() const { - return DeclRefExprBits.HasExplicitTemplateArgs; + bool hasTemplateKWAndArgsInfo() const { + return DeclRefExprBits.HasTemplateKWAndArgsInfo; } - /// \brief Retrieve the explicit template argument list that followed the - /// member template name. - ASTTemplateArgumentListInfo &getExplicitTemplateArgs() { - assert(hasExplicitTemplateArgs()); + /// \brief Return the optional template keyword and arguments info. + ASTTemplateKWAndArgsInfo *getTemplateKWAndArgsInfo() { + if (!hasTemplateKWAndArgsInfo()) + return 0; + if (hasFoundDecl()) - return *reinterpret_cast<ASTTemplateArgumentListInfo *>( + return reinterpret_cast<ASTTemplateKWAndArgsInfo *>( &getInternalFoundDecl() + 1); if (hasQualifier()) - return *reinterpret_cast<ASTTemplateArgumentListInfo *>( + return reinterpret_cast<ASTTemplateKWAndArgsInfo *>( &getInternalQualifierLoc() + 1); - return *reinterpret_cast<ASTTemplateArgumentListInfo *>(this + 1); + return reinterpret_cast<ASTTemplateKWAndArgsInfo *>(this + 1); + } + + /// \brief Return the optional template keyword and arguments info. + const ASTTemplateKWAndArgsInfo *getTemplateKWAndArgsInfo() const { + return const_cast<DeclRefExpr*>(this)->getTemplateKWAndArgsInfo(); + } + + /// \brief Retrieve the location of the template keyword preceding + /// this name, if any. + SourceLocation getTemplateKeywordLoc() const { + if (!hasTemplateKWAndArgsInfo()) return SourceLocation(); + return getTemplateKWAndArgsInfo()->getTemplateKeywordLoc(); + } + + /// \brief Retrieve the location of the left angle bracket starting the + /// explicit template argument list following the name, if any. + SourceLocation getLAngleLoc() const { + if (!hasTemplateKWAndArgsInfo()) return SourceLocation(); + return getTemplateKWAndArgsInfo()->LAngleLoc; + } + + /// \brief Retrieve the location of the right angle bracket ending the + /// explicit template argument list following the name, if any. + SourceLocation getRAngleLoc() const { + if (!hasTemplateKWAndArgsInfo()) return SourceLocation(); + return getTemplateKWAndArgsInfo()->RAngleLoc; + } + + /// \brief Determines whether the name in this declaration reference + /// was preceded by the template keyword. + bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); } + + /// \brief Determines whether this declaration reference was followed by an + /// explicit template argument list. + bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); } + + /// \brief Retrieve the explicit template argument list that followed the + /// member template name. + ASTTemplateArgumentListInfo &getExplicitTemplateArgs() { + assert(hasExplicitTemplateArgs()); + return *getTemplateKWAndArgsInfo(); } /// \brief Retrieve the explicit template argument list that followed the @@ -918,7 +961,7 @@ public: /// \brief Retrieves the optional explicit template arguments. /// This points to the same data as getExplicitTemplateArgs(), but /// returns null if there are no explicit template arguments. - const ASTTemplateArgumentListInfo *getExplicitTemplateArgsOpt() const { + const ASTTemplateArgumentListInfo *getOptionalExplicitTemplateArgs() const { if (!hasExplicitTemplateArgs()) return 0; return &getExplicitTemplateArgs(); } @@ -930,15 +973,6 @@ public: getExplicitTemplateArgs().copyInto(List); } - /// \brief Retrieve the location of the left angle bracket following the - /// member name ('<'), if any. - SourceLocation getLAngleLoc() const { - if (!hasExplicitTemplateArgs()) - return SourceLocation(); - - return getExplicitTemplateArgs().LAngleLoc; - } - /// \brief Retrieve the template arguments provided as part of this /// template-id. const TemplateArgumentLoc *getTemplateArgs() const { @@ -957,15 +991,6 @@ public: return getExplicitTemplateArgs().NumTemplateArgs; } - /// \brief Retrieve the location of the right angle bracket following the - /// template arguments ('>'). - SourceLocation getRAngleLoc() const { - if (!hasExplicitTemplateArgs()) - return SourceLocation(); - - return getExplicitTemplateArgs().RAngleLoc; - } - /// \brief Returns true if this expression refers to a function that /// was resolved from an overloaded set having size greater than 1. bool hadMultipleCandidates() const { @@ -2139,12 +2164,14 @@ class MemberExpr : public Expr { /// structure is allocated immediately after the MemberExpr. bool HasQualifierOrFoundDecl : 1; - /// \brief True if this member expression specified a template argument list - /// explicitly, e.g., x->f<int>. When true, an ExplicitTemplateArgumentList - /// structure (and its TemplateArguments) are allocated immediately after - /// the MemberExpr or, if the member expression also has a qualifier, after - /// the MemberNameQualifier structure. - bool HasExplicitTemplateArgumentList : 1; + /// \brief True if this member expression specified a template keyword + /// and/or a template argument list explicitly, e.g., x->f<int>, + /// x->template f, x->template f<int>. + /// When true, an ASTTemplateKWAndArgsInfo structure and its + /// TemplateArguments (if any) are allocated immediately after + /// the MemberExpr or, if the member expression also has a qualifier, + /// after the MemberNameQualifier structure. + bool HasTemplateKWAndArgsInfo : 1; /// \brief True if this member expression refers to a method that /// was resolved from an overloaded set having size greater than 1. @@ -2172,7 +2199,7 @@ public: base->containsUnexpandedParameterPack()), Base(base), MemberDecl(memberdecl), MemberLoc(NameInfo.getLoc()), MemberDNLoc(NameInfo.getInfo()), IsArrow(isarrow), - HasQualifierOrFoundDecl(false), HasExplicitTemplateArgumentList(false), + HasQualifierOrFoundDecl(false), HasTemplateKWAndArgsInfo(false), HadMultipleCandidates(false) { assert(memberdecl->getDeclName() == NameInfo.getName()); } @@ -2180,7 +2207,7 @@ public: // NOTE: this constructor should be used only when it is known that // the member name can not provide additional syntactic info // (i.e., source locations for C++ operator names or type source info - // for constructors, destructors and conversion oeprators). + // for constructors, destructors and conversion operators). MemberExpr(Expr *base, bool isarrow, ValueDecl *memberdecl, SourceLocation l, QualType ty, ExprValueKind VK, ExprObjectKind OK) @@ -2190,11 +2217,12 @@ public: base->containsUnexpandedParameterPack()), Base(base), MemberDecl(memberdecl), MemberLoc(l), MemberDNLoc(), IsArrow(isarrow), - HasQualifierOrFoundDecl(false), HasExplicitTemplateArgumentList(false), + HasQualifierOrFoundDecl(false), HasTemplateKWAndArgsInfo(false), HadMultipleCandidates(false) {} static MemberExpr *Create(ASTContext &C, Expr *base, bool isarrow, NestedNameSpecifierLoc QualifierLoc, + SourceLocation TemplateKWLoc, ValueDecl *memberdecl, DeclAccessPair founddecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *targs, @@ -2243,12 +2271,51 @@ public: return getMemberQualifier()->QualifierLoc; } - /// \brief Determines whether this member expression actually had a C++ - /// template argument list explicitly specified, e.g., x.f<int>. - bool hasExplicitTemplateArgs() const { - return HasExplicitTemplateArgumentList; + /// \brief Return the optional template keyword and arguments info. + ASTTemplateKWAndArgsInfo *getTemplateKWAndArgsInfo() { + if (!HasTemplateKWAndArgsInfo) + return 0; + + if (!HasQualifierOrFoundDecl) + return reinterpret_cast<ASTTemplateKWAndArgsInfo *>(this + 1); + + return reinterpret_cast<ASTTemplateKWAndArgsInfo *>( + getMemberQualifier() + 1); + } + + /// \brief Return the optional template keyword and arguments info. + const ASTTemplateKWAndArgsInfo *getTemplateKWAndArgsInfo() const { + return const_cast<MemberExpr*>(this)->getTemplateKWAndArgsInfo(); + } + + /// \brief Retrieve the location of the template keyword preceding + /// the member name, if any. + SourceLocation getTemplateKeywordLoc() const { + if (!HasTemplateKWAndArgsInfo) return SourceLocation(); + return getTemplateKWAndArgsInfo()->getTemplateKeywordLoc(); + } + + /// \brief Retrieve the location of the left angle bracket starting the + /// explicit template argument list following the member name, if any. + SourceLocation getLAngleLoc() const { + if (!HasTemplateKWAndArgsInfo) return SourceLocation(); + return getTemplateKWAndArgsInfo()->LAngleLoc; + } + + /// \brief Retrieve the location of the right angle bracket ending the + /// explicit template argument list following the member name, if any. + SourceLocation getRAngleLoc() const { + if (!HasTemplateKWAndArgsInfo) return SourceLocation(); + return getTemplateKWAndArgsInfo()->RAngleLoc; } + /// Determines whether the member name was preceded by the template keyword. + bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); } + + /// \brief Determines whether the member name was followed by an + /// explicit template argument list. + bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); } + /// \brief Copies the template arguments (if present) into the given /// structure. void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { @@ -2260,12 +2327,8 @@ public: /// follow the member template name. This must only be called on an /// expression with explicit template arguments. ASTTemplateArgumentListInfo &getExplicitTemplateArgs() { - assert(HasExplicitTemplateArgumentList); - if (!HasQualifierOrFoundDecl) - return *reinterpret_cast<ASTTemplateArgumentListInfo *>(this + 1); - - return *reinterpret_cast<ASTTemplateArgumentListInfo *>( - getMemberQualifier() + 1); + assert(hasExplicitTemplateArgs()); + return *getTemplateKWAndArgsInfo(); } /// \brief Retrieve the explicit template argument list that @@ -2283,19 +2346,10 @@ public: return &getExplicitTemplateArgs(); } - /// \brief Retrieve the location of the left angle bracket following the - /// member name ('<'), if any. - SourceLocation getLAngleLoc() const { - if (!HasExplicitTemplateArgumentList) - return SourceLocation(); - - return getExplicitTemplateArgs().LAngleLoc; - } - /// \brief Retrieve the template arguments provided as part of this /// template-id. const TemplateArgumentLoc *getTemplateArgs() const { - if (!HasExplicitTemplateArgumentList) + if (!hasExplicitTemplateArgs()) return 0; return getExplicitTemplateArgs().getTemplateArgs(); @@ -2304,21 +2358,12 @@ public: /// \brief Retrieve the number of template arguments provided as part of this /// template-id. unsigned getNumTemplateArgs() const { - if (!HasExplicitTemplateArgumentList) + if (!hasExplicitTemplateArgs()) return 0; return getExplicitTemplateArgs().NumTemplateArgs; } - /// \brief Retrieve the location of the right angle bracket following the - /// template arguments ('>'). - SourceLocation getRAngleLoc() const { - if (!HasExplicitTemplateArgumentList) - return SourceLocation(); - - return getExplicitTemplateArgs().RAngleLoc; - } - /// \brief Retrieve the member declaration name info. DeclarationNameInfo getMemberNameInfo() const { return DeclarationNameInfo(MemberDecl->getDeclName(), diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 9d07e051ad..fcc417ad1d 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -1778,11 +1778,21 @@ class OverloadExpr : public Expr { NestedNameSpecifierLoc QualifierLoc; protected: - /// True if the name was a template-id. - bool HasExplicitTemplateArgs; + /// \brief Whether the name includes info for explicit template + /// keyword and arguments. + bool HasTemplateKWAndArgsInfo; + + /// \brief Return the optional template keyword and arguments info. + ASTTemplateKWAndArgsInfo *getTemplateKWAndArgsInfo(); // defined far below. + + /// \brief Return the optional template keyword and arguments info. + const ASTTemplateKWAndArgsInfo *getTemplateKWAndArgsInfo() const { + return const_cast<OverloadExpr*>(this)->getTemplateKWAndArgsInfo(); + } OverloadExpr(StmtClass K, ASTContext &C, NestedNameSpecifierLoc QualifierLoc, + SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End, @@ -1792,7 +1802,7 @@ protected: OverloadExpr(StmtClass K, EmptyShell Empty) : Expr(K, Empty), Results(0), NumResults(0), - QualifierLoc(), HasExplicitTemplateArgs(false) { } + QualifierLoc(), HasTemplateKWAndArgsInfo(false) { } void initializeResults(ASTContext &C, UnresolvedSetIterator Begin, @@ -1863,16 +1873,59 @@ public: /// one was given. NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; } - /// \brief Determines whether this expression had an explicit - /// template argument list, e.g. f<int>. - bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } + /// \brief Retrieve the location of the template keyword preceding + /// this name, if any. + SourceLocation getTemplateKeywordLoc() const { + if (!HasTemplateKWAndArgsInfo) return SourceLocation(); + return getTemplateKWAndArgsInfo()->getTemplateKeywordLoc(); + } + + /// \brief Retrieve the location of the left angle bracket starting the + /// explicit template argument list following the name, if any. + SourceLocation getLAngleLoc() const { + if (!HasTemplateKWAndArgsInfo) return SourceLocation(); + return getTemplateKWAndArgsInfo()->LAngleLoc; + } + + /// \brief Retrieve the location of the right angle bracket ending the + /// explicit template argument list following the name, if any. + SourceLocation getRAngleLoc() const { + if (!HasTemplateKWAndArgsInfo) return SourceLocation(); + return getTemplateKWAndArgsInfo()->RAngleLoc; + } - ASTTemplateArgumentListInfo &getExplicitTemplateArgs(); // defined far below + /// Determines whether the name was preceded by the template keyword. + bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); } + + /// Determines whether this expression had explicit template arguments. + bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); } + + // Note that, inconsistently with the explicit-template-argument AST + // nodes, users are *forbidden* from calling these methods on objects + // without explicit template arguments. + + ASTTemplateArgumentListInfo &getExplicitTemplateArgs() { + assert(hasExplicitTemplateArgs()); + return *getTemplateKWAndArgsInfo(); + } const ASTTemplateArgumentListInfo &getExplicitTemplateArgs() const { return const_cast<OverloadExpr*>(this)->getExplicitTemplateArgs(); } + TemplateArgumentLoc const *getTemplateArgs() const { + return getExplicitTemplateArgs().getTemplateArgs(); + } + + unsigned getNumTemplateArgs() const { + return getExplicitTemplateArgs().NumTemplateArgs; + } + + /// Copies the template arguments into the given structure. + void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { + getExplicitTemplateArgs().copyInto(List); + } + /// \brief Retrieves the optional explicit template arguments. /// This points to the same data as getExplicitTemplateArgs(), but /// returns null if there are no explicit template arguments. @@ -1925,13 +1978,14 @@ class UnresolvedLookupExpr : public OverloadExpr { UnresolvedLookupExpr(ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, + SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool StdIsAssociatedNamespace) - : OverloadExpr(UnresolvedLookupExprClass, C, QualifierLoc, NameInfo, - TemplateArgs, Begin, End, false, false, false), + : OverloadExpr(UnresolvedLookupExprClass, C, QualifierLoc, TemplateKWLoc, + NameInfo, TemplateArgs, Begin, End, false, false, false), RequiresADL(RequiresADL), StdIsAssociatedNamespace(StdIsAssociatedNamespace), Overloaded(Overloaded), NamingClass(NamingClass) @@ -1956,7 +2010,8 @@ public: bool StdIsAssociatedNamespace = false) { assert((ADL || !StdIsAssociatedNamespace) && "std considered associated namespace when not performing ADL"); - return new(C) UnresolvedLookupExpr(C, NamingClass, QualifierLoc, NameInfo, + return new(C) UnresolvedLookupExpr(C, NamingClass, QualifierLoc, + SourceLocation(), NameInfo, ADL, Overloaded, 0, Begin, End, StdIsAssociatedNamespace); } @@ -1964,6 +2019,7 @@ public: static UnresolvedLookupExpr *Create(ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, + SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, bool ADL, const TemplateArgumentListInfo &Args, @@ -1971,7 +2027,7 @@ public: UnresolvedSetIterator End); static UnresolvedLookupExpr *CreateEmpty(ASTContext &C, - bool HasExplicitTemplateArgs, + bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs); /// True if this declaration should be extended by @@ -1990,51 +2046,6 @@ public: /// that was looked in to find these results. CXXRecordDecl *getNamingClass() const { return NamingClass; } - // Note that, inconsistently with the explicit-template-argument AST - // nodes, users are *forbidden* from calling these methods on objects - // without explicit template arguments. - - ASTTemplateArgumentListInfo &getExplicitTemplateArgs() { - assert(hasExplicitTemplateArgs()); - return *reinterpret_cast<ASTTemplateArgumentListInfo*>(this + 1); - } - - /// Gets a reference to the explicit template argument list. - const ASTTemplateArgumentListInfo &getExplicitTemplateArgs() const { - assert(hasExplicitTemplateArgs()); - return *reinterpret_cast<const ASTTemplateArgumentListInfo*>(this + 1); - } - - /// \brief Retrieves the optional explicit template arguments. - /// This points to the same data as getExplicitTemplateArgs(), but - /// returns null if there are no explicit template arguments. - const ASTTemplateArgumentListInfo *getOptionalExplicitTemplateArgs() { - if (!hasExplicitTemplateArgs()) return 0; - return &getExplicitTemplateArgs(); - } - - /// \brief Copies the template arguments (if present) into the given - /// structure. - void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const { - getExplicitTemplateArgs().copyInto(List); - } - - SourceLocation getLAngleLoc() const { - return getExplicitTemplateArgs().LAngleLoc; - } - - SourceLocation getRAngleLoc() const { - return getExplicitTemplateArgs().RAngleLoc; - } - - TemplateArgumentLoc const *getTemplateArgs() const { - return getExplicitTemplateArgs().getTemplateArgs(); - } - - unsigned getNumTemplateArgs() const { - return getExplicitTemplateArgs().NumTemplateArgs; - } - SourceRange getSourceRange() const { SourceRange Range(getNameInfo().getSourceRange()); if (getQualifierLoc()) @@ -2074,22 +2085,36 @@ class DependentScopeDeclRefExpr : public Expr { /// The name of the entity we will be referencing. DeclarationNameInfo NameInfo; - /// \brief Whether the name includes explicit template arguments. - bool HasExplicitTemplateArgs; + /// \brief Whether the name includes info for explicit template + /// keyword and arguments. + bool HasTemplateKWAndArgsInfo; + + /// \brief Return the optional template keyword and arguments info. + ASTTemplateKWAndArgsInfo *getTemplateKWAndArgsInfo() { + if (!HasTemplateKWAndArgsInfo) return 0; + return reinterpret_cast<ASTTemplateKWAndArgsInfo*>(this + 1); + } + /// \brief Return the optional template keyword and arguments info. + const ASTTemplateKWAndArgsInfo *getTemplateKWAndArgsInfo() const { + return const_cast<DependentScopeDeclRefExpr*>(this) + ->getTemplateKWAndArgsInfo(); + } DependentScopeDeclRefExpr(QualType T, NestedNameSpecifierLoc QualifierLoc, + SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *Args); public: static DependentScopeDeclRefExpr *Create(ASTContext &C, NestedNameSpecifierLoc QualifierLoc, + SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, - const TemplateArgumentListInfo *TemplateArgs = 0); + const TemplateArgumentListInfo *TemplateArgs); static DependentScopeDeclRefExpr *CreateEmpty(ASTContext &C, - bool HasExplicitTemplateArgs, + bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs); /// \brief Retrieve the name that this expression refers to. @@ -2112,8 +2137,32 @@ public: return QualifierLoc.getNestedNameSpecifier(); } + /// \brief Retrieve the location of the template keyword preceding + /// this name, if any. + SourceLocation getTemplateKeywordLoc() const { + if (!HasTemplateKWAndArgsInfo) return SourceLocation(); + return getTemplateKWAndArgsInfo()->getTemplateKeywordLoc(); + } + + /// \brief Retrieve the location of the left angle bracket starting the + /// explicit template argument list following the name, if any. + SourceLocation getLAngleLoc() const { + if (!HasTemplateKWAndArgsInfo) return SourceLocation(); + return getTemplateKWAndArgsInfo()->LAngleLoc; + } + + /// \brief Retrieve the location of the right angle bracket ending the + /// explicit template argument list following the name, if any. + SourceLocation getRAngleLoc() const { + if (!HasTemplateKWAndArgsInfo) return SourceLocation(); + return getTemplateKWAndArgsInfo()->RAngleLoc; + } + + /// Determines whether the name was preceded by the template keyword. + bool hasTemplateKeyword() const { return getTemplateKeywordLoc().isValid(); } + /// Determines whether this lookup had explicit template arguments. - bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } + bool hasExplicitTemplateArgs() const { return getLAngleLoc().isValid(); } // Note that, inconsistently with the explicit-template-argument AST // nodes, users are *forbidden* from calling these methods on objects @@ -2144,14 +2193,6 @@ public: getExplicitTemplateArgs().copyInto(List); } - SourceLocation getLAngleLoc() const { - return getExplicitTemplateArgs().LAngleLoc; - } - - SourceLocation getRAngleLoc() const { - return getExplicitTemplateArgs().RAngleLoc; - } - TemplateArgumentLoc const *getTemplateArgs() const { return getExplicitTemplateArgs().getTemplateArgs(); } @@ -2387,9 +2428,9 @@ class CXXDependentScopeMemberExpr : public Expr { /// the '.' operator. bool IsArrow : 1; - /// \brief Whether this member expression has explicitly-specified template - /// arguments. - bool HasExplicitTemplateArgs : 1; + /// \brief Whether this member expression has info for explicit template + /// keyword and arguments. + bool HasTemplateKWAndArgsInfo : 1; /// \brief The location of the '->' or '.' operator. SourceLocation OperatorLoc; @@ -2411,10 +2452,22 @@ class CXXDependentScopeMemberExpr : public Expr { /// FIXME: could also be a template-id DeclarationNameInfo MemberNameInfo; |