clang: lib/AST/Decl.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

54#include "llvm/ADT/APSInt.h"

55#include "llvm/ADT/ArrayRef.h"

56#include "llvm/ADT/STLExtras.h"

57#include "llvm/ADT/SmallVector.h"

58#include "llvm/ADT/StringRef.h"

59#include "llvm/ADT/StringSwitch.h"

60#include "llvm/Support/Casting.h"

61#include "llvm/Support/ErrorHandling.h"

62#include "llvm/Support/raw_ostream.h"

63#include "llvm/TargetParser/Triple.h"

64#include

65#include

66#include

67#include

68#include

69#include

70#include

71#include

72#include <type_traits>

73

74using namespace clang;

75

78}

79

85 OS << ": ";

86 }

87 OS << Message;

88

89 if (auto *ND = dyn_cast_if_present(TheDecl)) {

90 OS << " '";

92 OS << "'";

93 }

94

95 OS << '\n';

96}

97

98

101}

102

103TranslationUnitDecl::TranslationUnitDecl(ASTContext &ctx)

105 DeclContext(TranslationUnit), redeclarable_base(ctx), Ctx(ctx) {}

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

161}

162

163

164

167 Kind.IgnoreExplicitVisibility = true;

168 return Kind;

169}

170

173 assert(!kind.IgnoreExplicitVisibility &&

174 "asking for explicit visibility when we shouldn't be");

175 return D->getExplicitVisibility(kind.getExplicitVisibilityKind());

176}

177

178

179

181 return isa(D) ||

182 isa(D) ||

183 isa(D);

184}

185

186

187

188template

189static std::enable_if_t<!std::is_base_of_v<RedeclarableTemplateDecl, T>, bool>

192 D->getMemberSpecializationInfo()) {

193 return member->isExplicitSpecialization();

194 }

195 return false;

196}

197

198

199

200

202 return D->isMemberSpecialization();

203}

204

205

206

207template

209 switch (attr->getVisibility()) {

210 case T::Default:

212 case T::Hidden:

214 case T::Protected:

216 }

217 llvm_unreachable("bad visibility kind");

218}

219

220

221static std::optional

223

224

226 if (const auto *A = D->getAttr()) {

228 }

229 }

230

231

232 if (const auto *A = D->getAttr()) {

234 }

235

236 return std::nullopt;

237}

238

244}

245

246

247

248

249LinkageInfo LinkageComputer::getLVForTemplateParameterList(

253

254

255 if (isa(P))

256 continue;

257

258

259

260

261

262 if (const auto *NTTP = dyn_cast(P)) {

263

264 if (!NTTP->isExpandedParameterPack()) {

265 if (!NTTP->getType()->isDependentType()) {

266 LV.merge(getLVForType(*NTTP->getType(), computation));

267 }

268 continue;

269 }

270

271

272 for (unsigned i = 0, n = NTTP->getNumExpansionTypes(); i != n; ++i) {

274 if (type->isDependentType())

276 }

277 continue;

278 }

279

280

281

282 const auto *TTP = cast(P);

283

284

285 if (!TTP->isExpandedParameterPack()) {

286 LV.merge(getLVForTemplateParameterList(TTP->getTemplateParameters(),

287 computation));

288 continue;

289 }

290

291

292 for (unsigned i = 0, n = TTP->getNumExpansionTemplateParameters();

293 i != n; ++i) {

294 LV.merge(getLVForTemplateParameterList(

295 TTP->getExpansionTemplateParameters(i), computation));

296 }

297 }

298

299 return LV;

300}

301

303 const Decl *Ret = nullptr;

305 while (DC->getDeclKind() != Decl::TranslationUnit) {

306 if (isa(DC) || isa(DC))

307 Ret = cast(DC);

309 }

310 return Ret;

311}

312

313

314

315

316

317

322

324 switch (Arg.getKind()) {

328 continue;

329

331 LV.merge(getLVForType(*Arg.getAsType(), computation));

332 continue;

333

335 const NamedDecl *ND = Arg.getAsDecl();

338 continue;

339 }

340

343 continue;

344

346 LV.merge(getLVForValue(Arg.getAsStructuralValue(), computation));

347 continue;

348

352 Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl(

353 true))

355 continue;

356

358 LV.merge(getLVForTemplateArgumentList(Arg.getPackAsArray(), computation));

359 continue;

360 }

361 llvm_unreachable("bad template argument kind");

362 }

363

364 return LV;

365}

366

368LinkageComputer::getLVForTemplateArgumentList(const TemplateArgumentList &TArgs,

370 return getLVForTemplateArgumentList(TArgs.asArray(), computation);

371}

372

375

376

377

378

380 return true;

381

382 return !fn->hasAttr();

383}

384

385

386

387

388

389

390

391

392void LinkageComputer::mergeTemplateLV(

396 bool considerVisibility =

398

400

402

403

405

406

410

411

413 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);

415}

416

417

418

422 return false;

423

425 D->hasAttr();

426}

427

428

429

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

454 return true;

455

456

459 return false;

460

462}

463

464

465

466void LinkageComputer::mergeTemplateLV(

470

471

472

474

476

477

479

484

485

486

487

489 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);

490 if (considerVisibility)

493}

494

495

496

497

498

502

503

504

505

507 return true;

508

509

510

511

512

515 return false;

516

518}

519

520

521

522

523void LinkageComputer::mergeTemplateLV(LinkageInfo &LV,

527

528

529

535

536

537

538

540 LinkageInfo argsLV = getLVForTemplateArgumentList(templateArgs, computation);

541 if (considerVisibility)

544}

545

547

549 if (!Opts.CPlusPlus || !Opts.InlineVisibilityHidden)

550 return false;

551

552 const auto *FD = dyn_cast(D);

553 if (!FD)

554 return false;

555

558 = FD->getTemplateSpecializationInfo()) {

561 FD->getMemberSpecializationInfo()) {

562 TSK = MSI->getTemplateSpecializationKind();

563 }

564

566

567

568

571 FD->hasBody(Def) && Def->isInlined() && !Def->hasAttr();

572}

573

575 const T *First = D->getFirstDecl();

576 return First->isInExternCContext();

577}

578

580 if (const auto *SD = dyn_cast(D.getDeclContext()))

581 if (!SD->hasBraces())

582 return true;

583 return false;

584}

585

588}

589

591 if (auto *TD = dyn_cast(D))

592 D = TD->getTemplatedDecl();

593 if (D) {

594 if (auto *VD = dyn_cast(D))

595 return VD->getStorageClass();

596 if (auto *FD = dyn_cast(D))

597 return FD->getStorageClass();

598 }

600}

601

603LinkageComputer::getLVForNamespaceScopeDecl(const NamedDecl *D,

605 bool IgnoreVarTypeLinkage) {

607 "Not a name having namespace scope");

609 const auto *Var = dyn_cast(D);

610

611

612

613

614

616 (Context.getLangOpts().C23 && Var && Var->isConstexpr())) {

617

618

619

620

621

622

623

624

626 }

627

628 if (Var) {

629

630

631

632

633

634

635

636

637 if (Context.getLangOpts().CPlusPlus && Var->getType().isConstQualified() &&

638 !Var->getType().isVolatileQualified() && !Var->isInline() &&

639 ![Var]() {

640

641

642 if (auto *M = Var->getOwningModule())

643 return M->isInterfaceOrPartition() || M->isImplicitGlobalModule();

644 return false;

645 }() &&

646 !isa(Var) &&

647 !Var->getDescribedVarTemplate()) {

649 if (PrevVar)

651

652 if (Var->getStorageClass() != SC_Extern &&

656 }

657

661 Var->getStorageClass() == SC_None)

663

666 }

667 } else if (const auto *IFD = dyn_cast(D)) {

668

669 const VarDecl *VD = IFD->getVarDecl();

670 assert(VD && "Expected a VarDecl in this IndirectFieldDecl!");

671 return getLVForNamespaceScopeDecl(VD, computation, IgnoreVarTypeLinkage);

672 }

673 assert(!isa(D) && "Didn't expect a FieldDecl!");

674

675

676

678 const auto *Var = dyn_cast(D);

679 const auto *Func = dyn_cast(D);

680

681

682

683

684

685

686

690 }

691

692

693

694

695

696

697

699

703 } else {

704

705

707 !isa(DC);

709 const auto *ND = dyn_cast(DC);

710 if (!ND) continue;

711 if (std::optional Vis =

714 break;

715 }

716 }

717 }

718

719

721

724 ? Context.getLangOpts().getValueVisibilityMode()

725 : Context.getLangOpts().getTypeVisibilityMode();

726 LV.mergeVisibility(globalVisibility, false);

727

728

729

732 }

733 }

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

751 if (const auto *Var = dyn_cast(D)) {

752

753

754

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

775 !IgnoreVarTypeLinkage) {

776 LinkageInfo TypeLV = getLVForType(*Var->getType(), computation);

781 }

782

785

786

787

788

789

790

791

792

793 if (const auto *spec = dyn_cast(Var)) {

794 mergeTemplateLV(LV, spec, computation);

795 }

796

797

798 } else if (const auto *Function = dyn_cast(D)) {

799

800

801

802

803

806

807

808

809

811 Context.getLangOpts().OpenMPIsTargetDevice &&

814 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(Function)))

816

817

818

819

820

821

822

823

824

826

827

830 TypeAsWritten = TSI->getType();

833 }

834

835

836

837

839 = Function->getTemplateSpecializationInfo()) {

840 mergeTemplateLV(LV, Function, specInfo, computation);

841 }

842

843

844

845

846

847

848

849 } else if (const auto *Tag = dyn_cast(D)) {

850

851 if (Tag->hasNameForLinkage())

853

854

855

856

857 if (const auto *spec = dyn_cast(Tag)) {

858 mergeTemplateLV(LV, spec, computation);

859 }

860

861

862

863 } else if (isa(D)) {

865 computation);

868 LV.merge(EnumLV);

869

870

871 } else if (const auto *temp = dyn_cast(D)) {

876

877

878

879

880

881

882 } else if (isa(D)) {

883 return LV;

884

885

886

887 } else if (isa(D)) {

888

889

890 } else if (auto *TD = dyn_cast(D)) {

891

892

893 if (!TD->getAnonDeclWithTypedefName(true))

895

896 } else if (isa(D)) {

897

898

899

900

901 } else {

903 }

904

905

906

909

910 return LV;

911}

912

914LinkageComputer::getLVForClassMember(const NamedDecl *D,

916 bool IgnoreVarTypeLinkage) {

917

918

919

920

921

922

923

924

925

926

927 if (!(isa(D) ||

928 isa(D) ||

929 isa(D) ||

930 isa(D) ||

931 isa(D) ||

932 isa(D)))

934

936

937

941

942

943

944

945

948 }

949

950

951

952

956

959

960

961

963 return classLV;

964

965

966

967

968

969

970 const NamedDecl *explicitSpecSuppressor = nullptr;

971

972 if (const auto *MD = dyn_cast(D)) {

973

974

975 QualType TypeAsWritten = MD->getType();

977 TypeAsWritten = TSI->getType();

980

981

982

984 = MD->getTemplateSpecializationInfo()) {

985 mergeTemplateLV(LV, MD, spec, computation);

987 explicitSpecSuppressor = MD;

989 explicitSpecSuppressor = spec->getTemplate()->getTemplatedDecl();

990 }

992 explicitSpecSuppressor = MD;

993 }

994

995

996

997

1000 Context.getLangOpts().OpenMPIsTargetDevice &&

1003 OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(MD)))

1005

1006 } else if (const auto *RD = dyn_cast(D)) {

1007 if (const auto *spec = dyn_cast(RD)) {

1008 mergeTemplateLV(LV, spec, computation);

1010 explicitSpecSuppressor = spec;

1011 } else {

1015 }

1016 }

1018 explicitSpecSuppressor = RD;

1019 }

1020

1021

1022 } else if (const auto *VD = dyn_cast(D)) {

1023 if (const auto *spec = dyn_cast(VD))

1024 mergeTemplateLV(LV, spec, computation);

1025

1026

1027

1028 if (!IgnoreVarTypeLinkage) {

1030

1031

1035 }

1036

1038 explicitSpecSuppressor = VD;

1039 }

1040

1041

1042 } else if (const auto *temp = dyn_cast(D)) {

1043 bool considerVisibility =

1050

1051 if (const auto *redeclTemp = dyn_cast(temp)) {

1054 }

1055 }

1056 }

1057

1058

1059 assert(!explicitSpecSuppressor || !isa(explicitSpecSuppressor));

1060

1061

1062

1063 bool considerClassVisibility = true;

1064 if (explicitSpecSuppressor &&

1065

1069 considerClassVisibility = false;

1070 }

1071

1072

1074 return LV;

1075}

1076

1077void NamedDecl::anchor() {}

1078

1081 return true;

1082

1087}

1088

1090

1091

1092

1093

1094

1095

1096

1099 return false;

1100 if (isa(this))

1101 return true;

1102 if (const auto *IFD = dyn_cast(this)) {

1105 return false;

1106 const VarDecl *VD = IFD->getVarDecl();

1108 }

1109

1110 if (const auto *VD = dyn_cast(this)) {

1111 if (isa(VD))

1112 return false;

1114 return true;

1116 }

1117 if (const auto *BD = dyn_cast(this);

1119 const VarDecl *VD = BD->getHoldingVar();

1121 }

1122 return false;

1123}

1124

1128

1129

1130

1131 if (!II)

1133

1136

1137

1140

1141

1142

1143

1144

1145

1146

1147

1150 return Status;

1151 if (auto *VD = dyn_cast(this))

1154 if (auto *FD = dyn_cast(this))

1155 if (FD->isExternC())

1158 }

1159

1160 return Status;

1161}

1162

1164 StringRef name = getName();

1165 if (name.empty()) return SFF_None;

1166

1167 if (name.front() == 'C')

1168 if (name == "CFStringCreateWithFormat" ||

1169 name == "CFStringCreateWithFormatAndArguments" ||

1170 name == "CFStringAppendFormat" ||

1171 name == "CFStringAppendFormatAndArguments")

1174}

1175

1177

1178

1182}

1183

1185

1190 return false;

1194 }

1195 llvm_unreachable("unexpected module ownership kind");

1196}

1197

1198

1199

1202

1203

1204

1205

1206

1207

1208

1209

1210

1214 !isa(this))

1216

1218}

1219

1222}

1223

1224static std::optional

1227 bool IsMostRecent) {

1229

1230

1231 if (std::optional V = getVisibilityOf(ND, kind))

1232 return V;

1233

1234

1235

1236 if (const auto *RD = dyn_cast(ND)) {

1238 if (InstantiatedFrom)

1240 }

1241

1242

1243

1244

1245 if (const auto *spec = dyn_cast(ND)) {

1246

1247

1249 while (TD != nullptr) {

1251 if (Vis != std::nullopt)

1252 return Vis;

1253 TD = TD->getPreviousDecl();

1254 }

1255 return std::nullopt;

1256 }

1257

1258

1259 if (!IsMostRecent && !isa(ND)) {

1261 if (MostRecent != ND)

1263 }

1264

1265 if (const auto *Var = dyn_cast(ND)) {

1266 if (Var->isStaticDataMember()) {

1268 if (InstantiatedFrom)

1270 }

1271

1272 if (const auto *VTSD = dyn_cast(Var))

1273 return getVisibilityOf(VTSD->getSpecializedTemplate()->getTemplatedDecl(),

1274 kind);

1275

1276 return std::nullopt;

1277 }

1278

1279 if (const auto *fn = dyn_cast(ND)) {

1280

1281

1284 return getVisibilityOf(templateInfo->getTemplate()->getTemplatedDecl(),

1285 kind);

1286

1287

1288

1290 if (InstantiatedFrom)

1292

1293 return std::nullopt;

1294 }

1295

1296

1297 if (const auto *TD = dyn_cast(ND))

1299

1300 return std::nullopt;

1301}

1302

1303std::optional

1306}

1307

1309 Decl *ContextDecl,

1311

1313 if (!ContextDecl)

1314 Owner = dyn_cast(DC);

1315 else if (isa(ContextDecl))

1316 Owner =

1318 else if (isa(ContextDecl)) {

1319

1320

1321 Owner = dyn_cast(ContextDecl->getDeclContext());

1322 } else {

1323 Owner = cast(ContextDecl);

1324 }

1325

1326 if (!Owner)

1328

1329

1330

1331

1332

1333 auto *VD = dyn_cast(Owner);

1336 ? computeLVForDecl(Owner, computation, true)

1338

1339

1340

1345}

1346

1349 if (const auto *Function = dyn_cast(D)) {

1350 if (Function->isInAnonymousNamespace() &&

1353

1354

1355 if (Function->getCanonicalDecl()->getStorageClass() == SC_Static)

1357

1360 if (std::optional Vis =

1363 }

1364

1365

1366

1367

1368

1369 return LV;

1370 }

1371

1372 if (const auto *Var = dyn_cast(D)) {

1373 if (Var->hasExternalStorage()) {

1376

1381 if (std::optional Vis =

1384 }

1385

1391 }

1392

1393 return LV;

1394 }

1395

1396 if (!Var->isStaticLocal())

1398 }

1399

1403

1407

1409 if (const auto *BD = dyn_cast(OuterD)) {

1410 if (!BD->getBlockManglingNumber())

1412

1413 LV = getLVForClosure(BD->getDeclContext()->getRedeclContext(),

1414 BD->getBlockManglingContextDecl(), computation);

1415 } else {

1416 const auto *FD = cast(OuterD);

1417 if (!FD->isInlined() &&

1420

1421

1422

1423

1427 !Context.getLangOpts().VisibilityInlinesHiddenStaticLocalVar) {

1428 assert(cast(D)->isStaticLocal());

1429

1430

1431

1432 if (const auto *MD = dyn_cast(FD))

1433 LV = getLVForDecl(MD->getParent(), computation);

1437 ? Context.getLangOpts().getValueVisibilityMode()

1438 : Context.getLangOpts().getTypeVisibilityMode();

1440 false);

1441 }

1442 }

1443 }

1448}

1449

