aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 12e2813ef..6af8066 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -110,6 +110,33 @@ static bool IsArtificial(VarDecl const *VD) {
cast<Decl>(VD->getDeclContext())->isImplicit());
}
+/// Returns \c true if the specified variable \c VD is an explicit parameter of
+/// a synthesized Objective-C property accessor. E.g., a synthesized property
+/// setter method will have a single explicit parameter which is the property to
+/// set.
+static bool IsObjCSynthesizedPropertyExplicitParameter(VarDecl const *VD) {
+ assert(VD);
+
+ if (!llvm::isa<ParmVarDecl>(VD))
+ return false;
+
+ // Not a property method.
+ const auto *Method =
+ llvm::dyn_cast_or_null<ObjCMethodDecl>(VD->getDeclContext());
+ if (!Method)
+ return false;
+
+ // Not a synthesized property accessor.
+ if (!Method->isImplicit() || !Method->isPropertyAccessor())
+ return false;
+
+ // Not an explicit parameter.
+ if (VD->isImplicit())
+ return false;
+
+ return true;
+}
+
CGDebugInfo::CGDebugInfo(CodeGenModule &CGM)
: CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()),
DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs),
@@ -5158,7 +5185,12 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
}
SmallVector<uint64_t, 13> Expr;
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
- if (VarIsArtificial)
+
+ // While synthesized Objective-C property setters are "artificial" (i.e., they
+ // are not spelled out in source), we want to pretend they are just like a
+ // regular non-compiler generated method. Hence, don't mark explicitly passed
+ // parameters of such methods as artificial.
+ if (VarIsArtificial && !IsObjCSynthesizedPropertyExplicitParameter(VD))
Flags |= llvm::DINode::FlagArtificial;
auto Align = getDeclAlignIfRequired(VD, CGM.getContext());