This is an archive of the discontinued LLVM Phabricator instance.

[clang][deps] Reset non-modular language and preprocessor options
ClosedPublic

Authored by jansvoboda11 on Aug 25 2021, 10:09 AM.

Details

Summary

There are a number of language and preprocessor options that are reset in the CompilerInvocation that describes the build of an implicit module. This patch uses the logic for explicit modules as well.

Diff Detail

Unit TestsFailed

Event Timeline

jansvoboda11 requested review of this revision.Aug 25 2021, 10:09 AM
jansvoboda11 created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2021, 10:09 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
dexonsmith requested changes to this revision.Aug 25 2021, 11:08 AM
dexonsmith added inline comments.
clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
4

It looks to me like that this test would have passed before the code change, since there was already logic for dropping -include. Can you also add some other argument(s) that wouldn't have been dropped before, but will be now?

clang/test/ClangScanDeps/removed-args.c
3

Please add a comment here explaining what args are expected to be dropped and why, to help future readers to understand the testcase.

This revision now requires changes to proceed.Aug 25 2021, 11:08 AM
jansvoboda11 requested review of this revision.Aug 25 2021, 12:29 PM

Re-requesting review, since the test does cover the changes to ModuleDepCollector.cpp.

clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
4

Only the -include-pch argument was being dropped (PreprocessorOptions::ImplicitPCHInclude). The -include arguments (PreprocessorOptions::Includes) were being preserved. This test would not pass without the changes to ModuleDepCollector.cpp.

I can add checks for other arguments that are being dropped now that weren't before, but assuming resetNonModularOptions are already being tested elsewhere, I don't think there's much value in that.

clang/test/ClangScanDeps/removed-args.c
3

Will do.

jansvoboda11 added inline comments.Aug 25 2021, 12:37 PM
clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
4

Note that the driver will expand -include <header> into -include-pch <header>.gch only if the PCH <header>.gch file exists. Since we're not precompiling the header in this particular test, that won't be the case. This argument therefore doesn't map onto PreprocessorOptions::ImplicitPCHInclude. It maps onto PreprocessorOptions::Includes.

dexonsmith accepted this revision.Aug 25 2021, 1:18 PM

LGTM with after adding a comment to the testcase. Thanks for explaining!

This revision is now accepted and ready to land.Aug 25 2021, 1:18 PM
This revision was landed with ongoing or failed builds.Aug 25 2021, 11:43 PM
This revision was automatically updated to reflect the committed changes.