clang: lib/Sema/SemaExprMember.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

24

25using namespace clang;

26using namespace sema;

27

29

30

31

35 return !Bases.count(Base->getCanonicalDecl());

36 };

37 return BaseIsNotInSet(Record) && Record->forallBases(BaseIsNotInSet);

38}

39

41

43

44

46

47

48

50

51

52

54

55

57

58

60

61

63

64

65

67

68

69

71

72

73

74

76

77

78

80

81

82

85

86

87

88

89

90

91

94 assert(!R.empty() && (*R.begin())->isCXXClassMember());

95

97

98 bool couldInstantiateToStatic = false;

100

101 if (auto *MD = dyn_cast(DC)) {

102 if (MD->isImplicitObjectMemberFunction()) {

103 isStaticOrExplicitContext = false;

104

105

106

107 couldInstantiateToStatic = MD->getDependentSpecializationInfo();

108 }

109 }

110

112 if (couldInstantiateToStatic)

116 }

117

118

119 bool hasNonInstance = false;

120 bool isField = false;

123

124 D = D->getUnderlyingDecl();

125

126 if (D->isCXXInstanceMember()) {

127 isField |= isa(D) || isa(D) ||

128 isa(D);

129

132 } else

133 hasNonInstance = true;

134 }

135

136

137

138 if (Classes.empty())

140

141 if (couldInstantiateToStatic)

143

144

145

146

147

148

149

150

151

152

153 IMAKind AbstractInstanceResult = IMA_Static;

154 assert(!AbstractInstanceResult);

156 case Sema::ExpressionEvaluationContext::Unevaluated:

157 case Sema::ExpressionEvaluationContext::UnevaluatedList:

158 if (isField && SemaRef.getLangOpts().CPlusPlus11)

160 break;

161

162 case Sema::ExpressionEvaluationContext::UnevaluatedAbstract:

164 break;

165

166 case Sema::ExpressionEvaluationContext::DiscardedStatement:

167 case Sema::ExpressionEvaluationContext::ConstantEvaluated:

168 case Sema::ExpressionEvaluationContext::ImmediateFunctionContext:

169 case Sema::ExpressionEvaluationContext::PotentiallyEvaluated:

170 case Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed:

171 break;

172 }

173

174

175

176 if (isStaticOrExplicitContext) {

177 if (hasNonInstance)

179

180 return AbstractInstanceResult ? AbstractInstanceResult

182 }

183

185 if (auto *MD = dyn_cast(DC))

186 contextClass = MD->getParent()->getCanonicalDecl();

187 else if (auto *RD = dyn_cast(DC))

188 contextClass = RD;

189 else

190 return AbstractInstanceResult ? AbstractInstanceResult

192

193

194

195

196

197

198

202

203

204

205 Classes.clear();

207 }

208

209

210

211

214 AbstractInstanceResult ? AbstractInstanceResult :

216

218}

219

220

228

229

231

233 CXXMethodDecl *Method = dyn_cast(FunctionLevelDC);

236

237 bool InStaticMethod = Method && Method->isStatic();

238 bool InExplicitObjectMethod =

240 bool IsField = isa(Rep) || isa(Rep);

241

242 std::string Replacement;

243 if (InExplicitObjectMethod) {

247 Replacement.append(".");

248 }

249 }

250 if (IsField && InStaticMethod)

251

252 SemaRef.Diag(Loc, diag::err_invalid_member_use_in_method)

253 << Range << nameInfo.getName() << 0;

254 else if (IsField && InExplicitObjectMethod) {

255 auto Diag = SemaRef.Diag(Loc, diag::err_invalid_member_use_in_method)

256 << Range << nameInfo.getName() << 1;

257 if (!Replacement.empty())

259 } else if (ContextClass && RepClass && SS.isEmpty() &&

260 !InExplicitObjectMethod && !InStaticMethod &&

261 !RepClass->Equals(ContextClass) &&

262 RepClass->Encloses(ContextClass))

263

264

265 SemaRef.Diag(Loc, diag::err_nested_non_static_member_use)

266 << IsField << RepClass << nameInfo.getName() << ContextClass << Range;

267 else if (IsField)

268 SemaRef.Diag(Loc, diag::err_invalid_non_static_member_use)

270 else if (!InExplicitObjectMethod)

271 SemaRef.Diag(Loc, diag::err_member_call_without_object)

272 << Range << 0;

273 else {

274 if (const auto *Tpl = dyn_cast(Rep))

275 Rep = Tpl->getTemplatedDecl();

276 const auto *Callee = cast(Rep);

277 auto Diag = SemaRef.Diag(Loc, diag::err_member_call_without_object)

278 << Range << Callee->isExplicitObjectMemberFunction();

279 if (!Replacement.empty())

281 }

282}

283

286 bool IsAddressOfOperand) {

288 return false;

290 return false;

291 else if (!IsAddressOfOperand)

292 return true;

294 return false;

296 return false;

298 return true;

299 else

300 return isa<FieldDecl, IndirectFieldDecl, MSPropertyDecl>(R.getFoundDecl());

301}

302

312 SS, TemplateKWLoc, R, TemplateArgs,

313 Classification == IMA_Instance, S);

315 Diag(R.getNameLoc(), diag::warn_cxx98_compat_non_static_member_use)

317 [[fallthrough]];

322 if (TemplateArgs || TemplateKWLoc.isValid())

324 TemplateArgs);

326 false);

332 TemplateArgs, R.begin(), R.end(), true,

333 true);

334

340 }

341

342 llvm_unreachable("unexpected instance member access kind");

343}

344

345

346static bool

348 switch (c) {

349 case 'r':

350 case 'g':

351 case 'b':

352 case 'a':

353 return true;

354 default:

355 return false;

356 }

357}

358

359

360

361

363{

364 return (len >= 1 && len <= 4) || len == 8 || len == 16;

365}

366

367

368

369

370

375

376

377

378

379

381

382

383 const char *compStr = CompName->getNameStart();

384

385

386

387

388 bool HalvingSwizzle = false;

389

390

391

392 bool HexSwizzle = (*compStr == 's' || *compStr == 'S') && compStr[1];

393

394 bool HasRepeated = false;

395 bool HasIndex[16] = {};

396

397 int Idx;

398

399

400

401 if (!strcmp(compStr, "hi") || !strcmp(compStr, "lo") ||

402 !strcmp(compStr, "even") || !strcmp(compStr, "odd")) {

403 HalvingSwizzle = true;

404 } else if (!HexSwizzle &&

406 bool HasRGBA = IsRGBA(*compStr);

407 do {

408

409 if (HasRGBA != IsRGBA(*compStr))

410 break;

411 if (HasIndex[Idx]) HasRepeated = true;

412 HasIndex[Idx] = true;

413 compStr++;

414 } while (*compStr && (Idx = vecType->getPointAccessorIdx(*compStr)) != -1);

415

416

417 if (HasRGBA || (*compStr && IsRGBA(*compStr))) {

420 const char *DiagBegin = HasRGBA ? CompName->getNameStart() : compStr;

421 S.Diag(OpLoc, diag::ext_opencl_ext_vector_type_rgba_selector)

422 << StringRef(DiagBegin, 1) << SourceRange(CompLoc);

423 }

424 }

