Added to all official builds in issue 632385 , we use directives to emit warnings to indicate which resource ids are used so that we can filter out the unused resources.
Filtering the output is a little tricky. From the original issue:
1. GCC and clang have different warning formats
2. Warnings have extra lines depending on context (e.g. "In file included by...")
3. clang has a summary line: "4 warnings"
Now that clang is on by default we don't need to worry about 1.
Regarding the context, I think there's only two warning formats - 7 or 9 lines per warning:
a.
In file included from ../../chrome/browser/android/resource_mapper.cc:45:
../../chrome/browser/android/resource_id.h:94:18: warning: unknown pragma ignored [-Wunknown-pragmas]
LINK_RESOURCE_ID(IDR_AUTOFILL_SETTINGS, R.drawable.ic_settings_black)
^
gen/components/grit/components_scaled_resources.h:18:31: note: expanded from macro 'IDR_AUTOFILL_SETTINGS'
#define IDR_AUTOFILL_SETTINGS _Pragma("whitelisted_resource_17213") 17213
^
b.
../../chrome/browser/chrome_content_browser_client.cc:3317:10: warning: unknown pragma ignored [-Wunknown-pragmas]
IDR_CHROME_RENDERER_SERVICE_MANIFEST},
^
gen/chrome/grit/browser_resources.h:38:46: note: expanded from macro 'IDR_CHROME_RENDERER_SERVICE_MANIFEST'
#define IDR_CHROME_RENDERER_SERVICE_MANIFEST _Pragma("whitelisted_resource_11042") 11042
^
<scratch space>:59:2: note: expanded from here
whitelisted_resource_11042
^
followed by the summary line: "9 warnings generated."
Filtering this out might be a little hacky, but definitely doable and will make viewing logs nicer for all devs.
Another option mentioned in the original issue is to write a clang plugin to handle all of our resource whitelisting. I'm not sure it's worth the effort to migrate to that given that our current approach is already implemented and works well.
Comment 1 by thakis@chromium.org
, Mar 7 2018