11 #include "llvm/ADT/STLExtras.h" 12 #include "llvm/ADT/StringSwitch.h" 27 #define TYPE(NAME, ID, PP_TYPE, TEMP_SUFFIX, FLAGS) \ 28 { NAME, FLAGS, TEMP_SUFFIX, TY_##PP_TYPE, }, 29 #include "clang/Driver/Types.def" 32 static const unsigned numTypes = llvm::array_lengthof(TypeInfos);
35 assert(
id > 0 &&
id - 1 <
numTypes &&
"Invalid Type ID.");
36 return TypeInfos[
id - 1];
48 if (strchr(
getInfo(Id).Flags,
'm'))
73 return strchr(
getInfo(Id).Flags,
'a');
77 return strchr(
getInfo(Id).Flags,
'p');
81 return strchr(
getInfo(Id).Flags,
'u');
85 return strchr(
getInfo(Id).Flags,
'A');
89 return (Id == TY_Nothing ||
101 case TY_C:
case TY_PP_C:
103 case TY_CUDA:
case TY_PP_CUDA:
108 case TY_ObjC:
case TY_PP_ObjC:
case TY_PP_ObjC_Alias:
109 case TY_CXX:
case TY_PP_CXX:
110 case TY_ObjCXX:
case TY_PP_ObjCXX:
case TY_PP_ObjCXX_Alias:
111 case TY_CHeader:
case TY_PP_CHeader:
113 case TY_ObjCHeader:
case TY_PP_ObjCHeader:
114 case TY_CXXHeader:
case TY_PP_CXXHeader:
115 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
116 case TY_CXXModule:
case TY_PP_CXXModule:
117 case TY_AST:
case TY_ModuleFile:
118 case TY_LLVM_IR:
case TY_LLVM_BC:
128 case TY_ObjC:
case TY_PP_ObjC:
case TY_PP_ObjC_Alias:
129 case TY_ObjCXX:
case TY_PP_ObjCXX:
130 case TY_ObjCHeader:
case TY_PP_ObjCHeader:
131 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
case TY_PP_ObjCXX_Alias:
141 case TY_CXX:
case TY_PP_CXX:
142 case TY_ObjCXX:
case TY_PP_ObjCXX:
case TY_PP_ObjCXX_Alias:
143 case TY_CXXHeader:
case TY_PP_CXXHeader:
144 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
145 case TY_CXXModule:
case TY_PP_CXXModule:
146 case TY_CUDA:
case TY_PP_CUDA:
case TY_CUDA_DEVICE:
196 return llvm::StringSwitch<types::ID>(Ext)
199 .Case(
"F", TY_Fortran)
200 .Case(
"f", TY_PP_Fortran)
201 .Case(
"h", TY_CHeader)
202 .Case(
"H", TY_CXXHeader)
205 .Case(
"M", TY_ObjCXX)
206 .Case(
"o", TY_Object)
208 .Case(
"s", TY_PP_Asm)
209 .Case(
"bc", TY_LLVM_BC)
215 .Case(
"hh", TY_CXXHeader)
216 .Case(
"ii", TY_PP_CXX)
217 .Case(
"ll", TY_LLVM_IR)
218 .Case(
"mi", TY_PP_ObjC)
219 .Case(
"mm", TY_ObjCXX)
220 .Case(
"rs", TY_RenderScript)
223 .Case(
"asm", TY_PP_Asm)
225 .Case(
"ccm", TY_CXXModule)
230 .Case(
"cui", TY_PP_CUDA)
233 .Case(
"F90", TY_Fortran)
234 .Case(
"f90", TY_PP_Fortran)
235 .Case(
"F95", TY_Fortran)
236 .Case(
"f95", TY_PP_Fortran)
237 .Case(
"for", TY_PP_Fortran)
238 .Case(
"FOR", TY_PP_Fortran)
239 .Case(
"fpp", TY_Fortran)
240 .Case(
"FPP", TY_Fortran)
243 .Case(
"hpp", TY_CXXHeader)
244 .Case(
"iim", TY_PP_CXXModule)
245 .Case(
"lib", TY_Object)
246 .Case(
"mii", TY_PP_ObjCXX)
247 .Case(
"obj", TY_Object)
249 .Case(
"pcm", TY_ModuleFile)
250 .Case(
"c++m", TY_CXXModule)
251 .Case(
"cppm", TY_CXXModule)
252 .Case(
"cxxm", TY_CXXModule)
257 for (
unsigned i=0; i<
numTypes; ++i) {
260 strcmp(Name,
getInfo(Id).Name) == 0)
269 if (Id != TY_Object) {
290 assert(0 < P.size() &&
"Not enough phases in list");
300 return types::TY_CXX;
302 return types::TY_PP_CXX;
303 case types::TY_CHeader:
304 return types::TY_CXXHeader;
305 case types::TY_PP_CHeader:
306 return types::TY_PP_CXXHeader;
316 return types::TY_CHeader;
318 return types::TY_CXXHeader;
320 return types::TY_ObjCHeader;
321 case types::TY_ObjCXX:
322 return types::TY_ObjCXXHeader;
324 return types::TY_CLHeader;
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...
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.
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 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 isObjC(ID Id)
isObjC - Is this an "ObjC" input (Obj-C and Obj-C++ sources and headers).