425 } else {

426 if (HexSwizzle) compStr++;

428 if (HasIndex[Idx]) HasRepeated = true;

429 HasIndex[Idx] = true;

430 compStr++;

431 }

432 }

433

434 if (!HalvingSwizzle && *compStr) {

435

436

437 size_t Offset = compStr - CompName->getNameStart() + 1;

438 char Fmt[3] = {'\'', *compStr, '\''};

440 diag::err_ext_vector_component_name_illegal)

441 << StringRef(Fmt, 3) << SourceRange(CompLoc);

443 }

444

445

446

447 if (!HalvingSwizzle) {

449

450 if (HexSwizzle)

451 compStr++;

452

453 while (*compStr) {

455 S.Diag(OpLoc, diag::err_ext_vector_component_exceeds_length)

458 }

459 }

460 }

461

462

463

464 if (S.getLangOpts().OpenCL && !HalvingSwizzle) {

465 unsigned SwizzleLength = CompName->getLength();

466

467 if (HexSwizzle)

468 SwizzleLength--;

469

471 S.Diag(OpLoc, diag::err_opencl_ext_vector_component_invalid_length)

472 << SwizzleLength << SourceRange(CompLoc);

474 }

475 }

476

477

478

479

480

481

482 unsigned CompSize = HalvingSwizzle ? (vecType->getNumElements() + 1) / 2

484 if (HexSwizzle)

485 CompSize--;

486

487 if (CompSize == 1)

489

490 if (HasRepeated)

492

494

495

496 for (Sema::ExtVectorDeclsType::iterator

499 I != E; ++I) {

500 if ((*I)->getUnderlyingType() == VT)

502 }

503

504 return VT;

505}

506

514 return PD;

516 return OMD;

517

518 for (const auto *I : PDecl->protocols()) {

520 Context))

521 return D;

522 }

523 return nullptr;

524}

525

530

531 Decl *GDecl = nullptr;

532 for (const auto *I : QIdTy->quals()) {

536 GDecl = PD;

537 break;

538 }

539

540 if (ObjCMethodDecl *OMD = I->getInstanceMethod(Sel)) {

541 GDecl = OMD;

542 break;

543 }

544 }

545 if (!GDecl) {

546 for (const auto *I : QIdTy->quals()) {

547

549 if (GDecl)

550 return GDecl;

551 }

552 }

553 return GDecl;

554}

555

561 NamedDecl *FirstQualifierInScope,

564

565

566

567

568

569

570

571

572

573 if (!IsArrow) {

577 assert(BaseExpr && "cannot happen with implicit member accesses");

578 Diag(OpLoc, diag::err_typecheck_member_reference_struct_union)

581 }

582 }

583

586 (TemplateArgs && llvm::any_of(TemplateArgs->arguments(),

588 return Arg.getArgument().isDependent();

589 })));

590

591

592

594 Context, BaseExpr, BaseType, IsArrow, OpLoc,

596 NameInfo, TemplateArgs);

597}

598

599

600

601

603 Expr *BaseExpr,

608

609

610 if (!BaseExpr)

612

613 SemaRef.Diag(nameInfo.getLoc(), diag::err_qualified_member_of_unrelated)

614 << SS.getRange() << rep << BaseType;

615}

616

623 if (!BaseRecord) {

624

625

627 return false;

628 }

629

631

632

633 if (!BaseExpr && !(*I)->isCXXInstanceMember())

634 return false;

635

636

639 continue;

640

644 return false;

645 }

646

650 return true;

651}

652

653namespace {

654

655

656

657

659public:

660 explicit RecordMemberExprValidatorCCC(QualType RTy)

662

663

664 WantTypeSpecifiers = false;

665 WantExpressionKeywords = false;

666 WantCXXNamedCasts = false;

667 WantFunctionLikeCasts = false;

668 WantRemainingKeywords = false;

669 }

670

671 bool ValidateCandidate(const TypoCorrection &candidate) override {

673

674

675 if (!ND || !(isa(ND) || isa(ND)))

676 return false;

677

678

679 if (Record->containsDecl(ND))

680 return true;

681

682 if (const auto *RD = dyn_cast(Record)) {

683

684 for (const auto &BS : RD->bases()) {

685 if (const auto *BSTy = BS.getType()->getAs<RecordType>()) {

686 if (BSTy->getDecl()->containsDecl(ND))

687 return true;

688 }

689 }

690 }

691

692 return false;

693 }

694

695 std::unique_ptr clone() override {

696 return std::make_unique(*this);

697 }

698

699private:

701};

702

703}

704

715 OpLoc, RTy, diag::err_typecheck_incomplete_tag, BaseRange))

716 return true;

717

718

719

721 if (HasTemplateArgs || TemplateKWLoc.isValid())

723 nullptr, SS, ObjectType,

724 false, TemplateKWLoc);

725

727

729 return false;

730

733

736

737 struct QueryState {

738 Sema &SemaRef;

742 };

745 RecordMemberExprValidatorCCC CCC(RTy);

749 if (TC) {

750 assert(!TC.isKeyword() &&

751 "Got a keyword as a correction for a member!");

752 bool DroppedSpecifier =

753 TC.WillReplaceSpecifier() &&

754 Typo.getAsString() == TC.getAsString(SemaRef.getLangOpts());

755 SemaRef.diagnoseTypo(TC, SemaRef.PDiag(diag::err_no_member_suggest)

756 << Typo << DC << DroppedSpecifier

757 << SS.getRange());

758 } else {

759 SemaRef.Diag(TypoLoc, diag::err_no_member)

760 << Typo << DC << (SS.isSet() ? SS.getRange() : BaseRange);

761 }

762 },

764 LookupResult R(Q.SemaRef, Q.NameInfo, Q.LookupKind, Q.Redecl);

765 R.clear();

766 R.suppressDiagnostics();

767 R.setLookupName(TC.getCorrection());

769 R.addDecl(ND);

770 R.resolveKind();

772 BaseExpr, BaseExpr->getType(), OpLoc, IsArrow, SS, SourceLocation(),

773 nullptr, R, nullptr, nullptr);

774 },

776

777 return false;

778}

779

783 Decl *ObjCImpDecl, bool HasTemplateArgs,

785

793

794

797 QualType RecordTy = BaseType;

800 SS, TemplateArgs != nullptr, TemplateKWLoc,

801 TE))

803 if (TE)

804 return TE;

805

806

807 } else {

811 ExtraArgs ? ExtraArgs->ObjCImpDecl : nullptr,

812 TemplateArgs != nullptr, TemplateKWLoc);

