diff options
author | Adrian Prantl <aprantl@apple.com> | 2019-11-04 14:28:14 -0800 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2019-11-08 08:23:22 -0800 |
commit | 2073dd2da702baca447efaf1879cb6151e8c6100 (patch) | |
tree | 9ec90e6d822e23671983144f24051873e521ede9 /clang/lib/Analysis | |
parent | 8d22100f66c4170510c6ff028c60672acfe1cff9 (diff) | |
download | bcm5719-llvm-2073dd2da702baca447efaf1879cb6151e8c6100.tar.gz bcm5719-llvm-2073dd2da702baca447efaf1879cb6151e8c6100.zip |
Redeclare Objective-C property accessors inside the ObjCImplDecl in which they are synthesized.
This patch is motivated by (and factored out from)
https://reviews.llvm.org/D66121 which is a debug info bugfix. Starting
with DWARF 5 all Objective-C methods are nested inside their
containing type, and that patch implements this for synthesized
Objective-C properties.
1. SemaObjCProperty populates a list of synthesized accessors that may
need to inserted into an ObjCImplDecl.
2. SemaDeclObjC::ActOnEnd inserts forward-declarations for all
accessors for which no override was provided into their
ObjCImplDecl. This patch does *not* synthesize AST function
*bodies*. Moving that code from the static analyzer into Sema may
be a good idea though.
3. Places that expect all methods to have bodies have been updated.
I did not update the static analyzer's inliner for synthesized
properties to point back to the property declaration (see
test/Analysis/Inputs/expected-plists/nullability-notes.m.plist), which
I believed to be more bug than a feature.
Differential Revision: https://reviews.llvm.org/D68108
rdar://problem/53782400
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r-- | clang/lib/Analysis/BodyFarm.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/Analysis/BodyFarm.cpp b/clang/lib/Analysis/BodyFarm.cpp index 43f9e715b3d..be065ed9330 100644 --- a/clang/lib/Analysis/BodyFarm.cpp +++ b/clang/lib/Analysis/BodyFarm.cpp @@ -830,6 +830,16 @@ Stmt *BodyFarm::getBody(const ObjCMethodDecl *D) { if (D->param_size() != 0) return nullptr; + // If the property was defined in an extension, search the extensions for + // overrides. + const ObjCInterfaceDecl *OID = D->getClassInterface(); + if (dyn_cast<ObjCInterfaceDecl>(D->getParent()) != OID) + for (auto *Ext : OID->known_extensions()) { + auto *OMD = Ext->getInstanceMethod(D->getSelector()); + if (OMD && !OMD->isImplicit()) + return nullptr; + } + Val = createObjCPropertyGetter(C, Prop); return Val.getValue(); |