This file is indexed.

/usr/share/doc/clang-3.8-doc/html/AttributeReference.html is in clang-3.8-doc 1:3.8-2ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Attributes in Clang &mdash; Clang 3.8 documentation</title>
    
    <link rel="stylesheet" href="_static/haiku.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '3.8',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="top" title="Clang 3.8 documentation" href="index.html" />
    <link rel="next" title="Cross-compilation using Clang" href="CrossCompilation.html" />
    <link rel="prev" title="Objective-C Automatic Reference Counting (ARC)" href="AutomaticReferenceCounting.html" /> 
  </head>
  <body role="document">
      <div class="header" role="banner"><h1 class="heading"><a href="index.html">
          <span>Clang 3.8 documentation</span></a></h1>
        <h2 class="heading"><span>Attributes in Clang</span></h2>
      </div>
      <div class="topnav" role="navigation" aria-label="top navigation">
      
        <p>
        «&#160;&#160;<a href="AutomaticReferenceCounting.html">Objective-C Automatic Reference Counting (ARC)</a>
        &#160;&#160;::&#160;&#160;
        <a class="uplink" href="index.html">Contents</a>
        &#160;&#160;::&#160;&#160;
        <a href="CrossCompilation.html">Cross-compilation using Clang</a>&#160;&#160;»
        </p>

      </div>
      <div class="content">
        
        
  <div class="section" id="attributes-in-clang">
<h1>Attributes in Clang<a class="headerlink" href="#attributes-in-clang" title="Permalink to this headline"></a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#introduction" id="id76">Introduction</a></li>
<li><a class="reference internal" href="#function-attributes" id="id77">Function Attributes</a><ul>
<li><a class="reference internal" href="#interrupt" id="id78">interrupt</a></li>
<li><a class="reference internal" href="#acquire-capability-acquire-shared-capability-clang-acquire-capability-clang-acquire-shared-capability" id="id79">acquire_capability (acquire_shared_capability, clang::acquire_capability, clang::acquire_shared_capability)</a></li>
<li><a class="reference internal" href="#assert-capability-assert-shared-capability-clang-assert-capability-clang-assert-shared-capability" id="id80">assert_capability (assert_shared_capability, clang::assert_capability, clang::assert_shared_capability)</a></li>
<li><a class="reference internal" href="#assume-aligned-gnu-assume-aligned" id="id81">assume_aligned (gnu::assume_aligned)</a></li>
<li><a class="reference internal" href="#availability" id="id82">availability</a></li>
<li><a class="reference internal" href="#noreturn" id="id83">_Noreturn</a></li>
<li><a class="reference internal" href="#id1" id="id84">noreturn</a></li>
<li><a class="reference internal" href="#carries-dependency" id="id85">carries_dependency</a></li>
<li><a class="reference internal" href="#disable-tail-calls-clang-disable-tail-calls" id="id86">disable_tail_calls (clang::disable_tail_calls)</a></li>
<li><a class="reference internal" href="#enable-if" id="id87">enable_if</a></li>
<li><a class="reference internal" href="#flatten-gnu-flatten" id="id88">flatten (gnu::flatten)</a></li>
<li><a class="reference internal" href="#format-gnu-format" id="id89">format (gnu::format)</a></li>
<li><a class="reference internal" href="#internal-linkage-clang-internal-linkage" id="id90">internal_linkage (clang::internal_linkage)</a></li>
<li><a class="reference internal" href="#id2" id="id91">interrupt</a></li>
<li><a class="reference internal" href="#noalias" id="id92">noalias</a></li>
<li><a class="reference internal" href="#noduplicate-clang-noduplicate" id="id93">noduplicate (clang::noduplicate)</a></li>
<li><a class="reference internal" href="#no-sanitize-clang-no-sanitize" id="id94">no_sanitize (clang::no_sanitize)</a></li>
<li><a class="reference internal" href="#no-sanitize-address-no-address-safety-analysis-gnu-no-address-safety-analysis-gnu-no-sanitize-address" id="id95">no_sanitize_address (no_address_safety_analysis, gnu::no_address_safety_analysis, gnu::no_sanitize_address)</a></li>
<li><a class="reference internal" href="#no-sanitize-thread" id="id96">no_sanitize_thread</a></li>
<li><a class="reference internal" href="#no-sanitize-memory" id="id97">no_sanitize_memory</a></li>
<li><a class="reference internal" href="#no-split-stack-gnu-no-split-stack" id="id98">no_split_stack (gnu::no_split_stack)</a></li>
<li><a class="reference internal" href="#not-tail-called-clang-not-tail-called" id="id99">not_tail_called (clang::not_tail_called)</a></li>
<li><a class="reference internal" href="#objc-boxable" id="id100">objc_boxable</a></li>
<li><a class="reference internal" href="#objc-method-family" id="id101">objc_method_family</a></li>
<li><a class="reference internal" href="#objc-requires-super" id="id102">objc_requires_super</a></li>
<li><a class="reference internal" href="#objc-runtime-name" id="id103">objc_runtime_name</a></li>
<li><a class="reference internal" href="#optnone-clang-optnone" id="id104">optnone (clang::optnone)</a></li>
<li><a class="reference internal" href="#overloadable" id="id105">overloadable</a></li>
<li><a class="reference internal" href="#release-capability-release-shared-capability-clang-release-capability-clang-release-shared-capability" id="id106">release_capability (release_shared_capability, clang::release_capability, clang::release_shared_capability)</a></li>
<li><a class="reference internal" href="#target-gnu-target" id="id107">target (gnu::target)</a></li>
<li><a class="reference internal" href="#try-acquire-capability-try-acquire-shared-capability-clang-try-acquire-capability-clang-try-acquire-shared-capability" id="id108">try_acquire_capability (try_acquire_shared_capability, clang::try_acquire_capability, clang::try_acquire_shared_capability)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#variable-attributes" id="id109">Variable Attributes</a><ul>
<li><a class="reference internal" href="#init-seg" id="id110">init_seg</a></li>
<li><a class="reference internal" href="#pass-object-size" id="id111">pass_object_size</a></li>
<li><a class="reference internal" href="#section-gnu-section-declspec-allocate" id="id112">section (gnu::section, __declspec(allocate))</a></li>
<li><a class="reference internal" href="#tls-model-gnu-tls-model" id="id113">tls_model (gnu::tls_model)</a></li>
<li><a class="reference internal" href="#thread" id="id114">thread</a></li>
</ul>
</li>
<li><a class="reference internal" href="#type-attributes" id="id115">Type Attributes</a><ul>
<li><a class="reference internal" href="#align-value" id="id116">align_value</a></li>
<li><a class="reference internal" href="#flag-enum" id="id117">flag_enum</a></li>
<li><a class="reference internal" href="#single-inhertiance-multiple-inheritance-virtual-inheritance" id="id118">__single_inhertiance, __multiple_inheritance, __virtual_inheritance</a></li>
<li><a class="reference internal" href="#novtable" id="id119">novtable</a></li>
</ul>
</li>
<li><a class="reference internal" href="#statement-attributes" id="id120">Statement Attributes</a><ul>
<li><a class="reference internal" href="#fallthrough-clang-fallthrough" id="id121">fallthrough (clang::fallthrough)</a></li>
<li><a class="reference internal" href="#pragma-clang-loop" id="id122">#pragma clang loop</a></li>
<li><a class="reference internal" href="#pragma-unroll-pragma-nounroll" id="id123">#pragma unroll, #pragma nounroll</a></li>
</ul>
</li>
<li><a class="reference internal" href="#type-safety-checking" id="id124">Type Safety Checking</a><ul>
<li><a class="reference internal" href="#argument-with-type-tag" id="id125">argument_with_type_tag</a></li>
<li><a class="reference internal" href="#pointer-with-type-tag" id="id126">pointer_with_type_tag</a></li>
<li><a class="reference internal" href="#type-tag-for-datatype" id="id127">type_tag_for_datatype</a></li>
</ul>
</li>
<li><a class="reference internal" href="#amd-gpu-register-attributes" id="id128">AMD GPU Register Attributes</a><ul>
<li><a class="reference internal" href="#amdgpu-num-sgpr" id="id129">amdgpu_num_sgpr</a></li>
<li><a class="reference internal" href="#amdgpu-num-vgpr" id="id130">amdgpu_num_vgpr</a></li>
</ul>
</li>
<li><a class="reference internal" href="#calling-conventions" id="id131">Calling Conventions</a><ul>
<li><a class="reference internal" href="#fastcall-gnu-fastcall-fastcall-fastcall" id="id132">fastcall (gnu::fastcall, __fastcall, _fastcall)</a></li>
<li><a class="reference internal" href="#ms-abi-gnu-ms-abi" id="id133">ms_abi (gnu::ms_abi)</a></li>
<li><a class="reference internal" href="#pcs-gnu-pcs" id="id134">pcs (gnu::pcs)</a></li>
<li><a class="reference internal" href="#regparm-gnu-regparm" id="id135">regparm (gnu::regparm)</a></li>
<li><a class="reference internal" href="#stdcall-gnu-stdcall-stdcall-stdcall" id="id136">stdcall (gnu::stdcall, __stdcall, _stdcall)</a></li>
<li><a class="reference internal" href="#thiscall-gnu-thiscall-thiscall-thiscall" id="id137">thiscall (gnu::thiscall, __thiscall, _thiscall)</a></li>
<li><a class="reference internal" href="#vectorcall-vectorcall-vectorcall" id="id138">vectorcall (__vectorcall, _vectorcall)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#consumed-annotation-checking" id="id139">Consumed Annotation Checking</a><ul>
<li><a class="reference internal" href="#callable-when" id="id140">callable_when</a></li>
<li><a class="reference internal" href="#consumable" id="id141">consumable</a></li>
<li><a class="reference internal" href="#param-typestate" id="id142">param_typestate</a></li>
<li><a class="reference internal" href="#return-typestate" id="id143">return_typestate</a></li>
<li><a class="reference internal" href="#set-typestate" id="id144">set_typestate</a></li>
<li><a class="reference internal" href="#test-typestate" id="id145">test_typestate</a></li>
</ul>
</li>
<li><a class="reference internal" href="#opencl-address-spaces" id="id146">OpenCL Address Spaces</a><ul>
<li><a class="reference internal" href="#constant-constant" id="id147">constant (__constant)</a></li>
<li><a class="reference internal" href="#generic-generic" id="id148">generic (__generic)</a></li>
<li><a class="reference internal" href="#global-global" id="id149">global (__global)</a></li>
<li><a class="reference internal" href="#local-local" id="id150">local (__local)</a></li>
<li><a class="reference internal" href="#private-private" id="id151">private (__private)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#nullability-attributes" id="id152">Nullability Attributes</a><ul>
<li><a class="reference internal" href="#nonnull-gnu-nonnull" id="id153">nonnull (gnu::nonnull)</a></li>
<li><a class="reference internal" href="#returns-nonnull-gnu-returns-nonnull" id="id154">returns_nonnull (gnu::returns_nonnull)</a></li>
<li><a class="reference internal" href="#nonnull" id="id155">_Nonnull</a></li>
<li><a class="reference internal" href="#null-unspecified" id="id156">_Null_unspecified</a></li>
<li><a class="reference internal" href="#nullable" id="id157">_Nullable</a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="introduction">
<h2><a class="toc-backref" href="#id76">Introduction</a><a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h2>
<p>This page lists the attributes currently supported by Clang.</p>
</div>
<div class="section" id="function-attributes">
<h2><a class="toc-backref" href="#id77">Function Attributes</a><a class="headerlink" href="#function-attributes" title="Permalink to this headline"></a></h2>
<div class="section" id="interrupt">
<h3><a class="toc-backref" href="#id78">interrupt</a><a class="headerlink" href="#interrupt" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id5">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id5" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Clang supports the GNU style <code class="docutils literal"><span class="pre">__attribute__((interrupt(&quot;TYPE&quot;)))</span></code> attribute on
ARM targets. This attribute may be attached to a function definition and
instructs the backend to generate appropriate function entry/exit code so that
it can be used directly as an interrupt service routine.</p>
<p>The parameter passed to the interrupt attribute is optional, but if
provided it must be a string literal with one of the following values: &#8220;IRQ&#8221;,
&#8220;FIQ&#8221;, &#8220;SWI&#8221;, &#8220;ABORT&#8221;, &#8220;UNDEF&#8221;.</p>
<p>The semantics are as follows:</p>
<ul>
<li><p class="first">If the function is AAPCS, Clang instructs the backend to realign the stack to
8 bytes on entry. This is a general requirement of the AAPCS at public
interfaces, but may not hold when an exception is taken. Doing this allows
other AAPCS functions to be called.</p>
</li>
<li><p class="first">If the CPU is M-class this is all that needs to be done since the architecture
itself is designed in such a way that functions obeying the normal AAPCS ABI
constraints are valid exception handlers.</p>
</li>
<li><p class="first">If the CPU is not M-class, the prologue and epilogue are modified to save all
non-banked registers that are used, so that upon return the user-mode state
will not be corrupted. Note that to avoid unnecessary overhead, only
general-purpose (integer) registers are saved in this way. If VFP operations
are needed, that state must be saved manually.</p>
<p>Specifically, interrupt kinds other than &#8220;FIQ&#8221; will save all core registers
except &#8220;lr&#8221; and &#8220;sp&#8221;. &#8220;FIQ&#8221; interrupts will save r0-r7.</p>
</li>
<li><p class="first">If the CPU is not M-class, the return instruction is changed to one of the
canonical sequences permitted by the architecture for exception return. Where
possible the function itself will make the necessary &#8220;lr&#8221; adjustments so that
the &#8220;preferred return address&#8221; is selected.</p>
<p>Unfortunately the compiler is unable to make this guarantee for an &#8220;UNDEF&#8221;
handler, where the offset from &#8220;lr&#8221; to the preferred return address depends on
the execution state of the code which generated the exception. In this case
a sequence equivalent to &#8220;movs pc, lr&#8221; will be used.</p>
</li>
</ul>
</div>
<div class="section" id="acquire-capability-acquire-shared-capability-clang-acquire-capability-clang-acquire-shared-capability">
<h3><a class="toc-backref" href="#id79">acquire_capability (acquire_shared_capability, clang::acquire_capability, clang::acquire_shared_capability)</a><a class="headerlink" href="#acquire-capability-acquire-shared-capability-clang-acquire-capability-clang-acquire-shared-capability" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id6">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id6" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Marks a function as acquiring a capability.</p>
</div>
<div class="section" id="assert-capability-assert-shared-capability-clang-assert-capability-clang-assert-shared-capability">
<h3><a class="toc-backref" href="#id80">assert_capability (assert_shared_capability, clang::assert_capability, clang::assert_shared_capability)</a><a class="headerlink" href="#assert-capability-assert-shared-capability-clang-assert-capability-clang-assert-shared-capability" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id7">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id7" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Marks a function that dynamically tests whether a capability is held, and halts
the program if it is not held.</p>
</div>
<div class="section" id="assume-aligned-gnu-assume-aligned">
<h3><a class="toc-backref" href="#id81">assume_aligned (gnu::assume_aligned)</a><a class="headerlink" href="#assume-aligned-gnu-assume-aligned" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id8">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id8" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Use <code class="docutils literal"><span class="pre">__attribute__((assume_aligned(&lt;alignment&gt;[,&lt;offset&gt;]))</span></code> on a function
declaration to specify that the return value of the function (which must be a
pointer type) has the specified offset, in bytes, from an address with the
specified alignment. The offset is taken to be zero if omitted.</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="c1">// The returned pointer value has 32-byte alignment.</span>
<span class="kt">void</span> <span class="o">*</span><span class="nf">a</span><span class="p">()</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">assume_aligned</span> <span class="p">(</span><span class="mi">32</span><span class="p">)));</span>

<span class="c1">// The returned pointer value is 4 bytes greater than an address having</span>
<span class="c1">// 32-byte alignment.</span>
<span class="kt">void</span> <span class="o">*</span><span class="nf">b</span><span class="p">()</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">assume_aligned</span> <span class="p">(</span><span class="mi">32</span><span class="p">,</span> <span class="mi">4</span><span class="p">)));</span>
</pre></div>
</div>
<p>Note that this attribute provides information to the compiler regarding a
condition that the code already ensures is true. It does not cause the compiler
to enforce the provided alignment assumption.</p>
</div>
<div class="section" id="availability">
<h3><a class="toc-backref" href="#id82">availability</a><a class="headerlink" href="#availability" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id9">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id9" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">availability</span></code> attribute can be placed on declarations to describe the
lifecycle of that declaration relative to operating system versions.  Consider
the function declaration for a hypothetical function <code class="docutils literal"><span class="pre">f</span></code>:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">f</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">availability</span><span class="p">(</span><span class="n">macosx</span><span class="p">,</span><span class="n">introduced</span><span class="o">=</span><span class="mf">10.4</span><span class="p">,</span><span class="n">deprecated</span><span class="o">=</span><span class="mf">10.6</span><span class="p">,</span><span class="n">obsoleted</span><span class="o">=</span><span class="mf">10.7</span><span class="p">)));</span>
</pre></div>
</div>
<p>The availability attribute states that <code class="docutils literal"><span class="pre">f</span></code> was introduced in Mac OS X 10.4,
deprecated in Mac OS X 10.6, and obsoleted in Mac OS X 10.7.  This information
is used by Clang to determine when it is safe to use <code class="docutils literal"><span class="pre">f</span></code>: for example, if
Clang is instructed to compile code for Mac OS X 10.5, a call to <code class="docutils literal"><span class="pre">f()</span></code>
succeeds.  If Clang is instructed to compile code for Mac OS X 10.6, the call
succeeds but Clang emits a warning specifying that the function is deprecated.
Finally, if Clang is instructed to compile code for Mac OS X 10.7, the call
fails because <code class="docutils literal"><span class="pre">f()</span></code> is no longer available.</p>
<p>The availability attribute is a comma-separated list starting with the
platform name and then including clauses specifying important milestones in the
declaration&#8217;s lifetime (in any order) along with additional information.  Those
clauses can be:</p>
<dl class="docutils">
<dt>introduced=<em>version</em></dt>
<dd>The first version in which this declaration was introduced.</dd>
<dt>deprecated=<em>version</em></dt>
<dd>The first version in which this declaration was deprecated, meaning that
users should migrate away from this API.</dd>
<dt>obsoleted=<em>version</em></dt>
<dd>The first version in which this declaration was obsoleted, meaning that it
was removed completely and can no longer be used.</dd>
<dt>unavailable</dt>
<dd>This declaration is never available on this platform.</dd>
<dt>message=<em>string-literal</em></dt>
<dd>Additional message text that Clang will provide when emitting a warning or
error about use of a deprecated or obsoleted declaration.  Useful to direct
users to replacement APIs.</dd>
</dl>
<p>Multiple availability attributes can be placed on a declaration, which may
correspond to different platforms.  Only the availability attribute with the
platform corresponding to the target platform will be used; any others will be
ignored.  If no availability attribute specifies availability for the current
target platform, the availability attributes are ignored.  Supported platforms
are:</p>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">ios</span></code></dt>
<dd>Apple&#8217;s iOS operating system.  The minimum deployment target is specified by
the <code class="docutils literal"><span class="pre">-mios-version-min=*version*</span></code> or <code class="docutils literal"><span class="pre">-miphoneos-version-min=*version*</span></code>
command-line arguments.</dd>
<dt><code class="docutils literal"><span class="pre">macosx</span></code></dt>
<dd>Apple&#8217;s Mac OS X operating system.  The minimum deployment target is
specified by the <code class="docutils literal"><span class="pre">-mmacosx-version-min=*version*</span></code> command-line argument.</dd>
<dt><code class="docutils literal"><span class="pre">tvos</span></code></dt>
<dd>Apple&#8217;s tvOS operating system.  The minimum deployment target is specified by
the <code class="docutils literal"><span class="pre">-mtvos-version-min=*version*</span></code> command-line argument.</dd>
<dt><code class="docutils literal"><span class="pre">watchos</span></code></dt>
<dd>Apple&#8217;s watchOS operating system.  The minimum deployment target is specified by
the <code class="docutils literal"><span class="pre">-mwatchos-version-min=*version*</span></code> command-line argument.</dd>
</dl>
<p>A declaration can be used even when deploying back to a platform version prior
to when the declaration was introduced.  When this happens, the declaration is
<a class="reference external" href="https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html">weakly linked</a>,
as if the <code class="docutils literal"><span class="pre">weak_import</span></code> attribute were added to the declaration.  A
weakly-linked declaration may or may not be present a run-time, and a program
can determine whether the declaration is present by checking whether the
address of that declaration is non-NULL.</p>
<p>If there are multiple declarations of the same entity, the availability
attributes must either match on a per-platform basis or later
declarations must not have availability attributes for that
platform. For example:</p>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">g</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">availability</span><span class="p">(</span><span class="n">macosx</span><span class="p">,</span><span class="n">introduced</span><span class="o">=</span><span class="mf">10.4</span><span class="p">)));</span>
<span class="kt">void</span> <span class="nf">g</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">availability</span><span class="p">(</span><span class="n">macosx</span><span class="p">,</span><span class="n">introduced</span><span class="o">=</span><span class="mf">10.4</span><span class="p">)));</span> <span class="c1">// okay, matches</span>
<span class="kt">void</span> <span class="nf">g</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">availability</span><span class="p">(</span><span class="n">ios</span><span class="p">,</span><span class="n">introduced</span><span class="o">=</span><span class="mf">4.0</span><span class="p">)));</span> <span class="c1">// okay, adds a new platform</span>
<span class="kt">void</span> <span class="nf">g</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span> <span class="c1">// okay, inherits both macosx and ios availability from above.</span>
<span class="kt">void</span> <span class="nf">g</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">availability</span><span class="p">(</span><span class="n">macosx</span><span class="p">,</span><span class="n">introduced</span><span class="o">=</span><span class="mf">10.5</span><span class="p">)));</span> <span class="c1">// error: mismatch</span>
</pre></div>
</div>
<p>When one method overrides another, the overriding method can be more widely available than the overridden method, e.g.,:</p>
<div class="highlight-objc"><div class="highlight"><pre><span class="k">@interface</span> <span class="nc">A</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">method</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">availability</span><span class="p">(</span><span class="n">macosx</span><span class="p">,</span><span class="n">introduced</span><span class="o">=</span><span class="mf">10.4</span><span class="p">)));</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">method2</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">availability</span><span class="p">(</span><span class="n">macosx</span><span class="p">,</span><span class="n">introduced</span><span class="o">=</span><span class="mf">10.4</span><span class="p">)));</span>
<span class="k">@end</span>

