diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-01-12 02:34:39 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-01-12 02:34:39 +0000 |
commit | 746f5bcbfde5b25269169c63c66492311673b67d (patch) | |
tree | ec07bd23c545817958c8b8340f40fdbcd1acf96e /lib/AST/Expr.cpp | |
parent | d8b4216c82d6ab1f8f2fb49c052aaea263027d7b (diff) |
Add IsImplicit field in ObjCMessageExpr that is true when the message
was constructed, e.g. for a property access.
This allows the selector identifier locations machinery for ObjCMessageExpr
to function correctly, in that there are not real locations to handle/report for
such a message.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148013 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r-- | lib/AST/Expr.cpp | 64 |
1 files changed, 45 insertions, 19 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index f87d60f7fb..e7177aabe2 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -2789,7 +2789,8 @@ ObjCMessageExpr::ObjCMessageExpr(QualType T, SelectorLocationsKind SelLocsK, ObjCMethodDecl *Method, ArrayRef<Expr *> Args, - SourceLocation RBracLoc) + SourceLocation RBracLoc, + bool isImplicit) : Expr(ObjCMessageExprClass, T, VK, OK_Ordinary, /*TypeDependent=*/false, /*ValueDependent=*/false, /*InstantiationDependent=*/false, @@ -2797,8 +2798,8 @@ ObjCMessageExpr::ObjCMessageExpr(QualType T, SelectorOrMethod(reinterpret_cast<uintptr_t>(Method? Method : Sel.getAsOpaquePtr())), Kind(IsInstanceSuper? SuperInstance : SuperClass), - HasMethod(Method != 0), IsDelegateInitCall(false), SuperLoc(SuperLoc), - LBracLoc(LBracLoc), RBracLoc(RBracLoc) + HasMethod(Method != 0), IsDelegateInitCall(false), IsImplicit(isImplicit), + SuperLoc(SuperLoc), LBracLoc(LBracLoc), RBracLoc(RBracLoc) { initArgsAndSelLocs(Args, SelLocs, SelLocsK); setReceiverPointer(SuperType.getAsOpaquePtr()); @@ -2813,14 +2814,15 @@ ObjCMessageExpr::ObjCMessageExpr(QualType T, SelectorLocationsKind SelLocsK, ObjCMethodDecl *Method, ArrayRef<Expr *> Args, - SourceLocation RBracLoc) + SourceLocation RBracLoc, + bool isImplicit) : Expr(ObjCMessageExprClass, T, VK, OK_Ordinary, T->isDependentType(), T->isDependentType(), T->isInstantiationDependentType(), T->containsUnexpandedParameterPack()), SelectorOrMethod(reinterpret_cast<uintptr_t>(Method? Method : Sel.getAsOpaquePtr())), Kind(Class), - HasMethod(Method != 0), IsDelegateInitCall(false), + HasMethod(Method != 0), IsDelegateInitCall(false), IsImplicit(isImplicit), LBracLoc(LBracLoc), RBracLoc(RBracLoc) { initArgsAndSelLocs(Args, SelLocs, SelLocsK); @@ -2836,7 +2838,8 @@ ObjCMessageExpr::ObjCMessageExpr(QualType T, SelectorLocationsKind SelLocsK, ObjCMethodDecl *Method, ArrayRef<Expr *> Args, - SourceLocation RBracLoc) + SourceLocation RBracLoc, + bool isImplicit) : Expr(ObjCMessageExprClass, T, VK, OK_Ordinary, Receiver->isTypeDependent(), Receiver->isTypeDependent(), Receiver->isInstantiationDependent(), @@ -2844,7 +2847,7 @@ ObjCMessageExpr::ObjCMessageExpr(QualType T, SelectorOrMethod(reinterpret_cast<uintptr_t>(Method? Method : Sel.getAsOpaquePtr())), Kind(Instance), - HasMethod(Method != 0), IsDelegateInitCall(false), + HasMethod(Method != 0), IsDelegateInitCall(false), IsImplicit(isImplicit), LBracLoc(LBracLoc), RBracLoc(RBracLoc) { initArgsAndSelLocs(Args, SelLocs, SelLocsK); @@ -2884,12 +2887,19 @@ ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T, ArrayRef<SourceLocation> SelLocs, ObjCMethodDecl *Method, ArrayRef<Expr *> Args, - SourceLocation RBracLoc) { - SelectorLocationsKind SelLocsK; - ObjCMessageExpr *Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK); + SourceLocation RBracLoc, + bool isImplicit) { + assert((!SelLocs.empty() || isImplicit) && + "No selector locs for non-implicit message"); + ObjCMessageExpr *Mem; + SelectorLocationsKind SelLocsK = SelectorLocationsKind(); + if (isImplicit) + Mem = alloc(Context, Args.size(), 0); + else + Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK); return new (Mem) ObjCMessageExpr(T, VK, LBracLoc, SuperLoc, IsInstanceSuper, SuperType, Sel, SelLocs, SelLocsK, - Method, Args, RBracLoc); + Method, Args, RBracLoc, isImplicit); } ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T, @@ -2900,11 +2910,19 @@ ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T, ArrayRef<SourceLocation> SelLocs, ObjCMethodDecl *Method, ArrayRef<Expr *> Args, - SourceLocation RBracLoc) { - SelectorLocationsKind SelLocsK; - ObjCMessageExpr *Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK); + SourceLocation RBracLoc, + bool isImplicit) { + assert((!SelLocs.empty() || isImplicit) && + "No selector locs for non-implicit message"); + ObjCMessageExpr *Mem; + SelectorLocationsKind SelLocsK = SelectorLocationsKind(); + if (isImplicit) + Mem = alloc(Context, Args.size(), 0); + else + Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK); return new (Mem) ObjCMessageExpr(T, VK, LBracLoc, Receiver, Sel, - SelLocs, SelLocsK, Method, Args, RBracLoc); + SelLocs, SelLocsK, Method, Args, RBracLoc, + isImplicit); } ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T, @@ -2915,11 +2933,19 @@ ObjCMessageExpr *ObjCMessageExpr::Create(ASTContext &Context, QualType T, ArrayRef<SourceLocation> SelLocs, ObjCMethodDecl *Method, ArrayRef<Expr *> Args, - SourceLocation RBracLoc) { - SelectorLocationsKind SelLocsK; - ObjCMessageExpr *Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK); + SourceLocation RBracLoc, + bool isImplicit) { + assert((!SelLocs.empty() || isImplicit) && + "No selector locs for non-implicit message"); + ObjCMessageExpr *Mem; + SelectorLocationsKind SelLocsK = SelectorLocationsKind(); + if (isImplicit) + Mem = alloc(Context, Args.size(), 0); + else + Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK); return new (Mem) ObjCMessageExpr(T, VK, LBracLoc, Receiver, Sel, - SelLocs, SelLocsK, Method, Args, RBracLoc); + SelLocs, SelLocsK, Method, Args, RBracLoc, + isImplicit); } ObjCMessageExpr *ObjCMessageExpr::CreateEmpty(ASTContext &Context, |