This is an archive of the discontinued LLVM Phabricator instance.

[clang][deps] During scanning don't emit warnings-as-errors that are ignored with diagnostic pragmas.
ClosedPublic

Authored by vsapsai on Nov 17 2022, 6:23 PM.

Details

Summary

Before the fix the scanning would fail with
-Werror,-Wnon-modular-include-in-module despite the warning being
suppressed in the source code.

Existing approach with -Wno-error is not sufficient because it negates
only general -Werror but not specific -Werror=... and some warnings
can still emitted as errors. Make the approach stricter by using -w
flag and ignore all warnings, including those upgraded to errors. This
approach is still valid as it doesn't affect the dependencies.

rdar://101588531

Diff Detail

Event Timeline

vsapsai created this revision.Nov 17 2022, 6:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 17 2022, 6:23 PM
Herald added a subscriber: ributzka. · View Herald Transcript
vsapsai requested review of this revision.Nov 17 2022, 6:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 17 2022, 6:23 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Should admit that approach with DiagOpts.IgnoreWarnings is pretty blunt but I'm not aware of any reasons to use something more elaborate, like stripping away all -Werror=... flags. So going with a simple change.

jansvoboda11 accepted this revision.Nov 28 2022, 1:05 PM

LGTM, thanks!

This revision is now accepted and ready to land.Nov 28 2022, 1:05 PM
benlangmuir accepted this revision.Nov 28 2022, 1:06 PM

Thanks for the reviews!

dyung added a subscriber: dyung.Nov 28 2022, 9:25 PM

@vsapsai I reverted your change because it was causing the test ClangScanDeps/no-werror.cpp to fail on the PS4/PS5 linux/Windows bots:

Ok, I was able to reproduce the error on macOS by adding -target x86_64-sie-ps5 to one of commands in "clang/test/ClangScanDeps/Inputs/no-werror.json" (wouldn't mind receiving PS5 DevKit, by the way). The problem is that Driver::BuildCompilation overwrites DiagnosticsEngine::IgnoreAllWarnings ignoring everything specified in DiagnosticOptions::IgnoreWarnings. Thus we still emit the warning despite asking in DiagnosticOptions not to. D138970 fixes this situation and relies on DiagnosticOptions to set diagnostic options.