Bug 297946
| Summary: | Enable format string attributes in Objective-C++ sources | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | David Kilzer (:ddkilzer) <ddkilzer> |
| Component: | New Bugs | Assignee: | David Kilzer (:ddkilzer) <ddkilzer> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Bug Depends on: | |||
| Bug Blocks: | 298071, 298073 | ||
David Kilzer (:ddkilzer)
Remove hack that disables format string attributes in Objective-C++ sources.
This is the code that disables format string attributes in Source/WTF/wtf/Assertions.h:
```
#if COMPILER(GCC_COMPATIBLE) && !defined(__OBJC__)
/* WTF logging functions can process %@ in the format string to log a NSObject* but the printf format attribute
emits a warning when %@ is used in the format string. Until <rdar://problem/5195437> is resolved we can't include
the attribute when being used from Objective-C code in case it decides to use %@. */
#define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) __attribute__((__format__(printf, formatStringArgument, extraArguments)))
#else
#define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments)
#endif
```
This is now fixable after this clang change from a few years ago:
<https://github.com/llvm/llvm-project/commit/91ed7e19418181ae385c2626cedd3b08b6ba43a6>
We can introduce a new attribute and a separate logging function that uses the attribute so the compiler is able to verify placeholders correctly:
__attribute__((__format__(__NSString__, format, vaargs)))
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/159245047>
David Kilzer (:ddkilzer)
Pull request: https://github.com/WebKit/WebKit/pull/49918
EWS
Committed 299238@main (1c37850168d7): <https://commits.webkit.org/299238@main>
Reviewed commits have been landed. Closing PR #49918 and removing active labels.