Skip to content

Commit 3854236

Browse files
[Clang] Fixes of builtins definitions after PR #68324.
This commit addresses few differences between the `Builtins.def` file before the refactoring done in PR #68324 and the currently generated `Builtins.inc` file.
1 parent 7c3ad9e commit 3854236

File tree

2 files changed

+54
-28
lines changed

2 files changed

+54
-28
lines changed

clang/include/clang/Basic/Builtins.td

+52-28
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,17 @@ class FPMathTemplate : Template<["float", "double", "long double"],
1212
["f", "", "l"]>;
1313

1414
class FPMathWithF16Template :
15-
Template<["float", "double", "long double", "__fp16", "__float128"],
16-
["f", "", "l", "f16", "f128"]>;
15+
Template<["float", "double", "long double", "__fp16"],
16+
["f", "", "l", "f16"]>;
1717

1818
class FPMathWithF16F128Template :
1919
Template<["float", "double", "long double", "__fp16", "__float128"],
2020
["f", "", "l", "f16", "f128"]>;
2121

22+
class FPMathWithF128Template :
23+
Template<["float", "double", "long double", "__float128"],
24+
["f", "", "l", "f128"]>;
25+
2226
class F16F128MathTemplate : Template<["__fp16", "__float128"],
2327
["f16", "f128"]>;
2428

@@ -253,18 +257,30 @@ def FrexpF16F128 : F16F128MathTemplate, Builtin {
253257
let Prototype = "T(T, int*)";
254258
}
255259

