This is an archive of the discontinued LLVM Phabricator instance.

[clang-cl] Add parsing support for a bunch of new flags
ClosedPublic

Authored by hans on Apr 28 2021, 4:01 AM.

Details

Summary

MSVC has added some new flags. Although they're not supported, this adds parsing support for them so clang-cl doesn't treat them as filenames.

Except for /fsanitize=address which we do support. (clang-cl already exposes the -fsanitize= option, but this allows using the MSVC-spelling with a slash.)

Diff Detail

Event Timeline

hans created this revision.Apr 28 2021, 4:01 AM
hans requested review of this revision.Apr 28 2021, 4:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2021, 4:01 AM

Do we silently ignore those all now? Are any of them semantically important enough that we should emit an "not implemented, ignoring" diag instead?

thakis added inline comments.Apr 28 2021, 6:26 AM
clang/include/clang/Driver/Options.td
6131

Can we ask (or check) how this one is implemented? Does it inject a custom __asan_default_options that returns detect_stack_use_after_return=1 or is it more involved?

6132

I guess this one controls library search paths and they have vc libs built with and without asan?

hans added a comment.Apr 28 2021, 6:30 AM

Do we silently ignore those all now? Are any of them semantically important enough that we should emit an "not implemented, ignoring" diag instead?

No, this patch makes us parse them as opposed to mistaking them for filenames, but they're still unsupported and we'll print a warning about them being unused during compilation.

thakis accepted this revision.Apr 28 2021, 8:25 AM

Great :)

This revision is now accepted and ready to land.Apr 28 2021, 8:25 AM
hans marked 2 inline comments as done.May 3 2021, 4:59 AM
hans added inline comments.
clang/include/clang/Driver/Options.td
6131

They have docs here:
https://docs.microsoft.com/en-us/cpp/sanitizers/asan-building?view=msvc-160#fsanitize-address-use-after-return-compiler-option-experimental

It sounds like unlike Clang, MSVC doesn't turn on the necessary instrumentation for this by default for performance reasons. The flag enables the instrumentation, but the user also needs to set ASAN_OPTIONS to enable it at run-time.

6132

There are some docs here: https://docs.microsoft.com/en-us/cpp/sanitizers/asan-building?view=msvc-160#fno-sanitize-address-vcasan-lib-compiler-option

It's an extra library that implements __asan_set_error_report_callback for a better debugging experience and integration with the IDE, it sounds like.

This revision was automatically updated to reflect the committed changes.
hans marked 2 inline comments as done.