1452 bool IgnoreVarTypeLinkage) {

1453

1454 if (D->hasAttr())

1456

1457

1458

1460 default:

1461 break;

1462

1463

1464

1465

1466

1467

1468

1469 case Decl::ImplicitParam:

1470 case Decl::Label:

1471 case Decl::NamespaceAlias:

1472 case Decl::ParmVar:

1473 case Decl::Using:

1474 case Decl::UsingEnum:

1475 case Decl::UsingShadow:

1476 case Decl::UsingDirective:

1478

1479 case Decl::EnumConstant:

1480

1484

1485 case Decl::Typedef:

1486 case Decl::TypeAlias:

1487

1488

1489 if (!cast(D)

1490 ->getAnonDeclWithTypedefName(true))

1492 break;

1493

1494 case Decl::TemplateTemplateParm:

1495 case Decl::NonTypeTemplateParm:

1496 case Decl::ObjCAtDefsField:

1497 case Decl::ObjCCategory:

1498 case Decl::ObjCCategoryImpl:

1499 case Decl::ObjCCompatibleAlias:

1500 case Decl::ObjCImplementation:

1501 case Decl::ObjCMethod:

1502 case Decl::ObjCProperty:

1503 case Decl::ObjCPropertyImpl:

1504 case Decl::ObjCProtocol:

1506

1507 case Decl::CXXRecord: {

1508 const auto *Record = cast(D);

1509 if (Record->isLambda()) {

1510 if (Record->hasKnownLambdaInternalLinkage() ||

1511 Record->getLambdaManglingNumber()) {

1512

1514 }

1515

1516 return getLVForClosure(

1517 Record->getDeclContext()->getRedeclContext(),

1518 Record->getLambdaContextDecl(), computation);

1519 }

1520

1521 break;

1522 }

1523

1524 case Decl::TemplateParamObject: {

1525

1526

1527 auto *TPO = cast(D);

1528 LinkageInfo LV = getLVForType(*TPO->getType(), computation);

1529 LV.merge(getLVForValue(TPO->getValue(), computation));

1530 return LV;

1531 }

1532 }

1533

1534

1536 return getLVForNamespaceScopeDecl(D, computation, IgnoreVarTypeLinkage);

1537

1538

1539

1540

1541

1542

1543

1544

1546 return getLVForClassMember(D, computation, IgnoreVarTypeLinkage);

1547

1548

1549

1550

1551

1552

1553

1554

1555

1556

1557

1558

1560 return getLVForLocalDecl(D, computation);

1561

1562

1563

1565}

1566

1567

1570

1571 if (D->hasAttr())

1573

1576

1577 if (std::optional LI = lookup(D, computation))

1578 return *LI;

1579

1583

1585 cache(D, computation, LV);

1586

1587#ifndef NDEBUG

1588

1589

1590

1592 if (!Opts.CPlusPlus || Opts.MicrosoftExt)

1593 return LV;

1594

1595

1596

1597

1599 for (auto *I : D->redecls()) {

1600 auto *T = cast(I);

1601 if (T == D)

1602 continue;

1603 if (T->isInvalidDecl() && T->hasCachedLinkage()) {

1604 Old = T;

1605 break;

1606 }

1607 }

1609#endif

1610

1611 return LV;

1612}

1613

1621 : CK);

1622}

1623

1625 if (isa(this))

1626

1627

1628 return nullptr;

1629

1631 if (!M)

1632 return nullptr;

1633

1634 switch (M->Kind) {

1636

1637 return nullptr;

1638

1643 return M;

1644

1648

1649 return nullptr;

1650

1652

1653

1655 }

1656

1657 llvm_unreachable("unknown module kind");

1658}

1659

1661 Name.print(OS, Policy);

1662}

1663

1666}

1667

1669 std::string QualName;

1670 llvm::raw_string_ostream OS(QualName);

1672 return QualName;

1673}

1674

1677}

1678

1682

1684 return;

1685 }

1688 OS << *this;

1689 else {

1690

1691

1693 llvm::raw_svector_ostream NameOS(NameBuffer);

1695 if (NameBuffer.empty())

1696 OS << "(anonymous)";

1697 else

1698 OS << NameBuffer;

1699 }

1700}

1701

1704}

1705

1709

1710

1711

1712 if (auto *MD = dyn_cast(this)) {

1713 if (auto *ID = MD->getClassInterface())

1714 Ctx = ID;

1715 } else if (auto *PD = dyn_cast(this)) {

1716 if (auto *MD = PD->getGetterMethodDecl())

1717 if (auto *ID = MD->getClassInterface())

1718 Ctx = ID;

1719 } else if (auto *ID = dyn_cast(this)) {

1720 if (auto *CI = ID->getContainingInterface())

1721 Ctx = CI;

1722 }

1723

1724 if (Ctx->isFunctionOrMethod())

1725 return;

1726

1728 ContextsTy Contexts;

1729

1730

1732 for (; Ctx; Ctx = Ctx->getParent()) {

1733

1734 if (P.SuppressUnwrittenScope && isa(Ctx) &&

1735 cast(Ctx)->isAnonymousNamespace())

1736 continue;

1737

1738

1739 if (Ctx->isInlineNamespace() && NameInScope) {

1740 if (P.SuppressInlineNamespace ==

1742 (P.SuppressInlineNamespace ==

1744 cast(Ctx)->isRedundantInlineQualifierFor(

1745 NameInScope))) {

1746 continue;

1747 }

1748 }

1749

1750

1751 const NamedDecl *ND = dyn_cast(Ctx);

1752 if (!ND)

1753 continue;

1754

1755 Contexts.push_back(Ctx);

1757 }

1758

1759 for (const DeclContext *DC : llvm::reverse(Contexts)) {

1760 if (const auto *Spec = dyn_cast(DC)) {

1761 OS << Spec->getName();

1764 OS, TemplateArgs.asArray(), P,

1765 Spec->getSpecializedTemplate()->getTemplateParameters());

1766 } else if (const auto *ND = dyn_cast(DC)) {

1767 if (ND->isAnonymousNamespace()) {

1768 OS << (P.MSVCFormatting ? "`anonymous namespace\'"

1769 : "(anonymous namespace)");

1770 }

1771 else

1772 OS << *ND;

1773 } else if (const auto *RD = dyn_cast(DC)) {

1774 if (!RD->getIdentifier())

1775 OS << "(anonymous " << RD->getKindName() << ')';

1776 else

1777 OS << *RD;

1778 } else if (const auto *FD = dyn_cast(DC)) {

1780 if (FD->hasWrittenPrototype())

1781 FT = dyn_cast(FD->getType()->castAs<FunctionType>());

1782

1783 OS << *FD << '(';

1784 if (FT) {

1785 unsigned NumParams = FD->getNumParams();

1786 for (unsigned i = 0; i < NumParams; ++i) {

1787 if (i)

1788 OS << ", ";

1789 OS << FD->getParamDecl(i)->getType().stream(P);

1790 }

1791

1793 if (NumParams > 0)

1794 OS << ", ";

1795 OS << "...";

1796 }

1797 }

1798 OS << ')';

1799 } else if (const auto *ED = dyn_cast(DC)) {

1800

1801

1802

1803

1804

1805

1806

1807 if (ED->isScoped())

1808 OS << *ED;

1809 else

1810 continue;

1811 } else {

1812 OS << *cast(DC);

1813 }

1814 OS << "::";

1815 }

1816}

1817

1823 else

1825}

1826

1828 return true;

1829}

1832 switch (K) {

1833#define DECL(Type, Base) \

1834 case Decl::Type: \

1835 return isRedeclarableImpl((Type##Decl *)nullptr);

1836#define ABSTRACT_DECL(DECL)

1837#include "clang/AST/DeclNodes.inc"

1838 }

1839 llvm_unreachable("unknown decl kind");

1840}

1841

1843 bool IsKnownNewer) const {

1845

1846

1847

1849 return false;

1850

1851

1853 return false;

1854

1855

1856 if (isa(this))

1857 return false;

1858

1859

1860

1861 if (isa(this))

1862 return true;

1863

1864

1865

1866

1867 if (!this->getDeclContext()->getRedeclContext()->Equals(

1869 return false;

1870

1871

1872

1873 if (const auto *UD = dyn_cast(this)) {

1877 cast(OldD)->getQualifier());

1878 }

1879 if (const auto *UUVD = dyn_cast(this)) {

1883 cast(OldD)->getQualifier());

1884 }

1885

1888 return false;

1889

1890 if (IsKnownNewer)

1891 return true;

1892

1893

1894

1895

1896 for (const auto *D : redecls()) {

1897 if (D == OldD)

1898 break;

1899

1900

1901

1902

1903

1905 return false;

1906 }

1907

1908

1909

1910 return true;

1911 }

1912

1913

1914

1915

1916 return false;

1917}

1918

1922 llvm_unreachable("Linkage hasn't been computed!");

1924 return false;

1926 return true;

1929 llvm_unreachable("Non-formal linkage is not allowed here!");

1932 return true;

1933 }

1934 llvm_unreachable("Unhandled Linkage enum");

1935}

1936

1937NamedDecl *NamedDecl::getUnderlyingDeclImpl() {

1939 if (auto *UD = dyn_cast(ND))

1940 ND = UD->getTargetDecl();

1941

1942 if (auto *AD = dyn_cast(ND))

1943 return AD->getClassInterface();

1944

1945 if (auto *AD = dyn_cast(ND))

1946 return AD->getNamespace();

1947

1948 return ND;

1949}

1950

1953 return false;

1954

1956 if (isa(D))

1957 D = cast(D)->getTargetDecl();

1958

1959 if (isa(D) || isa(D) || isa(D))

1960 return true;

1961 if (const auto *MD = dyn_cast_if_present(D->getAsFunction()))

1962 return MD->isInstance();

1963 return false;

1964}

1965

1966

1967

1968

1969

1970template

1972 if (decl->getNumTemplateParameterLists() > 0)

1973 return decl->getTemplateParameterList(0)->getTemplateLoc();

1974 return decl->getInnerLocStart();

1975}

1976

1981}

1982

1987}

1988

1990 if (QualifierLoc) {

1991

1992 if (!hasExtInfo()) {

1993

1994 auto *savedTInfo = cast<TypeSourceInfo *>(DeclInfo);

1995

1997

1998 getExtInfo()->TInfo = savedTInfo;

1999 }

2000

2001 getExtInfo()->QualifierLoc = QualifierLoc;

2002 } else if (hasExtInfo()) {

2003

2004 getExtInfo()->QualifierLoc = QualifierLoc;

2005 }

2006}

2007

2009 assert(TrailingRequiresClause);

2010

2011 if (!hasExtInfo()) {

2012

2013 auto *savedTInfo = cast<TypeSourceInfo *>(DeclInfo);

2014

2016

2017 getExtInfo()->TInfo = savedTInfo;

2018 }

2019

2020 getExtInfo()->TrailingRequiresClause = TrailingRequiresClause;

2021}

2022

2025 assert(!TPLists.empty());

2026

2027 if (!hasExtInfo()) {

2028

2029 auto *savedTInfo = cast<TypeSourceInfo *>(DeclInfo);

2030

2032

2033 getExtInfo()->TInfo = savedTInfo;

2034 }

2035

2036 getExtInfo()->setTemplateParameterListsInfo(Context, TPLists);

2037}

2038

2041}

2042

2043

2044

2046 while (true) {

2049 default:

2050 return false;

2051 case Type::Pointer:

2053 break;

2054 case Type::BlockPointer:

2056 break;

2057 case Type::MemberPointer:

2059 break;

2060 case Type::LValueReference:

2061 case Type::RValueReference:

2063 break;

2064 case Type::PackExpansion:

2065 QT = cast(T)->getPattern();

2066 break;

2067 case Type::Paren:

2068 case Type::ConstantArray:

2069 case Type::DependentSizedArray:

2070 case Type::IncompleteArray:

2071 case Type::VariableArray:

2072 case Type::FunctionProto:

2073 case Type::FunctionNoProto:

2074 return true;

2075 }

2076 }

2077}

2078

2082

2083

2085 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();

2086 }

2088}

2089

2092

2097 }

2098

2099 if (!TPLists.empty()) {

2102 std::copy(TPLists.begin(), TPLists.end(), TemplParamLists);

2103 }

2104}

2105

2106

2107

2108

2109

2111 switch (SC) {

2113 case SC_Auto: return "auto";

2114 case SC_Extern: return "extern";

2117 case SC_Static: return "static";

2118 }

2119

2120 llvm_unreachable("Invalid storage class");

2121}

2122

2129 static_assert(sizeof(VarDeclBitfields) <= sizeof(unsigned),

2130 "VarDeclBitfields too large!");

2132 "ParmVarDeclBitfields too large!");

2134 "NonParmVarDeclBitfields too large!");

2137

2138}

2139

2143 return new (C, DC) VarDecl(Var, C, DC, StartL, IdL, Id, T, TInfo, S);

2144}

2145

2147 return new (C, ID)

2150}

2151

2155}

2156

2160 if (!hasAttr() &&

2162 getASTContext().getTargetInfo().isTLSSupported() &&

2163 hasAttr()))

2167 hasAttr())

2175 }

2176 llvm_unreachable("Unknown thread storage class specifier!");

2177}

2178

2182

2183

2186 }

2188}

2189

2190template

2192

2193

2194 if (D.hasExternalFormalLinkage())

2196

2197

2198

2201

2202

2203

2204

2208

2209

2210

2211

2215}

2216

2217template

2219

2220

2224 return false;

2225 }

2226

2228}

2229

2232}

2233

2236}

2237

2240}

2241

2244}

2245

2247

2252

2253

2254

2255

2256

2257

2258

2259

2260

2261

2262

2263

2264

2265

2271

2272

2273

2278 isa(this)))

2283 }

2284

2285

2286

2287

2288

2289

2290

2293

2296

2297 if (const auto *SAA = getAttr())

2298 if (!SAA->isInherited())

2300

2301

2302

2303

2304 if (auto *VTSD = dyn_cast(this)) {

2306 !isa(VTSD) &&

2307 !VTSD->IsCompleteDefinition)

2309 }

2310

2313

2314

2315

2316

2317

2320

2321

2322

2323

2324

2325

2328

2329

2330

2332}

2333

2337 return nullptr;

2338

2339 VarDecl *LastTentative = nullptr;

2340

2341

2344 Kind = Decl->isThisDeclarationADefinition();

2346 return nullptr;

2347

2349 LastTentative = Decl;

2350 }

2351

2352 return LastTentative;

2353}

2354

2358 if (I->isThisDeclarationADefinition(C) == Definition)

2359 return I;

2360 }

2361 return nullptr;

2362}

2363

2366

2369 Kind = std::max(Kind, I->isThisDeclarationADefinition(C));

2371 break;

2372 }

2373

2374 return Kind;

2375}

2376

2378 for (auto *I : redecls()) {

2379 if (auto Expr = I->getInit()) {

2380 D = I;

2381 return Expr;

2382 }

2383 }

2384 return nullptr;

2385}

2386

2388 if (auto *P = dyn_cast(this))

2389 if (P->hasUnparsedDefaultArg() || P->hasUninstantiatedDefaultArg())

2390 return false;

2391

2393 return Eval->Value.isValid();

2394

2395 return Init.isNull();

2396}

2397

2400 return nullptr;

2401

2402 if (auto *S = dyn_cast<Stmt *>(Init))

2403 return cast(S);

2404

2406

2407 return cast(Eval->Value.get(

2408 Eval->Value.isOffset() ? getASTContext().getExternalSource() : nullptr));

2409}

2410

2413 return ES->Value.getAddressOfPointer(getASTContext().getExternalSource());

2414

2415 return Init.getAddrOfPtr1();

2416}

2417

2420 for (auto *I : redecls()) {

2421 if (I->hasInit())

2422 return I;

2423

2424 if (I->isThisDeclarationADefinition()) {

2426 return I;

2427 Def = I;

2428 }

2429 }

2430 return Def;

2431}

2432

2435 return true;

2436

2438 return false;

2439

2440

2441

2442

2445

2446 return false;

2447}

2448

2451 Eval->~EvaluatedStmt();

2453 }

2454

2456}

2457

2460

2461

2462

2463 if (!Lang.CPlusPlus && !Lang.OpenCL && !Lang.C23)

2464 return false;

2465

2466

2467 if (isa(this))

2468 return false;

2469

2470

2472 return false;

2473

2474

2475

2476 if (Lang.CPlusPlus11 && getType()->isReferenceType())

2477 return true;

2478

2479

2480

2481

2482 if (getType().isConstant(C) || getType().isVolatileQualified())

2483 return false;

2484

2485

2486

2487 if (getType()->isIntegralOrEnumerationType() && !Lang.C23)

2488 return true;

2489

2490

2491

2492

2493

2494

2495

2496

2497 return (Lang.CPlusPlus11 || Lang.C23) && isConstexpr();

2498}

2499

2501

2502

2503

2504 const VarDecl *DefVD = nullptr;

2506 if (Init || Init->isValueDependent() || getType()->isDependentType())

2507 return false;

2508

2509

2511 return false;

2512

2515 return false;

2516

2517

2518

2519

2522 return false;

2523 return true;

2524}

2525

2526

2527

2528

2531 if (!Eval) {

2532

2533

2534

2535

2537 Eval->Value = cast<Stmt *>(Init);

2538 Init = Eval;

2539 }

2540 return Eval;

2541}

2542

2545}

2546

2550}

2551

2553 bool IsConstantInitialization) const {

2555

2557 assert(Init->isValueDependent());

2558

2559

2560

2561

2564

2566

2567 return nullptr;

2568 }

2569

2571

2573 bool Result = Init->EvaluateAsInitializer(Eval->Evaluated, Ctx, this, Notes,

2574 IsConstantInitialization);

2575

2576

2577

2578

2579

2580 if (IsConstantInitialization &&

2583 !Notes.empty())

2585

2586

2587

2588

2593

2596

2598}

2599

2604

2605 return nullptr;

2606}

2607

2610 assert(Init && "no initializer");

2611

2615 Eval->HasICEInit = Init->isIntegerConstantExpr(Context);

2616 }

2618}

2619

2621

2622

2623

2626 return true;

2627

2628

2629

2632

2633 return false;

2634}

2635

2639

2640

2641

2643 "already evaluated var value before checking for constant init");

2646 "only meaningful in C++/C23");

2647

2648 assert(getInit()->isValueDependent());

2649

2650

2652 evaluateValueImpl(Notes, true) && Notes.empty();

2653

2654

2655

2658

2660}

2661

2663 return isa(getType());

2664}

2665

2666template

2668 assert(D);

2669 if (auto *Def = D->getDefinition())

2670 return Def;

2671 return D;

2672}

2673

2676}

2677

2680}

2681

2685 llvm::any_of(specific_attrs(), [](const AlignedAttr *AA) {

2686 return AA->isAlignmentDependent();

2687 });

2688}

2689

2691 const VarDecl *VD = this;

2692

2693

2694

2699 VD = NewVD;

2700 }

2701 }

2702

2703

2704

2705 if (auto *VDTemplSpec = dyn_cast(VD)) {

2707 auto From = VDTemplSpec->getInstantiatedFrom();

2709 while (!VTD->isMemberSpecialization()) {

2710 auto *NewVTD = VTD->getInstantiatedFromMemberTemplate();

2711 if (!NewVTD)

2712 break;

2713 VTD = NewVTD;

2714 }

2716 }

