11#include "llvm/ADT/STLExtras.h"
12#include "llvm/ADT/SmallVector.h"
13#include "llvm/ADT/StringSwitch.h"
37#define TYPE(NAME, ID, PP_TYPE, TEMP_SUFFIX, ...) \
38 { NAME, TEMP_SUFFIX, TY_##PP_TYPE, { __VA_ARGS__ }, },
39#include "clang/Driver/Types.def"
45 assert(
id > 0 &&
id - 1 <
numTypes &&
"Invalid Type ID.");
57 "Unexpected Preprocess Type.");
62 return Id == TY_CXXModule || Id == TY_PP_CXXModule || Id == TY_CXXStdModule ||
63 Id == TY_PP_CXXStdModule;
67 return Id == TY_CXXSHeader || Id == TY_CXXUHeader || Id == TY_CXXHUHeader ||
68 Id == TY_PP_CXXHeaderUnit;
118 TY_RewrittenLegacyObjC,
128 return !llvm::is_contained(kStaticLangageTypes, Id);
132 return Id == TY_PCH || Id == TY_dSYM || Id == TY_CUDA_FATBIN ||
133 Id == TY_HIP_FATBIN || Id == TY_SYCL_FATBIN;
137 return (Id == TY_Nothing ||
149 case TY_C:
case TY_PP_C:
150 case TY_CL:
case TY_PP_CL:
case TY_CLCXX:
case TY_PP_CLCXX:
151 case TY_CUDA:
case TY_PP_CUDA:
156 case TY_ObjC:
case TY_PP_ObjC:
case TY_PP_ObjC_Alias:
157 case TY_CXX:
case TY_PP_CXX:
158 case TY_ObjCXX:
case TY_PP_ObjCXX:
case TY_PP_ObjCXX_Alias:
159 case TY_CHeader:
case TY_PP_CHeader:
161 case TY_ObjCHeader:
case TY_PP_ObjCHeader:
162 case TY_CXXHeader:
case TY_PP_CXXHeader:
166 case TY_PP_CXXHeaderUnit:
167 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
169 case TY_PP_CXXModule:
170 case TY_CXXStdModule:
171 case TY_PP_CXXStdModule:
172 case TY_AST:
case TY_ModuleFile:
case TY_PCH:
173 case TY_LLVM_IR:
case TY_LLVM_BC:
216 case TY_PP_ObjC_Alias:
221 case TY_PP_ObjCXX_Alias:
226 case TY_PP_ObjCHeader:
228 case TY_PP_CXXHeader:
230 case TY_PP_ObjCXXHeader:
231 case TY_ObjCXXHeader:
233 case TY_PP_CXXModule:
234 case TY_CXXStdModule:
235 case TY_PP_CXXStdModule:
245 case TY_ObjC:
case TY_PP_ObjC:
case TY_PP_ObjC_Alias:
246 case TY_ObjCXX:
case TY_PP_ObjCXX:
247 case TY_ObjCHeader:
case TY_PP_ObjCHeader:
248 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
case TY_PP_ObjCXX_Alias:
270 case TY_CXX:
case TY_PP_CXX:
271 case TY_ObjCXX:
case TY_PP_ObjCXX:
case TY_PP_ObjCXX_Alias:
272 case TY_CXXHeader:
case TY_PP_CXXHeader:
276 case TY_PP_CXXHeaderUnit:
277 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
279 case TY_PP_CXXModule:
280 case TY_CXXStdModule:
281 case TY_PP_CXXStdModule:
284 case TY_CUDA:
case TY_PP_CUDA:
case TY_CUDA_DEVICE:
336 return llvm::StringSwitch<types::ID>(Ext)
339 .Case(
"F", TY_Fortran)
340 .Case(
"f", TY_PP_Fortran)
341 .Case(
"h", TY_CHeader)
342 .Case(
"H", TY_CXXHeader)
345 .Case(
"M", TY_ObjCXX)
346 .Case(
"o", TY_Object)
348 .Case(
"s", TY_PP_Asm)
349 .Case(
"bc", TY_LLVM_BC)
353 .Case(
"cli", TY_PP_CL)
354 .Case(
"clcpp", TY_CLCXX)
355 .Case(
"clii", TY_PP_CLCXX)
358 .Case(
"hh", TY_CXXHeader)
359 .Case(
"ii", TY_PP_CXX)
360 .Case(
"ll", TY_LLVM_IR)
361 .Case(
"mi", TY_PP_ObjC)
362 .Case(
"mm", TY_ObjCXX)
365 .Case(
"asm", TY_PP_Asm)
367 .Case(
"ccm", TY_CXXModule)
373 .Case(
"cirbc", TY_CIRBC)
374 .Case(
"cui", TY_PP_CUDA)
377 .Case(
"F03", TY_Fortran)
378 .Case(
"f03", TY_PP_Fortran)
379 .Case(
"F08", TY_Fortran)
380 .Case(
"f08", TY_PP_Fortran)
381 .Case(
"F90", TY_Fortran)
382 .Case(
"f90", TY_PP_Fortran)
383 .Case(
"F95", TY_Fortran)
384 .Case(
"f95", TY_PP_Fortran)
385 .Case(
"for", TY_PP_Fortran)
386 .Case(
"FOR", TY_PP_Fortran)
387 .Case(
"fpp", TY_Fortran)
388 .Case(
"FPP", TY_Fortran)
391 .Case(
"hipi", TY_PP_HIP)
392 .Case(
"hpp", TY_CXXHeader)
393 .Case(
"hxx", TY_CXXHeader)
394 .Case(
"iim", TY_PP_CXXModule)
395 .Case(
"iih", TY_PP_CXXHeaderUnit)
396 .Case(
"lib", TY_Object)
397 .Case(
"mii", TY_PP_ObjCXX)
398 .Case(
"obj", TY_Object)
401 .Case(
"pcm", TY_ModuleFile)
402 .Case(
"c++m", TY_CXXModule)
403 .Case(
"cppm", TY_CXXModule)
404 .Case(
"cxxm", TY_CXXModule)
405 .Case(
"hlsl", TY_HLSL)
410 for (
unsigned i=0; i<
numTypes; ++i) {
413 strcmp(Name,
getInfo(Id).Name) == 0)
417 if (strcmp(Name,
"cu") == 0) {
418 return types::TY_CUDA;
426 const auto &Info =
getInfo(Id);
427 for (
int I = 0; I <= LastPhase; ++I)
428 if (Info.Phases.contains(
static_cast<phases::ID>(I)))
436 llvm::opt::DerivedArgList &DAL,
ID Id) {
446 return types::TY_CXX;
448 return types::TY_PP_CXX;
449 case types::TY_CHeader:
450 return types::TY_CXXHeader;
451 case types::TY_PP_CHeader:
452 return types::TY_PP_CXXHeader;
463 return types::TY_CHeader;
465 case types::TY_CXXModule:
466 case types::TY_CXXStdModule:
467 return types::TY_CXXHeader;
469 return types::TY_ObjCHeader;
470 case types::TY_ObjCXX:
471 return types::TY_ObjCXXHeader;
473 case types::TY_CLCXX:
474 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