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:
105 case TY_ObjC:
case TY_PP_ObjC:
case TY_PP_ObjC_Alias:
106 case TY_CXX:
case TY_PP_CXX:
107 case TY_ObjCXX:
case TY_PP_ObjCXX:
case TY_PP_ObjCXX_Alias:
108 case TY_CHeader:
case TY_PP_CHeader:
110 case TY_ObjCHeader:
case TY_PP_ObjCHeader:
111 case TY_CXXHeader:
case TY_PP_CXXHeader:
112 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
113 case TY_CXXModule:
case TY_PP_CXXModule:
114 case TY_AST:
case TY_ModuleFile:
115 case TY_LLVM_IR:
case TY_LLVM_BC:
125 case TY_ObjC:
case TY_PP_ObjC:
case TY_PP_ObjC_Alias:
126 case TY_ObjCXX:
case TY_PP_ObjCXX:
127 case TY_ObjCHeader:
case TY_PP_ObjCHeader:
128 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
case TY_PP_ObjCXX_Alias:
138 case TY_CXX:
case TY_PP_CXX:
139 case TY_ObjCXX:
case TY_PP_ObjCXX:
case TY_PP_ObjCXX_Alias:
140 case TY_CXXHeader:
case TY_PP_CXXHeader:
141 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
142 case TY_CXXModule:
case TY_PP_CXXModule:
143 case TY_CUDA:
case TY_PP_CUDA:
case TY_CUDA_DEVICE:
178 return llvm::StringSwitch<types::ID>(Ext)
181 .Case(
"F", TY_Fortran)
182 .Case(
"f", TY_PP_Fortran)
183 .Case(
"h", TY_CHeader)
184 .Case(
"H", TY_CXXHeader)
187 .Case(
"M", TY_ObjCXX)
188 .Case(
"o", TY_Object)
190 .Case(
"s", TY_PP_Asm)
191 .Case(
"bc", TY_LLVM_BC)
197 .Case(
"hh", TY_CXXHeader)
198 .Case(
"ii", TY_PP_CXX)
199 .Case(
"ll", TY_LLVM_IR)
200 .Case(
"mi", TY_PP_ObjC)
201 .Case(
"mm", TY_ObjCXX)
202 .Case(
"rs", TY_RenderScript)
205 .Case(
"asm", TY_PP_Asm)
207 .Case(
"ccm", TY_CXXModule)
212 .Case(
"cui", TY_PP_CUDA)
215 .Case(
"F90", TY_Fortran)
216 .Case(
"f90", TY_PP_Fortran)
217 .Case(
"F95", TY_Fortran)
218 .Case(
"f95", TY_PP_Fortran)
219 .Case(
"for", TY_PP_Fortran)
220 .Case(
"FOR", TY_PP_Fortran)
221 .Case(
"fpp", TY_Fortran)
222 .Case(
"FPP", TY_Fortran)
224 .Case(
"hpp", TY_CXXHeader)
225 .Case(
"iim", TY_PP_CXXModule)
226 .Case(
"lib", TY_Object)
227 .Case(
"mii", TY_PP_ObjCXX)
228 .Case(
"obj", TY_Object)
230 .Case(
"pcm", TY_ModuleFile)
231 .Case(
"c++m", TY_CXXModule)
232 .Case(
"cppm", TY_CXXModule)
233 .Case(
"cxxm", TY_CXXModule)
238 for (
unsigned i=0; i<
numTypes; ++i) {
241 strcmp(Name,
getInfo(Id).Name) == 0)
250 if (Id != TY_Object) {
271 assert(0 < P.size() &&
"Not enough phases in list");
281 return types::TY_CXX;
283 return types::TY_PP_CXX;
284 case types::TY_CHeader:
285 return types::TY_CXXHeader;
286 case types::TY_PP_CHeader:
287 return types::TY_PP_CXXHeader;
297 return types::TY_CHeader;
299 return types::TY_CXXHeader;
301 return types::TY_ObjCHeader;
302 case types::TY_ObjCXX:
303 return types::TY_ObjCXXHeader;
305 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
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).