<span class="k">@interface</span> <span class="nc">B</span> : <span class="nc">A</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">method</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">availability</span><span class="p">(</span><span class="n">macosx</span><span class="p">,</span><span class="n">introduced</span><span class="o">=</span><span class="mf">10.3</span><span class="p">)));</span> <span class="c1">// okay: method moved into base class later</span>
<span class="p">-</span> <span class="p">(</span><span class="kt">id</span><span class="p">)</span><span class="nf">method</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">availability</span><span class="p">(</span><span class="n">macosx</span><span class="p">,</span><span class="n">introduced</span><span class="o">=</span><span class="mf">10.5</span><span class="p">)));</span> <span class="c1">// error: this method was available via the base class in 10.4</span>
<span class="k">@end</span>
</pre></div>
</div>
</div>
<div class="section" id="noreturn">
<h3><a class="toc-backref" href="#id83">_Noreturn</a><a class="headerlink" href="#noreturn" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id10">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id10" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>A function declared as <code class="docutils literal"><span class="pre">_Noreturn</span></code> shall not return to its caller. The
compiler will generate a diagnostic for a function declared as <code class="docutils literal"><span class="pre">_Noreturn</span></code>
that appears to be capable of returning to its caller.</p>
</div>
<div class="section" id="id1">
<h3><a class="toc-backref" href="#id84">noreturn</a><a class="headerlink" href="#id1" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id11">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id11" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>A function declared as <code class="docutils literal"><span class="pre">[[noreturn]]</span></code> shall not return to its caller. The
compiler will generate a diagnostic for a function declared as <code class="docutils literal"><span class="pre">[[noreturn]]</span></code>
that appears to be capable of returning to its caller.</p>
</div>
<div class="section" id="carries-dependency">
<h3><a class="toc-backref" href="#id85">carries_dependency</a><a class="headerlink" href="#carries-dependency" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id12">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id12" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">carries_dependency</span></code> attribute specifies dependency propagation into and
out of functions.</p>
<p>When specified on a function or Objective-C method, the <code class="docutils literal"><span class="pre">carries_dependency</span></code>
attribute means that the return value carries a dependency out of the function,
so that the implementation need not constrain ordering upon return from that
function. Implementations of the function and its caller may choose to preserve
dependencies instead of emitting memory ordering instructions such as fences.</p>
<p>Note, this attribute does not change the meaning of the program, but may result
in generation of more efficient code.</p>
</div>
<div class="section" id="disable-tail-calls-clang-disable-tail-calls">
<h3><a class="toc-backref" href="#id86">disable_tail_calls (clang::disable_tail_calls)</a><a class="headerlink" href="#disable-tail-calls-clang-disable-tail-calls" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id13">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id13" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">disable_tail_calls</span></code> attribute instructs the backend to not perform tail call optimization inside the marked function.</p>
<p>For example:</p>
<blockquote>
<div><div class="highlight-c"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">callee</span><span class="p">(</span><span class="kt">int</span><span class="p">);</span>

