13 #include "llvm/ADT/STLExtras.h" 14 #include "llvm/ADT/SmallVector.h" 15 #include "llvm/ADT/StringSwitch.h" 16 #include "llvm/Option/Arg.h" 31 #define TYPE(NAME, ID, PP_TYPE, TEMP_SUFFIX, ...) \ 32 { NAME, TEMP_SUFFIX, TY_##PP_TYPE, { __VA_ARGS__ }, }, 33 #include "clang/Driver/Types.def" 36 static const unsigned numTypes = llvm::array_lengthof(TypeInfos);
39 assert(
id > 0 &&
id - 1 <
numTypes &&
"Invalid Type ID.");
40 return TypeInfos[
id - 1];
51 "Unexpected Preprocess Type.");
56 return Id == TY_CXXModule || Id == TY_PP_CXXModule;
97 TY_CUDA_DEVICE, TY_HIP_DEVICE, TY_PP_CHeader,
98 TY_PP_ObjCHeader, TY_PP_CXXHeader, TY_PP_ObjCXXHeader,
99 TY_PP_CXXModule, TY_LTO_IR, TY_LTO_BC,
100 TY_Plist, TY_RewrittenObjC, TY_RewrittenLegacyObjC,
101 TY_Remap, TY_PCH, TY_Object,
102 TY_Image, TY_dSYM, TY_Dependencies,
103 TY_CUDA_FATBIN, TY_HIP_FATBIN};
104 return !llvm::is_contained(kStaticLangageTypes, Id);
108 return Id == TY_PCH || Id == TY_dSYM || Id == TY_CUDA_FATBIN ||
113 return (Id == TY_Nothing ||
125 case TY_C:
case TY_PP_C:
127 case TY_CUDA:
case TY_PP_CUDA:
132 case TY_ObjC:
case TY_PP_ObjC:
case TY_PP_ObjC_Alias:
133 case TY_CXX:
case TY_PP_CXX:
134 case TY_ObjCXX:
case TY_PP_ObjCXX:
case TY_PP_ObjCXX_Alias:
135 case TY_CHeader:
case TY_PP_CHeader:
137 case TY_ObjCHeader:
case TY_PP_ObjCHeader:
138 case TY_CXXHeader:
case TY_PP_CXXHeader:
139 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
140 case TY_CXXModule:
case TY_PP_CXXModule:
141 case TY_AST:
case TY_ModuleFile:
142 case TY_LLVM_IR:
case TY_LLVM_BC:
152 case TY_ObjC:
case TY_PP_ObjC:
case TY_PP_ObjC_Alias:
153 case TY_ObjCXX:
case TY_PP_ObjCXX:
154 case TY_ObjCHeader:
case TY_PP_ObjCHeader:
155 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
case TY_PP_ObjCXX_Alias:
165 case TY_CXX:
case TY_PP_CXX:
166 case TY_ObjCXX:
case TY_PP_ObjCXX:
case TY_PP_ObjCXX_Alias:
167 case TY_CXXHeader:
case TY_PP_CXXHeader:
168 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
169 case TY_CXXModule:
case TY_PP_CXXModule:
170 case TY_CUDA:
case TY_PP_CUDA:
case TY_CUDA_DEVICE:
220 case TY_Fortran:
case TY_PP_Fortran:
230 return llvm::StringSwitch<types::ID>(Ext)
233 .Case(
"F", TY_Fortran)
234 .Case(
"f", TY_PP_Fortran)
235 .Case(
"h", TY_CHeader)
236 .Case(
"H", TY_CXXHeader)
239 .Case(
"M", TY_ObjCXX)
240 .Case(
"o", TY_Object)
242 .Case(
"s", TY_PP_Asm)
243 .Case(
"bc", TY_LLVM_BC)
249 .Case(
"hh", TY_CXXHeader)
250 .Case(
"ii", TY_PP_CXX)
251 .Case(
"ll", TY_LLVM_IR)
252 .Case(
"mi", TY_PP_ObjC)
253 .Case(
"mm", TY_ObjCXX)
254 .Case(
"rs", TY_RenderScript)
257 .Case(
"asm", TY_PP_Asm)
259 .Case(
"ccm", TY_CXXModule)
264 .Case(
"cui", TY_PP_CUDA)
267 .Case(
"F90", TY_Fortran)
268 .Case(
"f90", TY_PP_Fortran)
269 .Case(
"F95", TY_Fortran)
270 .Case(
"f95", TY_PP_Fortran)
271 .Case(
"for", TY_PP_Fortran)
272 .Case(
"FOR", TY_PP_Fortran)
273 .Case(
"fpp", TY_Fortran)
274 .Case(
"FPP", TY_Fortran)
277 .Case(
"hpp", TY_CXXHeader)
278 .Case(
"iim", TY_PP_CXXModule)
279 .Case(
"lib", TY_Object)
280 .Case(
"mii", TY_PP_ObjCXX)
281 .Case(
"obj", TY_Object)
284 .Case(
"pcm", TY_ModuleFile)
285 .Case(
"c++m", TY_CXXModule)
286 .Case(
"cppm", TY_CXXModule)
287 .Case(
"cxxm", TY_CXXModule)
292 for (
unsigned i=0; i<
numTypes; ++i) {
295 strcmp(Name,
getInfo(Id).Name) == 0)
307 assert(0 < P.size() &&
"Not enough phases in list");
312 llvm::opt::DerivedArgList &DAL,
ID Id,
320 if (Driver.
CCCIsCPP() || DAL.getLastArg(options::OPT_E) ||
321 DAL.getLastArg(options::OPT__SLASH_EP) ||
322 DAL.getLastArg(options::OPT_M, options::OPT_MM) ||
323 DAL.getLastArg(options::OPT__SLASH_P))
324 llvm::copy_if(PhaseList, std::back_inserter(P),
329 else if (DAL.getLastArg(options::OPT__precompile))
330 llvm::copy_if(PhaseList, std::back_inserter(P),
334 else if (DAL.getLastArg(options::OPT_fsyntax_only) ||
335 DAL.getLastArg(options::OPT_print_supported_cpus) ||
336 DAL.getLastArg(options::OPT_module_file_info) ||
337 DAL.getLastArg(options::OPT_verify_pch) ||
338 DAL.getLastArg(options::OPT_rewrite_objc) ||
339 DAL.getLastArg(options::OPT_rewrite_legacy_objc) ||
340 DAL.getLastArg(options::OPT__migrate) ||
341 DAL.getLastArg(options::OPT__analyze) ||
342 DAL.getLastArg(options::OPT_emit_ast))
343 llvm::copy_if(PhaseList, std::back_inserter(P),
346 else if (DAL.getLastArg(options::OPT_S) ||
347 DAL.getLastArg(options::OPT_emit_llvm))
348 llvm::copy_if(PhaseList, std::back_inserter(P),
351 else if (DAL.getLastArg(options::OPT_c))
352 llvm::copy_if(PhaseList, std::back_inserter(P),
366 return types::TY_CXX;
368 return types::TY_PP_CXX;
369 case types::TY_CHeader:
370 return types::TY_CXXHeader;
371 case types::TY_PP_CHeader:
372 return types::TY_PP_CXXHeader;
383 return types::TY_CHeader;
385 case types::TY_CXXModule:
386 return types::TY_CXXHeader;
388 return types::TY_ObjCHeader;
389 case types::TY_ObjCXX:
390 return types::TY_ObjCXXHeader;
392 return types::TY_CLHeader;
ID
ID - Ordered values for successive stages in the compilation process which interact with user options...
const llvm::SmallVector< phases::ID, phases::MaxNumberOfPhases > Phases
bool canLipoType(ID Id)
canLipoType - Is this type acceptable as the output of a universal build (currently, just the Nothing, Image, and Object types).
const char * getTypeTempSuffix(ID Id, bool CLMode=false)
getTypeTempSuffix - Return the suffix to use when creating a temp file of this type, or null if unspecified.
bool onlyAssembleType(ID Id)
onlyAssembleType - Should this type only be assembled.
bool canTypeBeUserSpecified(ID Id)
canTypeBeUserSpecified - Can this type be specified on the command line (by the type name); this is u...
ID lookupCXXTypeForCType(ID Id)
lookupCXXTypeForCType - Lookup CXX input type that corresponds to given C type (used for clang++ emul...
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
static const unsigned numTypes
bool isHIP(ID Id)
isHIP - Is this a HIP input.
ID getPreprocessedType(ID Id)
getPreprocessedType - Get the ID of the type for this input when it has been preprocessed, or INVALID if this input is not preprocessed.
static const TypeInfo TypeInfos[]
ID lookupHeaderTypeForSourceType(ID Id)
Lookup header file input type that corresponds to given source file type (used for clang-cl emulation...
const char * getTypeName(ID Id)
getTypeName - Return the name of the type for Id.
void getCompilationPhases(ID Id, llvm::SmallVectorImpl< phases::ID > &Phases)
getCompilationPhases - Get the list of compilation phases ('Phases') to be done for type 'Id'...
bool isCuda(ID Id)
isCuda - Is this a CUDA input.
bool isAcceptedByClang(ID Id)
isAcceptedByClang - Can clang handle this input type.
static bool isPrepeocessedModuleType(ID Id)
ID getPrecompiledType(ID Id)
getPrecompiledType - Get the ID of the type for this input when it has been precompiled, or INVALID if this input is not precompiled.
static const TypeInfo & getInfo(unsigned id)
bool isCXX(ID Id)
isCXX - Is this a "C++" input (C++ and Obj-C++ sources and headers).
ID lookupTypeForExtension(llvm::StringRef Ext)
lookupTypeForExtension - Lookup the type to use for the file extension Ext.
bool onlyPrecompileType(ID Id)
onlyPrecompileType - Should this type only be precompiled.
bool CCCIsCPP() const
Whether the driver is just the preprocessor.
bool appendSuffixForType(ID Id)
appendSuffixForType - When generating outputs of this type, should the suffix be appended (instead of...
ID lookupTypeForTypeSpecifier(const char *Name)
lookupTypeForTypSpecifier - Lookup the type to use for a user specified type name.
bool isLLVMIR(ID Id)
Is this LLVM IR.
bool isSrcFile(ID Id)
isSrcFile - Is this a source file, i.e.
bool isFortran(ID Id)
isFortran - Is this a Fortran input.
bool isObjC(ID Id)
isObjC - Is this an "ObjC" input (Obj-C and Obj-C++ sources and headers).