813

817

818 if (Result.isInvalid())

820

823

824

825 BaseType = Base->getType();

826 }

827

828

829

832

834 OpLoc, IsArrow, SS, TemplateKWLoc,

835 FirstQualifierInScope, R, TemplateArgs, S,

836 false, ExtraArgs);

837}

838

844 Expr *baseObjectExpr,

846

847

848

851 if (baseVariable) {

853

854

855

856

857

858

859 assert(!baseObjectExpr && "anonymous struct/union is static data member?");

860

862

866

867 baseObjectExpr = result.get();

868 }

869

870 assert((baseVariable || baseObjectExpr) &&

871 "referencing anonymous struct/union without a base variable or "

872 "expression");

873

874

875

876 Expr *result = baseObjectExpr;

879

880

881

882 if (!baseVariable) {

883 FieldDecl *field = cast(*FI);

884

886

887

889

890

891 result =

893 SS, field, foundDecl, memberNameInfo)

895 if (!result)

897 }

898

899

900 ++FI;

901

902 while (FI != FEnd) {

903 FieldDecl *field = cast(*FI++);

904

905

909

910 result =

912 (FI == FEnd ? SS : EmptySS), field,

913 fakeFoundDecl, memberNameInfo)

915 }

916

917 return result;

918}

919

925

926

931}

932

939 assert((!IsArrow || Base->isPRValue()) &&

940 "-> base must be a pointer prvalue");

943 Member, FoundDecl, MemberNameInfo, TemplateArgs, Ty,

945 E->setHadMultipleCandidates(HadMultipleCandidates);

947

948

949

950

951

956 }

957 }

958

959 return E;

960}

961

962

964

965

966

967 for (; S != S->getFnParent(); S = S->getParent()) {

968 if (S->isFnTryCatchScope())

970 }

971 return false;

972}

973

979 NamedDecl *FirstQualifierInScope,

983 bool SuppressQualifierCheck,

985 assert(!SS.isInvalid() && "nested-name-specifier cannot be invalid");

986

987

988

994 TemplateKWLoc, FirstQualifierInScope,

996

997 QualType BaseType = BaseExprType;

998 if (IsArrow) {

1001 }

1003

1007 "dependent lookup context that isn't the current instantiation?");

1008

1012

1015

1016

1017

1018

1020 if (S && BaseExpr && FD &&

1021 (isa(FD) || isa(FD)) &&

1024 Diag(MemberLoc, diag::warn_cdtor_function_try_handler_mem_expr)

1025 << isa(FD);

1026

1027 if (R.empty()) {

1029 if (ExtraArgs && !IsArrow && BaseExpr && !BaseExpr->isTypeDependent()) {

1032 bool MayBePseudoDestructor = false;

1034 tok::arrow, ObjectType,

1035 MayBePseudoDestructor);

1039 ExtraArgs->S, RetryExpr.get(), OpLoc, tok::arrow, TempSS,

1040 TemplateKWLoc, ExtraArgs->Id, ExtraArgs->ObjCImpDecl);

1041 }

1044 }

1045

1046

1049 assert(DC);

1050

1052 Diag(OpLoc, diag::err_no_member_overloaded_arrow)

1054 else

1056 << MemberName << DC

1060 return RetryExpr;

1061 }

1062

1063

1064

1065

1066

1067

1068

1069

1070 if ((SS.isSet() || !BaseExpr ||

1071 (isa(BaseExpr) &&

1072 cast(BaseExpr)->isImplicit())) &&

1073 !SuppressQualifierCheck &&

1076

1077

1078

1080

1081

1083

1086 BaseExpr, BaseExprType,

1087 IsArrow, OpLoc,

1089 TemplateKWLoc, MemberNameInfo,

1090 TemplateArgs, R.begin(), R.end());

1091

1092 return MemExpr;

1093 }

1094

1098

1099

1100

1101

1102

1103

1106

1107

1108 if (!BaseExpr) {

1109

1111

1112

1113 if (TemplateArgs || TemplateKWLoc.isValid())

1114 return BuildTemplateIdExpr(SS, TemplateKWLoc, R, false, TemplateArgs);

1115

1117 FoundDecl, TemplateArgs);

1118 }

1123 }

1124

1125

1126

1127

1128

1129

1130 auto ConvertBaseExprToDiscardedValue = [&] {

1132 "Static member / member enumerator outside of C++");

1133 if (IsArrow)

1134 return false;

1137 return true;

1138 BaseExpr = Converted.get();

1140 return false;

1141 };

1142 auto ConvertBaseExprToGLValue = [&] {

1143 if (IsArrow || !BaseExpr->isPRValue())

1144 return false;

1147 return true;

1148 BaseExpr = Converted.get();

1149 return false;

1150 };

1151

1152

1155

1156 if (FieldDecl *FD = dyn_cast(MemberDecl)) {

1157 if (ConvertBaseExprToGLValue())

1160 MemberNameInfo);

1161 }

1162

1163 if (MSPropertyDecl *PD = dyn_cast(MemberDecl)) {

1164

1165

1166

1167

1168

1170 MemberNameInfo);

1171 }

1172

1173 if (IndirectFieldDecl *FD = dyn_cast(MemberDecl)) {

1174 if (ConvertBaseExprToGLValue())

1176

1177

1179 FoundDecl, BaseExpr,

1180 OpLoc);

1181 }

1182

1183

1184 if (VarDecl *Var = dyn_cast(MemberDecl)) {

1185 if (ConvertBaseExprToDiscardedValue())

1189 FoundDecl, false,

1190 MemberNameInfo, Var->getType().getNonReferenceType(),

1192 }

1193

1194 if (CXXMethodDecl *MemberFn = dyn_cast(MemberDecl)) {

1197 if (MemberFn->isInstance()) {

1200 if (MemberFn->isImplicitObjectMemberFunction() &&

1201 ConvertBaseExprToGLValue())

1203 } else {

1204

1205 if (ConvertBaseExprToDiscardedValue())

1208 type = MemberFn->getType();

1209 }

1210

1213 MemberFn, FoundDecl, false,

1215 }

1216 assert(!isa(MemberDecl) && "member function not C++ method?");

1217

1219 if (ConvertBaseExprToDiscardedValue())

1223 TemplateKWLoc, Enum, FoundDecl, false,

1225 }

1226

1227 if (VarTemplateDecl *VarTempl = dyn_cast(MemberDecl)) {

1228 if (ConvertBaseExprToDiscardedValue())

1230 if (!TemplateArgs) {

1232 SS, TemplateKWLoc.isValid(), VarTempl, MemberLoc);

1234 }

1235

1237 MemberNameInfo.getLoc(), *TemplateArgs);

1240

1241

1242 if (!VDecl.get())

1244 BaseExpr, BaseExpr->getType(), IsArrow, OpLoc, SS, TemplateKWLoc,

