This is an archive of the discontinued LLVM Phabricator instance.

[clang][cli] Port TargetOpts simple string based options to new option parsing system
ClosedPublic

Authored by jansvoboda11 on Jul 27 2020, 9:50 AM.

Diff Detail

Event Timeline

dang created this revision.Jul 27 2020, 9:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2020, 9:50 AM
jansvoboda11 commandeered this revision.Dec 15 2020, 4:33 AM
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a reviewer: dexonsmith.
jansvoboda11 added a subscriber: jansvoboda11.

Taking over this patch, as Daniel is no longer involved.

jansvoboda11 retitled this revision from Port TargetOpts simple string based options to new option parsing system to [clang][cli] Port TargetOpts simple string based options to new option parsing system.Dec 15 2020, 4:33 AM

Rebase, undo unnecessary move of options

Fix: avoid template instantiations

dexonsmith added inline comments.Dec 15 2020, 2:47 PM
clang/lib/Frontend/CompilerInvocation.cpp
248

I don't think this needs to be templated; it can just use the same prototype it did before this patch (using unsigned directly).

271–272

Once the template is gone from the unsigned overload above, I wonder if we can use !std::is_convertible<T, unsigned> here, and let the unsigned overload directly catch any enums that aren't strongly typed.

jansvoboda11 added inline comments.Dec 16 2020, 4:03 AM
clang/lib/Frontend/CompilerInvocation.cpp
248

I can remove it. I originally put it in there to be symmetrical with the template below.

271–272

Unfortunately, std::is_convertible<T, unsigned>::value == false when T is an enum class (and it's the same for std::is_constructible<unsigned, T>::value): https://godbolt.org/z/Pvsr7v.

I didn't find any type trait in the standard library that would have the same semantics as static_cast<unsigned, T>, but we could use something like this: https://godbolt.org/z/738dhe.

Remove template

Bigcheese accepted this revision.Dec 17 2020, 9:12 AM

lgtm with the fix above.

clang/lib/Frontend/CompilerInvocation.cpp
271–272

I would suggest instead to just rename the unsigned version to denormalizeSimpleEnumImpl and removing the constraints on this one.

This revision is now accepted and ready to land.Dec 17 2020, 9:12 AM
This revision was landed with ongoing or failed builds.Dec 18 2020, 12:41 AM
This revision was automatically updated to reflect the committed changes.