summaryrefslogtreecommitdiff
path: root/lib/Driver/Types.cpp
diff options
context:
space:
mode:
authorPuyan Lotfi <puyan@puyan.org>2019-07-25 22:05:55 +0000
committerPuyan Lotfi <puyan@puyan.org>2019-07-25 22:05:55 +0000
commit65f56b7e646a1ebc515f225ba4ffefe989e7eaca (patch)
tree75af910e7fc8755fa6a6e90f34650d55b3abbe83 /lib/Driver/Types.cpp
parentbcb1c9a78380b4facc05d15ce0db0aaf6cfa4ba4 (diff)
downloadclang-65f56b7e646a1ebc515f225ba4ffefe989e7eaca.tar.gz
[NFC][clang] Refactor getCompilationPhases()+Types.def step 2.
- Removing a few of the entries in the Flags for the Types.def table. - Removing redundant parts of getCompilationPhases(). Flags have been removed from Types.def: a - The type should only be assembled: Now, check that Phases contains phases::Assemble but not phases::Compile or phases::Backend. p - The type should only be precompiled: Now, check that Phases contains phases::Precompile but that Flags does not contain 'm'. m - Precompiling this type produces a module file: Now, check that isPrepeocessedModuleType. Differential Revision: https://reviews.llvm.org/D65176 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@367063 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Types.cpp')
-rw-r--r--lib/Driver/Types.cpp56
1 files changed, 18 insertions, 38 deletions
diff --git a/lib/Driver/Types.cpp b/lib/Driver/Types.cpp
index 9b72556539..acfc19d0a5 100644
--- a/lib/Driver/Types.cpp
+++ b/lib/Driver/Types.cpp
@@ -42,11 +42,19 @@ const char *types::getTypeName(ID Id) {
}
types::ID types::getPreprocessedType(ID Id) {
- return getInfo(Id).PreprocessedType;
+ ID PPT = getInfo(Id).PreprocessedType;
+ assert((llvm::is_contained(getInfo(Id).Phases, phases::Preprocess) !=
+ (PPT == TY_INVALID)) &&
+ "Unexpected Preprocess Type.");
+ return PPT;
+}
+
+static bool isPrepeocessedModuleType(ID Id) {
+ return Id == TY_CXXModule || Id == TY_PP_CXXModule;
}
types::ID types::getPrecompiledType(ID Id) {
- if (strchr(getInfo(Id).Flags, 'm'))
+ if (isPrepeocessedModuleType(Id))
return TY_ModuleFile;
if (onlyPrecompileType(Id))
return TY_PCH;
@@ -71,11 +79,14 @@ const char *types::getTypeTempSuffix(ID Id, bool CLMode) {
}
bool types::onlyAssembleType(ID Id) {
- return strchr(getInfo(Id).Flags, 'a');
+ return llvm::is_contained(getInfo(Id).Phases, phases::Assemble) &&
+ !llvm::is_contained(getInfo(Id).Phases, phases::Compile) &&
+ !llvm::is_contained(getInfo(Id).Phases, phases::Backend);
}
bool types::onlyPrecompileType(ID Id) {
- return strchr(getInfo(Id).Flags, 'p');
+ return llvm::is_contained(getInfo(Id).Phases, phases::Precompile) &&
+ !isPrepeocessedModuleType(Id);
}
bool types::canTypeBeUserSpecified(ID Id) {
@@ -83,7 +94,8 @@ bool types::canTypeBeUserSpecified(ID Id) {
}
bool types::appendSuffixForType(ID Id) {
- return strchr(getInfo(Id).Flags, 'A');
+ return Id == TY_PCH || Id == TY_dSYM || Id == TY_CUDA_FATBIN ||
+ Id == TY_HIP_FATBIN;
}
bool types::canLipoType(ID Id) {
@@ -269,39 +281,7 @@ types::ID types::lookupTypeForTypeSpecifier(const char *Name) {
// FIXME: The list is now in Types.def but for now this function will verify
// the old behavior and a subsequent change will delete most of the body.
void types::getCompilationPhases(ID Id, llvm::SmallVectorImpl<phases::ID> &P) {
- if (Id != TY_Object) {
- if (getPreprocessedType(Id) != TY_INVALID) {
- P.push_back(phases::Preprocess);
- }
-
- if (getPrecompiledType(Id) != TY_INVALID) {
- P.push_back(phases::Precompile);
- }
-
- if (!onlyPrecompileType(Id)) {
- if (!onlyAssembleType(Id)) {
- P.push_back(phases::Compile);
- P.push_back(phases::Backend);
- }
- P.push_back(phases::Assemble);
- }
- }
-
- if (!onlyPrecompileType(Id)) {
- P.push_back(phases::Link);
- }
-
- // Check that the static Phase list matches.
- // TODO: These will be deleted.
- const llvm::SmallVectorImpl<phases::ID> &Phases = getInfo(Id).Phases;
- assert(Phases.size() == P.size() &&
- std::equal(Phases.begin(), Phases.end(), P.begin()) &&
- "Invalid phase or size");
-
- // TODO: This function is still being used to assert that the phase list in
- // Types.def is correct. Everything above this comment will be removed
- // in a subsequent NFC commit.
- P = Phases;
+ P = getInfo(Id).Phases;
assert(0 < P.size() && "Not enough phases in list");
assert(P.size() <= phases::MaxNumberOfPhases && "Too many phases in list");
}