1245 FirstQualifierInScope, MemberNameInfo, TemplateArgs);

1246

1247 VarDecl *Var = cast(VDecl.get());

1250

1253 FoundDecl, false,

1256 }

1257

1258

1259 if (isa(MemberDecl))

1260 Diag(MemberLoc, diag::err_typecheck_member_reference_type)

1261 << MemberName << BaseType << int(IsArrow);

1262 else

1263 Diag(MemberLoc, diag::err_typecheck_member_reference_unknown)

1264 << MemberName << BaseType << int(IsArrow);

1265

1266 Diag(MemberDecl->getLocation(), diag::note_member_declared_here)

1267 << MemberName;

1270}

1271

1272

1273

1274

1275

1276

1277

1281 if (!opty) return false;

1282

1284

1290 } else {

1291 return false;

1292 }

1293

1294

1295

1298 return false;

1299

1301 return true;

1302}

1303

1306}

1309 return PT->getPointeeType()->isRecordType();

1310 return false;

1311}

1312

1315 if (IsArrow && Base->getType()->isFunctionType())

1317

1319}

1320

1321

1322

1323

1324

1325

1326

1327

1328

1329

1330

1332 ExprResult &BaseExpr, bool &IsArrow,

1334 Decl *ObjCImpDecl, bool HasTemplateArgs,

1336 assert(BaseExpr.get() && "no base expression");

1337

1338

1342

1344

1347

1348

1349

1350

1351

1352 if (IsArrow) {

1359 goto fail;

1363

1364

1365

1366

1367

1368

1369

1371 S.Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)

1374 }

1375 IsArrow = false;

1376 } else {

1377 S.Diag(MemberLoc, diag::err_typecheck_member_reference_arrow)

1380 }

1381 }

1382

1383

1384

1385

1386

1387

1390 S.PDiag(diag::warn_atomic_member_access));

1391 BaseType = ATy->getValueType().getUnqualifiedType();

1394 CK_AtomicToNonAtomic, BaseExpr.get(), nullptr,

1396 }

1397

1398

1402 SS, HasTemplateArgs, TemplateKWLoc, TE))

1404

1405

1406

1407

1408

1413 }

1414

1415

1422 }

1423

1425

1426

1427

1428

1429

1431 if (!IDecl) {

1433 (OTy->isObjCId() || OTy->isObjCClass()))

1434 goto fail;

1435

1436

1437

1438 if (OTy->isObjCId() && Member->isStr("isa"))

1443 ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);

1444 goto fail;

1445 }

1446

1448 diag::err_typecheck_incomplete_tag,

1449 BaseExpr.get()))

1451

1454

1455 if (!IV) {

1456

1462 IV = Corrected.getCorrectionDeclAs<ObjCIvarDecl>();

1464 Corrected,

1465 S.PDiag(diag::err_typecheck_member_reference_ivar_suggest)

1467

1468

1469 assert(!ClassDeclared);

1470

1472 if (auto *Category = dyn_cast(D))

1473 D = Category->getClassInterface();

1474

1475 if (auto *Implementation = dyn_cast(D))

1476 ClassDeclared = Implementation->getClassInterface();

1477 else if (auto *Interface = dyn_cast(D))

1479

1480 assert(ClassDeclared && "cannot query interface");

1481 } else {

1482 if (IsArrow &&

1485 S.Diag(MemberLoc, diag::err_property_found_suggest)

1489 }

1490

1491 S.Diag(MemberLoc, diag::err_typecheck_member_reference_ivar)

1495 }

1496 }

1497

1498 assert(ClassDeclared);

1499

1500

1501

1502

1505

1506

1513 ClassOfMethodDecl = MD->getClassInterface();

1515

1516

1517

1518

1519

1520

1522 dyn_cast(ObjCImpDecl))

1523 ClassOfMethodDecl = IMPD->getClassInterface();

1525 dyn_cast(ObjCImpDecl))

1526 ClassOfMethodDecl = CatImplClass->getClassInterface();

1527 }

1532 S.Diag(MemberLoc, diag::err_private_ivar_access)

1534 } else if (!IDecl->isSuperClassOf(ClassOfMethodDecl))

1535

1536 S.Diag(MemberLoc, diag::err_protected_ivar_access)

1538 }

1539 }

1540 bool warn = true;

1543 if (UnaryOperator *UO = dyn_cast(BaseExp))

1544 if (UO->getOpcode() == UO_Deref)

1546

1547 if (DeclRefExpr *DE = dyn_cast(BaseExp))

1549 S.Diag(DE->getLocation(), diag::err_arc_weak_ivar_access);

1550 warn = false;

1551 }

1552 }

1553 if (warn) {

1558 }

1559 if (warn)

1560 S.Diag(MemberLoc, diag::warn_direct_ivar_access) << IV->getDeclName();

1561 }

1562

1564 IV, IV->getUsageType(BaseType), MemberLoc, OpLoc, BaseExpr.get(),

1565 IsArrow);

1566

1569 !S.Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, MemberLoc))

1571 }

1572

1574 }

1575

1576

1583 }

1584

1585

1589

1592

1594

1596

1597

1599

1601 if (Decl *PMDecl =

1603 if (ObjCPropertyDecl *PD = dyn_cast(PMDecl)) {

1604

1607

1611 }

1612

1613 if (ObjCMethodDecl *OMD = dyn_cast(PMDecl)) {

1620 nullptr,

1622 SMD = dyn_cast(SDecl);

1623

1627 }

1628 }

1629

1630

1633 ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);

1634

1635 return ExprError(S.Diag(MemberLoc, diag::err_property_not_found)

1636 << MemberName << BaseType);

1637 }

1638

1639

1641

1643 if (!MD) {

1646 ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);

1647

1648 goto fail;

1649 }

1650

1651

1654 if (!IFace)

1655 goto fail;

1656

1659

1662 } else

1664

1665

1671 if (!Setter) {

1672

1673

1675 }

1676

1679

1680 if (Getter || Setter) {

1684 }

1685

1688 ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);

1689

1690 return ExprError(S.Diag(MemberLoc, diag::err_property_not_found)

1691 << MemberName << BaseType);

1692 }

1693

1694

1696 OPT, BaseExpr.get(), OpLoc, MemberName, MemberLoc, SourceLocation(),

1698 }

1699

1701

1702

1703

1704 S.Diag(R.getNameLoc(), diag::err_ext_vector_component_name_illegal)

1705 << MemberName

1708 }

1709

1710

1712

1722

1725 }

1726

1727

1728

1734 ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);

1735 }

1736

1737

1738 fail:

1739

1740

1741

1742

1743

1744

1745

1746

1748 if (!IsArrow && Ptr->getPointeeType()->isRecordType() &&

1750 S.Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)

1753

1756

1757

1758 IsArrow = true;

1760 ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);

1761 }

1762 }

1763

