forked from OSchip/llvm-project
Rename CXXQualifiedMemberExpr -> CXXAdornedMemberExpr, since we will
also be adding explicit template arguments as an additional "adornment". No functionality change. llvm-svn: 80628
This commit is contained in:
parent
e4cfcc3081
commit
96ee789d33
|
@ -33,7 +33,7 @@ namespace clang {
|
|||
class BlockDecl;
|
||||
class CXXOperatorCallExpr;
|
||||
class CXXMemberCallExpr;
|
||||
class CXXQualifiedMemberExpr;
|
||||
class CXXAdornedMemberExpr;
|
||||
|
||||
/// Expr - This represents one expression. Note that Expr's are subclasses of
|
||||
/// Stmt. This allows an expression to be transparently used any place a Stmt
|
||||
|
@ -1078,6 +1078,11 @@ public:
|
|||
NamedDecl *getMemberDecl() const { return MemberDecl; }
|
||||
void setMemberDecl(NamedDecl *D) { MemberDecl = D; }
|
||||
|
||||
/// \brief Determines whether this adorned member expression actually had
|
||||
/// a C++ nested-name-specifier prior to the name of the member, e.g.,
|
||||
/// x->Base::foo.
|
||||
bool hasQualifier() const;
|
||||
|
||||
bool isArrow() const { return IsArrow; }
|
||||
void setArrow(bool A) { IsArrow = A; }
|
||||
|
||||
|
@ -1099,10 +1104,10 @@ public:
|
|||
|
||||
static bool classof(const Stmt *T) {
|
||||
return T->getStmtClass() == MemberExprClass ||
|
||||
T->getStmtClass() == CXXQualifiedMemberExprClass;
|
||||
T->getStmtClass() == CXXAdornedMemberExprClass;
|
||||
}
|
||||
static bool classof(const MemberExpr *) { return true; }
|
||||
static bool classof(const CXXQualifiedMemberExpr *) { return true; }
|
||||
static bool classof(const CXXAdornedMemberExpr *) { return true; }
|
||||
|
||||
// Iterators
|
||||
virtual child_iterator child_begin();
|
||||
|
|
|
@ -1286,8 +1286,9 @@ public:
|
|||
};
|
||||
|
||||
/// \brief Represents a C++ member access expression that was written using
|
||||
/// a qualified name, e.g., "x->Base::f()".
|
||||
class CXXQualifiedMemberExpr : public MemberExpr {
|
||||
/// either a qualified name, e.g., "x->Base::f()" or originally had
|
||||
/// explicitly-specified template arguments (TODO!).
|
||||
class CXXAdornedMemberExpr : public MemberExpr {
|
||||
/// QualifierRange - The source range that covers the
|
||||
/// nested-name-specifier.
|
||||
SourceRange QualifierRange;
|
||||
|
@ -1297,10 +1298,10 @@ class CXXQualifiedMemberExpr : public MemberExpr {
|
|||
NestedNameSpecifier *Qualifier;
|
||||
|
||||
public:
|
||||
CXXQualifiedMemberExpr(Expr *base, bool isarrow, NestedNameSpecifier *Qual,
|
||||
SourceRange QualRange, NamedDecl *memberdecl,
|
||||
SourceLocation l, QualType ty)
|
||||
: MemberExpr(CXXQualifiedMemberExprClass, base, isarrow, memberdecl, l, ty),
|
||||
CXXAdornedMemberExpr(Expr *base, bool isarrow, NestedNameSpecifier *Qual,
|
||||
SourceRange QualRange, NamedDecl *memberdecl,
|
||||
SourceLocation l, QualType ty)
|
||||
: MemberExpr(CXXAdornedMemberExprClass, base, isarrow, memberdecl, l, ty),
|
||||
QualifierRange(QualRange), Qualifier(Qual) { }
|
||||
|
||||
/// \brief Retrieve the source range of the nested-name-specifier that
|
||||
|
@ -1311,10 +1312,14 @@ public:
|
|||
/// member reference expression.
|
||||
NestedNameSpecifier *getQualifier() const { return Qualifier; }
|
||||
|
||||
/// \brief Determines whether this adorned C++ member expression has a
|
||||
/// nested-name-specifier associated with it.
|
||||
bool hasQualifier() const { return getQualifier() != 0; }
|
||||
|
||||
static bool classof(const Stmt *T) {
|
||||
return T->getStmtClass() == CXXQualifiedMemberExprClass;
|
||||
return T->getStmtClass() == CXXAdornedMemberExprClass;
|
||||
}
|
||||
static bool classof(const CXXQualifiedMemberExpr *) { return true; }
|
||||
static bool classof(const CXXAdornedMemberExpr *) { return true; }
|
||||
};
|
||||
|
||||
/// \brief Represents a C++ member access expression where the actual member
|
||||
|
|
|
@ -134,7 +134,7 @@ EXPR(CXXBindTemporaryExpr , Expr)
|
|||
EXPR(CXXExprWithTemporaries , Expr)
|
||||
EXPR(CXXTemporaryObjectExpr , CXXConstructExpr)
|
||||
EXPR(CXXUnresolvedConstructExpr, Expr)
|
||||
EXPR(CXXQualifiedMemberExpr, MemberExpr)
|
||||
EXPR(CXXAdornedMemberExpr, MemberExpr)
|
||||
EXPR(CXXUnresolvedMemberExpr, Expr)
|
||||
|
||||
// Obj-C Expressions.
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/AST/Expr.h"
|
||||
#include "clang/AST/ExprCXX.h"
|
||||
#include "clang/AST/APValue.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/AST/DeclObjC.h"
|
||||
|
@ -497,7 +498,7 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
|
|||
}
|
||||
|
||||
case MemberExprClass:
|
||||
case CXXQualifiedMemberExprClass:
|
||||
case CXXAdornedMemberExprClass:
|
||||
// If the base pointer or element is to a volatile pointer/field, accessing
|
||||
// it is a side effect.
|
||||
if (getType().isVolatileQualified())
|
||||
|
@ -686,7 +687,7 @@ Expr::isLvalueResult Expr::isLvalueInternal(ASTContext &Ctx) const {
|
|||
break;
|
||||
}
|
||||
case MemberExprClass:
|
||||
case CXXQualifiedMemberExprClass: {
|
||||
case CXXAdornedMemberExprClass: {
|
||||
const MemberExpr *m = cast<MemberExpr>(this);
|
||||
if (Ctx.getLangOptions().CPlusPlus) { // C++ [expr.ref]p4:
|
||||
NamedDecl *Member = m->getMemberDecl();
|
||||
|
@ -958,7 +959,7 @@ bool Expr::isOBJCGCCandidate(ASTContext &Ctx) const {
|
|||
return false;
|
||||
}
|
||||
case MemberExprClass:
|
||||
case CXXQualifiedMemberExprClass: {
|
||||
case CXXAdornedMemberExprClass: {
|
||||
const MemberExpr *M = cast<MemberExpr>(this);
|
||||
return M->getBase()->isOBJCGCCandidate(Ctx);
|
||||
}
|
||||
|
@ -1916,6 +1917,13 @@ Stmt::child_iterator CallExpr::child_end() {
|
|||
Stmt::child_iterator MemberExpr::child_begin() { return &Base; }
|
||||
Stmt::child_iterator MemberExpr::child_end() { return &Base+1; }
|
||||
|
||||
bool MemberExpr::hasQualifier() const {
|
||||
if (const CXXAdornedMemberExpr *A = dyn_cast<CXXAdornedMemberExpr>(this))
|
||||
return A->hasQualifier();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ExtVectorElementExpr
|
||||
Stmt::child_iterator ExtVectorElementExpr::child_begin() { return &Base; }
|
||||
Stmt::child_iterator ExtVectorElementExpr::child_end() { return &Base+1; }
|
||||
|
|
|
@ -1126,7 +1126,7 @@ StmtPrinter::VisitCXXUnresolvedConstructExpr(
|
|||
OS << ")";
|
||||
}
|
||||
|
||||
void StmtPrinter::VisitCXXQualifiedMemberExpr(CXXQualifiedMemberExpr *Node) {
|
||||
void StmtPrinter::VisitCXXAdornedMemberExpr(CXXAdornedMemberExpr *Node) {
|
||||
// FIXME: Suppress printing implicit bases (like "this")
|
||||
PrintExpr(Node->getBase());
|
||||
OS << (Node->isArrow() ? "->" : ".");
|
||||
|
|
|
@ -546,7 +546,7 @@ StmtProfiler::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *S) {
|
|||
VisitType(S->getTypeAsWritten());
|
||||
}
|
||||
|
||||
void StmtProfiler::VisitCXXQualifiedMemberExpr(CXXQualifiedMemberExpr *S) {
|
||||
void StmtProfiler::VisitCXXAdornedMemberExpr(CXXAdornedMemberExpr *S) {
|
||||
VisitMemberExpr(S);
|
||||
VisitNestedNameSpecifier(S->getQualifier());
|
||||
}
|
||||
|
|
|
@ -407,7 +407,7 @@ void GRExprEngine::Visit(Stmt* S, ExplodedNode* Pred, ExplodedNodeSet& Dst) {
|
|||
break;
|
||||
|
||||
case Stmt::MemberExprClass:
|
||||
case Stmt::CXXQualifiedMemberExprClass:
|
||||
case Stmt::CXXAdornedMemberExprClass:
|
||||
VisitMemberExpr(cast<MemberExpr>(S), Pred, Dst, false);
|
||||
break;
|
||||
|
||||
|
@ -514,7 +514,7 @@ void GRExprEngine::VisitLValue(Expr* Ex, ExplodedNode* Pred,
|
|||
return;
|
||||
|
||||
case Stmt::MemberExprClass:
|
||||
case Stmt::CXXQualifiedMemberExprClass:
|
||||
case Stmt::CXXAdornedMemberExprClass:
|
||||
VisitMemberExpr(cast<MemberExpr>(Ex), Pred, Dst, true);
|
||||
return;
|
||||
|
||||
|
|
|
@ -216,9 +216,9 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE) {
|
|||
// Explicit qualification with the scope operator (5.1) suppresses the
|
||||
// virtual call mechanism.
|
||||
llvm::Value *Callee;
|
||||
if (MD->isVirtual() && !isa<CXXQualifiedMemberExpr>(ME)) {
|
||||
if (MD->isVirtual() && !ME->hasQualifier())
|
||||
Callee = BuildVirtualCall(MD, This, Ty);
|
||||
} else
|
||||
else
|
||||
Callee = CGM.GetAddrOfFunction(GlobalDecl(MD), Ty);
|
||||
|
||||
return EmitCXXMemberCall(MD, Callee, This,
|
||||
|
|
|
@ -241,7 +241,7 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) {
|
|||
case Expr::ExtVectorElementExprClass:
|
||||
return EmitExtVectorElementExpr(cast<ExtVectorElementExpr>(E));
|
||||
case Expr::MemberExprClass:
|
||||
case Stmt::CXXQualifiedMemberExprClass:
|
||||
case Stmt::CXXAdornedMemberExprClass:
|
||||
return EmitMemberExpr(cast<MemberExpr>(E));
|
||||
case Expr::CompoundLiteralExprClass:
|
||||
return EmitCompoundLiteralLValue(cast<CompoundLiteralExpr>(E));
|
||||
|
|
|
@ -1457,7 +1457,7 @@ static DeclRefExpr* EvalVal(Expr *E) {
|
|||
|
||||
// Accesses to members are potential references to data on the stack.
|
||||
case Stmt::MemberExprClass:
|
||||
case Stmt::CXXQualifiedMemberExprClass: {
|
||||
case Stmt::CXXAdornedMemberExprClass: {
|
||||
MemberExpr *M = cast<MemberExpr>(E);
|
||||
|
||||
// Check for indirect access. We only want direct field accesses.
|
||||
|
|
|
@ -878,15 +878,15 @@ Sema::PerformObjectMemberConversion(Expr *&From, NamedDecl *Member) {
|
|||
return false;
|
||||
}
|
||||
|
||||
/// \brief Build a MemberExpr or CXXQualifiedMemberExpr, as appropriate.
|
||||
/// \brief Build a MemberExpr or CXXAdornedMemberExpr, as appropriate.
|
||||
static MemberExpr *BuildMemberExpr(ASTContext &C, Expr *Base, bool isArrow,
|
||||
const CXXScopeSpec *SS, NamedDecl *Member,
|
||||
SourceLocation Loc, QualType Ty) {
|
||||
if (SS && SS->isSet())
|
||||
return new (C) CXXQualifiedMemberExpr(Base, isArrow,
|
||||
(NestedNameSpecifier *)SS->getScopeRep(),
|
||||
SS->getRange(),
|
||||
Member, Loc, Ty);
|
||||
return new (C) CXXAdornedMemberExpr(Base, isArrow,
|
||||
(NestedNameSpecifier *)SS->getScopeRep(),
|
||||
SS->getRange(),
|
||||
Member, Loc, Ty);
|
||||
|
||||
return new (C) MemberExpr(Base, isArrow, Member, Loc, Ty);
|
||||
}
|
||||
|
@ -4837,7 +4837,7 @@ static NamedDecl *getPrimaryDecl(Expr *E) {
|
|||
case Stmt::QualifiedDeclRefExprClass:
|
||||
return cast<DeclRefExpr>(E)->getDecl();
|
||||
case Stmt::MemberExprClass:
|
||||
case Stmt::CXXQualifiedMemberExprClass:
|
||||
case Stmt::CXXAdornedMemberExprClass:
|
||||
// If this is an arrow operator, the address is an offset from
|
||||
// the base's value, so the object the base refers to is
|
||||
// irrelevant.
|
||||
|
|
|
@ -1425,16 +1425,18 @@ public:
|
|||
///
|
||||
/// By default, performs semantic analysis to build the new expression.
|
||||
/// Subclasses may override this routine to provide different behavior.
|
||||
OwningExprResult RebuildCXXQualifiedMemberExpr(ExprArg Base,
|
||||
SourceLocation OpLoc,
|
||||
bool isArrow,
|
||||
NestedNameSpecifier *Qualifier,
|
||||
SourceRange QualifierRange,
|
||||
SourceLocation MemberLoc,
|
||||
NamedDecl *Member) {
|
||||
OwningExprResult RebuildCXXAdornedMemberExpr(ExprArg Base,
|
||||
SourceLocation OpLoc,
|
||||
bool isArrow,
|
||||
NestedNameSpecifier *Qualifier,
|
||||
SourceRange QualifierRange,
|
||||
SourceLocation MemberLoc,
|
||||
NamedDecl *Member) {
|
||||
CXXScopeSpec SS;
|
||||
SS.setRange(QualifierRange);
|
||||
SS.setScopeRep(Qualifier);
|
||||
if (Qualifier) {
|
||||
SS.setRange(QualifierRange);
|
||||
SS.setScopeRep(Qualifier);
|
||||
}
|
||||
return getSema().BuildMemberReferenceExpr(/*Scope=*/0, move(Base), OpLoc,
|
||||
isArrow? tok::arrow : tok::period,
|
||||
MemberLoc,
|
||||
|
@ -1588,6 +1590,9 @@ template<typename Derived>
|
|||
NestedNameSpecifier *
|
||||
TreeTransform<Derived>::TransformNestedNameSpecifier(NestedNameSpecifier *NNS,
|
||||
SourceRange Range) {
|
||||
if (!NNS)
|
||||
return 0;
|
||||
|
||||
// Transform the prefix of this nested name specifier.
|
||||
NestedNameSpecifier *Prefix = NNS->getPrefix();
|
||||
if (Prefix) {
|
||||
|
@ -4014,8 +4019,8 @@ TreeTransform<Derived>::TransformCXXUnresolvedConstructExpr(
|
|||
|
||||
template<typename Derived>
|
||||
Sema::OwningExprResult
|
||||
TreeTransform<Derived>::TransformCXXQualifiedMemberExpr(
|
||||
CXXQualifiedMemberExpr *E) {
|
||||
TreeTransform<Derived>::TransformCXXAdornedMemberExpr(
|
||||
CXXAdornedMemberExpr *E) {
|
||||
OwningExprResult Base = getDerived().TransformExpr(E->getBase());
|
||||
if (Base.isInvalid())
|
||||
return SemaRef.ExprError();
|
||||
|
@ -4028,7 +4033,7 @@ TreeTransform<Derived>::TransformCXXQualifiedMemberExpr(
|
|||
NestedNameSpecifier *Qualifier
|
||||
= getDerived().TransformNestedNameSpecifier(E->getQualifier(),
|
||||
E->getQualifierRange());
|
||||
if (Qualifier == 0)
|
||||
if (Qualifier == 0 && E->getQualifier() != 0)
|
||||
return SemaRef.ExprError();
|
||||
|
||||
if (!getDerived().AlwaysRebuild() &&
|
||||
|
@ -4041,7 +4046,7 @@ TreeTransform<Derived>::TransformCXXQualifiedMemberExpr(
|
|||
SourceLocation FakeOperatorLoc
|
||||
= SemaRef.PP.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
|
||||
|
||||
return getDerived().RebuildCXXQualifiedMemberExpr(move(Base),
|
||||
return getDerived().RebuildCXXAdornedMemberExpr(move(Base),
|
||||
FakeOperatorLoc,
|
||||
E->isArrow(),
|
||||
Qualifier,
|
||||
|
|
Loading…
Reference in New Issue