13#include "llvm/ADT/STLExtras.h"
14#include "llvm/ADT/SmallVector.h"
15#include "llvm/ADT/StringSwitch.h"
16#include "llvm/Option/Arg.h"
40#define TYPE(NAME, ID, PP_TYPE, TEMP_SUFFIX, ...) \
41 { NAME, TEMP_SUFFIX, TY_##PP_TYPE, { __VA_ARGS__ }, },
42#include "clang/Driver/Types.def"
48 assert(
id > 0 &&
id - 1 <
numTypes &&
"Invalid Type ID.");
60 "Unexpected Preprocess Type.");
65 return Id == TY_CXXModule ||
Id == TY_PP_CXXModule;
69 return Id == TY_CXXSHeader ||
Id == TY_CXXUHeader ||
Id == TY_CXXHUHeader ||
70 Id == TY_PP_CXXHeaderUnit;
107 TY_CUDA_DEVICE, TY_HIP_DEVICE, TY_PP_CHeader,
108 TY_PP_ObjCHeader, TY_PP_CXXHeader, TY_PP_ObjCXXHeader,
109 TY_PP_CXXModule, TY_LTO_IR, TY_LTO_BC,
110 TY_Plist, TY_RewrittenObjC, TY_RewrittenLegacyObjC,
111 TY_Remap, TY_PCH, TY_Object,
112 TY_Image, TY_dSYM, TY_Dependencies,
113 TY_CUDA_FATBIN, TY_HIP_FATBIN};
114 return !llvm::is_contained(kStaticLangageTypes,
Id);
118 return Id == TY_PCH ||
Id == TY_dSYM ||
Id == TY_CUDA_FATBIN ||
123 return (
Id == TY_Nothing ||
135 case TY_C:
case TY_PP_C:
136 case TY_CL:
case TY_PP_CL:
case TY_CLCXX:
case TY_PP_CLCXX:
137 case TY_CUDA:
case TY_PP_CUDA:
142 case TY_ObjC:
case TY_PP_ObjC:
case TY_PP_ObjC_Alias:
143 case TY_CXX:
case TY_PP_CXX:
144 case TY_ObjCXX:
case TY_PP_ObjCXX:
case TY_PP_ObjCXX_Alias:
145 case TY_CHeader:
case TY_PP_CHeader:
147 case TY_ObjCHeader:
case TY_PP_ObjCHeader:
148 case TY_CXXHeader:
case TY_PP_CXXHeader:
152 case TY_PP_CXXHeaderUnit:
153 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
154 case TY_CXXModule:
case TY_PP_CXXModule:
155 case TY_AST:
case TY_ModuleFile:
case TY_PCH:
156 case TY_LLVM_IR:
case TY_LLVM_BC:
197 case TY_PP_ObjC_Alias:
202 case TY_PP_ObjCXX_Alias:
204 case TY_RenderScript:
208 case TY_PP_ObjCHeader:
210 case TY_PP_CXXHeader:
212 case TY_PP_ObjCXXHeader:
213 case TY_ObjCXXHeader:
215 case TY_PP_CXXModule:
225 case TY_ObjC:
case TY_PP_ObjC:
case TY_PP_ObjC_Alias:
226 case TY_ObjCXX:
case TY_PP_ObjCXX:
227 case TY_ObjCHeader:
case TY_PP_ObjCHeader:
228 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
case TY_PP_ObjCXX_Alias:
240 case TY_CXX:
case TY_PP_CXX:
241 case TY_ObjCXX:
case TY_PP_ObjCXX:
case TY_PP_ObjCXX_Alias:
242 case TY_CXXHeader:
case TY_PP_CXXHeader:
246 case TY_PP_CXXHeaderUnit:
247 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
249 case TY_PP_CXXModule:
252 case TY_CUDA:
case TY_PP_CUDA:
case TY_CUDA_DEVICE:
304 return llvm::StringSwitch<types::ID>(Ext)
307 .Case(
"F", TY_Fortran)
308 .Case(
"f", TY_PP_Fortran)
309 .Case(
"h", TY_CHeader)
310 .Case(
"H", TY_CXXHeader)
313 .Case(
"M", TY_ObjCXX)
314 .Case(
"o", TY_Object)
316 .Case(
"s", TY_PP_Asm)
317 .Case(
"bc", TY_LLVM_BC)
321 .Case(
"cli", TY_PP_CL)
322 .Case(
"clcpp", TY_CLCXX)
323 .Case(
"clii", TY_PP_CLCXX)
326 .Case(
"hh", TY_CXXHeader)
327 .Case(
"ii", TY_PP_CXX)
328 .Case(
"ll", TY_LLVM_IR)
329 .Case(
"mi", TY_PP_ObjC)
330 .Case(
"mm", TY_ObjCXX)
331 .Case(
"rs", TY_RenderScript)
334 .Case(
"asm", TY_PP_Asm)
336 .Case(
"ccm", TY_CXXModule)
341 .Case(
"cui", TY_PP_CUDA)
344 .Case(
"F03", TY_Fortran)
345 .Case(
"f03", TY_PP_Fortran)
346 .Case(
"F08", TY_Fortran)
347 .Case(
"f08", TY_PP_Fortran)
348 .Case(
"F90", TY_Fortran)
349 .Case(
"f90", TY_PP_Fortran)
350 .Case(
"F95", TY_Fortran)
351 .Case(
"f95", TY_PP_Fortran)
352 .Case(
"for", TY_PP_Fortran)
353 .Case(
"FOR", TY_PP_Fortran)
354 .Case(
"fpp", TY_Fortran)
355 .Case(
"FPP", TY_Fortran)
358 .Case(
"hipi", TY_PP_HIP)
359 .Case(
"hpp", TY_CXXHeader)
360 .Case(
"hxx", TY_CXXHeader)
361 .Case(
"iim", TY_PP_CXXModule)
362 .Case(
"iih", TY_PP_CXXHeaderUnit)
363 .Case(
"lib", TY_Object)
364 .Case(
"mii", TY_PP_ObjCXX)
365 .Case(
"obj", TY_Object)
368 .Case(
"pcm", TY_ModuleFile)
369 .Case(
"c++m", TY_CXXModule)
370 .Case(
"cppm", TY_CXXModule)
371 .Case(
"cxxm", TY_CXXModule)
372 .Case(
"hlsl", TY_HLSL)
377 for (
unsigned i=0; i<
numTypes; ++i) {
384 if (strcmp(Name,
"cu") == 0) {
385 return types::TY_CUDA;
394 for (
int I = 0; I <= LastPhase; ++I)
395 if (Info.Phases.contains(
static_cast<phases::ID>(I)))
403 llvm::opt::DerivedArgList &DAL,
ID Id) {
413 return types::TY_CXX;
415 return types::TY_PP_CXX;
416 case types::TY_CHeader:
417 return types::TY_CXXHeader;
418 case types::TY_PP_CHeader:
419 return types::TY_PP_CXXHeader;
430 return types::TY_CHeader;
432 case types::TY_CXXModule:
433 return types::TY_CXXHeader;
435 return types::TY_ObjCHeader;
436 case types::TY_ObjCXX:
437 return types::TY_ObjCXXHeader;
439 case types::TY_CLCXX:
440 return types::TY_CLHeader;
static constexpr TypeInfo TypeInfos[]
static const TypeInfo & getInfo(unsigned id)
static bool isPreprocessedHeaderUnitType(ID Id)
static const unsigned numTypes
static bool isPreprocessedModuleType(ID Id)
constexpr PhasesBitSet(std::initializer_list< phases::ID > Phases)
bool contains(phases::ID Id) const
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
phases::ID getFinalPhase(const llvm::opt::DerivedArgList &DAL, llvm::opt::Arg **FinalPhaseArg=nullptr) const
ID
ID - Ordered values for successive stages in the compilation process which interact with user options...
ID lookupTypeForTypeSpecifier(const char *Name)
lookupTypeForTypSpecifier - Lookup the type to use for a user specified type name.
bool isHLSL(ID Id)
isHLSL - Is this an HLSL input.
bool isObjC(ID Id)
isObjC - Is this an "ObjC" input (Obj-C and Obj-C++ sources and headers).
ID getPreprocessedType(ID Id)
getPreprocessedType - Get the ID of the type for this input when it has been preprocessed,...
bool isCuda(ID Id)
isCuda - Is this a CUDA input.
bool onlyPrecompileType(ID Id)
onlyPrecompileType - Should this type only be precompiled.
bool isLLVMIR(ID Id)
Is this LLVM IR.
const char * getTypeName(ID Id)
getTypeName - Return the name of the type for Id.
bool isOpenCL(ID Id)
isOpenCL - Is this an "OpenCL" input.
bool canTypeBeUserSpecified(ID Id)
canTypeBeUserSpecified - Can this type be specified on the command line (by the type name); this is u...
llvm::SmallVector< phases::ID, phases::MaxNumberOfPhases > getCompilationPhases(ID Id, phases::ID LastPhase=phases::IfsMerge)
getCompilationPhases - Get the list of compilation phases ('Phases') to be done for type 'Id' up unti...
bool isSrcFile(ID Id)
isSrcFile - Is this a source file, i.e.
bool isDerivedFromC(ID Id)
isDerivedFromC - Is the input derived from C.
ID lookupCXXTypeForCType(ID Id)
lookupCXXTypeForCType - Lookup CXX input type that corresponds to given C type (used for clang++ emul...
ID getPrecompiledType(ID Id)
getPrecompiledType - Get the ID of the type for this input when it has been precompiled,...
bool isHIP(ID Id)
isHIP - Is this a HIP input.
bool isAcceptedByClang(ID Id)
isAcceptedByClang - Can clang handle this input type.
bool appendSuffixForType(ID Id)
appendSuffixForType - When generating outputs of this type, should the suffix be appended (instead of...
bool canLipoType(ID Id)
canLipoType - Is this type acceptable as the output of a universal build (currently,...
const char * getTypeTempSuffix(ID Id, bool CLStyle=false)
getTypeTempSuffix - Return the suffix to use when creating a temp file of this type,...
ID lookupHeaderTypeForSourceType(ID Id)
Lookup header file input type that corresponds to given source file type (used for clang-cl emulation...
ID lookupTypeForExtension(llvm::StringRef Ext)
lookupTypeForExtension - Lookup the type to use for the file extension Ext.
bool isAcceptedByFlang(ID Id)
isAcceptedByFlang - Can flang handle this input type.
bool isCXX(ID Id)
isCXX - Is this a "C++" input (C++ and Obj-C++ sources and headers).
class TypeInfo::PhasesBitSet Phases