[cfe-commits] r80628 - in /cfe/trunk: include/clang/AST/Expr.h include/clang/AST/ExprCXX.h include/clang/AST/StmtNodes.def lib/AST/Expr.cpp lib/AST/StmtPrinter.cpp lib/AST/StmtProfile.cpp lib/Analysis/GRExprEngine.cpp lib/CodeGen/CGCXX.cpp lib/CodeGen/CGExpr.cpp lib/Sema/SemaChecking.cpp lib/Sema/SemaExpr.cpp lib/Sema/TreeTransform.h
Douglas Gregor
dgregor at apple.com
Mon Aug 31 14:41:49 PDT 2009
Author: dgregor
Date: Mon Aug 31 16:41:48 2009
New Revision: 80628
URL: http://llvm.org/viewvc/llvm-project?rev=80628&view=rev
Log:
Rename CXXQualifiedMemberExpr -> CXXAdornedMemberExpr, since we will
also be adding explicit template arguments as an additional
"adornment". No functionality change.
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/include/clang/AST/StmtNodes.def
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Analysis/GRExprEngine.cpp
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/TreeTransform.h
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=80628&r1=80627&r2=80628&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Mon Aug 31 16:41:48 2009
@@ -33,7 +33,7 @@
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 @@
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 @@
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();
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=80628&r1=80627&r2=80628&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Mon Aug 31 16:41:48 2009
@@ -1286,8 +1286,9 @@
};
/// \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 @@
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 @@
/// 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
Modified: cfe/trunk/include/clang/AST/StmtNodes.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtNodes.def?rev=80628&r1=80627&r2=80628&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/StmtNodes.def (original)
+++ cfe/trunk/include/clang/AST/StmtNodes.def Mon Aug 31 16:41:48 2009
@@ -134,7 +134,7 @@
EXPR(CXXExprWithTemporaries , Expr)
EXPR(CXXTemporaryObjectExpr , CXXConstructExpr)
EXPR(CXXUnresolvedConstructExpr, Expr)
-EXPR(CXXQualifiedMemberExpr, MemberExpr)
+EXPR(CXXAdornedMemberExpr, MemberExpr)
EXPR(CXXUnresolvedMemberExpr, Expr)
// Obj-C Expressions.
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=80628&r1=80627&r2=80628&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Mon Aug 31 16:41:48 2009
@@ -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 @@
}
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 @@
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 @@
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 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; }
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=80628&r1=80627&r2=80628&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Mon Aug 31 16:41:48 2009
@@ -1126,7 +1126,7 @@
OS << ")";
}
-void StmtPrinter::VisitCXXQualifiedMemberExpr(CXXQualifiedMemberExpr *Node) {
+void StmtPrinter::VisitCXXAdornedMemberExpr(CXXAdornedMemberExpr *Node) {
// FIXME: Suppress printing implicit bases (like "this")
PrintExpr(Node->getBase());
OS << (Node->isArrow() ? "->" : ".");
Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=80628&r1=80627&r2=80628&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Mon Aug 31 16:41:48 2009
@@ -546,7 +546,7 @@
VisitType(S->getTypeAsWritten());
}
-void StmtProfiler::VisitCXXQualifiedMemberExpr(CXXQualifiedMemberExpr *S) {
+void StmtProfiler::VisitCXXAdornedMemberExpr(CXXAdornedMemberExpr *S) {
VisitMemberExpr(S);
VisitNestedNameSpecifier(S->getQualifier());
}
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=80628&r1=80627&r2=80628&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Mon Aug 31 16:41:48 2009
@@ -407,7 +407,7 @@
break;
case Stmt::MemberExprClass:
- case Stmt::CXXQualifiedMemberExprClass:
+ case Stmt::CXXAdornedMemberExprClass:
VisitMemberExpr(cast<MemberExpr>(S), Pred, Dst, false);
break;
@@ -514,7 +514,7 @@
return;
case Stmt::MemberExprClass:
- case Stmt::CXXQualifiedMemberExprClass:
+ case Stmt::CXXAdornedMemberExprClass:
VisitMemberExpr(cast<MemberExpr>(Ex), Pred, Dst, true);
return;
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=80628&r1=80627&r2=80628&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Mon Aug 31 16:41:48 2009
@@ -216,9 +216,9 @@
// 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,
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=80628&r1=80627&r2=80628&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Aug 31 16:41:48 2009
@@ -241,7 +241,7 @@
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));
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=80628&r1=80627&r2=80628&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Aug 31 16:41:48 2009
@@ -1457,7 +1457,7 @@
// 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.
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=80628&r1=80627&r2=80628&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Aug 31 16:41:48 2009
@@ -878,15 +878,15 @@
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 @@
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.
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=80628&r1=80627&r2=80628&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Aug 31 16:41:48 2009
@@ -1425,16 +1425,18 @@
///
/// 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 @@
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 @@
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 @@
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 @@
SourceLocation FakeOperatorLoc
= SemaRef.PP.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
- return getDerived().RebuildCXXQualifiedMemberExpr(move(Base),
+ return getDerived().RebuildCXXAdornedMemberExpr(move(Base),
FakeOperatorLoc,
E->isArrow(),
Qualifier,
More information about the cfe-commits
mailing list