diff options
author | Matthew Curtis <mcurtis@codeaurora.org> | 2013-03-07 12:32:26 +0000 |
---|---|---|
committer | Matthew Curtis <mcurtis@codeaurora.org> | 2013-03-07 12:32:26 +0000 |
commit | b9aa6739700d10e99da64cfa9b58ba7ca1c248e2 (patch) | |
tree | 5aaa5fe7408b5eb7c0d826b670229ce0fa635b15 /lib/Driver/Types.cpp | |
parent | 9789d0d247d0bc1a06d1ea82c0630b427aa209c3 (diff) |
Minor refactor of how we get compilation phases.
There is now a single function to get the list of phases for a given
output Type.
No functionality change intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176628 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Types.cpp')
-rw-r--r-- | lib/Driver/Types.cpp | 62 |
1 files changed, 22 insertions, 40 deletions
diff --git a/lib/Driver/Types.cpp b/lib/Driver/Types.cpp index 88574fc2c3..9665095b00 100644 --- a/lib/Driver/Types.cpp +++ b/lib/Driver/Types.cpp @@ -179,47 +179,29 @@ types::ID types::lookupTypeForTypeSpecifier(const char *Name) { } // FIXME: Why don't we just put this list in the defs file, eh. - -unsigned types::getNumCompilationPhases(ID Id) { - if (Id == TY_Object) - return 1; - - unsigned N = 0; - if (getPreprocessedType(Id) != TY_INVALID) - N += 1; - - if (onlyAssembleType(Id)) - return N + 2; // assemble, link - if (onlyPrecompileType(Id)) - return N + 1; // precompile - - return N + 3; // compile, assemble, link -} - -phases::ID types::getCompilationPhase(ID Id, unsigned N) { - assert(N < getNumCompilationPhases(Id) && "Invalid index."); - - if (Id == TY_Object) - return phases::Link; - - if (getPreprocessedType(Id) != TY_INVALID) { - if (N == 0) - return phases::Preprocess; - --N; +void types::getCompilationPhases( + ID Id, + llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> &P) { + if (Id != TY_Object) { + if (getPreprocessedType(Id) != TY_INVALID) { + P.push_back(phases::Preprocess); + } + + if (onlyPrecompileType(Id)) { + P.push_back(phases::Precompile); + } else { + if (!onlyAssembleType(Id)) { + P.push_back(phases::Compile); + } + P.push_back(phases::Assemble); + } } - - if (onlyAssembleType(Id)) - return N == 0 ? phases::Assemble : phases::Link; - - if (onlyPrecompileType(Id)) - return phases::Precompile; - - if (N == 0) - return phases::Compile; - if (N == 1) - return phases::Assemble; - - return phases::Link; + if (!onlyPrecompileType(Id)) { + P.push_back(phases::Link); + } + assert(0 < P.size() && "Not enough phases in list"); + assert(P.size() <= phases::MaxNumberOfPhases && "Too many phases in list"); + return; } ID types::lookupCXXTypeForCType(ID Id) { |