[PATCH] D113636: format_arg attribute does not support nullable instancetype return type
FĂ©lix Cloutier via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 12 13:41:25 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG12ab3e6c8402: format_arg attribute does not support nullable instancetype return type (authored by fcloutier).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113636/new/
https://reviews.llvm.org/D113636
Files:
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/SemaObjC/format-arg-attribute.m
Index: clang/test/SemaObjC/format-arg-attribute.m
===================================================================
--- clang/test/SemaObjC/format-arg-attribute.m
+++ clang/test/SemaObjC/format-arg-attribute.m
@@ -2,7 +2,10 @@
@interface NSString
+(instancetype)stringWithCString:(const char *)cstr __attribute__((format_arg(1)));
-+(instancetype)stringWithString:(NSString *)cstr __attribute__((format_arg(1)));
+-(instancetype)initWithString:(NSString *)str __attribute__((format_arg(1)));
+
++(instancetype _Nonnull)nonNullableString:(NSString *)str __attribute__((format_arg(1)));
++(instancetype _Nullable)nullableString:(NSString *)str __attribute__((format_arg(1)));
@end
@protocol MaybeString
Index: clang/lib/Sema/SemaDeclAttr.cpp
===================================================================
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -3389,7 +3389,8 @@
}
Ty = getFunctionOrMethodResultType(D);
// replace instancetype with the class type
- if (Ty.getTypePtr() == S.Context.getObjCInstanceTypeDecl()->getTypeForDecl())
+ auto Instancetype = S.Context.getObjCInstanceTypeDecl()->getTypeForDecl();
+ if (Ty->getAs<TypedefType>() == Instancetype)
if (auto *OMD = dyn_cast<ObjCMethodDecl>(D))
if (auto *Interface = OMD->getClassInterface())
Ty = S.Context.getObjCObjectPointerType(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113636.386942.patch
Type: text/x-patch
Size: 1369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211112/e07b3f90/attachment-0001.bin>
More information about the cfe-commits
mailing list