2717 if (auto *VTPSD =

2719 while (!VTPSD->isMemberSpecialization()) {

2720 auto *NewVTPSD = VTPSD->getInstantiatedFromMember();

2721 if (!NewVTPSD)

2722 break;

2723 VTPSD = NewVTPSD;

2724 }

2725 return getDefinitionOrSelf(VTPSD);

2726 }

2727 }

2728 }

2729

2730

2731

2733 while (!VarTemplate->isMemberSpecialization()) {

2734 auto *NewVT = VarTemplate->getInstantiatedFromMemberTemplate();

2735 if (!NewVT)

2736 break;

2737 VarTemplate = NewVT;

2738 }

2739

2741 }

2742

2743 if (VD == this)

2744 return nullptr;

2746}

2747

2750 return cast(MSI->getInstantiatedFrom());

2751

2752 return nullptr;

2753}

2754

2756 if (const auto *Spec = dyn_cast(this))

2757 return Spec->getSpecializationKind();

2758

2760 return MSI->getTemplateSpecializationKind();

2761

2763}

2764

2768 return MSI->getTemplateSpecializationKind();

2769

2770 if (const auto *Spec = dyn_cast(this))

2771 return Spec->getSpecializationKind();

2772

2774}

2775

2777 if (const auto *Spec = dyn_cast(this))

2778 return Spec->getPointOfInstantiation();

2779

2781 return MSI->getPointOfInstantiation();

2782

2784}

2785

2789}

2790

2793}

2794

2797

2798

2799

2800

2801

2802

2803

2804 if (LangOpts.CUDA && !LangOpts.GPURelocatableDeviceCode &&

2806 isa(getType()))

2807 return true;

2808

2810}

2811

2814 return false;

2815 if (hasAttr())

2816 return true;

2817 if (hasAttr())

2818 return false;

2819

2821 RSDKind K = Ctx.getLangOpts().getRegisterStaticDestructors();

2822 return K == RSDKind::None ||

2824}

2825

2831

2834

2836}

2837

2839 assert(hasInit() && "Expect initializer to check for flexible array init");

2841 if (!Ty || !Ty->getDecl()->hasFlexibleArrayMember())

2842 return false;

2843 auto *List = dyn_cast(getInit()->IgnoreParens());

2844 if (!List)

2845 return false;

2846 const Expr *FlexibleInit = List->getInit(List->getNumInits() - 1);

2848 if (!InitTy)

2849 return false;

2851}

2852

2854 assert(hasInit() && "Expect initializer to check for flexible array init");

2856 if (!Ty || !Ty->getDecl()->hasFlexibleArrayMember())

2858 auto *List = dyn_cast(getInit()->IgnoreParens());

2859 if (!List || List->getNumInits() == 0)

2861 const Expr *FlexibleInit = List->getInit(List->getNumInits() - 1);

2863 if (!InitTy)

2869 if (FlexibleArrayOffset + FlexibleArraySize < RL.getSize())

2871 return FlexibleArrayOffset + FlexibleArraySize - RL.getSize();

2872}

2873

2876

2877

2880 return nullptr;

2881}

2882

2885 assert((isa(this) ||

2887 "not a variable or static data member template specialization");

2888

2890 dyn_cast(this)) {

2891 Spec->setSpecializationKind(TSK);

2893 PointOfInstantiation.isValid() &&

2894 Spec->getPointOfInstantiation().isInvalid()) {

2895 Spec->setPointOfInstantiation(PointOfInstantiation);

2897 L->InstantiationRequested(this);

2898 }

2900 MSI->setTemplateSpecializationKind(TSK);

2902 MSI->getPointOfInstantiation().isInvalid()) {

2903 MSI->setPointOfInstantiation(PointOfInstantiation);

2905 L->InstantiationRequested(this);

2906 }

2907 }

2908}

2909

2910void

2913 assert(getASTContext().getTemplateOrSpecializationInfo(this).isNull() &&

2914 "Previous template or instantiation?");

2916}

2917

2918

2919

2920

2921

2926 Expr *DefArg) {

2927 return new (C, DC) ParmVarDecl(ParmVar, C, DC, StartLoc, IdLoc, Id, T, TInfo,

2928 S, DefArg);

2929}

2930

2934 if (const auto *DT = dyn_cast(T))

2935 return DT->getOriginalType();

2936 return T;

2937}

2938

2940 return new (C, ID)

2943}

2944

2950 }

2951

2952

2953

2956

2958}

2959

2961

2962 if (hasAttr())

2964

2965

2966

2968 if (RT && RT->getDecl()->isParamDestroyedInCallee() &&

2970 return true;

2971

2972 return false;

2973}

2974

2978 "Default argument is not yet instantiated!");

2979

2981 if (auto *E = dyn_cast_if_present(Arg))

2982 return E->getSubExpr();

2983

2984 return Arg;

2985}

2986

2989 Init = defarg;

2990}

2991

2996

2998

3001

3005

3006

3008 }

3009 llvm_unreachable("Invalid default argument kind.");

3010}

3011

3015}

3016

3019 "Wrong kind of initialization expression!");

3020 return cast_if_present(cast<Stmt *>(Init));

3021}

3022

3024

3025

3026

3028 Init.isNull();

3029}

3030

3031void ParmVarDecl::setParameterIndexLarge(unsigned parameterIndex) {

3033 ParmVarDeclBits.ParameterIndex = ParameterIndexSentinel;

3034}

3035

3036unsigned ParmVarDecl::getParameterIndexLarge() const {

3038}

3039

3040

3041

3042

3043

3048 bool UsesFPIntrin, bool isInlineSpecified,

3050 Expr *TrailingRequiresClause)

3052 StartLoc),

3054 EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) {

3072 FunctionDeclBits.ConstexprKind = static_cast<uint64_t>(ConstexprKind);

3073 FunctionDeclBits.BodyContainsImmediateEscalatingExpression = false;

3083 FunctionDeclBits.FriendConstraintRefersToEnclosingTemplate = false;

3084 if (TrailingRequiresClause)

3086}

3087

3092 if (TemplateArgs)

3094}

3095

3097 if (const auto *FT = getType()->getAs())

3098 return FT->isVariadic();

3099 return false;

3100}

3101

3106 static constexpr size_t Alignment =

3109 size_t Size = totalSizeToAlloc<DeclAccessPair, StringLiteral *>(

3110 Lookups.size(), DeletedMessage != nullptr);

3111

3114 Info->NumLookups = Lookups.size();

3115 Info->HasDeletedMessage = DeletedMessage != nullptr;

3116

3117 std::uninitialized_copy(Lookups.begin(), Lookups.end(),

3119 if (DeletedMessage)

3120 *Info->getTrailingObjects<StringLiteral *>() = DeletedMessage;

3121 return Info;

3122}

3123

3126 assert(FunctionDeclBits.HasDefaultedOrDeletedInfo && "already have this");

3127 assert(Body && "can't replace function body with defaulted function info");

3128

3131}

3132

3135

3136 if (Message) {

3140 else

3143 }

3144}

3145

3148

3149

3150

3151

3152 assert(HasDeletedMessage &&

3153 "No space to store a delete message in this DefaultedOrDeletedInfo");

3154 *getTrailingObjects<StringLiteral *>() = Message;

3155}

3156

3160 : nullptr;

3161}

3162

3164 for (const auto *I : redecls()) {

3165 if (I->doesThisDeclarationHaveABody()) {

3167 return true;

3168 }

3169 }

3170

3171 return false;

3172}

3173

3176 if (!S) {

3177

3178

3179 return false;

3180 }

3181

3182 if (isa(S) && cast(S)->body_empty())

3183 return true;

3184 return false;

3185}

3186

3189 return false;

3190

3191

3192

3195 return InstantiatedFrom->getFriendObjectKind() &&

3196 InstantiatedFrom->isThisDeclarationADefinition();

3197

3198

3199

3203 return InstantiatedFrom->getFriendObjectKind() &&

3204 InstantiatedFrom->isThisDeclarationADefinition();

3205 }

3206

3207 return false;

3208}

3209

3211 bool CheckForPendingFriendDefinition) const {

3213 if (FD->isThisDeclarationADefinition()) {

3215 return true;

3216 }

3217

3218

3219

3220

3221

3222

3223

3224

3225

3226

3227

3228

3229

3230

3231

3232

3233 if (CheckForPendingFriendDefinition &&

3234 FD->isThisDeclarationInstantiatedFromAFriendDefinition()) {

3236 return true;

3237 }

3238 }

3239

3240 return false;

3241}

3242

3245 return nullptr;

3246

3247 assert(Definition->FunctionDeclBits.HasDefaultedOrDeletedInfo &&

3248 "definition should not have a body");

3251

3252 return nullptr;

3253}

3254

3258 if (B)

3260}

3261

3264 if (P)

3266 Parent->markedVirtualFunctionPure();

3267}

3268

3269template<std::size_t Len>

3272 return II && II->isStr(Str);

3273}

3274

3276

3277

3278

3279

3281 return true;

3282

3283

3285 return true;

3286

3287 if (auto *CD = dyn_cast(this);

3288 CD && CD->isInheritingConstructor())

3289 return CD->getInheritedConstructor().getConstructor();

3290

3291

3292

3296 return true;

3297 return false;

3298}

3299

3301

3302

3303

3305 return true;

3306

3307

3309 return true;

3310

3311 if (auto *CD = dyn_cast(this);

3312 CD && CD->isInheritingConstructor())

3313 return CD->getInheritedConstructor()

3314 .getConstructor()

3315 ->isImmediateFunction();

3316

3317 if (const auto *MD = dyn_cast(this);

3318 MD && MD->isLambdaStaticInvoker())

3319 return MD->getParent()->getLambdaCallOperator()->isImmediateFunction();

3320

3321 return false;

3322}

3323

3329}

3330

3334 if (!TUnit)

3335 return false;

3336

3337

3338

3339

3340

3342 return false;

3343

3344

3346 return false;

3347

3348 return llvm::StringSwitch(getName())

3349 .Cases("main",

3350 "wmain",

3351 "WinMain",

3352 "wWinMain",

3353 "DllMain",

3354 true)

3355 .Default(false);

3356}

3357

3360 return false;

3361 if (getDeclName().getCXXOverloadedOperator() != OO_New &&

3362 getDeclName().getCXXOverloadedOperator() != OO_Delete &&

3363 getDeclName().getCXXOverloadedOperator() != OO_Array_New &&

3364 getDeclName().getCXXOverloadedOperator() != OO_Array_Delete)

3365 return false;

3366

3368 return false;

3369

3371 if (proto->getNumParams() != 2 || proto->isVariadic())

3372 return false;

3373

3376 ->getASTContext();

3377

3378

3379

3380 return (proto->getParamType(1).getCanonicalType() == Context.VoidPtrTy);

3381}

3382

3384 std::optional *AlignmentParam, bool *IsNothrow) const {

3386 return false;

3387 if (getDeclName().getCXXOverloadedOperator() != OO_New &&

3388 getDeclName().getCXXOverloadedOperator() != OO_Delete &&

3389 getDeclName().getCXXOverloadedOperator() != OO_Array_New &&

3390 getDeclName().getCXXOverloadedOperator() != OO_Array_Delete)

3391 return false;

3392

3394 return false;

3395

3396

3398 return false;

3399

3401 if (FPT->getNumParams() == 0 || FPT->getNumParams() > 4 || FPT->isVariadic())

3402 return false;

3403

3404

3405

3406 if (FPT->getNumParams() == 1)

3407 return true;

3408

3409 unsigned Params = 1;

3410 QualType Ty = FPT->getParamType(Params);

3412

3413 auto Consume = [&] {

3414 ++Params;

3415 Ty = Params < FPT->getNumParams() ? FPT->getParamType(Params) : QualType();

3416 };

3417

3418

3419 bool IsSizedDelete = false;

3420 if (Ctx.getLangOpts().SizedDeallocation &&

3421 (getDeclName().getCXXOverloadedOperator() == OO_Delete ||

3422 getDeclName().getCXXOverloadedOperator() == OO_Array_Delete) &&

3424 IsSizedDelete = true;

3425 Consume();

3426 }

3427

3428

3429

3431 Consume();

3432 if (AlignmentParam)

3433 *AlignmentParam = Params;

3434 }

3435

3436

3437

3441 return false;

3443 if (IsNothrow)

3444 *IsNothrow = true;

3445 Consume();

3446 }

3447 }

3448

3449

3450

3451

3452

3456 T = TD->getDecl()->getUnderlyingType();

3459 if (II && II->isStr("__hot_cold_t"))

3460 Consume();

3461 }

3462

3463 return Params == FPT->getNumParams();

3464}

3465

3468 return false;

3469

3472 return false;

3473

3474 if (Definition->isInlineSpecified() ||

3475 Definition->hasAttr())

3476 return false;

3477

3483 return false;

3486 return true;

3487 }

3488 llvm_unreachable("Unknown GVALinkage");

3489}

3490

3492

3493

3494

3495

3498 return false;

3499

3501 return RD && RD->isInStdNamespace() && RD->getIdentifier() &&

3502 RD->getIdentifier()->isStr("destroying_delete_t");

3503}

3504

3507}

3508

3511}

3512

3514 if (hasAttr())

3515 return true;

3517}

3518

3521}

3522

3524 if (const auto *Method = dyn_cast(this))

3525 return Method->isStatic();

3526

3528 return false;

3529

3533 if (const auto *Namespace = cast(DC)) {

3534 if (!Namespace->getDeclName())

3535 return false;

3536 }

3537 }

3538

3539 return true;

3540}

3541

3543 if (hasAttr() || hasAttr() ||

3544 hasAttr())

3545 return true;

3546

3547 if (auto *FnTy = getType()->getAs())

3548 return FnTy->getNoReturnAttr();

3549

3550 return false;

3551}

3552

3554

3555

3556

3557

3558

3559

3560

3562 return false;

3563 }

3564

3566

3567

3568

3570 }

3571

3573}

3574

3576 if (hasAttr())

3578 if (hasAttr())

3580 if (hasAttr())

3582 if (hasAttr())

3584 if (hasAttr())

3587}

3588

3590 return isMultiVersion() && hasAttr();

3591}

3592

3594 return isMultiVersion() && hasAttr();

3595}

3596

3599 (hasAttr() || hasAttr());

3600}

3601

3604 return false;

3605 if (hasAttr())

3606 return getAttr()->isDefaultVersion();

3607 return hasAttr() &&

3608 getAttr()->isDefaultVersion();

3609}

3610

3612 return isMultiVersion() && hasAttr();

3613}

3614

3616 return isMultiVersion() && hasAttr();

3617}

3618

3619void

3622

3626 assert((!PrevDecl || PrevFunTmpl) && "Function/function template mismatch");

3627 FunTmpl->setPreviousDecl(PrevFunTmpl);

3628 }

3629

3630 if (PrevDecl && PrevDecl->isInlined())

3632}

3633

3635

3636

3637

3638

3639

3640

3641

3642

3643

3644

3645

3646

3647

3648

3650 unsigned BuiltinID = 0;

3651

3652 if (const auto *ABAA = getAttr()) {

3653 BuiltinID = ABAA->getBuiltinName()->getBuiltinID();

3654 } else if (const auto *BAA = getAttr()) {

3655 BuiltinID = BAA->getBuiltinName()->getBuiltinID();

3656 } else if (const auto *A = getAttr()) {

3657 BuiltinID = A->getID();

3658 }

3659

3660 if (!BuiltinID)

3661 return 0;

3662

3663

3664

3665 if (!ConsiderWrapperFunctions && hasAttr() &&

3666 (!hasAttr() && !hasAttr()))

3667 return 0;

3668

3670 BuiltinID == Builtin::BI__builtin_counted_by_ref)

3671 return 0;

3672

3675 return BuiltinID;

3676

3677

3678

3679

3680

3681

3683 return 0;

3684

3685

3686

3689 return 0;

3690

3691

3692

3693 if (Context.getLangOpts().CUDA && hasAttr() &&

3694 !hasAttr() &&

3695 !(BuiltinID == Builtin::BIprintf || BuiltinID == Builtin::BImalloc))

3696 return 0;

3697

3698

3699

3700

3702 Context.getLangOpts().OpenMPIsTargetDevice &&

3704 !(BuiltinID == Builtin::BIprintf || BuiltinID == Builtin::BImalloc))

3705 return 0;

3706

3707 return BuiltinID;

3708}

3709

3710

3711

3712

3716}

3717

3718void FunctionDecl::setParams(ASTContext &C,

3720 assert(!ParamInfo && "Already has param info!");

3721 assert(NewParamInfo.size() == getNumParams() && "Parameter count mismatch!");

3722

3723

3724 if (!NewParamInfo.empty()) {

3725 ParamInfo = new (C) ParmVarDecl*[NewParamInfo.size()];

3726 std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);

3727 }

3728}

3729

3730

3731

3732

3733

3737

3738

3739

3740 unsigned NumRequiredArgs = 0;

3741 unsigned MinParamsSoFar = 0;

3743 if (!Param->isParameterPack()) {

3744 ++MinParamsSoFar;

3745 if (!Param->hasDefaultArg())

3746 NumRequiredArgs = MinParamsSoFar;

3747 }

3748 }

3749 return NumRequiredArgs;

3750}

3751

3754}

3755

3759}

3760

3764}

3765

3769 llvm::all_of(llvm::drop_begin(parameters()),

3770 [](ParmVarDecl *P) { return P->hasDefaultArg(); }));

3771}

3772

3773

3774

3775

3776

3777

3779 assert(isInlined() && "expected to get called on an inlined function!");

3780

3783 !hasAttr())

3784 return false;

3785

3788 if (!FD->isImplicit() && FD->getStorageClass() == SC_Extern)

3789 return true;

3790

3791 return false;

3792}

3793

3796 return false;

3797

3800 if (!FD->isImplicit() && FD->getStorageClass() == SC_Extern)

3801 return false;

3802

3803 return true;

3804}

3805

3807

3809 return false;

3810

3811

3812

3814 return false;

3815

3817 return true;

3818

3819 return false;

3820}

3821

3822

3823

3824

3825

3826

3827

3830 "Must have a declaration without a body.");

3831

3833

3838 return true;

3839 }

3840

3842 return false;

3843

3844 if (Context.getLangOpts().GNUInline || hasAttr()) {

3845

3846

3847

3848

3849

3851 return false;

3852

3854 bool FoundBody = false;

3857

3859

3860

3863 return false;

3866 return false;

3867 }

3868 }

3869 return FoundBody;

3870 }

3871

3872

3873

3874

3875

3877 return false;

3879 bool FoundBody = false;

3883 return false;

3884 }

