[PATCH] D125254: [clang] Allow all string types for all attribute(format) styles
Akira Hatanaka via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 12 10:17:59 PDT 2022
ahatanak accepted this revision.
ahatanak added a comment.
This revision is now accepted and ready to land.
LGTM with one minor comment.
================
Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3864
- if (Kind == CFStringFormat) {
- if (!isCFStringType(Ty, S.Context)) {
- S.Diag(AL.getLoc(), diag::err_format_attribute_not)
- << "a CFString" << IdxExpr->getSourceRange()
- << getFunctionOrMethodParamRange(D, ArgIdx);
- return;
- }
- } else if (Kind == NSStringFormat) {
- // FIXME: do we need to check if the type is NSString*? What are the
- // semantics?
- if (!isNSStringType(Ty, S.Context, /*AllowNSAttributedString=*/true)) {
- S.Diag(AL.getLoc(), diag::err_format_attribute_not)
- << "an NSString" << IdxExpr->getSourceRange()
- << getFunctionOrMethodParamRange(D, ArgIdx);
- return;
- }
- } else if (!Ty->isPointerType() ||
- !Ty->castAs<PointerType>()->getPointeeType()->isCharType()) {
+ bool NotNSStringTy = !isNSStringType(Ty, S.Context, true);
+ if (NotNSStringTy &&
----------------
You can fold this into the `if` below.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125254/new/
https://reviews.llvm.org/D125254
More information about the cfe-commits
mailing list