<span class="kt">int</span> <span class="nf">foo</span><span class="p">(</span><span class="kt">int</span> <span class="n">a</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">disable_tail_calls</span><span class="p">))</span> <span class="p">{</span>
  <span class="k">return</span> <span class="n">callee</span><span class="p">(</span><span class="n">a</span><span class="p">);</span> <span class="c1">// This call is not tail-call optimized.</span>
<span class="p">}</span>
</pre></div>
</div>
</div></blockquote>
<p>Marking virtual functions as <code class="docutils literal"><span class="pre">disable_tail_calls</span></code> is legal.</p>
<blockquote>
<div></div></blockquote>
</div>
<div class="section" id="enable-if">
<h3><a class="toc-backref" href="#id87">enable_if</a><a class="headerlink" href="#enable-if" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id14">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id14" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Some features of this attribute are experimental. The meaning of
multiple enable_if attributes on a single declaration is subject to change in
a future version of clang. Also, the ABI is not standardized and the name
mangling may change in future versions. To avoid that, use asm labels.</p>
</div>
<p>The <code class="docutils literal"><span class="pre">enable_if</span></code> attribute can be placed on function declarations to control
which overload is selected based on the values of the function&#8217;s arguments.
When combined with the <code class="docutils literal"><span class="pre">overloadable</span></code> attribute, this feature is also
available in C.</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">isdigit</span><span class="p">(</span><span class="kt">int</span> <span class="n">c</span><span class="p">);</span>
<span class="kt">int</span> <span class="nf">isdigit</span><span class="p">(</span><span class="kt">int</span> <span class="n">c</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">enable_if</span><span class="p">(</span><span class="n">c</span> <span class="o">&lt;=</span> <span class="o">-</span><span class="mi">1</span> <span class="o">||</span> <span class="n">c</span> <span class="o">&gt;</span> <span class="mi">255</span><span class="p">,</span> <span class="s">&quot;chosen when &#39;c&#39; is out of range&quot;</span><span class="p">)))</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">unavailable</span><span class="p">(</span><span class="s">&quot;&#39;c&#39; must have the value of an unsigned char or EOF&quot;</span><span class="p">)));</span>

<span class="kt">void</span> <span class="nf">foo</span><span class="p">(</span><span class="kt">char</span> <span class="n">c</span><span class="p">)</span> <span class="p">{</span>
  <span class="n">isdigit</span><span class="p">(</span><span class="n">c</span><span class="p">);</span>
  <span class="n">isdigit</span><span class="p">(</span><span class="mi">10</span><span class="p">);</span>
  <span class="n">isdigit</span><span class="p">(</span><span class="o">-</span><span class="mi">10</span><span class="p">);</span>  <span class="c1">// results in a compile-time error.</span>
<span class="p">}</span>
</pre></div>
</div>
<p>The enable_if attribute takes two arguments, the first is an expression written
in terms of the function parameters, the second is a string explaining why this
overload candidate could not be selected to be displayed in diagnostics. The
expression is part of the function signature for the purposes of determining
whether it is a redeclaration (following the rules used when determining
whether a C++ template specialization is ODR-equivalent), but is not part of
the type.</p>
<p>The enable_if expression is evaluated as if it were the body of a
bool-returning constexpr function declared with the arguments of the function
it is being applied to, then called with the parameters at the call site. If the
result is false or could not be determined through constant expression
evaluation, then this overload will not be chosen and the provided string may
be used in a diagnostic if the compile fails as a result.</p>
<p>Because the enable_if expression is an unevaluated context, there are no global
state changes, nor the ability to pass information from the enable_if
expression to the function body. For example, suppose we want calls to
strnlen(strbuf, maxlen) to resolve to strnlen_chk(strbuf, maxlen, size of
strbuf) only if the size of strbuf can be determined:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="n">__attribute__</span><span class="p">((</span><span class="n">always_inline</span><span class="p">))</span>
<span class="k">static</span> <span class="kr">inline</span> <span class="kt">size_t</span> <span class="n">strnlen</span><span class="p">(</span><span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">s</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">maxlen</span><span class="p">)</span>
  <span class="n">__attribute__</span><span class="p">((</span><span class="n">overloadable</span><span class="p">))</span>
  <span class="n">__attribute__</span><span class="p">((</span><span class="n">enable_if</span><span class="p">(</span><span class="n">__builtin_object_size</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">))),</span>
                           <span class="s">&quot;chosen when the buffer size is known but &#39;maxlen&#39; is not&quot;</span><span class="p">)))</span>
<span class="p">{</span>
  <span class="k">return</span> <span class="n">strnlen_chk</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">maxlen</span><span class="p">,</span> <span class="n">__builtin_object_size</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="mi">0</span><span class="p">));</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Multiple enable_if attributes may be applied to a single declaration. In this
case, the enable_if expressions are evaluated from left to right in the
following manner. First, the candidates whose enable_if expressions evaluate to
false or cannot be evaluated are discarded. If the remaining candidates do not
share ODR-equivalent enable_if expressions, the overload resolution is
ambiguous. Otherwise, enable_if overload resolution continues with the next
enable_if attribute on the candidates that have not been discarded and have
remaining enable_if attributes. In this way, we pick the most specific
overload out of a number of viable overloads using enable_if.</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">f</span><span class="p">()</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">enable_if</span><span class="p">(</span><span class="nb">true</span><span class="p">,</span> <span class="s">&quot;&quot;</span><span class="p">)));</span>  <span class="c1">// #1</span>
<span class="kt">void</span> <span class="nf">f</span><span class="p">()</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">enable_if</span><span class="p">(</span><span class="nb">true</span><span class="p">,</span> <span class="s">&quot;&quot;</span><span class="p">)))</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">enable_if</span><span class="p">(</span><span class="nb">true</span><span class="p">,</span> <span class="s">&quot;&quot;</span><span class="p">)));</span>  <span class="c1">// #2</span>

<span class="kt">void</span> <span class="nf">g</span><span class="p">(</span><span class="kt">int</span> <span class="n">i</span><span class="p">,</span> <span class="kt">int</span> <span class="n">j</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">enable_if</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="s">&quot;&quot;</span><span class="p">)));</span>  <span class="c1">// #1</span>
<span class="kt">void</span> <span class="nf">g</span><span class="p">(</span><span class="kt">int</span> <span class="n">i</span><span class="p">,</span> <span class="kt">int</span> <span class="n">j</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">enable_if</span><span class="p">(</span><span class="n">j</span><span class="p">,</span> <span class="s">&quot;&quot;</span><span class="p">)))</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">enable_if</span><span class="p">(</span><span class="nb">true</span><span class="p">)));</span>  <span class="c1">// #2</span>
</pre></div>
</div>
<p>In this example, a call to f() is always resolved to #2, as the first enable_if
expression is ODR-equivalent for both declarations, but #1 does not have another
enable_if expression to continue evaluating, so the next round of evaluation has
only a single candidate. In a call to g(1, 1), the call is ambiguous even though
#2 has more enable_if attributes, because the first enable_if expressions are
not ODR-equivalent.</p>
<p>Query for this feature with <code class="docutils literal"><span class="pre">__has_attribute(enable_if)</span></code>.</p>
</div>
<div class="section" id="flatten-gnu-flatten">
<h3><a class="toc-backref" href="#id88">flatten (gnu::flatten)</a><a class="headerlink" href="#flatten-gnu-flatten" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id15">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id15" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">flatten</span></code> attribute causes calls within the attributed function to
be inlined unless it is impossible to do so, for example if the body of the
callee is unavailable or if the callee has the <code class="docutils literal"><span class="pre">noinline</span></code> attribute.</p>
</div>
<div class="section" id="format-gnu-format">
<h3><a class="toc-backref" href="#id89">format (gnu::format)</a><a class="headerlink" href="#format-gnu-format" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id16">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id16" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Clang supports the <code class="docutils literal"><span class="pre">format</span></code> attribute, which indicates that the function
accepts a <code class="docutils literal"><span class="pre">printf</span></code> or <code class="docutils literal"><span class="pre">scanf</span></code>-like format string and corresponding
arguments or a <code class="docutils literal"><span class="pre">va_list</span></code> that contains these arguments.</p>
<p>Please see <a class="reference external" href="http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html">GCC documentation about format attribute</a> to find details
about attribute syntax.</p>
<p>Clang implements two kinds of checks with this attribute.</p>
<ol class="arabic">
<li><p class="first">Clang checks that the function with the <code class="docutils literal"><span class="pre">format</span></code> attribute is called with
a format string that uses format specifiers that are allowed, and that
arguments match the format string.  This is the <code class="docutils literal"><span class="pre">-Wformat</span></code> warning, it is
on by default.</p>
</li>
<li><p class="first">Clang checks that the format string argument is a literal string.  This is
the <code class="docutils literal"><span class="pre">-Wformat-nonliteral</span></code> warning, it is off by default.</p>
<p>Clang implements this mostly the same way as GCC, but there is a difference
for functions that accept a <code class="docutils literal"><span class="pre">va_list</span></code> argument (for example, <code class="docutils literal"><span class="pre">vprintf</span></code>).
GCC does not emit <code class="docutils literal"><span class="pre">-Wformat-nonliteral</span></code> warning for calls to such
functions.  Clang does not warn if the format string comes from a function
parameter, where the function is annotated with a compatible attribute,
otherwise it warns.  For example:</p>
<div class="highlight-c"><div class="highlight"><pre><span class="n">__attribute__</span><span class="p">((</span><span class="n">__format__</span> <span class="p">(</span><span class="n">__scanf__</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)))</span>
<span class="kt">void</span> <span class="n">foo</span><span class="p">(</span><span class="k">const</span> <span class="kt">char</span><span class="o">*</span> <span class="n">s</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span><span class="n">buf</span><span class="p">,</span> <span class="p">...)</span> <span class="p">{</span>
  <span class="kt">va_list</span> <span class="n">ap</span><span class="p">;</span>
  <span class="n">va_start</span><span class="p">(</span><span class="n">ap</span><span class="p">,</span> <span class="n">buf</span><span class="p">);</span>

  <span class="n">vprintf</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">ap</span><span class="p">);</span> <span class="c1">// warning: format string is not a string literal</span>
<span class="p">}</span>
</pre></div>
</div>
<p>In this case we warn because <code class="docutils literal"><span class="pre">s</span></code> contains a format string for a
<code class="docutils literal"><span class="pre">scanf</span></code>-like function, but it is passed to a <code class="docutils literal"><span class="pre">printf</span></code>-like function.</p>
<p>If the attribute is removed, clang still warns, because the format string is
not a string literal.</p>
<p>Another example:</p>
<div class="highlight-c"><div class="highlight"><pre><span class="n">__attribute__</span><span class="p">((</span><span class="n">__format__</span> <span class="p">(</span><span class="n">__printf__</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">)))</span>
<span class="kt">void</span> <span class="n">foo</span><span class="p">(</span><span class="k">const</span> <span class="kt">char</span><span class="o">*</span> <span class="n">s</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span><span class="n">buf</span><span class="p">,</span> <span class="p">...)</span> <span class="p">{</span>
  <span class="kt">va_list</span> <span class="n">ap</span><span class="p">;</span>
  <span class="n">va_start</span><span class="p">(</span><span class="n">ap</span><span class="p">,</span> <span class="n">buf</span><span class="p">);</span>

  <span class="n">vprintf</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">ap</span><span class="p">);</span> <span class="c1">// warning</span>
<span class="p">}</span>
</pre></div>
</div>
<p>In this case Clang does not warn because the format string <code class="docutils literal"><span class="pre">s</span></code> and
the corresponding arguments are annotated.  If the arguments are
incorrect, the caller of <code class="docutils literal"><span class="pre">foo</span></code> will receive a warning.</p>
</li>
</ol>
</div>
<div class="section" id="internal-linkage-clang-internal-linkage">
<h3><a class="toc-backref" href="#id90">internal_linkage (clang::internal_linkage)</a><a class="headerlink" href="#internal-linkage-clang-internal-linkage" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id17">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id17" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">internal_linkage</span></code> attribute changes the linkage type of the declaration to internal.
This is similar to C-style <code class="docutils literal"><span class="pre">static</span></code>, but can be used on classes and class methods. When applied to a class definition,
this attribute affects all methods and static data members of that class.
This can be used to contain the ABI of a C++ library by excluding unwanted class methods from the export tables.</p>
</div>
<div class="section" id="id2">
<h3><a class="toc-backref" href="#id91">interrupt</a><a class="headerlink" href="#id2" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id18">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id18" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Clang supports the GNU style <code class="docutils literal"><span class="pre">__attribute__((interrupt(&quot;ARGUMENT&quot;)))</span></code> attribute on
MIPS targets. This attribute may be attached to a function definition and instructs
the backend to generate appropriate function entry/exit code so that it can be used
directly as an interrupt service routine.</p>
<p>By default, the compiler will produce a function prologue and epilogue suitable for
an interrupt service routine that handles an External Interrupt Controller (eic)
generated interrupt. This behaviour can be explicitly requested with the &#8220;eic&#8221;
argument.</p>
<p>Otherwise, for use with vectored interrupt mode, the argument passed should be
of the form &#8220;vector=LEVEL&#8221; where LEVEL is one of the following values:
&#8220;sw0&#8221;, &#8220;sw1&#8221;, &#8220;hw0&#8221;, &#8220;hw1&#8221;, &#8220;hw2&#8221;, &#8220;hw3&#8221;, &#8220;hw4&#8221;, &#8220;hw5&#8221;. The compiler will
then set the interrupt mask to the corresponding level which will mask all
interrupts up to and including the argument.</p>
<p>The semantics are as follows:</p>
<ul class="simple">
<li>The prologue is modified so that the Exception Program Counter (EPC) and
Status coprocessor registers are saved to the stack. The interrupt mask is
set so that the function can only be interrupted by a higher priority
interrupt. The epilogue will restore the previous values of EPC and Status.</li>
<li>The prologue and epilogue are modified to save and restore all non-kernel
registers as necessary.</li>
<li>The FPU is disabled in the prologue, as the floating pointer registers are not
spilled to the stack.</li>
<li>The function return sequence is changed to use an exception return instruction.</li>
<li>The parameter sets the interrupt mask for the function corresponding to the
interrupt level specified. If no mask is specified the interrupt mask
defaults to &#8220;eic&#8221;.</li>
</ul>
</div>
<div class="section" id="noalias">
<h3><a class="toc-backref" href="#id92">noalias</a><a class="headerlink" href="#noalias" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id19">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id19" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">noalias</span></code> attribute indicates that the only memory accesses inside
function are loads and stores from objects pointed to by its pointer-typed
arguments, with arbitrary offsets.</p>
</div>
<div class="section" id="noduplicate-clang-noduplicate">
<h3><a class="toc-backref" href="#id93">noduplicate (clang::noduplicate)</a><a class="headerlink" href="#noduplicate-clang-noduplicate" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id20">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id20" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">noduplicate</span></code> attribute can be placed on function declarations to control
whether function calls to this function can be duplicated or not as a result of
optimizations. This is required for the implementation of functions with
certain special requirements, like the OpenCL &#8220;barrier&#8221; function, that might
need to be run concurrently by all the threads that are executing in lockstep
on the hardware. For example this attribute applied on the function
&#8220;nodupfunc&#8221; in the code below avoids that:</p>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">nodupfunc</span><span class="p">()</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">noduplicate</span><span class="p">));</span>
<span class="c1">// Setting it as a C++11 attribute is also valid</span>
<span class="c1">// void nodupfunc() [[clang::noduplicate]];</span>
<span class="kt">void</span> <span class="nf">foo</span><span class="p">();</span>
<span class="kt">void</span> <span class="nf">bar</span><span class="p">();</span>

<span class="n">nodupfunc</span><span class="p">();</span>
<span class="k">if</span> <span class="p">(</span><span class="n">a</span> <span class="o">&gt;</span> <span class="n">n</span><span class="p">)</span> <span class="p">{</span>
  <span class="n">foo</span><span class="p">();</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
  <span class="n">bar</span><span class="p">();</span>
<span class="p">}</span>
</pre></div>
</div>
<p>gets possibly modified by some optimizations into code similar to this:</p>
<div class="highlight-c"><div class="highlight"><pre><span class="k">if</span> <span class="p">(</span><span class="n">a</span> <span class="o">&gt;</span> <span class="n">n</span><span class="p">)</span> <span class="p">{</span>
  <span class="n">nodupfunc</span><span class="p">();</span>
  <span class="n">foo</span><span class="p">();</span>
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
  <span class="n">nodupfunc</span><span class="p">();</span>
  <span class="n">bar</span><span class="p">();</span>
<span class="p">}</span>
</pre></div>
</div>
<p>where the call to &#8220;nodupfunc&#8221; is duplicated and sunk into the two branches
of the condition.</p>
</div>
<div class="section" id="no-sanitize-clang-no-sanitize">
<h3><a class="toc-backref" href="#id94">no_sanitize (clang::no_sanitize)</a><a class="headerlink" href="#no-sanitize-clang-no-sanitize" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id21">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id21" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Use the <code class="docutils literal"><span class="pre">no_sanitize</span></code> attribute on a function declaration to specify
that a particular instrumentation or set of instrumentations should not be
applied to that function. The attribute takes a list of string literals,
which have the same meaning as values accepted by the <code class="docutils literal"><span class="pre">-fno-sanitize=</span></code>
flag. For example, <code class="docutils literal"><span class="pre">__attribute__((no_sanitize(&quot;address&quot;,</span> <span class="pre">&quot;thread&quot;)))</span></code>
specifies that AddressSanitizer and ThreadSanitizer should not be applied
to the function.</p>
<p>See <a class="reference internal" href="UsersManual.html#controlling-code-generation"><span>Controlling Code Generation</span></a> for a
full list of supported sanitizer flags.</p>
</div>
<div class="section" id="no-sanitize-address-no-address-safety-analysis-gnu-no-address-safety-analysis-gnu-no-sanitize-address">
<h3><a class="toc-backref" href="#id95">no_sanitize_address (no_address_safety_analysis, gnu::no_address_safety_analysis, gnu::no_sanitize_address)</a><a class="headerlink" href="#no-sanitize-address-no-address-safety-analysis-gnu-no-address-safety-analysis-gnu-no-sanitize-address" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id22">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id22" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p id="langext-address-sanitizer">Use <code class="docutils literal"><span class="pre">__attribute__((no_sanitize_address))</span></code> on a function declaration to
specify that address safety instrumentation (e.g. AddressSanitizer) should
not be applied to that function.</p>
</div>
<div class="section" id="no-sanitize-thread">
<h3><a class="toc-backref" href="#id96">no_sanitize_thread</a><a class="headerlink" href="#no-sanitize-thread" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id23">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id23" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p id="langext-thread-sanitizer">Use <code class="docutils literal"><span class="pre">__attribute__((no_sanitize_thread))</span></code> on a function declaration to
specify that checks for data races on plain (non-atomic) memory accesses should
not be inserted by ThreadSanitizer. The function is still instrumented by the
tool to avoid false positives and provide meaningful stack traces.</p>
</div>
<div class="section" id="no-sanitize-memory">
<h3><a class="toc-backref" href="#id97">no_sanitize_memory</a><a class="headerlink" href="#no-sanitize-memory" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id24">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id24" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p id="langext-memory-sanitizer">Use <code class="docutils literal"><span class="pre">__attribute__((no_sanitize_memory))</span></code> on a function declaration to
specify that checks for uninitialized memory should not be inserted
(e.g. by MemorySanitizer). The function may still be instrumented by the tool
to avoid false positives in other places.</p>
</div>
<div class="section" id="no-split-stack-gnu-no-split-stack">
<h3><a class="toc-backref" href="#id98">no_split_stack (gnu::no_split_stack)</a><a class="headerlink" href="#no-split-stack-gnu-no-split-stack" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id25">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id25" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">no_split_stack</span></code> attribute disables the emission of the split stack
preamble for a particular function. It has no effect if <code class="docutils literal"><span class="pre">-fsplit-stack</span></code>
is not specified.</p>
</div>
<div class="section" id="not-tail-called-clang-not-tail-called">
<h3><a class="toc-backref" href="#id99">not_tail_called (clang::not_tail_called)</a><a class="headerlink" href="#not-tail-called-clang-not-tail-called" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id26">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id26" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">not_tail_called</span></code> attribute prevents tail-call optimization on statically bound calls. It has no effect on indirect calls. Virtual functions, objective-c methods, and functions marked as <code class="docutils literal"><span class="pre">always_inline</span></code> cannot be marked as <code class="docutils literal"><span class="pre">not_tail_called</span></code>.</p>
<p>For example, it prevents tail-call optimization in the following case:</p>
<blockquote>
<div></div></blockquote>
<p>However, it doesn&#8217;t prevent tail-call optimization in this case:</p>
<blockquote>
<div></div></blockquote>
<p>Marking virtual functions as <code class="docutils literal"><span class="pre">not_tail_called</span></code> is an error:</p>
<blockquote>
<div></div></blockquote>
</div>
<div class="section" id="objc-boxable">
<h3><a class="toc-backref" href="#id100">objc_boxable</a><a class="headerlink" href="#objc-boxable" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id27">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id27" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Structs and unions marked with the <code class="docutils literal"><span class="pre">objc_boxable</span></code> attribute can be used
with the Objective-C boxed expression syntax, <code class="docutils literal"><span class="pre">&#64;(...)</span></code>.</p>
<p><strong>Usage</strong>: <code class="docutils literal"><span class="pre">__attribute__((objc_boxable))</span></code>. This attribute
can only be placed on a declaration of a trivially-copyable struct or union:</p>
<div class="highlight-objc"><div class="highlight"><pre><span class="k">struct</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">objc_boxable</span><span class="p">))</span> <span class="n">some_struct</span> <span class="p">{</span>
  <span class="kt">int</span> <span class="n">i</span><span class="p">;</span>
<span class="p">};</span>
<span class="k">union</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">objc_boxable</span><span class="p">))</span> <span class="n">some_union</span> <span class="p">{</span>
  <span class="kt">int</span> <span class="n">i</span><span class="p">;</span>
  <span class="kt">float</span> <span class="n">f</span><span class="p">;</span>
<span class="p">};</span>
<span class="k">typedef</span> <span class="k">struct</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">objc_boxable</span><span class="p">))</span> <span class="n">_some_struct</span> <span class="n">some_struct</span><span class="p">;</span>

<span class="c1">// ...</span>

<span class="n">some_struct</span> <span class="n">ss</span><span class="p">;</span>
<span class="bp">NSValue</span> <span class="o">*</span><span class="n">boxed</span> <span class="o">=</span> <span class="l">@(</span><span class="n">ss</span><span class="l">)</span><span class="p">;</span>
</pre></div>
</div>
</div>
<div class="section" id="objc-method-family">
<h3><a class="toc-backref" href="#id101">objc_method_family</a><a class="headerlink" href="#objc-method-family" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id28">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id28" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Many methods in Objective-C have conventional meanings determined by their
selectors. It is sometimes useful to be able to mark a method as having a
particular conventional meaning despite not having the right selector, or as
not having the conventional meaning that its selector would suggest. For these
use cases, we provide an attribute to specifically describe the &#8220;method family&#8221;
that a method belongs to.</p>
<p><strong>Usage</strong>: <code class="docutils literal"><span class="pre">__attribute__((objc_method_family(X)))</span></code>, where <code class="docutils literal"><span class="pre">X</span></code> is one of
<code class="docutils literal"><span class="pre">none</span></code>, <code class="docutils literal"><span class="pre">alloc</span></code>, <code class="docutils literal"><span class="pre">copy</span></code>, <code class="docutils literal"><span class="pre">init</span></code>, <code class="docutils literal"><span class="pre">mutableCopy</span></code>, or <code class="docutils literal"><span class="pre">new</span></code>.  This
attribute can only be placed at the end of a method declaration:</p>
<div class="highlight-objc"><div class="highlight"><pre><span class="p">-</span> <span class="p">(</span><span class="bp">NSString</span> <span class="o">*</span><span class="p">)</span><span class="nf">initMyStringValue</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">objc_method_family</span><span class="p">(</span><span class="n">none</span><span class="p">)));</span>
</pre></div>
</div>
<p>Users who do not wish to change the conventional meaning of a method, and who
merely want to document its non-standard retain and release semantics, should
use the retaining behavior attributes (<code class="docutils literal"><span class="pre">ns_returns_retained</span></code>,
<code class="docutils literal"><span class="pre">ns_returns_not_retained</span></code>, etc).</p>
<p>Query for this feature with <code class="docutils literal"><span class="pre">__has_attribute(objc_method_family)</span></code>.</p>
</div>
<div class="section" id="objc-requires-super">
<h3><a class="toc-backref" href="#id102">objc_requires_super</a><a class="headerlink" href="#objc-requires-super" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id29">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id29" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Some Objective-C classes allow a subclass to override a particular method in a
parent class but expect that the overriding method also calls the overridden
method in the parent class. For these cases, we provide an attribute to
designate that a method requires a &#8220;call to <code class="docutils literal"><span class="pre">super</span></code>&#8221; in the overriding
method in the subclass.</p>
<p><strong>Usage</strong>: <code class="docutils literal"><span class="pre">__attribute__((objc_requires_super))</span></code>.  This attribute can only
be placed at the end of a method declaration:</p>
<div class="highlight-objc"><div class="highlight"><pre><span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">foo</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">objc_requires_super</span><span class="p">));</span>
</pre></div>
</div>
<p>This attribute can only be applied the method declarations within a class, and
not a protocol.  Currently this attribute does not enforce any placement of
where the call occurs in the overriding method (such as in the case of
<code class="docutils literal"><span class="pre">-dealloc</span></code> where the call must appear at the end).  It checks only that it
exists.</p>
<p>Note that on both OS X and iOS that the Foundation framework provides a
convenience macro <code class="docutils literal"><span class="pre">NS_REQUIRES_SUPER</span></code> that provides syntactic sugar for this
attribute:</p>
<div class="highlight-objc"><div class="highlight"><pre><span class="p">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span><span class="nf">foo</span> <span class="n">NS_REQUIRES_SUPER</span><span class="p">;</span>
</pre></div>
</div>
<p>This macro is conditionally defined depending on the compiler&#8217;s support for
this attribute.  If the compiler does not support the attribute the macro
expands to nothing.</p>
<p>Operationally, when a method has this annotation the compiler will warn if the
implementation of an override in a subclass does not call super.  For example:</p>
<div class="highlight-objc"><div class="highlight"><pre><span class="nl">warning</span><span class="p">:</span> <span class="n">method</span> <span class="n">possibly</span> <span class="n">missing</span> <span class="n">a</span> <span class="p">[</span><span class="nb">super</span> <span class="n">AnnotMeth</span><span class="p">]</span> <span class="n">call</span>
<span class="o">-</span> <span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="n">AnnotMeth</span><span class="p">{};</span>
                   <span class="o">^</span>
</pre></div>
</div>
</div>
<div class="section" id="objc-runtime-name">
<h3><a class="toc-backref" href="#id103">objc_runtime_name</a><a class="headerlink" href="#objc-runtime-name" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id30">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id30" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>By default, the Objective-C interface or protocol identifier is used
in the metadata name for that object. The <cite>objc_runtime_name</cite>
attribute allows annotated interfaces or protocols to use the
specified string argument in the object&#8217;s metadata name instead of the
default name.</p>
<p><strong>Usage</strong>: <code class="docutils literal"><span class="pre">__attribute__((objc_runtime_name(&quot;MyLocalName&quot;)))</span></code>.  This attribute
can only be placed before an &#64;protocol or &#64;interface declaration:</p>
<div class="highlight-objc"><div class="highlight"><pre><span class="n">__attribute__</span><span class="p">((</span><span class="n">objc_runtime_name</span><span class="p">(</span><span class="s">&quot;MyLocalName&quot;</span><span class="p">)))</span>
<span class="k">@interface</span> <span class="nc">Message</span>
<span class="k">@end</span>
</pre></div>
</div>
</div>
<div class="section" id="optnone-clang-optnone">
<h3><a class="toc-backref" href="#id104">optnone (clang::optnone)</a><a class="headerlink" href="#optnone-clang-optnone" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id31">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id31" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">optnone</span></code> attribute suppresses essentially all optimizations
on a function or method, regardless of the optimization level applied to
the compilation unit as a whole.  This is particularly useful when you
need to debug a particular function, but it is infeasible to build the
entire application without optimization.  Avoiding optimization on the
specified function can improve the quality of the debugging information
for that function.</p>
<p>This attribute is incompatible with the <code class="docutils literal"><span class="pre">always_inline</span></code> and <code class="docutils literal"><span class="pre">minsize</span></code>
attributes.</p>
</div>
<div class="section" id="overloadable">
<h3><a class="toc-backref" href="#id105">overloadable</a><a class="headerlink" href="#overloadable" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id32">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id32" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Clang provides support for C++ function overloading in C.  Function overloading
in C is introduced using the <code class="docutils literal"><span class="pre">overloadable</span></code> attribute.  For example, one
might provide several overloaded versions of a <code class="docutils literal"><span class="pre">tgsin</span></code> function that invokes
the appropriate standard function computing the sine of a value with <code class="docutils literal"><span class="pre">float</span></code>,
<code class="docutils literal"><span class="pre">double</span></code>, or <code class="docutils literal"><span class="pre">long</span> <span class="pre">double</span></code> precision:</p>
<div class="highlight-c"><div class="highlight"><pre><span class="cp">#include</span> <span class="cpf">&lt;math.h&gt;</span><span class="cp"></span>
<span class="kt">float</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">overloadable</span><span class="p">))</span> <span class="n">tgsin</span><span class="p">(</span><span class="kt">float</span> <span class="n">x</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="n">sinf</span><span class="p">(</span><span class="n">x</span><span class="p">);</span> <span class="p">}</span>
<span class="kt">double</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">overloadable</span><span class="p">))</span> <span class="n">tgsin</span><span class="p">(</span><span class="kt">double</span> <span class="n">x</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="n">sin</span><span class="p">(</span><span class="n">x</span><span class="p">);</span> <span class="p">}</span>
<span class="kt">long</span> <span class="kt">double</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">overloadable</span><span class="p">))</span> <span class="n">tgsin</span><span class="p">(</span><span class="kt">long</span> <span class="kt">double</span> <span class="n">x</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="n">sinl</span><span class="p">(</span><span class="n">x</span><span class="p">);</span> <span class="p">}</span>
</pre></div>
</div>
<p>Given these declarations, one can call <code class="docutils literal"><span class="pre">tgsin</span></code> with a <code class="docutils literal"><span class="pre">float</span></code> value to
receive a <code class="docutils literal"><span class="pre">float</span></code> result, with a <code class="docutils literal"><span class="pre">double</span></code> to receive a <code class="docutils literal"><span class="pre">double</span></code> result,
etc.  Function overloading in C follows the rules of C++ function overloading
to pick the best overload given the call arguments, with a few C-specific
semantics:</p>
<ul class="simple">
<li>Conversion from <code class="docutils literal"><span class="pre">float</span></code> or <code class="docutils literal"><span class="pre">double</span></code> to <code class="docutils literal"><span class="pre">long</span> <span class="pre">double</span></code> is ranked as a
floating-point promotion (per C99) rather than as a floating-point conversion
(as in C++).</li>
<li>A conversion from a pointer of type <code class="docutils literal"><span class="pre">T*</span></code> to a pointer of type <code class="docutils literal"><span class="pre">U*</span></code> is
considered a pointer conversion (with conversion rank) if <code class="docutils literal"><span class="pre">T</span></code> and <code class="docutils literal"><span class="pre">U</span></code> are
compatible types.</li>
<li>A conversion from type <code class="docutils literal"><span class="pre">T</span></code> to a value of type <code class="docutils literal"><span class="pre">U</span></code> is permitted if <code class="docutils literal"><span class="pre">T</span></code>
and <code class="docutils literal"><span class="pre">U</span></code> are compatible types.  This conversion is given &#8220;conversion&#8221; rank.</li>
</ul>
<p>The declaration of <code class="docutils literal"><span class="pre">overloadable</span></code> functions is restricted to function
declarations and definitions.  Most importantly, if any function with a given
name is given the <code class="docutils literal"><span class="pre">overloadable</span></code> attribute, then all function declarations
and definitions with that name (and in that scope) must have the
<code class="docutils literal"><span class="pre">overloadable</span></code> attribute.  This rule even applies to redeclarations of
functions whose original declaration had the <code class="docutils literal"><span class="pre">overloadable</span></code> attribute, e.g.,</p>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">f</span><span class="p">(</span><span class="kt">int</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">overloadable</span><span class="p">));</span>
<span class="kt">float</span> <span class="nf">f</span><span class="p">(</span><span class="kt">float</span><span class="p">);</span> <span class="c1">// error: declaration of &quot;f&quot; must have the &quot;overloadable&quot; attribute</span>