3885 return FoundBody;

3886}

3887

3892}

3893

3896 if (!FTL)

3898

3899

3904 SM.isBeforeInTranslationUnit(RTRange.getEnd(), Boundary))

3906

3907 return RTRange;

3908}

3909

3913

3914 if (NP == 0 && EllipsisLoc.isInvalid())

3916

3920 ? EllipsisLoc

3922

3924}

3925

3929}

3930

3931

3932

3933

3934

3935

3936

3937

3938

3939

3940

3941

3942

3943

3944

3945

3946

3947

3950 hasAttr()) &&

3951 "Must be a function definition");

3952 assert(isInlined() && "Function must be inline");

3954

3955 if (Context.getLangOpts().GNUInline || hasAttr()) {

3956

3957

3958

3959

3960

3961

3963 return false;

3965 return true;

3966

3967

3968

3969 for (auto *Redecl : redecls()) {

3970 if (Redecl->isInlineSpecified() &&

3971 Redecl->getStorageClass() != SC_Extern)

3972 return true;

3973 }

3974

3975 return false;

3976 }

3977

3978

3979 assert(!Context.getLangOpts().CPlusPlus &&

3980 "should not use C inline rules in C++");

3981

3982

3983

3984

3985

3986 for (auto *Redecl : redecls()) {

3988 return true;

3989 }

3990

3991

3992

3993

3994

3995 return false;

3996}

3997

3998

3999

4004}

4005

4006

4007

4011 return nullptr;

4012}

4013

4015 if (TemplateOrSpecialization.isNull())

4017 if (const auto *ND = dyn_cast<NamedDecl *>(TemplateOrSpecialization)) {

4018 if (isa(ND))

4020 assert(isa(ND) &&

4021 "No other valid types in NamedDecl");

4023 }

4024 if (isa<MemberSpecializationInfo *>(TemplateOrSpecialization))

4026 if (isa<FunctionTemplateSpecializationInfo *>(TemplateOrSpecialization))

4028 if (isa<DependentFunctionTemplateSpecializationInfo *>(

4029 TemplateOrSpecialization))

4031

4032 llvm_unreachable("Did we miss a TemplateOrSpecialization type?");

4033}

4034

4037 return cast(Info->getInstantiatedFrom());

4038

4039 return nullptr;

4040}

4041

4043 if (auto *MSI =

4045 return MSI;

4046 if (auto *FTSI = TemplateOrSpecialization

4047 .dyn_cast<FunctionTemplateSpecializationInfo *>())

4048 return FTSI->getMemberSpecializationInfo();

4049 return nullptr;

4050}

4051

4052void

4053FunctionDecl::setInstantiationOfMemberFunction(ASTContext &C,

4056 assert(TemplateOrSpecialization.isNull() &&

4057 "Member function is already a specialization");

4060 TemplateOrSpecialization = Info;

4061}

4062

4064 return dyn_cast_if_present(

4065 TemplateOrSpecialization.dyn_cast<NamedDecl *>());

4066}

4067

4070 assert(TemplateOrSpecialization.isNull() &&

4071 "Member function is already a specialization");

4072 TemplateOrSpecialization = Template;

4073}

4074

4076 return isa<FunctionTemplateSpecializationInfo *>(TemplateOrSpecialization) ||

4077 isa<DependentFunctionTemplateSpecializationInfo *>(

4078 TemplateOrSpecialization);

4079}

4080

4082 assert(TemplateOrSpecialization.isNull() &&

4083 "Function is already a specialization");

4084 TemplateOrSpecialization = FD;

4085}

4086

4088 return dyn_cast_if_present(

4089 TemplateOrSpecialization.dyn_cast<NamedDecl *>());

4090}

4091

4093

4095 return false;

4096

4101 return false;

4102

4104 return true;

4105

4107

4108 break;

4109 }

4110

4111

4113 bool HasPattern = false;

4114 if (PatternDecl)

4115 HasPattern = PatternDecl->hasBody(PatternDecl);

4116

4117

4118

4119

4120

4121 if (!HasPattern || !PatternDecl)

4122 return true;

4123

4124 return PatternDecl->isInlined();

4125}

4126

4128

4129

4131}

4132

4135

4136

4137

4138

4139

4140

4141

4142

4143

4145 dyn_cast(this))) {

4146 assert(getPrimaryTemplate() && "not a generic lambda call operator?");

4148 }

4149

4150

4151

4153 if (isDefined(FD, true))

4154 FD = this;

4155

4157 if (ForDefinition &&

4159 return nullptr;

4161 }

4162

4163 if (ForDefinition &&

4165 return nullptr;

4166

4168

4169

4170 while (!ForDefinition || !Primary->isMemberSpecialization()) {

4171 auto *NewPrimary = Primary->getInstantiatedFromMemberTemplate();

4172 if (!NewPrimary)

4173 break;

4174 Primary = NewPrimary;

4175 }

4176

4178 }

4179

4180 return nullptr;

4181}

4182

4185 = TemplateOrSpecialization

4186 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {

4187 return Info->getTemplate();

4188 }

4189 return nullptr;

4190}

4191

4194 return TemplateOrSpecialization

4196}

4197

4201 = TemplateOrSpecialization

4202 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {

4203 return Info->TemplateArguments;

4204 }

4205 return nullptr;

4206}

4207

4211 = TemplateOrSpecialization

4212 .dyn_cast<FunctionTemplateSpecializationInfo*>()) {

4213 return Info->TemplateArgumentsAsWritten;

4214 }

4216 TemplateOrSpecialization

4217 .dyn_cast<DependentFunctionTemplateSpecializationInfo *>()) {

4218 return Info->TemplateArgumentsAsWritten;

4219 }

4220 return nullptr;

4221}

4222

4223void FunctionDecl::setFunctionTemplateSpecialization(

4229 assert((TemplateOrSpecialization.isNull() ||

4230 isa<MemberSpecializationInfo *>(TemplateOrSpecialization)) &&

4231 "Member function is already a specialization");

4233 "Must specify the type of function template specialization");

4234 assert((TemplateOrSpecialization.isNull() ||

4237 "Member specialization must be an explicit specialization");

4240 C, this, Template, TSK, TemplateArgs, TemplateArgsAsWritten,

4241 PointOfInstantiation,

4243 TemplateOrSpecialization = Info;

4245}

4246

4250 assert(TemplateOrSpecialization.isNull());

4253 TemplateArgs);

4254 TemplateOrSpecialization = Info;

4255}

4256

4259 return TemplateOrSpecialization

4261}

4262

4267 const auto *TArgsWritten =

4269 return new (Context.Allocate(

4270 totalSizeToAlloc<FunctionTemplateDecl *>(Candidates.size())))

4272}

4273

4274DependentFunctionTemplateSpecializationInfo::

4275 DependentFunctionTemplateSpecializationInfo(

4278 : NumCandidates(Candidates.size()),

4279 TemplateArgumentsAsWritten(TemplateArgsWritten) {

4280 std::transform(Candidates.begin(), Candidates.end(),

4281 getTrailingObjects<FunctionTemplateDecl *>(),

4283 return cast(ND->getUnderlyingDecl());

4284 });

4285}

4286

4288

4289

4291 TemplateOrSpecialization

4292 .dyn_cast<FunctionTemplateSpecializationInfo *>())

4293 return FTSInfo->getTemplateSpecializationKind();

4294

4297 return MSInfo->getTemplateSpecializationKind();

4298

4299

4300

4301 if (isa<DependentFunctionTemplateSpecializationInfo *>(

4302 TemplateOrSpecialization) &&

4305

4307}

4308

4311

4312

4313

4314

4315

4316

4317

4318

4319

4320

4321

4322

4323

4324

4325

4326

4327

4328

4329

4330

4331

4332

4334 TemplateOrSpecialization

4335 .dyn_cast<FunctionTemplateSpecializationInfo *>()) {

4336 if (auto *MSInfo = FTSInfo->getMemberSpecializationInfo())

4337 return MSInfo->getTemplateSpecializationKind();

4338 return FTSInfo->getTemplateSpecializationKind();

4339 }

4340

4343 return MSInfo->getTemplateSpecializationKind();

4344

4345 if (isa<DependentFunctionTemplateSpecializationInfo *>(

4346 TemplateOrSpecialization) &&

4349

4351}

4352

4353void

4357 = TemplateOrSpecialization.dyn_cast<

4359 FTSInfo->setTemplateSpecializationKind(TSK);

4361 PointOfInstantiation.isValid() &&

4362 FTSInfo->getPointOfInstantiation().isInvalid()) {

4363 FTSInfo->setPointOfInstantiation(PointOfInstantiation);

4365 L->InstantiationRequested(this);

4366 }

4369 MSInfo->setTemplateSpecializationKind(TSK);

4371 PointOfInstantiation.isValid() &&

4372 MSInfo->getPointOfInstantiation().isInvalid()) {

4373 MSInfo->setPointOfInstantiation(PointOfInstantiation);

4375 L->InstantiationRequested(this);

4376 }

4377 } else

4378 llvm_unreachable("Function cannot have a template specialization kind");

4379}

4380

4383 = TemplateOrSpecialization.dyn_cast<

4385 return FTSInfo->getPointOfInstantiation();

4388 return MSInfo->getPointOfInstantiation();

4389

4391}

4392

4395 return true;

4396

4397

4398

4403 }

4404

4405

4406

4409 if (FunTmpl->getTemplatedDecl()->hasBody(Definition))

4411 }

4412

4413 return false;

4414}

4415

4418}

4419

4422

4423 if (!FnInfo)

4424 return 0;

4425

4426

4428 case Builtin::BI__builtin_memset:

4429 case Builtin::BI__builtin___memset_chk:

4430 case Builtin::BImemset:

4431 return Builtin::BImemset;

4432

4433 case Builtin::BI__builtin_memcpy:

4434 case Builtin::BI__builtin___memcpy_chk:

4435 case Builtin::BImemcpy:

4436 return Builtin::BImemcpy;

4437

4438 case Builtin::BI__builtin_mempcpy:

4439 case Builtin::BI__builtin___mempcpy_chk:

4440 case Builtin::BImempcpy:

4441 return Builtin::BImempcpy;

4442

4443 case Builtin::BI__builtin_memmove:

4444 case Builtin::BI__builtin___memmove_chk:

4445 case Builtin::BImemmove:

4446 return Builtin::BImemmove;

4447

4448 case Builtin::BIstrlcpy:

4449 case Builtin::BI__builtin___strlcpy_chk:

4450 return Builtin::BIstrlcpy;

4451

4452 case Builtin::BIstrlcat:

4453 case Builtin::BI__builtin___strlcat_chk:

4454 return Builtin::BIstrlcat;

4455

4456 case Builtin::BI__builtin_memcmp:

4457 case Builtin::BImemcmp:

4458 return Builtin::BImemcmp;

4459

4460 case Builtin::BI__builtin_bcmp:

4461 case Builtin::BIbcmp:

4462 return Builtin::BIbcmp;

4463

4464 case Builtin::BI__builtin_strncpy:

4465 case Builtin::BI__builtin___strncpy_chk:

4466 case Builtin::BIstrncpy:

4467 return Builtin::BIstrncpy;

4468

4469 case Builtin::BI__builtin_strncmp:

4470 case Builtin::BIstrncmp:

4471 return Builtin::BIstrncmp;

4472

4473 case Builtin::BI__builtin_strncasecmp:

4474 case Builtin::BIstrncasecmp:

4475 return Builtin::BIstrncasecmp;

4476

4477 case Builtin::BI__builtin_strncat:

4478 case Builtin::BI__builtin___strncat_chk:

4479 case Builtin::BIstrncat:

4480 return Builtin::BIstrncat;

4481

4482 case Builtin::BI__builtin_strndup:

4483 case Builtin::BIstrndup:

4484 return Builtin::BIstrndup;

4485

4486 case Builtin::BI__builtin_strlen:

4487 case Builtin::BIstrlen:

4488 return Builtin::BIstrlen;

4489

4490 case Builtin::BI__builtin_bzero:

4491 case Builtin::BIbzero:

4492 return Builtin::BIbzero;

4493

4494 case Builtin::BI__builtin_bcopy:

4495 case Builtin::BIbcopy:

4496 return Builtin::BIbcopy;

4497

4498 case Builtin::BIfree:

4499 return Builtin::BIfree;

4500

4501 default:

4503 if (FnInfo->isStr("memset"))

4504 return Builtin::BImemset;

4505 if (FnInfo->isStr("memcpy"))

4506 return Builtin::BImemcpy;

4507 if (FnInfo->isStr("mempcpy"))

4508 return Builtin::BImempcpy;

4509 if (FnInfo->isStr("memmove"))

4510 return Builtin::BImemmove;

4511 if (FnInfo->isStr("memcmp"))

4512 return Builtin::BImemcmp;

4513 if (FnInfo->isStr("bcmp"))

4514 return Builtin::BIbcmp;

4515 if (FnInfo->isStr("strncpy"))

4516 return Builtin::BIstrncpy;

4517 if (FnInfo->isStr("strncmp"))

4518 return Builtin::BIstrncmp;

4519 if (FnInfo->isStr("strncasecmp"))

4520 return Builtin::BIstrncasecmp;

4521 if (FnInfo->isStr("strncat"))

4522 return Builtin::BIstrncat;

4523 if (FnInfo->isStr("strndup"))

4524 return Builtin::BIstrndup;

4525 if (FnInfo->isStr("strlen"))

4526 return Builtin::BIstrlen;

4527 if (FnInfo->isStr("bzero"))

4528 return Builtin::BIbzero;

4529 if (FnInfo->isStr("bcopy"))

4530 return Builtin::BIbcopy;

4532 if (FnInfo->isStr("free"))

4533 return Builtin::BIfree;

4534 }

4535 break;

4536 }

4537 return 0;

4538}

4539

4541 assert(hasODRHash());

4543}

4544

4546 if (hasODRHash())

4548

4550 setHasODRHash(true);

4551 ODRHash = FT->getODRHash();

4553 }

4554

4557 setHasODRHash(true);

4560}

4561

4562

4563

4564

4565

4571 return new (C, DC) FieldDecl(Decl::Field, DC, StartLoc, IdLoc, Id, T, TInfo,

4572 BW, Mutable, InitStyle);

4573}

4574

4579}

4580

4583 return false;

4584

4585 if (const auto *Record = getType()->getAs())

4586 return Record->getDecl()->isAnonymousStructOrUnion();

4587

4588 return false;

4589}

4590

4593 return nullptr;

4594

4596 return cast_if_present(

4598 : InitPtr.get(nullptr));

4599}

4600

4603}

4604

4605void FieldDecl::setLazyInClassInitializer(LazyDeclStmtPtr NewInit) {

4607 if (BitField)

4609 else

4610 Init = NewInit;

4611}

4612

4614 assert(isBitField() && "not a bitfield");

4615 assert(isa(getBitWidth()));

4616 assert(cast(getBitWidth())->hasAPValueResult());

4617 assert(cast(getBitWidth())->getAPValueResult().isInt());

4618 return cast(getBitWidth())

4619 ->getAPValueResult()

4620 .getInt()

4621 .getZExtValue();

4622}

4623

4627}

4628

4631 return true;

4632

4633

4634

4635

4636 if (!hasAttr())

4637 return false;

4638

4639

4641 if (!RT)

4642 return false;

4644 if (!RD) {

4645 assert(isInvalidDecl() && "valid field has incomplete type");

4646 return false;

4647 }

4648

4649

4650

4651 const auto *CXXRD = cast(RD);

4652 if (!CXXRD->isEmpty())

4653 return false;

4654

4655

4656

4658 return true;

4659

4660

4661

4662 return !llvm::any_of(CXXRD->fields(), [](const FieldDecl *Field) {

4663 return Field->getType()->getAs();

4664 });

4665}

4666

4669}

4670

4671void FieldDecl::setCachedFieldIndex() const {

4673 "should be called on the canonical decl");

4674

4675 unsigned Index = 0;

4677 assert(RD && "requested index for field of struct with no definition");

4678

4679 for (auto *Field : RD->fields()) {

4680 Field->getCanonicalDecl()->CachedFieldIndex = Index + 1;

4681 assert(Field->getCanonicalDecl()->CachedFieldIndex == Index + 1 &&

4682 "overflow in field numbering");

4683 ++Index;

4684 }

4685

4686 assert(CachedFieldIndex && "failed to find field in parent");

4687}

4688

4691 if (!FinalExpr)

4693 if (FinalExpr)

4696}

4697

4699 assert((getParent()->isLambda() || getParent()->isCapturedRecord()) &&

4700 "capturing type in non-lambda or captured record.");

4701 assert(StorageKind == ISK_NoInit && !BitField &&

4702 "bit-field or field with default member initializer cannot capture "

4703 "VLA type");

4704 StorageKind = ISK_CapturedVLAType;

4706}

4707

4709

4712 return;

4713 }

4714

4716}

4717

4720 if (!CAT)

4721 return nullptr;

4722

4723 const auto *CountDRE = cast(CAT->getCountExpr());

4724 const auto *CountDecl = CountDRE->getDecl();

4725 if (const auto *IFD = dyn_cast(CountDecl))

4726 CountDecl = IFD->getAnonField();

4727

4728 return dyn_cast(CountDecl);

4729}

4730

4731

4732

4733

4734

4739 TypedefNameDeclOrQualifier((TypedefNameDecl *)nullptr) {

4741 "EnumDecl not matched with TagTypeKind::Enum");

4749 TagDeclBits.IsThisDeclarationADemotedDefinition = false;

4750}

4751

4754}

4755

4760}

4761

4763

4765 TypedefNameDeclOrQualifier = TDD;

4767 (void)T;

4769 }

4771}

4772

4775

4776 if (auto *D = dyn_cast(this)) {

4777 struct CXXRecordDecl::DefinitionData *Data =

4778 new (getASTContext()) struct CXXRecordDecl::DefinitionData(D);

4779 for (auto *I : redecls())

4780 cast(I)->DefinitionData = Data;

4781 }

4782}

4783

4785 assert((!isa(this) ||

4787 "definition completed but not started");

4788

4791

4793 L->CompletedTagDefinition(this);

4794}

4795

4798 return const_cast<TagDecl *>(this);

4799

4800

4803 if (II->isOutOfDate()) {

4805 }

4806 }

4807 }

4808

4809 if (const auto *CXXRD = dyn_cast(this))

4810 return CXXRD->getDefinition();

4811

4812 for (auto *R : redecls())

4813 if (R->isCompleteDefinition())

4814 return R;

4815

4816 return nullptr;

4817}

4818

