extract unifyTargetFeatures to be used by lld.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Driver/ToolChains/CommonArgs.cpp | ||
---|---|---|
93 | I don't think assert should be used for something that may be specified to the user on command line. | |
97 | Would it be simpler to just iterate over features backwards and skip the features we've already seen? | |
clang/lib/Driver/ToolChains/CommonArgs.h | ||
120 | Returning a new std::vector<StringRef> would make it more convenient to use and there's less complexity -- no need for the caller to create a temporary vector and the function itself can just return the temporary vector it collects the items in. for (auto Feature : unifyTargetFeatures(Features)) { ... } |
clang/lib/Driver/ToolChains/CommonArgs.cpp | ||
---|---|---|
93 | The entries in this array is not directly from command line. It is either put in by clang code, or translated from -mxxx or -mno-xxx options whereas the translated entry should always have + or - prefix. So if things go wrong, it is due to developers. | |
97 | That may save a little when there are repeating entries but you need to reverse the obtained vector to maintain the order. Since most cases there are just a few unique features, reversing may ends up slower. |
clang/lib/Driver/ToolChains/CommonArgs.cpp | ||
---|---|---|
93 | While clang may be the primary user of those options, features can be specified by the user, too. | |
97 | Up to you. Performance does not matter here, but simpler code with improved readability is always a plus. |
clang/lib/Driver/ToolChains/CommonArgs.cpp | ||
---|---|---|
93 | user may use -target-feature to directly specify features and they may forget +/- there but that is a -cc1 option, whereas this function is used in tool and will never be used in -cc1. The features in this vector can only come from clang driver, where the code is supposed to always add +/- to the entries. How could user inputs can cause +/- not added? |
clang/lib/Driver/ToolChains/CommonArgs.cpp | ||
---|---|---|
93 | Got it. I indeed had -target-feature in mind: https://github.com/llvm/llvm-project/blob/32ea3397bec820f98f0b77ca37244142ce700207/clang/lib/Frontend/CompilerInvocation.cpp#L3648 |
Returning a new std::vector<StringRef> would make it more convenient to use and there's less complexity -- no need for the caller to create a temporary vector and the function itself can just return the temporary vector it collects the items in.