@@ -90,12 +90,6 @@ const char *types::getTypeTempSuffix(ID Id, bool CLMode) {
9090 return getInfo (Id).TempSuffix ;
9191}
9292
93- bool types::onlyAssembleType (ID Id) {
94- return getInfo (Id).Phases .contains (phases::Assemble) &&
95- !getInfo (Id).Phases .contains (phases::Compile) &&
96- !getInfo (Id).Phases .contains (phases::Backend);
97- }
98-
9993bool types::onlyPrecompileType (ID Id) {
10094 return getInfo (Id).Phases .contains (phases::Precompile) &&
10195 !isPreprocessedModuleType (Id);
@@ -311,23 +305,21 @@ types::ID types::lookupTypeForTypeSpecifier(const char *Name) {
311305 return TY_INVALID;
312306}
313307
314- // FIXME: Why don't we just put this list in the defs file, eh.
315- // FIXME: The list is now in Types.def but for now this function will verify
316- // the old behavior and a subsequent change will delete most of the body.
317- void types::getCompilationPhases (ID Id, llvm::SmallVectorImpl<phases::ID> &P) {
308+ llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases>
309+ types::getCompilationPhases (ID Id, phases::ID LastPhase) {
310+ llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> P;
318311 const auto &Info = getInfo (Id);
319- for (int I = 0 ; I != phases::MaxNumberOfPhases ; ++I)
312+ for (int I = 0 ; I <= LastPhase ; ++I)
320313 if (Info.Phases .contains (static_cast <phases::ID>(I)))
321314 P.push_back (static_cast <phases::ID>(I));
322- assert (0 < P.size () && " Not enough phases in list" );
323315 assert (P.size () <= phases::MaxNumberOfPhases && " Too many phases in list" );
316+ return P;
324317}
325318
326- void types::getCompilationPhases (const clang::driver::Driver &Driver,
327- llvm::opt::DerivedArgList &DAL, ID Id,
328- llvm::SmallVectorImpl<phases::ID> &P) {
329- llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> PhaseList;
330- types::getCompilationPhases (Id, PhaseList);
319+ llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases>
320+ types::getCompilationPhases (const clang::driver::Driver &Driver,
321+ llvm::opt::DerivedArgList &DAL, ID Id) {
322+ phases::ID LastPhase;
331323
332324 // Filter to compiler mode. When the compiler is run as a preprocessor then
333325 // compilation is not an option.
@@ -336,14 +328,12 @@ void types::getCompilationPhases(const clang::driver::Driver &Driver,
336328 DAL.getLastArg (options::OPT__SLASH_EP) ||
337329 DAL.getLastArg (options::OPT_M, options::OPT_MM) ||
338330 DAL.getLastArg (options::OPT__SLASH_P))
339- llvm::copy_if (PhaseList, std::back_inserter (P),
340- [](phases::ID Phase) { return Phase <= phases::Preprocess; });
331+ LastPhase = phases::Preprocess;
341332
342333 // --precompile only runs up to precompilation.
343334 // This is a clang extension and is not compatible with GCC.
344335 else if (DAL.getLastArg (options::OPT__precompile))
345- llvm::copy_if (PhaseList, std::back_inserter (P),
346- [](phases::ID Phase) { return Phase <= phases::Precompile; });
336+ LastPhase = phases::Precompile;
347337
348338 // -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.
349339 else if (DAL.getLastArg (options::OPT_fsyntax_only) ||
@@ -355,21 +345,20 @@ void types::getCompilationPhases(const clang::driver::Driver &Driver,
355345 DAL.getLastArg (options::OPT__migrate) ||
356346 DAL.getLastArg (options::OPT__analyze) ||
357347 DAL.getLastArg (options::OPT_emit_ast))
358- llvm::copy_if (PhaseList, std::back_inserter (P),
359- [](phases::ID Phase) { return Phase <= phases::Compile; });
348+ LastPhase = phases::Compile;
360349
361350 else if (DAL.getLastArg (options::OPT_S) ||
362351 DAL.getLastArg (options::OPT_emit_llvm))
363- llvm::copy_if (PhaseList, std::back_inserter (P),
364- [](phases::ID Phase) { return Phase <= phases::Backend; });
352+ LastPhase = phases::Backend;
365353
366354 else if (DAL.getLastArg (options::OPT_c))
367- llvm::copy_if (PhaseList, std::back_inserter (P),
368- [](phases::ID Phase) { return Phase <= phases::Assemble; });
355+ LastPhase = phases::Assemble;
369356
370357 // Generally means, do every phase until Link.
371358 else
372- P = PhaseList;
359+ LastPhase = phases::LastPhase;
360+
361+ return types::getCompilationPhases (Id, LastPhase);
373362}
374363
375364ID types::lookupCXXTypeForCType (ID Id) {
0 commit comments