4820 if (QualifierLoc) {

4821

4822 if (!hasExtInfo())

4824

4826 } else {

4827

4828 if (hasExtInfo()) {

4829 if (getExtInfo()->NumTemplParamLists == 0) {

4831 TypedefNameDeclOrQualifier = (TypedefNameDecl *)nullptr;

4832 }

4833 else

4835 }

4836 }

4837}

4838

4841

4842

4843 if (Name.isIdentifier() && !Name.getAsIdentifierInfo()) {

4844

4845

4846

4848 Copy.SuppressScope = true;

4850 return;

4851 }

4852

4853 Name.print(OS, Policy);

4854}

4855

4858 assert(!TPLists.empty());

4859

4860 if (!hasExtInfo())

4861

4863

4865}

4866

4867

4868

4869

4870

4873 bool Scoped, bool ScopedUsingClassTag, bool Fixed)

4875 assert(Scoped || !ScopedUsingClassTag);

4876 IntegerType = nullptr;

4877 setNumPositiveBits(0);

4878 setNumNegativeBits(0);

4879 setScoped(Scoped);

4880 setScopedUsingClassTag(ScopedUsingClassTag);

4881 setFixed(Fixed);

4882 setHasODRHash(false);

4884}

4885

4886void EnumDecl::anchor() {}

4887

4891 EnumDecl *PrevDecl, bool IsScoped,

4892 bool IsScopedUsingClassTag, bool IsFixed) {

4893 auto *Enum = new (C, DC) EnumDecl(C, DC, StartLoc, IdLoc, Id, PrevDecl,

4894 IsScoped, IsScopedUsingClassTag, IsFixed);

4895 Enum->setMayHaveOutOfDateDef(C.getLangOpts().Modules);

4896 C.getTypeDeclType(Enum, PrevDecl);

4897 return Enum;

4898}

4899

4903 nullptr, nullptr, false, false, false);

4904 Enum->setMayHaveOutOfDateDef(C.getLangOpts().Modules);

4905 return Enum;

4906}

4907

4910 return TI->getTypeLoc().getSourceRange();

4912}

4913

4916 unsigned NumPositiveBits,

4917 unsigned NumNegativeBits) {

4919 if (!IntegerType)

4921 PromotionType = NewPromotionType;

4922 setNumPositiveBits(NumPositiveBits);

4923 setNumNegativeBits(NumNegativeBits);

4925}

4926

4928 if (const auto *A = getAttr())

4929 return A->getExtensibility() == EnumExtensibilityAttr::Closed;

4930 return true;

4931}

4932

4934 return isClosed() && hasAttr();

4935}

4936

4938 return isClosed() && !hasAttr();

4939}

4940

4943 return MSI->getTemplateSpecializationKind();

4944

4946}

4947

4951 assert(MSI && "Not an instantiated member enumeration?");

4954 PointOfInstantiation.isValid() &&

4957}

4958

4964 ED = NewED;

4966 }

4967 }

4968

4970 "couldn't find pattern for enum instantiation");

4971 return nullptr;

4972}

4973

4975 if (SpecializationInfo)

4977

4978 return nullptr;

4979}

4980

4983 assert(!SpecializationInfo && "Member enum is already a specialization");

4985}

4986

4988 if (hasODRHash())

4990

4993 setHasODRHash(true);

4996}

4997

5000

5002

5004 Res.setEnd(TSI->getTypeLoc().getEndLoc());

5005 }

5006 return Res;

5007}

5008

5013

5014 if (NumNegativeBits) {

5015 unsigned NumBits = std::max(NumNegativeBits, NumPositiveBits + 1);

5016 Max = llvm::APInt(Bitwidth, 1) << (NumBits - 1);

5018 } else {

5019 Max = llvm::APInt(Bitwidth, 1) << NumPositiveBits;

5020 Min = llvm::APInt::getZero(Bitwidth);

5021 }

5022}

5023

5024

5025

5026

5027

5032 : TagDecl(DK, TK, C, DC, IdLoc, Id, PrevDecl, StartLoc) {

5033 assert(classof(static_cast<Decl *>(this)) && "Invalid Kind!");

5049 setODRHash(0);

5050}

5051

5056 StartLoc, IdLoc, Id, PrevDecl);

5058

5059 C.getTypeDeclType(R, PrevDecl);

5060 return R;

5061}

5062

5069 return R;

5070}

5071

5075}

5076

5078 if (auto RD = dyn_cast(this))

5080 return false;

5081}

5082

5084 return hasAttr();

5085}

5086

5089}

5090

5093 return true;

5094

5096 for (const FieldDecl *FD : Def->fields()) {

5099 return true;

5100 }

5101 }

5102

5103 return false;

5104}

5105

5108 LoadFieldsFromExternalStorage();

5109

5110

5112 return D->field_begin();

5114}

5115

5116

5117

5121

5123

5124

5125

5126

5127

5128

5129

5130

5134}

5135

5136

5137

5138

5140 return hasAttr() || C.getLangOpts().MSBitfields == 1;

5141}

5142

5147}

5148

5149void RecordDecl::LoadFieldsFromExternalStorage() const {

5152

5153

5155

5160 }, Decls);

5161

5162#ifndef NDEBUG

5163

5164 for (unsigned i=0, e=Decls.size(); i != e; ++i)

5165 assert(isa(Decls[i]) || isa(Decls[i]));

5166#endif

5167

5168 if (Decls.empty())

5169 return;

5170

5171 auto [ExternalFirst, ExternalLast] =

5173 false);

5174 ExternalLast->NextInContextAndBits.setPointer(FirstDecl);

5178}

5179

5183 (SanitizerKind::Address | SanitizerKind::KernelAddress);

5184 if (!EnabledAsanMask || !Context.getLangOpts().SanitizeAddressFieldPadding)

5185 return false;

5187 const auto *CXXRD = dyn_cast(this);

5188

5189 int ReasonToReject = -1;

5190 if (!CXXRD || CXXRD->isExternCContext())

5191 ReasonToReject = 0;

5192 else if (CXXRD->hasAttr())

5193 ReasonToReject = 1;

5194 else if (CXXRD->isUnion())

5195 ReasonToReject = 2;

5196 else if (CXXRD->isTriviallyCopyable())

5197 ReasonToReject = 3;

5198 else if (CXXRD->hasTrivialDestructor())

5199 ReasonToReject = 4;

5200 else if (CXXRD->isStandardLayout())

5201 ReasonToReject = 5;

5203 "field-padding"))

5204 ReasonToReject = 6;

5207 ReasonToReject = 7;

5208

5209 if (EmitRemark) {

5210 if (ReasonToReject >= 0)

5213 diag::remark_sanitize_address_insert_extra_padding_rejected)

5215 else

5218 diag::remark_sanitize_address_insert_extra_padding_accepted)

5220 }

5221 return ReasonToReject < 0;

5222}

5223

5225 for (const auto *I : fields()) {

5226 if (I->getIdentifier())

5227 return I;

5228

5229 if (const auto *RT = I->getType()->getAs<RecordType>())

5230 if (const FieldDecl *NamedDataMember =

5231 RT->getDecl()->findFirstNamedDataMember())

5232 return NamedDataMember;

5233 }

5234

5235

5236 return nullptr;

5237}

5238

5240 if (hasODRHash())

5242

5243

5246

5247

5251}

5252

5253

5254

5255

5256

5265}

5266

5268 assert(!ParamInfo && "Already has param info!");

5269

5270

5271 if (!NewParamInfo.empty()) {

5272 NumParams = NewParamInfo.size();

5274 std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo);

5275 }

5276}

5277

5279 bool CapturesCXXThis) {

5281 this->NumCaptures = Captures.size();

5282

5283 if (Captures.empty()) {

5284 this->Captures = nullptr;

5285 return;

5286 }

5287

5288 this->Captures = Captures.copy(Context).data();

5289}

5290

5292 for (const auto &I : captures())

5293

5294 if (I.getVariable() == variable)

5295 return true;

5296

5297 return false;

5298}

5299

5302}

5303

5304

5305

5306

5307

5308void TranslationUnitDecl::anchor() {}

5309

5312}

5313

5315 AnonymousNamespace = D;

5316

5318 Listener->AddedAnonymousNamespace(this, D);

5319}

5320

5321void PragmaCommentDecl::anchor() {}

5322

5327 StringRef Arg) {

5329 new (C, DC, additionalSizeToAlloc(Arg.size() + 1))

5331 memcpy(PCD->getTrailingObjects<char>(), Arg.data(), Arg.size());

5332 PCD->getTrailingObjects<char>()[Arg.size()] = '\0';

5333 return PCD;

5334}

5335

5338 unsigned ArgSize) {

5339 return new (C, ID, additionalSizeToAlloc(ArgSize + 1))

5341}

5342

5343void PragmaDetectMismatchDecl::anchor() {}

5344

5348 StringRef Value) {

5349 size_t ValueStart = Name.size() + 1;

5351 new (C, DC, additionalSizeToAlloc(ValueStart + Value.size() + 1))

5353 memcpy(PDMD->getTrailingObjects<char>(), Name.data(), Name.size());

5354 PDMD->getTrailingObjects<char>()[Name.size()] = '\0';

5355 memcpy(PDMD->getTrailingObjects<char>() + ValueStart, Value.data(),

5357 PDMD->getTrailingObjects<char>()[ValueStart + Value.size()] = '\0';

5358 return PDMD;

5359}

5360

5363 unsigned NameValueSize) {

5364 return new (C, ID, additionalSizeToAlloc(NameValueSize + 1))

5366}

5367

5368void ExternCContextDecl::anchor() {}

5369

5373}

5374

5375void LabelDecl::anchor() {}

5376

5379 return new (C, DC) LabelDecl(DC, IdentL, II, nullptr, IdentL);

5380}

5381

5385 assert(GnuLabelL != IdentL && "Use this only for GNU local labels");

5386 return new (C, DC) LabelDecl(DC, IdentL, II, nullptr, GnuLabelL);

5387}

5388

5392}

5393

5395char *Buffer = new (getASTContext(), 1) char[Name.size() + 1];

5396 memcpy(Buffer, Name.data(), Name.size());

5397 Buffer[Name.size()] = '\0';

5398 MSAsmName = Buffer;

5399}

5400

5401void ValueDecl::anchor() {}

5402

5405 return MostRecent->hasAttr() ||

5406 MostRecent->hasAttr() || isWeakImported();

5407}

5408

5410 if (auto *Var = llvm::dyn_cast(this))

5411 return Var->isInitCapture();

5412 return false;

5413}

5414

5415void ImplicitParamDecl::anchor() {}

5416

5422}

5423

5427}

5428

5432}

5433

5438 bool isInlineSpecified, bool hasWrittenPrototype,

5440 Expr *TrailingRequiresClause) {

5445 return New;

5446}

5447

5452}

5453

5455 return new (C, DC) BlockDecl(DC, L);

5456}

5457

5460}

5461

5462OutlinedFunctionDecl::OutlinedFunctionDecl(DeclContext *DC, unsigned NumParams)

5464 DeclContext(OutlinedFunction), NumParams(NumParams),

5465 BodyAndNothrow(nullptr, false) {}

5466

5469 unsigned NumParams) {

5470 return new (C, DC, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))

5472}

5473

5476 unsigned NumParams) {

5477 return new (C, ID, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))

5479}

5480

5482 return BodyAndNothrow.getPointer();

5483}

5485

5488 BodyAndNothrow.setInt(Nothrow);

5489}

5490

5491CapturedDecl::CapturedDecl(DeclContext *DC, unsigned NumParams)

5493 NumParams(NumParams), ContextParam(0), BodyAndNothrow(nullptr, false) {}

5494

5496 unsigned NumParams) {

5497 return new (C, DC, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))

5499}

5500

5502 unsigned NumParams) {

5503 return new (C, ID, additionalSizeToAlloc<ImplicitParamDecl *>(NumParams))

5505}

5506

5509

5512

5518}

5519

5523 Expr *E, const llvm::APSInt &V) {

5525}

5526

5530 QualType(), nullptr, llvm::APSInt());

5531}

5532

5533void IndirectFieldDecl::anchor() {}

5534

5539 : ValueDecl(IndirectField, DC, L, N, T), Chaining(CH.data()),

5540 ChainingSize(CH.size()) {

5541

5542

5543 if (C.getLangOpts().CPlusPlus)

5545}

5546

5552}

5553

5558}

5559

5563 End = Init->getEndLoc();

5565}

5566

5567void TypeDecl::anchor() {}

5568

5573 return new (C, DC) TypedefDecl(C, DC, StartLoc, IdLoc, Id, TInfo);

5574}

5575

5576void TypedefNameDecl::anchor() {}

5577

5579 if (auto *TT = getTypeSourceInfo()->getType()->getAs()) {

5581 auto *ThisTypedef = this;

5582 if (AnyRedecl && OwningTypedef) {

5585 }

5586 if (OwningTypedef == ThisTypedef)

5587 return TT->getDecl();

5588 }

5589

5590 return nullptr;

5591}

5592

5593bool TypedefNameDecl::isTransparentTagSlow() const {

5594 auto determineIsTransparent = [&]() {

5596 if (auto *TD = TT->getDecl()) {

5597 if (TD->getName() != getName())

5598 return false;

5602 return false;

5604 return SM.getSpellingLoc(TTLoc) == SM.getSpellingLoc(TDLoc);

5605 }

5606 }

5607 return false;

5608 };

5609

5610 bool isTransparent = determineIsTransparent();

5611 MaybeModedTInfo.setInt((isTransparent << 1) | 1);

5612 return isTransparent;

5613}

5614

5617 nullptr, nullptr);

5618}

5619

5625 return new (C, DC) TypeAliasDecl(C, DC, StartLoc, IdLoc, Id, TInfo);

5626}

5627

5632}

5633

5638 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();

5639 }

5641}

5642

5646 RangeEnd = TInfo->getTypeLoc().getSourceRange().getEnd();

5648}

5649

5650void FileScopeAsmDecl::anchor() {}

5651

5656 return new (C, DC) FileScopeAsmDecl(DC, Str, AsmLoc, RParenLoc);

5657}

5658

5663}

5664

5665void TopLevelStmtDecl::anchor() {}

5666

5668 assert(C.getLangOpts().IncrementalExtensions &&

5669 "Must be used only in incremental mode");

5670

5672 DeclContext *DC = C.getTranslationUnitDecl();

5673

5675}

5676

5679 return new (C, ID)

5681}

5682

5685}

5686

5688 assert(S);

5689 Statement = S;

5691}

5692

5693void EmptyDecl::anchor() {}

5694

5696 return new (C, DC) EmptyDecl(DC, L);

5697}

5698

5701}

5702

5703HLSLBufferDecl::HLSLBufferDecl(DeclContext *DC, bool CBuffer,

5708 IsCBuffer(CBuffer) {}

5709

5711 DeclContext *LexicalParent, bool CBuffer,

5715

5716

5717

5718

5719

5720

5721

5722

5723

5724

5725

5728 new (C, DC) HLSLBufferDecl(DC, CBuffer, KwLoc, ID, IDLoc, LBrace);

5730}

5731

5736}

5737

5738

5739

5740

5741

5742

5743

5745 unsigned Result = 1;

5746 while (Mod->Parent) {

5749 }

5751}

5752

5756 : Decl(Import, DC, StartLoc), ImportedModule(Imported),

5757 NextLocalImportAndComplete(nullptr, true) {

5759 auto *StoredLocs = getTrailingObjects();

5760 std::uninitialized_copy(IdentifierLocs.begin(), IdentifierLocs.end(),

5761 StoredLocs);

5762}

5763

5766 : Decl(Import, DC, StartLoc), ImportedModule(Imported),

5767 NextLocalImportAndComplete(nullptr, false) {

5768 *getTrailingObjects() = EndLoc;

5769}

5770

5774 return new (C, DC,

5775 additionalSizeToAlloc(IdentifierLocs.size()))

5776 ImportDecl(DC, StartLoc, Imported, IdentifierLocs);

5777}

5778

5783 ImportDecl *Import = new (C, DC, additionalSizeToAlloc(1))

5784 ImportDecl(DC, StartLoc, Imported, EndLoc);

5785 Import->setImplicit();

5786 return Import;

5787}

5788

5790 unsigned NumLocations) {

5791 return new (C, ID, additionalSizeToAlloc(NumLocations))

5793}

5794

5796 if (!isImportComplete())

5797 return {};

5798

5799 const auto *StoredLocs = getTrailingObjects();

5802}

5803

5805 if (!isImportComplete())

5807

5809}

5810

5811

5812

5813

5814

5815void ExportDecl::anchor() {}

5816

5819 return new (C, DC) ExportDecl(DC, ExportLoc);

5820}

5821

5824}

5825

5827 bool IncludeLocallyStreaming) {

5828 if (IncludeLocallyStreaming)

5829 if (FD->hasAttr())

5830 return true;

5831

5834 if (FPT->getAArch64SMEAttributes() &

5836 return true;

5837

5838 return false;

5839}

Defines the clang::ASTContext interface.

This file provides some common utility functions for processing Lambda related AST Constructs.

Defines enum values for all the target-independent builtin functions.

enum clang::sema::@1727::IndirectLocalPathEntry::EntryKind Kind

Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....

Defines the C++ template declaration subclasses.

static bool isFirstInExternCContext(T *D)

static bool isRedeclarableImpl(Redeclarable< T > *)

static bool isDeclExternC(const T &D)

static bool hasExplicitVisibilityAlready(LVComputationKind computation)

Does this computation kind permit us to consider additional visibility settings from attributes and t...

static bool RedeclForcesDefC99(const FunctionDecl *Redecl)

static bool isExportedFromModuleInterfaceUnit(const NamedDecl *D)

static bool isRedeclarable(Decl::Kind K)

static bool redeclForcesDefMSVC(const FunctionDecl *Redecl)

static bool usesTypeVisibility(const NamedDecl *D)

Is the given declaration a "type" or a "value" for the purposes of visibility computation?

static std::optional< Visibility > getVisibilityOf(const NamedDecl *D, NamedDecl::ExplicitVisibilityKind kind)

Return the explicit visibility of the given declaration.

static LanguageLinkage getDeclLanguageLinkage(const T &D)

static LVComputationKind withExplicitVisibilityAlready(LVComputationKind Kind)

Given an LVComputationKind, return one of the same type/value sort that records that it already has e...

static std::enable_if_t<!std::is_base_of_v< RedeclarableTemplateDecl, T >, bool > isExplicitMemberSpecialization(const T *D)

Does the given declaration have member specialization information, and if so, is it an explicit speci...

static unsigned getNumModuleIdentifiers(Module *Mod)

Retrieve the number of module identifiers needed to name the given module.

static bool isSingleLineLanguageLinkage(const Decl &D)

static bool useInlineVisibilityHidden(const NamedDecl *D)

static bool shouldConsiderTemplateVisibility(const FunctionDecl *fn, const FunctionTemplateSpecializationInfo *specInfo)

static bool hasDirectVisibilityAttribute(const NamedDecl *D, LVComputationKind computation)

Does the given declaration have a direct visibility attribute that would match the given rules?

static DeclT * getDefinitionOrSelf(DeclT *D)

static Visibility getVisibilityFromAttr(const T *attr)

Given a visibility attribute, return the explicit visibility associated with it.

static const Decl * getOutermostFuncOrBlockContext(const Decl *D)

static bool typeIsPostfix(QualType QT)

static LinkageInfo getExternalLinkageFor(const NamedDecl *D)

static StorageClass getStorageClass(const Decl *D)

static std::optional< Visibility > getExplicitVisibilityAux(const NamedDecl *ND, NamedDecl::ExplicitVisibilityKind kind, bool IsMostRecent)

static SourceLocation getTemplateOrInnerLocStart(const DeclT *decl)

static bool isNamed(const NamedDecl *ND, const char(&Str)[Len])

static std::optional< Visibility > getExplicitVisibility(const NamedDecl *D, LVComputationKind kind)

static bool hasDefinition(const ObjCObjectPointerType *ObjPtr)

Defines the clang::Expr interface and subclasses for C++ expressions.

Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.

Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.

Defines the clang::LangOptions interface.

llvm::MachO::Record Record

Defines the clang::Module class, which describes a module in the source code.

This file contains the declaration of the ODRHash class, which calculates a hash based on AST nodes,...

Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.

static std::string getName(const CallEvent &Call)

Defines the clang::SanitizerKind enum.

Defines the clang::SourceLocation class and associated facilities.

Defines the SourceManager interface.

Defines various enumerations that describe declaration and type specifiers.

Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we're targeting.

Defines the clang::TypeLoc interface and its subclasses.

C Language Family Type Representation.

static const TypeInfo & getInfo(unsigned id)

Defines the clang::Visibility enumeration and various utility functions.

__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)

APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...

bool needsCleanup() const

Returns whether the object performed allocations.

Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...

SourceManager & getSourceManager()

const ConstantArrayType * getAsConstantArrayType(QualType T) const

unsigned getIntWidth(QualType T) const

TemplateOrSpecializationInfo getTemplateOrSpecializationInfo(const VarDecl *Var)

void setTemplateOrSpecializationInfo(VarDecl *Inst, TemplateOrSpecializationInfo TSI)

QualType getTagDeclType(const TagDecl *Decl) const

Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.

ASTMutationListener * getASTMutationListener() const

Retrieve a pointer to the AST mutation listener associated with this AST context, if any.

const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const

Get or compute information about the layout of the specified record (struct/union/class) D,...

bool hasSameType(QualType T1, QualType T2) const

Determine whether the given types T1 and T2 are equivalent.

void Deallocate(void *Ptr) const

Builtin::Context & BuiltinInfo

const LangOptions & getLangOpts() const

void setParameterIndex(const ParmVarDecl *D, unsigned index)

Used by ParmVarDecl to store on the side the index of the parameter when it exceeds the size of the n...

Decl * getPrimaryMergedDecl(Decl *D)

const NoSanitizeList & getNoSanitizeList() const

GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const

CanQualType getSizeType() const

Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.

const clang::PrintingPolicy & getPrintingPolicy() const

CharUnits getTypeSizeInChars(QualType T) const

Return the size of the specified (complete) type T, in characters.

void * Allocate(size_t Size, unsigned Align=8) const

void setInstantiatedFromStaticDataMember(VarDecl *Inst, VarDecl *Tmpl, TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())

Note that the static data member Inst is an instantiation of the static data member template Tmpl of ...

DiagnosticsEngine & getDiagnostics() const

const TargetInfo & getTargetInfo() const

CharUnits toCharUnitsFromBits(int64_t BitSize) const

Convert a size in bits to a size in characters.

void addDestruction(T *Ptr) const

If T isn't trivially destructible, calls AddDeallocation to register it for destruction.

ExternalASTSource * getExternalSource() const

Retrieve a pointer to the external AST source associated with this AST context, if any.

NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const

Retrieves the "canonical" nested name specifier for a given nested name specifier.

unsigned getParameterIndex(const ParmVarDecl *D) const

Used by ParmVarDecl to retrieve on the side the index of the parameter when it exceeds the size of th...

An abstract interface that should be implemented by listeners that want to be notified when an AST en...

ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...

CharUnits getSize() const

getSize - Get the record size in characters.

unsigned getFieldCount() const

getFieldCount - Get the number of fields in the layout.

uint64_t getFieldOffset(unsigned FieldNo) const

getFieldOffset - Get the offset of the given field index, in bits.

Represents a block literal declaration, which is like an unnamed FunctionDecl.

BlockDecl(DeclContext *DC, SourceLocation CaretLoc)

void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)

void setDoesNotEscape(bool B=true)

void setCapturesCXXThis(bool B=true)

void setCanAvoidCopyToHeap(bool B=true)

void setIsConversionFromLambda(bool val=true)

void setBlockMissingReturnType(bool val=true)

ArrayRef< Capture > captures() const

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

static BlockDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

void setIsVariadic(bool value)

bool capturesVariable(const VarDecl *var) const

void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)

static BlockDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)

bool isPredefinedLibFunction(unsigned ID) const

Determines whether this builtin is a predefined libc/libm function, such as "malloc",...

Represents a C++ struct/union/class.

CXXRecordDecl * getInstantiatedFromMemberClass() const

If this record is an instantiation of a member class, retrieves the member class from which it was in...

Represents the body of a CapturedStmt, and serves as its DeclContext.

static CapturedDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumParams)

void setNothrow(bool Nothrow=true)

static CapturedDecl * Create(ASTContext &C, DeclContext *DC, unsigned NumParams)

Stmt * getBody() const override

getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...

CharUnits - This is an opaque type for sizes expressed in character units.

static CharUnits Zero()

Zero - Construct a CharUnits quantity of zero.

Declaration of a class template.

CXXRecordDecl * getTemplatedDecl() const

Get the underlying class declarations of the template.

Represents a class template specialization, which refers to a class template with a given set of temp...

ClassTemplateDecl * getSpecializedTemplate() const

Retrieve the template that this specialization specializes.

const TemplateArgumentList & getTemplateArgs() const

Retrieve the template arguments of the class template specialization.

bool isExplicitSpecialization() const

bool isExplicitInstantiationOrSpecialization() const

True if this declaration is an explicit specialization, explicit instantiation declaration,...

bool isZeroSize() const

Return true if the size is zero.

Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...

A POD class for pairing a NamedDecl* with an access specifier.

decl_iterator - Iterates through the declarations stored within this context.

specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...

DeclContext - This is used only as base class of specific decl types that can act as declaration cont...

DeclContext * getParent()

getParent - Returns the containing DeclContext.

bool Equals(const DeclContext *DC) const

Determine whether this declaration context is equivalent to the declaration context DC.

FunctionDeclBitfields FunctionDeclBits

bool isFileContext() const

static std::pair< Decl *, Decl * > BuildDeclChain(ArrayRef< Decl * > Decls, bool FieldsAlreadyLoaded)

Build up a chain of declarations.

TagDeclBitfields TagDeclBits

bool isExternCXXContext() const

Determines whether this context or some of its ancestors is a linkage specification context that spec...

bool isTranslationUnit() const

DeclContext * getRedeclContext()

getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...

RecordDeclBitfields RecordDeclBits

Decl * FirstDecl

FirstDecl - The first declaration stored within this declaration context.

bool hasExternalLexicalStorage() const

Whether this DeclContext has external storage containing additional declarations that are lexically i...

Decl * LastDecl

LastDecl - The last declaration stored within this declaration context.

bool isFunctionOrMethod() const

bool isExternCContext() const

Determines whether this context or some of its ancestors is a linkage specification context that spec...

Decl::Kind getDeclKind() const

Decl - This represents one declaration (or definition), e.g.

Decl * getPreviousDecl()

Retrieve the previous declaration that declares the same entity as this declaration,...

bool isInStdNamespace() const

FriendObjectKind getFriendObjectKind() const

Determines whether this declaration is the object of a friend declaration and, if so,...

ASTContext & getASTContext() const LLVM_READONLY

bool isImplicit() const

isImplicit - Indicates whether the declaration was implicitly generated by the implementation.

bool isInNamedModule() const

Whether this declaration comes from a named module.

virtual bool isOutOfLine() const

Determine whether this declaration is declared out of line (outside its semantic context).

bool isWeakImported() const

Determine whether this is a weak-imported symbol.

ModuleOwnershipKind getModuleOwnershipKind() const

Get the kind of module ownership for this declaration.

ASTMutationListener * getASTMutationListener() const

bool hasCachedLinkage() const

Kind

Lists the kind of concrete classes of Decl.

@ FOK_None

Not a friend object.

bool isCanonicalDecl() const

Whether this particular Decl is a canonical one.

llvm::PointerIntPair< Decl *, 3, ModuleOwnershipKind > NextInContextAndBits

The next declaration within the same lexical DeclContext.

Module * getOwningModule() const

Get the module that owns this declaration (for visibility purposes).

FunctionDecl * getAsFunction() LLVM_READONLY

Returns the function itself, or the templated function if this is a function template.

bool isFromASTFile() const

Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...

Linkage getCachedLinkage() const

bool isTemplateParameter() const

isTemplateParameter - Determines whether this declaration is a template parameter.

bool isInvalidDecl() const

bool hasDefiningAttr() const

Return true if this declaration has an attribute which acts as definition of the entity,...

SourceLocation getLocation() const

IdentifierNamespace

IdentifierNamespace - The different namespaces in which declarations may appear.

@ IDNS_Tag

Tags, declared with 'struct foo;' and referenced with 'struct foo'.

redecl_range redecls() const

Returns an iterator range for all the redeclarations of the same decl.

void setLocation(SourceLocation L)

DeclContext * getDeclContext()

bool isInAnonymousNamespace() const

void setCachedLinkage(Linkage L) const

void updateOutOfDate(IdentifierInfo &II) const

Update a potentially out-of-date declaration.

Module * getOwningModuleForLinkage() const

Get the module that owns this declaration for linkage purposes.

DeclContext * getLexicalDeclContext()

getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).

virtual Decl * getCanonicalDecl()

Retrieves the "canonical" declaration of the given declaration.

@ VisibleWhenImported

This declaration has an owning module, and is visible when that module is imported.

@ Unowned

This declaration is not owned by a module.

@ ReachableWhenImported

This declaration has an owning module, and is visible to lookups that occurs within that module.

@ ModulePrivate

This declaration has an owning module, but is only visible to lookups that occur within that module.

@ Visible

This declaration has an owning module, but is globally visible (typically because its owning module i...

const LangOptions & getLangOpts() const LLVM_READONLY

Helper to get the language options from the ASTContext.

The name of a declaration.

void print(raw_ostream &OS, const PrintingPolicy &Policy) const

const IdentifierInfo * getCXXLiteralIdentifier() const

If this name is the name of a literal operator, retrieve the identifier associated with it.

OverloadedOperatorKind getCXXOverloadedOperator() const

If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...

Represents a ValueDecl that came out of a declarator.

SourceLocation getTypeSpecEndLoc() const

SourceLocation getInnerLocStart() const

Return start of source range ignoring outer template declarations.

SourceLocation getOuterLocStart() const

Return start of source range taking into account any outer template declarations.

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

SourceLocation getTypeSpecStartLoc() const

SourceLocation getBeginLoc() const LLVM_READONLY

void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)

void setTrailingRequiresClause(Expr *TrailingRequiresClause)

Expr * getTrailingRequiresClause()

Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...

TypeSourceInfo * getTypeSourceInfo() const

void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)

Provides information about a dependent function-template specialization declaration.

static DependentFunctionTemplateSpecializationInfo * Create(ASTContext &Context, const UnresolvedSetImpl &Candidates, const TemplateArgumentListInfo *TemplateArgs)

DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)

Issue the message to the client.

Represents an empty-declaration.

static EmptyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)

static EmptyDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

An instance of this object exists for each enum constant that is defined.

EnumConstantDecl(const ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)

static EnumConstantDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

void setInitVal(const ASTContext &C, const llvm::APSInt &V)

static EnumConstantDecl * Create(ASTContext &C, EnumDecl *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

MemberSpecializationInfo * getMemberSpecializationInfo() const

If this enumeration is an instantiation of a member enumeration of a class template specialization,...

unsigned getNumNegativeBits() const

Returns the width in bits required to store all the negative enumerators of this enum.

void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())

For an enumeration member that was instantiated from a member enumeration of a templated class,...

static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)

TypeSourceInfo * getIntegerTypeSourceInfo() const

Return the type source info for the underlying integer type, if no type source info exists,...

static EnumDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

bool isClosedFlag() const

Returns true if this enum is annotated with flag_enum and isn't annotated with enum_extensibility(ope...

SourceRange getIntegerTypeRange() const LLVM_READONLY

Retrieve the source range that covers the underlying type if specified.

SourceRange getSourceRange() const override LLVM_READONLY

Overrides to provide correct range when there's an enum-base specifier with forward declarations.

QualType getIntegerType() const

Return the integer type this enum decl corresponds to.

EnumDecl * getInstantiatedFromMemberEnum() const

Returns the enumeration (declared within the template) from which this enumeration type was instantia...

unsigned getNumPositiveBits() const

Returns the width in bits required to store all the non-negative enumerators of this enum.

TemplateSpecializationKind getTemplateSpecializationKind() const

If this enumeration is a member of a specialization of a templated class, determine what kind of temp...

bool isClosed() const

Returns true if this enum is either annotated with enum_extensibility(closed) or isn't annotated with...

EnumDecl * getTemplateInstantiationPattern() const

Retrieve the enum definition from which this enumeration could be instantiated, if it is an instantia...

bool isClosedNonFlag() const

Returns true if this enum is annotated with neither flag_enum nor enum_extensibility(open).

void getValueRange(llvm::APInt &Max, llvm::APInt &Min) const

Calculates the [Min,Max) values the enum can store based on the NumPositiveBits and NumNegativeBits.

A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.

Represents a standard C++ module export declaration.

static ExportDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExportLoc)

static ExportDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

This represents one expression.

bool isValueDependent() const

Determines whether the value of this expression depends on.

Declaration context for names declared as extern "C" in C++.

static ExternCContextDecl * Create(const ASTContext &C, TranslationUnitDecl *TU)

RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.

Abstract interface for external sources of AST nodes.

virtual void FindExternalLexicalDecls(const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl * > &Result)

Finds all declarations lexically contained within the given DeclContext, after applying an optional f...

Represents a member of a struct/union/class.

Expr * getInClassInitializer() const

Get the C++11 default member initializer for this member, or null if one has not been set.

bool isBitField() const

Determines whether this field is a bitfield.

bool hasInClassInitializer() const

Determine whether this member has a C++11 default member initializer.

unsigned getBitWidthValue() const

Computes the bit width of this field, if this is a bit field.

bool isAnonymousStructOrUnion() const

Determines whether this field is a representative for an anonymous struct or union.

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

static FieldDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

void setInClassInitializer(Expr *NewInit)

Set the C++11 in-class initializer for this member.

const RecordDecl * getParent() const

Returns the parent of this field declaration, which is the struct in which this field is defined.

bool isZeroSize(const ASTContext &Ctx) const

Determine if this field is a subobject of zero size, that is, either a zero-length bit-field or a fie...

InitAndBitWidthStorage * InitAndBitWidth

static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)

FieldDecl * getCanonicalDecl() override

Retrieves the canonical declaration of this field.

static bool classofKind(Kind K)

bool isUnnamedBitField() const

Determines whether this is an unnamed bitfield.

bool isZeroLengthBitField() const

Is this a zero-length bit-field? Such bit-fields aren't really bit-fields at all and instead act as a...

Expr * getBitWidth() const

Returns the expression that represents the bit width, if this field is a bit field.

void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override

Pretty-print the unqualified name of this declaration.

const FieldDecl * findCountedByField() const

Find the FieldDecl specified in a FAM's "counted_by" attribute.

bool isPotentiallyOverlapping() const

Determine if this field is of potentially-overlapping class type, that is, subobject with the [[no_un...

void setCapturedVLAType(const VariableArrayType *VLAType)

Set the captured variable length array type for this field.

const VariableArrayType * CapturedVLAType

static FileScopeAsmDecl * Create(ASTContext &C, DeclContext *DC, StringLiteral *Str, SourceLocation AsmLoc, SourceLocation RParenLoc)

static FileScopeAsmDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

Stashed information about a defaulted/deleted function body.

static DefaultedOrDeletedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups, StringLiteral *DeletedMessage=nullptr)

void setDeletedMessage(StringLiteral *Message)

Represents a function declaration or definition.

unsigned getMemoryFunctionKind() const

Identify a memory copying or setting function.

bool isTargetClonesMultiVersion() const

True if this function is a multiversioned dispatch function as a part of the target-clones functional...

bool isMultiVersion() const

True if this function is considered a multiversioned function.

const ParmVarDecl * getParamDecl(unsigned i) const

bool hasTrivialBody() const

Returns whether the function has a trivial body that does not require any specific codegen.

unsigned getMinRequiredArguments() const

Returns the minimum number of arguments needed to call this function.

bool isFunctionTemplateSpecialization() const

Determine whether this function is a function template specialization.

void setPreviousDeclaration(FunctionDecl *PrevDecl)

void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)

FunctionTemplateDecl * getDescribedFunctionTemplate() const

Retrieves the function template that is described by this function declaration.

void setIsPureVirtual(bool P=true)

bool isImmediateFunction() const

void setDefaultedOrDeletedInfo(DefaultedOrDeletedFunctionInfo *Info)

SourceLocation getEllipsisLoc() const

Returns the location of the ellipsis of a variadic function.

SourceRange getReturnTypeSourceRange() const

Attempt to compute an informative source range covering the function return type.

bool isDestroyingOperatorDelete() const

Determine whether this is a destroying operator delete.

static FunctionDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const

Returns a value indicating whether this function corresponds to a builtin function.

SourceLocation getPointOfInstantiation() const

Retrieve the (first) point of instantiation of a function template specialization or a member of a cl...

bool isMemberLikeConstrainedFriend() const

Determine whether a function is a friend function that cannot be redeclared outside of its class,...

bool hasCXXExplicitFunctionObjectParameter() const

bool isInlined() const

Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...

bool UsesFPIntrin() const

Determine whether the function was declared in source context that requires constrained FP intrinsics...

void setHasWrittenPrototype(bool P=true)

State that this function has a written prototype.

bool isNoReturn() const

Determines whether this function is known to be 'noreturn', through an attribute on its declaration o...

ArrayRef< ParmVarDecl * > parameters() const