<span class="kt">int</span> <span class="nf">g</span><span class="p">(</span><span class="kt">int</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">overloadable</span><span class="p">));</span>
<span class="kt">int</span> <span class="nf">g</span><span class="p">(</span><span class="kt">int</span><span class="p">)</span> <span class="p">{</span> <span class="p">}</span> <span class="c1">// error: redeclaration of &quot;g&quot; must also have the &quot;overloadable&quot; attribute</span>
</pre></div>
</div>
<p>Functions marked <code class="docutils literal"><span class="pre">overloadable</span></code> must have prototypes.  Therefore, the
following code is ill-formed:</p>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">h</span><span class="p">()</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">overloadable</span><span class="p">));</span> <span class="c1">// error: h does not have a prototype</span>
</pre></div>
</div>
<p>However, <code class="docutils literal"><span class="pre">overloadable</span></code> functions are allowed to use a ellipsis even if there
are no named parameters (as is permitted in C++).  This feature is particularly
useful when combined with the <code class="docutils literal"><span class="pre">unavailable</span></code> attribute:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">void</span> <span class="nf">honeypot</span><span class="p">(...)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">overloadable</span><span class="p">,</span> <span class="n">unavailable</span><span class="p">));</span> <span class="c1">// calling me is an error</span>
</pre></div>
</div>
<p>Functions declared with the <code class="docutils literal"><span class="pre">overloadable</span></code> attribute have their names mangled
according to the same rules as C++ function names.  For example, the three
<code class="docutils literal"><span class="pre">tgsin</span></code> functions in our motivating example get the mangled names
<code class="docutils literal"><span class="pre">_Z5tgsinf</span></code>, <code class="docutils literal"><span class="pre">_Z5tgsind</span></code>, and <code class="docutils literal"><span class="pre">_Z5tgsine</span></code>, respectively.  There are two
caveats to this use of name mangling:</p>
<ul class="simple">
<li>Future versions of Clang may change the name mangling of functions overloaded
in C, so you should not depend on an specific mangling.  To be completely
safe, we strongly urge the use of <code class="docutils literal"><span class="pre">static</span> <span class="pre">inline</span></code> with <code class="docutils literal"><span class="pre">overloadable</span></code>
functions.</li>
<li>The <code class="docutils literal"><span class="pre">overloadable</span></code> attribute has almost no meaning when used in C++,
because names will already be mangled and functions are already overloadable.
However, when an <code class="docutils literal"><span class="pre">overloadable</span></code> function occurs within an <code class="docutils literal"><span class="pre">extern</span> <span class="pre">&quot;C&quot;</span></code>
linkage specification, it&#8217;s name <em>will</em> be mangled in the same way as it
would in C.</li>
</ul>
<p>Query for this feature with <code class="docutils literal"><span class="pre">__has_extension(attribute_overloadable)</span></code>.</p>
</div>
<div class="section" id="release-capability-release-shared-capability-clang-release-capability-clang-release-shared-capability">
<h3><a class="toc-backref" href="#id106">release_capability (release_shared_capability, clang::release_capability, clang::release_shared_capability)</a><a class="headerlink" href="#release-capability-release-shared-capability-clang-release-capability-clang-release-shared-capability" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id33">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id33" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Marks a function as releasing a capability.</p>
</div>
<div class="section" id="target-gnu-target">
<h3><a class="toc-backref" href="#id107">target (gnu::target)</a><a class="headerlink" href="#target-gnu-target" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id34">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id34" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Clang supports the GNU style <code class="docutils literal"><span class="pre">__attribute__((target(&quot;OPTIONS&quot;)))</span></code> attribute.
This attribute may be attached to a function definition and instructs
the backend to use different code generation options than were passed on the
command line.</p>
<p>The current set of options correspond to the existing &#8220;subtarget features&#8221; for
the target with or without a &#8220;-mno-&#8221; in front corresponding to the absence
of the feature, as well as <code class="docutils literal"><span class="pre">arch=&quot;CPU&quot;</span></code> which will change the default &#8220;CPU&#8221;
for the function.</p>
<p>Example &#8220;subtarget features&#8221; from the x86 backend include: &#8220;mmx&#8221;, &#8220;sse&#8221;, &#8220;sse4.2&#8221;,
&#8220;avx&#8221;, &#8220;xop&#8221; and largely correspond to the machine specific options handled by
the front end.</p>
</div>
<div class="section" id="try-acquire-capability-try-acquire-shared-capability-clang-try-acquire-capability-clang-try-acquire-shared-capability">
<h3><a class="toc-backref" href="#id108">try_acquire_capability (try_acquire_shared_capability, clang::try_acquire_capability, clang::try_acquire_shared_capability)</a><a class="headerlink" href="#try-acquire-capability-try-acquire-shared-capability-clang-try-acquire-capability-clang-try-acquire-shared-capability" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id35">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id35" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Marks a function that attempts to acquire a capability. This function may fail to
actually acquire the capability; they accept a Boolean value determining
whether acquiring the capability means success (true), or failing to acquire
the capability means success (false).</p>
</div>
</div>
<div class="section" id="variable-attributes">
<h2><a class="toc-backref" href="#id109">Variable Attributes</a><a class="headerlink" href="#variable-attributes" title="Permalink to this headline"></a></h2>
<div class="section" id="init-seg">
<h3><a class="toc-backref" href="#id110">init_seg</a><a class="headerlink" href="#init-seg" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id36">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id36" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
</tr>
</tbody>
</table>
<p>The attribute applied by <code class="docutils literal"><span class="pre">pragma</span> <span class="pre">init_seg()</span></code> controls the section into
which global initialization function pointers are emitted.  It is only
available with <code class="docutils literal"><span class="pre">-fms-extensions</span></code>.  Typically, this function pointer is
emitted into <code class="docutils literal"><span class="pre">.CRT$XCU</span></code> on Windows.  The user can change the order of
initialization by using a different section name with the same
<code class="docutils literal"><span class="pre">.CRT$XC</span></code> prefix and a suffix that sorts lexicographically before or
after the standard <code class="docutils literal"><span class="pre">.CRT$XCU</span></code> sections.  See the <a class="reference external" href="http://msdn.microsoft.com/en-us/library/7977wcck(v=vs.110).aspx">init_seg</a>
documentation on MSDN for more information.</p>
</div>
<div class="section" id="pass-object-size">
<h3><a class="toc-backref" href="#id111">pass_object_size</a><a class="headerlink" href="#pass-object-size" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id37">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id37" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The mangling of functions with parameters that are annotated with
<code class="docutils literal"><span class="pre">pass_object_size</span></code> is subject to change. You can get around this by
using <code class="docutils literal"><span class="pre">__asm__(&quot;foo&quot;)</span></code> to explicitly name your functions, thus preserving
your ABI; also, non-overloadable C functions with <code class="docutils literal"><span class="pre">pass_object_size</span></code> are
not mangled.</p>
</div>
<p>The <code class="docutils literal"><span class="pre">pass_object_size(Type)</span></code> attribute can be placed on function parameters to
instruct clang to call <code class="docutils literal"><span class="pre">__builtin_object_size(param,</span> <span class="pre">Type)</span></code> at each callsite
of said function, and implicitly pass the result of this call in as an invisible
argument of type <code class="docutils literal"><span class="pre">size_t</span></code> directly after the parameter annotated with
<code class="docutils literal"><span class="pre">pass_object_size</span></code>. Clang will also replace any calls to
<code class="docutils literal"><span class="pre">__builtin_object_size(param,</span> <span class="pre">Type)</span></code> in the function by said implicit
parameter.</p>
<p>Example usage:</p>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">bzero1</span><span class="p">(</span><span class="kt">char</span> <span class="o">*</span><span class="k">const</span> <span class="n">p</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">pass_object_size</span><span class="p">(</span><span class="mi">0</span><span class="p">))))</span>
    <span class="n">__attribute__</span><span class="p">((</span><span class="n">noinline</span><span class="p">))</span> <span class="p">{</span>
  <span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
  <span class="k">for</span> <span class="p">(</span><span class="cm">/**/</span><span class="p">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="p">(</span><span class="kt">int</span><span class="p">)</span><span class="n">__builtin_object_size</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> <span class="o">++</span><span class="n">i</span><span class="p">)</span> <span class="p">{</span>
    <span class="n">p</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
  <span class="p">}</span>
  <span class="k">return</span> <span class="n">i</span><span class="p">;</span>
<span class="p">}</span>

