11 #include "llvm/ADT/STLExtras.h"
12 #include "llvm/ADT/StringSwitch.h"
16 using namespace clang::driver;
17 using namespace clang::driver::types;
27 #define TYPE(NAME, ID, PP_TYPE, TEMP_SUFFIX, FLAGS) \
28 { NAME, FLAGS, TEMP_SUFFIX, TY_##PP_TYPE, },
29 #include "clang/Driver/Types.def"
35 assert(
id > 0 &&
id - 1 <
numTypes &&
"Invalid Type ID.");
48 if (Id == TY_Object && CLMode)
50 if (Id == TY_Image && CLMode)
52 if (Id == TY_PP_Asm && CLMode)
58 return strchr(
getInfo(Id).Flags,
'a');
62 return strchr(
getInfo(Id).Flags,
'p');
66 return strchr(
getInfo(Id).Flags,
'u');
70 return strchr(
getInfo(Id).Flags,
'A');
74 return (Id == TY_Nothing ||
86 case TY_C:
case TY_PP_C:
88 case TY_CUDA:
case TY_PP_CUDA:
90 case TY_ObjC:
case TY_PP_ObjC:
case TY_PP_ObjC_Alias:
91 case TY_CXX:
case TY_PP_CXX:
92 case TY_ObjCXX:
case TY_PP_ObjCXX:
case TY_PP_ObjCXX_Alias:
93 case TY_CHeader:
case TY_PP_CHeader:
95 case TY_ObjCHeader:
case TY_PP_ObjCHeader:
96 case TY_CXXHeader:
case TY_PP_CXXHeader:
97 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
98 case TY_AST:
case TY_ModuleFile:
99 case TY_LLVM_IR:
case TY_LLVM_BC:
109 case TY_ObjC:
case TY_PP_ObjC:
case TY_PP_ObjC_Alias:
110 case TY_ObjCXX:
case TY_PP_ObjCXX:
111 case TY_ObjCHeader:
case TY_PP_ObjCHeader:
112 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
case TY_PP_ObjCXX_Alias:
122 case TY_CXX:
case TY_PP_CXX:
123 case TY_ObjCXX:
case TY_PP_ObjCXX:
case TY_PP_ObjCXX_Alias:
124 case TY_CXXHeader:
case TY_PP_CXXHeader:
125 case TY_ObjCXXHeader:
case TY_PP_ObjCXXHeader:
126 case TY_CUDA:
case TY_PP_CUDA:
case TY_CUDA_DEVICE:
157 return llvm::StringSwitch<types::ID>(Ext)
161 .Case(
"M", TY_ObjCXX)
162 .Case(
"h", TY_CHeader)
164 .Case(
"H", TY_CXXHeader)
165 .Case(
"f", TY_PP_Fortran)
166 .Case(
"F", TY_Fortran)
167 .Case(
"s", TY_PP_Asm)
168 .Case(
"asm", TY_PP_Asm)
170 .Case(
"o", TY_Object)
171 .Case(
"obj", TY_Object)
172 .Case(
"lib", TY_Object)
173 .Case(
"ii", TY_PP_CXX)
174 .Case(
"mi", TY_PP_ObjC)
175 .Case(
"mm", TY_ObjCXX)
176 .Case(
"bc", TY_LLVM_BC)
182 .Case(
"cui", TY_PP_CUDA)
183 .Case(
"hh", TY_CXXHeader)
184 .Case(
"ll", TY_LLVM_IR)
185 .Case(
"hpp", TY_CXXHeader)
195 .Case(
"for", TY_PP_Fortran)
196 .Case(
"FOR", TY_PP_Fortran)
197 .Case(
"fpp", TY_Fortran)
198 .Case(
"FPP", TY_Fortran)
199 .Case(
"f90", TY_PP_Fortran)
200 .Case(
"f95", TY_PP_Fortran)
201 .Case(
"F90", TY_Fortran)
202 .Case(
"F95", TY_Fortran)
203 .Case(
"mii", TY_PP_ObjCXX)
204 .Case(
"pcm", TY_ModuleFile)
207 .Case(
"rs", TY_RenderScript)
212 for (
unsigned i=0; i<
numTypes; ++i) {
215 strcmp(Name,
getInfo(Id).Name) == 0)
224 if (Id != TY_Object) {
243 assert(0 < P.size() &&
"Not enough phases in list");
253 return types::TY_CXX;
255 return types::TY_PP_CXX;
256 case types::TY_CHeader:
257 return types::TY_CXXHeader;
258 case types::TY_PP_CHeader:
259 return types::TY_PP_CXXHeader;
ID lookupTypeForExtension(const char *Ext)
lookupTypeForExtension - Lookup the type to use for the file extension Ext.
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...
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
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[]
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.
static const TypeInfo & getInfo(unsigned id)
bool isCXX(ID Id)
isCXX - Is this a "C++" input (C++ and Obj-C++ sources and headers).
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 isObjC(ID Id)
isObjC - Is this an "ObjC" input (Obj-C and Obj-C++ sources and headers).