17 #include "llvm/ADT/StringRef.h"
18 using namespace clang;
21 {
"not a builtin function",
nullptr,
nullptr,
nullptr,
ALL_LANGUAGES,
nullptr},
22 #define BUILTIN(ID, TYPE, ATTRS) \
23 { #ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr },
24 #define LANGBUILTIN(ID, TYPE, ATTRS, LANGS) \
25 { #ID, TYPE, ATTRS, nullptr, LANGS, nullptr },
26 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER, LANGS) \
27 { #ID, TYPE, ATTRS, HEADER, LANGS, nullptr },
28 #include "clang/Basic/Builtins.def"
35 (TSRecords.size() + AuxTSRecords.size())) &&
36 "Invalid builtin ID!");
44 assert(TSRecords.empty() &&
"Already initialized target?");
45 TSRecords =
Target.getTargetBuiltins();
53 return strchr(
BuiltinInfo[i].Attributes,
'f') !=
nullptr;
60 bool BuiltinsUnsupported =
63 bool MathBuiltinsUnsupported =
67 bool MSModeUnsupported =
70 bool OclC1Unsupported = (LangOpts.OpenCLVersion / 100) != 1 &&
72 bool OclC2Unsupported =
73 (LangOpts.OpenCLVersion != 200 && !LangOpts.OpenCLCPlusPlus) &&
75 bool OclCUnsupported = !LangOpts.OpenCL &&
79 bool CPlusPlusUnsupported =
81 return !BuiltinsUnsupported && !MathBuiltinsUnsupported && !OclCUnsupported &&
82 !OclC1Unsupported && !OclC2Unsupported && !OpenMPUnsupported &&
83 !GnuModeUnsupported && !MSModeUnsupported && !ObjCUnsupported &&
84 !CPlusPlusUnsupported && !CUDAUnsupported;
99 for (
unsigned i = 0, e = TSRecords.size(); i != e; ++i)
100 if (builtinIsSupported(TSRecords[i], LangOpts))
104 for (
unsigned i = 0, e = AuxTSRecords.size(); i != e; ++i)
105 Table.
get(AuxTSRecords[i].Name)
110 const char *WidthPos = ::strchr(getRecord(
ID).Attributes,
'V');
115 assert(*WidthPos ==
':' &&
116 "Vector width specifier must be followed by a ':'");
120 unsigned Width = ::strtol(WidthPos, &EndPos, 10);
121 assert(*EndPos ==
':' &&
"Vector width specific must end with a ':'");
125 bool Builtin::Context::isLike(
unsigned ID,
unsigned &FormatIdx,
126 bool &HasVAListArg,
const char *Fmt)
const {
127 assert(Fmt &&
"Not passed a format string");
128 assert(::strlen(Fmt) == 2 &&
129 "Format string needs to be two characters long");
130 assert(::toupper(Fmt[0]) == Fmt[1] &&
131 "Format string is not in the form \"xX\"");
133 const char *Like = ::strpbrk(getRecord(
ID).Attributes, Fmt);
137 HasVAListArg = (*Like == Fmt[1]);
140 assert(*Like ==
':' &&
"Format specifier must be followed by a ':'");
143 assert(::strchr(Like,
':') &&
"Format specifier must end with a ':'");
144 FormatIdx = ::strtol(Like,
nullptr, 10);
149 bool &HasVAListArg) {
150 return isLike(
ID, FormatIdx, HasVAListArg,
"pP");
154 bool &HasVAListArg) {
155 return isLike(
ID, FormatIdx, HasVAListArg,
"sS");
160 const char *CalleePos = ::strchr(getRecord(
ID).Attributes,
'C');
165 assert(*CalleePos ==
'<' &&
166 "Callback callee specifier must be followed by a '<'");
170 int CalleeIdx = ::strtol(CalleePos, &EndPos, 10);
171 assert(CalleeIdx >= 0 &&
"Callee index is supposed to be positive!");
174 while (*EndPos ==
',') {
175 const char *PayloadPos = EndPos + 1;
177 int PayloadIdx = ::strtol(PayloadPos, &EndPos, 10);
181 assert(*EndPos ==
'>' &&
"Callback callee specifier must end with a '>'");
187 ID == Builtin::BI__va_start ||
188 (!hasReferenceArgsOrResult(
ID) &&
189 !hasCustomTypechecking(
ID));