256-
def HugeVal : Builtin, FPMathWithF16F128Template {
260+
def HugeVal : Builtin, FPMathWithF128Template {
257261
let Spellings = ["__builtin_huge_val"];
258262
let Attributes = [NoThrow, Const, Constexpr];
259263
let Prototype = "T()";
260264
}
261265

262-
def Inf : Builtin, FPMathWithF16F128Template {
266+
def HugeValF16 : Builtin {
267+
let Spellings = ["__builtin_huge_valf16"];
268+
let Attributes = [NoThrow, Const, Constexpr];
269+
let Prototype = "_Float16()";
270+
}
271+
272+
def Inf : Builtin, FPMathWithF128Template {
263273
let Spellings = ["__builtin_inf"];
264274
let Attributes = [NoThrow, Const, Constexpr];
265275
let Prototype = "T()";
266276
}
267277

278+
def InfF16 : Builtin {
279+
let Spellings = ["__builtin_inff16"];
280+
let Attributes = [NoThrow, Const, Constexpr];
281+
let Prototype = "_Float16()";
282+
}
283+
268284
def LdexpF16F128 : F16F128MathTemplate, Builtin {
269285
let Spellings = ["__builtin_ldexp"];
270286
let Attributes = [FunctionWithBuiltinPrefix, NoThrow, ConstIgnoringErrnoAndExceptions];
@@ -1544,7 +1560,7 @@ def SyncBoolCompareAndSwap : Builtin {
15441560
def SyncBoolCompareAndSwapN : Builtin, SyncBuiltinsTemplate {
15451561
let Spellings = ["__sync_bool_compare_and_swap_"];
15461562
let Attributes = [CustomTypeChecking, NoThrow];
1547-
let Prototype = "T(T volatile*, T, ...)";
1563+
let Prototype = "bool(T volatile*, T, T, ...)";
15481564
}
15491565

15501566
def SyncValCompareAndSwap : Builtin {
@@ -1556,7 +1572,7 @@ def SyncValCompareAndSwap : Builtin {
15561572
def SynLockValCompareAndSwapN : Builtin, SyncBuiltinsTemplate {
15571573
let Spellings = ["__sync_val_compare_and_swap_"];
15581574
let Attributes = [CustomTypeChecking, NoThrow];
1559-
let Prototype = "T(T volatile*, T, ...)";
1575+
let Prototype = "T(T volatile*, T, T, ...)";
15601576
}
15611577

15621578
def SyncLockTestAndSet : Builtin {
@@ -1571,16 +1587,16 @@ def SynLockLockTestAndSetN : Builtin, SyncBuiltinsTemplate {
15711587
let Prototype = "T(T volatile*, T, ...)";
15721588
}
15731589

1574-
def SyncLockReleaseN : Builtin {
1590+
def SyncLockRelease : Builtin {
15751591
let Spellings = ["__sync_lock_release"];
15761592
let Attributes = [CustomTypeChecking];
15771593
let Prototype = "void(...)";
15781594
}
15791595

1580-
def SynLockReleaseN : Builtin, SyncBuiltinsTemplate {
1596+
def SyncLockReleaseN : Builtin, SyncBuiltinsTemplate {
15811597
let Spellings = ["__sync_lock_release_"];
15821598
let Attributes = [CustomTypeChecking, NoThrow];
1583-
let Prototype = "T(T volatile*, T, ...)";
1599+
let Prototype = "void(T volatile*, ...)";
15841600
}
15851601

15861602
def SyncSwap : Builtin {
@@ -2563,6 +2579,13 @@ def Abort : LibBuiltin<"stdlib.h"> {
25632579
let AddBuiltinPrefixedAlias = 1;
25642580
}
25652581

2582+
def Abs : IntMathTemplate, LibBuiltin<"stdlib.h"> {
2583+
let Spellings = ["abs"];
2584+
let Attributes = [NoThrow, Const];
2585+
let Prototype = "T(T)";
2586+
let AddBuiltinPrefixedAlias = 1;
2587+
}
2588+
25662589
def Calloc : LibBuiltin<"stdlib.h"> {
25672590
let Spellings = ["calloc"];
25682591
let Prototype = "void*(size_t, size_t)";
@@ -3079,38 +3102,38 @@ def MemAlign : GNULibBuiltin<"malloc.h"> {
30793102

30803103
// POSIX string.h
30813104

3082-
def MemcCpy : GNULibBuiltin<"stdlib.h"> {
3105+
def MemcCpy : GNULibBuiltin<"string.h"> {
30833106
let Spellings = ["memccpy"];
30843107
let Prototype = "void*(void*, void const*, int, size_t)";
30853108
}
30863109

3087-
def MempCpy : GNULibBuiltin<"stdlib.h"> {
3110+
def MempCpy : GNULibBuiltin<"string.h"> {
30883111
let Spellings = ["mempcpy"];
30893112
let Prototype = "void*(void*, void const*, size_t)";
30903113
}
30913114

3092-
def StpCpy : GNULibBuiltin<"stdlib.h"> {
3115+
def StpCpy : GNULibBuiltin<"string.h"> {
30933116
let Spellings = ["stpcpy"];
30943117
let Attributes = [NoThrow];
30953118
let Prototype = "char*(char*, char const*)";
30963119
let AddBuiltinPrefixedAlias = 1;
30973120
}
30983121

3099-
def StpnCpy : GNULibBuiltin<"stdlib.h"> {
3122+
def StpnCpy : GNULibBuiltin<"string.h"> {
31003123
let Spellings = ["stpncpy"];
31013124
let Attributes = [NoThrow];
31023125
let Prototype = "char*(char*, char const*, size_t)";
31033126
let AddBuiltinPrefixedAlias = 1;
31043127
}
31053128

3106-
def StrDup : GNULibBuiltin<"stdlib.h"> {
3129+
def StrDup : GNULibBuiltin<"string.h"> {
31073130
let Spellings = ["strdup"];
31083131
let Attributes = [NoThrow];
31093132
let Prototype = "char*(char const*)";
31103133
let AddBuiltinPrefixedAlias = 1;
31113134
}
31123135

3113-
def StrnDup : GNULibBuiltin<"stdlib.h"> {
3136+
def StrnDup : GNULibBuiltin<"string.h"> {
31143137
let Spellings = ["strndup"];
31153138
let Attributes = [NoThrow];
31163139
let Prototype = "char*(char const*, size_t)";
@@ -3280,22 +3303,22 @@ def ObjcEnumerationMutation : ObjCLibBuiltin<"objc/runtime.h"> {
32803303
let Prototype = "void(id)";
32813304
}
32823305

3283-
def ObjcReadWeak : ObjCLibBuiltin<"objc/message.h"> {
3306+
def ObjcReadWeak : ObjCLibBuiltin<"objc/objc-auto.h"> {
32843307
let Spellings = ["objc_read_weak"];
32853308
let Prototype = "id(id*)";
32863309
}
32873310

3288-
def ObjcAssignWeak : ObjCLibBuiltin<"objc/message.h"> {
3311+
def ObjcAssignWeak : ObjCLibBuiltin<"objc/objc-auto.h"> {
32893312
let Spellings = ["objc_assign_weak"];
32903313
let Prototype = "id(id, id*)";
32913314
}
32923315

3293-
def ObjcAssignIvar : ObjCLibBuiltin<"objc/message.h"> {
3316+
def ObjcAssignIvar : ObjCLibBuiltin<"objc/objc-auto.h"> {
32943317
let Spellings = ["objc_assign_ivar"];
32953318
let Prototype = "id(id, id, ptrdiff_t)";
32963319
}
32973320

3298-
def ObjcAssignGlobal : ObjCLibBuiltin<"objc/message.h"> {
3321+
def ObjcAssignGlobal : ObjCLibBuiltin<"objc/objc-auto.h"> {
32993322
let Spellings = ["objc_assign_global"];
33003323
let Prototype = "id(id, id*)";
33013324
}
@@ -3365,13 +3388,6 @@ def Atan2 : FPMathTemplate, LibBuiltin<"math.h"> {
33653388
let AddBuiltinPrefixedAlias = 1;
33663389
}
33673390

3368-
def Abs : IntMathTemplate, LibBuiltin<"math.h"> {
3369-
let Spellings = ["abs"];
3370-
let Attributes = [NoThrow, Const];
3371-
let Prototype = "T(T)";
3372-
let AddBuiltinPrefixedAlias = 1;
3373-
}
3374-
33753391
def Copysign : FPMathTemplate, LibBuiltin<"math.h"> {
33763392
let Spellings = ["copysign"];
33773393
let Attributes = [NoThrow, Const];
@@ -3990,8 +4006,16 @@ def BlockObjectDispose : LibBuiltin<"blocks.h"> {
39904006
}
39914007
// FIXME: Also declare NSConcreteGlobalBlock and NSConcreteStackBlock.
39924008

4009+
def __Addressof : LangBuiltin<"CXX_LANG"> {
4010+
let Spellings = ["__addressof"];
4011+
let Attributes = [FunctionWithoutBuiltinPrefix, NoThrow, Const,
4012+
IgnoreSignature, Constexpr];
4013+
let Prototype = "void*(void&)";
4014+
let Namespace = "std";
4015+
}
4016+
39934017
def Addressof : CxxLibBuiltin<"memory"> {
3994-
let Spellings = ["addressof", "__addressof"];
4018+
let Spellings = ["addressof"];
39954019
let Attributes = [NoThrow, Const, IgnoreSignature, RequireDeclaration,
39964020
Constexpr];
39974021
let Prototype = "void*(void&)";
@@ -4030,7 +4054,7 @@ def Move : CxxLibBuiltin<"utility"> {
40304054
let Namespace = "std";
40314055
}
40324056

4033-
def MoveIfNsoexcept : CxxLibBuiltin<"memory"> {
4057+
def MoveIfNsoexcept : CxxLibBuiltin<"utility"> {
40344058
let Spellings = ["move_if_noexcept"];
40354059
let Attributes = [NoThrow, Const, IgnoreSignature, RequireDeclaration,
40364060
Constexpr];

clang/include/clang/Basic/BuiltinsBase.td

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def UnevaluatedArguments : Attribute<"u">;
4949
// is required for a builtin.
5050
def FunctionWithBuiltinPrefix : Attribute<"F">;
5151

52+
def FunctionWithoutBuiltinPrefix : Attribute<"f">;
53+
5254
// const, but only when -fno-math-errno and FP exceptions are ignored.
5355
def ConstIgnoringErrnoAndExceptions : Attribute<"e">;
5456

0 commit comments

Comments
 (0)