1764

1765

1767 BaseExpr, S.PDiag(diag::err_member_reference_needs_call),

1768 false,

1774 ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);

1775 }

1776

1777

1778

1783 return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS, ObjCImpDecl,

1784 HasTemplateArgs, TemplateKWLoc);

1785 }

1786

1787 S.Diag(OpLoc, diag::err_typecheck_member_reference_struct_union)

1789

1791}

1792

1798

1801 Diag(Id.getSourceRange().getBegin(),

1802 diag::ext_ms_explicit_constructor_call);

1803

1805

1806

1810 NameInfo, TemplateArgs);

1811

1812 bool IsArrow = (OpKind == tok::arrow);

1813

1815 return ExprError(Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 2);

1816

1817 NamedDecl *FirstQualifierInScope

1819

1820

1824

1827 Base, Base->getType(), OpLoc, IsArrow, SS, TemplateKWLoc,

1828 FirstQualifierInScope, NameInfo, TemplateArgs, S, &ExtraArgs);

1829

1830 if (!Res.isInvalid() && isa(Res.get()))

1831 CheckMemberAccessOfNoDeref(cast(Res.get()));

1832

1833 return Res;

1834}

1835

1836void Sema::CheckMemberAccessOfNoDeref(const MemberExpr *E) {

1838 return;

1839

1841

1842

1843

1844

1845

1846

1847

1849 if (E->isArrow()) {

1850

1851

1852

1853

1854

1855

1856 CheckAddressOfNoDeref(E->getBase());

1857 }

1858 } else if (E->isArrow()) {

1859 if (const auto *Ptr = dyn_cast(

1861 if (Ptr->getPointeeType()->hasAttr(attr::NoDeref))

1863 }

1864 }

1865}

1866

1872

1873

1874

1875

1878 if (!IsArrow) {

1881 else

1883 }

1884 if (VK != VK_PRValue && Field->isBitField())

1886

1887

1888 QualType MemberType = Field->getType();

1892 } else {

1895

1897

1898

1900

1901

1902

1903 if (Field->isMutable()) BaseQuals.removeConst();

1904

1907

1909

1910 Qualifiers Combined = BaseQuals + MemberQuals;

1911 if (Combined != MemberQuals)

1913

1914

1915

1916

1917

1918 if (BaseType->hasAttr(attr::NoDeref))

1919 MemberType =

1921 }

1922

1923 auto isDefaultedSpecialMember = [this](const DeclContext *Ctx) {

1924 auto *Method = dyn_cast(CurContext);

1925 if (!Method || !Method->isDefaulted())

1926 return false;

1927

1929 };

1930

1931

1932 if (!isDefaultedSpecialMember(CurContext))

1934

1936 FoundDecl, Field);

1937 if (Base.isInvalid())

1939

1940

1941

1944 isa(Base.get()->IgnoreParenImpCasts())) {

1945 if (auto *PrivateCopy = OpenMP().isOpenMPCapturedDecl(Field)) {

1947 MemberNameInfo.getLoc());

1948 }

1949 }

1950

1953 SourceLocation(), Field, FoundDecl,

1954 false, MemberNameInfo, MemberType, VK, OK);

1955}

1956

1962 bool IsKnownInstance, const Scope *S) {

1964

1966

1967

1968

1970 assert(!ThisTy.isNull() && "didn't correctly pre-flight capture of 'this'");

1971

1972 Expr *baseExpr = nullptr;

1973 if (IsKnownInstance) {

1977 baseExpr = BuildCXXThisExpr(loc, ThisTy, true);

1978 }

1979

1981 baseExpr, ThisTy,

1984 nullptr, R, TemplateArgs, S);

1985}

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

Defines the C++ template declaration subclasses.

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

static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)

Produce a diagnostic highlighting some portion of a literal.

llvm::MachO::Record Record

Defines the clang::Preprocessor interface.

RedeclarationKind

Specifies whether (or how) name lookup is being performed for a redeclaration (vs.

static RecordDecl * getAsRecordDecl(QualType BaseType)

static bool ShouldTryAgainWithRedefinitionType(Sema &S, ExprResult &base)

Given that normal member access failed on the given expression, and given that the expression's type ...

static bool isPointerToRecordType(QualType T)

static Decl * FindGetterSetterNameDeclFromProtocolList(const ObjCProtocolDecl *PDecl, IdentifierInfo *Member, const Selector &Sel, ASTContext &Context)

@ IMA_Mixed_Unrelated

The reference may be to an instance member, but it is invalid if so, because the context is from an u...

@ IMA_Mixed

The reference may be an implicit instance member access.

@ IMA_Error_Unrelated

All possible referrents are instance members of an unrelated class.

@ IMA_Unresolved

The reference may be to an unresolved using declaration.

@ IMA_Abstract

The reference is a contextually-permitted abstract member reference.

@ IMA_Mixed_StaticOrExplicitContext

The reference may be to an instance member, but it might be invalid if so, because the context is not...

@ IMA_Instance

The reference is definitely an implicit instance member access.

@ IMA_Error_StaticOrExplicitContext

All possible referrents are instance members and the current context is not an instance method.

@ IMA_Unresolved_StaticOrExplicitContext

The reference may be to an unresolved using declaration and the context is not an instance method.

@ IMA_Dependent

Whether the context is static is dependent on the enclosing template (i.e.

@ IMA_Field_Uneval_Context

@ IMA_Static

The reference is definitely not an instance member access.

static bool isProvablyNotDerivedFrom(Sema &SemaRef, CXXRecordDecl *Record, const BaseSet &Bases)

Determines if the given class is provably not derived from all of the prospective base classes.

static void diagnoseInstanceReference(Sema &SemaRef, const CXXScopeSpec &SS, NamedDecl *Rep, const DeclarationNameInfo &nameInfo)

Diagnose a reference to a field with no object available.

static bool isRecordType(QualType T)

static QualType CheckExtVectorComponent(Sema &S, QualType baseType, ExprValueKind &VK, SourceLocation OpLoc, const IdentifierInfo *CompName, SourceLocation CompLoc)

Check an ext-vector component access expression.

llvm::SmallPtrSet< const CXXRecordDecl *, 4 > BaseSet

static Decl * FindGetterSetterNameDecl(const ObjCObjectPointerType *QIdTy, IdentifierInfo *Member, const Selector &Sel, ASTContext &Context)

static void DiagnoseQualifiedMemberReference(Sema &SemaRef, Expr *BaseExpr, QualType BaseType, const CXXScopeSpec &SS, NamedDecl *rep, const DeclarationNameInfo &nameInfo)

We know that the given qualified member reference points only to declarations which do not belong to ...

static bool IsValidOpenCLComponentSwizzleLength(unsigned len)

static ExprResult BuildMSPropertyRefExpr(Sema &S, Expr *BaseExpr, bool IsArrow, const CXXScopeSpec &SS, MSPropertyDecl *PD, const DeclarationNameInfo &NameInfo)

static bool IsRGBA(char c)

Determine whether input char is from rgba component set.

static bool LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R, Expr *BaseExpr, QualType RTy, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, bool HasTemplateArgs, SourceLocation TemplateKWLoc, TypoExpr *&TE)

static IMAKind ClassifyImplicitMemberAccess(Sema &SemaRef, const LookupResult &R)

The given lookup names class member(s) and is not being used for an address-of-member expression.

static ExprResult LookupMemberExpr(Sema &S, LookupResult &R, ExprResult &BaseExpr, bool &IsArrow, SourceLocation OpLoc, CXXScopeSpec &SS, Decl *ObjCImpDecl, bool HasTemplateArgs, SourceLocation TemplateKWLoc)

Look up the given member of the given non-type-dependent expression.

static bool IsInFnTryBlockHandler(const Scope *S)

Determine if the given scope is within a function-try-block handler.

This file declares semantic analysis for Objective-C.

This file declares semantic analysis for OpenMP constructs and clauses.

static QualType getPointeeType(const MemRegion *R)

__device__ __2f16 float c

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

QualType getObjCClassType() const

Represents the Objective-C Class type.

QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const

CanQualType getCanonicalType(QualType T) const

Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...

QualType getObjCSelRedefinitionType() const

Retrieve the type that 'SEL' has been defined to, which may be different from the built-in 'SEL' if '...

QualType getPointerType(QualType T) const

Return the uniqued reference to the type for a pointer to the specified type.

CanQualType BoundMemberTy

CanQualType PseudoObjectTy

QualType getQualifiedType(SplitQualType split) const

Un-split a SplitQualType.

bool hasSameUnqualifiedType(QualType T1, QualType T2) const

Determine whether the given types are equivalent after cvr-qualifiers have been removed.

QualType getObjCClassRedefinitionType() const

Retrieve the type that Class has been defined to, which may be different from the built-in Class if C...

QualType getObjCIdRedefinitionType() const

Retrieve the type that id has been defined to, which may be different from the built-in id if id has ...

QualType getExtVectorType(QualType VectorType, unsigned NumElts) const

Return the unique reference to an extended vector type of the specified element type and size.

QualType getTypedefType(const TypedefNameDecl *Decl, QualType Underlying=QualType()) const

Return the unique reference to the type for the specified typedef-name decl.

static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)

