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;
66 return Id == TY_CXXSHeader ||
Id == TY_CXXUHeader ||
Id == TY_CXXHUHeader ||
67 Id == TY_PP_CXXHeaderUnit;
104 TY_CUDA_DEVICE, TY_HIP_DEVICE, TY_PP_CHeader,
105 TY_PP_ObjCHeader, TY_PP_CXXHeader, TY_PP_ObjCXXHeader,
106 TY_PP_CXXModule, TY_LTO_IR, TY_LTO_BC,
107 TY_Plist, TY_RewrittenObjC, TY_RewrittenLegacyObjC,
108 TY_Remap, TY_PCH, TY_Object,
109 TY_Image, TY_dSYM, TY_Dependencies,
110 TY_CUDA_FATBIN, TY_HIP_FATBIN};
111 return !llvm::is_contained(kStaticLangageTypes,
Id);
115 return Id == TY_PCH ||
Id == TY_dSYM ||
Id == TY_CUDA_FATBIN ||
120 return (
Id == TY_Nothing ||
132 case TY_C:
case TY_PP_C:
133 case TY_CL:
case TY_PP_CL:
case TY_CLCXX:
case TY_PP_CLCXX:
134 case TY_CUDA:
case TY_PP_CUDA:
139 case TY_ObjC:
case TY_PP_ObjC:
case TY_PP_ObjC_Alias:
140 case TY_CXX:
case TY_PP_CXX:
141 case TY_ObjCXX:
case TY_PP_ObjCXX:
case TY_PP_ObjCXX_Alias:
142 case TY_CHeader:
case TY_PP_CHeader:
144 case TY_ObjCHeader:
case TY_PP_ObjCHeader:
145 case TY_CXXHeader:
case TY_PP_CXXHeader:
149 case TY_PP_CXXHeaderUnit:
150 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
151 case TY_CXXModule:
case TY_PP_CXXModule:
152 case TY_AST:
case TY_ModuleFile:
case TY_PCH:
153 case TY_LLVM_IR:
case TY_LLVM_BC:
194 case TY_PP_ObjC_Alias:
199 case TY_PP_ObjCXX_Alias:
204 case TY_PP_ObjCHeader:
206 case TY_PP_CXXHeader:
208 case TY_PP_ObjCXXHeader:
209 case TY_ObjCXXHeader:
211 case TY_PP_CXXModule:
221 case TY_ObjC:
case TY_PP_ObjC:
case TY_PP_ObjC_Alias:
222 case TY_ObjCXX:
case TY_PP_ObjCXX:
223 case TY_ObjCHeader:
case TY_PP_ObjCHeader:
224 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
case TY_PP_ObjCXX_Alias:
236 case TY_CXX:
case TY_PP_CXX:
237 case TY_ObjCXX:
case TY_PP_ObjCXX:
case TY_PP_ObjCXX_Alias:
238 case TY_CXXHeader:
case TY_PP_CXXHeader:
242 case TY_PP_CXXHeaderUnit:
243 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
245 case TY_PP_CXXModule:
248 case TY_CUDA:
case TY_PP_CUDA:
case TY_CUDA_DEVICE:
300 return llvm::StringSwitch<types::ID>(Ext)
303 .Case(
"F", TY_Fortran)
304 .Case(
"f", TY_PP_Fortran)
305 .Case(
"h", TY_CHeader)
306 .Case(
"H", TY_CXXHeader)
309 .Case(
"M", TY_ObjCXX)
310 .Case(
"o", TY_Object)
312 .Case(
"s", TY_PP_Asm)
313 .Case(
"bc", TY_LLVM_BC)
317 .Case(
"cli", TY_PP_CL)
318 .Case(
"clcpp", TY_CLCXX)
319 .Case(
"clii", TY_PP_CLCXX)
322 .Case(
"hh", TY_CXXHeader)
323 .Case(
"ii", TY_PP_CXX)
324 .Case(
"ll", TY_LLVM_IR)
325 .Case(
"mi", TY_PP_ObjC)
326 .Case(
"mm", TY_ObjCXX)
329 .Case(
"asm", TY_PP_Asm)
331 .Case(
"ccm", TY_CXXModule)
336 .Case(
"cui", TY_PP_CUDA)
339 .Case(
"F03", TY_Fortran)
340 .Case(
"f03", TY_PP_Fortran)
341 .Case(
"F08", TY_Fortran)
342 .Case(
"f08", TY_PP_Fortran)
343 .Case(
"F90", TY_Fortran)
344 .Case(
"f90", TY_PP_Fortran)
345 .Case(
"F95", TY_Fortran)
346 .Case(
"f95", TY_PP_Fortran)
347 .Case(
"for", TY_PP_Fortran)
348 .Case(
"FOR", TY_PP_Fortran)
349 .Case(
"fpp", TY_Fortran)
350 .Case(
"FPP", TY_Fortran)
353 .Case(
"hipi", TY_PP_HIP)
354 .Case(
"hpp", TY_CXXHeader)
355 .Case(
"hxx", TY_CXXHeader)
356 .Case(
"iim", TY_PP_CXXModule)
357 .Case(
"iih", TY_PP_CXXHeaderUnit)
358 .Case(
"lib", TY_Object)
359 .Case(
"mii", TY_PP_ObjCXX)
360 .Case(
"obj", TY_Object)
363 .Case(
"pcm", TY_ModuleFile)
364 .Case(
"c++m", TY_CXXModule)
365 .Case(
"cppm", TY_CXXModule)
366 .Case(
"cxxm", TY_CXXModule)
367 .Case(
"hlsl", TY_HLSL)
372 for (
unsigned i=0; i<
numTypes; ++i) {
379 if (strcmp(Name,
"cu") == 0) {
380 return types::TY_CUDA;
389 for (
int I = 0; I <= LastPhase; ++I)
390 if (Info.Phases.contains(
static_cast<phases::ID>(I)))
398 llvm::opt::DerivedArgList &DAL,
ID Id) {
408 return types::TY_CXX;
410 return types::TY_PP_CXX;
411 case types::TY_CHeader:
412 return types::TY_CXXHeader;
413 case types::TY_PP_CHeader:
414 return types::TY_PP_CXXHeader;
425 return types::TY_CHeader;
427 case types::TY_CXXModule:
428 return types::TY_CXXHeader;
430 return types::TY_ObjCHeader;
431 case types::TY_ObjCXX:
432 return types::TY_ObjCXXHeader;
434 case types::TY_CLCXX:
435 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