bool isCPUSpecificMultiVersion() const

True if this function is a multiversioned processor specific function as a part of the cpu_specific/c...

FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const

Retrieve the function declaration from which this function could be instantiated, if it is an instant...

bool isMSExternInline() const

The combination of the extern and inline keywords under MSVC forces the function to be required.

unsigned getMinRequiredExplicitArguments() const

Returns the minimum number of non-object arguments needed to call this function.

bool BodyContainsImmediateEscalatingExpressions() const

LanguageLinkage getLanguageLinkage() const

Compute the language linkage.

FunctionTemplateDecl * getPrimaryTemplate() const

Retrieve the primary template that this function template specialization either specializes or was in...

bool hasWrittenPrototype() const

Whether this function has a written prototype.

MemberSpecializationInfo * getMemberSpecializationInfo() const

If this function is an instantiation of a member function of a class template specialization,...

FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const

If this function is actually a function template specialization, retrieve information about this func...

FunctionDecl * getCanonicalDecl() override

Retrieves the "canonical" declaration of the given declaration.

FunctionTypeLoc getFunctionTypeLoc() const

Find the source location information for how the type of this function was written.

bool isVariadic() const

Whether this function is variadic.

bool doesThisDeclarationHaveABody() const

Returns whether this specific declaration of the function has a body.

bool isConstexprSpecified() const

DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const

const TemplateArgumentList * getTemplateSpecializationArgs() const

Retrieve the template arguments used to produce this function template specialization from the primar...

SourceRange getExceptionSpecSourceRange() const

Attempt to compute an informative source range covering the function exception specification,...

bool hasBody() const override

Returns true if this Decl represents a declaration for a body of code, such as a function or method d...

bool isMSVCRTEntryPoint() const

Determines whether this function is a MSVCRT user defined entry point.

unsigned getODRHash()

Returns ODRHash of the function.

TemplateSpecializationKind getTemplateSpecializationKindForInstantiation() const

Determine the kind of template specialization this function represents for the purpose of template in...

bool isTemplateInstantiation() const

Determines if the given function was instantiated from a function template.

unsigned getNumNonObjectParams() const

TemplatedKind

The kind of templated function a FunctionDecl can be.

@ TK_MemberSpecialization

@ TK_DependentNonTemplate

@ TK_FunctionTemplateSpecialization

@ TK_DependentFunctionTemplateSpecialization

StorageClass getStorageClass() const

Returns the storage class as written in the source.

bool isOutOfLine() const override

Determine whether this is or was instantiated from an out-of-line definition of a member function.

bool isInlineBuiltinDeclaration() const

Determine if this function provides an inline implementation of a builtin.

bool FriendConstraintRefersToEnclosingTemplate() const

TemplatedKind getTemplatedKind() const

What kind of templated function this is.

void setInstantiatedFromDecl(FunctionDecl *FD)

Specify that this function declaration was instantiated from a FunctionDecl FD.

bool isDeletedAsWritten() const

bool isReservedGlobalPlacementOperator() const

Determines whether this operator new or delete is one of the reserved global placement operators: voi...

void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo *TemplateArgs)

Specifies that this function declaration is actually a dependent function template specialization.

bool isInExternCContext() const

Determines whether this function's context is, or is nested within, a C++ extern "C" linkage spec.

FunctionDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass S, bool UsesFPIntrin, bool isInlineSpecified, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause=nullptr)

bool isImplicitlyInstantiable() const

Determines whether this function is a function template specialization or a member of a class templat...

bool isExternC() const

Determines whether this function is a function with external, C linkage.

Stmt * getBody() const override

getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...

LazyDeclStmtPtr Body

The body of the function.

bool isImmediateEscalating() const

DefaultedOrDeletedFunctionInfo * DefaultedOrDeletedInfo

Information about a future defaulted function definition.

bool isInExternCXXContext() const

Determines whether this function's context is, or is nested within, a C++ extern "C++" linkage spec.

bool isMain() const

Determines whether this function is "main", which is the entry point into an executable program.

void setImplicitlyInline(bool I=true)

Flag that this function is implicitly inline.

bool isTargetVersionMultiVersion() const

True if this function is a multiversioned dispatch function as a part of the target-version functiona...

bool isReplaceableGlobalAllocationFunction(std::optional< unsigned > *AlignmentParam=nullptr, bool *IsNothrow=nullptr) const

Determines whether this function is one of the replaceable global allocation functions: void *operato...

static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, Expr *TrailingRequiresClause=nullptr)

bool isThisDeclarationInstantiatedFromAFriendDefinition() const

Determine whether this specific declaration of the function is a friend declaration that was instanti...

bool isCPUDispatchMultiVersion() const

True if this function is a multiversioned dispatch function as a part of the cpu_specific/cpu_dispatc...

bool isDefaulted() const

Whether this function is defaulted.

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

FunctionDecl * getInstantiatedFromDecl() const

void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())

Determine what kind of template instantiation this function represents.

const IdentifierInfo * getLiteralIdentifier() const

getLiteralIdentifier - The literal suffix identifier this function represents, if any.

OverloadedOperatorKind getOverloadedOperator() const

getOverloadedOperator - Which C++ overloaded operator this function represents, if any.

TemplateSpecializationKind getTemplateSpecializationKind() const

Determine what kind of template instantiation this function represents.

bool doesDeclarationForceExternallyVisibleDefinition() const

For a function declaration in C or C++, determine whether this declaration causes the definition to b...

bool isTargetMultiVersion() const

True if this function is a multiversioned dispatch function as a part of the target functionality.

bool isGlobal() const

Determines whether this is a global function.

bool hasOneParamOrDefaultArgs() const

Determine whether this function has a single parameter, or multiple parameters where all but the firs...

void setDeletedAsWritten(bool D=true, StringLiteral *Message=nullptr)

bool isTargetMultiVersionDefault() const

True if this function is the default version of a multiversioned dispatch function as a part of the t...

FunctionDecl * getInstantiatedFromMemberFunction() const

If this function is an instantiation of a member function of a class template specialization,...

bool isInlineDefinitionExternallyVisible() const

For an inline function definition in C, or for a gnu_inline function in C++, determine whether the de...

unsigned getNumParams() const

Return the number of parameters this function must have based on its FunctionType.

DeclarationNameInfo getNameInfo() const

bool hasBody(const FunctionDecl *&Definition) const

Returns true if the function has a body.

SourceRange getParametersSourceRange() const

Attempt to compute an informative source range covering the function parameters, including the ellips...

bool isInlineSpecified() const

Determine whether the "inline" keyword was specified for this function.

MultiVersionKind getMultiVersionKind() const

Gets the kind of multiversioning attribute this declaration has.

DefaultedOrDeletedFunctionInfo * getDefalutedOrDeletedInfo() const

void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override

Appends a human-readable name for this declaration into the given stream.

bool willHaveBody() const

True if this function will eventually have a body, once it's fully parsed.

const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const

Retrieve the template argument list as written in the sources, if any.

Represents a prototype with parameter type info, e.g.

unsigned getNumParams() const

bool isVariadic() const

Whether this function prototype is variadic.

Declaration of a template function.

void addSpecialization(FunctionTemplateSpecializationInfo *Info, void *InsertPos)

Add a specialization of this function template.

FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const

Provides information about a function template specialization, which is a FunctionDecl that has been ...

TemplateArgumentList * TemplateArguments

The template arguments used to produce the function template specialization from the function templat...

FunctionTemplateDecl * getTemplate() const

Retrieve the template from which this function was specialized.

static FunctionTemplateSpecializationInfo * Create(ASTContext &C, FunctionDecl *FD, FunctionTemplateDecl *Template, TemplateSpecializationKind TSK, TemplateArgumentList *TemplateArgs, const TemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI, MemberSpecializationInfo *MSInfo)

bool isExplicitInstantiationOrSpecialization() const

True if this declaration is an explicit specialization, explicit instantiation declaration,...

Wrapper for source info for functions.

SourceRange getExceptionSpecRange() const

TypeLoc getReturnLoc() const

FunctionType - C99 6.7.5.3 - Function Declarators.

@ SME_PStateSMEnabledMask

HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.

static HLSLBufferDecl * Create(ASTContext &C, DeclContext *LexicalParent, bool CBuffer, SourceLocation KwLoc, IdentifierInfo *ID, SourceLocation IDLoc, SourceLocation LBrace)

static HLSLBufferDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

One of these records is kept for each identifier that is lexed.

ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const

Determine whether this is a name reserved for the implementation (C99 7.1.3, C++ [lib....

bool isStr(const char(&Str)[StrLen]) const

Return true if this is the identifier for the specified string.

static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)

Create implicit parameter.

static ImplicitParamDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

Describes a module import declaration, which makes the contents of the named module visible in the cu...

static ImportDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, ArrayRef< SourceLocation > IdentifierLocs)

Create a new module import declaration.

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

static ImportDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumLocations)

Create a new, deserialized module import declaration.

ArrayRef< SourceLocation > getIdentifierLocs() const

Retrieves the locations of each of the identifiers that make up the complete module name in the impor...

Module * getImportedModule() const

Retrieve the module that was imported by the import declaration.

static ImportDecl * CreateImplicit(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, SourceLocation EndLoc)

Create a new module import declaration for an implicitly-generated import.

Represents a field injected from an anonymous union/struct into the parent scope.

static bool classofKind(Kind K)

static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, const IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl * > CH)

static IndirectFieldDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

Represents the declaration of a label.

void setMSAsmLabel(StringRef Name)

static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)

static LabelDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

RegisterStaticDestructorsKind

Controls which variables have static destructors registered.

Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...

SanitizerSet Sanitize

Set of enabled sanitizers.

LinkageInfo getTypeLinkageAndVisibility(const Type *T)

LinkageInfo computeLVForDecl(const NamedDecl *D, LVComputationKind computation, bool IgnoreVarTypeLinkage=false)

LinkageInfo getLVForDecl(const NamedDecl *D, LVComputationKind computation)

getLVForDecl - Get the linkage and visibility for the given declaration.

LinkageInfo getDeclLinkageAndVisibility(const NamedDecl *D)

Visibility getVisibility() const

static LinkageInfo external()

static LinkageInfo none()

void setLinkage(Linkage L)

void mergeExternalVisibility(Linkage L)

void mergeMaybeWithVisibility(LinkageInfo other, bool withVis)

Merge linkage and conditionally merge visibility.

Linkage getLinkage() const

static LinkageInfo internal()

static LinkageInfo visible_none()

static LinkageInfo uniqueExternal()

void mergeVisibility(Visibility newVis, bool newExplicit)

Merge in the visibility 'newVis'.

bool isVisibilityExplicit() const

void merge(LinkageInfo other)

Merge both linkage and visibility.

Provides information a specialization of a member of a class template, which may be a member function...

void setTemplateSpecializationKind(TemplateSpecializationKind TSK)

Set the template specialization kind.

TemplateSpecializationKind getTemplateSpecializationKind() const

Determine what kind of template specialization this is.

SourceLocation getPointOfInstantiation() const

Retrieve the first point of instantiation of this member.

void setPointOfInstantiation(SourceLocation POI)

Set the first point of instantiation.

NamedDecl * getInstantiatedFrom() const

Retrieve the member declaration from which this member was instantiated.

Describes a module or submodule.

Module * Parent

The parent of this module.

ModuleKind Kind

The kind of this module.

@ ModuleImplementationUnit

This is a C++20 module implementation unit.

@ ModuleMapModule

This is a module that was defined by a module map and built out of header files.

@ ImplicitGlobalModuleFragment

This is an implicit fragment of the global module which contains only language linkage declarations (...

@ ModulePartitionInterface

This is a C++20 module partition interface.

@ ModuleInterfaceUnit

This is a C++20 module interface unit.

@ ModuleHeaderUnit

This is a C++20 header unit.

@ ModulePartitionImplementation

This is a C++20 module partition implementation.

@ PrivateModuleFragment

This is the private module fragment within some C++ module.

@ ExplicitGlobalModuleFragment

This is the explicit Global Module Fragment of a modular TU.

This represents a decl that may have a name.

ExplicitVisibilityKind

Kinds of explicit visibility.

@ VisibilityForValue

Do an LV computation for, ultimately, a non-type declaration.

@ VisibilityForType

Do an LV computation for, ultimately, a type.

Linkage getLinkageInternal() const

Determine what kind of linkage this entity has.

IdentifierInfo * getIdentifier() const

Get the identifier that names this declaration, if there is one.

LinkageInfo getLinkageAndVisibility() const

Determines the linkage and visibility of this entity.

bool isLinkageValid() const

True if the computed linkage is valid.

StringRef getName() const

Get the name of identifier for this declaration as a StringRef.

bool isPlaceholderVar(const LangOptions &LangOpts) const

DeclarationName getDeclName() const

Get the actual, stored name of the declaration, which may be a special name.

std::string getQualifiedNameAsString() const

std::optional< Visibility > getExplicitVisibility(ExplicitVisibilityKind kind) const

If visibility was explicitly specified for this declaration, return that visibility.

NamedDecl * getMostRecentDecl()

virtual void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const

Appends a human-readable name for this declaration into the given stream.

bool declarationReplaces(const NamedDecl *OldD, bool IsKnownNewer=true) const

Determine whether this declaration, if known to be well-formed within its context,...

ObjCStringFormatFamily getObjCFStringFormattingFamily() const

Linkage getFormalLinkage() const

Get the linkage from a semantic point of view.

void printQualifiedName(raw_ostream &OS) const

Returns a human-readable qualified name for this declaration, like A::B::i, for i being member of nam...

virtual void printName(raw_ostream &OS, const PrintingPolicy &Policy) const

Pretty-print the unqualified name of this declaration.

bool isCXXInstanceMember() const

Determine whether the given declaration is an instance member of a C++ class.

bool hasLinkage() const

Determine whether this declaration has linkage.

ReservedIdentifierStatus isReserved(const LangOptions &LangOpts) const

Determine if the declaration obeys the reserved identifier rules of the given language.

bool isCXXClassMember() const

Determine whether this declaration is a C++ class member.

void printNestedNameSpecifier(raw_ostream &OS) const

Print only the nested name specifier part of a fully-qualified name, including the '::' at the end.

Represent a C++ namespace.

A C++ nested-name-specifier augmented with source location information.

bool containsType(SanitizerMask Mask, StringRef MangledTypeName, StringRef Category=StringRef()) const

bool containsLocation(SanitizerMask Mask, SourceLocation Loc, StringRef Category=StringRef()) const

void AddEnumDecl(const EnumDecl *Enum)

void AddFunctionDecl(const FunctionDecl *Function, bool SkipBody=false)

void AddRecordDecl(const RecordDecl *Record)

Represents a partial function definition.

static OutlinedFunctionDecl * Create(ASTContext &C, DeclContext *DC, unsigned NumParams)

void setNothrow(bool Nothrow=true)

static OutlinedFunctionDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NumParams)

Stmt * getBody() const override

getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...

Represents a parameter to a function.

void setDefaultArg(Expr *defarg)

static ParmVarDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

bool hasUnparsedDefaultArg() const

Determines whether this parameter has a default argument that has not yet been parsed.

SourceRange getDefaultArgRange() const

Retrieve the source range that covers the entire default argument.

void setUninstantiatedDefaultArg(Expr *arg)

bool hasUninstantiatedDefaultArg() const

bool isDestroyedInCallee() const

Determines whether this parameter is destroyed in the callee function.

bool hasInheritedDefaultArg() const

bool isExplicitObjectParameter() const

QualType getOriginalType() const

static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)

Expr * getUninstantiatedDefaultArg()

bool hasDefaultArg() const

Determines whether this parameter has a default argument, either parsed or not.

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

Represents a #pragma detect_mismatch line.

static PragmaDetectMismatchDecl * Create(const ASTContext &C, TranslationUnitDecl *DC, SourceLocation Loc, StringRef Name, StringRef Value)

static PragmaDetectMismatchDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID, unsigned NameValueSize)

void print(raw_ostream &OS) const override

A (possibly-)qualified type.

bool isNull() const

Return true if this QualType doesn't point to a type yet.

const Type * getTypePtr() const

Retrieves a pointer to the underlying (unqualified) type.

void print(raw_ostream &OS, const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const

DestructionKind isDestructedType() const

Returns a nonzero value if objects of this type require non-trivial work to clean up after.

unsigned getCVRQualifiers() const

Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.

const Type * getTypePtrOrNull() const

Represents a struct/union/class.

bool hasLoadedFieldsFromExternalStorage() const

unsigned getODRHash()

Get precomputed ODRHash or add a new one.

bool isLambda() const

Determine whether this record is a class describing a lambda function object.

bool isMsStruct(const ASTContext &C) const

Get whether or not this is an ms_struct which can be turned on with an attribute, pragma,...

void setAnonymousStructOrUnion(bool Anon)

const FieldDecl * findFirstNamedDataMember() const

Finds the first data member which has a name.

void setArgPassingRestrictions(RecordArgPassingKind Kind)

void setNonTrivialToPrimitiveCopy(bool V)

bool isCapturedRecord() const

Determine whether this record is a record for captured variables in CapturedStmt construct.

void setHasNonTrivialToPrimitiveCopyCUnion(bool V)

field_range fields() const

void setHasNonTrivialToPrimitiveDestructCUnion(bool V)

void setHasFlexibleArrayMember(bool V)

void setParamDestroyedInCallee(bool V)

void setNonTrivialToPrimitiveDestroy(bool V)

void setHasObjectMember(bool val)

static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)

bool isInjectedClassName() const

Determines whether this declaration represents the injected class name.

void setHasVolatileMember(bool val)

void setHasNonTrivialToPrimitiveDefaultInitializeCUnion(bool V)

void reorderDecls(const SmallVectorImpl< Decl * > &Decls)

void setIsRandomized(bool V)

static RecordDecl * CreateDeserialized(const ASTContext &C, GlobalDeclID ID)

bool mayInsertExtraPadding(bool EmitRemark=false) const

Whether we are allowed to insert extra padding between fields.

static bool classof(const Decl *D)

bool isOrContainsUnion() const

Returns whether this record is a union, or contains (at any nesting level) a union member.

virtual void completeDefinition()

Note that the definition of this type is now complete.

RecordDecl * getDefinition() const

Returns the RecordDecl that actually defines this struct/union/class.

void setCapturedRecord()

Mark the record as a record for captured variables in CapturedStmt construct.

specific_decl_iterator< FieldDecl > field_iterator

void setHasUninitializedExplicitInitFields(bool V)

void setNonTrivialToPrimitiveDefaultInitialize(bool V)

void setHasLoadedFieldsFromExternalStorage(bool val) const

field_iterator field_begin() const

A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...

RecordDecl * getDecl() const

