Enable -Wcast-qual for WebInspectorUI, WebKitLegacy, WebKit projects
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Jan 2018 06:00:43 +0000 (06:00 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Jan 2018 06:00:43 +0000 (06:00 +0000)
commit1697861f5ed78854263a156b6578515f303550a6
treecfb23d4000923db06cf353d634d370678f272790
parent1998b1cd31831f766129f59fb97277c2c209e936
Enable -Wcast-qual for WebInspectorUI, WebKitLegacy, WebKit projects
<https://webkit.org/b/181256>
<rdar://problem/36281730>

Reviewed by Darin Adler.

Source/WebInspectorUI:

* Configurations/Base.xcconfig:
(WARNING_CFLAGS): Add -Wcast-qual.

Source/WebKit:

* Configurations/Base.xcconfig:
(WARNING_CFLAGS): Add -Wcast-qual.
* NetworkProcess/cache/NetworkCacheCodersCocoa.cpp:
(WTF::Persistence::encodeCertificateChain): Include
TypeCastsCF.h from WTF, and use
checked_cf_cast<SecCertificateRef>() to fix warning.
* Platform/cocoa/WKCrashReporter.mm:
(WebKit::setCrashReportApplicationSpecificInformation):
- Move `oldMessage` check above nullptr check to fix a leak when
  passing in nullptr after previously setting the crash string.
- Change C-style cast to const_cast<char*>() to fix warning.
* PluginProcess/mac/PluginProcessShim.mm:
(WebKit::shim_shmat): Change C-style cast to
const_cast<void*>() to fix warning.
* Shared/Authentication/mac/AuthenticationManager.mac.mm:
(WebKit::leafCertificate): Include TypeCastsCF.h from
WTF, and use checked_cf_cast<SecCertificateRef>() to fix
warning.
* Shared/cf/ArgumentCodersCF.cpp:
(IPC::encode): Use static_cast<>(const_cast<void*>() to
fix warnings since the CFTypeID has already been
checked.
* Shared/mac/WebCoreArgumentCodersMac.mm:
(IPC::decodeNSError): Use an `auto` variable to hold the
CFMutableDictionaryRef, then WTFMove() to assign it back to
`userInfo`.
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::takeWindowSnapshot): Include TypeCastsCF.h from
WTF, and use checked_cf_cast<CGImageRef>() to fix
warning.

Source/WebKitLegacy:

* PlatformMac.cmake:
* WebKitLegacy.xcodeproj/project.pbxproj:
- Rename WebNSDataExtras.m to WebNSDataExtras.mm and change file
  type to Objective-C++.

Source/WebKitLegacy/mac:

* Carbon/CarbonUtils.m:
(PoolCleaner):
- Use #pragmas to ignore -Wcast-qual warnings when using a
  C-style cast from CFTypeRef to CFRunloopRef.
* Carbon/CarbonWindowFrame.m:
(-[CarbonWindowFrame title]):
- Use #pragmas to ignore -Wcast-qual warnings when using a
  C-style cast from CFStringRef to NSString *.
* Carbon/HIViewAdapter.m:
(+[HIViewAdapter getHIViewForNSView:]):
- Use #pragmas to ignore -Wcast-qual warnings when using a
  C-style cast from CFTypeRef to HIViewRef.
* Configurations/Base.xcconfig:
(WARNING_CFLAGS): Add -Wcast-qual.
* Misc/WebElementDictionary.mm:
(-[WebElementDictionary objectForKey:]):
- Use static_cast<SEL>(const_cast<void*>()) to fix
  warning.
* Misc/WebNSDataExtras.mm: Renamed from Source/WebKitLegacy/mac/Misc/WebNSDataExtras.m.
(-[NSString _web_capitalizeRFC822HeaderFieldName]):
(-[NSData _webkit_guessedMIMETypeForXML]):
(-[NSData _webkit_guessedMIMEType]):
(-[NSData _web_isCaseInsensitiveEqualToCString:]):
(_findEOL):
(-[NSData _webkit_parseRFC822HeaderFields]):
(-[NSData _web_startsWithBlankLine]):
(-[NSData _web_locationAfterFirstBlankLine]):
- Rename WebNSDataExtras.m to WebNSDataExtras.mm and change file
  type to Objective-C++.  This fixes the warnings about
  discarding the `const` modifier when casing from CFStringRef
  to NSString * because in older clang versions, -Wcast-qual was
  completely broken when compiling C++ and Objective-C++ source
  files.  In newer clang versions, discarding the `const`
  modifier for toll-free bridged types is ignored when compiling
  Objective-C++ source.
- Update copyright and license header.
- Use reinterpret_cast<> and static_cast<> to fix warnings
  unrelated to (NSString *) C-style casts.
- Replace use of MIN() macro with std::min<> template functions.
- Fix location of `*` for local variables modified above.
* Plugins/Hosted/NetscapePluginHostManager.mm:
(WebKit::NetscapePluginHostManager::spawnPluginHost):
(WebKit::NetscapePluginHostManager::initializeVendorPort):
(WebKit::NetscapePluginHostManager::instantiatePlugin):
- Use static_cast<uint8_t*>(const_cast<void*>()) to fix
  warnings.
* Plugins/Hosted/NetscapePluginHostProxy.mm:
(WebKit::NetscapePluginHostProxy::NetscapePluginHostProxy):
- Use reinterpret_cast<mig_subsystem_t>(const_cast<struct WKWebKitPluginClient_subsystem*>())
  to fix warning.
* Plugins/Hosted/ProxyInstance.mm:
(WebKit::ProxyInstance::invoke):
- Use static_cast<char*>(const_cast<void*>()) to fix
  warning when using -[NSData bytes].
(WebKit::ProxyInstance::fieldValue const):
- Use reinterpret_cast<char*>(const_cast<unsigned char*>())
  to fix warning when using CFDataGetBytePtr().
* Plugins/Hosted/WebTextInputWindowController.m:
(-[WebTextInputPanel _interpretKeyEvent:string:]):
- Use #pragma to ignore -Wcast-qual warning since there
  is not a good way to avoid this warning in Objective-C.
* Plugins/WebNetscapePluginStream.mm:
(WebNetscapePluginStream::deliverData):
- Use const_cast<void*>() to fix warning when using
  -[NSData bytes].
* Plugins/WebNetscapePluginView.mm:
(-[WebNetscapePluginView _createPlugin]):
- Change C-style cast to const_cast<char*>() to fix
  warning.
* WebCoreSupport/WebChromeClient.mm:
(WebChromeClient::wrapCryptoKey const):
(WebChromeClient::unwrapCryptoKey const):
- Change C-style cast to
  static_cast<uint8_t*>(const_cast<void*>() to fix
  warning.
* WebView/WebPDFView.mm:
(_applicationInfoForMIMEType):
- Change local variable type from 'NSURL *' to
  'CFURLRef' to fix warning.  Cast back to 'NSURL *'
  when calling -[NSURL path].

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226499 268f45cc-cd09-0410-ab3c-d52691b4dbfc
29 files changed:
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Configurations/Base.xcconfig
Source/WebKit/ChangeLog
Source/WebKit/Configurations/Base.xcconfig
Source/WebKit/NetworkProcess/cache/NetworkCacheCodersCocoa.cpp
Source/WebKit/Platform/cocoa/WKCrashReporter.mm
Source/WebKit/PluginProcess/mac/PluginProcessShim.mm
Source/WebKit/Shared/Authentication/mac/AuthenticationManager.mac.mm
Source/WebKit/Shared/cf/ArgumentCodersCF.cpp
Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm
Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm
Source/WebKitLegacy/ChangeLog
Source/WebKitLegacy/PlatformMac.cmake
Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj
Source/WebKitLegacy/mac/Carbon/CarbonUtils.m
Source/WebKitLegacy/mac/Carbon/CarbonWindowFrame.m
Source/WebKitLegacy/mac/Carbon/HIViewAdapter.m
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/Configurations/Base.xcconfig
Source/WebKitLegacy/mac/Misc/WebElementDictionary.mm
Source/WebKitLegacy/mac/Misc/WebNSDataExtras.mm [moved from Source/WebKitLegacy/mac/Misc/WebNSDataExtras.m with 82% similarity]
Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostManager.mm
Source/WebKitLegacy/mac/Plugins/Hosted/NetscapePluginHostProxy.mm
Source/WebKitLegacy/mac/Plugins/Hosted/ProxyInstance.mm
Source/WebKitLegacy/mac/Plugins/Hosted/WebTextInputWindowController.m
Source/WebKitLegacy/mac/Plugins/WebNetscapePluginStream.mm
Source/WebKitLegacy/mac/Plugins/WebNetscapePluginView.mm
Source/WebKitLegacy/mac/WebCoreSupport/WebChromeClient.mm
Source/WebKitLegacy/mac/WebView/WebPDFView.mm