<span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span>
  <span class="kt">char</span> <span class="n">chars</span><span class="p">[</span><span class="mi">100</span><span class="p">];</span>
  <span class="kt">int</span> <span class="n">n</span> <span class="o">=</span> <span class="n">bzero1</span><span class="p">(</span><span class="o">&amp;</span><span class="n">chars</span><span class="p">[</span><span class="mi">0</span><span class="p">]);</span>
  <span class="n">assert</span><span class="p">(</span><span class="n">n</span> <span class="o">==</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">chars</span><span class="p">));</span>
  <span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>If successfully evaluating <code class="docutils literal"><span class="pre">__builtin_object_size(param,</span> <span class="pre">Type)</span></code> at the
callsite is not possible, then the &#8220;failed&#8221; value is passed in. So, using the
definition of <code class="docutils literal"><span class="pre">bzero1</span></code> from above, the following code would exit cleanly:</p>
<div class="highlight-c"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">main2</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span><span class="n">argv</span><span class="p">[])</span> <span class="p">{</span>
  <span class="kt">int</span> <span class="n">n</span> <span class="o">=</span> <span class="n">bzero1</span><span class="p">(</span><span class="n">argv</span><span class="p">);</span>
  <span class="n">assert</span><span class="p">(</span><span class="n">n</span> <span class="o">==</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span>
  <span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p><code class="docutils literal"><span class="pre">pass_object_size</span></code> plays a part in overload resolution. If two overload
candidates are otherwise equally good, then the overload with one or more
parameters with <code class="docutils literal"><span class="pre">pass_object_size</span></code> is preferred. This implies that the choice
between two identical overloads both with <code class="docutils literal"><span class="pre">pass_object_size</span></code> on one or more
parameters will always be ambiguous; for this reason, having two such overloads
is illegal. For example:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#define PS(N) __attribute__((pass_object_size(N)))</span>
<span class="c1">// OK</span>
<span class="kt">void</span> <span class="nf">Foo</span><span class="p">(</span><span class="kt">char</span> <span class="o">*</span><span class="n">a</span><span class="p">,</span> <span class="kt">char</span> <span class="o">*</span><span class="n">b</span><span class="p">);</span> <span class="c1">// Overload A</span>
<span class="c1">// OK -- overload A has no parameters with pass_object_size.</span>
<span class="kt">void</span> <span class="nf">Foo</span><span class="p">(</span><span class="kt">char</span> <span class="o">*</span><span class="n">a</span> <span class="n">PS</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="kt">char</span> <span class="o">*</span><span class="n">b</span> <span class="n">PS</span><span class="p">(</span><span class="mi">0</span><span class="p">));</span> <span class="c1">// Overload B</span>
<span class="c1">// Error -- Same signature (sans pass_object_size) as overload B, and both</span>
<span class="c1">// overloads have one or more parameters with the pass_object_size attribute.</span>
<span class="kt">void</span> <span class="nf">Foo</span><span class="p">(</span><span class="kt">void</span> <span class="o">*</span><span class="n">a</span> <span class="n">PS</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="kt">void</span> <span class="o">*</span><span class="n">b</span><span class="p">);</span>

<span class="c1">// OK</span>
<span class="kt">void</span> <span class="nf">Bar</span><span class="p">(</span><span class="kt">void</span> <span class="o">*</span><span class="n">a</span> <span class="n">PS</span><span class="p">(</span><span class="mi">0</span><span class="p">));</span> <span class="c1">// Overload C</span>
<span class="c1">// OK</span>
<span class="kt">void</span> <span class="nf">Bar</span><span class="p">(</span><span class="kt">char</span> <span class="o">*</span><span class="n">c</span> <span class="n">PS</span><span class="p">(</span><span class="mi">1</span><span class="p">));</span> <span class="c1">// Overload D</span>

<span class="kt">void</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span>
  <span class="kt">char</span> <span class="n">known</span><span class="p">[</span><span class="mi">10</span><span class="p">],</span> <span class="o">*</span><span class="n">unknown</span><span class="p">;</span>
  <span class="n">Foo</span><span class="p">(</span><span class="n">unknown</span><span class="p">,</span> <span class="n">unknown</span><span class="p">);</span> <span class="c1">// Calls overload B</span>
  <span class="n">Foo</span><span class="p">(</span><span class="n">known</span><span class="p">,</span> <span class="n">unknown</span><span class="p">);</span> <span class="c1">// Calls overload B</span>
  <span class="n">Foo</span><span class="p">(</span><span class="n">unknown</span><span class="p">,</span> <span class="n">known</span><span class="p">);</span> <span class="c1">// Calls overload B</span>
  <span class="n">Foo</span><span class="p">(</span><span class="n">known</span><span class="p">,</span> <span class="n">known</span><span class="p">);</span> <span class="c1">// Calls overload B</span>

  <span class="n">Bar</span><span class="p">(</span><span class="n">known</span><span class="p">);</span> <span class="c1">// Calls overload D</span>
  <span class="n">Bar</span><span class="p">(</span><span class="n">unknown</span><span class="p">);</span> <span class="c1">// Calls overload D</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Currently, <code class="docutils literal"><span class="pre">pass_object_size</span></code> is a bit restricted in terms of its usage:</p>
<ul class="simple">
<li>Only one use of <code class="docutils literal"><span class="pre">pass_object_size</span></code> is allowed per parameter.</li>
<li>It is an error to take the address of a function with <code class="docutils literal"><span class="pre">pass_object_size</span></code> on
any of its parameters. If you wish to do this, you can create an overload
without <code class="docutils literal"><span class="pre">pass_object_size</span></code> on any parameters.</li>
<li>It is an error to apply the <code class="docutils literal"><span class="pre">pass_object_size</span></code> attribute to parameters that
are not pointers. Additionally, any parameter that <code class="docutils literal"><span class="pre">pass_object_size</span></code> is
applied to must be marked <code class="docutils literal"><span class="pre">const</span></code> at its function&#8217;s definition.</li>
</ul>
</div>
<div class="section" id="section-gnu-section-declspec-allocate">
<h3><a class="toc-backref" href="#id112">section (gnu::section, __declspec(allocate))</a><a class="headerlink" href="#section-gnu-section-declspec-allocate" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id38">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id38" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">section</span></code> attribute allows you to specify a specific section a
global variable or function should be in after translation.</p>
</div>
<div class="section" id="tls-model-gnu-tls-model">
<h3><a class="toc-backref" href="#id113">tls_model (gnu::tls_model)</a><a class="headerlink" href="#tls-model-gnu-tls-model" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id39">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id39" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">tls_model</span></code> attribute allows you to specify which thread-local storage
model to use. It accepts the following strings:</p>
<ul class="simple">
<li>global-dynamic</li>
<li>local-dynamic</li>
<li>initial-exec</li>
<li>local-exec</li>
</ul>
<p>TLS models are mutually exclusive.</p>
</div>
<div class="section" id="thread">
<h3><a class="toc-backref" href="#id114">thread</a><a class="headerlink" href="#thread" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id40">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id40" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">__declspec(thread)</span></code> attribute declares a variable with thread local
storage.  It is available under the <code class="docutils literal"><span class="pre">-fms-extensions</span></code> flag for MSVC
compatibility.  See the documentation for <a class="reference external" href="http://msdn.microsoft.com/en-us/library/9w1sdazb.aspx">__declspec(thread)</a> on MSDN.</p>
<p>In Clang, <code class="docutils literal"><span class="pre">__declspec(thread)</span></code> is generally equivalent in functionality to the
GNU <code class="docutils literal"><span class="pre">__thread</span></code> keyword.  The variable must not have a destructor and must have
a constant initializer, if any.  The attribute only applies to variables
declared with static storage duration, such as globals, class static data
members, and static locals.</p>
</div>
</div>
<div class="section" id="type-attributes">
<h2><a class="toc-backref" href="#id115">Type Attributes</a><a class="headerlink" href="#type-attributes" title="Permalink to this headline"></a></h2>
<div class="section" id="align-value">
<h3><a class="toc-backref" href="#id116">align_value</a><a class="headerlink" href="#align-value" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id41">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id41" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The align_value attribute can be added to the typedef of a pointer type or the
declaration of a variable of pointer or reference type. It specifies that the
pointer will point to, or the reference will bind to, only objects with at
least the provided alignment. This alignment value must be some positive power
of 2.</p>
<blockquote>
<div><div class="highlight-c"><div class="highlight"><pre><span class="k">typedef</span> <span class="kt">double</span> <span class="o">*</span> <span class="n">aligned_double_ptr</span> <span class="nf">__attribute__</span><span class="p">((</span><span class="n">align_value</span><span class="p">(</span><span class="mi">64</span><span class="p">)));</span>
<span class="kt">void</span> <span class="nf">foo</span><span class="p">(</span><span class="kt">double</span> <span class="o">&amp;</span> <span class="n">x</span>  <span class="n">__attribute__</span><span class="p">((</span><span class="n">align_value</span><span class="p">(</span><span class="mi">128</span><span class="p">)),</span>
         <span class="n">aligned_double_ptr</span> <span class="n">y</span><span class="p">)</span> <span class="p">{</span> <span class="p">...</span> <span class="p">}</span>
</pre></div>
</div>
</div></blockquote>
<p>If the pointer value does not have the specified alignment at runtime, the
behavior of the program is undefined.</p>
</div>
<div class="section" id="flag-enum">
<h3><a class="toc-backref" href="#id117">flag_enum</a><a class="headerlink" href="#flag-enum" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id42">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id42" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>This attribute can be added to an enumerator to signal to the compiler that it
is intended to be used as a flag type. This will cause the compiler to assume
that the range of the type includes all of the values that you can get by
manipulating bits of the enumerator when issuing warnings.</p>
</div>
<div class="section" id="single-inhertiance-multiple-inheritance-virtual-inheritance">
<h3><a class="toc-backref" href="#id118">__single_inhertiance, __multiple_inheritance, __virtual_inheritance</a><a class="headerlink" href="#single-inhertiance-multiple-inheritance-virtual-inheritance" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id43">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id43" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>This collection of keywords is enabled under <code class="docutils literal"><span class="pre">-fms-extensions</span></code> and controls
the pointer-to-member representation used on <code class="docutils literal"><span class="pre">*-*-win32</span></code> targets.</p>
<p>The <code class="docutils literal"><span class="pre">*-*-win32</span></code> targets utilize a pointer-to-member representation which
varies in size and alignment depending on the definition of the underlying
class.</p>
<p>However, this is problematic when a forward declaration is only available and
no definition has been made yet.  In such cases, Clang is forced to utilize the
most general representation that is available to it.</p>
<p>These keywords make it possible to use a pointer-to-member representation other
than the most general one regardless of whether or not the definition will ever
be present in the current translation unit.</p>
<p>This family of keywords belong between the <code class="docutils literal"><span class="pre">class-key</span></code> and <code class="docutils literal"><span class="pre">class-name</span></code>:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="k">struct</span> <span class="n">__single_inheritance</span> <span class="n">S</span><span class="p">;</span>
<span class="kt">int</span> <span class="n">S</span><span class="o">::*</span><span class="n">i</span><span class="p">;</span>
<span class="k">struct</span> <span class="n">S</span> <span class="p">{};</span>
</pre></div>
</div>
<p>This keyword can be applied to class templates but only has an effect when used
on full specializations:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="k">template</span> <span class="o">&lt;</span><span class="k">typename</span> <span class="n">T</span><span class="p">,</span> <span class="k">typename</span> <span class="n">U</span><span class="o">&gt;</span> <span class="k">struct</span> <span class="n">__single_inheritance</span> <span class="n">A</span><span class="p">;</span> <span class="c1">// warning: inheritance model ignored on primary template</span>
<span class="k">template</span> <span class="o">&lt;</span><span class="k">typename</span> <span class="n">T</span><span class="o">&gt;</span> <span class="k">struct</span> <span class="n">__multiple_inheritance</span> <span class="n">A</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span> <span class="n">T</span><span class="o">&gt;</span><span class="p">;</span> <span class="c1">// warning: inheritance model ignored on partial specialization</span>
<span class="k">template</span> <span class="o">&lt;&gt;</span> <span class="k">struct</span> <span class="n">__single_inheritance</span> <span class="n">A</span><span class="o">&lt;</span><span class="kt">int</span><span class="p">,</span> <span class="kt">float</span><span class="o">&gt;</span><span class="p">;</span>
</pre></div>
</div>
<p>Note that choosing an inheritance model less general than strictly necessary is
an error:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="k">struct</span> <span class="n">__multiple_inheritance</span> <span class="n">S</span><span class="p">;</span> <span class="c1">// error: inheritance model does not match definition</span>
<span class="kt">int</span> <span class="n">S</span><span class="o">::*</span><span class="n">i</span><span class="p">;</span>
<span class="k">struct</span> <span class="n">S</span> <span class="p">{};</span>
</pre></div>
</div>
</div>
<div class="section" id="novtable">
<h3><a class="toc-backref" href="#id119">novtable</a><a class="headerlink" href="#novtable" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id44">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id44" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>This attribute can be added to a class declaration or definition to signal to
the compiler that constructors and destructors will not reference the virtual
function table. It is only supported when using the Microsoft C++ ABI.</p>
</div>
</div>
<div class="section" id="statement-attributes">
<h2><a class="toc-backref" href="#id120">Statement Attributes</a><a class="headerlink" href="#statement-attributes" title="Permalink to this headline"></a></h2>
<div class="section" id="fallthrough-clang-fallthrough">
<h3><a class="toc-backref" href="#id121">fallthrough (clang::fallthrough)</a><a class="headerlink" href="#fallthrough-clang-fallthrough" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id45">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id45" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">clang::fallthrough</span></code> attribute is used along with the
<code class="docutils literal"><span class="pre">-Wimplicit-fallthrough</span></code> argument to annotate intentional fall-through
between switch labels.  It can only be applied to a null statement placed at a
point of execution between any statement and the next switch label.  It is
common to mark these places with a specific comment, but this attribute is
meant to replace comments with a more strict annotation, which can be checked
by the compiler.  This attribute doesn&#8217;t change semantics of the code and can
be used wherever an intended fall-through occurs.  It is designed to mimic
control-flow statements like <code class="docutils literal"><span class="pre">break;</span></code>, so it can be placed in most places
where <code class="docutils literal"><span class="pre">break;</span></code> can, but only if there are no statements on the execution path
between it and the next switch label.</p>
<p>Here is an example:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="c1">// compile with -Wimplicit-fallthrough</span>
<span class="k">switch</span> <span class="p">(</span><span class="n">n</span><span class="p">)</span> <span class="p">{</span>
<span class="k">case</span> <span class="mi">22</span><span class="o">:</span>
<span class="k">case</span> <span class="mi">33</span><span class="o">:</span>  <span class="c1">// no warning: no statements between case labels</span>
  <span class="n">f</span><span class="p">();</span>
<span class="k">case</span> <span class="mi">44</span><span class="o">:</span>  <span class="c1">// warning: unannotated fall-through</span>
  <span class="n">g</span><span class="p">();</span>
  <span class="p">[[</span><span class="n">clang</span><span class="o">::</span><span class="n">fallthrough</span><span class="p">]];</span>
<span class="k">case</span> <span class="mi">55</span><span class="o">:</span>  <span class="c1">// no warning</span>
  <span class="k">if</span> <span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="p">{</span>
    <span class="n">h</span><span class="p">();</span>
    <span class="k">break</span><span class="p">;</span>
  <span class="p">}</span>
  <span class="k">else</span> <span class="p">{</span>
    <span class="n">i</span><span class="p">();</span>
    <span class="p">[[</span><span class="n">clang</span><span class="o">::</span><span class="n">fallthrough</span><span class="p">]];</span>
  <span class="p">}</span>
<span class="k">case</span> <span class="mi">66</span><span class="o">:</span>  <span class="c1">// no warning</span>
  <span class="n">p</span><span class="p">();</span>
  <span class="p">[[</span><span class="n">clang</span><span class="o">::</span><span class="n">fallthrough</span><span class="p">]];</span> <span class="c1">// warning: fallthrough annotation does not</span>
                          <span class="c1">//          directly precede case label</span>
  <span class="n">q</span><span class="p">();</span>
<span class="k">case</span> <span class="mi">77</span><span class="o">:</span>  <span class="c1">// warning: unannotated fall-through</span>
  <span class="n">r</span><span class="p">();</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="pragma-clang-loop">
<h3><a class="toc-backref" href="#id122">#pragma clang loop</a><a class="headerlink" href="#pragma-clang-loop" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id46">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id46" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">#pragma</span> <span class="pre">clang</span> <span class="pre">loop</span></code> directive allows loop optimization hints to be
specified for the subsequent loop. The directive allows vectorization,
interleaving, and unrolling to be enabled or disabled. Vector width as well
as interleave and unrolling count can be manually specified. See
<a class="reference external" href="http://clang.llvm.org/docs/LanguageExtensions.html#extensions-for-loop-hint-optimizations">language extensions</a>
for details.</p>
</div>
<div class="section" id="pragma-unroll-pragma-nounroll">
<h3><a class="toc-backref" href="#id123">#pragma unroll, #pragma nounroll</a><a class="headerlink" href="#pragma-unroll-pragma-nounroll" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id47">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id47" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
</tr>
</tbody>
</table>
<p>Loop unrolling optimization hints can be specified with <code class="docutils literal"><span class="pre">#pragma</span> <span class="pre">unroll</span></code> and
<code class="docutils literal"><span class="pre">#pragma</span> <span class="pre">nounroll</span></code>. The pragma is placed immediately before a for, while,
do-while, or c++11 range-based for loop.</p>
<p>Specifying <code class="docutils literal"><span class="pre">#pragma</span> <span class="pre">unroll</span></code> without a parameter directs the loop unroller to
attempt to fully unroll the loop if the trip count is known at compile time and
attempt to partially unroll the loop if the trip count is not known at compile
time:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#pragma unroll</span>
<span class="k">for</span> <span class="p">(...)</span> <span class="p">{</span>
  <span class="p">...</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Specifying the optional parameter, <code class="docutils literal"><span class="pre">#pragma</span> <span class="pre">unroll</span> <span class="pre">_value_</span></code>, directs the
unroller to unroll the loop <code class="docutils literal"><span class="pre">_value_</span></code> times.  The parameter may optionally be
enclosed in parentheses:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#pragma unroll 16</span>
<span class="k">for</span> <span class="p">(...)</span> <span class="p">{</span>
  <span class="p">...</span>
<span class="p">}</span>

<span class="cp">#pragma unroll(16)</span>
<span class="k">for</span> <span class="p">(...)</span> <span class="p">{</span>
  <span class="p">...</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Specifying <code class="docutils literal"><span class="pre">#pragma</span> <span class="pre">nounroll</span></code> indicates that the loop should not be unrolled:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#pragma nounroll</span>
<span class="k">for</span> <span class="p">(...)</span> <span class="p">{</span>
  <span class="p">...</span>
<span class="p">}</span>
</pre></div>
</div>
<p><code class="docutils literal"><span class="pre">#pragma</span> <span class="pre">unroll</span></code> and <code class="docutils literal"><span class="pre">#pragma</span> <span class="pre">unroll</span> <span class="pre">_value_</span></code> have identical semantics to
<code class="docutils literal"><span class="pre">#pragma</span> <span class="pre">clang</span> <span class="pre">loop</span> <span class="pre">unroll(full)</span></code> and
<code class="docutils literal"><span class="pre">#pragma</span> <span class="pre">clang</span> <span class="pre">loop</span> <span class="pre">unroll_count(_value_)</span></code> respectively. <code class="docutils literal"><span class="pre">#pragma</span> <span class="pre">nounroll</span></code>
is equivalent to <code class="docutils literal"><span class="pre">#pragma</span> <span class="pre">clang</span> <span class="pre">loop</span> <span class="pre">unroll(disable)</span></code>.  See
<a class="reference external" href="http://clang.llvm.org/docs/LanguageExtensions.html#extensions-for-loop-hint-optimizations">language extensions</a>
for further details including limitations of the unroll hints.</p>
</div>
</div>
<div class="section" id="type-safety-checking">
<h2><a class="toc-backref" href="#id124">Type Safety Checking</a><a class="headerlink" href="#type-safety-checking" title="Permalink to this headline"></a></h2>
<p>Clang supports additional attributes to enable checking type safety properties
that can&#8217;t be enforced by the C type system.  Use cases include:</p>
<ul class="simple">
<li>MPI library implementations, where these attributes enable checking that
the buffer type matches the passed <code class="docutils literal"><span class="pre">MPI_Datatype</span></code>;</li>
<li>for HDF5 library there is a similar use case to MPI;</li>
<li>checking types of variadic functions&#8217; arguments for functions like
<code class="docutils literal"><span class="pre">fcntl()</span></code> and <code class="docutils literal"><span class="pre">ioctl()</span></code>.</li>
</ul>
<p>You can detect support for these attributes with <code class="docutils literal"><span class="pre">__has_attribute()</span></code>.  For
example:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#if defined(__has_attribute)</span>
<span class="cp">#  if __has_attribute(argument_with_type_tag) &amp;&amp; \</span>
<span class="cp">      __has_attribute(pointer_with_type_tag) &amp;&amp; \</span>
<span class="cp">      __has_attribute(type_tag_for_datatype)</span>
<span class="cp">#    define ATTR_MPI_PWT(buffer_idx, type_idx) __attribute__((pointer_with_type_tag(mpi,buffer_idx,type_idx)))</span>
<span class="cm">/* ... other macros ...  */</span>
<span class="cp">#  endif</span>
<span class="cp">#endif</span>

<span class="cp">#if !defined(ATTR_MPI_PWT)</span>
<span class="cp"># define ATTR_MPI_PWT(buffer_idx, type_idx)</span>
<span class="cp">#endif</span>

<span class="kt">int</span> <span class="nf">MPI_Send</span><span class="p">(</span><span class="kt">void</span> <span class="o">*</span><span class="n">buf</span><span class="p">,</span> <span class="kt">int</span> <span class="n">count</span><span class="p">,</span> <span class="n">MPI_Datatype</span> <span class="n">datatype</span> <span class="cm">/*, other args omitted */</span><span class="p">)</span>
    <span class="n">ATTR_MPI_PWT</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">);</span>
</pre></div>
</div>
<div class="section" id="argument-with-type-tag">
<h3><a class="toc-backref" href="#id125">argument_with_type_tag</a><a class="headerlink" href="#argument-with-type-tag" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id48">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id48" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Use <code class="docutils literal"><span class="pre">__attribute__((argument_with_type_tag(arg_kind,</span> <span class="pre">arg_idx,</span>
<span class="pre">type_tag_idx)))</span></code> on a function declaration to specify that the function
accepts a type tag that determines the type of some other argument.
<code class="docutils literal"><span class="pre">arg_kind</span></code> is an identifier that should be used when annotating all
applicable type tags.</p>
<p>This attribute is primarily useful for checking arguments of variadic functions
(<code class="docutils literal"><span class="pre">pointer_with_type_tag</span></code> can be used in most non-variadic cases).</p>
<p>For example:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">fcntl</span><span class="p">(</span><span class="kt">int</span> <span class="n">fd</span><span class="p">,</span> <span class="kt">int</span> <span class="n">cmd</span><span class="p">,</span> <span class="p">...)</span>
    <span class="n">__attribute__</span><span class="p">((</span> <span class="n">argument_with_type_tag</span><span class="p">(</span><span class="n">fcntl</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span> <span class="p">));</span>
</pre></div>
</div>
</div>
<div class="section" id="pointer-with-type-tag">
<h3><a class="toc-backref" href="#id126">pointer_with_type_tag</a><a class="headerlink" href="#pointer-with-type-tag" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id49">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id49" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Use <code class="docutils literal"><span class="pre">__attribute__((pointer_with_type_tag(ptr_kind,</span> <span class="pre">ptr_idx,</span> <span class="pre">type_tag_idx)))</span></code>
on a function declaration to specify that the function accepts a type tag that
determines the pointee type of some other pointer argument.</p>
<p>For example:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">MPI_Send</span><span class="p">(</span><span class="kt">void</span> <span class="o">*</span><span class="n">buf</span><span class="p">,</span> <span class="kt">int</span> <span class="n">count</span><span class="p">,</span> <span class="n">MPI_Datatype</span> <span class="n">datatype</span> <span class="cm">/*, other args omitted */</span><span class="p">)</span>
    <span class="n">__attribute__</span><span class="p">((</span> <span class="n">pointer_with_type_tag</span><span class="p">(</span><span class="n">mpi</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">3</span><span class="p">)</span> <span class="p">));</span>
</pre></div>
</div>
</div>
<div class="section" id="type-tag-for-datatype">
<h3><a class="toc-backref" href="#id127">type_tag_for_datatype</a><a class="headerlink" href="#type-tag-for-datatype" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id50">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id50" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Clang supports annotating type tags of two forms.</p>
<ul>
<li><p class="first"><strong>Type tag that is an expression containing a reference to some declared
identifier.</strong> Use <code class="docutils literal"><span class="pre">__attribute__((type_tag_for_datatype(kind,</span> <span class="pre">type)))</span></code> on a
declaration with that identifier:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="k">extern</span> <span class="k">struct</span> <span class="n">mpi_datatype</span> <span class="n">mpi_datatype_int</span>
    <span class="nf">__attribute__</span><span class="p">((</span> <span class="n">type_tag_for_datatype</span><span class="p">(</span><span class="n">mpi</span><span class="p">,</span><span class="kt">int</span><span class="p">)</span> <span class="p">));</span>
<span class="cp">#define MPI_INT ((MPI_Datatype) &amp;mpi_datatype_int)</span>
</pre></div>
</div>
</li>
<li><p class="first"><strong>Type tag that is an integral literal.</strong> Introduce a <code class="docutils literal"><span class="pre">static</span> <span class="pre">const</span></code>
variable with a corresponding initializer value and attach
<code class="docutils literal"><span class="pre">__attribute__((type_tag_for_datatype(kind,</span> <span class="pre">type)))</span></code> on that declaration,
for example:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="cp">#define MPI_INT ((MPI_Datatype) 42)</span>
<span class="k">static</span> <span class="k">const</span> <span class="n">MPI_Datatype</span> <span class="n">mpi_datatype_int</span>
    <span class="n">__attribute__</span><span class="p">((</span> <span class="n">type_tag_for_datatype</span><span class="p">(</span><span class="n">mpi</span><span class="p">,</span><span class="kt">int</span><span class="p">)</span> <span class="p">))</span> <span class="o">=</span> <span class="mi">42</span>
</pre></div>
</div>
</li>
</ul>
<p>The attribute also accepts an optional third argument that determines how the
expression is compared to the type tag.  There are two supported flags:</p>
<ul>
<li><p class="first"><code class="docutils literal"><span class="pre">layout_compatible</span></code> will cause types to be compared according to
layout-compatibility rules (C++11 [class.mem] p 17, 18).  This is
implemented to support annotating types like <code class="docutils literal"><span class="pre">MPI_DOUBLE_INT</span></code>.</p>
<p>For example:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="cm">/* In mpi.h */</span>
<span class="k">struct</span> <span class="n">internal_mpi_double_int</span> <span class="p">{</span> <span class="kt">double</span> <span class="n">d</span><span class="p">;</span> <span class="kt">int</span> <span class="n">i</span><span class="p">;</span> <span class="p">};</span>
<span class="k">extern</span> <span class="k">struct</span> <span class="n">mpi_datatype</span> <span class="n">mpi_datatype_double_int</span>
    <span class="nf">__attribute__</span><span class="p">((</span> <span class="n">type_tag_for_datatype</span><span class="p">(</span><span class="n">mpi</span><span class="p">,</span> <span class="k">struct</span> <span class="n">internal_mpi_double_int</span><span class="p">,</span> <span class="n">layout_compatible</span><span class="p">)</span> <span class="p">));</span>

<span class="cp">#define MPI_DOUBLE_INT ((MPI_Datatype) &amp;mpi_datatype_double_int)</span>

<span class="cm">/* In user code */</span>
<span class="k">struct</span> <span class="n">my_pair</span> <span class="p">{</span> <span class="kt">double</span> <span class="n">a</span><span class="p">;</span> <span class="kt">int</span> <span class="n">b</span><span class="p">;</span> <span class="p">};</span>
<span class="k">struct</span> <span class="n">my_pair</span> <span class="o">*</span><span class="n">buffer</span><span class="p">;</span>
<span class="n">MPI_Send</span><span class="p">(</span><span class="n">buffer</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">MPI_DOUBLE_INT</span> <span class="cm">/*, ...  */</span><span class="p">);</span> <span class="c1">// no warning</span>

<span class="k">struct</span> <span class="n">my_int_pair</span> <span class="p">{</span> <span class="kt">int</span> <span class="n">a</span><span class="p">;</span> <span class="kt">int</span> <span class="n">b</span><span class="p">;</span> <span class="p">}</span>
<span class="k">struct</span> <span class="n">my_int_pair</span> <span class="o">*</span><span class="n">buffer2</span><span class="p">;</span>
<span class="n">MPI_Send</span><span class="p">(</span><span class="n">buffer2</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">MPI_DOUBLE_INT</span> <span class="cm">/*, ...  */</span><span class="p">);</span> <span class="c1">// warning: actual buffer element</span>
                                                  <span class="c1">// type &#39;struct my_int_pair&#39;</span>
                                                  <span class="c1">// doesn&#39;t match specified MPI_Datatype</span>
</pre></div>
</div>
</li>
<li><p class="first"><code class="docutils literal"><span class="pre">must_be_null</span></code> specifies that the expression should be a null pointer
constant, for example:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="cm">/* In mpi.h */</span>
<span class="k">extern</span> <span class="k">struct</span> <span class="n">mpi_datatype</span> <span class="n">mpi_datatype_null</span>
    <span class="nf">__attribute__</span><span class="p">((</span> <span class="n">type_tag_for_datatype</span><span class="p">(</span><span class="n">mpi</span><span class="p">,</span> <span class="kt">void</span><span class="p">,</span> <span class="n">must_be_null</span><span class="p">)</span> <span class="p">));</span>

<span class="cp">#define MPI_DATATYPE_NULL ((MPI_Datatype) &amp;mpi_datatype_null)</span>

<span class="cm">/* In user code */</span>
<span class="n">MPI_Send</span><span class="p">(</span><span class="n">buffer</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">MPI_DATATYPE_NULL</span> <span class="cm">/*, ...  */</span><span class="p">);</span> <span class="c1">// warning: MPI_DATATYPE_NULL</span>
                                                    <span class="c1">// was specified but buffer</span>
                                                    <span class="c1">// is not a null pointer</span>
</pre></div>
</div>
</li>
</ul>
</div>
</div>
<div class="section" id="amd-gpu-register-attributes">
<h2><a class="toc-backref" href="#id128">AMD GPU Register Attributes</a><a class="headerlink" href="#amd-gpu-register-attributes" title="Permalink to this headline"></a></h2>
<p>Clang supports attributes for controlling register usage on AMD GPU
targets. These attributes may be attached to a kernel function
definition and is an optimization hint to the backend for the maximum
number of registers to use. This is useful in cases where register
limited occupancy is known to be an important factor for the
performance for the kernel.</p>
<p>The semantics are as follows:</p>
<ul class="simple">
<li>The backend will attempt to limit the number of used registers to
the specified value, but the exact number used is not
guaranteed. The number used may be rounded up to satisfy the
allocation requirements or ABI constraints of the subtarget. For
example, on Southern Islands VGPRs may only be allocated in
increments of 4, so requesting a limit of 39 VGPRs will really
attempt to use up to 40. Requesting more registers than the
subtarget supports will truncate to the maximum allowed. The backend
may also use fewer registers than requested whenever possible.</li>
<li>0 implies the default no limit on register usage.</li>
<li>Ignored on older VLIW subtargets which did not have separate scalar
and vector registers, R600 through Northern Islands.</li>
</ul>
<div class="section" id="amdgpu-num-sgpr">
<h3><a class="toc-backref" href="#id129">amdgpu_num_sgpr</a><a class="headerlink" href="#amdgpu-num-sgpr" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id51">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id51" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Clang supports the
<code class="docutils literal"><span class="pre">__attribute__((amdgpu_num_sgpr(&lt;num_registers&gt;)))</span></code> attribute on AMD
Southern Islands GPUs and later for controlling the number of scalar
registers. A typical value would be between 8 and 104 in increments of
8.</p>
<p>Due to common instruction constraints, an additional 2-4 SGPRs are
typically required for internal use depending on features used. This
value is a hint for the total number of SGPRs to use, and not the
number of user SGPRs, so no special consideration needs to be given
for these.</p>
</div>
<div class="section" id="amdgpu-num-vgpr">
<h3><a class="toc-backref" href="#id130">amdgpu_num_vgpr</a><a class="headerlink" href="#amdgpu-num-vgpr" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id52">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id52" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Clang supports the
<code class="docutils literal"><span class="pre">__attribute__((amdgpu_num_vgpr(&lt;num_registers&gt;)))</span></code> attribute on AMD
Southern Islands GPUs and later for controlling the number of vector
registers. A typical value would be between 4 and 256 in increments
of 4.</p>
</div>
</div>
<div class="section" id="calling-conventions">
<h2><a class="toc-backref" href="#id131">Calling Conventions</a><a class="headerlink" href="#calling-conventions" title="Permalink to this headline"></a></h2>
<p>Clang supports several different calling conventions, depending on the target
platform and architecture. The calling convention used for a function determines
how parameters are passed, how results are returned to the caller, and other
low-level details of calling a function.</p>
<div class="section" id="fastcall-gnu-fastcall-fastcall-fastcall">
<h3><a class="toc-backref" href="#id132">fastcall (gnu::fastcall, __fastcall, _fastcall)</a><a class="headerlink" href="#fastcall-gnu-fastcall-fastcall-fastcall" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id53">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id53" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>On 32-bit x86 targets, this attribute changes the calling convention of a
function to use ECX and EDX as register parameters and clear parameters off of
the stack on return. This convention does not support variadic calls or
unprototyped functions in C, and has no effect on x86_64 targets. This calling
convention is supported primarily for compatibility with existing code. Users
seeking register parameters should use the <code class="docutils literal"><span class="pre">regparm</span></code> attribute, which does
not require callee-cleanup.  See the documentation for <a class="reference external" href="http://msdn.microsoft.com/en-us/library/6xa169sk.aspx">__fastcall</a> on MSDN.</p>
</div>
<div class="section" id="ms-abi-gnu-ms-abi">
<h3><a class="toc-backref" href="#id133">ms_abi (gnu::ms_abi)</a><a class="headerlink" href="#ms-abi-gnu-ms-abi" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id54">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id54" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>On non-Windows x86_64 targets, this attribute changes the calling convention of
a function to match the default convention used on Windows x86_64. This
attribute has no effect on Windows targets or non-x86_64 targets.</p>
</div>
<div class="section" id="pcs-gnu-pcs">
<h3><a class="toc-backref" href="#id134">pcs (gnu::pcs)</a><a class="headerlink" href="#pcs-gnu-pcs" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id55">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id55" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>On ARM targets, this attribute can be used to select calling conventions
similar to <code class="docutils literal"><span class="pre">stdcall</span></code> on x86. Valid parameter values are &#8220;aapcs&#8221; and
&#8220;aapcs-vfp&#8221;.</p>
</div>
<div class="section" id="regparm-gnu-regparm">
<h3><a class="toc-backref" href="#id135">regparm (gnu::regparm)</a><a class="headerlink" href="#regparm-gnu-regparm" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id56">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id56" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>On 32-bit x86 targets, the regparm attribute causes the compiler to pass
the first three integer parameters in EAX, EDX, and ECX instead of on the
stack. This attribute has no effect on variadic functions, and all parameters
are passed via the stack as normal.</p>
</div>
<div class="section" id="stdcall-gnu-stdcall-stdcall-stdcall">
<h3><a class="toc-backref" href="#id136">stdcall (gnu::stdcall, __stdcall, _stdcall)</a><a class="headerlink" href="#stdcall-gnu-stdcall-stdcall-stdcall" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id57">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id57" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>On 32-bit x86 targets, this attribute changes the calling convention of a
function to clear parameters off of the stack on return. This convention does
not support variadic calls or unprototyped functions in C, and has no effect on
x86_64 targets. This calling convention is used widely by the Windows API and
COM applications.  See the documentation for <a class="reference external" href="http://msdn.microsoft.com/en-us/library/zxk0tw93.aspx">__stdcall</a> on MSDN.</p>
</div>
<div class="section" id="thiscall-gnu-thiscall-thiscall-thiscall">
<h3><a class="toc-backref" href="#id137">thiscall (gnu::thiscall, __thiscall, _thiscall)</a><a class="headerlink" href="#thiscall-gnu-thiscall-thiscall-thiscall" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id58">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id58" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>On 32-bit x86 targets, this attribute changes the calling convention of a
function to use ECX for the first parameter (typically the implicit <code class="docutils literal"><span class="pre">this</span></code>
parameter of C++ methods) and clear parameters off of the stack on return. This
convention does not support variadic calls or unprototyped functions in C, and
has no effect on x86_64 targets. See the documentation for <a class="reference external" href="http://msdn.microsoft.com/en-us/library/ek8tkfbw.aspx">__thiscall</a> on
MSDN.</p>
</div>
<div class="section" id="vectorcall-vectorcall-vectorcall">
<h3><a class="toc-backref" href="#id138">vectorcall (__vectorcall, _vectorcall)</a><a class="headerlink" href="#vectorcall-vectorcall-vectorcall" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id59">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id59" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>On 32-bit x86 <em>and</em> x86_64 targets, this attribute changes the calling
convention of a function to pass vector parameters in SSE registers.</p>
<p>On 32-bit x86 targets, this calling convention is similar to <code class="docutils literal"><span class="pre">__fastcall</span></code>.
The first two integer parameters are passed in ECX and EDX. Subsequent integer
parameters are passed in memory, and callee clears the stack.  On x86_64
targets, the callee does <em>not</em> clear the stack, and integer parameters are
passed in RCX, RDX, R8, and R9 as is done for the default Windows x64 calling
convention.</p>
<p>On both 32-bit x86 and x86_64 targets, vector and floating point arguments are
passed in XMM0-XMM5. Homogenous vector aggregates of up to four elements are
passed in sequential SSE registers if enough are available. If AVX is enabled,
256 bit vectors are passed in YMM0-YMM5. Any vector or aggregate type that
cannot be passed in registers for any reason is passed by reference, which
allows the caller to align the parameter memory.</p>
<p>See the documentation for <a class="reference external" href="http://msdn.microsoft.com/en-us/library/dn375768.aspx">__vectorcall</a> on MSDN for more details.</p>
</div>
</div>
<div class="section" id="consumed-annotation-checking">
<h2><a class="toc-backref" href="#id139">Consumed Annotation Checking</a><a class="headerlink" href="#consumed-annotation-checking" title="Permalink to this headline"></a></h2>
<p>Clang supports additional attributes for checking basic resource management
properties, specifically for unique objects that have a single owning reference.
The following attributes are currently supported, although <strong>the implementation
for these annotations is currently in development and are subject to change.</strong></p>
<div class="section" id="callable-when">
<h3><a class="toc-backref" href="#id140">callable_when</a><a class="headerlink" href="#callable-when" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id60">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id60" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Use <code class="docutils literal"><span class="pre">__attribute__((callable_when(...)))</span></code> to indicate what states a method
may be called in.  Valid states are unconsumed, consumed, or unknown.  Each
argument to this attribute must be a quoted string.  E.g.:</p>
<p><code class="docutils literal"><span class="pre">__attribute__((callable_when(&quot;unconsumed&quot;,</span> <span class="pre">&quot;unknown&quot;)))</span></code></p>
</div>
<div class="section" id="consumable">
<h3><a class="toc-backref" href="#id141">consumable</a><a class="headerlink" href="#consumable" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id61">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id61" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Each <code class="docutils literal"><span class="pre">class</span></code> that uses any of the typestate annotations must first be marked
using the <code class="docutils literal"><span class="pre">consumable</span></code> attribute.  Failure to do so will result in a warning.</p>
<p>This attribute accepts a single parameter that must be one of the following:
<code class="docutils literal"><span class="pre">unknown</span></code>, <code class="docutils literal"><span class="pre">consumed</span></code>, or <code class="docutils literal"><span class="pre">unconsumed</span></code>.</p>
</div>
<div class="section" id="param-typestate">
<h3><a class="toc-backref" href="#id142">param_typestate</a><a class="headerlink" href="#param-typestate" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id62">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id62" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>This attribute specifies expectations about function parameters.  Calls to an
function with annotated parameters will issue a warning if the corresponding
argument isn&#8217;t in the expected state.  The attribute is also used to set the
initial state of the parameter when analyzing the function&#8217;s body.</p>
</div>
<div class="section" id="return-typestate">
<h3><a class="toc-backref" href="#id143">return_typestate</a><a class="headerlink" href="#return-typestate" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id63">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id63" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">return_typestate</span></code> attribute can be applied to functions or parameters.
When applied to a function the attribute specifies the state of the returned
value.  The function&#8217;s body is checked to ensure that it always returns a value
in the specified state.  On the caller side, values returned by the annotated
function are initialized to the given state.</p>
<p>When applied to a function parameter it modifies the state of an argument after
a call to the function returns.  The function&#8217;s body is checked to ensure that
the parameter is in the expected state before returning.</p>
</div>
<div class="section" id="set-typestate">
<h3><a class="toc-backref" href="#id144">set_typestate</a><a class="headerlink" href="#set-typestate" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id64">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id64" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Annotate methods that transition an object into a new state with
<code class="docutils literal"><span class="pre">__attribute__((set_typestate(new_state)))</span></code>.  The new state must be
unconsumed, consumed, or unknown.</p>
</div>
<div class="section" id="test-typestate">
<h3><a class="toc-backref" href="#id145">test_typestate</a><a class="headerlink" href="#test-typestate" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id65">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id65" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>Use <code class="docutils literal"><span class="pre">__attribute__((test_typestate(tested_state)))</span></code> to indicate that a method
returns true if the object is in the specified state..</p>
</div>
</div>
<div class="section" id="opencl-address-spaces">
<h2><a class="toc-backref" href="#id146">OpenCL Address Spaces</a><a class="headerlink" href="#opencl-address-spaces" title="Permalink to this headline"></a></h2>
<p>The address space qualifier may be used to specify the region of memory that is
used to allocate the object. OpenCL supports the following address spaces:
__generic(generic), __global(global), __local(local), __private(private),
__constant(constant).</p>
<blockquote>
<div><div class="highlight-c"><div class="highlight"><pre><span class="n">__constant</span> <span class="kt">int</span> <span class="n">c</span> <span class="o">=</span> <span class="p">...;</span>

<span class="n">__generic</span> <span class="kt">int</span><span class="o">*</span> <span class="nf">foo</span><span class="p">(</span><span class="n">global</span> <span class="kt">int</span><span class="o">*</span> <span class="n">g</span><span class="p">)</span> <span class="p">{</span>
  <span class="n">__local</span> <span class="kt">int</span><span class="o">*</span> <span class="n">l</span><span class="p">;</span>
  <span class="n">private</span> <span class="kt">int</span> <span class="n">p</span><span class="p">;</span>
  <span class="p">...</span>
  <span class="k">return</span> <span class="n">l</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
</div></blockquote>
<p>More details can be found in the OpenCL C language Spec v2.0, Section 6.5.</p>
<div class="section" id="constant-constant">
<h3><a class="toc-backref" href="#id147">constant (__constant)</a><a class="headerlink" href="#constant-constant" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id66">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id66" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The constant address space attribute signals that an object is located in
a constant (non-modifiable) memory region. It is available to all work items.
Any type can be annotated with the constant address space attribute. Objects
with the constant address space qualifier can be declared in any scope and must
have an initializer.</p>
</div>
<div class="section" id="generic-generic">
<h3><a class="toc-backref" href="#id148">generic (__generic)</a><a class="headerlink" href="#generic-generic" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id67">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id67" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The generic address space attribute is only available with OpenCL v2.0 and later.
It can be used with pointer types. Variables in global and local scope and
function parameters in non-kernel functions can have the generic address space
type attribute. It is intended to be a placeholder for any other address space
except for &#8216;__constant&#8217; in OpenCL code which can be used with multiple address
spaces.</p>
</div>
<div class="section" id="global-global">
<h3><a class="toc-backref" href="#id149">global (__global)</a><a class="headerlink" href="#global-global" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id68">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id68" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The global address space attribute specifies that an object is allocated in
global memory, which is accessible by all work items. The content stored in this
memory area persists between kernel executions. Pointer types to the global
address space are allowed as function parameters or local variables. Starting
with OpenCL v2.0, the global address space can be used with global (program
scope) variables and static local variable as well.</p>
</div>
<div class="section" id="local-local">
<h3><a class="toc-backref" href="#id150">local (__local)</a><a class="headerlink" href="#local-local" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id69">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id69" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The local address space specifies that an object is allocated in the local (work
group) memory area, which is accessible to all work items in the same work
group. The content stored in this memory region is not accessible after
the kernel execution ends. In a kernel function scope, any variable can be in
the local address space. In other scopes, only pointer types to the local address
space are allowed. Local address space variables cannot have an initializer.</p>
</div>
<div class="section" id="private-private">
<h3><a class="toc-backref" href="#id151">private (__private)</a><a class="headerlink" href="#private-private" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id70">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id70" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The private address space specifies that an object is allocated in the private
(work item) memory. Other work items cannot access the same memory area and its
content is destroyed after work item execution ends. Local variables can be
declared in the private address space. Function arguments are always in the
private address space. Kernel function arguments of a pointer or an array type
cannot point to the private address space.</p>
</div>
</div>
<div class="section" id="nullability-attributes">
<h2><a class="toc-backref" href="#id152">Nullability Attributes</a><a class="headerlink" href="#nullability-attributes" title="Permalink to this headline"></a></h2>
<p>Whether a particular pointer may be &#8220;null&#8221; is an important concern when working with pointers in the C family of languages. The various nullability attributes indicate whether a particular pointer can be null or not, which makes APIs more expressive and can help static analysis tools identify bugs involving null pointers. Clang supports several kinds of nullability attributes: the <code class="docutils literal"><span class="pre">nonnull</span></code> and <code class="docutils literal"><span class="pre">returns_nonnull</span></code> attributes indicate which function or method parameters and result types can never be null, while nullability type qualifiers indicate which pointer types can be null (<code class="docutils literal"><span class="pre">_Nullable</span></code>) or cannot be null (<code class="docutils literal"><span class="pre">_Nonnull</span></code>).</p>
<p>The nullability (type) qualifiers express whether a value of a given pointer type can be null (the <code class="docutils literal"><span class="pre">_Nullable</span></code> qualifier), doesn&#8217;t have a defined meaning for null (the <code class="docutils literal"><span class="pre">_Nonnull</span></code> qualifier), or for which the purpose of null is unclear (the <code class="docutils literal"><span class="pre">_Null_unspecified</span></code> qualifier). Because nullability qualifiers are expressed within the type system, they are more general than the <code class="docutils literal"><span class="pre">nonnull</span></code> and <code class="docutils literal"><span class="pre">returns_nonnull</span></code> attributes, allowing one to express (for example) a nullable pointer to an array of nonnull pointers. Nullability qualifiers are written to the right of the pointer to which they apply. For example:</p>
<blockquote>
<div><div class="highlight-c"><div class="highlight"><pre><span class="c1">// No meaningful result when &#39;ptr&#39; is null (here, it happens to be undefined behavior).</span>
<span class="kt">int</span> <span class="nf">fetch</span><span class="p">(</span><span class="kt">int</span> <span class="o">*</span> <span class="n">_Nonnull</span> <span class="n">ptr</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="o">*</span><span class="n">ptr</span><span class="p">;</span> <span class="p">}</span>

<span class="c1">// &#39;ptr&#39; may be null.</span>
<span class="kt">int</span> <span class="nf">fetch_or_zero</span><span class="p">(</span><span class="kt">int</span> <span class="o">*</span> <span class="n">_Nullable</span> <span class="n">ptr</span><span class="p">)</span> <span class="p">{</span>
  <span class="k">return</span> <span class="n">ptr</span> <span class="o">?</span> <span class="o">*</span><span class="nl">ptr</span> <span class="p">:</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>

<span class="c1">// A nullable pointer to non-null pointers to const characters.</span>
<span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="nf">join_strings</span><span class="p">(</span><span class="k">const</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">_Nonnull</span> <span class="o">*</span> <span class="n">_Nullable</span> <span class="n">strings</span><span class="p">,</span> <span class="kt">unsigned</span> <span class="n">n</span><span class="p">);</span>
</pre></div>
</div>
</div></blockquote>
<p>In Objective-C, there is an alternate spelling for the nullability qualifiers that can be used in Objective-C methods and properties using context-sensitive, non-underscored keywords. For example:</p>
<blockquote>
<div><div class="highlight-objective-c"><div class="highlight"><pre><span class="k">@interface</span> <span class="nc">NSView</span> : <span class="nc">NSResponder</span>
  <span class="o">-</span> <span class="p">(</span><span class="n">nullable</span> <span class="n">NSView</span> <span class="o">*</span><span class="p">)</span><span class="nl">ancestorSharedWithView</span><span class="p">:(</span><span class="n">nonnull</span> <span class="n">NSView</span> <span class="o">*</span><span class="p">)</span><span class="n">aView</span><span class="p">;</span>
  <span class="k">@property</span> <span class="p">(</span><span class="k">assign</span><span class="p">,</span> <span class="n">nullable</span><span class="p">)</span> <span class="n">NSView</span> <span class="o">*</span><span class="n">superview</span><span class="p">;</span>
  <span class="k">@property</span> <span class="p">(</span><span class="k">readonly</span><span class="p">,</span> <span class="n">nonnull</span><span class="p">)</span> <span class="bp">NSArray</span> <span class="o">*</span><span class="n">subviews</span><span class="p">;</span>
<span class="k">@end</span>
</pre></div>
</div>
</div></blockquote>
<div class="section" id="nonnull-gnu-nonnull">
<h3><a class="toc-backref" href="#id153">nonnull (gnu::nonnull)</a><a class="headerlink" href="#nonnull-gnu-nonnull" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id71">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id71" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">nonnull</span></code> attribute indicates that some function parameters must not be null, and can be used in several different ways. It&#8217;s original usage (<a class="reference external" href="https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes">from GCC</a>) is as a function (or Objective-C method) attribute that specifies which parameters of the function are nonnull in a comma-separated list. For example:</p>
<blockquote>
<div><div class="highlight-c"><div class="highlight"><pre><span class="k">extern</span> <span class="kt">void</span> <span class="o">*</span> <span class="nf">my_memcpy</span> <span class="p">(</span><span class="kt">void</span> <span class="o">*</span><span class="n">dest</span><span class="p">,</span> <span class="k">const</span> <span class="kt">void</span> <span class="o">*</span><span class="n">src</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">len</span><span class="p">)</span>
                <span class="n">__attribute__</span><span class="p">((</span><span class="n">nonnull</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)));</span>
</pre></div>
</div>
</div></blockquote>
<p>Here, the <code class="docutils literal"><span class="pre">nonnull</span></code> attribute indicates that parameters 1 and 2
cannot have a null value. Omitting the parenthesized list of parameter indices means that all parameters of pointer type cannot be null:</p>
<blockquote>
<div><div class="highlight-c"><div class="highlight"><pre><span class="k">extern</span> <span class="kt">void</span> <span class="o">*</span> <span class="nf">my_memcpy</span> <span class="p">(</span><span class="kt">void</span> <span class="o">*</span><span class="n">dest</span><span class="p">,</span> <span class="k">const</span> <span class="kt">void</span> <span class="o">*</span><span class="n">src</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">len</span><span class="p">)</span>
                <span class="n">__attribute__</span><span class="p">((</span><span class="n">nonnull</span><span class="p">));</span>
</pre></div>
</div>
</div></blockquote>
<p>Clang also allows the <code class="docutils literal"><span class="pre">nonnull</span></code> attribute to be placed directly on a function (or Objective-C method) parameter, eliminating the need to specify the parameter index ahead of type. For example:</p>
<blockquote>
<div><div class="highlight-c"><div class="highlight"><pre><span class="k">extern</span> <span class="kt">void</span> <span class="o">*</span> <span class="nf">my_memcpy</span> <span class="p">(</span><span class="kt">void</span> <span class="o">*</span><span class="n">dest</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">nonnull</span><span class="p">)),</span>
                         <span class="k">const</span> <span class="kt">void</span> <span class="o">*</span><span class="n">src</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">nonnull</span><span class="p">)),</span> <span class="kt">size_t</span> <span class="n">len</span><span class="p">);</span>
</pre></div>
</div>
</div></blockquote>
<p>Note that the <code class="docutils literal"><span class="pre">nonnull</span></code> attribute indicates that passing null to a non-null parameter is undefined behavior, which the optimizer may take advantage of to, e.g., remove null checks. The <code class="docutils literal"><span class="pre">_Nonnull</span></code> type qualifier indicates that a pointer cannot be null in a more general manner (because it is part of the type system) and does not imply undefined behavior, making it more widely applicable.</p>
</div>
<div class="section" id="returns-nonnull-gnu-returns-nonnull">
<h3><a class="toc-backref" href="#id154">returns_nonnull (gnu::returns_nonnull)</a><a class="headerlink" href="#returns-nonnull-gnu-returns-nonnull" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id72">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id72" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>X</td>
<td>X</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">returns_nonnull</span></code> attribute indicates that a particular function (or Objective-C method) always returns a non-null pointer. For example, a particular system <code class="docutils literal"><span class="pre">malloc</span></code> might be defined to terminate a process when memory is not available rather than returning a null pointer:</p>
<blockquote>
<div><div class="highlight-c"><div class="highlight"><pre><span class="k">extern</span> <span class="kt">void</span> <span class="o">*</span> <span class="nf">malloc</span> <span class="p">(</span><span class="kt">size_t</span> <span class="n">size</span><span class="p">)</span> <span class="n">__attribute__</span><span class="p">((</span><span class="n">returns_nonnull</span><span class="p">));</span>
</pre></div>
</div>
</div></blockquote>
<p>The <code class="docutils literal"><span class="pre">returns_nonnull</span></code> attribute implies that returning a null pointer is undefined behavior, which the optimizer may take advantage of. The <code class="docutils literal"><span class="pre">_Nonnull</span></code> type qualifier indicates that a pointer cannot be null in a more general manner (because it is part of the type system) and does not imply undefined behavior, making it more widely applicable</p>
</div>
<div class="section" id="nonnull">
<h3><a class="toc-backref" href="#id155">_Nonnull</a><a class="headerlink" href="#nonnull" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id73">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id73" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">_Nonnull</span></code> nullability qualifier indicates that null is not a meaningful value for a value of the <code class="docutils literal"><span class="pre">_Nonnull</span></code> pointer type. For example, given a declaration such as:</p>
<blockquote>
<div><div class="highlight-c"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">fetch</span><span class="p">(</span><span class="kt">int</span> <span class="o">*</span> <span class="n">_Nonnull</span> <span class="n">ptr</span><span class="p">);</span>
</pre></div>
</div>
</div></blockquote>
<p>a caller of <code class="docutils literal"><span class="pre">fetch</span></code> should not provide a null value, and the compiler will produce a warning if it sees a literal null value passed to <code class="docutils literal"><span class="pre">fetch</span></code>. Note that, unlike the declaration attribute <code class="docutils literal"><span class="pre">nonnull</span></code>, the presence of <code class="docutils literal"><span class="pre">_Nonnull</span></code> does not imply that passing null is undefined behavior: <code class="docutils literal"><span class="pre">fetch</span></code> is free to consider null undefined behavior or (perhaps for backward-compatibility reasons) defensively handle null.</p>
</div>
<div class="section" id="null-unspecified">
<h3><a class="toc-backref" href="#id156">_Null_unspecified</a><a class="headerlink" href="#null-unspecified" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id74">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id74" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">_Null_unspecified</span></code> nullability qualifier indicates that neither the <code class="docutils literal"><span class="pre">_Nonnull</span></code> nor <code class="docutils literal"><span class="pre">_Nullable</span></code> qualifiers make sense for a particular pointer type. It is used primarily to indicate that the role of null with specific pointers in a nullability-annotated header is unclear, e.g., due to overly-complex implementations or historical factors with a long-lived API.</p>
</div>
<div class="section" id="nullable">
<h3><a class="toc-backref" href="#id157">_Nullable</a><a class="headerlink" href="#nullable" title="Permalink to this headline"></a></h3>
<table border="1" class="docutils" id="id75">
<caption><span class="caption-text">Supported Syntaxes</span><a class="headerlink" href="#id75" title="Permalink to this table"></a></caption>
<colgroup>
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
<col width="20%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">GNU</th>
<th class="head">C++11</th>
<th class="head">__declspec</th>
<th class="head">Keyword</th>
<th class="head">Pragma</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>X</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">_Nullable</span></code> nullability qualifier indicates that a value of the <code class="docutils literal"><span class="pre">_Nullable</span></code> pointer type can be null. For example, given:</p>
<blockquote>
<div><div class="highlight-c"><div class="highlight"><pre><span class="kt">int</span> <span class="nf">fetch_or_zero</span><span class="p">(</span><span class="kt">int</span> <span class="o">*</span> <span class="n">_Nullable</span> <span class="n">ptr</span><span class="p">);</span>
</pre></div>
</div>
</div></blockquote>
<p>a caller of <code class="docutils literal"><span class="pre">fetch_or_zero</span></code> can provide null.</p>
</div>
</div>
</div>


      </div>
      <div class="bottomnav" role="navigation" aria-label="bottom navigation">
      
        <p>
        «&#160;&#160;<a href="AutomaticReferenceCounting.html">Objective-C Automatic Reference Counting (ARC)</a>
        &#160;&#160;::&#160;&#160;
        <a class="uplink" href="index.html">Contents</a>
        &#160;&#160;::&#160;&#160;
        <a href="CrossCompilation.html">Cross-compilation using Clang</a>&#160;&#160;»
        </p>

      </div>

    <div class="footer" role="contentinfo">
        &copy; Copyright 2007-2016, The Clang Team.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.3.6.
    </div>
  </body>
</html>