[ObjC] Make sure that the implicit arguments for direct methods have been setup
authorAlex Lorenz <arphaman@gmail.com>
Fri, 6 Dec 2019 22:24:37 +0000 (14:24 -0800)
committerAlex Lorenz <arphaman@gmail.com>
Fri, 6 Dec 2019 22:28:28 +0000 (14:28 -0800)
commitf3efd6957474bfd3b9b232ac6e4b3608174c3b79
treefbf82d313c6709844ad16b309d840bd0e560cb21
parent3b42eb3512e680caa75c0c5016abf060b1c10bb6
[ObjC] Make sure that the implicit arguments for direct methods have been setup

This commit sets the Self and Imp declarations for ObjC method declarations,
in addition to the definitions. It also fixes
a bunch of code in clang that had wrong assumptions about when getSelfDecl() would be set:

- CGDebugInfo::getObjCMethodName and AnalysisConsumer::getFunctionName would assume that it was
  set for method declarations part of a protocol, which they never were,
  and that self would be a Class type, which it isn't as it is id for a protocol.

Also use the Canonical Decl to index the set of Direct methods so that
when calls and implementations interleave, the same llvm::Function is
used and the same symbol name emitted.

Radar-Id: rdar://problem/57661767

Patch by: Pierre Habouzit

Differential Revision: https://reviews.llvm.org/D71091
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/Sema/SemaDeclObjC.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
clang/test/CodeGenObjC/direct-method.m