Represents a static or instance method of a struct/union/class.

bool isExplicitObjectMemberFunction() const

[C++2b][dcl.fct]/p7 An explicit object member function is a non-static member function with an explic...

const CXXRecordDecl * getParent() const

Return the parent of this method declaration, which is the class in which this method is defined.

Represents a C++ struct/union/class.

bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const

Determine whether this class is provably not derived from the type Base.

CXXRecordDecl * getCanonicalDecl() override

Retrieves the "canonical" declaration of the given declaration.

Represents a C++ nested-name-specifier or a global scope specifier.

SourceRange getRange() const

bool isSet() const

Deprecated.

NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const

Retrieve a nested-name-specifier with location information, copied into the given AST context.

NestedNameSpecifier * getScopeRep() const

Retrieve the representation of the nested-name-specifier.

bool isInvalid() const

An error occurred during parsing of the scope specifier.

bool isEmpty() const

No scope specifier.

Qualifiers getQualifiers() const

Retrieve all qualifiers.

Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...

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

static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)

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.

bool isDependentContext() const

Determines whether this context is dependent on a template parameter.

bool Encloses(const DeclContext *DC) const

Determine whether this declaration context encloses the declaration context DC.

DeclContext * getNonTransparentContext()

Simple template class for restricting typo correction candidates to ones having a single Decl* of the...

A reference to a declared variable, function, enum, etc.

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

bool isInvalidDecl() const

SourceLocation getLocation() const

DeclContext * getDeclContext()

AccessSpecifier getAccess() const

The name of a declaration.

IdentifierInfo * getAsIdentifierInfo() const

Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...

bool isDependentName() const

Determines whether the name itself is dependent, e.g., because it involves a C++ type that is itself ...

std::string getAsString() const

Retrieve the human-readable string for this name.

OverloadedOperatorKind getCXXOverloadedOperator() const

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

NameKind getNameKind() const

Determine what kind of name this is.

bool isEmpty() const

Evaluates true when this declaration name is empty.

bool isIgnored(unsigned DiagID, SourceLocation Loc) const

Determine whether the diagnostic is known to be ignored.

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

This represents one expression.

Expr * IgnoreParenCasts() LLVM_READONLY

Skip past any parentheses and casts which might surround this expression until reaching a fixed point...

ExprValueKind getValueKind() const

getValueKind - The value kind that this expression produces.

bool isTypeDependent() const

Determines whether the type of this expression depends on.

Expr * IgnoreParenImpCasts() LLVM_READONLY

Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...

ExprObjectKind getObjectKind() const

getObjectKind - The object kind that this expression produces.

Expr * IgnoreImpCasts() LLVM_READONLY

Skip past any implicit casts which might surround this expression until reaching a fixed point.

ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...

ExtVectorType - Extended vector type.

bool isAccessorWithinNumElements(char c, bool isNumericAccessor) const

static int getNumericAccessorIdx(char c)

static int getPointAccessorIdx(char c)

Represents difference between two FPOptions values.

Represents a member of a struct/union/class.

static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)

Create a code modification hint that replaces the given source range with the given code string.

static FixItHint CreateRemoval(CharSourceRange RemoveRange)

Create a code modification hint that removes the given source range.

static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)

Create a code modification hint that inserts the given code string at a specific location.

const ParmVarDecl * getParamDecl(unsigned i) const

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

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

unsigned getLength() const

Efficiently return the length of this identifier info.

const char * getNameStart() const

Return the beginning of the actual null-terminated string for this identifier.

static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)

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

chain_iterator chain_end() const

chain_iterator chain_begin() const

VarDecl * getVarDecl() const

ArrayRef< NamedDecl * >::const_iterator chain_iterator

unsigned getOpenCLCompatibleVersion() const

Return the OpenCL version that kernel language is compatible with.

iterator begin(Source *source, bool LocalOnly=false)

Represents the results of name lookup.

RedeclarationKind redeclarationKind() const

bool wasNotFoundInCurrentInstantiation() const

Determine whether no result was found because we could not search into dependent base classes of the ...

bool isUnresolvableResult() const

void setBaseObjectType(QualType T)

Sets the base object type for this lookup.

bool empty() const

Return true if no decls were found.

bool isOverloadedResult() const

Determines if the results are overloaded.

SourceLocation getNameLoc() const

Gets the location of the identifier.

NamedDecl * getFoundDecl() const

Fetch the unique decl found by this lookup.

bool isSingleResult() const

Determines if this names a single result which is not an unresolved value using decl.