Declaration of a redeclarable template.

Provides common interface for the Decls that can be redeclared.

VarDecl * getFirstDecl()

Return the first declaration of this declaration or itself if this is the only declaration.

decl_type * getPreviousDecl()

Return the previous declaration of this declaration or NULL if this is the first declaration.

VarDecl * getMostRecentDecl()

Returns the most recent (re)declaration of this declaration.

void setPreviousDecl(FunctionDecl *PrevDecl)

Set the previous declaration.

redecl_range redecls() const

Returns an iterator range for all the redeclarations of the same decl.

Encodes a location in the source.

bool isValid() const

Return true if this is a valid SourceLocation object.

void print(raw_ostream &OS, const SourceManager &SM) const

This class handles loading and caching of source files into memory.

A trivial tuple used to represent a source range.

SourceLocation getEnd() const

SourceLocation getBegin() const

Stmt - This represents one statement.

SourceLocation getEndLoc() const LLVM_READONLY

SourceRange getSourceRange() const LLVM_READONLY

SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...

SourceLocation getBeginLoc() const LLVM_READONLY

StringLiteral - This represents a string literal expression, e.g.

Represents the declaration of a struct/union/class/enum.

void setTagKind(TagKind TK)

void setCompleteDefinitionRequired(bool V=true)

True if this complete decl is required to be complete for some existing use.

SourceRange getBraceRange() const

TagDecl * getDefinition() const

Returns the TagDecl that actually defines this struct/union/class/enum.

void setEmbeddedInDeclarator(bool isInDeclarator)

True if this tag declaration is "embedded" (i.e., defined or declared for the very first time) in the...

bool isCompleteDefinition() const

Return true if this decl has its body fully specified.

void setMayHaveOutOfDateDef(bool V=true)

Indicates whether it is possible for declarations of this kind to have an out-of-date definition.

TypedefNameDecl * getTypedefNameForAnonDecl() const

void startDefinition()

Starts the definition of this tag declaration.

TagDecl * getCanonicalDecl() override

Retrieves the "canonical" declaration of the given declaration.

void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)

bool mayHaveOutOfDateDef() const

Indicates whether it is possible for declarations of this kind to have an out-of-date definition.

SourceLocation getOuterLocStart() const

Return SourceLocation representing start of source range taking into account any outer template decla...

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

void setBeingDefined(bool V=true)

True if this decl is currently being defined.

void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)

void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)

void completeDefinition()

Completes the definition of this tag declaration.

void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override

Pretty-print the unqualified name of this declaration.

void setFreeStanding(bool isFreeStanding=true)

True if this tag is free standing, e.g. "struct foo;".

bool isDependentType() const

Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...

TagDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, TagDecl *PrevDecl, SourceLocation StartL)

void setCompleteDefinition(bool V=true)

True if this decl has its body fully specified.

bool isMicrosoft() const

Is this ABI an MSVC-compatible ABI?

const llvm::Triple & getTriple() const

Returns the target triple of the primary target.

TargetCXXABI getCXXABI() const

Get the C++ ABI currently in use.

A convenient class for passing around template argument information.

A template argument list.

ArrayRef< TemplateArgument > asArray() const

Produce this as an array ref.

Represents a template argument.

@ Declaration

The template argument is a declaration that was provided for a pointer, reference,...

@ Template

The template argument is a template name that was provided for a template template parameter.

@ StructuralValue

The template argument is a non-type template argument that can't be represented by the special-case D...

@ Pack

The template argument is actually a parameter pack.

@ TemplateExpansion

The template argument is a pack expansion of a template name that was provided for a template templat...

@ NullPtr

The template argument is a null pointer or null pointer to member that was provided for a non-type te...

@ Type

The template argument is a type.

@ Null

Represents an empty template argument, e.g., one that has not been deduced.

@ Integral

The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...

@ Expression

The template argument is an expression, and we've not resolved it to one of the other forms yet,...

The base class of all kinds of template declarations (e.g., class, function, etc.).

TemplateParameterList * getTemplateParameters() const

Get the list of template parameters.

Stores a list of template parameters for a TemplateDecl and its derived classes.

A declaration that models statements at global scope.

static TopLevelStmtDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

static TopLevelStmtDecl * Create(ASTContext &C, Stmt *Statement)

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

The top declaration context.

static TranslationUnitDecl * Create(ASTContext &C)

ASTContext & getASTContext() const

void setAnonymousNamespace(NamespaceDecl *D)

Represents the declaration of a typedef-name via a C++11 alias-declaration.

static TypeAliasDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

Represents a declaration of a type.

const Type * getTypeForDecl() const

SourceLocation getBeginLoc() const LLVM_READONLY

T getAs() const

Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...

TypeLoc IgnoreParens() const

SourceRange getSourceRange() const LLVM_READONLY

Get the full source range.

SourceLocation getEndLoc() const

Get the end source location.

SourceLocation getBeginLoc() const

Get the begin source location.

A container of type source information.

TypeLoc getTypeLoc() const

Return the TypeLoc wrapper for the type source info.

QualType getType() const

Return the type wrapped by this type source info.

The base class of the type hierarchy.

CXXRecordDecl * getAsCXXRecordDecl() const

Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...

bool isLinkageValid() const

True if the computed linkage is valid.

const T * castAs() const

Member-template castAs.

bool isReferenceType() const

bool isEnumeralType() const

QualType getPointeeType() const

If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.

bool isDependentType() const

Whether this type is a dependent type, meaning that its definition somehow depends on a template para...

DeducedType * getContainedDeducedType() const

Get the DeducedType whose type will be deduced for a variable with an initializer of this type.

bool isUndeducedType() const

Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...

bool isFunctionType() const

Linkage getLinkage() const

Determine the linkage of this type.

TypeClass getTypeClass() const

const T * getAs() const

Member-template getAs'.

Represents the declaration of a typedef-name via the 'typedef' type specifier.

static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

static TypedefDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

Base class for declarations which introduce a typedef-name.

TypeSourceInfo * getTypeSourceInfo() const

QualType getUnderlyingType() const

TypedefNameDecl * getCanonicalDecl() override

Retrieves the canonical declaration of this typedef-name.

TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const

Retrieves the tag declaration for which this is the typedef name for linkage purposes,...

A set of unresolved declarations.

Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...

bool isWeak() const

Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr.

bool isInitCapture() const

Whether this variable is the implicit variable for a lambda init-capture.

Represents a variable declaration or definition.

VarTemplateDecl * getDescribedVarTemplate() const

Retrieves the variable template that is described by this variable declaration.

static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)

Stmt ** getInitAddress()

Retrieve the address of the initializer expression.

DefinitionKind isThisDeclarationADefinition() const

bool isConstexpr() const

Whether this variable is (C++11) constexpr.

void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)

Specify that this variable is an instantiation of the static data member VD.

TLSKind getTLSKind() const

bool hasICEInitializer(const ASTContext &Context) const

Determine whether the initializer of this variable is an integer constant expression.

ParmVarDeclBitfields ParmVarDeclBits

DefinitionKind hasDefinition() const

static const char * getStorageClassSpecifierString(StorageClass SC)

Return the string used to specify the storage class SC.

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

bool isOutOfLine() const override

Determine whether this is or was instantiated from an out-of-line definition of a static data member.

VarDecl * getCanonicalDecl() override

Retrieves the "canonical" declaration of the given declaration.

bool hasFlexibleArrayInit(const ASTContext &Ctx) const

Whether this variable has a flexible array member initialized with one or more elements.

bool isNoDestroy(const ASTContext &) const

Is destruction of this variable entirely suppressed? If so, the variable need not have a usable destr...

bool isInitCapture() const

Whether this variable is the implicit variable for a lambda init-capture.

void setStorageClass(StorageClass SC)

APValue * evaluateValue() const

Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...

bool isStaticDataMember() const

Determines whether this is a static data member.

static VarDecl * CreateDeserialized(ASTContext &C, GlobalDeclID ID)

VarDecl * getTemplateInstantiationPattern() const

Retrieve the variable declaration from which this variable could be instantiated, if it is an instant...

bool hasGlobalStorage() const

Returns true for all variables that do not have local storage.

VarDeclBitfields VarDeclBits

CharUnits getFlexibleArrayInitChars(const ASTContext &Ctx) const

If hasFlexibleArrayInit is true, compute the number of additional bytes necessary to store those elem...

bool hasConstantInitialization() const

Determine whether this variable has constant initialization.

LanguageLinkage getLanguageLinkage() const

Compute the language linkage.

EvaluatedStmt * getEvaluatedStmt() const

bool mightBeUsableInConstantExpressions(const ASTContext &C) const

Determine whether this variable's value might be usable in a constant expression, according to the re...

EvaluatedStmt * ensureEvaluatedStmt() const

Convert the initializer for this declaration to the elaborated EvaluatedStmt form,...

VarDecl * getInstantiatedFromStaticDataMember() const

If this variable is an instantiated static data member of a class template specialization,...

bool isFileVarDecl() const

Returns true for file scoped variable declaration.

void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())

For a static data member that was instantiated from a static data member of a class template,...

QualType::DestructionKind needsDestruction(const ASTContext &Ctx) const

Would the destruction of this variable have any effect, and if so, what kind?

bool checkForConstantInitialization(SmallVectorImpl< PartialDiagnosticAt > &Notes) const

Evaluate the initializer of this variable to determine whether it's a constant initializer.

bool isInline() const

Whether this variable is (C++1z) inline.

const Expr * getInit() const

bool isNonEscapingByref() const

Indicates the capture is a __block variable that is never captured by an escaping block.

bool isInExternCContext() const

Determines whether this variable's context is, or is nested within, a C++ extern "C" linkage spec.

NonParmVarDeclBitfields NonParmVarDeclBits

bool hasExternalStorage() const

Returns true if a variable has extern or private_extern storage.

InitType Init

The initializer for this variable or, for a ParmVarDecl, the C++ default argument.

APValue * getEvaluatedValue() const

Return the already-evaluated value of this variable's initializer, or NULL if the value is not yet kn...

VarDecl * getInitializingDeclaration()

Get the initializing declaration of this variable, if any.

TLSKind

Kinds of thread-local storage.

@ TLS_Static

TLS with a known-constant initializer.

@ TLS_Dynamic

TLS with a dynamic initializer.

@ TLS_None

Not a TLS variable.

VarDecl * getActingDefinition()

Get the tentative definition that acts as the real definition in a TU.

@ TentativeDefinition

This declaration is a tentative definition.

@ DeclarationOnly

This declaration is only a declaration.

@ Definition

This declaration is definitely a definition.

void setDescribedVarTemplate(VarTemplateDecl *Template)

bool isExternC() const

Determines whether this variable is a variable with external, C linkage.

VarDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass SC)

StorageDuration getStorageDuration() const

Get the storage duration of this variable, per C++ [basic.stc].

StorageClass getStorageClass() const

Returns the storage class as written in the source.

bool isEscapingByref() const

Indicates the capture is a __block variable that is captured by a block that can potentially escape (...

bool isThisDeclarationADemotedDefinition() const

If this definition should pretend to be a declaration.

bool isUsableInConstantExpressions(const ASTContext &C) const

Determine whether this variable's value can be used in a constant expression, according to the releva...

bool isInExternCXXContext() const

Determines whether this variable's context is, or is nested within, a C++ extern "C++" linkage spec.

SourceLocation getPointOfInstantiation() const

If this variable is an instantiation of a variable template or a static data member of a class templa...

bool hasDependentAlignment() const

Determines if this variable's alignment is dependent.

TemplateSpecializationKind getTemplateSpecializationKindForInstantiation() const

Get the template specialization kind of this variable for the purposes of template instantiation.

VarDecl * getDefinition()

TemplateSpecializationKind getTemplateSpecializationKind() const

If this variable is an instantiation of a variable template or a static data member of a class templa...

const Expr * getAnyInitializer() const

Get the initializer for this variable, no matter which declaration it is attached to.

bool isKnownToBeDefined() const

bool isParameterPack() const

Determine whether this variable is actually a function parameter pack or init-capture pack.

MemberSpecializationInfo * getMemberSpecializationInfo() const

If this variable is an instantiation of a static data member of a class template specialization,...

Declaration of a variable template.

VarDecl * getTemplatedDecl() const

Get the underlying variable declarations of the template.

Represents a variable template specialization, which refers to a variable template with a given set o...

const TemplateArgumentList & getTemplateArgs() const

Retrieve the template arguments of the variable template specialization.

VarTemplateDecl * getSpecializedTemplate() const

Retrieve the template that this specialization specializes.

bool isExplicitInstantiationOrSpecialization() const

True if this declaration is an explicit specialization, explicit instantiation declaration,...

bool isExplicitSpecialization() const

Represents a C array with a specified size that is not an integer-constant-expression.

Defines the Linkage enumeration and various utility functions.

Defines the clang::TargetInfo interface.

const internal::VariadicAllOfMatcher< Attr > attr

Matches attributes.

const internal::VariadicAllOfMatcher< Type > type

Matches Types in the clang AST.

const internal::VariadicAllOfMatcher< Decl > decl

Matches declarations.

The JSON file list parser is used to communicate input to InstallAPI.

OverloadedOperatorKind

Enumeration specifying the different kinds of C++ overloaded operators.

@ OO_None

Not an overloaded operator.

bool isTemplateInstantiation(TemplateSpecializationKind Kind)

Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...

@ GVA_AvailableExternally

bool isReservedInAllContexts(ReservedIdentifierStatus Status)

Determine whether an identifier is reserved in all contexts.

ConstexprSpecKind

Define the kind of constexpr specifier.

Decl * getPrimaryMergedDecl(Decl *D)

Get the primary declaration for a declaration from an AST file.

InClassInitStyle

In-class initialization styles for non-static data members.

@ ICIS_NoInit

No in-class initializer.

LazyOffsetPtr< Stmt, uint64_t, &ExternalASTSource::GetExternalDeclStmt > LazyDeclStmtPtr

A lazy pointer to a statement.

Linkage getFormalLinkage(Linkage L)

LanguageLinkage

Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have.

StorageClass

Storage classes.

@ TSCS_thread_local

C++11 thread_local.

@ TSCS__Thread_local

C11 _Thread_local.

@ TSCS___thread

GNU __thread.

Linkage

Describes the different kinds of linkage (C++ [basic.link], C99 6.2.2) that an entity may have.

@ VisibleNone

No linkage according to the standard, but is visible from other translation units because of types de...

@ None

No linkage, which means that the entity is unique and can only be referred to from within its scope.

@ UniqueExternal

External linkage within a unique namespace.

@ Internal

Internal linkage, which indicates that the entity can be referred to from within the translation unit...

@ External

External linkage, which indicates that the entity can be referred to from other translation units.

@ Module

Module linkage, which indicates that the entity can be referred to from other translation units withi...

@ SD_Automatic

Automatic storage duration (most local variables).

bool isLambdaCallOperator(const CXXMethodDecl *MD)

@ Result

The result type of a method or function.

TagTypeKind

The kind of a tag type.

@ Struct

The "struct" keyword.

@ Enum

The "enum" keyword.

@ CanPassInRegs

The argument of this type can be passed directly in registers.

bool isLegalForVariable(StorageClass SC)

Checks whether the given storage class is legal for variables.

const FunctionProtoType * T

void printTemplateArgumentList(raw_ostream &OS, ArrayRef< TemplateArgument > Args, const PrintingPolicy &Policy, const TemplateParameterList *TPL=nullptr)

Print a template argument list, including the '<' and '>' enclosing the template arguments.

bool isReservedAtGlobalScope(ReservedIdentifierStatus Status)

Determine whether an identifier is reserved for use as a name at global scope.

bool isExternalFormalLinkage(Linkage L)

TemplateSpecializationKind

Describes the kind of template specialization that a particular template specialization declaration r...

@ TSK_ExplicitInstantiationDefinition

This template specialization was instantiated from a template due to an explicit instantiation defini...

@ TSK_ExplicitInstantiationDeclaration

This template specialization was instantiated from a template due to an explicit instantiation declar...

@ TSK_ExplicitSpecialization

This template specialization was declared or defined by an explicit specialization (C++ [temp....

@ TSK_ImplicitInstantiation

This template specialization was implicitly instantiated from a template.

@ TSK_Undeclared

This template specialization was formed from a template-id but has not yet been declared,...

@ Enum

The "enum" keyword introduces the elaborated-type-specifier.

bool IsArmStreamingFunction(const FunctionDecl *FD, bool IncludeLocallyStreaming)

Returns whether the given FunctionDecl has an __arm[_locally]_streaming attribute.

@ StartsWithUnderscoreAndIsExternC

bool isExternallyVisible(Linkage L)

ImplicitParamKind

Defines the kind of the implicit parameter: is this an implicit parameter with pointer to 'this',...

@ Other

Other implicit parameter.

Visibility

Describes the different kinds of visibility that a declaration may have.

@ HiddenVisibility

Objects with "hidden" visibility are not seen by the dynamic linker.

@ ProtectedVisibility

Objects with "protected" visibility are seen by the dynamic linker but always dynamically resolve to ...

@ DefaultVisibility

Objects with "default" visibility are seen by the dynamic linker and act like normal objects.

bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)

Represents an explicit template argument list in C++, e.g., the "" in "sort".

static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)

A placeholder type used to construct an empty shell of a decl-derived type that will be filled in lat...

DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...

SourceLocation getBeginLoc() const

getBeginLoc - Retrieve the location of the first token.

Structure used to store a statement, the constant value to which it was evaluated (if any),...

bool HasConstantDestruction

Whether this variable is known to have constant destruction.

bool WasEvaluated

Whether this statement was already evaluated.

bool IsEvaluating

Whether this statement is being evaluated.

bool HasConstantInitialization

Whether this variable is known to have constant initialization.

bool HasICEInit

In C++98, whether the initializer is an ICE.

bool isTypeVisibility() const

unsigned IgnoreExplicitVisibility

Whether explicit visibility attributes should be ignored.

unsigned IgnoreAllVisibility

Whether all visibility should be ignored.

static LVComputationKind forLinkageOnly()

Do an LV computation when we only care about the linkage.

bool isValueVisibility() const

bool isOffset() const

Whether this pointer is currently stored as an offset.

T * get(ExternalASTSource *Source) const

Retrieve the pointer to the AST node that this lazy pointer points to.

Describes how types, statements, expressions, and declarations should be printed.

A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...

TemplateParameterList ** TemplParamLists

A new-allocated array of size NumTemplParamLists, containing pointers to the "outer" template paramet...

NestedNameSpecifierLoc QualifierLoc

unsigned NumTemplParamLists

The number of "outer" template parameter lists.

void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)

Sets info about "outer" template parameter lists.

SanitizerMask Mask

Bitmask of enabled sanitizers.