32 #include "llvm/Support/ErrorHandling.h" 33 #include "llvm/Support/raw_ostream.h" 36 using namespace clang;
44 if (
auto *BO = dyn_cast<BinaryOperator>(E)) {
45 if (BO->getOpcode() == BO_Comma) {
52 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
53 E = MTE->GetTemporaryExpr();
74 return cast<CXXRecordDecl>(D);
84 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
85 if ((CE->getCastKind() == CK_DerivedToBase ||
86 CE->getCastKind() == CK_UncheckedDerivedToBase) &&
95 if (CE->getCastKind() == CK_NoOp) {
99 }
else if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
100 if (!ME->isArrow()) {
101 assert(ME->getBase()->getType()->isRecordType());
102 if (
FieldDecl *Field = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
103 if (!Field->isBitField() && !Field->getType()->isReferenceType()) {
110 }
else if (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
111 if (BO->getOpcode() == BO_PtrMemD) {
112 assert(BO->getRHS()->isRValue());
118 }
else if (BO->getOpcode() == BO_Comma) {
119 CommaLHSs.push_back(BO->getLHS());
144 switch (UO->getOpcode()) {
146 return UO->getSubExpr()->isKnownToHaveBooleanValue();
157 return CE->getSubExpr()->isKnownToHaveBooleanValue();
160 switch (BO->getOpcode()) {
161 default:
return false;
176 return BO->getLHS()->isKnownToHaveBooleanValue() &&
177 BO->getRHS()->isKnownToHaveBooleanValue();
181 return BO->getRHS()->isKnownToHaveBooleanValue();
186 return CO->getTrueExpr()->isKnownToHaveBooleanValue() &&
187 CO->getFalseExpr()->isKnownToHaveBooleanValue();
199 template <
class E,
class T>
219 #define ABSTRACT_STMT(type) 220 #define STMT(type, base) \ 221 case Stmt::type##Class: break; 222 #define EXPR(type, base) \ 223 case Stmt::type##Class: return getExprLocImpl<type>(this, &type::getExprLoc); 224 #include "clang/AST/StmtNodes.inc" 226 llvm_unreachable(
"unknown expression kind");
238 bool &ValueDependent,
239 bool &InstantiationDependent) {
240 TypeDependent =
false;
241 ValueDependent =
false;
242 InstantiationDependent =
false;
255 TypeDependent =
true;
256 ValueDependent =
true;
257 InstantiationDependent =
true;
260 InstantiationDependent =
true;
268 TypeDependent =
true;
269 ValueDependent =
true;
270 InstantiationDependent =
true;
275 InstantiationDependent =
true;
279 if (isa<NonTypeTemplateParmDecl>(D)) {
280 ValueDependent =
true;
281 InstantiationDependent =
true;
292 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
294 Var->getType()->isLiteralType(Ctx) :
295 Var->getType()->isIntegralOrEnumerationType()) &&
296 (Var->getType().isConstQualified() ||
297 Var->getType()->isReferenceType())) {
298 if (
const Expr *Init = Var->getAnyInitializer())
299 if (Init->isValueDependent()) {
300 ValueDependent =
true;
301 InstantiationDependent =
true;
308 if (Var->isStaticDataMember() &&
309 Var->getDeclContext()->isDependentContext()) {
310 ValueDependent =
true;
311 InstantiationDependent =
true;
314 TypeDependent =
true;
324 ValueDependent =
true;
325 InstantiationDependent =
true;
329 void DeclRefExpr::computeDependence(
const ASTContext &Ctx) {
330 bool TypeDependent =
false;
331 bool ValueDependent =
false;
332 bool InstantiationDependent =
false;
334 ValueDependent, InstantiationDependent);
336 ExprBits.TypeDependent |= TypeDependent;
337 ExprBits.ValueDependent |= ValueDependent;
338 ExprBits.InstantiationDependent |= InstantiationDependent;
341 if (getDecl()->isParameterPack())
342 ExprBits.ContainsUnexpandedParameterPack =
true;
345 DeclRefExpr::DeclRefExpr(
const ASTContext &Ctx,
348 ValueDecl *D,
bool RefersToEnclosingVariableOrCapture,
353 :
Expr(DeclRefExprClass, T, VK,
OK_Ordinary,
false,
false,
false,
false),
357 new (getTrailingObjects<NestedNameSpecifierLoc>())
360 if (NNS->isInstantiationDependent())
361 ExprBits.InstantiationDependent =
true;
362 if (NNS->containsUnexpandedParameterPack())
363 ExprBits.ContainsUnexpandedParameterPack =
true;
367 *getTrailingObjects<NamedDecl *>() = FoundD;
369 = (TemplateArgs || TemplateKWLoc.
isValid()) ? 1 : 0;
371 RefersToEnclosingVariableOrCapture;
373 bool Dependent =
false;
374 bool InstantiationDependent =
false;
375 bool ContainsUnexpandedParameterPack =
false;
376 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
377 TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
378 Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
379 assert(!Dependent &&
"built a DeclRefExpr with dependent template args");
380 ExprBits.InstantiationDependent |= InstantiationDependent;
381 ExprBits.ContainsUnexpandedParameterPack |= ContainsUnexpandedParameterPack;
382 }
else if (TemplateKWLoc.
isValid()) {
383 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
388 computeDependence(Ctx);
395 bool RefersToEnclosingVariableOrCapture,
401 return Create(Context, QualifierLoc, TemplateKWLoc, D,
402 RefersToEnclosingVariableOrCapture,
404 T, VK, FoundD, TemplateArgs);
411 bool RefersToEnclosingVariableOrCapture,
421 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
425 QualifierLoc ? 1 : 0, FoundD ? 1 : 0,
426 HasTemplateKWAndArgsInfo ? 1 : 0,
427 TemplateArgs ? TemplateArgs->
size() : 0);
430 return new (Mem)
DeclRefExpr(Context, QualifierLoc, TemplateKWLoc, D,
431 RefersToEnclosingVariableOrCapture,
432 NameInfo, FoundD, TemplateArgs, T, VK);
438 bool HasTemplateKWAndArgsInfo,
439 unsigned NumTemplateArgs) {
440 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
444 HasQualifier ? 1 : 0, HasFoundDecl ? 1 : 0, HasTemplateKWAndArgsInfo,
452 return getQualifierLoc().getBeginLoc();
453 return getNameInfo().getLocStart();
456 if (hasExplicitTemplateArgs())
457 return getRAngleLoc();
458 return getNameInfo().getLocEnd();
464 FNTy->isDependentType(), FNTy->isDependentType(),
465 FNTy->isInstantiationDependentType(),
467 Loc(L),
Type(IT), FnName(SL) {}
470 return cast_or_null<StringLiteral>(FnName);
478 return "__FUNCTION__";
480 return "__FUNCDNAME__";
482 return "L__FUNCTION__";
484 return "__PRETTY_FUNCTION__";
486 return "__FUNCSIG__";
488 return "L__FUNCSIG__";
492 llvm_unreachable(
"Unknown ident type for PredefinedExpr");
501 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(CurrentDecl)) {
502 std::unique_ptr<MangleContext> MC;
505 if (MC->shouldMangleDeclName(ND)) {
507 llvm::raw_svector_ostream Out(Buffer);
513 MC->mangleName(ND, Out);
515 if (!Buffer.empty() && Buffer.front() ==
'\01')
516 return Buffer.substr(1);
519 return ND->getIdentifier()->getName();
523 if (isa<BlockDecl>(CurrentDecl)) {
528 if (DC->isFileContext())
532 llvm::raw_svector_ostream Out(Buffer);
533 if (
auto *DCBlock = dyn_cast<BlockDecl>(DC))
536 else if (
auto *DCDecl = dyn_cast<Decl>(DC))
540 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
543 return FD->getNameAsString();
546 llvm::raw_svector_ostream Out(Name);
557 llvm::raw_string_ostream POut(Proto);
564 if (FD->hasWrittenPrototype())
565 FT = dyn_cast<FunctionProtoType>(AFT);
569 case CC_C: POut <<
"__cdecl ";
break;
580 FD->printQualifiedName(POut, Policy);
584 for (
unsigned i = 0, e = Decl->
getNumParams(); i != e; ++i) {
589 if (FT->isVariadic()) {
590 if (FD->getNumParams()) POut <<
", ";
601 assert(FT &&
"We must have a written prototype in this case.");
604 if (FT->isVolatile())
616 while (Ctx && isa<NamedDecl>(Ctx)) {
620 Specs.push_back(Spec);
624 std::string TemplateParams;
625 llvm::raw_string_ostream TOut(TemplateParams);
626 for (SpecsTy::reverse_iterator I = Specs.rbegin(), E = Specs.rend();
629 = (*I)->getSpecializedTemplate()->getTemplateParameters();
631 assert(Params->
size() == Args.
size());
632 for (
unsigned i = 0, numParams = Params->
size(); i != numParams; ++i) {
634 if (Param.empty())
continue;
635 TOut << Param <<
" = ";
642 = FD->getTemplateSpecializationInfo();
647 assert(Params->
size() == Args->
size());
648 for (
unsigned i = 0, e = Params->
size(); i != e; ++i) {
650 if (Param.empty())
continue;
651 TOut << Param <<
" = ";
658 if (!TemplateParams.empty()) {
660 TemplateParams.resize(TemplateParams.size() - 2);
661 POut <<
" [" << TemplateParams <<
"]";
670 if (isa<CXXMethodDecl>(FD) &&
671 cast<CXXMethodDecl>(FD)->getParent()->isLambda())
672 Proto =
"auto " + Proto;
673 else if (FT && FT->getReturnType()->getAs<
DecltypeType>())
678 else if (!isa<CXXConstructorDecl>(FD) && !isa<CXXDestructorDecl>(FD))
683 return Name.str().str();
685 if (
const CapturedDecl *CD = dyn_cast<CapturedDecl>(CurrentDecl)) {
689 if (DC->isFunctionOrMethod() && (DC->getDeclKind() != Decl::Captured)) {
693 llvm_unreachable(
"CapturedDecl not inside a function or method");
695 if (
const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(CurrentDecl)) {
697 llvm::raw_svector_ostream Out(Name);
698 Out << (MD->isInstanceMethod() ?
'-' :
'+');
707 dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext()))
708 Out <<
'(' << *CID <<
')';
711 MD->getSelector().print(Out);
714 return Name.str().str();
716 if (isa<TranslationUnitDecl>(CurrentDecl) && IT ==
PrettyFunction) {
724 const llvm::APInt &Val) {
728 BitWidth = Val.getBitWidth();
729 unsigned NumWords = Val.getNumWords();
730 const uint64_t* Words = Val.getRawData();
732 pVal =
new (
C) uint64_t[NumWords];
733 std::copy(Words, Words + NumWords, pVal);
734 }
else if (NumWords == 1)
740 IntegerLiteral::IntegerLiteral(
const ASTContext &
C,
const llvm::APInt &V,
745 assert(type->
isIntegerType() &&
"Illegal type in IntegerLiteral");
747 "Integer type is not the correct size for constant.");
762 FixedPointLiteral::FixedPointLiteral(
const ASTContext &
C,
const llvm::APInt &V,
767 Loc(l), Scale(Scale) {
770 "Fixed point type is not the correct size for constant.");
775 const llvm::APInt &V,
788 S, llvm::APSInt::getUnsigned(
getValue().getZExtValue()), Scale, Radix);
792 FloatingLiteral::FloatingLiteral(
const ASTContext &
C,
const llvm::APFloat &V,
795 false,
false), Loc(L) {
796 setSemantics(V.getSemantics());
802 :
Expr(FloatingLiteralClass, Empty) {
821 return llvm::APFloat::IEEEhalf();
823 return llvm::APFloat::IEEEsingle();
825 return llvm::APFloat::IEEEdouble();
827 return llvm::APFloat::x87DoubleExtended();
829 return llvm::APFloat::IEEEquad();
831 return llvm::APFloat::PPCDoubleDouble();
833 llvm_unreachable(
"Unrecognised floating semantics");
837 if (&Sem == &llvm::APFloat::IEEEhalf())
839 else if (&Sem == &llvm::APFloat::IEEEsingle())
841 else if (&Sem == &llvm::APFloat::IEEEdouble())
843 else if (&Sem == &llvm::APFloat::x87DoubleExtended())
845 else if (&Sem == &llvm::APFloat::IEEEquad())
847 else if (&Sem == &llvm::APFloat::PPCDoubleDouble())
850 llvm_unreachable(
"Unknown floating semantics");
859 V.convert(llvm::APFloat::IEEEdouble(), llvm::APFloat::rmNearestTiesToEven,
861 return V.convertToDouble();
864 int StringLiteral::mapCharByteWidth(
TargetInfo const &target,StringKind k) {
865 int CharByteWidth = 0;
881 assert((CharByteWidth & 7) == 0 &&
"Assumes character size is byte multiple");
883 assert((CharByteWidth==1 || CharByteWidth==2 || CharByteWidth==4)
884 &&
"character byte widths supported are 1, 2, and 4 only");
885 return CharByteWidth;
893 "StringLiteral must be of constant array type!");
905 SL->TokLocs[0] = Loc[0];
906 SL->NumConcatenated = NumStrs;
920 SL->CharByteWidth = 0;
922 SL->NumConcatenated = NumStrs;
929 case Wide: OS <<
'L';
break;
930 case UTF8: OS <<
"u8";
break;
931 case UTF16: OS <<
'u';
break;
932 case UTF32: OS <<
'U';
break;
935 static const char Hex[] =
"0123456789ABCDEF";
937 unsigned LastSlashX = getLength();
938 for (
unsigned I = 0, N = getLength(); I != N; ++I) {
939 switch (uint32_t Char = getCodeUnit(I)) {
945 if (
getKind() == UTF16 && I != N - 1 && Char >= 0xd800 &&
947 uint32_t Trail = getCodeUnit(I + 1);
948 if (Trail >= 0xdc00 && Trail <= 0xdfff) {
949 Char = 0x10000 + ((Char - 0xd800) << 10) + (Trail - 0xdc00);
959 (Char >= 0xd800 && Char <= 0xdfff) || Char >= 0x110000) {
963 while ((Char >> Shift) == 0)
965 for (; Shift >= 0; Shift -= 4)
966 OS << Hex[(Char >> Shift) & 15];
973 << Hex[(Char >> 20) & 15]
974 << Hex[(Char >> 16) & 15];
977 OS << Hex[(Char >> 12) & 15]
978 << Hex[(Char >> 8) & 15]
979 << Hex[(Char >> 4) & 15]
980 << Hex[(Char >> 0) & 15];
986 if (LastSlashX + 1 == I) {
988 case '0':
case '1':
case '2':
case '3':
case '4':
989 case '5':
case '6':
case '7':
case '8':
case '9':
990 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
991 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
996 assert(Char <= 0xff &&
997 "Characters above 0xff should already have been handled.");
1003 << (char)(
'0' + ((Char >> 6) & 7))
1004 << (char)(
'0' + ((Char >> 3) & 7))
1005 << (char)(
'0' + ((Char >> 0) & 7));
1008 case '\\': OS <<
"\\\\";
break;
1009 case '"': OS <<
"\\\"";
break;
1010 case '\a': OS <<
"\\a";
break;
1011 case '\b': OS <<
"\\b";
break;
1012 case '\f': OS <<
"\\f";
break;
1013 case '\n': OS <<
"\\n";
break;
1014 case '\r': OS <<
"\\r";
break;
1015 case '\t': OS <<
"\\t";
break;
1016 case '\v': OS <<
"\\v";
break;
1027 this->IsPascal = IsPascal;
1030 assert((Str.size()%CharByteWidth == 0)
1031 &&
"size of data must be multiple of CharByteWidth");
1032 Length = Str.size()/CharByteWidth;
1034 switch(CharByteWidth) {
1036 char *AStrData =
new (
C)
char[Length];
1037 std::memcpy(AStrData,Str.data(),Length*
sizeof(*AStrData));
1038 StrData.asChar = AStrData;
1042 uint16_t *AStrData =
new (
C) uint16_t[Length];
1043 std::memcpy(AStrData,Str.data(),Length*
sizeof(*AStrData));
1044 StrData.asUInt16 = AStrData;
1048 uint32_t *AStrData =
new (
C) uint32_t[Length];
1049 std::memcpy(AStrData,Str.data(),Length*
sizeof(*AStrData));
1050 StrData.asUInt32 = AStrData;
1054 llvm_unreachable(
"unsupported CharByteWidth");
1078 unsigned *StartTokenByteOffset)
const {
1080 "Only narrow string literals are currently supported");
1085 unsigned StringOffset = 0;
1087 TokNo = *StartToken;
1088 if (StartTokenByteOffset) {
1089 StringOffset = *StartTokenByteOffset;
1090 ByteNo -= StringOffset;
1093 assert(TokNo < getNumConcatenated() &&
"Invalid byte number!");
1102 std::pair<FileID, unsigned> LocInfo =
1104 bool Invalid =
false;
1105 StringRef Buffer = SM.
getBufferData(LocInfo.first, &Invalid);
1107 if (StartTokenByteOffset !=
nullptr)
1108 *StartTokenByteOffset = StringOffset;
1109 if (StartToken !=
nullptr)
1110 *StartToken = TokNo;
1111 return StrTokSpellingLoc;
1114 const char *StrData = Buffer.data()+LocInfo.second;
1118 Buffer.begin(), StrData, Buffer.end());
1120 TheLexer.LexFromRawLexer(TheTok);
1127 if (ByteNo < TokNumBytes ||
1128 (ByteNo == TokNumBytes && TokNo == getNumConcatenated() - 1)) {
1133 if (StartTokenByteOffset !=
nullptr)
1134 *StartTokenByteOffset = StringOffset;
1135 if (StartToken !=
nullptr)
1136 *StartToken = TokNo;
1141 StringOffset += TokNumBytes;
1143 ByteNo -= TokNumBytes;
1153 #define UNARY_OPERATION(Name, Spelling) case UO_##Name: return Spelling; 1154 #include "clang/AST/OperationKinds.def" 1156 llvm_unreachable(
"Unknown unary operator");
1162 default: llvm_unreachable(
"No unary operator for overloaded function");
1163 case OO_PlusPlus:
return Postfix ? UO_PostInc : UO_PreInc;
1164 case OO_MinusMinus:
return Postfix ? UO_PostDec : UO_PreDec;
1165 case OO_Amp:
return UO_AddrOf;
1166 case OO_Star:
return UO_Deref;
1167 case OO_Plus:
return UO_Plus;
1168 case OO_Minus:
return UO_Minus;
1169 case OO_Tilde:
return UO_Not;
1170 case OO_Exclaim:
return UO_LNot;
1171 case OO_Coawait:
return UO_Coawait;
1177 case UO_PostInc:
case UO_PreInc:
return OO_PlusPlus;
1178 case UO_PostDec:
case UO_PreDec:
return OO_MinusMinus;
1179 case UO_AddrOf:
return OO_Amp;
1180 case UO_Deref:
return OO_Star;
1181 case UO_Plus:
return OO_Plus;
1182 case UO_Minus:
return OO_Minus;
1183 case UO_Not:
return OO_Tilde;
1184 case UO_LNot:
return OO_Exclaim;
1185 case UO_Coawait:
return OO_Coawait;
1201 NumArgs(args.size()) {
1203 unsigned NumPreArgs = preargs.size();
1204 SubExprs =
new (
C)
Stmt *[args.size()+PREARGS_START+NumPreArgs];
1206 for (
unsigned i = 0; i != NumPreArgs; ++i) {
1207 updateDependenciesFromArg(preargs[i]);
1208 SubExprs[i+PREARGS_START] = preargs[i];
1210 for (
unsigned i = 0; i != args.size(); ++i) {
1211 updateDependenciesFromArg(args[i]);
1212 SubExprs[i+PREARGS_START+NumPreArgs] = args[i];
1216 RParenLoc = rparenloc;
1234 :
Expr(SC, Empty), SubExprs(nullptr), NumArgs(0) {
1236 SubExprs =
new (
C)
Stmt*[PREARGS_START+NumPreArgs]();
1240 void CallExpr::updateDependenciesFromArg(
Expr *Arg) {
1246 ExprBits.InstantiationDependent =
true;
1248 ExprBits.ContainsUnexpandedParameterPack =
true;
1263 = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE)) {
1269 if (BO->isPtrMemOp())
1271 }
else if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(CEE)) {
1272 if (UO->getOpcode() == UO_Deref)
1275 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE))
1276 return DRE->getDecl();
1277 if (
MemberExpr *ME = dyn_cast<MemberExpr>(CEE))
1278 return ME->getMemberDecl();
1292 this->NumArgs = NumArgs;
1298 Stmt **NewSubExprs =
new (
C)
Stmt*[NumArgs+PREARGS_START+NumPreArgs];
1300 for (
unsigned i = 0; i !=
getNumArgs()+PREARGS_START+NumPreArgs; ++i)
1301 NewSubExprs[i] = SubExprs[i];
1303 for (
unsigned i =
getNumArgs()+PREARGS_START+NumPreArgs;
1304 i != NumArgs+PREARGS_START+NumPreArgs; ++i)
1305 NewSubExprs[i] =
nullptr;
1308 SubExprs = NewSubExprs;
1309 this->NumArgs = NumArgs;
1350 if (isa<CXXPseudoDestructorExpr>(Callee->
IgnoreParens()))
1362 if (isa<CXXOperatorCallExpr>(
this))
1363 return cast<CXXOperatorCallExpr>(
this)->
getLocStart();
1371 if (isa<CXXOperatorCallExpr>(
this))
1372 return cast<CXXOperatorCallExpr>(
this)->
getLocEnd();
1387 totalSizeToAlloc<OffsetOfNode, Expr *>(comps.size(), exprs.size()));
1389 return new (Mem)
OffsetOfExpr(C, type, OperatorLoc, tsi, comps, exprs,
1394 unsigned numComps,
unsigned numExprs) {
1396 C.
Allocate(totalSizeToAlloc<OffsetOfNode, Expr *>(numComps, numExprs));
1409 OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
1410 NumComps(comps.size()), NumExprs(exprs.size())
1412 for (
unsigned i = 0; i != comps.size(); ++i) {
1413 setComponent(i, comps[i]);
1416 for (
unsigned i = 0; i != exprs.size(); ++i) {
1420 ExprBits.ContainsUnexpandedParameterPack =
true;
1422 setIndexExpr(i, exprs[i]);
1429 return getField()->getIdentifier();
1442 OpLoc(op), RParenLoc(rp) {
1454 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
1456 else if (
const auto *ME = dyn_cast<MemberExpr>(E))
1457 D = ME->getMemberDecl();
1461 if (I->isAlignmentDependent()) {
1479 bool hasQualOrFound = (QualifierLoc ||
1480 founddecl.
getDecl() != memberdecl ||
1483 bool HasTemplateKWAndArgsInfo = targs || TemplateKWLoc.
isValid();
1487 HasTemplateKWAndArgsInfo ? 1 : 0,
1488 targs ? targs->
size() : 0);
1492 MemberExpr(base, isarrow, OperatorLoc, memberdecl, nameinfo, ty, vk, ok);
1494 if (hasQualOrFound) {
1501 else if (QualifierLoc &&
1505 E->HasQualifierOrFoundDecl =
true;
1507 MemberExprNameQualifier *NQ =
1508 E->getTrailingObjects<MemberExprNameQualifier>();
1513 E->HasTemplateKWAndArgsInfo = (targs || TemplateKWLoc.
isValid());
1516 bool Dependent =
false;
1517 bool InstantiationDependent =
false;
1518 bool ContainsUnexpandedParameterPack =
false;
1519 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1521 Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
1522 if (InstantiationDependent)
1524 }
else if (TemplateKWLoc.
isValid()) {
1525 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1533 if (isImplicitAccess()) {
1535 return getQualifierLoc().getBeginLoc();
1543 return BaseStartLoc;
1548 if (hasExplicitTemplateArgs())
1549 EndLoc = getRAngleLoc();
1551 EndLoc = getBase()->getLocEnd();
1555 bool CastExpr::CastConsistency()
const {
1556 switch (getCastKind()) {
1557 case CK_DerivedToBase:
1558 case CK_UncheckedDerivedToBase:
1559 case CK_DerivedToBaseMemberPointer:
1560 case CK_BaseToDerived:
1561 case CK_BaseToDerivedMemberPointer:
1562 assert(!path_empty() &&
"Cast kind should have a base path!");
1565 case CK_CPointerToObjCPointerCast:
1566 assert(
getType()->isObjCObjectPointerType());
1567 assert(getSubExpr()->
getType()->isPointerType());
1568 goto CheckNoBasePath;
1570 case CK_BlockPointerToObjCPointerCast:
1571 assert(
getType()->isObjCObjectPointerType());
1572 assert(getSubExpr()->
getType()->isBlockPointerType());
1573 goto CheckNoBasePath;
1575 case CK_ReinterpretMemberPointer:
1576 assert(
getType()->isMemberPointerType());
1577 assert(getSubExpr()->
getType()->isMemberPointerType());
1578 goto CheckNoBasePath;
1584 if (!
getType()->isPointerType()) {
1585 assert(
getType()->isObjCObjectPointerType() ==
1586 getSubExpr()->
getType()->isObjCObjectPointerType());
1587 assert(
getType()->isBlockPointerType() ==
1588 getSubExpr()->
getType()->isBlockPointerType());
1590 goto CheckNoBasePath;
1592 case CK_AnyPointerToBlockPointerCast:
1593 assert(
getType()->isBlockPointerType());
1594 assert(getSubExpr()->
getType()->isAnyPointerType() &&
1595 !getSubExpr()->
getType()->isBlockPointerType());
1596 goto CheckNoBasePath;
1598 case CK_CopyAndAutoreleaseBlockObject:
1599 assert(
getType()->isBlockPointerType());
1600 assert(getSubExpr()->
getType()->isBlockPointerType());
1601 goto CheckNoBasePath;
1603 case CK_FunctionToPointerDecay:
1604 assert(
getType()->isPointerType());
1605 assert(getSubExpr()->
getType()->isFunctionType());
1606 goto CheckNoBasePath;
1608 case CK_AddressSpaceConversion:
1609 assert(
getType()->isPointerType() ||
getType()->isBlockPointerType());
1610 assert(getSubExpr()->
getType()->isPointerType() ||
1611 getSubExpr()->
getType()->isBlockPointerType());
1612 assert(
getType()->getPointeeType().getAddressSpace() !=
1613 getSubExpr()->
getType()->getPointeeType().getAddressSpace());
1618 case CK_ArrayToPointerDecay:
1619 case CK_NullToMemberPointer:
1620 case CK_NullToPointer:
1621 case CK_ConstructorConversion:
1622 case CK_IntegralToPointer:
1623 case CK_PointerToIntegral:
1625 case CK_VectorSplat:
1626 case CK_IntegralCast:
1627 case CK_BooleanToSignedIntegral:
1628 case CK_IntegralToFloating:
1629 case CK_FloatingToIntegral:
1630 case CK_FloatingCast:
1631 case CK_ObjCObjectLValueCast:
1632 case CK_FloatingRealToComplex:
1633 case CK_FloatingComplexToReal:
1634 case CK_FloatingComplexCast:
1635 case CK_FloatingComplexToIntegralComplex:
1636 case CK_IntegralRealToComplex:
1637 case CK_IntegralComplexToReal:
1638 case CK_IntegralComplexCast:
1639 case CK_IntegralComplexToFloatingComplex:
1640 case CK_ARCProduceObject:
1641 case CK_ARCConsumeObject:
1642 case CK_ARCReclaimReturnedObject:
1643 case CK_ARCExtendBlockObject:
1644 case CK_ZeroToOCLEvent:
1645 case CK_ZeroToOCLQueue:
1646 case CK_IntToOCLSampler:
1648 goto CheckNoBasePath;
1651 case CK_LValueToRValue:
1653 case CK_AtomicToNonAtomic:
1654 case CK_NonAtomicToAtomic:
1655 case CK_PointerToBoolean:
1656 case CK_IntegralToBoolean:
1657 case CK_FloatingToBoolean:
1658 case CK_MemberPointerToBoolean:
1659 case CK_FloatingComplexToBoolean:
1660 case CK_IntegralComplexToBoolean:
1661 case CK_LValueBitCast:
1662 case CK_UserDefinedConversion:
1663 case CK_BuiltinFnToFnPtr:
1665 assert(path_empty() &&
"Cast kind should not have a base path!");
1673 #define CAST_OPERATION(Name) case CK_##Name: return #Name; 1674 #include "clang/AST/OperationKinds.def" 1676 llvm_unreachable(
"Unhandled cast kind!");
1680 const Expr *skipImplicitTemporary(
const Expr *E) {
1682 if (
auto *Materialize = dyn_cast<MaterializeTemporaryExpr>(E))
1683 E = Materialize->GetTemporaryExpr();
1686 if (
auto *Binder = dyn_cast<CXXBindTemporaryExpr>(E))
1687 E = Binder->getSubExpr();
1694 const Expr *SubExpr =
nullptr;
1697 SubExpr = skipImplicitTemporary(E->
getSubExpr());
1703 skipImplicitTemporary(cast<CXXConstructExpr>(SubExpr)->getArg(0));
1704 else if (E->
getCastKind() == CK_UserDefinedConversion) {
1705 assert((isa<CXXMemberCallExpr>(SubExpr) ||
1706 isa<BlockExpr>(SubExpr)) &&
1707 "Unexpected SubExpr for CK_UserDefinedConversion.");
1708 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
1709 SubExpr = MCE->getImplicitObjectArgument();
1714 }
while ((E = dyn_cast<ImplicitCastExpr>(SubExpr)));
1716 return const_cast<Expr*
>(SubExpr);
1720 const Expr *SubExpr =
nullptr;
1723 SubExpr = skipImplicitTemporary(E->getSubExpr());
1725 if (E->getCastKind() == CK_ConstructorConversion)
1726 return cast<CXXConstructExpr>(SubExpr)->getConstructor();
1728 if (E->getCastKind() == CK_UserDefinedConversion) {
1729 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
1730 return MCE->getMethodDecl();
1738 assert(!path_empty());
1740 #define ABSTRACT_STMT(x) 1741 #define CASTEXPR(Type, Base) \ 1742 case Stmt::Type##Class: \ 1743 return static_cast<Type *>(this) \ 1744 ->getTrailingObjects<CastExpr::BasePathSizeTy>(); 1745 #define STMT(Type, Base) 1746 #include "clang/AST/StmtNodes.inc" 1748 llvm_unreachable(
"non-cast expressions not possible here");
1754 #define ABSTRACT_STMT(x) 1755 #define CASTEXPR(Type, Base) \ 1756 case Stmt::Type##Class: \ 1757 return static_cast<Type *>(this)->getTrailingObjects<CXXBaseSpecifier *>(); 1758 #define STMT(Type, Base) 1759 #include "clang/AST/StmtNodes.inc" 1761 llvm_unreachable(
"non-cast expressions not possible here");
1768 return getTargetFieldForToUnionCast(RD, opType);
1776 Field != FieldEnd; ++Field) {
1778 !Field->isUnnamedBitfield()) {
1789 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1791 C.
Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
1792 PathSize ? 1 : 0, PathSize));
1796 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1802 unsigned PathSize) {
1804 C.
Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
1805 PathSize ? 1 : 0, PathSize));
1815 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1817 C.
Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
1818 PathSize ? 1 : 0, PathSize));
1820 new (Buffer)
CStyleCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, R);
1822 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1828 unsigned PathSize) {
1830 C.
Allocate(totalSizeToAlloc<CastExpr::BasePathSizeTy, CXXBaseSpecifier *>(
1831 PathSize ? 1 : 0, PathSize));
1839 #define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling; 1840 #include "clang/AST/OperationKinds.def" 1842 llvm_unreachable(
"Invalid OpCode!");
1848 default: llvm_unreachable(
"Not an overloadable binary operator");
1849 case OO_Plus:
return BO_Add;
1850 case OO_Minus:
return BO_Sub;
1851 case OO_Star:
return BO_Mul;
1852 case OO_Slash:
return BO_Div;
1853 case OO_Percent:
return BO_Rem;
1854 case OO_Caret:
return BO_Xor;
1855 case OO_Amp:
return BO_And;
1856 case OO_Pipe:
return BO_Or;
1857 case OO_Equal:
return BO_Assign;
1858 case OO_Spaceship:
return BO_Cmp;
1859 case OO_Less:
return BO_LT;
1860 case OO_Greater:
return BO_GT;
1861 case OO_PlusEqual:
return BO_AddAssign;
1862 case OO_MinusEqual:
return BO_SubAssign;
1863 case OO_StarEqual:
return BO_MulAssign;
1864 case OO_SlashEqual:
return BO_DivAssign;
1865 case OO_PercentEqual:
return BO_RemAssign;
1866 case OO_CaretEqual:
return BO_XorAssign;
1867 case OO_AmpEqual:
return BO_AndAssign;
1868 case OO_PipeEqual:
return BO_OrAssign;
1869 case OO_LessLess:
return BO_Shl;
1870 case OO_GreaterGreater:
return BO_Shr;
1871 case OO_LessLessEqual:
return BO_ShlAssign;
1872 case OO_GreaterGreaterEqual:
return BO_ShrAssign;
1873 case OO_EqualEqual:
return BO_EQ;
1874 case OO_ExclaimEqual:
return BO_NE;
1875 case OO_LessEqual:
return BO_LE;
1876 case OO_GreaterEqual:
return BO_GE;
1877 case OO_AmpAmp:
return BO_LAnd;
1878 case OO_PipePipe:
return BO_LOr;
1879 case OO_Comma:
return BO_Comma;
1880 case OO_ArrowStar:
return BO_PtrMemI;
1887 OO_Star, OO_Slash, OO_Percent,
1889 OO_LessLess, OO_GreaterGreater,
1891 OO_Less, OO_Greater, OO_LessEqual, OO_GreaterEqual,
1892 OO_EqualEqual, OO_ExclaimEqual,
1898 OO_Equal, OO_StarEqual,
1899 OO_SlashEqual, OO_PercentEqual,
1900 OO_PlusEqual, OO_MinusEqual,
1901 OO_LessLessEqual, OO_GreaterGreaterEqual,
1902 OO_AmpEqual, OO_CaretEqual,
1906 return OverOps[Opc];
1945 InitExprs(C, initExprs.size()),
1946 LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(nullptr,
true)
1949 for (
unsigned I = 0; I != initExprs.size(); ++I) {
1955 ExprBits.InstantiationDependent =
true;
1957 ExprBits.ContainsUnexpandedParameterPack =
true;
1960 InitExprs.
insert(C, InitExprs.
end(), initExprs.begin(), initExprs.end());
1964 if (NumInits > InitExprs.
size())
1965 InitExprs.
reserve(C, NumInits);
1969 InitExprs.
resize(C, NumInits,
nullptr);
1973 if (Init >= InitExprs.
size()) {
1974 InitExprs.
insert(C, InitExprs.
end(), Init - InitExprs.
size() + 1,
nullptr);
1979 Expr *
Result = cast_or_null<Expr>(InitExprs[Init]);
1986 ArrayFillerOrUnionFieldInit = filler;
1989 for (
unsigned i = 0, e =
getNumInits(); i != e; ++i)
1990 if (inits[i] ==
nullptr)
2005 return isa<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init);
2009 assert(
isSemanticForm() &&
"syntactic form never semantically transparent");
2013 assert(
getNumInits() == 1 &&
"multiple inits in glvalue init list");
2032 assert(
isSyntacticForm() &&
"only test syntactic form as zero initializer");
2039 return Lit && Lit->
getValue() == 0;
2044 return SyntacticForm->getLocStart();
2049 E = InitExprs.
end();
2052 Beg = S->getLocStart();
2062 return SyntacticForm->getLocEnd();
2067 E = InitExprs.
rend();
2070 End = S->getLocEnd();
2082 return cast<BlockPointerType>(
getType())
2087 return TheBlock->getCaretLocation();
2090 return TheBlock->getBody();
2093 return TheBlock->getBody();
2121 case ParenExprClass:
2122 return cast<ParenExpr>(
this)->getSubExpr()->
2124 case GenericSelectionExprClass:
2125 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
2127 case CoawaitExprClass:
2128 case CoyieldExprClass:
2129 return cast<CoroutineSuspendExpr>(
this)->getResumeExpr()->
2131 case ChooseExprClass:
2132 return cast<ChooseExpr>(
this)->getChosenSubExpr()->
2134 case UnaryOperatorClass: {
2157 .isVolatileQualified())
2168 case BinaryOperatorClass: {
2180 if (IE->getValue() == 0)
2199 case CompoundAssignOperatorClass:
2200 case VAArgExprClass:
2201 case AtomicExprClass:
2204 case ConditionalOperatorClass: {
2216 case MemberExprClass:
2218 Loc = cast<MemberExpr>(
this)->getMemberLoc();
2220 R2 = cast<MemberExpr>(
this)->getBase()->getSourceRange();
2223 case ArraySubscriptExprClass:
2225 Loc = cast<ArraySubscriptExpr>(
this)->getRBracketLoc();
2226 R1 = cast<ArraySubscriptExpr>(
this)->getLHS()->getSourceRange();
2227 R2 = cast<ArraySubscriptExpr>(
this)->getRHS()->getSourceRange();
2230 case CXXOperatorCallExprClass: {
2242 case OO_ExclaimEqual:
2245 case OO_GreaterEqual:
2260 case CXXMemberCallExprClass:
2261 case UserDefinedLiteralClass: {
2263 const CallExpr *CE = cast<CallExpr>(
this);
2267 : FD->hasAttr<WarnUnusedResultAttr>();
2274 if (HasWarnUnusedResultAttr ||
2275 FD->hasAttr<PureAttr>() || FD->hasAttr<ConstAttr>()) {
2290 case UnresolvedLookupExprClass:
2291 case CXXUnresolvedConstructExprClass:
2294 case CXXTemporaryObjectExprClass:
2295 case CXXConstructExprClass: {
2297 if (Type->hasAttr<WarnUnusedAttr>()) {
2307 case ObjCMessageExprClass: {
2320 if (MD->hasAttr<WarnUnusedResultAttr>()) {
2329 case ObjCPropertyRefExprClass:
2335 case PseudoObjectExprClass: {
2349 case StmtExprClass: {
2355 const CompoundStmt *CS = cast<StmtExpr>(
this)->getSubStmt();
2358 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2360 if (
const Expr *E = dyn_cast<Expr>(
Label->getSubStmt()))
2361 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2367 Loc = cast<StmtExpr>(
this)->getLParenLoc();
2371 case CXXFunctionalCastExprClass:
2372 case CStyleCastExprClass: {
2375 const CastExpr *CE = cast<CastExpr>(
this);
2381 if (!(DRE && isa<VarDecl>(DRE->
getDecl()) &&
2382 cast<VarDecl>(DRE->
getDecl())->hasLocalStorage()) &&
2393 if (CE->
getCastKind() == CK_ConstructorConversion)
2398 dyn_cast<CXXFunctionalCastExpr>(
this)) {
2399 Loc = CXXCE->getLocStart();
2400 R1 = CXXCE->getSubExpr()->getSourceRange();
2408 case ImplicitCastExprClass: {
2409 const CastExpr *ICE = cast<ImplicitCastExpr>(
this);
2418 case CXXDefaultArgExprClass:
2419 return (cast<CXXDefaultArgExpr>(
this)
2421 case CXXDefaultInitExprClass:
2422 return (cast<CXXDefaultInitExpr>(
this)
2425 case CXXNewExprClass:
2428 case CXXDeleteExprClass:
2430 case MaterializeTemporaryExprClass:
2431 return cast<MaterializeTemporaryExpr>(
this)->GetTemporaryExpr()
2432 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2433 case CXXBindTemporaryExprClass:
2434 return cast<CXXBindTemporaryExpr>(
this)->getSubExpr()
2435 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2436 case ExprWithCleanupsClass:
2437 return cast<ExprWithCleanups>(
this)->getSubExpr()
2438 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2449 case ObjCIvarRefExprClass:
2451 case Expr::UnaryOperatorClass:
2452 return cast<UnaryOperator>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2453 case ImplicitCastExprClass:
2454 return cast<ImplicitCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2455 case MaterializeTemporaryExprClass:
2456 return cast<MaterializeTemporaryExpr>(E)->GetTemporaryExpr()
2457 ->isOBJCGCCandidate(Ctx);
2458 case CStyleCastExprClass:
2459 return cast<CStyleCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2460 case DeclRefExprClass: {
2461 const Decl *D = cast<DeclRefExpr>(E)->getDecl();
2463 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2464 if (VD->hasGlobalStorage())
2474 case MemberExprClass: {
2478 case ArraySubscriptExprClass:
2479 return cast<ArraySubscriptExpr>(E)->getBase()->isOBJCGCCandidate(Ctx);
2497 if (
const MemberExpr *mem = dyn_cast<MemberExpr>(expr)) {
2498 assert(isa<CXXMethodDecl>(mem->getMemberDecl()));
2499 return mem->getMemberDecl()->getType();
2509 assert(isa<UnresolvedMemberExpr>(expr) || isa<CXXPseudoDestructorExpr>(expr));
2517 E =
P->getSubExpr();
2521 if (
P->getOpcode() == UO_Extension) {
2522 E =
P->getSubExpr();
2527 if (!
P->isResultDependent()) {
2528 E =
P->getResultExpr();
2533 if (!
P->isConditionDependent()) {
2534 E =
P->getChosenSubExpr();
2548 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2549 E =
P->getSubExpr();
2553 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2554 E = Materialize->GetTemporaryExpr();
2558 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2559 E = NTTP->getReplacement();
2569 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2570 E =
P->getSubExpr();
2574 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2575 E = Materialize->GetTemporaryExpr();
2579 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2580 E = NTTP->getReplacement();
2595 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2596 if (
P->getCastKind() == CK_LValueToRValue) {
2597 E =
P->getSubExpr();
2601 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2602 E = Materialize->GetTemporaryExpr();
2605 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2606 E = NTTP->getReplacement();
2618 if (
CastExpr *CE = dyn_cast<CastExpr>(E)) {
2619 if (CE->getCastKind() == CK_DerivedToBase ||
2620 CE->getCastKind() == CK_UncheckedDerivedToBase ||
2621 CE->getCastKind() == CK_NoOp) {
2622 E = CE->getSubExpr();
2636 E =
P->getSubExpr();
2640 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2641 E = Materialize->GetTemporaryExpr();
2645 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2646 E = NTTP->getReplacement();
2655 if (MCE->getMethodDecl() && isa<CXXConversionDecl>(MCE->getMethodDecl()))
2656 return MCE->getImplicitObjectArgument();
2669 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2672 Expr *SE =
P->getSubExpr();
2690 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2691 E = NTTP->getReplacement();
2700 const Expr *E =
this;
2702 E = M->GetTemporaryExpr();
2705 E = ICE->getSubExprAsWritten();
2707 return isa<CXXDefaultArgExpr>(E);
2714 E = M->GetTemporaryExpr();
2717 if (ICE->getCastKind() == CK_NoOp)
2718 E = ICE->getSubExpr();
2724 E = BE->getSubExpr();
2727 if (ICE->getCastKind() == CK_NoOp)
2728 E = ICE->getSubExpr();
2747 if (!isa<ObjCPropertyRefExpr>(E))
2755 if (isa<ImplicitCastExpr>(E)) {
2756 switch (cast<ImplicitCastExpr>(E)->getCastKind()) {
2757 case CK_DerivedToBase:
2758 case CK_UncheckedDerivedToBase:
2766 if (isa<MemberExpr>(E))
2770 if (BO->isPtrMemOp())
2774 if (isa<OpaqueValueExpr>(E))
2781 const Expr *E =
this;
2786 E =
Paren->getSubExpr();
2791 if (ICE->getCastKind() == CK_NoOp ||
2792 ICE->getCastKind() == CK_LValueToRValue ||
2793 ICE->getCastKind() == CK_DerivedToBase ||
2794 ICE->getCastKind() == CK_UncheckedDerivedToBase) {
2795 E = ICE->getSubExpr();
2800 if (
const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) {
2801 if (UnOp->getOpcode() == UO_Extension) {
2802 E = UnOp->getSubExpr();
2808 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2809 E = M->GetTemporaryExpr();
2816 if (
const CXXThisExpr *This = dyn_cast<CXXThisExpr>(E))
2817 return This->isImplicit();
2825 for (
unsigned I = 0; I < Exprs.size(); ++I)
2833 const Expr **Culprit)
const {
2854 case StringLiteralClass:
2855 case ObjCEncodeExprClass:
2857 case CXXTemporaryObjectExprClass:
2858 case CXXConstructExprClass: {
2867 assert(CE->
getNumArgs() == 1 &&
"trivial ctor with > 1 argument");
2873 case CompoundLiteralExprClass: {
2877 const Expr *Exp = cast<CompoundLiteralExpr>(
this)->getInitializer();
2880 case DesignatedInitUpdateExprClass: {
2885 case InitListExprClass: {
2889 for (
unsigned i = 0; i < numInits; i++) {
2897 unsigned ElementNo = 0;
2899 for (
const auto *Field : RD->
fields()) {
2905 if (Field->isUnnamedBitfield())
2910 if (Field->isBitField()) {
2912 llvm::APSInt ResultTmp;
2919 bool RefType = Field->getType()->isReferenceType();
2930 case ImplicitValueInitExprClass:
2931 case NoInitExprClass:
2933 case ParenExprClass:
2934 return cast<ParenExpr>(
this)->getSubExpr()
2935 ->isConstantInitializer(Ctx, IsForRef, Culprit);
2936 case GenericSelectionExprClass:
2937 return cast<GenericSelectionExpr>(
this)->getResultExpr()
2938 ->isConstantInitializer(Ctx, IsForRef, Culprit);
2939 case ChooseExprClass:
2940 if (cast<ChooseExpr>(
this)->isConditionDependent()) {
2945 return cast<ChooseExpr>(
this)->getChosenSubExpr()
2947 case UnaryOperatorClass: {
2953 case CXXFunctionalCastExprClass:
2954 case CXXStaticCastExprClass:
2955 case ImplicitCastExprClass:
2956 case CStyleCastExprClass:
2957 case ObjCBridgedCastExprClass:
2958 case CXXDynamicCastExprClass:
2959 case CXXReinterpretCastExprClass:
2960 case CXXConstCastExprClass: {
2961 const CastExpr *CE = cast<CastExpr>(
this);
2975 case MaterializeTemporaryExprClass:
2976 return cast<MaterializeTemporaryExpr>(
this)->GetTemporaryExpr()
2977 ->isConstantInitializer(Ctx,
false, Culprit);
2979 case SubstNonTypeTemplateParmExprClass:
2980 return cast<SubstNonTypeTemplateParmExpr>(
this)->getReplacement()
2981 ->isConstantInitializer(Ctx,
false, Culprit);
2982 case CXXDefaultArgExprClass:
2983 return cast<CXXDefaultArgExpr>(
this)->getExpr()
2984 ->isConstantInitializer(Ctx,
false, Culprit);
2985 case CXXDefaultInitExprClass:
2986 return cast<CXXDefaultInitExpr>(
this)->getExpr()
2987 ->isConstantInitializer(Ctx,
false, Culprit);
3001 if (!FD || (FD->
getBuiltinID() != Builtin::BI__assume &&
3005 const Expr* Arg = getArg(0);
3015 const bool IncludePossibleEffects;
3019 explicit SideEffectFinder(
const ASTContext &Context,
bool IncludePossible)
3020 : Inherited(Context),
3021 IncludePossibleEffects(IncludePossible),
HasSideEffects(
false) { }
3025 void VisitExpr(
const Expr *E) {
3026 if (!HasSideEffects &&
3028 HasSideEffects =
true;
3034 bool IncludePossibleEffects)
const {
3038 if (!IncludePossibleEffects &&
getExprLoc().isMacroID())
3042 return IncludePossibleEffects;
3046 #define ABSTRACT_STMT(Type) 3047 #define STMT(Type, Base) case Type##Class: 3048 #define EXPR(Type, Base) 3049 #include "clang/AST/StmtNodes.inc" 3050 llvm_unreachable(
"unexpected Expr kind");
3052 case DependentScopeDeclRefExprClass:
3053 case CXXUnresolvedConstructExprClass:
3054 case CXXDependentScopeMemberExprClass:
3055 case UnresolvedLookupExprClass:
3056 case UnresolvedMemberExprClass:
3057 case PackExpansionExprClass:
3058 case SubstNonTypeTemplateParmPackExprClass:
3059 case FunctionParmPackExprClass:
3061 case CXXFoldExprClass:
3062 llvm_unreachable(
"shouldn't see dependent / unresolved nodes here");
3064 case DeclRefExprClass:
3065 case ObjCIvarRefExprClass:
3066 case PredefinedExprClass:
3067 case IntegerLiteralClass:
3068 case FixedPointLiteralClass:
3069 case FloatingLiteralClass:
3070 case ImaginaryLiteralClass:
3071 case StringLiteralClass:
3072 case CharacterLiteralClass:
3073 case OffsetOfExprClass:
3074 case ImplicitValueInitExprClass:
3075 case UnaryExprOrTypeTraitExprClass:
3076 case AddrLabelExprClass:
3077 case GNUNullExprClass:
3078 case ArrayInitIndexExprClass:
3079 case NoInitExprClass:
3080 case CXXBoolLiteralExprClass:
3081 case CXXNullPtrLiteralExprClass:
3082 case CXXThisExprClass:
3083 case CXXScalarValueInitExprClass:
3084 case TypeTraitExprClass:
3085 case ArrayTypeTraitExprClass:
3086 case ExpressionTraitExprClass:
3087 case CXXNoexceptExprClass:
3088 case SizeOfPackExprClass:
3089 case ObjCStringLiteralClass:
3090 case ObjCEncodeExprClass:
3091 case ObjCBoolLiteralExprClass:
3092 case ObjCAvailabilityCheckExprClass:
3093 case CXXUuidofExprClass:
3094 case OpaqueValueExprClass:
3099 case CXXOperatorCallExprClass:
3100 case CXXMemberCallExprClass:
3101 case CUDAKernelCallExprClass:
3102 case UserDefinedLiteralClass: {
3106 const Decl *FD = cast<CallExpr>(
this)->getCalleeDecl();
3107 bool IsPure = FD && (FD->
hasAttr<ConstAttr>() || FD->
hasAttr<PureAttr>());
3108 if (IsPure || !IncludePossibleEffects)
3113 case BlockExprClass:
3114 case CXXBindTemporaryExprClass:
3115 if (!IncludePossibleEffects)
3119 case MSPropertyRefExprClass:
3120 case MSPropertySubscriptExprClass:
3121 case CompoundAssignOperatorClass:
3122 case VAArgExprClass:
3123 case AtomicExprClass:
3124 case CXXThrowExprClass:
3125 case CXXNewExprClass:
3126 case CXXDeleteExprClass:
3127 case CoawaitExprClass:
3128 case DependentCoawaitExprClass:
3129 case CoyieldExprClass:
3133 case StmtExprClass: {
3135 SideEffectFinder Finder(Ctx, IncludePossibleEffects);
3136 Finder.Visit(cast<StmtExpr>(
this)->getSubStmt());
3137 return Finder.hasSideEffects();
3140 case ExprWithCleanupsClass:
3141 if (IncludePossibleEffects)
3142 if (cast<ExprWithCleanups>(
this)->cleanupsHaveSideEffects())
3146 case ParenExprClass:
3147 case ArraySubscriptExprClass:
3148 case OMPArraySectionExprClass:
3149 case MemberExprClass:
3150 case ConditionalOperatorClass:
3151 case BinaryConditionalOperatorClass:
3152 case CompoundLiteralExprClass:
3153 case ExtVectorElementExprClass:
3154 case DesignatedInitExprClass:
3155 case DesignatedInitUpdateExprClass:
3156 case ArrayInitLoopExprClass:
3157 case ParenListExprClass:
3158 case CXXPseudoDestructorExprClass:
3159 case CXXStdInitializerListExprClass:
3160 case SubstNonTypeTemplateParmExprClass:
3161 case MaterializeTemporaryExprClass:
3162 case ShuffleVectorExprClass:
3163 case ConvertVectorExprClass:
3164 case AsTypeExprClass:
3168 case UnaryOperatorClass:
3169 if (cast<UnaryOperator>(
this)->isIncrementDecrementOp())
3173 case BinaryOperatorClass:
3174 if (cast<BinaryOperator>(
this)->isAssignmentOp())
3178 case InitListExprClass:
3181 if (E->HasSideEffects(Ctx, IncludePossibleEffects))
3185 case GenericSelectionExprClass:
3186 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
3189 case ChooseExprClass:
3190 return cast<ChooseExpr>(
this)->getChosenSubExpr()->HasSideEffects(
3191 Ctx, IncludePossibleEffects);
3193 case CXXDefaultArgExprClass:
3194 return cast<CXXDefaultArgExpr>(
this)->getExpr()->HasSideEffects(
3195 Ctx, IncludePossibleEffects);
3197 case CXXDefaultInitExprClass: {
3198 const FieldDecl *FD = cast<CXXDefaultInitExpr>(
this)->getField();
3200 return E->HasSideEffects(Ctx, IncludePossibleEffects);
3205 case CXXDynamicCastExprClass: {
3213 case ImplicitCastExprClass:
3214 case CStyleCastExprClass:
3215 case CXXStaticCastExprClass:
3216 case CXXReinterpretCastExprClass:
3217 case CXXConstCastExprClass:
3218 case CXXFunctionalCastExprClass: {
3223 if (!IncludePossibleEffects)
3226 const CastExpr *CE = cast<CastExpr>(
this);
3233 case CXXTypeidExprClass:
3236 return cast<CXXTypeidExpr>(
this)->isPotentiallyEvaluated();
3238 case CXXConstructExprClass:
3239 case CXXTemporaryObjectExprClass: {
3248 case CXXInheritedCtorInitExprClass: {
3249 const auto *ICIE = cast<CXXInheritedCtorInitExpr>(
this);
3250 if (!ICIE->getConstructor()->isTrivial() && IncludePossibleEffects)
3255 case LambdaExprClass: {
3256 const LambdaExpr *LE = cast<LambdaExpr>(
this);
3266 case PseudoObjectExprClass: {
3273 const Expr *Subexpr = *I;
3275 Subexpr = OVE->getSourceExpr();
3282 case ObjCBoxedExprClass:
3283 case ObjCArrayLiteralClass:
3284 case ObjCDictionaryLiteralClass:
3285 case ObjCSelectorExprClass:
3286 case ObjCProtocolExprClass:
3287 case ObjCIsaExprClass:
3288 case ObjCIndirectCopyRestoreExprClass:
3289 case ObjCSubscriptRefExprClass:
3290 case ObjCBridgedCastExprClass:
3291 case ObjCMessageExprClass:
3292 case ObjCPropertyRefExprClass:
3294 if (IncludePossibleEffects)
3302 cast<Expr>(SubStmt)->HasSideEffects(Ctx, IncludePossibleEffects))
3317 explicit NonTrivialCallFinder(
const ASTContext &Context)
3318 : Inherited(Context), NonTrivial(
false) { }
3322 void VisitCallExpr(
const CallExpr *E) {
3324 = dyn_cast_or_null<const CXXMethodDecl>(E->
getCalleeDecl())) {
3325 if (Method->isTrivial()) {
3327 Inherited::VisitStmt(E);
3338 Inherited::VisitStmt(E);
3347 Inherited::VisitStmt(E);
3357 NonTrivialCallFinder Finder(Ctx);
3359 return Finder.hasNonTrivialCall();
3374 llvm_unreachable(
"Unexpected value dependent expression!");
3396 bool PointeeHasDefaultAS =
3404 if (PointeeHasDefaultAS && Pointee->
isVoidType() &&
3405 CE->getSubExpr()->getType()->isIntegerType())
3406 return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3409 }
else if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(
this)) {
3411 return ICE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3412 }
else if (
const ParenExpr *PE = dyn_cast<ParenExpr>(
this)) {
3415 return PE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3417 dyn_cast<GenericSelectionExpr>(
this)) {
3418 if (GE->isResultDependent())
3420 return GE->getResultExpr()->isNullPointerConstant(Ctx, NPC);
3421 }
else if (
const ChooseExpr *CE = dyn_cast<ChooseExpr>(
this)) {
3422 if (CE->isConditionDependent())
3424 return CE->getChosenSubExpr()->isNullPointerConstant(Ctx, NPC);
3426 = dyn_cast<CXXDefaultArgExpr>(
this)) {
3428 return DefaultArg->getExpr()->isNullPointerConstant(Ctx, NPC);
3430 = dyn_cast<CXXDefaultInitExpr>(
this)) {
3432 return DefaultInit->getExpr()->isNullPointerConstant(Ctx, NPC);
3433 }
else if (isa<GNUNullExpr>(
this)) {
3437 = dyn_cast<MaterializeTemporaryExpr>(
this)) {
3438 return M->GetTemporaryExpr()->isNullPointerConstant(Ctx, NPC);
3439 }
else if (
const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(
this)) {
3440 if (
const Expr *Source = OVE->getSourceExpr())
3441 return Source->isNullPointerConstant(Ctx, NPC);
3445 if (
getType()->isNullPtrType())
3450 UT && UT->getDecl()->hasAttr<TransparentUnionAttr>())
3452 const Expr *InitExpr = CLE->getInitializer();
3453 if (
const InitListExpr *ILE = dyn_cast<InitListExpr>(InitExpr))
3457 if (!
getType()->isIntegerType() ||
3480 if (isa<IntegerLiteral>(
this))
3488 const Expr *E =
this;
3492 "expression is not a property reference");
3495 if (BO->getOpcode() == BO_Comma) {
3504 return cast<ObjCPropertyRefExpr>(E);
3529 if (ICE->getCastKind() == CK_LValueToRValue ||
3530 (ICE->getValueKind() !=
VK_RValue && ICE->getCastKind() == CK_NoOp))
3536 if (
MemberExpr *MemRef = dyn_cast<MemberExpr>(E))
3537 if (
FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
3538 if (Field->isBitField())
3547 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E)) {
3548 if (
FieldDecl *Field = dyn_cast<FieldDecl>(DeclRef->getDecl()))
3549 if (Field->isBitField())
3552 if (
BindingDecl *BD = dyn_cast<BindingDecl>(DeclRef->getDecl()))
3553 if (
Expr *E = BD->getBinding())
3558 if (BinOp->isAssignmentOp() && BinOp->getLHS())
3559 return BinOp->getLHS()->getSourceBitField();
3561 if (BinOp->getOpcode() == BO_Comma && BinOp->getRHS())
3562 return BinOp->getRHS()->getSourceBitField();
3566 if (UnOp->isPrefix() && UnOp->isIncrementDecrementOp())
3567 return UnOp->getSubExpr()->getSourceBitField();
3578 ICE->getCastKind() == CK_NoOp)
3587 if (isa<ExtVectorElementExpr>(E))
3590 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
3591 if (
auto *BD = dyn_cast<BindingDecl>(DRE->getDecl()))
3592 if (
auto *E = BD->getBinding())
3601 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
3602 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
3604 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
3613 return getBase()->getType()->isPointerType();
3618 return VT->getNumElements();
3626 StringRef Comp = Accessor->getName();
3629 if (Comp ==
"hi" || Comp ==
"lo" || Comp ==
"even" || Comp ==
"odd")
3633 if (Comp[0] ==
's' || Comp[0] ==
'S')
3634 Comp = Comp.substr(1);
3636 for (
unsigned i = 0, e = Comp.size(); i != e; ++i)
3637 if (Comp.substr(i + 1).find(Comp[i]) != StringRef::npos)
3646 StringRef Comp = Accessor->getName();
3647 bool isNumericAccessor =
false;
3648 if (Comp[0] ==
's' || Comp[0] ==
'S') {
3649 Comp = Comp.substr(1);
3650 isNumericAccessor =
true;
3653 bool isHi = Comp ==
"hi";
3654 bool isLo = Comp ==
"lo";
3655 bool isEven = Comp ==
"even";
3656 bool isOdd = Comp ==
"odd";
3658 for (
unsigned i = 0, e = getNumElements(); i != e; ++i) {
3672 Elts.push_back(Index);
3680 Type->isDependentType(), Type->isDependentType(),
3681 Type->isInstantiationDependentType(),
3683 BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size())
3685 SubExprs =
new (
C)
Stmt*[args.size()];
3686 for (
unsigned i = 0; i != args.size(); i++) {
3692 ExprBits.InstantiationDependent =
true;
3694 ExprBits.ContainsUnexpandedParameterPack =
true;
3696 SubExprs[i] = args[i];
3703 this->NumExprs = Exprs.size();
3704 SubExprs =
new (
C)
Stmt*[NumExprs];
3705 memcpy(SubExprs, Exprs.data(),
sizeof(
Expr *) * Exprs.size());
3714 bool ContainsUnexpandedParameterPack,
3715 unsigned ResultIndex)
3716 :
Expr(GenericSelectionExprClass,
3717 AssocExprs[ResultIndex]->
getType(),
3723 ContainsUnexpandedParameterPack),
3725 SubExprs(new (Context)
Stmt*[END_EXPR+AssocExprs.size()]),
3726 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
3727 GenericLoc(GenericLoc), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
3728 SubExprs[CONTROLLING] = ControllingExpr;
3729 assert(AssocTypes.size() == AssocExprs.size());
3730 std::copy(AssocTypes.begin(), AssocTypes.end(), this->AssocTypes);
3731 std::copy(AssocExprs.begin(), AssocExprs.end(), SubExprs+END_EXPR);
3740 bool ContainsUnexpandedParameterPack)
3741 :
Expr(GenericSelectionExprClass,
3742 Context.DependentTy,
3748 ContainsUnexpandedParameterPack),
3750 SubExprs(new (Context)
Stmt*[END_EXPR+AssocExprs.size()]),
3751 NumAssocs(AssocExprs.size()), ResultIndex(-1U), GenericLoc(GenericLoc),
3752 DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
3753 SubExprs[CONTROLLING] = ControllingExpr;
3754 assert(AssocTypes.size() == AssocExprs.size());
3755 std::copy(AssocTypes.begin(), AssocTypes.end(), this->AssocTypes);
3756 std::copy(AssocExprs.begin(), AssocExprs.end(), SubExprs+END_EXPR);
3765 if (Field.NameOrField & 0x01)
3766 return reinterpret_cast<IdentifierInfo *
>(Field.NameOrField&~0x01);
3768 return getField()->getIdentifier();
3777 :
Expr(DesignatedInitExprClass, Ty,
3782 EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
3783 NumDesignators(Designators.size()), NumSubExprs(IndexExprs.size() + 1) {
3784 this->Designators =
new (
C)
Designator[NumDesignators];
3792 unsigned IndexIdx = 0;
3793 for (
unsigned I = 0; I != NumDesignators; ++I) {
3794 this->Designators[I] = Designators[I];
3796 if (this->Designators[I].isArrayDesignator()) {
3798 Expr *Index = IndexExprs[IndexIdx];
3802 ExprBits.InstantiationDependent =
true;
3805 ExprBits.ContainsUnexpandedParameterPack =
true;
3808 *Child++ = IndexExprs[IndexIdx++];
3809 }
else if (this->Designators[I].isArrayRangeDesignator()) {
3811 Expr *Start = IndexExprs[IndexIdx];
3812 Expr *
End = IndexExprs[IndexIdx + 1];
3816 ExprBits.InstantiationDependent =
true;
3819 ExprBits.InstantiationDependent =
true;
3825 ExprBits.ContainsUnexpandedParameterPack =
true;
3828 *Child++ = IndexExprs[IndexIdx++];
3829 *Child++ = IndexExprs[IndexIdx++];
3833 assert(IndexIdx == IndexExprs.size() &&
"Wrong number of index expressions");
3841 bool UsesColonSyntax,
Expr *Init) {
3842 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(IndexExprs.size() + 1),
3845 ColonOrEqualLoc, UsesColonSyntax,
3850 unsigned NumIndexExprs) {
3851 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(NumIndexExprs + 1),
3858 unsigned NumDesigs) {
3860 NumDesignators = NumDesigs;
3861 for (
unsigned I = 0; I != NumDesigs; ++I)
3862 Designators[I] = Desigs[I];
3889 return getInit()->getLocEnd();
3899 "Requires array range designator");
3905 "Requires array range designator");
3914 unsigned NumNewDesignators = Last -
First;
3915 if (NumNewDesignators == 0) {
3916 std::copy_backward(Designators + Idx + 1,
3917 Designators + NumDesignators,
3919 --NumNewDesignators;
3921 }
else if (NumNewDesignators == 1) {
3922 Designators[Idx] = *
First;
3927 =
new (
C)
Designator[NumDesignators - 1 + NumNewDesignators];
3928 std::copy(Designators, Designators + Idx, NewDesignators);
3929 std::copy(First, Last, NewDesignators + Idx);
3930 std::copy(Designators + Idx + 1, Designators + NumDesignators,
3931 NewDesignators + Idx + NumNewDesignators);
3932 Designators = NewDesignators;
3933 NumDesignators = NumDesignators - 1 + NumNewDesignators;
3940 BaseAndUpdaterExprs[0] = baseExpr;
3944 BaseAndUpdaterExprs[1] = ILE;
3960 NumExprs(exprs.size()), LParenLoc(lparenloc), RParenLoc(rparenloc) {
3961 Exprs =
new (
C)
Stmt*[exprs.size()];
3962 for (
unsigned i = 0; i != exprs.size(); ++i) {
3968 ExprBits.InstantiationDependent =
true;
3970 ExprBits.ContainsUnexpandedParameterPack =
true;
3972 Exprs[i] = exprs[i];
3978 e = ewc->getSubExpr();
3980 e = m->GetTemporaryExpr();
3981 e = cast<CXXConstructExpr>(e)->getArg(0);
3983 e = ice->getSubExpr();
3984 return cast<OpaqueValueExpr>(e);
3989 unsigned numSemanticExprs) {
3991 Context.
Allocate(totalSizeToAlloc<Expr *>(1 + numSemanticExprs),
3996 PseudoObjectExpr::PseudoObjectExpr(
EmptyShell shell,
unsigned numSemanticExprs)
3997 :
Expr(PseudoObjectExprClass, shell) {
4003 unsigned resultIndex) {
4004 assert(syntax &&
"no syntactic expression!");
4005 assert(semantics.size() &&
"no semantic expressions!");
4009 if (resultIndex == NoResult) {
4013 assert(resultIndex < semantics.size());
4014 type = semantics[resultIndex]->getType();
4015 VK = semantics[resultIndex]->getValueKind();
4019 void *buffer = C.
Allocate(totalSizeToAlloc<Expr *>(semantics.size() + 1),
4027 unsigned resultIndex)
4029 false,
false,
false,
false) {
4033 for (
unsigned i = 0, e = semantics.size() + 1; i != e; ++i) {
4034 Expr *E = (i == 0 ? syntax : semantics[i-1]);
4035 getSubExprsBuffer()[i] = E;
4042 ExprBits.InstantiationDependent =
true;
4044 ExprBits.ContainsUnexpandedParameterPack =
true;
4046 if (isa<OpaqueValueExpr>(E))
4047 assert(cast<OpaqueValueExpr>(E)->getSourceExpr() !=
nullptr &&
4048 "opaque-value semantic expressions for pseudo-object " 4049 "operations must have sources");
4068 if (isArgumentType()) {
4070 dyn_cast<VariableArrayType>(getArgumentType().getTypePtr()))
4081 NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op)
4083 assert(args.size() ==
getNumSubExprs(op) &&
"wrong number of subexpressions");
4084 for (
unsigned i = 0; i != args.size(); i++) {
4090 ExprBits.InstantiationDependent =
true;
4092 ExprBits.ContainsUnexpandedParameterPack =
true;
4094 SubExprs[i] = args[i];
4100 case AO__c11_atomic_init:
4101 case AO__opencl_atomic_init:
4102 case AO__c11_atomic_load:
4103 case AO__atomic_load_n:
4106 case AO__opencl_atomic_load:
4107 case AO__c11_atomic_store:
4108 case AO__c11_atomic_exchange:
4109 case AO__atomic_load:
4110 case AO__atomic_store:
4111 case AO__atomic_store_n:
4112 case AO__atomic_exchange_n:
4113 case AO__c11_atomic_fetch_add:
4114 case AO__c11_atomic_fetch_sub:
4115 case AO__c11_atomic_fetch_and:
4116 case AO__c11_atomic_fetch_or:
4117 case AO__c11_atomic_fetch_xor:
4118 case AO__atomic_fetch_add:
4119 case AO__atomic_fetch_sub:
4120 case AO__atomic_fetch_and:
4121 case AO__atomic_fetch_or:
4122 case AO__atomic_fetch_xor:
4123 case AO__atomic_fetch_nand:
4124 case AO__atomic_add_fetch:
4125 case AO__atomic_sub_fetch:
4126 case AO__atomic_and_fetch:
4127 case AO__atomic_or_fetch:
4128 case AO__atomic_xor_fetch:
4129 case AO__atomic_nand_fetch:
4130 case AO__atomic_fetch_min:
4131 case AO__atomic_fetch_max:
4134 case AO__opencl_atomic_store:
4135 case AO__opencl_atomic_exchange:
4136 case AO__opencl_atomic_fetch_add:
4137 case AO__opencl_atomic_fetch_sub:
4138 case AO__opencl_atomic_fetch_and:
4139 case AO__opencl_atomic_fetch_or:
4140 case AO__opencl_atomic_fetch_xor:
4141 case AO__opencl_atomic_fetch_min:
4142 case AO__opencl_atomic_fetch_max:
4143 case AO__atomic_exchange:
4146 case AO__c11_atomic_compare_exchange_strong:
4147 case AO__c11_atomic_compare_exchange_weak:
4150 case AO__opencl_atomic_compare_exchange_strong:
4151 case AO__opencl_atomic_compare_exchange_weak:
4152 case AO__atomic_compare_exchange:
4153 case AO__atomic_compare_exchange_n:
4156 llvm_unreachable(
"unknown atomic op");
4162 return AT->getValueType();
4167 unsigned ArraySectionCount = 0;
4168 while (
auto *OASE = dyn_cast<OMPArraySectionExpr>(Base->
IgnoreParens())) {
4169 Base = OASE->getBase();
4170 ++ArraySectionCount;
4174 Base = ASE->getBase();
4175 ++ArraySectionCount;
4178 auto OriginalTy = Base->
getType();
4179 if (
auto *DRE = dyn_cast<DeclRefExpr>(Base))
4180 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl()))
4181 OriginalTy = PVD->getOriginalType().getNonReferenceType();
4183 for (
unsigned Cnt = 0; Cnt < ArraySectionCount; ++Cnt) {
4184 if (OriginalTy->isAnyPointerType())
4187 assert (OriginalTy->isArrayType());
child_iterator child_begin()
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
A call to an overloaded operator written using operator syntax.
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
Represents a single C99 designator.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
void setValueDependent(bool VD)
Set whether this expression is value-dependent or not.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Defines the clang::ASTContext interface.
SourceLocation getBeginLoc() const LLVM_READONLY
static std::string ComputeName(IdentType IT, const Decl *CurrentDecl)
const CXXDestructorDecl * getDestructor() const
Represents a function declaration or definition.
Expr * getArrayIndex(const Designator &D) const
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D, QualType T, bool &TypeDependent, bool &ValueDependent, bool &InstantiationDependent)
Compute the type-, value-, and instantiation-dependence of a declaration reference based on the decla...
bool isFixedPointType() const
Return true if this is a fixed point type according to ISO/IEC JTC1 SC22 WG14 N1169.
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens...
SourceLocation getRParenLoc() const
void setArrayFiller(Expr *filler)
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
SourceLocation getBeginLoc() const LLVM_READONLY
QualType getPointeeType() const
A (possibly-)qualified type.
unsigned getOffsetOfStringByte(const Token &TheTok, unsigned ByteNo) const
getOffsetOfStringByte - This function returns the offset of the specified byte of the string data rep...
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
static StringLiteral * CreateEmpty(const ASTContext &C, unsigned NumStrs)
Construct an empty string literal.
const DeclarationNameLoc & getInfo() const
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
static Decl * castFromDeclContext(const DeclContext *)
unsigned FieldLoc
The location of the field name in the designated initializer.
SourceLocation getLocEnd() const LLVM_READONLY
const Expr * getInit(unsigned Init) const
Stmt - This represents one statement.
DesignatedInitUpdateExpr(const ASTContext &C, SourceLocation lBraceLoc, Expr *baseExprs, SourceLocation rBraceLoc)
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
FunctionType - C99 6.7.5.3 - Function Declarators.
SourceLocation getLocationOfByte(unsigned ByteNo, const SourceManager &SM, const LangOptions &Features, const TargetInfo &Target, unsigned *StartToken=nullptr, unsigned *StartTokenByteOffset=nullptr) const
getLocationOfByte - Return a source location that points to the specified byte of this string literal...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Defines the SourceManager interface.
bool hasNonTrivialCall(const ASTContext &Ctx) const
Determine whether this expression involves a call to any function that is not trivial.
bool isRecordType() const
void FixedPointValueToString(SmallVectorImpl< char > &Str, const llvm::APSInt &Val, unsigned Scale, unsigned Radix)
reverse_iterator rbegin()
unsigned size() const
Retrieve the number of template arguments in this template argument list.
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
SourceLocation getLocEnd() const LLVM_READONLY
void setSemantics(const llvm::fltSemantics &Sem)
Set the APFloat semantics this literal uses.
Decl - This represents one declaration (or definition), e.g.
bool hasUnusedResultAttr() const
Returns true if this function or its return type has the warn_unused_result attribute.
FloatingLiteralBitfields FloatingLiteralBits
void getEncodedElementAccess(SmallVectorImpl< uint32_t > &Elts) const
getEncodedElementAccess - Encode the elements accessed into an llvm aggregate Constant of ConstantInt...
bool isTransparent() const
Is this a transparent initializer list (that is, an InitListExpr that is purely syntactic, and whose semantics are that of the sole contained initializer)?
Defines the C++ template declaration subclasses.
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
iterator insert(const ASTContext &C, iterator I, const T &Elt)
ParenExpr - This represents a parethesized expression, e.g.
NamedDecl * getDecl() const
bool isExplicitSpecialization() const
The base class of the type hierarchy.
bool isSemanticForm() const
llvm::iterator_range< child_iterator > child_range
Represents an array type, per C99 6.7.5.2 - Array Declarators.
DeclRefExprBitfields DeclRefExprBits
Represents a call to a C++ constructor.
NamedDecl * getParam(unsigned Idx)
SourceLocation getLParenLoc() const
const TargetInfo & getTargetInfo() const
QualType adjustStringLiteralBaseType(QualType StrLTy) const
A container of type source information.
bool containsDuplicateElements() const
containsDuplicateElements - Return true if any element access is repeated.
static StringLiteral * Create(const ASTContext &C, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumStrs)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
CallExpr(const ASTContext &C, StmtClass SC, Expr *fn, ArrayRef< Expr *> preargs, ArrayRef< Expr *> args, QualType t, ExprValueKind VK, SourceLocation rparenloc)
Describes the capture of a variable or of this, or of a C++1y init-capture.
unsigned getCharWidth() const
Represents a C++ constructor within a class.
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Expr * ignoreParenBaseCasts() LLVM_READONLY
Ignore parentheses and derived-to-base casts.
QualType getElementType() const
SourceLocation getEndLoc() const LLVM_READONLY
StringRef getBufferData(FileID FID, bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
SourceLocation getLocStart() const LLVM_READONLY
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
static OffsetOfExpr * CreateEmpty(const ASTContext &C, unsigned NumComps, unsigned NumExprs)
static const OpaqueValueExpr * findInCopyConstruct(const Expr *expr)
Given an expression which invokes a copy constructor — i.e.
Represents a variable declaration or definition.
const ObjCPropertyRefExpr * getObjCProperty() const
If this expression is an l-value for an Objective C property, find the underlying property reference ...
CompoundLiteralExpr - [C99 6.5.2.5].
bool isEnumeralType() const
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const T * getAs() const
Member-template getAs<specific type>'.
MangleContext * createMangleContext()
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type...
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
void setInit(unsigned Init, Expr *expr)
ObjCMethodDecl - Represents an instance or class method declaration.
PredefinedExpr(SourceLocation L, QualType FNTy, IdentType IT, StringLiteral *SL)
bool isIdiomaticZeroInitializer(const LangOptions &LangOpts) const
Is this the zero initializer {0} in a language which considers it idiomatic?
Stores a list of template parameters for a TemplateDecl and its derived classes.
static DeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasQualifier, bool HasFoundDecl, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Construct an empty declaration reference expression.
Describes how types, statements, expressions, and declarations should be printed. ...
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
static bool isAssignmentOp(Opcode Opc)
Defines the clang::Expr interface and subclasses for C++ expressions.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
LabelStmt - Represents a label, which has a substatement.
Represents a struct/union/class.
Represents a C99 designated initializer expression.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
One of these records is kept for each identifier that is lexed.
Represents a class template specialization, which refers to a class template with a given set of temp...
unsigned GetStringLength() const
const Expr * getBestDynamicClassTypeExpr() const
Get the inner expression that determines the best dynamic class.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
StmtIterator cast_away_const(const ConstStmtIterator &RHS)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
unsigned getChar32Width() const
getChar32Width/Align - Return the size of 'char32_t' for this target, in bits.
field_range fields() const
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
Represents a member of a struct/union/class.
void setNumArgs(const ASTContext &C, unsigned NumArgs)
setNumArgs - This changes the number of arguments present in this call.
static DesignatedInitExpr * Create(const ASTContext &C, llvm::ArrayRef< Designator > Designators, ArrayRef< Expr *> IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
bool isReferenceType() const
Token - This structure provides full information about a lexed token.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
bool isArrow() const
isArrow - Return true if the base expression is a pointer to vector, return false if the base express...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
NestedNameSpecifierLoc QualifierLoc
The nested-name-specifier that qualifies the name, including source-location information.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
struct FieldDesignator Field
A field designator, e.g., ".x".
const Expr *const * const_semantics_iterator
ShuffleVectorExpr(const ASTContext &C, ArrayRef< Expr *> args, QualType Type, SourceLocation BLoc, SourceLocation RP)
Provides information about a function template specialization, which is a FunctionDecl that has been ...
StringRef getOpcodeStr() const
Describes an C or C++ initializer list.
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx) const
EvaluateAsBooleanCondition - Return true if this is a constant which we can fold and convert to a boo...
void setValue(const ASTContext &C, const llvm::APInt &Val)
static FixedPointLiteral * CreateFromRawInt(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l, unsigned Scale)
bool isBitField() const
Determines whether this field is a bitfield.
SourceLocation getEndLoc() const LLVM_READONLY
An lvalue ref-qualifier was provided (&).
< Capturing the *this object by copy
A convenient class for passing around template argument information.
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
NullPointerConstantValueDependence
Enumeration used to describe how isNullPointerConstant() should cope with value-dependent expressions...
unsigned getNumPreArgs() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
static bool isRecordType(QualType T)
semantics_iterator semantics_end()
A builtin binary operation expression such as "x + y" or "x <= y".
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isBoundMemberFunction(ASTContext &Ctx) const
Returns true if this expression is a bound member function.
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
field_iterator field_begin() const
SourceLocation getCaretLocation() const
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Characters, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token...
static bool isBooleanType(QualType Ty)
An adjustment to be made to the temporary created when emitting a reference binding, which accesses a particular subobject of that temporary.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Represents binding an expression to a temporary.
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
CXXTemporary * getTemporary()
bool isCXX98IntegralConstantExpr(const ASTContext &Ctx) const
isCXX98IntegralConstantExpr - Return true if this expression is an integral constant expression in C+...
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
An ordinary object is located at an address in memory.
Represents the body of a CapturedStmt, and serves as its DeclContext.
Represents an ObjC class declaration.
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Expression is a GNU-style __null constant.
bool isExplicitSpecialization() const
const Stmt * getBody() const
A binding in a decomposition declaration.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
bool isUnevaluated(unsigned ID) const
Returns true if this builtin does not perform the side-effects of its arguments.
A default argument (C++ [dcl.fct.default]).
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
void setIntValue(const ASTContext &C, const llvm::APInt &Val)
bool isObjCSelfExpr() const
Check if this expression is the ObjC 'self' implicit parameter.
ParenListExpr(const ASTContext &C, SourceLocation lparenloc, ArrayRef< Expr *> exprs, SourceLocation rparenloc)
Represents the this expression in C++.
static bool isNullPointerArithmeticExtension(ASTContext &Ctx, Opcode Opc, Expr *LHS, Expr *RHS)
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
bool isInstantiationDependent() const
Whether this nested name specifier involves a template parameter.
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
bool isUnevaluatedBuiltinCall(const ASTContext &Ctx) const
Returns true if this is a call to a builtin which does not evaluate side-effects within its arguments...
ConditionalOperator - The ?: ternary operator.
llvm::iterator_range< const_child_iterator > const_child_range
CompoundStmt - This represents a group of statements like { stmt stmt }.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
bool EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsLValue - Evaluate an expression to see if we can fold it to an lvalue with link time known ...
Expr * IgnoreParenNoopCasts(ASTContext &Ctx) LLVM_READONLY
IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the value (including ptr->int ...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
CastKind
CastKind - The kind of operation required for a conversion.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
Specifies that the expression should never be value-dependent.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
InitListExpr * getUpdater() const
void outputString(raw_ostream &OS) const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
ConstStmtIterator const_child_iterator
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Exposes information about the current target.
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
void setString(const ASTContext &C, StringRef Str, StringKind Kind, bool IsPascal)
Sets the string data to the given string data.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
SourceLocation getLocStart() const LLVM_READONLY
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Expr - This represents one expression.
void setDesignators(const ASTContext &C, const Designator *Desigs, unsigned NumDesigs)
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
SourceLocation getEndLoc() const LLVM_READONLY
const T * castAs() const
Member-template castAs<specific type>.
void setTypeDependent(bool TD)
Set whether this expression is type-dependent or not.
Represents a C++ destructor within a class.
bool isFieldDesignator() const
unsigned getNumInits() const
const Expr * getCallee() const
const Expr * skipRValueSubobjectAdjustments() const
field_iterator field_end() const
DeclContext * getDeclContext()
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
Represents the type decltype(expr) (C++11).
ArrayRef< Expr * > inits()
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
Extra data stored in some MemberExpr objects.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
An expression that sends a message to the given Objective-C object or class.
InitListExpr(const ASTContext &C, SourceLocation lbraceloc, ArrayRef< Expr *> initExprs, SourceLocation rbraceloc)
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
unsigned Index
Location of the first index expression within the designated initializer expression's list of subexpr...
Represents a GCC generic vector type.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Allow UB that we can give a value, but not arbitrary unmodeled side effects.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
The result type of a method or function.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.
ImplicitParamDecl * getSelfDecl() const
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
SourceRange getSourceRange() const
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
unsigned getBuiltinCallee() const
getBuiltinCallee - If this is a call to a builtin, return the builtin ID of the callee.
unsigned getWCharWidth() const
getWCharWidth/Align - Return the size of 'wchar_t' for this target, in bits.
RecordDecl * getDecl() const
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Expr * IgnoreCasts() LLVM_READONLY
Ignore casts. Strip off any CastExprs, returning their operand.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
const llvm::fltSemantics & getSemantics() const
Return the APFloat semantics this literal uses.
Expr * IgnoreConversionOperator() LLVM_READONLY
IgnoreConversionOperator - Ignore conversion operator.
AtomicExpr(SourceLocation BLoc, ArrayRef< Expr *> args, QualType t, AtomicOp op, SourceLocation RP)
unsigned DotLoc
The location of the '.' in the designated initializer.
UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, TypeSourceInfo *TInfo, QualType resultType, SourceLocation op, SourceLocation rp)
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
void ExpandDesignator(const ASTContext &C, unsigned Idx, const Designator *First, const Designator *Last)
Replaces the designator at index Idx with the series of designators in [First, Last).
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
QualType getCanonicalType() const
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Encodes a location in the source.
QualType getReturnType() const
SourceLocation getOperatorLoc() const
PseudoObjectExprBitfields PseudoObjectExprBits
LangAS getAddressSpace() const
Return the address space of this type.
Expression is not a Null pointer constant.
Expr * getSubExpr() const
CastKind getCastKind() const
static const FieldDecl * getTargetFieldForToUnionCast(QualType unionType, QualType opType)
ObjCMethodFamily getMethodFamily() const
unsigned getChar16Width() const
getChar16Width/Align - Return the size of 'char16_t' for this target, in bits.
Represents a call to a member function that may be written either with member call syntax (e...
ASTContext & getASTContext() const LLVM_READONLY
SourceLocation getLocStart() const LLVM_READONLY
static QualType getUnderlyingType(const SubRegion *R)
unsigned int BasePathSizeTy
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr *> exprs, SourceLocation RParenLoc)
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents a static or instance method of a struct/union/class.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
std::string getValueAsString(unsigned Radix) const
const ParmVarDecl * getParamDecl(unsigned i) const
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
Expr * updateInit(const ASTContext &C, unsigned Init, Expr *expr)
Updates the initializer at index Init with the new expression expr, and returns the old expression at...
SourceLocation getEndLoc() const LLVM_READONLY
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
AccessSpecifier getAccess() const
bool isKnownToHaveBooleanValue() const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
StringLiteral * getFunctionName()
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
Expr ** getInits()
Retrieve the set of initializers.
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
SourceLocation getLocEnd() const LLVM_READONLY
static DesignatedInitExpr * CreateEmpty(const ASTContext &C, unsigned NumIndexExprs)
const CXXRecordDecl * getBestDynamicClassType() const
For an expression of class type or pointer to class type, return the most derived class decl the expr...
Expr * getArrayRangeStart(const Designator &D) const
const ObjCMethodDecl * getMethodDecl() const
bool isVectorType() const
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
An rvalue ref-qualifier was provided (&&).
unsigned LBracketLoc
The location of the '[' starting the array range designator.
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
LLVM_READONLY bool isPrintable(unsigned char c)
Return true if this character is an ASCII printable character; that is, a character that should take ...
void sawArrayRangeDesignator(bool ARD=true)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
static MemberExpr * Create(const ASTContext &C, Expr *base, bool isarrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *memberdecl, DeclAccessPair founddecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *targs, QualType ty, ExprValueKind VK, ExprObjectKind OK)
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
A POD class for pairing a NamedDecl* with an access specifier.
void * Allocate(size_t Size, unsigned Align=8) const
Represents a C11 generic selection.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getDesignatorsSourceRange() const
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Dataflow Directional Tag Classes.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getBeginLoc() const LLVM_READONLY
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
EvalResult is a struct with detailed info about an evaluated expression.
bool hasSideEffects(Expr *E, ASTContext &Ctx)
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Decl * getReferencedDeclOfCallee()
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
A field designator, e.g., ".x".
The same as PrettyFunction, except that the 'virtual' keyword is omitted for virtual member functions...
void setExprs(const ASTContext &C, ArrayRef< Expr *> Exprs)
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
AccessSpecifier getAccess() const
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
StmtClass getStmtClass() const
const char * getCastKindName() const
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isBooleanType() const
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
SourceLocation getLocStart() const LLVM_READONLY
void resize(const ASTContext &C, unsigned N, const T &NV)
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr *> semantic, unsigned resultIndex)
void setInstantiationDependent(bool ID)
Set whether this expression is instantiation-dependent or not.
Expression is a C++11 nullptr.
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
unsigned getNumElements() const
getNumElements - Get the number of components being selected.
semantics_iterator semantics_begin()
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
ExplicitCastExpr - An explicit cast written in the source code.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
Expr * getArrayRangeEnd(const Designator &D) const
llvm::APInt getValue() const
unsigned getNumSubExprs() const
GenericSelectionExpr(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo *> AssocTypes, ArrayRef< Expr *> AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
SourceLocation getBeginLoc() const LLVM_READONLY
bool isStringLiteralInit() const
struct ArrayOrRangeDesignator ArrayOrRange
An array or GNU array-range designator, e.g., "[9]" or "[10..15]".
unsigned getIntWidth(QualType T) const
Not an overloaded operator.
bool isIncompleteArrayType() const
bool HasSideEffects
Whether the evaluated expression has side effects.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Location wrapper for a TemplateArgument.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
static StringRef getIdentTypeName(IdentType IT)
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isConstantInitializer(ASTContext &Ctx, bool ForRef, const Expr **Culprit=nullptr) const
isConstantInitializer - Returns true if this expression can be emitted to IR as a constant...
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
SourceLocation getEndLoc() const LLVM_READONLY
bool isFunctionType() const
static ImplicitCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize)
Expr * IgnoreParenLValueCasts() LLVM_READONLY
Ignore parentheses and lvalue casts.
Expr * getArg(unsigned Arg)
Return the specified argument.
NamedDecl * getConversionFunction() const
If this cast applies a user-defined conversion, retrieve the conversion function that it invokes...
UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits
Represents a base class of a C++ class.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
A use of a default initializer in a constructor or in aggregate initialization.
A template argument list.
static CStyleCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize)
static const Expr * skipTemporaryBindingsNoOpCastsAndParens(const Expr *E)
Skip over any no-op casts and any temporary-binding expressions.
bool refersToGlobalRegisterVar() const
Returns whether this expression refers to a global register variable.
bool isUnusedResultAWarning(const Expr *&WarnExpr, SourceLocation &Loc, SourceRange &R1, SourceRange &R2, ASTContext &Ctx) const
isUnusedResultAWarning - Return true if this immediate expression should be warned about if the resul...
void reserve(const ASTContext &C, unsigned N)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Expression is a Null pointer constant built from a literal zero.
void Deallocate(void *Ptr) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
CallingConv getCallConv() const
Represents a C++ struct/union/class.
bool isSyntacticForm() const
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr *> Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Builtin::Context & BuiltinInfo
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool isImplicitCXXThis() const
Whether this expression is an implicit reference to 'this' in C++.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
bool isBuiltinAssumeFalse(const ASTContext &Ctx) const
Return true if this is a call to __assume() or __builtin_assume() with a non-value-dependent constant...
Designator * getDesignator(unsigned Idx)
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
void reserveInits(const ASTContext &C, unsigned NumInits)
Reserve space for some number of initializers.
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
static Decl::Kind getKind(const Decl *D)
DeclAccessPair FoundDecl
The DeclAccessPair through which the MemberDecl was found due to name qualifiers. ...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isEvaluatable(const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
isEvaluatable - Call EvaluateAsRValue to see if this expression can be constant folded without side-e...
std::reverse_iterator< const_iterator > const_reverse_iterator
SourceLocation getBeginLoc() const LLVM_READONLY
A reference to a declared variable, function, enum, etc.
bool isPointerType() const
CallExprBitfields CallExprBits
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
bool isOBJCGCCandidate(ASTContext &Ctx) const
isOBJCGCCandidate - Return true if this expression may be used in a read/ write barrier.
An l-value expression is a reference to an object with independent storage.
unsigned getNumArgs() const
A trivial tuple used to represent a source range.
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
SourceLocation getBeginLoc() const LLVM_READONLY
This represents a decl that may have a name.
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Represents a C array with a specified size that is not an integer-constant-expression.
static int getAccessorIdx(char c, bool isNumericAccessor)
QualType getValueType() const
double getValueAsApproximateDouble() const
getValueAsApproximateDouble - This returns the value as an inaccurate double.
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
const LangOptions & getLangOpts() const
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
IdentifierInfo * getFieldName() const
This class handles loading and caching of source files into memory.
InitListExpr * getSyntacticForm() const
Defines enum values for all the target-independent builtin functions.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
QualType getType() const
Return the type wrapped by this type source info.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
SourceRange getSourceRange() const LLVM_READONLY