forked from OSchip/llvm-project
Push nested-name-specifier source location information into
UnresolvedLookupExpr and UnresolvedMemberExpr. Also, improve the computation that checks whether the base of a member expression (either unresolved or dependent-scoped) is implicit. The previous check didn't cover all of the cases we use in our representation, which threw off source-location information for these expressions (which, in turn, caused some breakage in libclang's token annotation). llvm-svn: 126681
This commit is contained in:
parent
6564ca0c23
commit
0da1d43e16
|
@ -1590,18 +1590,15 @@ class OverloadExpr : public Expr {
|
||||||
/// The common name of these declarations.
|
/// The common name of these declarations.
|
||||||
DeclarationNameInfo NameInfo;
|
DeclarationNameInfo NameInfo;
|
||||||
|
|
||||||
/// The scope specifier, if any.
|
/// \brief The nested-name-specifier that qualifies the name, if any.
|
||||||
NestedNameSpecifier *Qualifier;
|
NestedNameSpecifierLoc QualifierLoc;
|
||||||
|
|
||||||
/// The source range of the scope specifier.
|
|
||||||
SourceRange QualifierRange;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// True if the name was a template-id.
|
/// True if the name was a template-id.
|
||||||
bool HasExplicitTemplateArgs;
|
bool HasExplicitTemplateArgs;
|
||||||
|
|
||||||
OverloadExpr(StmtClass K, ASTContext &C,
|
OverloadExpr(StmtClass K, ASTContext &C,
|
||||||
NestedNameSpecifier *Qualifier, SourceRange QRange,
|
NestedNameSpecifierLoc QualifierLoc,
|
||||||
const DeclarationNameInfo &NameInfo,
|
const DeclarationNameInfo &NameInfo,
|
||||||
const TemplateArgumentListInfo *TemplateArgs,
|
const TemplateArgumentListInfo *TemplateArgs,
|
||||||
UnresolvedSetIterator Begin, UnresolvedSetIterator End,
|
UnresolvedSetIterator Begin, UnresolvedSetIterator End,
|
||||||
|
@ -1610,7 +1607,7 @@ protected:
|
||||||
|
|
||||||
OverloadExpr(StmtClass K, EmptyShell Empty)
|
OverloadExpr(StmtClass K, EmptyShell Empty)
|
||||||
: Expr(K, Empty), Results(0), NumResults(0),
|
: Expr(K, Empty), Results(0), NumResults(0),
|
||||||
Qualifier(0), HasExplicitTemplateArgs(false) { }
|
QualifierLoc(), HasExplicitTemplateArgs(false) { }
|
||||||
|
|
||||||
void initializeResults(ASTContext &C,
|
void initializeResults(ASTContext &C,
|
||||||
UnresolvedSetIterator Begin,
|
UnresolvedSetIterator Begin,
|
||||||
|
@ -1665,23 +1662,21 @@ public:
|
||||||
|
|
||||||
/// Gets the full name info.
|
/// Gets the full name info.
|
||||||
const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
|
const DeclarationNameInfo &getNameInfo() const { return NameInfo; }
|
||||||
void setNameInfo(const DeclarationNameInfo &N) { NameInfo = N; }
|
|
||||||
|
|
||||||
/// Gets the name looked up.
|
/// Gets the name looked up.
|
||||||
DeclarationName getName() const { return NameInfo.getName(); }
|
DeclarationName getName() const { return NameInfo.getName(); }
|
||||||
void setName(DeclarationName N) { NameInfo.setName(N); }
|
|
||||||
|
|
||||||
/// Gets the location of the name.
|
/// Gets the location of the name.
|
||||||
SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
|
SourceLocation getNameLoc() const { return NameInfo.getLoc(); }
|
||||||
void setNameLoc(SourceLocation Loc) { NameInfo.setLoc(Loc); }
|
|
||||||
|
|
||||||
/// Fetches the nested-name qualifier, if one was given.
|
/// Fetches the nested-name qualifier, if one was given.
|
||||||
NestedNameSpecifier *getQualifier() const { return Qualifier; }
|
NestedNameSpecifier *getQualifier() const {
|
||||||
void setQualifier(NestedNameSpecifier *NNS) { Qualifier = NNS; }
|
return QualifierLoc.getNestedNameSpecifier();
|
||||||
|
}
|
||||||
|
|
||||||
/// Fetches the range of the nested-name qualifier.
|
/// Fetches the nested-name qualifier with source-location information, if
|
||||||
SourceRange getQualifierRange() const { return QualifierRange; }
|
/// one was given.
|
||||||
void setQualifierRange(SourceRange R) { QualifierRange = R; }
|
NestedNameSpecifierLoc getQualifierLoc() const { return QualifierLoc; }
|
||||||
|
|
||||||
/// \brief Determines whether this expression had an explicit
|
/// \brief Determines whether this expression had an explicit
|
||||||
/// template argument list, e.g. f<int>.
|
/// template argument list, e.g. f<int>.
|
||||||
|
@ -1740,12 +1735,12 @@ class UnresolvedLookupExpr : public OverloadExpr {
|
||||||
|
|
||||||
UnresolvedLookupExpr(ASTContext &C,
|
UnresolvedLookupExpr(ASTContext &C,
|
||||||
CXXRecordDecl *NamingClass,
|
CXXRecordDecl *NamingClass,
|
||||||
NestedNameSpecifier *Qualifier, SourceRange QRange,
|
NestedNameSpecifierLoc QualifierLoc,
|
||||||
const DeclarationNameInfo &NameInfo,
|
const DeclarationNameInfo &NameInfo,
|
||||||
bool RequiresADL, bool Overloaded,
|
bool RequiresADL, bool Overloaded,
|
||||||
const TemplateArgumentListInfo *TemplateArgs,
|
const TemplateArgumentListInfo *TemplateArgs,
|
||||||
UnresolvedSetIterator Begin, UnresolvedSetIterator End)
|
UnresolvedSetIterator Begin, UnresolvedSetIterator End)
|
||||||
: OverloadExpr(UnresolvedLookupExprClass, C, Qualifier, QRange, NameInfo,
|
: OverloadExpr(UnresolvedLookupExprClass, C, QualifierLoc, NameInfo,
|
||||||
TemplateArgs, Begin, End),
|
TemplateArgs, Begin, End),
|
||||||
RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
|
RequiresADL(RequiresADL), Overloaded(Overloaded), NamingClass(NamingClass)
|
||||||
{}
|
{}
|
||||||
|
@ -1755,24 +1750,23 @@ class UnresolvedLookupExpr : public OverloadExpr {
|
||||||
RequiresADL(false), Overloaded(false), NamingClass(0)
|
RequiresADL(false), Overloaded(false), NamingClass(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
friend class ASTStmtReader;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static UnresolvedLookupExpr *Create(ASTContext &C,
|
static UnresolvedLookupExpr *Create(ASTContext &C,
|
||||||
CXXRecordDecl *NamingClass,
|
CXXRecordDecl *NamingClass,
|
||||||
NestedNameSpecifier *Qualifier,
|
NestedNameSpecifierLoc QualifierLoc,
|
||||||
SourceRange QualifierRange,
|
|
||||||
const DeclarationNameInfo &NameInfo,
|
const DeclarationNameInfo &NameInfo,
|
||||||
bool ADL, bool Overloaded,
|
bool ADL, bool Overloaded,
|
||||||
UnresolvedSetIterator Begin,
|
UnresolvedSetIterator Begin,
|
||||||
UnresolvedSetIterator End) {
|
UnresolvedSetIterator End) {
|
||||||
return new(C) UnresolvedLookupExpr(C, NamingClass, Qualifier,
|
return new(C) UnresolvedLookupExpr(C, NamingClass, QualifierLoc, NameInfo,
|
||||||
QualifierRange, NameInfo, ADL,
|
ADL, Overloaded, 0, Begin, End);
|
||||||
Overloaded, 0, Begin, End);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static UnresolvedLookupExpr *Create(ASTContext &C,
|
static UnresolvedLookupExpr *Create(ASTContext &C,
|
||||||
CXXRecordDecl *NamingClass,
|
CXXRecordDecl *NamingClass,
|
||||||
NestedNameSpecifier *Qualifier,
|
NestedNameSpecifierLoc QualifierLoc,
|
||||||
SourceRange QualifierRange,
|
|
||||||
const DeclarationNameInfo &NameInfo,
|
const DeclarationNameInfo &NameInfo,
|
||||||
bool ADL,
|
bool ADL,
|
||||||
const TemplateArgumentListInfo &Args,
|
const TemplateArgumentListInfo &Args,
|
||||||
|
@ -1786,17 +1780,14 @@ public:
|
||||||
/// True if this declaration should be extended by
|
/// True if this declaration should be extended by
|
||||||
/// argument-dependent lookup.
|
/// argument-dependent lookup.
|
||||||
bool requiresADL() const { return RequiresADL; }
|
bool requiresADL() const { return RequiresADL; }
|
||||||
void setRequiresADL(bool V) { RequiresADL = V; }
|
|
||||||
|
|
||||||
/// True if this lookup is overloaded.
|
/// True if this lookup is overloaded.
|
||||||
bool isOverloaded() const { return Overloaded; }
|
bool isOverloaded() const { return Overloaded; }
|
||||||
void setOverloaded(bool V) { Overloaded = V; }
|
|
||||||
|
|
||||||
/// Gets the 'naming class' (in the sense of C++0x
|
/// Gets the 'naming class' (in the sense of C++0x
|
||||||
/// [class.access.base]p5) of the lookup. This is the scope
|
/// [class.access.base]p5) of the lookup. This is the scope
|
||||||
/// that was looked in to find these results.
|
/// that was looked in to find these results.
|
||||||
CXXRecordDecl *getNamingClass() const { return NamingClass; }
|
CXXRecordDecl *getNamingClass() const { return NamingClass; }
|
||||||
void setNamingClass(CXXRecordDecl *D) { NamingClass = D; }
|
|
||||||
|
|
||||||
// Note that, inconsistently with the explicit-template-argument AST
|
// Note that, inconsistently with the explicit-template-argument AST
|
||||||
// nodes, users are *forbidden* from calling these methods on objects
|
// nodes, users are *forbidden* from calling these methods on objects
|
||||||
|
@ -1845,8 +1836,10 @@ public:
|
||||||
|
|
||||||
SourceRange getSourceRange() const {
|
SourceRange getSourceRange() const {
|
||||||
SourceRange Range(getNameInfo().getSourceRange());
|
SourceRange Range(getNameInfo().getSourceRange());
|
||||||
if (getQualifier()) Range.setBegin(getQualifierRange().getBegin());
|
if (getQualifierLoc())
|
||||||
if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc());
|
Range.setBegin(getQualifierLoc().getBeginLoc());
|
||||||
|
if (hasExplicitTemplateArgs())
|
||||||
|
Range.setEnd(getRAngleLoc());
|
||||||
return Range;
|
return Range;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2235,7 +2228,7 @@ public:
|
||||||
/// \brief True if this is an implicit access, i.e. one in which the
|
/// \brief True if this is an implicit access, i.e. one in which the
|
||||||
/// member being accessed was not written in the source. The source
|
/// member being accessed was not written in the source. The source
|
||||||
/// location of the operator is invalid in this case.
|
/// location of the operator is invalid in this case.
|
||||||
bool isImplicitAccess() const { return Base == 0; }
|
bool isImplicitAccess() const;
|
||||||
|
|
||||||
/// \brief Retrieve the base object of this member expressions,
|
/// \brief Retrieve the base object of this member expressions,
|
||||||
/// e.g., the \c x in \c x.m.
|
/// e.g., the \c x in \c x.m.
|
||||||
|
@ -2423,8 +2416,7 @@ class UnresolvedMemberExpr : public OverloadExpr {
|
||||||
UnresolvedMemberExpr(ASTContext &C, bool HasUnresolvedUsing,
|
UnresolvedMemberExpr(ASTContext &C, bool HasUnresolvedUsing,
|
||||||
Expr *Base, QualType BaseType, bool IsArrow,
|
Expr *Base, QualType BaseType, bool IsArrow,
|
||||||
SourceLocation OperatorLoc,
|
SourceLocation OperatorLoc,
|
||||||
NestedNameSpecifier *Qualifier,
|
NestedNameSpecifierLoc QualifierLoc,
|
||||||
SourceRange QualifierRange,
|
|
||||||
const DeclarationNameInfo &MemberNameInfo,
|
const DeclarationNameInfo &MemberNameInfo,
|
||||||
const TemplateArgumentListInfo *TemplateArgs,
|
const TemplateArgumentListInfo *TemplateArgs,
|
||||||
UnresolvedSetIterator Begin, UnresolvedSetIterator End);
|
UnresolvedSetIterator Begin, UnresolvedSetIterator End);
|
||||||
|
@ -2433,13 +2425,14 @@ class UnresolvedMemberExpr : public OverloadExpr {
|
||||||
: OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false),
|
: OverloadExpr(UnresolvedMemberExprClass, Empty), IsArrow(false),
|
||||||
HasUnresolvedUsing(false), Base(0) { }
|
HasUnresolvedUsing(false), Base(0) { }
|
||||||
|
|
||||||
|
friend class ASTStmtReader;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static UnresolvedMemberExpr *
|
static UnresolvedMemberExpr *
|
||||||
Create(ASTContext &C, bool HasUnresolvedUsing,
|
Create(ASTContext &C, bool HasUnresolvedUsing,
|
||||||
Expr *Base, QualType BaseType, bool IsArrow,
|
Expr *Base, QualType BaseType, bool IsArrow,
|
||||||
SourceLocation OperatorLoc,
|
SourceLocation OperatorLoc,
|
||||||
NestedNameSpecifier *Qualifier,
|
NestedNameSpecifierLoc QualifierLoc,
|
||||||
SourceRange QualifierRange,
|
|
||||||
const DeclarationNameInfo &MemberNameInfo,
|
const DeclarationNameInfo &MemberNameInfo,
|
||||||
const TemplateArgumentListInfo *TemplateArgs,
|
const TemplateArgumentListInfo *TemplateArgs,
|
||||||
UnresolvedSetIterator Begin, UnresolvedSetIterator End);
|
UnresolvedSetIterator Begin, UnresolvedSetIterator End);
|
||||||
|
@ -2451,7 +2444,7 @@ public:
|
||||||
/// \brief True if this is an implicit access, i.e. one in which the
|
/// \brief True if this is an implicit access, i.e. one in which the
|
||||||
/// member being accessed was not written in the source. The source
|
/// member being accessed was not written in the source. The source
|
||||||
/// location of the operator is invalid in this case.
|
/// location of the operator is invalid in this case.
|
||||||
bool isImplicitAccess() const { return Base == 0; }
|
bool isImplicitAccess() const;
|
||||||
|
|
||||||
/// \brief Retrieve the base object of this member expressions,
|
/// \brief Retrieve the base object of this member expressions,
|
||||||
/// e.g., the \c x in \c x.m.
|
/// e.g., the \c x in \c x.m.
|
||||||
|
@ -2463,24 +2456,19 @@ public:
|
||||||
assert(!isImplicitAccess());
|
assert(!isImplicitAccess());
|
||||||
return cast<Expr>(Base);
|
return cast<Expr>(Base);
|
||||||
}
|
}
|
||||||
void setBase(Expr *E) { Base = E; }
|
|
||||||
|
|
||||||
QualType getBaseType() const { return BaseType; }
|
QualType getBaseType() const { return BaseType; }
|
||||||
void setBaseType(QualType T) { BaseType = T; }
|
|
||||||
|
|
||||||
/// \brief Determine whether the lookup results contain an unresolved using
|
/// \brief Determine whether the lookup results contain an unresolved using
|
||||||
/// declaration.
|
/// declaration.
|
||||||
bool hasUnresolvedUsing() const { return HasUnresolvedUsing; }
|
bool hasUnresolvedUsing() const { return HasUnresolvedUsing; }
|
||||||
void setHasUnresolvedUsing(bool V) { HasUnresolvedUsing = V; }
|
|
||||||
|
|
||||||
/// \brief Determine whether this member expression used the '->'
|
/// \brief Determine whether this member expression used the '->'
|
||||||
/// operator; otherwise, it used the '.' operator.
|
/// operator; otherwise, it used the '.' operator.
|
||||||
bool isArrow() const { return IsArrow; }
|
bool isArrow() const { return IsArrow; }
|
||||||
void setArrow(bool A) { IsArrow = A; }
|
|
||||||
|
|
||||||
/// \brief Retrieve the location of the '->' or '.' operator.
|
/// \brief Retrieve the location of the '->' or '.' operator.
|
||||||
SourceLocation getOperatorLoc() const { return OperatorLoc; }
|
SourceLocation getOperatorLoc() const { return OperatorLoc; }
|
||||||
void setOperatorLoc(SourceLocation L) { OperatorLoc = L; }
|
|
||||||
|
|
||||||
/// \brief Retrieves the naming class of this lookup.
|
/// \brief Retrieves the naming class of this lookup.
|
||||||
CXXRecordDecl *getNamingClass() const;
|
CXXRecordDecl *getNamingClass() const;
|
||||||
|
@ -2488,17 +2476,14 @@ public:
|
||||||
/// \brief Retrieve the full name info for the member that this expression
|
/// \brief Retrieve the full name info for the member that this expression
|
||||||
/// refers to.
|
/// refers to.
|
||||||
const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); }
|
const DeclarationNameInfo &getMemberNameInfo() const { return getNameInfo(); }
|
||||||
void setMemberNameInfo(const DeclarationNameInfo &N) { setNameInfo(N); }
|
|
||||||
|
|
||||||
/// \brief Retrieve the name of the member that this expression
|
/// \brief Retrieve the name of the member that this expression
|
||||||
/// refers to.
|
/// refers to.
|
||||||
DeclarationName getMemberName() const { return getName(); }
|
DeclarationName getMemberName() const { return getName(); }
|
||||||
void setMemberName(DeclarationName N) { setName(N); }
|
|
||||||
|
|
||||||
// \brief Retrieve the location of the name of the member that this
|
// \brief Retrieve the location of the name of the member that this
|
||||||
// expression refers to.
|
// expression refers to.
|
||||||
SourceLocation getMemberLoc() const { return getNameLoc(); }
|
SourceLocation getMemberLoc() const { return getNameLoc(); }
|
||||||
void setMemberLoc(SourceLocation L) { setNameLoc(L); }
|
|
||||||
|
|
||||||
/// \brief Retrieve the explicit template argument list that followed the
|
/// \brief Retrieve the explicit template argument list that followed the
|
||||||
/// member template name.
|
/// member template name.
|
||||||
|
@ -2555,8 +2540,8 @@ public:
|
||||||
SourceRange Range = getMemberNameInfo().getSourceRange();
|
SourceRange Range = getMemberNameInfo().getSourceRange();
|
||||||
if (!isImplicitAccess())
|
if (!isImplicitAccess())
|
||||||
Range.setBegin(Base->getSourceRange().getBegin());
|
Range.setBegin(Base->getSourceRange().getBegin());
|
||||||
else if (getQualifier())
|
else if (getQualifierLoc())
|
||||||
Range.setBegin(getQualifierRange().getBegin());
|
Range.setBegin(getQualifierLoc().getBeginLoc());
|
||||||
|
|
||||||
if (hasExplicitTemplateArgs())
|
if (hasExplicitTemplateArgs())
|
||||||
Range.setEnd(getRAngleLoc());
|
Range.setEnd(getRAngleLoc());
|
||||||
|
|
|
@ -1869,7 +1869,7 @@ DEF_TRAVERSE_STMT(PredefinedExpr, { })
|
||||||
DEF_TRAVERSE_STMT(ShuffleVectorExpr, { })
|
DEF_TRAVERSE_STMT(ShuffleVectorExpr, { })
|
||||||
DEF_TRAVERSE_STMT(StmtExpr, { })
|
DEF_TRAVERSE_STMT(StmtExpr, { })
|
||||||
DEF_TRAVERSE_STMT(UnresolvedLookupExpr, {
|
DEF_TRAVERSE_STMT(UnresolvedLookupExpr, {
|
||||||
TRY_TO(TraverseNestedNameSpecifier(S->getQualifier()));
|
TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
|
||||||
if (S->hasExplicitTemplateArgs()) {
|
if (S->hasExplicitTemplateArgs()) {
|
||||||
TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
|
TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
|
||||||
S->getNumTemplateArgs()));
|
S->getNumTemplateArgs()));
|
||||||
|
@ -1877,7 +1877,7 @@ DEF_TRAVERSE_STMT(UnresolvedLookupExpr, {
|
||||||
})
|
})
|
||||||
|
|
||||||
DEF_TRAVERSE_STMT(UnresolvedMemberExpr, {
|
DEF_TRAVERSE_STMT(UnresolvedMemberExpr, {
|
||||||
TRY_TO(TraverseNestedNameSpecifier(S->getQualifier()));
|
TRY_TO(TraverseNestedNameSpecifierLoc(S->getQualifierLoc()));
|
||||||
if (S->hasExplicitTemplateArgs()) {
|
if (S->hasExplicitTemplateArgs()) {
|
||||||
TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
|
TRY_TO(TraverseTemplateArgumentLocsHelper(S->getTemplateArgs(),
|
||||||
S->getNumTemplateArgs()));
|
S->getNumTemplateArgs()));
|
||||||
|
|
|
@ -174,8 +174,7 @@ SourceRange CXXPseudoDestructorExpr::getSourceRange() const {
|
||||||
UnresolvedLookupExpr *
|
UnresolvedLookupExpr *
|
||||||
UnresolvedLookupExpr::Create(ASTContext &C,
|
UnresolvedLookupExpr::Create(ASTContext &C,
|
||||||
CXXRecordDecl *NamingClass,
|
CXXRecordDecl *NamingClass,
|
||||||
NestedNameSpecifier *Qualifier,
|
NestedNameSpecifierLoc QualifierLoc,
|
||||||
SourceRange QualifierRange,
|
|
||||||
const DeclarationNameInfo &NameInfo,
|
const DeclarationNameInfo &NameInfo,
|
||||||
bool ADL,
|
bool ADL,
|
||||||
const TemplateArgumentListInfo &Args,
|
const TemplateArgumentListInfo &Args,
|
||||||
|
@ -184,8 +183,7 @@ UnresolvedLookupExpr::Create(ASTContext &C,
|
||||||
{
|
{
|
||||||
void *Mem = C.Allocate(sizeof(UnresolvedLookupExpr) +
|
void *Mem = C.Allocate(sizeof(UnresolvedLookupExpr) +
|
||||||
ExplicitTemplateArgumentList::sizeFor(Args));
|
ExplicitTemplateArgumentList::sizeFor(Args));
|
||||||
return new (Mem) UnresolvedLookupExpr(C, NamingClass,
|
return new (Mem) UnresolvedLookupExpr(C, NamingClass, QualifierLoc, NameInfo,
|
||||||
Qualifier, QualifierRange, NameInfo,
|
|
||||||
ADL, /*Overload*/ true, &Args,
|
ADL, /*Overload*/ true, &Args,
|
||||||
Begin, End);
|
Begin, End);
|
||||||
}
|
}
|
||||||
|
@ -204,7 +202,7 @@ UnresolvedLookupExpr::CreateEmpty(ASTContext &C, bool HasExplicitTemplateArgs,
|
||||||
}
|
}
|
||||||
|
|
||||||
OverloadExpr::OverloadExpr(StmtClass K, ASTContext &C,
|
OverloadExpr::OverloadExpr(StmtClass K, ASTContext &C,
|
||||||
NestedNameSpecifier *Qualifier, SourceRange QRange,
|
NestedNameSpecifierLoc QualifierLoc,
|
||||||
const DeclarationNameInfo &NameInfo,
|
const DeclarationNameInfo &NameInfo,
|
||||||
const TemplateArgumentListInfo *TemplateArgs,
|
const TemplateArgumentListInfo *TemplateArgs,
|
||||||
UnresolvedSetIterator Begin,
|
UnresolvedSetIterator Begin,
|
||||||
|
@ -215,10 +213,11 @@ OverloadExpr::OverloadExpr(StmtClass K, ASTContext &C,
|
||||||
KnownDependent,
|
KnownDependent,
|
||||||
(KnownContainsUnexpandedParameterPack ||
|
(KnownContainsUnexpandedParameterPack ||
|
||||||
NameInfo.containsUnexpandedParameterPack() ||
|
NameInfo.containsUnexpandedParameterPack() ||
|
||||||
(Qualifier && Qualifier->containsUnexpandedParameterPack()))),
|
(QualifierLoc &&
|
||||||
|
QualifierLoc.getNestedNameSpecifier()
|
||||||
|
->containsUnexpandedParameterPack()))),
|
||||||
Results(0), NumResults(End - Begin), NameInfo(NameInfo),
|
Results(0), NumResults(End - Begin), NameInfo(NameInfo),
|
||||||
Qualifier(Qualifier), QualifierRange(QRange),
|
QualifierLoc(QualifierLoc), HasExplicitTemplateArgs(TemplateArgs != 0)
|
||||||
HasExplicitTemplateArgs(TemplateArgs != 0)
|
|
||||||
{
|
{
|
||||||
NumResults = End - Begin;
|
NumResults = End - Begin;
|
||||||
if (NumResults) {
|
if (NumResults) {
|
||||||
|
@ -784,19 +783,59 @@ CXXDependentScopeMemberExpr::CreateEmpty(ASTContext &C,
|
||||||
return E;
|
return E;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// \brief Determine whether this expression is an implicit C++ 'this'.
|
||||||
|
static bool isImplicitThis(const Expr *E) {
|
||||||
|
// Strip away parentheses and casts we don't care about.
|
||||||
|
while (true) {
|
||||||
|
if (const ParenExpr *Paren = dyn_cast<ParenExpr>(E)) {
|
||||||
|
E = Paren->getSubExpr();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
|
||||||
|
if (ICE->getCastKind() == CK_NoOp ||
|
||||||
|
ICE->getCastKind() == CK_LValueToRValue ||
|
||||||
|
ICE->getCastKind() == CK_DerivedToBase ||
|
||||||
|
ICE->getCastKind() == CK_UncheckedDerivedToBase) {
|
||||||
|
E = ICE->getSubExpr();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) {
|
||||||
|
if (UnOp->getOpcode() == UO_Extension) {
|
||||||
|
E = UnOp->getSubExpr();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (const CXXThisExpr *This = dyn_cast<CXXThisExpr>(E))
|
||||||
|
return This->isImplicit();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CXXDependentScopeMemberExpr::isImplicitAccess() const {
|
||||||
|
if (Base == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return isImplicitThis(cast<Expr>(Base));
|
||||||
|
}
|
||||||
|
|
||||||
UnresolvedMemberExpr::UnresolvedMemberExpr(ASTContext &C,
|
UnresolvedMemberExpr::UnresolvedMemberExpr(ASTContext &C,
|
||||||
bool HasUnresolvedUsing,
|
bool HasUnresolvedUsing,
|
||||||
Expr *Base, QualType BaseType,
|
Expr *Base, QualType BaseType,
|
||||||
bool IsArrow,
|
bool IsArrow,
|
||||||
SourceLocation OperatorLoc,
|
SourceLocation OperatorLoc,
|
||||||
NestedNameSpecifier *Qualifier,
|
NestedNameSpecifierLoc QualifierLoc,
|
||||||
SourceRange QualifierRange,
|
|
||||||
const DeclarationNameInfo &MemberNameInfo,
|
const DeclarationNameInfo &MemberNameInfo,
|
||||||
const TemplateArgumentListInfo *TemplateArgs,
|
const TemplateArgumentListInfo *TemplateArgs,
|
||||||
UnresolvedSetIterator Begin,
|
UnresolvedSetIterator Begin,
|
||||||
UnresolvedSetIterator End)
|
UnresolvedSetIterator End)
|
||||||
: OverloadExpr(UnresolvedMemberExprClass, C,
|
: OverloadExpr(UnresolvedMemberExprClass, C, QualifierLoc, MemberNameInfo,
|
||||||
Qualifier, QualifierRange, MemberNameInfo,
|
|
||||||
TemplateArgs, Begin, End,
|
TemplateArgs, Begin, End,
|
||||||
// Dependent
|
// Dependent
|
||||||
((Base && Base->isTypeDependent()) ||
|
((Base && Base->isTypeDependent()) ||
|
||||||
|
@ -808,13 +847,19 @@ UnresolvedMemberExpr::UnresolvedMemberExpr(ASTContext &C,
|
||||||
Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) {
|
Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UnresolvedMemberExpr::isImplicitAccess() const {
|
||||||
|
if (Base == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return isImplicitThis(cast<Expr>(Base));
|
||||||
|
}
|
||||||
|
|
||||||
UnresolvedMemberExpr *
|
UnresolvedMemberExpr *
|
||||||
UnresolvedMemberExpr::Create(ASTContext &C,
|
UnresolvedMemberExpr::Create(ASTContext &C,
|
||||||
bool HasUnresolvedUsing,
|
bool HasUnresolvedUsing,
|
||||||
Expr *Base, QualType BaseType, bool IsArrow,
|
Expr *Base, QualType BaseType, bool IsArrow,
|
||||||
SourceLocation OperatorLoc,
|
SourceLocation OperatorLoc,
|
||||||
NestedNameSpecifier *Qualifier,
|
NestedNameSpecifierLoc QualifierLoc,
|
||||||
SourceRange QualifierRange,
|
|
||||||
const DeclarationNameInfo &MemberNameInfo,
|
const DeclarationNameInfo &MemberNameInfo,
|
||||||
const TemplateArgumentListInfo *TemplateArgs,
|
const TemplateArgumentListInfo *TemplateArgs,
|
||||||
UnresolvedSetIterator Begin,
|
UnresolvedSetIterator Begin,
|
||||||
|
@ -826,7 +871,7 @@ UnresolvedMemberExpr::Create(ASTContext &C,
|
||||||
void *Mem = C.Allocate(size, llvm::alignOf<UnresolvedMemberExpr>());
|
void *Mem = C.Allocate(size, llvm::alignOf<UnresolvedMemberExpr>());
|
||||||
return new (Mem) UnresolvedMemberExpr(C,
|
return new (Mem) UnresolvedMemberExpr(C,
|
||||||
HasUnresolvedUsing, Base, BaseType,
|
HasUnresolvedUsing, Base, BaseType,
|
||||||
IsArrow, OperatorLoc, Qualifier, QualifierRange,
|
IsArrow, OperatorLoc, QualifierLoc,
|
||||||
MemberNameInfo, TemplateArgs, Begin, End);
|
MemberNameInfo, TemplateArgs, Begin, End);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -642,7 +642,8 @@ CheckStaticCast(Sema &Self, Expr *&SrcExpr, QualType DestType,
|
||||||
if (SrcExpr->getType() == Self.Context.OverloadTy) {
|
if (SrcExpr->getType() == Self.Context.OverloadTy) {
|
||||||
OverloadExpr* oe = OverloadExpr::find(SrcExpr).Expression;
|
OverloadExpr* oe = OverloadExpr::find(SrcExpr).Expression;
|
||||||
Self.Diag(OpRange.getBegin(), diag::err_bad_static_cast_overload)
|
Self.Diag(OpRange.getBegin(), diag::err_bad_static_cast_overload)
|
||||||
<< oe->getName() << DestType << OpRange << oe->getQualifierRange();
|
<< oe->getName() << DestType << OpRange
|
||||||
|
<< oe->getQualifierLoc().getSourceRange();
|
||||||
Self.NoteAllOverloadCandidates(SrcExpr);
|
Self.NoteAllOverloadCandidates(SrcExpr);
|
||||||
} else {
|
} else {
|
||||||
diagnoseBadCast(Self, msg, CT_Static, OpRange, SrcExpr, DestType);
|
diagnoseBadCast(Self, msg, CT_Static, OpRange, SrcExpr, DestType);
|
||||||
|
@ -1289,7 +1290,7 @@ static ExprResult ResolveAndFixSingleFunctionTemplateSpecialization(
|
||||||
OverloadExpr* oe = OverloadExpr::find(SrcExpr).Expression;
|
OverloadExpr* oe = OverloadExpr::find(SrcExpr).Expression;
|
||||||
Self.Diag(OpRangeForComplaining.getBegin(), DiagIDForComplaining)
|
Self.Diag(OpRangeForComplaining.getBegin(), DiagIDForComplaining)
|
||||||
<< oe->getName() << DestTypeForComplaining << OpRangeForComplaining
|
<< oe->getName() << DestTypeForComplaining << OpRangeForComplaining
|
||||||
<< oe->getQualifierRange();
|
<< oe->getQualifierLoc().getSourceRange();
|
||||||
Self.NoteAllOverloadCandidates(SrcExpr);
|
Self.NoteAllOverloadCandidates(SrcExpr);
|
||||||
}
|
}
|
||||||
return SingleFunctionExpression;
|
return SingleFunctionExpression;
|
||||||
|
|
|
@ -1351,12 +1351,8 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
|
||||||
if (ULE->hasExplicitTemplateArgs())
|
if (ULE->hasExplicitTemplateArgs())
|
||||||
ULE->copyTemplateArgumentsInto(TList);
|
ULE->copyTemplateArgumentsInto(TList);
|
||||||
|
|
||||||
// FIXME: We should have nested-name-specifier location info in
|
|
||||||
// the ULE itself.
|
|
||||||
CXXScopeSpec SS;
|
CXXScopeSpec SS;
|
||||||
SS.MakeTrivial(Context, ULE->getQualifier(),
|
SS.Adopt(ULE->getQualifierLoc());
|
||||||
ULE->getQualifierRange());
|
|
||||||
|
|
||||||
CXXDependentScopeMemberExpr *DepExpr =
|
CXXDependentScopeMemberExpr *DepExpr =
|
||||||
CXXDependentScopeMemberExpr::Create(
|
CXXDependentScopeMemberExpr::Create(
|
||||||
Context, DepThis, DepThisType, true, SourceLocation(),
|
Context, DepThis, DepThisType, true, SourceLocation(),
|
||||||
|
@ -2283,8 +2279,8 @@ Sema::BuildDeclarationNameExpr(const CXXScopeSpec &SS,
|
||||||
|
|
||||||
UnresolvedLookupExpr *ULE
|
UnresolvedLookupExpr *ULE
|
||||||
= UnresolvedLookupExpr::Create(Context, R.getNamingClass(),
|
= UnresolvedLookupExpr::Create(Context, R.getNamingClass(),
|
||||||
(NestedNameSpecifier*) SS.getScopeRep(),
|
SS.getWithLocInContext(Context),
|
||||||
SS.getRange(), R.getLookupNameInfo(),
|
R.getLookupNameInfo(),
|
||||||
NeedsADL, R.isOverloadedResult(),
|
NeedsADL, R.isOverloadedResult(),
|
||||||
R.begin(), R.end());
|
R.begin(), R.end());
|
||||||
|
|
||||||
|
@ -3483,7 +3479,6 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
|
||||||
}
|
}
|
||||||
R.setBaseObjectType(BaseType);
|
R.setBaseObjectType(BaseType);
|
||||||
|
|
||||||
NestedNameSpecifier *Qualifier = SS.getScopeRep();
|
|
||||||
const DeclarationNameInfo &MemberNameInfo = R.getLookupNameInfo();
|
const DeclarationNameInfo &MemberNameInfo = R.getLookupNameInfo();
|
||||||
DeclarationName MemberName = MemberNameInfo.getName();
|
DeclarationName MemberName = MemberNameInfo.getName();
|
||||||
SourceLocation MemberLoc = MemberNameInfo.getLoc();
|
SourceLocation MemberLoc = MemberNameInfo.getLoc();
|
||||||
|
@ -3528,7 +3523,7 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
|
||||||
= UnresolvedMemberExpr::Create(Context, R.isUnresolvableResult(),
|
= UnresolvedMemberExpr::Create(Context, R.isUnresolvableResult(),
|
||||||
BaseExpr, BaseExprType,
|
BaseExpr, BaseExprType,
|
||||||
IsArrow, OpLoc,
|
IsArrow, OpLoc,
|
||||||
Qualifier, SS.getRange(),
|
SS.getWithLocInContext(Context),
|
||||||
MemberNameInfo,
|
MemberNameInfo,
|
||||||
TemplateArgs, R.begin(), R.end());
|
TemplateArgs, R.begin(), R.end());
|
||||||
|
|
||||||
|
|
|
@ -7590,9 +7590,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
|
||||||
SourceLocation RParenLoc) {
|
SourceLocation RParenLoc) {
|
||||||
|
|
||||||
CXXScopeSpec SS;
|
CXXScopeSpec SS;
|
||||||
if (ULE->getQualifier())
|
SS.Adopt(ULE->getQualifierLoc());
|
||||||
SS.MakeTrivial(SemaRef.Context,
|
|
||||||
ULE->getQualifier(), ULE->getQualifierRange());
|
|
||||||
|
|
||||||
TemplateArgumentListInfo TABuffer;
|
TemplateArgumentListInfo TABuffer;
|
||||||
const TemplateArgumentListInfo *ExplicitTemplateArgs = 0;
|
const TemplateArgumentListInfo *ExplicitTemplateArgs = 0;
|
||||||
|
@ -7776,11 +7774,11 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn,
|
||||||
CXXRecordDecl *NamingClass = 0; // because lookup ignores member operators
|
CXXRecordDecl *NamingClass = 0; // because lookup ignores member operators
|
||||||
UnresolvedLookupExpr *Fn
|
UnresolvedLookupExpr *Fn
|
||||||
= UnresolvedLookupExpr::Create(Context, NamingClass,
|
= UnresolvedLookupExpr::Create(Context, NamingClass,
|
||||||
0, SourceRange(), OpNameInfo,
|
NestedNameSpecifierLoc(), OpNameInfo,
|
||||||
/*ADL*/ true, IsOverloaded(Fns),
|
/*ADL*/ true, IsOverloaded(Fns),
|
||||||
Fns.begin(), Fns.end());
|
Fns.begin(), Fns.end());
|
||||||
return Owned(new (Context) CXXOperatorCallExpr(Context, Op, Fn,
|
return Owned(new (Context) CXXOperatorCallExpr(Context, Op, Fn,
|
||||||
&Args[0], NumArgs,
|
&Args[0], NumArgs,
|
||||||
Context.DependentTy,
|
Context.DependentTy,
|
||||||
VK_RValue,
|
VK_RValue,
|
||||||
OpLoc));
|
OpLoc));
|
||||||
|
@ -7956,8 +7954,9 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
|
||||||
// TODO: provide better source location info in DNLoc component.
|
// TODO: provide better source location info in DNLoc component.
|
||||||
DeclarationNameInfo OpNameInfo(OpName, OpLoc);
|
DeclarationNameInfo OpNameInfo(OpName, OpLoc);
|
||||||
UnresolvedLookupExpr *Fn
|
UnresolvedLookupExpr *Fn
|
||||||
= UnresolvedLookupExpr::Create(Context, NamingClass, 0, SourceRange(),
|
= UnresolvedLookupExpr::Create(Context, NamingClass,
|
||||||
OpNameInfo, /*ADL*/ true, IsOverloaded(Fns),
|
NestedNameSpecifierLoc(), OpNameInfo,
|
||||||
|
/*ADL*/ true, IsOverloaded(Fns),
|
||||||
Fns.begin(), Fns.end());
|
Fns.begin(), Fns.end());
|
||||||
return Owned(new (Context) CXXOperatorCallExpr(Context, Op, Fn,
|
return Owned(new (Context) CXXOperatorCallExpr(Context, Op, Fn,
|
||||||
Args, 2,
|
Args, 2,
|
||||||
|
@ -8187,7 +8186,7 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
|
||||||
OpNameInfo.setCXXOperatorNameRange(SourceRange(LLoc, RLoc));
|
OpNameInfo.setCXXOperatorNameRange(SourceRange(LLoc, RLoc));
|
||||||
UnresolvedLookupExpr *Fn
|
UnresolvedLookupExpr *Fn
|
||||||
= UnresolvedLookupExpr::Create(Context, NamingClass,
|
= UnresolvedLookupExpr::Create(Context, NamingClass,
|
||||||
0, SourceRange(), OpNameInfo,
|
NestedNameSpecifierLoc(), OpNameInfo,
|
||||||
/*ADL*/ true, /*Overloaded*/ false,
|
/*ADL*/ true, /*Overloaded*/ false,
|
||||||
UnresolvedSetIterator(),
|
UnresolvedSetIterator(),
|
||||||
UnresolvedSetIterator());
|
UnresolvedSetIterator());
|
||||||
|
@ -8929,9 +8928,10 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found,
|
||||||
TemplateArgs = &TemplateArgsBuffer;
|
TemplateArgs = &TemplateArgsBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Nested-name-specifier source location information for DeclRefExpr.
|
||||||
return DeclRefExpr::Create(Context,
|
return DeclRefExpr::Create(Context,
|
||||||
ULE->getQualifier(),
|
ULE->getQualifier(),
|
||||||
ULE->getQualifierRange(),
|
ULE->getQualifierLoc().getSourceRange(),
|
||||||
Fn,
|
Fn,
|
||||||
ULE->getNameLoc(),
|
ULE->getNameLoc(),
|
||||||
Fn->getType(),
|
Fn->getType(),
|
||||||
|
@ -8952,10 +8952,11 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found,
|
||||||
// If we're filling in a static method where we used to have an
|
// If we're filling in a static method where we used to have an
|
||||||
// implicit member access, rewrite to a simple decl ref.
|
// implicit member access, rewrite to a simple decl ref.
|
||||||
if (MemExpr->isImplicitAccess()) {
|
if (MemExpr->isImplicitAccess()) {
|
||||||
|
// FIXME: Source location information for DeclRefExpr
|
||||||
if (cast<CXXMethodDecl>(Fn)->isStatic()) {
|
if (cast<CXXMethodDecl>(Fn)->isStatic()) {
|
||||||
return DeclRefExpr::Create(Context,
|
return DeclRefExpr::Create(Context,
|
||||||
MemExpr->getQualifier(),
|
MemExpr->getQualifier(),
|
||||||
MemExpr->getQualifierRange(),
|
MemExpr->getQualifierLoc().getSourceRange(),
|
||||||
Fn,
|
Fn,
|
||||||
MemExpr->getMemberLoc(),
|
MemExpr->getMemberLoc(),
|
||||||
Fn->getType(),
|
Fn->getType(),
|
||||||
|
@ -8964,7 +8965,7 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found,
|
||||||
} else {
|
} else {
|
||||||
SourceLocation Loc = MemExpr->getMemberLoc();
|
SourceLocation Loc = MemExpr->getMemberLoc();
|
||||||
if (MemExpr->getQualifier())
|
if (MemExpr->getQualifier())
|
||||||
Loc = MemExpr->getQualifierRange().getBegin();
|
Loc = MemExpr->getQualifierLoc().getBeginLoc();
|
||||||
Base = new (Context) CXXThisExpr(Loc,
|
Base = new (Context) CXXThisExpr(Loc,
|
||||||
MemExpr->getBaseType(),
|
MemExpr->getBaseType(),
|
||||||
/*isImplicit=*/true);
|
/*isImplicit=*/true);
|
||||||
|
@ -8972,10 +8973,11 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found,
|
||||||
} else
|
} else
|
||||||
Base = MemExpr->getBase();
|
Base = MemExpr->getBase();
|
||||||
|
|
||||||
|
// FIXME: Source location information for MemberExpr
|
||||||
return MemberExpr::Create(Context, Base,
|
return MemberExpr::Create(Context, Base,
|
||||||
MemExpr->isArrow(),
|
MemExpr->isArrow(),
|
||||||
MemExpr->getQualifier(),
|
MemExpr->getQualifier(),
|
||||||
MemExpr->getQualifierRange(),
|
MemExpr->getQualifierLoc().getSourceRange(),
|
||||||
Fn,
|
Fn,
|
||||||
Found,
|
Found,
|
||||||
MemExpr->getMemberNameInfo(),
|
MemExpr->getMemberNameInfo(),
|
||||||
|
|
|
@ -1832,8 +1832,8 @@ TypeResult Sema::ActOnTagTemplateIdType(CXXScopeSpec &SS,
|
||||||
}
|
}
|
||||||
|
|
||||||
ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,
|
ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,
|
||||||
LookupResult &R,
|
LookupResult &R,
|
||||||
bool RequiresADL,
|
bool RequiresADL,
|
||||||
const TemplateArgumentListInfo &TemplateArgs) {
|
const TemplateArgumentListInfo &TemplateArgs) {
|
||||||
// FIXME: Can we do any checking at this point? I guess we could check the
|
// FIXME: Can we do any checking at this point? I guess we could check the
|
||||||
// template arguments that we have against the template name, if the template
|
// template arguments that we have against the template name, if the template
|
||||||
|
@ -1849,19 +1849,12 @@ ExprResult Sema::BuildTemplateIdExpr(const CXXScopeSpec &SS,
|
||||||
assert(!R.empty() && "empty lookup results when building templateid");
|
assert(!R.empty() && "empty lookup results when building templateid");
|
||||||
assert(!R.isAmbiguous() && "ambiguous lookup when building templateid");
|
assert(!R.isAmbiguous() && "ambiguous lookup when building templateid");
|
||||||
|
|
||||||
NestedNameSpecifier *Qualifier = 0;
|
|
||||||
SourceRange QualifierRange;
|
|
||||||
if (SS.isSet()) {
|
|
||||||
Qualifier = static_cast<NestedNameSpecifier*>(SS.getScopeRep());
|
|
||||||
QualifierRange = SS.getRange();
|
|
||||||
}
|
|
||||||
|
|
||||||
// We don't want lookup warnings at this point.
|
// We don't want lookup warnings at this point.
|
||||||
R.suppressDiagnostics();
|
R.suppressDiagnostics();
|
||||||
|
|
||||||
UnresolvedLookupExpr *ULE
|
UnresolvedLookupExpr *ULE
|
||||||
= UnresolvedLookupExpr::Create(Context, R.getNamingClass(),
|
= UnresolvedLookupExpr::Create(Context, R.getNamingClass(),
|
||||||
Qualifier, QualifierRange,
|
SS.getWithLocInContext(Context),
|
||||||
R.getLookupNameInfo(),
|
R.getLookupNameInfo(),
|
||||||
RequiresADL, TemplateArgs,
|
RequiresADL, TemplateArgs,
|
||||||
R.begin(), R.end());
|
R.begin(), R.end());
|
||||||
|
|
|
@ -2000,13 +2000,12 @@ public:
|
||||||
QualType BaseType,
|
QualType BaseType,
|
||||||
SourceLocation OperatorLoc,
|
SourceLocation OperatorLoc,
|
||||||
bool IsArrow,
|
bool IsArrow,
|
||||||
NestedNameSpecifier *Qualifier,
|
NestedNameSpecifierLoc QualifierLoc,
|
||||||
SourceRange QualifierRange,
|
|
||||||
NamedDecl *FirstQualifierInScope,
|
NamedDecl *FirstQualifierInScope,
|
||||||
LookupResult &R,
|
LookupResult &R,
|
||||||
const TemplateArgumentListInfo *TemplateArgs) {
|
const TemplateArgumentListInfo *TemplateArgs) {
|
||||||
CXXScopeSpec SS;
|
CXXScopeSpec SS;
|
||||||
SS.MakeTrivial(SemaRef.Context, Qualifier, QualifierRange);
|
SS.Adopt(QualifierLoc);
|
||||||
|
|
||||||
return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
|
return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
|
||||||
OperatorLoc, IsArrow,
|
OperatorLoc, IsArrow,
|
||||||
|
@ -6779,14 +6778,13 @@ TreeTransform<Derived>::TransformUnresolvedLookupExpr(
|
||||||
|
|
||||||
// Rebuild the nested-name qualifier, if present.
|
// Rebuild the nested-name qualifier, if present.
|
||||||
CXXScopeSpec SS;
|
CXXScopeSpec SS;
|
||||||
NestedNameSpecifier *Qualifier = 0;
|
if (Old->getQualifierLoc()) {
|
||||||
if (Old->getQualifier()) {
|
NestedNameSpecifierLoc QualifierLoc
|
||||||
Qualifier = getDerived().TransformNestedNameSpecifier(Old->getQualifier(),
|
= getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
|
||||||
Old->getQualifierRange());
|
if (!QualifierLoc)
|
||||||
if (!Qualifier)
|
|
||||||
return ExprError();
|
return ExprError();
|
||||||
|
|
||||||
SS.MakeTrivial(SemaRef.Context, Qualifier, Old->getQualifierRange());
|
SS.Adopt(QualifierLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Old->getNamingClass()) {
|
if (Old->getNamingClass()) {
|
||||||
|
@ -7139,12 +7137,11 @@ TreeTransform<Derived>::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old)
|
||||||
BaseType = getDerived().TransformType(Old->getBaseType());
|
BaseType = getDerived().TransformType(Old->getBaseType());
|
||||||
}
|
}
|
||||||
|
|
||||||
NestedNameSpecifier *Qualifier = 0;
|
NestedNameSpecifierLoc QualifierLoc;
|
||||||
if (Old->getQualifier()) {
|
if (Old->getQualifierLoc()) {
|
||||||
Qualifier
|
QualifierLoc
|
||||||
= getDerived().TransformNestedNameSpecifier(Old->getQualifier(),
|
= getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
|
||||||
Old->getQualifierRange());
|
if (!QualifierLoc)
|
||||||
if (Qualifier == 0)
|
|
||||||
return ExprError();
|
return ExprError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7212,8 +7209,7 @@ TreeTransform<Derived>::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old)
|
||||||
BaseType,
|
BaseType,
|
||||||
Old->getOperatorLoc(),
|
Old->getOperatorLoc(),
|
||||||
Old->isArrow(),
|
Old->isArrow(),
|
||||||
Qualifier,
|
QualifierLoc,
|
||||||
Old->getQualifierRange(),
|
|
||||||
FirstQualifierInScope,
|
FirstQualifierInScope,
|
||||||
R,
|
R,
|
||||||
(Old->hasExplicitTemplateArgs()
|
(Old->hasExplicitTemplateArgs()
|
||||||
|
|
|
@ -1253,24 +1253,23 @@ void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
|
||||||
E->initializeResults(*Reader.getContext(), Decls.begin(), Decls.end());
|
E->initializeResults(*Reader.getContext(), Decls.begin(), Decls.end());
|
||||||
|
|
||||||
ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
|
ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
|
||||||
E->setQualifier(Reader.ReadNestedNameSpecifier(Record, Idx));
|
E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
|
||||||
E->setQualifierRange(ReadSourceRange(Record, Idx));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
|
void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
|
||||||
VisitOverloadExpr(E);
|
VisitOverloadExpr(E);
|
||||||
E->setArrow(Record[Idx++]);
|
E->IsArrow = Record[Idx++];
|
||||||
E->setHasUnresolvedUsing(Record[Idx++]);
|
E->HasUnresolvedUsing = Record[Idx++];
|
||||||
E->setBase(Reader.ReadSubExpr());
|
E->Base = Reader.ReadSubExpr();
|
||||||
E->setBaseType(Reader.GetType(Record[Idx++]));
|
E->BaseType = Reader.GetType(Record[Idx++]);
|
||||||
E->setOperatorLoc(ReadSourceLocation(Record, Idx));
|
E->OperatorLoc = ReadSourceLocation(Record, Idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
|
void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
|
||||||
VisitOverloadExpr(E);
|
VisitOverloadExpr(E);
|
||||||
E->setRequiresADL(Record[Idx++]);
|
E->RequiresADL = Record[Idx++];
|
||||||
E->setOverloaded(Record[Idx++]);
|
E->Overloaded = Record[Idx++];
|
||||||
E->setNamingClass(cast_or_null<CXXRecordDecl>(Reader.GetDecl(Record[Idx++])));
|
E->NamingClass = cast_or_null<CXXRecordDecl>(Reader.GetDecl(Record[Idx++]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
|
void ASTStmtReader::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
|
||||||
|
|
|
@ -1252,8 +1252,7 @@ void ASTStmtWriter::VisitOverloadExpr(OverloadExpr *E) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Writer.AddDeclarationNameInfo(E->NameInfo, Record);
|
Writer.AddDeclarationNameInfo(E->NameInfo, Record);
|
||||||
Writer.AddNestedNameSpecifier(E->getQualifier(), Record);
|
Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
|
||||||
Writer.AddSourceRange(E->getQualifierRange(), Record);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
|
void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
|
||||||
|
|
|
@ -58,7 +58,27 @@ struct X3 {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// RUN: c-index-test -test-annotate-tokens=%s:13:1:60:1 %s | FileCheck %s
|
namespace outer {
|
||||||
|
namespace inner {
|
||||||
|
void f(int);
|
||||||
|
void f(float);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
struct X4 {
|
||||||
|
typedef T type;
|
||||||
|
void g(int);
|
||||||
|
void g(float);
|
||||||
|
|
||||||
|
void h(T t) {
|
||||||
|
::outer_alias::inner::f(t);
|
||||||
|
::X4<type>::g(t);
|
||||||
|
this->::X4<type>::g(t);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// RUN: c-index-test -test-annotate-tokens=%s:13:1:78:1 %s | FileCheck %s
|
||||||
|
|
||||||
// CHECK: Keyword: "using" [14:1 - 14:6] UsingDeclaration=vector[4:12]
|
// CHECK: Keyword: "using" [14:1 - 14:6] UsingDeclaration=vector[4:12]
|
||||||
// CHECK: Identifier: "outer_alias" [14:7 - 14:18] NamespaceRef=outer_alias:10:11
|
// CHECK: Identifier: "outer_alias" [14:7 - 14:18] NamespaceRef=outer_alias:10:11
|
||||||
|
@ -148,3 +168,37 @@ struct X3 {
|
||||||
// CHECK: Punctuation: ">" [57:59 - 57:60] UnexposedExpr=
|
// CHECK: Punctuation: ">" [57:59 - 57:60] UnexposedExpr=
|
||||||
// CHECK: Punctuation: "(" [57:60 - 57:61] CallExpr=
|
// CHECK: Punctuation: "(" [57:60 - 57:61] CallExpr=
|
||||||
// CHECK: Punctuation: ")" [57:61 - 57:62] CallExpr=
|
// CHECK: Punctuation: ")" [57:61 - 57:62] CallExpr=
|
||||||
|
|
||||||
|
// Unresolved member and non-member references
|
||||||
|
// CHECK: Punctuation: "::" [75:5 - 75:7] UnexposedExpr=[63:10, 64:10]
|
||||||
|
// CHECK: Identifier: "outer_alias" [75:7 - 75:18] NamespaceRef=outer_alias:10:11
|
||||||
|
// CHECK: Punctuation: "::" [75:18 - 75:20] UnexposedExpr=[63:10, 64:10]
|
||||||
|
// CHECK: Identifier: "inner" [75:20 - 75:25] NamespaceRef=inner:62:13
|
||||||
|
// CHECK: Punctuation: "::" [75:25 - 75:27] UnexposedExpr=[63:10, 64:10]
|
||||||
|
// CHECK: Identifier: "f" [75:27 - 75:28] OverloadedDeclRef=f[63:10, 64:10]
|
||||||
|
// CHECK: Punctuation: "(" [75:28 - 75:29] CallExpr=
|
||||||
|
// CHECK: Identifier: "t" [75:29 - 75:30] DeclRefExpr=t:74:12
|
||||||
|
// CHECK: Punctuation: ")" [75:30 - 75:31] CallExpr=
|
||||||
|
// CHECK: Punctuation: "::" [76:5 - 76:7] UnexposedExpr=[71:8, 72:8]
|
||||||
|
// CHECK: Identifier: "X4" [76:7 - 76:9] TemplateRef=X4:69:8
|
||||||
|
// CHECK: Punctuation: "<" [76:9 - 76:10] UnexposedExpr=[71:8, 72:8]
|
||||||
|
// CHECK: Identifier: "type" [76:10 - 76:14] TypeRef=type:70:13
|
||||||
|
// CHECK: Punctuation: ">" [76:14 - 76:15] UnexposedExpr=[71:8, 72:8]
|
||||||
|
// CHECK: Punctuation: "::" [76:15 - 76:17] UnexposedExpr=[71:8, 72:8]
|
||||||
|
// CHECK: Identifier: "g" [76:17 - 76:18] OverloadedDeclRef=g[71:8, 72:8]
|
||||||
|
// CHECK: Punctuation: "(" [76:18 - 76:19] CallExpr=
|
||||||
|
// CHECK: Identifier: "t" [76:19 - 76:20] DeclRefExpr=t:74:12
|
||||||
|
// CHECK: Punctuation: ")" [76:20 - 76:21] CallExpr=
|
||||||
|
// CHECK: Punctuation: ";" [76:21 - 76:22] UnexposedStmt=
|
||||||
|
// CHECK: Keyword: "this" [77:5 - 77:9] UnexposedExpr=
|
||||||
|
// CHECK: Punctuation: "->" [77:9 - 77:11] UnexposedExpr=
|
||||||
|
// CHECK: Punctuation: "::" [77:11 - 77:13] UnexposedExpr=
|
||||||
|
// CHECK: Identifier: "X4" [77:13 - 77:15] TemplateRef=X4:69:8
|
||||||
|
// CHECK: Punctuation: "<" [77:15 - 77:16] UnexposedExpr=
|
||||||
|
// CHECK: Identifier: "type" [77:16 - 77:20] TypeRef=type:70:13
|
||||||
|
// CHECK: Punctuation: ">" [77:20 - 77:21] UnexposedExpr=
|
||||||
|
// CHECK: Punctuation: "::" [77:21 - 77:23] UnexposedExpr=
|
||||||
|
// CHECK: Identifier: "g" [77:23 - 77:24] UnexposedExpr=
|
||||||
|
// CHECK: Punctuation: "(" [77:24 - 77:25] CallExpr=
|
||||||
|
// CHECK: Identifier: "t" [77:25 - 77:26] DeclRefExpr=t:74:12
|
||||||
|
// CHECK: Punctuation: ")" [77:26 - 77:27] CallExpr=
|
||||||
|
|
|
@ -2157,8 +2157,8 @@ bool CursorVisitor::RunVisitorWorkList(VisitorWorkList &WL) {
|
||||||
case VisitorJob::OverloadExprPartsKind: {
|
case VisitorJob::OverloadExprPartsKind: {
|
||||||
OverloadExpr *O = cast<OverloadExprParts>(&LI)->get();
|
OverloadExpr *O = cast<OverloadExprParts>(&LI)->get();
|
||||||
// Visit the nested-name-specifier.
|
// Visit the nested-name-specifier.
|
||||||
if (NestedNameSpecifier *Qualifier = O->getQualifier())
|
if (NestedNameSpecifierLoc QualifierLoc = O->getQualifierLoc())
|
||||||
if (VisitNestedNameSpecifier(Qualifier, O->getQualifierRange()))
|
if (VisitNestedNameSpecifierLoc(QualifierLoc))
|
||||||
return true;
|
return true;
|
||||||
// Visit the declaration name.
|
// Visit the declaration name.
|
||||||
if (VisitDeclarationNameInfo(O->getNameInfo()))
|
if (VisitDeclarationNameInfo(O->getNameInfo()))
|
||||||
|
|
Loading…
Reference in New Issue