[PATCH] D71084: Set a source location for Objective-C accessor stubs
Adrian Prantl via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 5 12:47:18 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa1a9aa17b4db: Set a source location for Objective-C accessor stubs even when there is no… (authored by aprantl).
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71084/new/
https://reviews.llvm.org/D71084
Files:
clang/lib/Sema/SemaObjCProperty.cpp
clang/test/SemaObjC/default-synthesize-sourceloc.m
Index: clang/test/SemaObjC/default-synthesize-sourceloc.m
===================================================================
--- /dev/null
+++ clang/test/SemaObjC/default-synthesize-sourceloc.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -ast-dump %s | FileCheck %s
+
+// Test that accessor stubs for default-synthesized ObjC accessors
+// have a valid source location.
+
+__attribute__((objc_root_class))
+ at interface NSObject
++ (id)alloc;
+ at end
+
+ at interface NSString : NSObject
+ at end
+
+ at interface MyData : NSObject
+struct Data {
+ NSString *name;
+};
+ at property struct Data data;
+ at end
+// CHECK: ObjCImplementationDecl {{.*}}line:[[@LINE+2]]{{.*}} MyData
+// CHECK: ObjCMethodDecl {{.*}}col:23 implicit - setData: 'void'
+ at implementation MyData
+ at end
Index: clang/lib/Sema/SemaObjCProperty.cpp
===================================================================
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -1058,11 +1058,13 @@
SourceLocation PropertyLoc) {
ObjCMethodDecl *Decl = AccessorDecl;
ObjCMethodDecl *ImplDecl = ObjCMethodDecl::Create(
- Context, AtLoc, PropertyLoc, Decl->getSelector(), Decl->getReturnType(),
+ Context, AtLoc.isValid() ? AtLoc : Decl->getBeginLoc(),
+ PropertyLoc.isValid() ? PropertyLoc : Decl->getEndLoc(),
+ Decl->getSelector(), Decl->getReturnType(),
Decl->getReturnTypeSourceInfo(), Impl, Decl->isInstanceMethod(),
- Decl->isVariadic(), Decl->isPropertyAccessor(), /* isSynthesized*/ true,
- Decl->isImplicit(), Decl->isDefined(), Decl->getImplementationControl(),
- Decl->hasRelatedResultType());
+ Decl->isVariadic(), Decl->isPropertyAccessor(),
+ /* isSynthesized*/ true, Decl->isImplicit(), Decl->isDefined(),
+ Decl->getImplementationControl(), Decl->hasRelatedResultType());
ImplDecl->getMethodFamily();
if (Decl->hasAttrs())
ImplDecl->setAttrs(Decl->getAttrs());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71084.232434.patch
Type: text/x-patch
Size: 1946 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191205/4bd3c101/attachment.bin>
More information about the cfe-commits
mailing list