summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2019-05-29 21:23:30 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2019-05-29 21:23:30 +0000
commitd64e6eeea912442cc75aa09d187bbdb9340d7fb7 (patch)
treef15f3bc5afb20fe3494f500d1ae9f494c68c7b87 /lib
parent2713d755f233be02f536332ab532d3776cdc6293 (diff)
downloadclang-d64e6eeea912442cc75aa09d187bbdb9340d7fb7.tar.gz
[ObjC] Fix encoding of ObjC pointer types that are pointers to typedefs
clang was encoding pointers to typedefs as if they were pointers to structs because that is apparently what gcc is doing. For example: ``` @class Class1; typedef NSArray<Class1 *> MyArray; void foo1(void) { const char *s0 = @encode(MyArray *); // "^{NSArray=#}" const char *s1 = @encode(NSArray<Class1 *> *); // "@" } ``` This commit removes the code that was there to make clang compatible with gcc and make clang emit the correct encoding for ObjC pointers, which is "@". rdar://problem/50563529 Differential Revision: https://reviews.llvm.org/D61974 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@362034 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/ASTContext.cpp39
1 files changed, 3 insertions, 36 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index c3a09723ef..87ecb5a57b 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -6927,13 +6927,10 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string &S,
getObjCEncodingForTypeImpl(Field->getType(), S,
ObjCEncOptions().setExpandStructures(),
Field);
- else {
- ObjCEncOptions NewOptions = ObjCEncOptions().setExpandStructures();
- if (Options.EncodePointerToObjCTypedef())
- NewOptions.setEncodePointerToObjCTypedef();
- getObjCEncodingForTypeImpl(Field->getType(), S, NewOptions, FD,
+ else
+ getObjCEncodingForTypeImpl(Field->getType(), S,
+ ObjCEncOptions().setExpandStructures(), FD,
NotEncodedT);
- }
}
}
S += '}';
@@ -6976,36 +6973,6 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string &S,
return;
}
- QualType PointeeTy = OPT->getPointeeType();
- if (!Options.EncodingProperty() &&
- isa<TypedefType>(PointeeTy.getTypePtr()) &&
- !Options.EncodePointerToObjCTypedef()) {
- // Another historical/compatibility reason.
- // We encode the underlying type which comes out as
- // {...};
- S += '^';
- if (FD && OPT->getInterfaceDecl()) {
- // Prevent recursive encoding of fields in some rare cases.
- ObjCInterfaceDecl *OI = OPT->getInterfaceDecl();
- SmallVector<const ObjCIvarDecl*, 32> Ivars;
- DeepCollectObjCIvars(OI, true, Ivars);
- for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
- if (Ivars[i] == FD) {
- S += '{';
- S += OI->getObjCRuntimeNameAsString();
- S += '}';
- return;
- }
- }
- }
- ObjCEncOptions NewOptions =
- ObjCEncOptions().setEncodePointerToObjCTypedef();
- if (Options.ExpandPointedToStructures())
- NewOptions.setExpandStructures();
- getObjCEncodingForTypeImpl(PointeeTy, S, NewOptions, /*Field=*/nullptr);
- return;
- }
-
S += '@';
if (OPT->getInterfaceDecl() &&
(FD || Options.EncodingProperty() || Options.EncodeClassNames())) {