[PATCH] D64098: [NFC][clang] Refactor getCompilationPhases step 1: Move list of phases into Types.def table.
Puyan Lotfi via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 17 14:57:11 PDT 2019
plotfi added inline comments.
================
Comment at: clang/lib/Driver/Driver.cpp:2217
public:
- typedef llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> PhasesTy;
+ typedef const std::vector<phases::ID> PhasesTy;
----------------
aaron.ballman wrote:
> Why are you changing this to an STL type?
I changed it because it didn't look like you can return a SmallVector, but I just changed it back to the old SmallVector function calling style.
================
Comment at: clang/lib/Driver/Driver.cpp:3236
- PL.clear();
- types::getCompilationPhases(InputType, PL);
+ const std::vector<phases::ID> PL = types::getCompilationPhases(InputType);
+ LastPLSize = PL.size();
----------------
aaron.ballman wrote:
> You could use a `const &` here and avoid the copy. Either that, or drop the `const` (it's not a common pattern in the code base).
Going to keep the copy. I want to eventually merge getCompilationPhases and getFinalPhase into the same function.
================
Comment at: clang/lib/Driver/Types.cpp:301-303
+ assert(Phases.size() == P.size() && "Invalid size.");
+ for (unsigned i = 0; i < Phases.size(); i++)
+ assert(Phases[i] == P[i] && "Invalid Phase");
----------------
aaron.ballman wrote:
> You can replace all three lines by:
> `assert(std::equal(Phases.begin(), Phases.end(), P.begin(), P.end()) && "Invalid phase or size");`
Nice!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64098/new/
https://reviews.llvm.org/D64098
More information about the cfe-commits
mailing list