CXXRecordDecl * getNamingClass() const

Returns the 'naming class' for this lookup, i.e.

Sema::LookupNameKind getLookupKind() const

Gets the kind of lookup to perform.

Sema & getSema() const

Get the Sema object that this lookup result is searching with.

NamedDecl * getRepresentativeDecl() const

Fetches a representative decl. Useful for lazy diagnostics.

void suppressDiagnostics()

Suppress the diagnostics that would normally fire because of this lookup.

DeclarationName getLookupName() const

Gets the name to look up.

void setNotFoundInCurrentInstantiation()

Note that while no result was found in the current instantiation, there were dependent base classes t...

const DeclarationNameInfo & getLookupNameInfo() const

Gets the name info to look up.

An instance of this class represents the declaration of a property member.

A member reference to an MSPropertyDecl.

MemberExpr - [C99 6.5.2.3] Structure and Union Members.

static MemberExpr * Create(const ASTContext &C, Expr *Base, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *MemberDecl, DeclAccessPair FoundDecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, QualType T, ExprValueKind VK, ExprObjectKind OK, NonOdrUseReason NOUR)

This represents a decl that may have a name.

NamedDecl * getUnderlyingDecl()

Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.

DeclarationName getDeclName() const

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

bool isCXXInstanceMember() const

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

bool isCXXClassMember() const

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

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

bool isDependent() const

Whether this nested name specifier refers to a dependent type or not.

ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.

ObjCPropertyDecl * FindPropertyDeclaration(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const

FindPropertyDeclaration - Finds declaration of the property given its name in 'PropertyId' and return...

ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const

ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...

Represents an ObjC class declaration.

ObjCMethodDecl * lookupClassMethod(Selector Sel) const

Lookup a class method for a given selector.

ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)

ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const

Lookup a method in the classes implementation hierarchy.

bool isSuperClassOf(const ObjCInterfaceDecl *I) const

isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...

ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.

ObjCIvarDecl - Represents an ObjC instance variable.

AccessControl getAccessControl() const

QualType getUsageType(QualType objectType) const

Retrieve the type of this instance variable when viewed as a member of a specific object type.

ObjCIvarRefExpr - A reference to an ObjC instance variable.

ObjCMethodDecl - Represents an instance or class method declaration.

ObjCInterfaceDecl * getClassInterface()

Represents a pointer to an Objective C object.

const ObjCObjectType * getObjectType() const

Gets the type pointed to by this ObjC pointer.

Represents a class type in Objective C.

ObjCInterfaceDecl * getInterface() const

Gets the interface declaration for this object type, if the base type really is an interface.

Represents one property declaration in an Objective-C interface.

ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.

Represents an Objective-C protocol declaration.

protocol_range protocols() const

PointerType - C99 6.7.5.1 - Pointer Declarators.

QualType getPointeeType() const

IdentifierTable & getIdentifierTable()

SelectorTable & getSelectorTable()

A (possibly-)qualified type.

QualType getDesugaredType(const ASTContext &Context) const

Return the specified type with any "sugar" removed from the type.

bool isNull() const

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

Qualifiers getQualifiers() const

Retrieve the set of qualifiers applied to this type.

Qualifiers::ObjCLifetime getObjCLifetime() const

Returns lifetime attribute of this type.

QualType getNonReferenceType() const

If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...

The collection of all-type qualifiers we support.

@ OCL_Weak

Reading or writing from this object requires a barrier call.

bool hasAddressSpace() const

Represents a struct/union/class.

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

Base for LValueReferenceType and RValueReferenceType.

Scope - A scope is a transient data structure that is used while parsing the program.

@ TryScope

This is the scope of a C++ try statement.

static Selector constructSetterSelector(IdentifierTable &Idents, SelectorTable &SelTable, const IdentifierInfo *Name)

Return the default setter selector for the given identifier.

Selector getNullarySelector(const IdentifierInfo *ID)

Smart pointer class that efficiently represents Objective-C method names.

SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)

Emit a diagnostic.

PartialDiagnostic PDiag(unsigned DiagID=0)

Build a partial diagnostic.

ExprResult HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, Expr *BaseExpr, SourceLocation OpLoc, DeclarationName MemberName, SourceLocation MemberLoc, SourceLocation SuperLoc, QualType SuperType, bool Super)

HandleExprPropertyRefExpr - Handle foo.bar where foo is a pointer to an objective C interface.

bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace, ObjCMethodDecl *Method, ObjCIvarDecl *IV)

IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is an ivar synthesized for 'Meth...

ExprResult getOpenMPCapturedExpr(VarDecl *Capture, ExprValueKind VK, ExprObjectKind OK, SourceLocation Loc)

bool isSpecialMember() const

RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...

bool hasErrorOccurred() const

Determine whether any SFINAE errors have been trapped.

Sema - This implements semantic analysis and AST building for C.

QualType getCurrentThisType()

Try to retrieve the type of the 'this' pointer.

Scope * getCurScope() const

Retrieve the parser's current scope.

void DiagnoseDiscardedExprMarkedNodiscard(const Expr *E)

DiagnoseDiscardedExprMarkedNodiscard - Given an expression that is semantically a discarded-value exp...

DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)

Determine the kind of defaulting that would be done for a given function.

ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)

ExprResult IgnoredValueConversions(Expr *E)

IgnoredValueConversions - Given that an expression's result is syntactically ignored,...

NamedDecl * FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS)

If the given nested-name-specifier begins with a bare identifier (e.g., Base::), perform name lookup ...

LookupNameKind

Describes the kind of name lookup to perform.

@ LookupMemberName

Member name lookup, which finds the names of class/struct/union members.

bool LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, QualType ObjectType, bool EnteringContext, RequiredTemplateKind RequiredTemplate=SourceLocation(), AssumedTemplateKind *ATK=nullptr, bool AllowTypoCorrection=true)

void DecomposeUnqualifiedId(const UnqualifiedId &Id, TemplateArgumentListInfo &Buffer, DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *&TemplateArgs)

Decomposes the given name into a DeclarationNameInfo, its location, and possibly a list of template a...

ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor)

ExtVectorDeclsType ExtVectorDecls

ExtVectorDecls - This is a list all the extended vector types.

FunctionDecl * getCurFunctionDecl(bool AllowLambda=false) const

Returns a pointer to the innermost enclosing function, or nullptr if the current context is not insid...

ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)

Perform conversions on the LHS of a member access expression.

ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME)

This is not an AltiVec-style cast or or C++ direct-initialization, so turn the ParenListExpr into a s...

bool tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, bool ForceComplain=false, bool(*IsPlausibleResult)(QualType)=nullptr)

Try to recover by turning the given expression into a call.

ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)

ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)

ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)

ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.

ObjCMethodDecl * getCurMethodDecl()

getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...

const LangOptions & getLangOpts() const

TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)

Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...

TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)

Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...

const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)

NonOdrUseReason getNonOdrUseReasonInCurrentContext(ValueDecl *D)

