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
84};
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()) {
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);
158 if (isField && SemaRef.getLangOpts().CPlusPlus11)
160 break;
161
164 break;
165
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 =
239 Method && Method->isExplicitObjectMemberFunction();
241
242 std::string Replacement;
243 if (InExplicitObjectMethod) {
244 DeclarationName N = Method->getParamDecl(0)->getDeclName();
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)
269 << nameInfo.getName() << Range;
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();
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
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 std::nullopt, *I);
503 }
504
505 return VT;
506}
507
515 return PD;
517 return OMD;
518
519 for (const auto *I : PDecl->protocols()) {
521 Context))
522 return D;
523 }
524 return nullptr;
525}
526
531
532 Decl *GDecl = nullptr;
533 for (const auto *I : QIdTy->quals()) {
537 GDecl = PD;
538 break;
539 }
540
541 if (ObjCMethodDecl *OMD = I->getInstanceMethod(Sel)) {
542 GDecl = OMD;
543 break;
544 }
545 }
546 if (!GDecl) {
547 for (const auto *I : QIdTy->quals()) {
548
550 if (GDecl)
551 return GDecl;
552 }
553 }
554 return GDecl;
555}
556
562 NamedDecl *FirstQualifierInScope,
565
566
567
568
569
570
571
572
573
574 if (!IsArrow) {
578 assert(BaseExpr && "cannot happen with implicit member accesses");
579 Diag(OpLoc, diag::err_typecheck_member_reference_struct_union)
582 }
583 }
584
587 (TemplateArgs && llvm::any_of(TemplateArgs->arguments(),
589 return Arg.getArgument().isDependent();
590 })));
591
592
593
595 Context, BaseExpr, BaseType, IsArrow, OpLoc,
597 NameInfo, TemplateArgs);
598}
599
600
601
602
604 Expr *BaseExpr,
609
610
611 if (!BaseExpr)
613
614 SemaRef.Diag(nameInfo.getLoc(), diag::err_qualified_member_of_unrelated)
615 << SS.getRange() << rep << BaseType;
616}
617
624 if (!BaseRecord) {
625
626
627 assert(BaseType->isDependentType());
628 return false;
629 }
630
632
633
634 if (!BaseExpr && !(*I)->isCXXInstanceMember())
635 return false;
636
637
640 continue;
641
645 return false;
646 }
647
651 return true;
652}
653
663 OpLoc, RTy, diag::err_typecheck_incomplete_tag, BaseRange))
664 return true;
665
666
667
669 if (HasTemplateArgs || TemplateKWLoc.isValid())
671 nullptr, SS, ObjectType,
672 false, TemplateKWLoc);
673
675 return false;
676}
677
681 Decl *ObjCImpDecl, bool HasTemplateArgs,
683
691
692
694 QualType RecordTy = BaseType;
697 SS, TemplateArgs != nullptr, TemplateKWLoc))
699
700
701 } else {
705 ExtraArgs ? ExtraArgs->ObjCImpDecl : nullptr,
706 TemplateArgs != nullptr, TemplateKWLoc);
707
711
712 if (Result.isInvalid())
714
717
718
719 BaseType = Base->getType();
720 }
721
722
723
726
728 OpLoc, IsArrow, SS, TemplateKWLoc,
729 FirstQualifierInScope, R, TemplateArgs, S,
730 false, ExtraArgs);
731}
732
738 Expr *baseObjectExpr,
740
741
742
745 if (baseVariable) {
747
748
749
750
751
752
753 assert(!baseObjectExpr && "anonymous struct/union is static data member?");
754
756
760
761 baseObjectExpr = result.get();
762 }
763
764 assert((baseVariable || baseObjectExpr) &&
765 "referencing anonymous struct/union without a base variable or "
766 "expression");
767
768
769
770 Expr *result = baseObjectExpr;
773
774
775
776 if (!baseVariable) {
778
780
781
783
784
785 result =
787 SS, field, foundDecl, memberNameInfo)
789 if (!result)
791 }
792
793
794 ++FI;
795
796 while (FI != FEnd) {
798
799
803
804 result =
806 (FI == FEnd ? SS : EmptySS), field,
807 fakeFoundDecl, memberNameInfo)
809 }
810
811 return result;
812}
813
826
833 assert((!IsArrow || Base->isPRValue()) &&
834 "-> base must be a pointer prvalue");
837 Member, FoundDecl, MemberNameInfo, TemplateArgs, Ty,
841
842
843
844
845
850 }
851 }
852
853 return E;
854}
855
856
858
859
860
864 }
865 return false;
866}
867
873 NamedDecl *FirstQualifierInScope,
877 bool SuppressQualifierCheck,
879 assert(!SS.isInvalid() && "nested-name-specifier cannot be invalid");
880
881
882
888 TemplateKWLoc, FirstQualifierInScope,
890
891 QualType BaseType = BaseExprType;
892 if (IsArrow) {
893 assert(BaseType->isPointerType());
895 }
897
901 "dependent lookup context that isn't the current instantiation?");
902
906
909
910
911
912
914 if (S && BaseExpr && FD &&
918 Diag(MemberLoc, diag::warn_cdtor_function_try_handler_mem_expr)
920
923 if (ExtraArgs && !IsArrow && BaseExpr && !BaseExpr->isTypeDependent()) {
926 bool MayBePseudoDestructor = false;
928 tok::arrow, ObjectType,
929 MayBePseudoDestructor);
933 ExtraArgs->S, RetryExpr.get(), OpLoc, tok::arrow, TempSS,
934 TemplateKWLoc, ExtraArgs->Id, ExtraArgs->ObjCImpDecl);
935 }
938 }
939
940
943 assert(DC);
944
946 Diag(OpLoc, diag::err_no_member_overloaded_arrow)
948 else
950 << MemberName << DC
954 return RetryExpr;
955 }
956
957
958
959
960
961
962
963
964 if ((SS.isSet() || !BaseExpr ||
967 !SuppressQualifierCheck &&
970
971
972
974
975
977
980 BaseExpr, BaseExprType,
981 IsArrow, OpLoc,
983 TemplateKWLoc, MemberNameInfo,
984 TemplateArgs, R.begin(), R.end());
985
986 return MemExpr;
987 }
988
992
993
994
995
996
997
1000
1001
1002 if (!BaseExpr) {
1003
1005
1006
1007 if (TemplateArgs || TemplateKWLoc.isValid())
1008 return BuildTemplateIdExpr(SS, TemplateKWLoc, R, false, TemplateArgs);
1009
1011 FoundDecl, TemplateArgs);
1012 }
1016 BaseExpr = BuildCXXThisExpr(Loc, BaseExprType, true);
1017 }
1018
1019
1020
1021
1022
1023
1024 auto ConvertBaseExprToDiscardedValue = [&] {
1026 "Static member / member enumerator outside of C++");
1027 if (IsArrow)
1028 return false;
1031 return true;
1032 BaseExpr = Converted.get();
1033 return false;
1034 };
1035 auto ConvertBaseExprToGLValue = [&] {
1036 if (IsArrow || !BaseExpr->isPRValue())
1037 return false;
1040 return true;
1041 BaseExpr = Converted.get();
1042 return false;
1043 };
1044
1045
1048
1049 if (FieldDecl *FD = dyn_cast(MemberDecl)) {
1050 if (ConvertBaseExprToGLValue())
1053 MemberNameInfo);
1054 }
1055
1056 if (MSPropertyDecl *PD = dyn_cast(MemberDecl)) {
1057
1058
1059
1060
1061
1063 MemberNameInfo);
1064 }
1065
1066 if (IndirectFieldDecl *FD = dyn_cast(MemberDecl)) {
1067 if (ConvertBaseExprToGLValue())
1069
1070
1072 FoundDecl, BaseExpr,
1073 OpLoc);
1074 }
1075
1076
1077 if (VarDecl *Var = dyn_cast(MemberDecl)) {
1078 if (ConvertBaseExprToDiscardedValue())
1082 FoundDecl, false,
1083 MemberNameInfo, Var->getType().getNonReferenceType(),
1085 }
1086
1087 if (CXXMethodDecl *MemberFn = dyn_cast(MemberDecl)) {
1090 if (MemberFn->isInstance()) {
1093 if (MemberFn->isImplicitObjectMemberFunction() &&
1094 ConvertBaseExprToGLValue())
1096 } else {
1097
1098 if (ConvertBaseExprToDiscardedValue())
1101 type = MemberFn->getType();
1102 }
1103
1106 MemberFn, FoundDecl, false,
1108 }
1109 assert((MemberDecl) && "member function not C++ method?");
1110
1112 if (ConvertBaseExprToDiscardedValue())
1116 TemplateKWLoc, Enum, FoundDecl, false,
1118 }
1119
1120 if (VarTemplateDecl *VarTempl = dyn_cast(MemberDecl)) {
1121 if (ConvertBaseExprToDiscardedValue())
1123 if (!TemplateArgs) {
1125 SS, TemplateKWLoc.isValid(), VarTempl, MemberLoc);
1127 }
1128
1131 *TemplateArgs, false);
1134
1135
1136 if (!VDecl.get())
1138 BaseExpr, BaseExpr->getType(), IsArrow, OpLoc, SS, TemplateKWLoc,
1139 FirstQualifierInScope, MemberNameInfo, TemplateArgs);
1140
1144
1147 FoundDecl, false,
1150 }
1151
1152
1154 Diag(MemberLoc, diag::err_typecheck_member_reference_type)
1155 << MemberName << BaseType << int(IsArrow);
1156 else
1157 Diag(MemberLoc, diag::err_typecheck_member_reference_unknown)
1158 << MemberName << BaseType << int(IsArrow);
1159
1160 Diag(MemberDecl->getLocation(), diag::note_member_declared_here)
1161 << MemberName;
1164}
1165
1166
1167
1168
1169
1170
1171
1175 if (!opty) return false;
1176
1178
1180 if (ty->isObjCId()) {
1182 } else if (ty->isObjCClass()) {
1184 } else {
1185 return false;
1186 }
1187
1188
1189
1191 if (opty && !opty->getObjectType()->getInterface())
1192 return false;
1193
1195 return true;
1196}
1197
1199 return T->isRecordType();
1200}
1203 return PT->getPointeeType()->isRecordType();
1204 return false;
1205}
1206
1209 if (IsArrow && ->getType()->isFunctionType())
1211
1213}
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1226 ExprResult &BaseExpr, bool &IsArrow,
1228 Decl *ObjCImpDecl, bool HasTemplateArgs,
1230 assert(BaseExpr.get() && "no base expression");
1231
1232
1236
1238
1241
1242
1243
1244
1245
1246 if (IsArrow) {
1248 BaseType = Ptr->getPointeeType();
1251 BaseType = Ptr->getPointeeType();
1252 else if (BaseType->isFunctionType())
1253 goto fail;
1254 else if (BaseType->isDependentType())
1256 else if (BaseType->isRecordType()) {
1257
1258
1259
1260
1261
1262
1263
1265 S.Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
1268 }
1269 IsArrow = false;
1270 } else {
1271 S.Diag(MemberLoc, diag::err_typecheck_member_reference_arrow)
1274 }
1275 }
1276
1277
1278
1279
1280
1281
1282 if (const auto *ATy = BaseType->getAs<AtomicType>()) {
1284 S.PDiag(diag::warn_atomic_member_access));
1285 BaseType = ATy->getValueType().getUnqualifiedType();
1288 CK_AtomicToNonAtomic, BaseExpr.get(), nullptr,
1290 }
1291
1292
1293 if (BaseType->getAsRecordDecl()) {
1295 SS, HasTemplateArgs, TemplateKWLoc))
1297
1298
1299
1300
1301
1303 } else if (BaseType->isDependentType()) {
1306 }
1307
1308
1315 }
1316
1318
1319
1320
1321
1322
1324 if (!IDecl) {
1326 (OTy->isObjCId() || OTy->isObjCClass()))
1327 goto fail;
1328
1329
1330
1331 if (OTy->isObjCId() && Member->isStr("isa"))
1336 ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
1337 goto fail;
1338 }
1339
1341 diag::err_typecheck_incomplete_tag,
1342 BaseExpr.get()))
1344
1347
1348 if (!IV) {
1349
1355 IV = Corrected.getCorrectionDeclAs<ObjCIvarDecl>();
1357 Corrected,
1358 S.PDiag(diag::err_typecheck_member_reference_ivar_suggest)
1360
1361
1362 assert(!ClassDeclared);
1363
1365 if (auto *Category = dyn_cast(D))
1366 D = Category->getClassInterface();
1367
1368 if (auto *Implementation = dyn_cast(D))
1369 ClassDeclared = Implementation->getClassInterface();
1370 else if (auto *Interface = dyn_cast(D))
1372
1373 assert(ClassDeclared && "cannot query interface");
1374 } else {
1375 if (IsArrow &&
1378 S.Diag(MemberLoc, diag::err_property_found_suggest)
1382 }
1383
1384 S.Diag(MemberLoc, diag::err_typecheck_member_reference_ivar)
1388 }
1389 }
1390
1391 assert(ClassDeclared);
1392
1393
1394
1395
1398
1399
1406 ClassOfMethodDecl = MD->getClassInterface();
1408
1409
1410
1411
1412
1413
1415 dyn_cast(ObjCImpDecl))
1416 ClassOfMethodDecl = IMPD->getClassInterface();
1418 dyn_cast(ObjCImpDecl))
1419 ClassOfMethodDecl = CatImplClass->getClassInterface();
1420 }
1425 S.Diag(MemberLoc, diag::err_private_ivar_access)
1427 } else if (!IDecl->isSuperClassOf(ClassOfMethodDecl))
1428
1429 S.Diag(MemberLoc, diag::err_protected_ivar_access)
1431 }
1432 }
1433 bool warn = true;
1436 if (UnaryOperator *UO = dyn_cast(BaseExp))
1437 if (UO->getOpcode() == UO_Deref)
1439
1440 if (DeclRefExpr *DE = dyn_cast(BaseExp))
1442 S.Diag(DE->getLocation(), diag::err_arc_weak_ivar_access);
1443 warn = false;
1444 }
1445 }
1446 if (warn) {
1450 !S.ObjC().IvarBacksCurrentMethodAccessor(IDecl, MD, IV));
1451 }
1452 if (warn)
1453 S.Diag(MemberLoc, diag::warn_direct_ivar_access) << IV->getDeclName();
1454 }
1455
1457 IV, IV->getUsageType(BaseType), MemberLoc, OpLoc, BaseExpr.get(),
1458 IsArrow);
1459
1462 !S.Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, MemberLoc))
1464 }
1465
1466 return Result;
1467 }
1468
1469
1476 }
1477
1478
1482
1485
1487
1489
1490
1491 if (OT->isObjCId()) {
1492
1494 if (Decl *PMDecl =
1496 if (ObjCPropertyDecl *PD = dyn_cast(PMDecl)) {
1497
1500
1504 }
1505
1506 if (ObjCMethodDecl *OMD = dyn_cast(PMDecl)) {
1513 nullptr,
1515 SMD = dyn_cast(SDecl);
1516
1520 }
1521 }
1522
1523
1526 ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
1527
1528 return ExprError(S.Diag(MemberLoc, diag::err_property_not_found)
1529 << MemberName << BaseType);
1530 }
1531
1532
1533 if (OT->isObjCClass()) {
1534
1536 if (!MD) {
1539 ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
1540
1541 goto fail;
1542 }
1543
1544
1547 if (!IFace)
1548 goto fail;
1549
1552
1555 } else
1557
1558
1564 if (!Setter) {
1565
1566
1568 }
1569
1572
1573 if (Getter || Setter) {
1577 }
1578
1581 ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
1582
1583 return ExprError(S.Diag(MemberLoc, diag::err_property_not_found)
1584 << MemberName << BaseType);
1585 }
1586
1587
1589 OPT, BaseExpr.get(), OpLoc, MemberName, MemberLoc, SourceLocation(),
1591 }
1592
1593 if (BaseType->isPackedVectorBoolType(S.Context)) {
1594
1595
1596
1597 S.Diag(R.getNameLoc(), diag::err_ext_vector_component_name_illegal)
1598 << MemberName
1601 }
1602
1603
1604 if (BaseType->isExtVectorType()) {
1605
1615
1618 }
1619
1620
1621
1622 if (IsArrow && BaseType->isSpecificBuiltinType(BuiltinType::ObjCSel) &&
1627 ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
1628 }
1629
1630
1631 fail:
1632
1633
1634
1635
1636
1637
1638
1639
1641 if (!IsArrow && Ptr->getPointeeType()->isRecordType() &&
1643 S.Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
1646
1649
1650
1651 IsArrow = true;
1653 ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
1654 }
1655 }
1656
1657
1658
1660 BaseExpr, S.PDiag(diag::err_member_reference_needs_call),
1661 false,
1667 ObjCImpDecl, HasTemplateArgs, TemplateKWLoc);
1668 }
1669
1670
1671
1672 if (S.getLangOpts().HLSL && BaseType->isScalarType()) {
1676 return LookupMemberExpr(S, R, BaseExpr, IsArrow, OpLoc, SS, ObjCImpDecl,
1677 HasTemplateArgs, TemplateKWLoc);
1678 }
1679
1680 S.Diag(OpLoc, diag::err_typecheck_member_reference_struct_union)
1682
1684}
1685
1691
1695 diag::ext_ms_explicit_constructor_call);
1696
1698
1699
1703 NameInfo, TemplateArgs);
1704
1705 bool IsArrow = (OpKind == tok::arrow);
1706
1708 return ExprError(Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 2);
1709
1710 NamedDecl *FirstQualifierInScope
1712
1713
1717
1720 Base, Base->getType(), OpLoc, IsArrow, SS, TemplateKWLoc,
1721 FirstQualifierInScope, NameInfo, TemplateArgs, S, &ExtraArgs);
1722
1725
1726 return Res;
1727}
1728
1729void Sema::CheckMemberAccessOfNoDeref(const MemberExpr *E) {
1731 return;
1732
1734
1735
1736
1737
1738
1739
1740
1743
1744
1745
1746
1747
1748
1749 CheckAddressOfNoDeref(E->getBase());
1750 }
1751 } else if (E->isArrow()) {
1752 if (const auto *Ptr = dyn_cast(
1754 if (Ptr->getPointeeType()->hasAttr(attr::NoDeref))
1756 }
1757 }
1758}
1759
1765
1766
1767
1768
1771 if (!IsArrow) {
1774 else
1776 }
1777 if (VK != VK_PRValue && Field->isBitField())
1779
1780
1781 QualType MemberType = Field->getType();
1785 } else {
1788
1789 Qualifiers BaseQuals = BaseType.getQualifiers();
1790
1791
1793
1794
1795
1796 if (Field->isMutable()) BaseQuals.removeConst();
1797
1799 Context.getCanonicalType(MemberType).getQualifiers();
1800
1802
1803 Qualifiers Combined = BaseQuals + MemberQuals;
1804 if (Combined != MemberQuals)
1805 MemberType = Context.getQualifiedType(MemberType, Combined);
1806
1807
1808
1809
1810
1811 if (BaseType->hasAttr(attr::NoDeref))
1812 MemberType =
1813 Context.getAttributedType(attr::NoDeref, MemberType, MemberType);
1814 }
1815
1816 auto isDefaultedSpecialMember = [this](const DeclContext *Ctx) {
1819 return false;
1820
1822 };
1823
1824
1825 if (!isDefaultedSpecialMember(CurContext))
1827
1829 FoundDecl, Field);
1830 if (Base.isInvalid())
1832
1833
1834
1836 ->isDependentContext() &&
1838 if (auto *PrivateCopy = OpenMP().isOpenMPCapturedDecl(Field)) {
1840 MemberNameInfo.getLoc());
1841 }
1842 }
1843
1846 SourceLocation(), Field, FoundDecl,
1847 false, MemberNameInfo, MemberType, VK, OK);
1848}
1849
1855 bool IsKnownInstance, const Scope *S) {
1857
1859
1860
1861
1863 assert(!ThisTy.isNull() && "didn't correctly pre-flight capture of 'this'");
1864
1865 Expr *baseExpr = nullptr;
1866 if (IsKnownInstance) {
1870 baseExpr = BuildCXXThisExpr(loc, ThisTy, true);
1871 }
1872
1874 baseExpr, ThisTy,
1877 nullptr, R, TemplateArgs, S);
1878}
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.
static bool ShouldTryAgainWithRedefinitionType(Sema &S, ExprResult &base)
Given that normal member access failed on the given expression, and given that the expression's type ...
Definition SemaExprMember.cpp:1172
static bool LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R, Expr *BaseExpr, QualType RTy, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, bool HasTemplateArgs, SourceLocation TemplateKWLoc)
Definition SemaExprMember.cpp:654
static bool isPointerToRecordType(QualType T)
Definition SemaExprMember.cpp:1201
static Decl * FindGetterSetterNameDeclFromProtocolList(const ObjCProtocolDecl *PDecl, IdentifierInfo *Member, const Selector &Sel, ASTContext &Context)
Definition SemaExprMember.cpp:508
IMAKind
Definition SemaExprMember.cpp:40
@ IMA_Mixed_Unrelated
The reference may be to an instance member, but it is invalid if so, because the context is from an u...
Definition SemaExprMember.cpp:53
@ IMA_Mixed
The reference may be an implicit instance member access.
Definition SemaExprMember.cpp:45
@ IMA_Error_Unrelated
All possible referrents are instance members of an unrelated class.
Definition SemaExprMember.cpp:83
@ IMA_Unresolved
The reference may be to an unresolved using declaration.
Definition SemaExprMember.cpp:59
@ IMA_Abstract
The reference is a contextually-permitted abstract member reference.
Definition SemaExprMember.cpp:62
@ IMA_Mixed_StaticOrExplicitContext
The reference may be to an instance member, but it might be invalid if so, because the context is not...
Definition SemaExprMember.cpp:49
@ IMA_Instance
The reference is definitely an implicit instance member access.
Definition SemaExprMember.cpp:56
@ IMA_Error_StaticOrExplicitContext
All possible referrents are instance members and the current context is not an instance method.
Definition SemaExprMember.cpp:79
@ IMA_Unresolved_StaticOrExplicitContext
The reference may be to an unresolved using declaration and the context is not an instance method.
Definition SemaExprMember.cpp:70
@ IMA_Dependent
Whether the context is static is dependent on the enclosing template (i.e.
Definition SemaExprMember.cpp:66
@ IMA_Field_Uneval_Context
Definition SemaExprMember.cpp:75
@ IMA_Static
The reference is definitely not an instance member access.
Definition SemaExprMember.cpp:42
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.
Definition SemaExprMember.cpp:32
static void diagnoseInstanceReference(Sema &SemaRef, const CXXScopeSpec &SS, NamedDecl *Rep, const DeclarationNameInfo &nameInfo)
Diagnose a reference to a field with no object available.
Definition SemaExprMember.cpp:221
static bool isRecordType(QualType T)
Definition SemaExprMember.cpp:1198
static QualType CheckExtVectorComponent(Sema &S, QualType baseType, ExprValueKind &VK, SourceLocation OpLoc, const IdentifierInfo *CompName, SourceLocation CompLoc)
Check an ext-vector component access expression.
Definition SemaExprMember.cpp:372
llvm::SmallPtrSet< const CXXRecordDecl *, 4 > BaseSet
Definition SemaExprMember.cpp:28
static Decl * FindGetterSetterNameDecl(const ObjCObjectPointerType *QIdTy, IdentifierInfo *Member, const Selector &Sel, ASTContext &Context)
Definition SemaExprMember.cpp:527
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 ...
Definition SemaExprMember.cpp:603
static bool IsValidOpenCLComponentSwizzleLength(unsigned len)
Definition SemaExprMember.cpp:362
static ExprResult BuildMSPropertyRefExpr(Sema &S, Expr *BaseExpr, bool IsArrow, const CXXScopeSpec &SS, MSPropertyDecl *PD, const DeclarationNameInfo &NameInfo)
Definition SemaExprMember.cpp:815
static bool IsRGBA(char c)
Determine whether input char is from rgba component set.
Definition SemaExprMember.cpp:347
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.
Definition SemaExprMember.cpp:92
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.
Definition SemaExprMember.cpp:1225
static bool IsInFnTryBlockHandler(const Scope *S)
Determine if the given scope is within a function-try-block handler.
Definition SemaExprMember.cpp:857
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 ...
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType getObjCClassType() const
Represents the Objective-C Class 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 PseudoObjectTy
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypedefNameDecl *Decl, QualType UnderlyingType=QualType(), std::optional< bool > TypeMatchesDeclOrNone=std::nullopt) const
Return the unique reference to the type for the specified typedef-name decl.
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.
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
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.
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.
NestedNameSpecifier getScopeRep() const
Retrieve the representation of the nested-name-specifier.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
Qualifiers getQualifiers() const
Retrieve all qualifiers.
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 Encloses(const DeclContext *DC) const
Determine whether this declaration context semantically 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.
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.
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.
UnresolvedSetImpl::iterator iterator
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.
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a method that was resolved from an overloaded...
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 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
Base for LValueReferenceType and RValueReferenceType.
Scope - A scope is a transient data structure that is used while parsing the program.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
unsigned getFlags() const
getFlags - Return the flags for this scope.
bool isFnTryCatchScope() const
Determine whether this scope is a function-level C++ try or catch scope.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ 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.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a 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.
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.
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)
Definition SemaExprMember.cpp:684
ExprResult IgnoredValueConversions(Expr *E)
IgnoredValueConversions - Given that an expression's result is syntactically ignored,...
@ 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.
Definition SemaExprMember.cpp:1208
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...
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.
Definition SemaExprMember.cpp:284
NamedDecl * FindFirstQualifierInScope(Scope *S, NestedNameSpecifier NNS)
If the given nested-name-specifier begins with a bare identifier (e.g., Base::), perform name lookup ...
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.
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 .
Definition SemaExprMember.cpp:1686
ExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, bool IsDefiniteInstance, const Scope *S)
Builds an implicit member access expression.
Definition SemaExprMember.cpp:1851
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)
Definition SemaExprMember.cpp:1761
ExprResult ActOnDependentMemberExpr(Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
Definition SemaExprMember.cpp:558
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.
Definition SemaExprMember.cpp:303
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())
Definition SemaExprMember.cpp:734
ExternalSemaSource * getExternalSource() const
bool isSFINAEContext() 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.
@ UnevaluatedAbstract
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
@ UnevaluatedList
The current expression occurs within a braced-init-list within an unevaluated operand.
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ DiscardedStatement
The current expression occurs within a discarded statement.
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
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.
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
bool isDependentScopeSpecifier(const CXXScopeSpec &SS)
DeclResult CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, SourceLocation TemplateNameLoc, const TemplateArgumentListInfo &TemplateArgs, bool SetWrittenArgs)
Get the specialization of the given variable template corresponding to the specified argument list,...
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)
Definition SemaExprMember.cpp:827
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType, const CXXScopeSpec &SS, const LookupResult &R)
Definition SemaExprMember.cpp:618
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.
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.
ArrayRef< TemplateArgumentLoc > arguments() const
Location wrapper for a TemplateArgument.
bool isPointerType() const
bool isObjCSelType() const
const T * castAs() const
Member-template castAs.
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...
const T * getAs() const
Member-template getAs'.
bool isRecordType() const
Simple class containing the result of Sema::CorrectTypo.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Represents a C++ unqualified-id that has been parsed.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
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)
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 isa(CodeGen::Address addr)
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.
ActionResult< Decl * > DeclResult
ObjCMethodFamily
A family of Objective-C methods.
@ Result
The result type of a method or function.
const FunctionProtoType * T
ActionResult< CXXBaseSpecifier * > BaseResult
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.
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.
U cast(CodeGen::Address addr)
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ None
No keyword precedes the qualified type name.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
ActionResult< Expr * > ExprResult
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.