mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-12 02:47:10 +00:00
Revert "Factor out duplicated code building a MemberExpr and marking it" and "Convert MemberExpr creation and serialization to work the same way as"
This reverts commits r362551 and r362563. Crashes during modules selfhost. llvm-svn: 362597
This commit is contained in:
parent
b42196661b
commit
9b2b8ad8b1
@ -2735,7 +2735,6 @@ class MemberExpr final
|
||||
ASTTemplateKWAndArgsInfo,
|
||||
TemplateArgumentLoc> {
|
||||
friend class ASTReader;
|
||||
friend class ASTStmtReader;
|
||||
friend class ASTStmtWriter;
|
||||
friend TrailingObjects;
|
||||
|
||||
@ -2770,38 +2769,49 @@ class MemberExpr final
|
||||
return MemberExprBits.HasTemplateKWAndArgsInfo;
|
||||
}
|
||||
|
||||
MemberExpr(Expr *Base, bool IsArrow, SourceLocation OperatorLoc,
|
||||
ValueDecl *MemberDecl, const DeclarationNameInfo &NameInfo,
|
||||
QualType T, ExprValueKind VK, ExprObjectKind OK);
|
||||
MemberExpr(EmptyShell Empty)
|
||||
: Expr(MemberExprClass, Empty), Base(), MemberDecl() {}
|
||||
|
||||
public:
|
||||
static MemberExpr *Create(const ASTContext &C, Expr *Base, bool IsArrow,
|
||||
SourceLocation OperatorLoc,
|
||||
NestedNameSpecifierLoc QualifierLoc,
|
||||
SourceLocation TemplateKWLoc, ValueDecl *MemberDecl,
|
||||
DeclAccessPair FoundDecl,
|
||||
DeclarationNameInfo MemberNameInfo,
|
||||
const TemplateArgumentListInfo *TemplateArgs,
|
||||
QualType T, ExprValueKind VK, ExprObjectKind OK);
|
||||
|
||||
/// Create an implicit MemberExpr, with no location, qualifier, template
|
||||
/// arguments, and so on.
|
||||
static MemberExpr *CreateImplicit(const ASTContext &C, Expr *Base,
|
||||
bool IsArrow, ValueDecl *MemberDecl,
|
||||
QualType T, ExprValueKind VK,
|
||||
ExprObjectKind OK) {
|
||||
return Create(C, Base, IsArrow, SourceLocation(), NestedNameSpecifierLoc(),
|
||||
SourceLocation(), MemberDecl,
|
||||
DeclAccessPair::make(MemberDecl, MemberDecl->getAccess()),
|
||||
DeclarationNameInfo(), nullptr, T, VK, OK);
|
||||
MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,
|
||||
ValueDecl *memberdecl, const DeclarationNameInfo &NameInfo,
|
||||
QualType ty, ExprValueKind VK, ExprObjectKind OK)
|
||||
: Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),
|
||||
base->isValueDependent(), base->isInstantiationDependent(),
|
||||
base->containsUnexpandedParameterPack()),
|
||||
Base(base), MemberDecl(memberdecl), MemberDNLoc(NameInfo.getInfo()),
|
||||
MemberLoc(NameInfo.getLoc()) {
|
||||
assert(memberdecl->getDeclName() == NameInfo.getName());
|
||||
MemberExprBits.IsArrow = isarrow;
|
||||
MemberExprBits.HasQualifierOrFoundDecl = false;
|
||||
MemberExprBits.HasTemplateKWAndArgsInfo = false;
|
||||
MemberExprBits.HadMultipleCandidates = false;
|
||||
MemberExprBits.OperatorLoc = operatorloc;
|
||||
}
|
||||
|
||||
static MemberExpr *CreateEmpty(const ASTContext &Context, bool HasQualifier,
|
||||
bool HasFoundDecl,
|
||||
bool HasTemplateKWAndArgsInfo,
|
||||
unsigned NumTemplateArgs);
|
||||
// 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 operators).
|
||||
MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc,
|
||||
ValueDecl *memberdecl, SourceLocation l, QualType ty,
|
||||
ExprValueKind VK, ExprObjectKind OK)
|
||||
: Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(),
|
||||
base->isValueDependent(), base->isInstantiationDependent(),
|
||||
base->containsUnexpandedParameterPack()),
|
||||
Base(base), MemberDecl(memberdecl), MemberDNLoc(), MemberLoc(l) {
|
||||
MemberExprBits.IsArrow = isarrow;
|
||||
MemberExprBits.HasQualifierOrFoundDecl = false;
|
||||
MemberExprBits.HasTemplateKWAndArgsInfo = false;
|
||||
MemberExprBits.HadMultipleCandidates = false;
|
||||
MemberExprBits.OperatorLoc = operatorloc;
|
||||
}
|
||||
|
||||
static MemberExpr *Create(const ASTContext &C, Expr *base, bool isarrow,
|
||||
SourceLocation OperatorLoc,
|
||||
NestedNameSpecifierLoc QualifierLoc,
|
||||
SourceLocation TemplateKWLoc, ValueDecl *memberdecl,
|
||||
DeclAccessPair founddecl,
|
||||
DeclarationNameInfo MemberNameInfo,
|
||||
const TemplateArgumentListInfo *targs, QualType ty,
|
||||
ExprValueKind VK, ExprObjectKind OK);
|
||||
|
||||
void setBase(Expr *E) { Base = E; }
|
||||
Expr *getBase() const { return cast<Expr>(Base); }
|
||||
|
@ -453,7 +453,6 @@ protected:
|
||||
enum { NumCallExprBits = 32 };
|
||||
|
||||
class MemberExprBitfields {
|
||||
friend class ASTStmtReader;
|
||||
friend class MemberExpr;
|
||||
|
||||
unsigned : NumExprBits;
|
||||
|
@ -4510,23 +4510,6 @@ public:
|
||||
UnqualifiedId &Member,
|
||||
Decl *ObjCImpDecl);
|
||||
|
||||
MemberExpr *
|
||||
BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
|
||||
const CXXScopeSpec *SS, SourceLocation TemplateKWLoc,
|
||||
ValueDecl *Member, DeclAccessPair FoundDecl,
|
||||
bool HadMultipleCandidates,
|
||||
const DeclarationNameInfo &MemberNameInfo, QualType Ty,
|
||||
ExprValueKind VK, ExprObjectKind OK,
|
||||
const TemplateArgumentListInfo *TemplateArgs = nullptr);
|
||||
MemberExpr *
|
||||
BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc,
|
||||
NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
|
||||
ValueDecl *Member, DeclAccessPair FoundDecl,
|
||||
bool HadMultipleCandidates,
|
||||
const DeclarationNameInfo &MemberNameInfo, QualType Ty,
|
||||
ExprValueKind VK, ExprObjectKind OK,
|
||||
const TemplateArgumentListInfo *TemplateArgs = nullptr);
|
||||
|
||||
void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
|
||||
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
|
||||
FunctionDecl *FDecl,
|
||||
|
@ -920,7 +920,6 @@ bool Decl::AccessDeclContextSanity() const {
|
||||
if (isa<TranslationUnitDecl>(this) ||
|
||||
isa<TemplateTypeParmDecl>(this) ||
|
||||
isa<NonTypeTemplateParmDecl>(this) ||
|
||||
!getDeclContext() ||
|
||||
!isa<CXXRecordDecl>(getDeclContext()) ||
|
||||
isInvalidDecl() ||
|
||||
isa<StaticAssertDecl>(this) ||
|
||||
|
@ -1538,44 +1538,29 @@ UnaryExprOrTypeTraitExpr::UnaryExprOrTypeTraitExpr(
|
||||
}
|
||||
}
|
||||
|
||||
MemberExpr::MemberExpr(Expr *Base, bool IsArrow, SourceLocation OperatorLoc,
|
||||
ValueDecl *MemberDecl,
|
||||
const DeclarationNameInfo &NameInfo, QualType T,
|
||||
ExprValueKind VK, ExprObjectKind OK)
|
||||
: Expr(MemberExprClass, T, VK, OK, Base->isTypeDependent(),
|
||||
Base->isValueDependent(), Base->isInstantiationDependent(),
|
||||
Base->containsUnexpandedParameterPack()),
|
||||
Base(Base), MemberDecl(MemberDecl), MemberDNLoc(NameInfo.getInfo()),
|
||||
MemberLoc(NameInfo.getLoc()) {
|
||||
assert(!NameInfo.getName() ||
|
||||
MemberDecl->getDeclName() == NameInfo.getName());
|
||||
MemberExprBits.IsArrow = IsArrow;
|
||||
MemberExprBits.HasQualifierOrFoundDecl = false;
|
||||
MemberExprBits.HasTemplateKWAndArgsInfo = false;
|
||||
MemberExprBits.HadMultipleCandidates = false;
|
||||
MemberExprBits.OperatorLoc = OperatorLoc;
|
||||
}
|
||||
|
||||
MemberExpr *MemberExpr::Create(
|
||||
const ASTContext &C, Expr *Base, bool IsArrow, SourceLocation OperatorLoc,
|
||||
const ASTContext &C, Expr *base, bool isarrow, SourceLocation OperatorLoc,
|
||||
NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc,
|
||||
ValueDecl *MemberDecl, DeclAccessPair FoundDecl,
|
||||
DeclarationNameInfo NameInfo, const TemplateArgumentListInfo *TemplateArgs,
|
||||
QualType T, ExprValueKind VK, ExprObjectKind OK) {
|
||||
bool HasQualOrFound = QualifierLoc || FoundDecl.getDecl() != MemberDecl ||
|
||||
FoundDecl.getAccess() != MemberDecl->getAccess();
|
||||
bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.isValid();
|
||||
ValueDecl *memberdecl, DeclAccessPair founddecl,
|
||||
DeclarationNameInfo nameinfo, const TemplateArgumentListInfo *targs,
|
||||
QualType ty, ExprValueKind vk, ExprObjectKind ok) {
|
||||
|
||||
bool hasQualOrFound = (QualifierLoc ||
|
||||
founddecl.getDecl() != memberdecl ||
|
||||
founddecl.getAccess() != memberdecl->getAccess());
|
||||
|
||||
bool HasTemplateKWAndArgsInfo = targs || TemplateKWLoc.isValid();
|
||||
std::size_t Size =
|
||||
totalSizeToAlloc<MemberExprNameQualifier, ASTTemplateKWAndArgsInfo,
|
||||
TemplateArgumentLoc>(
|
||||
HasQualOrFound ? 1 : 0, HasTemplateKWAndArgsInfo ? 1 : 0,
|
||||
TemplateArgs ? TemplateArgs->size() : 0);
|
||||
TemplateArgumentLoc>(hasQualOrFound ? 1 : 0,
|
||||
HasTemplateKWAndArgsInfo ? 1 : 0,
|
||||
targs ? targs->size() : 0);
|
||||
|
||||
void *Mem = C.Allocate(Size, alignof(MemberExpr));
|
||||
MemberExpr *E = new (Mem)
|
||||
MemberExpr(Base, IsArrow, OperatorLoc, MemberDecl, NameInfo, T, VK, OK);
|
||||
MemberExpr(base, isarrow, OperatorLoc, memberdecl, nameinfo, ty, vk, ok);
|
||||
|
||||
if (HasQualOrFound) {
|
||||
if (hasQualOrFound) {
|
||||
// FIXME: Wrong. We should be looking at the member declaration we found.
|
||||
if (QualifierLoc && QualifierLoc.getNestedNameSpecifier()->isDependent()) {
|
||||
E->setValueDependent(true);
|
||||
@ -1591,20 +1576,19 @@ MemberExpr *MemberExpr::Create(
|
||||
MemberExprNameQualifier *NQ =
|
||||
E->getTrailingObjects<MemberExprNameQualifier>();
|
||||
NQ->QualifierLoc = QualifierLoc;
|
||||
NQ->FoundDecl = FoundDecl;
|
||||
NQ->FoundDecl = founddecl;
|
||||
}
|
||||
|
||||
E->MemberExprBits.HasTemplateKWAndArgsInfo =
|
||||
TemplateArgs || TemplateKWLoc.isValid();
|
||||
(targs || TemplateKWLoc.isValid());
|
||||
|
||||
if (TemplateArgs) {
|
||||
if (targs) {
|
||||
bool Dependent = false;
|
||||
bool InstantiationDependent = false;
|
||||
bool ContainsUnexpandedParameterPack = false;
|
||||
E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
|
||||
TemplateKWLoc, *TemplateArgs,
|
||||
E->getTrailingObjects<TemplateArgumentLoc>(), Dependent,
|
||||
InstantiationDependent, ContainsUnexpandedParameterPack);
|
||||
TemplateKWLoc, *targs, E->getTrailingObjects<TemplateArgumentLoc>(),
|
||||
Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
|
||||
if (InstantiationDependent)
|
||||
E->setInstantiationDependent(true);
|
||||
} else if (TemplateKWLoc.isValid()) {
|
||||
@ -1615,22 +1599,6 @@ MemberExpr *MemberExpr::Create(
|
||||
return E;
|
||||
}
|
||||
|
||||
MemberExpr *MemberExpr::CreateEmpty(const ASTContext &Context,
|
||||
bool HasQualifier, bool HasFoundDecl,
|
||||
bool HasTemplateKWAndArgsInfo,
|
||||
unsigned NumTemplateArgs) {
|
||||
assert((!NumTemplateArgs || HasTemplateKWAndArgsInfo) &&
|
||||
"template args but no template arg info?");
|
||||
bool HasQualOrFound = HasQualifier || HasFoundDecl;
|
||||
std::size_t Size =
|
||||
totalSizeToAlloc<MemberExprNameQualifier, ASTTemplateKWAndArgsInfo,
|
||||
TemplateArgumentLoc>(HasQualOrFound ? 1 : 0,
|
||||
HasTemplateKWAndArgsInfo ? 1 : 0,
|
||||
NumTemplateArgs);
|
||||
void *Mem = Context.Allocate(Size, alignof(MemberExpr));
|
||||
return new (Mem) MemberExpr(EmptyShell());
|
||||
}
|
||||
|
||||
SourceLocation MemberExpr::getBeginLoc() const {
|
||||
if (isImplicitAccess()) {
|
||||
if (hasQualifier())
|
||||
|
@ -881,8 +881,9 @@ RewriteModernObjC::getIvarAccessString(ObjCIvarDecl *D) {
|
||||
IvarT, nullptr,
|
||||
/*BitWidth=*/nullptr, /*Mutable=*/true,
|
||||
ICIS_NoInit);
|
||||
MemberExpr *ME = MemberExpr::CreateImplicit(
|
||||
*Context, PE, true, FD, FD->getType(), VK_LValue, OK_Ordinary);
|
||||
MemberExpr *ME = new (Context)
|
||||
MemberExpr(PE, true, SourceLocation(), FD, SourceLocation(),
|
||||
FD->getType(), VK_LValue, OK_Ordinary);
|
||||
IvarT = Context->getDecltypeType(ME, ME->getType());
|
||||
}
|
||||
}
|
||||
@ -2735,9 +2736,9 @@ Stmt *RewriteModernObjC::RewriteObjCArrayLiteralExpr(ObjCArrayLiteral *Exp) {
|
||||
Context->getPointerType(Context->VoidPtrTy),
|
||||
nullptr, /*BitWidth=*/nullptr,
|
||||
/*Mutable=*/true, ICIS_NoInit);
|
||||
MemberExpr *ArrayLiteralME =
|
||||
MemberExpr::CreateImplicit(*Context, NSArrayCallExpr, false, ARRFD,
|
||||
ARRFD->getType(), VK_LValue, OK_Ordinary);
|
||||
MemberExpr *ArrayLiteralME = new (Context)
|
||||
MemberExpr(NSArrayCallExpr, false, SourceLocation(), ARRFD,
|
||||
SourceLocation(), ARRFD->getType(), VK_LValue, OK_Ordinary);
|
||||
QualType ConstIdT = Context->getObjCIdType().withConst();
|
||||
CStyleCastExpr * ArrayLiteralObjects =
|
||||
NoTypeInfoCStyleCastExpr(Context,
|
||||
@ -2864,9 +2865,9 @@ Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral
|
||||
Context->getPointerType(Context->VoidPtrTy),
|
||||
nullptr, /*BitWidth=*/nullptr,
|
||||
/*Mutable=*/true, ICIS_NoInit);
|
||||
MemberExpr *DictLiteralValueME =
|
||||
MemberExpr::CreateImplicit(*Context, NSValueCallExpr, false, ARRFD,
|
||||
ARRFD->getType(), VK_LValue, OK_Ordinary);
|
||||
MemberExpr *DictLiteralValueME = new (Context)
|
||||
MemberExpr(NSValueCallExpr, false, SourceLocation(), ARRFD,
|
||||
SourceLocation(), ARRFD->getType(), VK_LValue, OK_Ordinary);
|
||||
QualType ConstIdT = Context->getObjCIdType().withConst();
|
||||
CStyleCastExpr * DictValueObjects =
|
||||
NoTypeInfoCStyleCastExpr(Context,
|
||||
@ -2877,9 +2878,9 @@ Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral
|
||||
Expr *NSKeyCallExpr = CallExpr::Create(
|
||||
*Context, NSDictDRE, KeyExprs, NSDictFType, VK_LValue, SourceLocation());
|
||||
|
||||
MemberExpr *DictLiteralKeyME =
|
||||
MemberExpr::CreateImplicit(*Context, NSKeyCallExpr, false, ARRFD,
|
||||
ARRFD->getType(), VK_LValue, OK_Ordinary);
|
||||
MemberExpr *DictLiteralKeyME = new (Context)
|
||||
MemberExpr(NSKeyCallExpr, false, SourceLocation(), ARRFD,
|
||||
SourceLocation(), ARRFD->getType(), VK_LValue, OK_Ordinary);
|
||||
|
||||
CStyleCastExpr * DictKeyObjects =
|
||||
NoTypeInfoCStyleCastExpr(Context,
|
||||
@ -3179,8 +3180,9 @@ Expr *RewriteModernObjC::SynthMsgSendStretCallExpr(FunctionDecl *MsgSendStretFla
|
||||
returnType, nullptr,
|
||||
/*BitWidth=*/nullptr,
|
||||
/*Mutable=*/true, ICIS_NoInit);
|
||||
MemberExpr *ME = MemberExpr::CreateImplicit(
|
||||
*Context, STCE, false, FieldD, FieldD->getType(), VK_LValue, OK_Ordinary);
|
||||
MemberExpr *ME = new (Context)
|
||||
MemberExpr(STCE, false, SourceLocation(), FieldD, SourceLocation(),
|
||||
FieldD->getType(), VK_LValue, OK_Ordinary);
|
||||
|
||||
return ME;
|
||||
}
|
||||
@ -4627,8 +4629,9 @@ Stmt *RewriteModernObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp
|
||||
Context->VoidPtrTy, nullptr,
|
||||
/*BitWidth=*/nullptr, /*Mutable=*/true,
|
||||
ICIS_NoInit);
|
||||
MemberExpr *ME = MemberExpr::CreateImplicit(
|
||||
*Context, PE, true, FD, FD->getType(), VK_LValue, OK_Ordinary);
|
||||
MemberExpr *ME =
|
||||
new (Context) MemberExpr(PE, true, SourceLocation(), FD, SourceLocation(),
|
||||
FD->getType(), VK_LValue, OK_Ordinary);
|
||||
|
||||
CastExpr *FunkCast = NoTypeInfoCStyleCastExpr(Context, PtrToFuncCastType,
|
||||
CK_BitCast, ME);
|
||||
@ -4673,8 +4676,9 @@ Stmt *RewriteModernObjC::RewriteBlockDeclRefExpr(DeclRefExpr *DeclRefExp) {
|
||||
Context->VoidPtrTy, nullptr,
|
||||
/*BitWidth=*/nullptr, /*Mutable=*/true,
|
||||
ICIS_NoInit);
|
||||
MemberExpr *ME = MemberExpr::CreateImplicit(
|
||||
*Context, DeclRefExp, isArrow, FD, FD->getType(), VK_LValue, OK_Ordinary);
|
||||
MemberExpr *ME = new (Context)
|
||||
MemberExpr(DeclRefExp, isArrow, SourceLocation(), FD, SourceLocation(),
|
||||
FD->getType(), VK_LValue, OK_Ordinary);
|
||||
|
||||
StringRef Name = VD->getName();
|
||||
FD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(),
|
||||
@ -4682,8 +4686,9 @@ Stmt *RewriteModernObjC::RewriteBlockDeclRefExpr(DeclRefExpr *DeclRefExp) {
|
||||
Context->VoidPtrTy, nullptr,
|
||||
/*BitWidth=*/nullptr, /*Mutable=*/true,
|
||||
ICIS_NoInit);
|
||||
ME = MemberExpr::CreateImplicit(*Context, ME, true, FD, DeclRefExp->getType(),
|
||||
VK_LValue, OK_Ordinary);
|
||||
ME =
|
||||
new (Context) MemberExpr(ME, true, SourceLocation(), FD, SourceLocation(),
|
||||
DeclRefExp->getType(), VK_LValue, OK_Ordinary);
|
||||
|
||||
// Need parens to enforce precedence.
|
||||
ParenExpr *PE = new (Context) ParenExpr(DeclRefExp->getExprLoc(),
|
||||
@ -7523,8 +7528,9 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
|
||||
IvarT, nullptr,
|
||||
/*BitWidth=*/nullptr,
|
||||
/*Mutable=*/true, ICIS_NoInit);
|
||||
MemberExpr *ME = MemberExpr::CreateImplicit(
|
||||
*Context, PE, true, FD, FD->getType(), VK_LValue, OK_Ordinary);
|
||||
MemberExpr *ME = new (Context)
|
||||
MemberExpr(PE, true, SourceLocation(), FD, SourceLocation(),
|
||||
FD->getType(), VK_LValue, OK_Ordinary);
|
||||
IvarT = Context->getDecltypeType(ME, ME->getType());
|
||||
}
|
||||
}
|
||||
@ -7551,9 +7557,9 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
|
||||
D->getType(), nullptr,
|
||||
/*BitWidth=*/D->getBitWidth(),
|
||||
/*Mutable=*/true, ICIS_NoInit);
|
||||
MemberExpr *ME =
|
||||
MemberExpr::CreateImplicit(*Context, PE, /*isArrow*/ false, FD,
|
||||
FD->getType(), VK_LValue, OK_Ordinary);
|
||||
MemberExpr *ME = new (Context)
|
||||
MemberExpr(PE, /*isArrow*/ false, SourceLocation(), FD,
|
||||
SourceLocation(), FD->getType(), VK_LValue, OK_Ordinary);
|
||||
Replacement = ME;
|
||||
|
||||
}
|
||||
|
@ -3793,8 +3793,9 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) {
|
||||
Context->VoidPtrTy, nullptr,
|
||||
/*BitWidth=*/nullptr, /*Mutable=*/true,
|
||||
ICIS_NoInit);
|
||||
MemberExpr *ME = MemberExpr::CreateImplicit(
|
||||
*Context, PE, true, FD, FD->getType(), VK_LValue, OK_Ordinary);
|
||||
MemberExpr *ME =
|
||||
new (Context) MemberExpr(PE, true, SourceLocation(), FD, SourceLocation(),
|
||||
FD->getType(), VK_LValue, OK_Ordinary);
|
||||
|
||||
CastExpr *FunkCast = NoTypeInfoCStyleCastExpr(Context, PtrToFuncCastType,
|
||||
CK_BitCast, ME);
|
||||
@ -3839,9 +3840,9 @@ Stmt *RewriteObjC::RewriteBlockDeclRefExpr(DeclRefExpr *DeclRefExp) {
|
||||
Context->VoidPtrTy, nullptr,
|
||||
/*BitWidth=*/nullptr, /*Mutable=*/true,
|
||||
ICIS_NoInit);
|
||||
MemberExpr *ME =
|
||||
MemberExpr::CreateImplicit(*Context, DeclRefExp, isArrow, FD,
|
||||
FD->getType(), VK_LValue, OK_Ordinary);
|
||||
MemberExpr *ME = new (Context)
|
||||
MemberExpr(DeclRefExp, isArrow, SourceLocation(), FD, SourceLocation(),
|
||||
FD->getType(), VK_LValue, OK_Ordinary);
|
||||
|
||||
StringRef Name = VD->getName();
|
||||
FD = FieldDecl::Create(*Context, nullptr, SourceLocation(), SourceLocation(),
|
||||
@ -3849,8 +3850,9 @@ Stmt *RewriteObjC::RewriteBlockDeclRefExpr(DeclRefExpr *DeclRefExp) {
|
||||
Context->VoidPtrTy, nullptr,
|
||||
/*BitWidth=*/nullptr, /*Mutable=*/true,
|
||||
ICIS_NoInit);
|
||||
ME = MemberExpr::CreateImplicit(*Context, ME, true, FD, DeclRefExp->getType(),
|
||||
VK_LValue, OK_Ordinary);
|
||||
ME =
|
||||
new (Context) MemberExpr(ME, true, SourceLocation(), FD, SourceLocation(),
|
||||
DeclRefExp->getType(), VK_LValue, OK_Ordinary);
|
||||
|
||||
// Need parens to enforce precedence.
|
||||
ParenExpr *PE = new (Context) ParenExpr(DeclRefExp->getExprLoc(),
|
||||
@ -5828,10 +5830,10 @@ Stmt *RewriteObjCFragileABI::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
|
||||
OldRange.getEnd(),
|
||||
castExpr);
|
||||
if (IV->isFreeIvar() &&
|
||||
declaresSameEntity(CurMethodDef->getClassInterface(),
|
||||
iFaceDecl->getDecl())) {
|
||||
MemberExpr *ME = MemberExpr::CreateImplicit(
|
||||
*Context, PE, true, D, D->getType(), VK_LValue, OK_Ordinary);
|
||||
declaresSameEntity(CurMethodDef->getClassInterface(), iFaceDecl->getDecl())) {
|
||||
MemberExpr *ME = new (Context)
|
||||
MemberExpr(PE, true, SourceLocation(), D, IV->getLocation(),
|
||||
D->getType(), VK_LValue, OK_Ordinary);
|
||||
Replacement = ME;
|
||||
} else {
|
||||
IV->setBase(PE);
|
||||
|
@ -7189,12 +7189,12 @@ ExprResult Sema::BuildCXXMemberCallExpr(Expr *E, NamedDecl *FoundDecl,
|
||||
}
|
||||
}
|
||||
|
||||
MemberExpr *ME =
|
||||
BuildMemberExpr(Exp.get(), /*IsArrow=*/false, SourceLocation(),
|
||||
NestedNameSpecifierLoc(), SourceLocation(), Method,
|
||||
DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()),
|
||||
HadMultipleCandidates, DeclarationNameInfo(),
|
||||
Context.BoundMemberTy, VK_RValue, OK_Ordinary);
|
||||
MemberExpr *ME = new (Context) MemberExpr(
|
||||
Exp.get(), /*IsArrow=*/false, SourceLocation(), Method, SourceLocation(),
|
||||
Context.BoundMemberTy, VK_RValue, OK_Ordinary);
|
||||
if (HadMultipleCandidates)
|
||||
ME->setHadMultipleCandidates(true);
|
||||
MarkMemberReferenced(ME);
|
||||
|
||||
QualType ResultType = Method->getReturnType();
|
||||
ExprValueKind VK = Expr::getValueKindForType(ResultType);
|
||||
|
@ -893,31 +893,18 @@ BuildMSPropertyRefExpr(Sema &S, Expr *BaseExpr, bool IsArrow,
|
||||
NameInfo.getLoc());
|
||||
}
|
||||
|
||||
MemberExpr *Sema::BuildMemberExpr(
|
||||
Expr *Base, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec *SS,
|
||||
SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl,
|
||||
bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo,
|
||||
QualType Ty, ExprValueKind VK, ExprObjectKind OK,
|
||||
const TemplateArgumentListInfo *TemplateArgs) {
|
||||
NestedNameSpecifierLoc NNS =
|
||||
SS ? SS->getWithLocInContext(Context) : NestedNameSpecifierLoc();
|
||||
return BuildMemberExpr(Base, IsArrow, OpLoc, NNS, TemplateKWLoc, Member,
|
||||
FoundDecl, HadMultipleCandidates, MemberNameInfo, Ty,
|
||||
VK, OK, TemplateArgs);
|
||||
}
|
||||
|
||||
MemberExpr *Sema::BuildMemberExpr(
|
||||
Expr *Base, bool IsArrow, SourceLocation OpLoc, NestedNameSpecifierLoc NNS,
|
||||
SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl,
|
||||
bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo,
|
||||
QualType Ty, ExprValueKind VK, ExprObjectKind OK,
|
||||
const TemplateArgumentListInfo *TemplateArgs) {
|
||||
assert((!IsArrow || Base->isRValue()) && "-> base must be a pointer rvalue");
|
||||
MemberExpr *E = MemberExpr::Create(Context, Base, IsArrow, OpLoc, NNS,
|
||||
TemplateKWLoc, Member, FoundDecl,
|
||||
MemberNameInfo, TemplateArgs, Ty, VK, OK);
|
||||
E->setHadMultipleCandidates(HadMultipleCandidates);
|
||||
MarkMemberReferenced(E);
|
||||
/// Build a MemberExpr AST node.
|
||||
static MemberExpr *BuildMemberExpr(
|
||||
Sema &SemaRef, ASTContext &C, Expr *Base, bool isArrow,
|
||||
SourceLocation OpLoc, const CXXScopeSpec &SS, SourceLocation TemplateKWLoc,
|
||||
ValueDecl *Member, DeclAccessPair FoundDecl,
|
||||
const DeclarationNameInfo &MemberNameInfo, QualType Ty, ExprValueKind VK,
|
||||
ExprObjectKind OK, const TemplateArgumentListInfo *TemplateArgs = nullptr) {
|
||||
assert((!isArrow || Base->isRValue()) && "-> base must be a pointer rvalue");
|
||||
MemberExpr *E = MemberExpr::Create(
|
||||
C, Base, isArrow, OpLoc, SS.getWithLocInContext(C), TemplateKWLoc, Member,
|
||||
FoundDecl, MemberNameInfo, TemplateArgs, Ty, VK, OK);
|
||||
SemaRef.MarkMemberReferenced(E);
|
||||
return E;
|
||||
}
|
||||
|
||||
@ -1128,10 +1115,10 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
|
||||
OpLoc);
|
||||
|
||||
if (VarDecl *Var = dyn_cast<VarDecl>(MemberDecl)) {
|
||||
return BuildMemberExpr(BaseExpr, IsArrow, OpLoc, &SS, TemplateKWLoc, Var,
|
||||
FoundDecl, /*MultipleCandidates=*/false,
|
||||
MemberNameInfo, Var->getType().getNonReferenceType(),
|
||||
VK_LValue, OK_Ordinary);
|
||||
return BuildMemberExpr(*this, Context, BaseExpr, IsArrow, OpLoc, SS,
|
||||
TemplateKWLoc, Var, FoundDecl, MemberNameInfo,
|
||||
Var->getType().getNonReferenceType(), VK_LValue,
|
||||
OK_Ordinary);
|
||||
}
|
||||
|
||||
if (CXXMethodDecl *MemberFn = dyn_cast<CXXMethodDecl>(MemberDecl)) {
|
||||
@ -1145,25 +1132,24 @@ Sema::BuildMemberReferenceExpr(Expr *BaseExpr, QualType BaseExprType,
|
||||
type = MemberFn->getType();
|
||||
}
|
||||
|
||||
return BuildMemberExpr(BaseExpr, IsArrow, OpLoc, &SS, TemplateKWLoc,
|
||||
MemberFn, FoundDecl, /*MultipleCandidates=*/false,
|
||||
MemberNameInfo, type, valueKind, OK_Ordinary);
|
||||
return BuildMemberExpr(*this, Context, BaseExpr, IsArrow, OpLoc, SS,
|
||||
TemplateKWLoc, MemberFn, FoundDecl, MemberNameInfo,
|
||||
type, valueKind, OK_Ordinary);
|
||||
}
|
||||
assert(!isa<FunctionDecl>(MemberDecl) && "member function not C++ method?");
|
||||
|
||||
if (EnumConstantDecl *Enum = dyn_cast<EnumConstantDecl>(MemberDecl)) {
|
||||
return BuildMemberExpr(BaseExpr, IsArrow, OpLoc, &SS, TemplateKWLoc, Enum,
|
||||
FoundDecl, /*MultipleCandidates=*/false,
|
||||
MemberNameInfo, Enum->getType(), VK_RValue,
|
||||
OK_Ordinary);
|
||||
return BuildMemberExpr(*this, Context, BaseExpr, IsArrow, OpLoc, SS,
|
||||
TemplateKWLoc, Enum, FoundDecl, MemberNameInfo,
|
||||
Enum->getType(), VK_RValue, OK_Ordinary);
|
||||
}
|
||||
if (VarTemplateDecl *VarTempl = dyn_cast<VarTemplateDecl>(MemberDecl)) {
|
||||
if (VarDecl *Var = getVarTemplateSpecialization(
|
||||
*this, VarTempl, TemplateArgs, MemberNameInfo, TemplateKWLoc))
|
||||
return BuildMemberExpr(
|
||||
BaseExpr, IsArrow, OpLoc, &SS, TemplateKWLoc, Var, FoundDecl,
|
||||
/*MultipleCandidates=*/false, MemberNameInfo,
|
||||
Var->getType().getNonReferenceType(), VK_LValue, OK_Ordinary);
|
||||
return BuildMemberExpr(*this, Context, BaseExpr, IsArrow, OpLoc, SS,
|
||||
TemplateKWLoc, Var, FoundDecl, MemberNameInfo,
|
||||
Var->getType().getNonReferenceType(), VK_LValue,
|
||||
OK_Ordinary);
|
||||
return ExprError();
|
||||
}
|
||||
|
||||
@ -1819,10 +1805,9 @@ Sema::BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow,
|
||||
}
|
||||
}
|
||||
|
||||
return BuildMemberExpr(Base.get(), IsArrow, OpLoc, &SS,
|
||||
return BuildMemberExpr(*this, Context, Base.get(), IsArrow, OpLoc, SS,
|
||||
/*TemplateKWLoc=*/SourceLocation(), Field, FoundDecl,
|
||||
/*MultipleCandidates=*/false, MemberNameInfo,
|
||||
MemberType, VK, OK);
|
||||
MemberNameInfo, MemberType, VK, OK);
|
||||
}
|
||||
|
||||
/// Builds an implicit member access expression. The current context
|
||||
|
@ -13912,11 +13912,14 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found,
|
||||
type = Context.BoundMemberTy;
|
||||
}
|
||||
|
||||
return BuildMemberExpr(
|
||||
Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
|
||||
MemberExpr *ME = MemberExpr::Create(
|
||||
Context, Base, MemExpr->isArrow(), MemExpr->getOperatorLoc(),
|
||||
MemExpr->getQualifierLoc(), MemExpr->getTemplateKeywordLoc(), Fn, Found,
|
||||
/*HadMultipleCandidates=*/true, MemExpr->getMemberNameInfo(),
|
||||
type, valueKind, OK_Ordinary, TemplateArgs);
|
||||
MemExpr->getMemberNameInfo(), TemplateArgs, type, valueKind,
|
||||
OK_Ordinary);
|
||||
ME->setHadMultipleCandidates(true);
|
||||
MarkMemberReferenced(ME);
|
||||
return ME;
|
||||
}
|
||||
|
||||
llvm_unreachable("Invalid reference to overloaded function");
|
||||
|
@ -752,42 +752,9 @@ void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
|
||||
}
|
||||
|
||||
void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
|
||||
VisitExpr(E);
|
||||
|
||||
bool HasQualifier = Record.readInt();
|
||||
bool HasFoundDecl = Record.readInt();
|
||||
bool HasTemplateInfo = Record.readInt();
|
||||
unsigned NumTemplateArgs = Record.readInt();
|
||||
|
||||
E->Base = Record.readSubExpr();
|
||||
E->MemberDecl = Record.readDeclAs<ValueDecl>();
|
||||
Record.readDeclarationNameLoc(E->MemberDNLoc, E->MemberDecl->getDeclName());
|
||||
E->MemberLoc = Record.readSourceLocation();
|
||||
E->MemberExprBits.IsArrow = Record.readInt();
|
||||
E->MemberExprBits.HasQualifierOrFoundDecl = HasQualifier || HasFoundDecl;
|
||||
E->MemberExprBits.HasTemplateKWAndArgsInfo = HasTemplateInfo;
|
||||
E->MemberExprBits.HadMultipleCandidates = Record.readInt();
|
||||
E->MemberExprBits.OperatorLoc = Record.readSourceLocation();
|
||||
|
||||
if (HasQualifier || HasFoundDecl)
|
||||
*E->getTrailingObjects<MemberExprNameQualifier>() =
|
||||
MemberExprNameQualifier();
|
||||
|
||||
if (HasFoundDecl) {
|
||||
auto *FoundD = Record.readDeclAs<NamedDecl>();
|
||||
auto AS = (AccessSpecifier)Record.readInt();
|
||||
E->getTrailingObjects<MemberExprNameQualifier>()->FoundDecl =
|
||||
DeclAccessPair::make(FoundD, AS);
|
||||
}
|
||||
|
||||
if (HasQualifier)
|
||||
E->getTrailingObjects<MemberExprNameQualifier>()->QualifierLoc =
|
||||
Record.readNestedNameSpecifierLoc();
|
||||
|
||||
if (HasTemplateInfo)
|
||||
ReadTemplateKWAndArgsInfo(
|
||||
*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
|
||||
E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
|
||||
// Don't call VisitExpr, this is fully initialized at creation.
|
||||
assert(E->getStmtClass() == Stmt::MemberExprClass &&
|
||||
"It's a subclass, we must advance Idx!");
|
||||
}
|
||||
|
||||
void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
|
||||
@ -2584,12 +2551,55 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
|
||||
Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
|
||||
break;
|
||||
|
||||
case EXPR_MEMBER:
|
||||
S = MemberExpr::CreateEmpty(Context, Record[ASTStmtReader::NumExprFields],
|
||||
Record[ASTStmtReader::NumExprFields + 1],
|
||||
Record[ASTStmtReader::NumExprFields + 2],
|
||||
Record[ASTStmtReader::NumExprFields + 3]);
|
||||
case EXPR_MEMBER: {
|
||||
// We load everything here and fully initialize it at creation.
|
||||
// That way we can use MemberExpr::Create and don't have to duplicate its
|
||||
// logic with a MemberExpr::CreateEmpty.
|
||||
|
||||
assert(Record.getIdx() == 0);
|
||||
NestedNameSpecifierLoc QualifierLoc;
|
||||
if (Record.readInt()) { // HasQualifier.
|
||||
QualifierLoc = Record.readNestedNameSpecifierLoc();
|
||||
}
|
||||
|
||||
SourceLocation TemplateKWLoc;
|
||||
TemplateArgumentListInfo ArgInfo;
|
||||
bool HasTemplateKWAndArgsInfo = Record.readInt();
|
||||
if (HasTemplateKWAndArgsInfo) {
|
||||
TemplateKWLoc = Record.readSourceLocation();
|
||||
unsigned NumTemplateArgs = Record.readInt();
|
||||
ArgInfo.setLAngleLoc(Record.readSourceLocation());
|
||||
ArgInfo.setRAngleLoc(Record.readSourceLocation());
|
||||
for (unsigned i = 0; i != NumTemplateArgs; ++i)
|
||||
ArgInfo.addArgument(Record.readTemplateArgumentLoc());
|
||||
}
|
||||
|
||||
bool HadMultipleCandidates = Record.readInt();
|
||||
|
||||
auto *FoundD = Record.readDeclAs<NamedDecl>();
|
||||
auto AS = (AccessSpecifier)Record.readInt();
|
||||
DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
|
||||
|
||||
QualType T = Record.readType();
|
||||
auto VK = static_cast<ExprValueKind>(Record.readInt());
|
||||
auto OK = static_cast<ExprObjectKind>(Record.readInt());
|
||||
Expr *Base = ReadSubExpr();
|
||||
auto *MemberD = Record.readDeclAs<ValueDecl>();
|
||||
SourceLocation MemberLoc = Record.readSourceLocation();
|
||||
DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
|
||||
bool IsArrow = Record.readInt();
|
||||
SourceLocation OperatorLoc = Record.readSourceLocation();
|
||||
|
||||
S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc,
|
||||
TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
|
||||
HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T,
|
||||
VK, OK);
|
||||
Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc,
|
||||
MemberD->getDeclName());
|
||||
if (HadMultipleCandidates)
|
||||
cast<MemberExpr>(S)->setHadMultipleCandidates(true);
|
||||
break;
|
||||
}
|
||||
|
||||
case EXPR_BINARY_OPERATOR:
|
||||
S = new (Context) BinaryOperator(Empty);
|
||||
|
@ -660,45 +660,39 @@ void ASTStmtWriter::VisitCallExpr(CallExpr *E) {
|
||||
}
|
||||
|
||||
void ASTStmtWriter::VisitMemberExpr(MemberExpr *E) {
|
||||
VisitExpr(E);
|
||||
// Don't call VisitExpr, we'll write everything here.
|
||||
|
||||
bool HasQualifier = E->hasQualifier();
|
||||
bool HasFoundDecl =
|
||||
E->hasQualifierOrFoundDecl() &&
|
||||
(E->getFoundDecl().getDecl() != E->getMemberDecl() ||
|
||||
E->getFoundDecl().getAccess() != E->getMemberDecl()->getAccess());
|
||||
bool HasTemplateInfo = E->hasTemplateKWAndArgsInfo();
|
||||
unsigned NumTemplateArgs = E->getNumTemplateArgs();
|
||||
|
||||
// Write these first for easy access when deserializing, as they affect the
|
||||
// size of the MemberExpr.
|
||||
Record.push_back(HasQualifier);
|
||||
Record.push_back(HasFoundDecl);
|
||||
Record.push_back(HasTemplateInfo);
|
||||
Record.push_back(NumTemplateArgs);
|
||||
|
||||
Record.AddStmt(E->getBase());
|
||||
Record.AddDeclRef(E->getMemberDecl());
|
||||
Record.AddDeclarationNameLoc(E->MemberDNLoc,
|
||||
E->getMemberDecl()->getDeclName());
|
||||
Record.AddSourceLocation(E->getMemberLoc());
|
||||
Record.push_back(E->isArrow());
|
||||
Record.push_back(E->hadMultipleCandidates());
|
||||
Record.AddSourceLocation(E->getOperatorLoc());
|
||||
|
||||
if (HasFoundDecl) {
|
||||
DeclAccessPair FoundDecl = E->getFoundDecl();
|
||||
Record.AddDeclRef(FoundDecl.getDecl());
|
||||
Record.push_back(FoundDecl.getAccess());
|
||||
}
|
||||
|
||||
if (HasQualifier)
|
||||
Record.push_back(E->hasQualifier());
|
||||
if (E->hasQualifier())
|
||||
Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
|
||||
|
||||
if (HasTemplateInfo)
|
||||
AddTemplateKWAndArgsInfo(*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
|
||||
E->getTrailingObjects<TemplateArgumentLoc>());
|
||||
Record.push_back(E->hasTemplateKWAndArgsInfo());
|
||||
if (E->hasTemplateKWAndArgsInfo()) {
|
||||
Record.AddSourceLocation(E->getTemplateKeywordLoc());
|
||||
unsigned NumTemplateArgs = E->getNumTemplateArgs();
|
||||
Record.push_back(NumTemplateArgs);
|
||||
Record.AddSourceLocation(E->getLAngleLoc());
|
||||
Record.AddSourceLocation(E->getRAngleLoc());
|
||||
for (unsigned i=0; i != NumTemplateArgs; ++i)
|
||||
Record.AddTemplateArgumentLoc(E->getTemplateArgs()[i]);
|
||||
}
|
||||
|
||||
Record.push_back(E->hadMultipleCandidates());
|
||||
|
||||
DeclAccessPair FoundDecl = E->getFoundDecl();
|
||||
Record.AddDeclRef(FoundDecl.getDecl());
|
||||
Record.push_back(FoundDecl.getAccess());
|
||||
|
||||
Record.AddTypeRef(E->getType());
|
||||
Record.push_back(E->getValueKind());
|
||||
Record.push_back(E->getObjectKind());
|
||||
Record.AddStmt(E->getBase());
|
||||
Record.AddDeclRef(E->getMemberDecl());
|
||||
Record.AddSourceLocation(E->getMemberLoc());
|
||||
Record.push_back(E->isArrow());
|
||||
Record.AddSourceLocation(E->getOperatorLoc());
|
||||
Record.AddDeclarationNameLoc(E->MemberDNLoc,
|
||||
E->getMemberDecl()->getDeclName());
|
||||
Code = serialization::EXPR_MEMBER;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user