If D cannot be odr-used in the current expression evaluation context, return a reason explaining why.

bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, QualType ObjectType, bool AllowBuiltinCreation=false, bool EnteringContext=false)

Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...

bool isPotentialImplicitMemberAccess(const CXXScopeSpec &SS, LookupResult &R, bool IsAddressOfOperand)

Check whether an expression might be an implicit class member access.

ExprResult TemporaryMaterializationConversion(Expr *E)

If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.

NamedDeclSetType UnusedPrivateFields

Set containing all declared private fields that are not used.

sema::FunctionScopeInfo * getCurFunction() const

Expr * BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit)

Build a CXXThisExpr and mark it referenced in the current context.

std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const

Determines whether we are currently in a context where template argument substitution failures are no...

ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Member, Decl *ObjCImpDecl)

The main callback when the parser finds something like expression .

ExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, bool IsDefiniteInstance, const Scope *S)

Builds an implicit member access expression.

ExprResult DefaultLvalueConversion(Expr *E)

ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)

DeclContext * CurContext

CurContext - This is the current declaration context of parsing.

bool isUnevaluatedContext() const

Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5.

DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const

If AllowLambda is true, treat lambda as function.

ExprResult CheckPlaceholderExpr(Expr *E)

Check for operands with placeholder types and complain if found.

QualType CXXThisTypeOverride

When non-NULL, the C++ 'this' expression is allowed despite the current context not being a non-stati...

ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)

ExprResult ActOnDependentMemberExpr(Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)

DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs)

Get the specialization of the given variable template corresponding to the specified argument list,...

bool isThisOutsideMemberFunctionBody(QualType BaseType)

Determine whether the given type is the type of *this that is used outside of the body of a member fu...

ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)

Builds an expression which might be an implicit member expression.

DeclContext * computeDeclContext(QualType T)

Compute the DeclContext that is associated with the given type.

bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)

Conditionally issue a diagnostic based on the current evaluation context.

ExprResult BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS, SourceLocation nameLoc, IndirectFieldDecl *indirectField, DeclAccessPair FoundDecl=DeclAccessPair::make(nullptr, AS_none), Expr *baseObjectExpr=nullptr, SourceLocation opLoc=SourceLocation())

ExternalSemaSource * getExternalSource() const

bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)

Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.

void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)

bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)

Ensure that the type T is a complete type.

SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts

A stack of expression evaluation contexts.

bool isDependentScopeSpecifier(const CXXScopeSpec &SS)

DiagnosticsEngine & Diags

ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)

DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).

void diagnoseMissingTemplateArguments(TemplateName Name, SourceLocation Loc)

MemberExpr * BuildMemberExpr(Expr *Base, bool IsArrow, SourceLocation OpLoc, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, ValueDecl *Member, DeclAccessPair FoundDecl, bool HadMultipleCandidates, const DeclarationNameInfo &MemberNameInfo, QualType Ty, ExprValueKind VK, ExprObjectKind OK, const TemplateArgumentListInfo *TemplateArgs=nullptr)

void MarkMemberReferenced(MemberExpr *E)

Perform reference-marking and odr-use handling for a MemberExpr.

ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)

Cast a base object to a member's actual type.

bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType, const CXXScopeSpec &SS, const LookupResult &R)

Encodes a location in the source.

bool isValid() const

Return true if this is a valid SourceLocation object.

SourceLocation getLocWithOffset(IntTy Offset) const

Return a source location with the specified offset from this SourceLocation.

A trivial tuple used to represent a source range.

void setBegin(SourceLocation b)

SourceLocation getBegin() const

SourceRange getSourceRange() const LLVM_READONLY

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

A convenient class for passing around template argument information.

llvm::ArrayRef< TemplateArgumentLoc > arguments() const

Location wrapper for a TemplateArgument.

bool hasAttr(attr::Kind AK) const

Determine whether this type had the specified attribute applied to it (looking through top-level type...

bool isPointerType() const

bool isObjCSelType() const

const T * castAs() const

Member-template castAs.

bool isScalarType() const

QualType getPointeeType() const

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

bool isExtVectorType() const

bool isExtVectorBoolType() const

bool isSpecificBuiltinType(unsigned K) const

Test for a particular builtin type.

bool isDependentType() const

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

bool isFunctionType() const

const T * getAs() const

Member-template getAs'.

bool isRecordType() const

RecordDecl * getAsRecordDecl() const

Retrieves the RecordDecl this type refers to.

Simple class containing the result of Sema::CorrectTypo.

NamedDecl * getCorrectionDecl() const

Gets the pointer to the declaration of the typo correction.

TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...

UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...

Represents a C++ unqualified-id that has been parsed.

static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)

Represents a C++ member access expression for which lookup produced a set of overloaded functions.

static UnresolvedMemberExpr * Create(const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End)

The iterator over UnresolvedSets.

const DeclAccessPair & getPair() const

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

Represents a variable declaration or definition.

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

For a static data member that was instantiated from a static data member of a class template,...

TemplateSpecializationKind getTemplateSpecializationKind() const

If this variable is an instantiation of a variable template or a static data member of a class templa...

Declaration of a variable template.

unsigned getNumElements() const

QualType getElementType() const

void recordUseOfWeak(const ExprT *E, bool IsRead=true)

Record that a weak object was accessed.

const internal::VariadicAllOfMatcher< Type > type

Matches Types in the clang AST.

TokenKind

Provides a simple uniform namespace for tokens from all C languages.

The JSON file list parser is used to communicate input to InstallAPI.

bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)

ExprObjectKind

A further classification of the kind of object referenced by an l-value or x-value.

@ OK_ObjCProperty

An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...

@ OK_Ordinary

An ordinary object is located at an address in memory.

@ OK_BitField

A bitfield object is a bitfield on a C or C++ record.

@ IK_ConstructorName

A constructor name.

ObjCMethodFamily

A family of Objective-C methods.

@ Result

The result type of a method or function.

ActionResult< Expr * > ExprResult

ExprValueKind

The categorization of expression values, currently following the C++11 scheme.

@ VK_PRValue

A pr-value expression (in the C++11 taxonomy) produces a temporary value.

@ VK_LValue

An l-value expression is a reference to an object with independent storage.

const FunctionProtoType * T

bool declaresSameEntity(const Decl *D1, const Decl *D2)

Determine whether two declarations declare the same entity.

@ TSK_ImplicitInstantiation

This template specialization was implicitly instantiated from a template.

@ Interface

The "__interface" keyword introduces the elaborated-type-specifier.

@ Enum

The "enum" keyword introduces the elaborated-type-specifier.

DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...

SourceLocation getLoc() const

getLoc - Returns the main location of the declaration name.

DeclarationName getName() const

getName - Returns the embedded declaration name.

SourceRange getSourceRange() const LLVM_READONLY

getSourceRange - The range of the declaration name.