31 #include "llvm/Support/ErrorHandling.h" 32 #include "llvm/Support/raw_ostream.h" 35 using namespace clang;
43 if (
auto *BO = dyn_cast<BinaryOperator>(E)) {
44 if (BO->getOpcode() == BO_Comma) {
51 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
52 E = MTE->GetTemporaryExpr();
73 return cast<CXXRecordDecl>(D);
83 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
84 if ((CE->getCastKind() == CK_DerivedToBase ||
85 CE->getCastKind() == CK_UncheckedDerivedToBase) &&
94 if (CE->getCastKind() == CK_NoOp) {
98 }
else if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
100 assert(ME->getBase()->getType()->isRecordType());
101 if (
FieldDecl *Field = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
102 if (!Field->isBitField() && !Field->getType()->isReferenceType()) {
109 }
else if (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
110 if (BO->getOpcode() == BO_PtrMemD) {
111 assert(BO->getRHS()->isRValue());
117 }
else if (BO->getOpcode() == BO_Comma) {
118 CommaLHSs.push_back(BO->getLHS());
143 switch (UO->getOpcode()) {
145 return UO->getSubExpr()->isKnownToHaveBooleanValue();
156 return CE->getSubExpr()->isKnownToHaveBooleanValue();
159 switch (BO->getOpcode()) {
160 default:
return false;
175 return BO->getLHS()->isKnownToHaveBooleanValue() &&
176 BO->getRHS()->isKnownToHaveBooleanValue();
180 return BO->getRHS()->isKnownToHaveBooleanValue();
185 return CO->getTrueExpr()->isKnownToHaveBooleanValue() &&
186 CO->getFalseExpr()->isKnownToHaveBooleanValue();
198 template <
class E,
class T>
218 #define ABSTRACT_STMT(type) 219 #define STMT(type, base) \ 220 case Stmt::type##Class: break; 221 #define EXPR(type, base) \ 222 case Stmt::type##Class: return getExprLocImpl<type>(this, &type::getExprLoc); 223 #include "clang/AST/StmtNodes.inc" 225 llvm_unreachable(
"unknown expression kind");
235 "Invalid StorageKind Value");
245 if (!Value.
getInt().needsCleanup())
265 ::new (getTrailingObjects<APValue>())
APValue();
269 :
FullExpr(ConstantExprClass, subexpr) {
270 DefaultInit(StorageKind);
275 assert(!isa<ConstantExpr>(E));
277 unsigned Size = totalSizeToAlloc<APValue, uint64_t>(
294 :
FullExpr(ConstantExprClass, Empty) {
295 DefaultInit(StorageKind);
302 unsigned Size = totalSizeToAlloc<APValue, uint64_t>(
312 "Invalid storage for this value kind");
318 Int64Result() = *Value.
getInt().getRawData();
327 APValueResult() = std::move(Value);
330 llvm_unreachable(
"Invalid ResultKind Bits");
336 return APValueResult().getInt();
341 llvm_unreachable(
"invalid Accessor");
348 return APValueResult();
356 llvm_unreachable(
"invalid ResultKind");
364 bool &ValueDependent,
365 bool &InstantiationDependent) {
366 TypeDependent =
false;
367 ValueDependent =
false;
368 InstantiationDependent =
false;
381 TypeDependent =
true;
382 ValueDependent =
true;
383 InstantiationDependent =
true;
386 InstantiationDependent =
true;
394 TypeDependent =
true;
395 ValueDependent =
true;
396 InstantiationDependent =
true;
401 InstantiationDependent =
true;
405 if (isa<NonTypeTemplateParmDecl>(D)) {
406 ValueDependent =
true;
407 InstantiationDependent =
true;
418 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
420 Var->getType()->isLiteralType(Ctx) :
421 Var->getType()->isIntegralOrEnumerationType()) &&
422 (Var->getType().isConstQualified() ||
423 Var->getType()->isReferenceType())) {
424 if (
const Expr *Init = Var->getAnyInitializer())
425 if (Init->isValueDependent()) {
426 ValueDependent =
true;
427 InstantiationDependent =
true;
434 if (Var->isStaticDataMember() &&
435 Var->getDeclContext()->isDependentContext()) {
436 ValueDependent =
true;
437 InstantiationDependent =
true;
440 TypeDependent =
true;
450 ValueDependent =
true;
451 InstantiationDependent =
true;
455 void DeclRefExpr::computeDependence(
const ASTContext &Ctx) {
456 bool TypeDependent =
false;
457 bool ValueDependent =
false;
458 bool InstantiationDependent =
false;
460 ValueDependent, InstantiationDependent);
462 ExprBits.TypeDependent |= TypeDependent;
463 ExprBits.ValueDependent |= ValueDependent;
464 ExprBits.InstantiationDependent |= InstantiationDependent;
467 if (getDecl()->isParameterPack())
468 ExprBits.ContainsUnexpandedParameterPack =
true;
472 bool RefersToEnclosingVariableOrCapture,
QualType T,
477 D(D), DNLoc(LocInfo) {
483 RefersToEnclosingVariableOrCapture;
486 computeDependence(Ctx);
489 DeclRefExpr::DeclRefExpr(
const ASTContext &Ctx,
492 bool RefersToEnclosingVariableOrCapture,
496 :
Expr(DeclRefExprClass, T, VK,
OK_Ordinary,
false,
false,
false,
false),
497 D(D), DNLoc(NameInfo.
getInfo()) {
501 new (getTrailingObjects<NestedNameSpecifierLoc>())
504 if (NNS->isInstantiationDependent())
505 ExprBits.InstantiationDependent =
true;
506 if (NNS->containsUnexpandedParameterPack())
507 ExprBits.ContainsUnexpandedParameterPack =
true;
511 *getTrailingObjects<NamedDecl *>() = FoundD;
513 = (TemplateArgs || TemplateKWLoc.
isValid()) ? 1 : 0;
515 RefersToEnclosingVariableOrCapture;
518 bool Dependent =
false;
519 bool InstantiationDependent =
false;
520 bool ContainsUnexpandedParameterPack =
false;
521 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
522 TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
523 Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
524 assert(!Dependent &&
"built a DeclRefExpr with dependent template args");
525 ExprBits.InstantiationDependent |= InstantiationDependent;
526 ExprBits.ContainsUnexpandedParameterPack |= ContainsUnexpandedParameterPack;
527 }
else if (TemplateKWLoc.
isValid()) {
528 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
533 computeDependence(Ctx);
539 bool RefersToEnclosingVariableOrCapture,
544 return Create(Context, QualifierLoc, TemplateKWLoc, D,
545 RefersToEnclosingVariableOrCapture,
547 T, VK, FoundD, TemplateArgs, NOUR);
553 bool RefersToEnclosingVariableOrCapture,
563 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
567 QualifierLoc ? 1 : 0, FoundD ? 1 : 0,
568 HasTemplateKWAndArgsInfo ? 1 : 0,
569 TemplateArgs ? TemplateArgs->
size() : 0);
572 return new (Mem)
DeclRefExpr(Context, QualifierLoc, TemplateKWLoc, D,
573 RefersToEnclosingVariableOrCapture, NameInfo,
574 FoundD, TemplateArgs, T, VK, NOUR);
580 bool HasTemplateKWAndArgsInfo,
581 unsigned NumTemplateArgs) {
582 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
586 HasQualifier ? 1 : 0, HasFoundDecl ? 1 : 0, HasTemplateKWAndArgsInfo,
610 assert((getIdentKind() == IK) &&
611 "IdentKind do not fit in PredefinedExprBitfields!");
612 bool HasFunctionName = SL !=
nullptr;
619 PredefinedExpr::PredefinedExpr(
EmptyShell Empty,
bool HasFunctionName)
620 :
Expr(PredefinedExprClass, Empty) {
627 bool HasFunctionName = SL !=
nullptr;
628 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
634 bool HasFunctionName) {
635 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
645 return "__FUNCTION__";
647 return "__FUNCDNAME__";
649 return "L__FUNCTION__";
651 return "__PRETTY_FUNCTION__";
653 return "__FUNCSIG__";
655 return "L__FUNCSIG__";
656 case PrettyFunctionNoVirtual:
659 llvm_unreachable(
"Unknown ident kind for PredefinedExpr");
668 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(CurrentDecl)) {
669 std::unique_ptr<MangleContext> MC;
672 if (MC->shouldMangleDeclName(ND)) {
674 llvm::raw_svector_ostream Out(Buffer);
680 MC->mangleName(ND, Out);
682 if (!Buffer.empty() && Buffer.front() ==
'\01')
683 return Buffer.substr(1);
686 return ND->getIdentifier()->getName();
690 if (isa<BlockDecl>(CurrentDecl)) {
695 if (DC->isFileContext())
699 llvm::raw_svector_ostream Out(Buffer);
700 if (
auto *DCBlock = dyn_cast<BlockDecl>(DC))
702 Out << ComputeName(IK, DCBlock);
703 else if (
auto *DCDecl = dyn_cast<Decl>(DC))
704 Out << ComputeName(IK, DCDecl) <<
"_block_invoke";
707 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
708 if (IK != PrettyFunction && IK != PrettyFunctionNoVirtual &&
709 IK != FuncSig && IK != LFuncSig)
710 return FD->getNameAsString();
713 llvm::raw_svector_ostream Out(Name);
716 if (MD->isVirtual() && IK != PrettyFunctionNoVirtual)
724 llvm::raw_string_ostream POut(Proto);
731 if (FD->hasWrittenPrototype())
732 FT = dyn_cast<FunctionProtoType>(AFT);
734 if (IK == FuncSig || IK == LFuncSig) {
736 case CC_C: POut <<
"__cdecl ";
break;
747 FD->printQualifiedName(POut, Policy);
756 if (FT->isVariadic()) {
757 if (FD->getNumParams()) POut <<
", ";
759 }
else if ((IK == FuncSig || IK == LFuncSig ||
768 assert(FT &&
"We must have a written prototype in this case.");
771 if (FT->isVolatile())
783 while (Ctx && isa<NamedDecl>(Ctx)) {
787 Specs.push_back(Spec);
791 std::string TemplateParams;
792 llvm::raw_string_ostream TOut(TemplateParams);
793 for (SpecsTy::reverse_iterator I = Specs.rbegin(), E = Specs.rend();
796 = (*I)->getSpecializedTemplate()->getTemplateParameters();
798 assert(Params->
size() == Args.
size());
799 for (
unsigned i = 0, numParams = Params->
size();
i != numParams; ++
i) {
801 if (Param.empty())
continue;
802 TOut << Param <<
" = ";
809 = FD->getTemplateSpecializationInfo();
814 assert(Params->
size() == Args->
size());
815 for (
unsigned i = 0, e = Params->
size();
i != e; ++
i) {
817 if (Param.empty())
continue;
818 TOut << Param <<
" = ";
825 if (!TemplateParams.empty()) {
827 TemplateParams.resize(TemplateParams.size() - 2);
828 POut <<
" [" << TemplateParams <<
"]";
837 if (isa<CXXMethodDecl>(FD) &&
838 cast<CXXMethodDecl>(FD)->getParent()->isLambda())
839 Proto =
"auto " + Proto;
840 else if (FT && FT->getReturnType()->getAs<
DecltypeType>())
845 else if (!isa<CXXConstructorDecl>(FD) && !isa<CXXDestructorDecl>(FD))
850 return Name.str().str();
852 if (
const CapturedDecl *CD = dyn_cast<CapturedDecl>(CurrentDecl)) {
856 if (DC->isFunctionOrMethod() && (DC->getDeclKind() != Decl::Captured)) {
858 return ComputeName(IK, D);
860 llvm_unreachable(
"CapturedDecl not inside a function or method");
862 if (
const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(CurrentDecl)) {
864 llvm::raw_svector_ostream Out(Name);
865 Out << (MD->isInstanceMethod() ?
'-' :
'+');
874 dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext()))
875 Out <<
'(' << *CID <<
')';
878 MD->getSelector().print(Out);
881 return Name.str().str();
883 if (isa<TranslationUnitDecl>(CurrentDecl) && IK == PrettyFunction) {
891 const llvm::APInt &Val) {
895 BitWidth = Val.getBitWidth();
896 unsigned NumWords = Val.getNumWords();
897 const uint64_t* Words = Val.getRawData();
899 pVal =
new (
C) uint64_t[NumWords];
900 std::copy(Words, Words + NumWords, pVal);
901 }
else if (NumWords == 1)
907 IntegerLiteral::IntegerLiteral(
const ASTContext &
C,
const llvm::APInt &
V,
912 assert(type->
isIntegerType() &&
"Illegal type in IntegerLiteral");
914 "Integer type is not the correct size for constant.");
929 FixedPointLiteral::FixedPointLiteral(
const ASTContext &
C,
const llvm::APInt &
V,
934 Loc(l), Scale(Scale) {
937 "Fixed point type is not the correct size for constant.");
942 const llvm::APInt &
V,
955 S, llvm::APSInt::getUnsigned(
getValue().getZExtValue()), Scale);
959 FloatingLiteral::FloatingLiteral(
const ASTContext &
C,
const llvm::APFloat &
V,
962 false,
false), Loc(L) {
963 setSemantics(
V.getSemantics());
969 :
Expr(FloatingLiteralClass, Empty) {
970 setRawSemantics(llvm::APFloatBase::S_IEEEhalf);
991 V.convert(llvm::APFloat::IEEEdouble(), llvm::APFloat::rmNearestTiesToEven,
993 return V.convertToDouble();
998 unsigned CharByteWidth = 0;
1014 assert((CharByteWidth & 7) == 0 &&
"Assumes character size is byte multiple");
1016 assert((CharByteWidth == 1 || CharByteWidth == 2 || CharByteWidth == 4) &&
1017 "The only supported character byte widths are 1,2 and 4!");
1018 return CharByteWidth;
1021 StringLiteral::StringLiteral(
const ASTContext &Ctx, StringRef Str,
1024 unsigned NumConcatenated)
1028 "StringLiteral must be of constant array type!");
1030 unsigned ByteLength = Str.size();
1031 assert((ByteLength % CharByteWidth == 0) &&
1032 "The size of the data must be a multiple of CharByteWidth!");
1038 switch (CharByteWidth) {
1040 Length = ByteLength;
1043 Length = ByteLength / 2;
1046 Length = ByteLength / 4;
1049 llvm_unreachable(
"Unsupported character width!");
1056 *getTrailingObjects<unsigned>() = Length;
1060 std::memcpy(getTrailingObjects<SourceLocation>(), Loc,
1064 std::memcpy(getTrailingObjects<char>(), Str.data(), ByteLength);
1067 StringLiteral::StringLiteral(
EmptyShell Empty,
unsigned NumConcatenated,
1068 unsigned Length,
unsigned CharByteWidth)
1069 :
Expr(StringLiteralClass, Empty) {
1072 *getTrailingObjects<unsigned>() = Length;
1078 unsigned NumConcatenated) {
1079 void *Mem = Ctx.
Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
1080 1, NumConcatenated, Str.size()),
1083 StringLiteral(Ctx, Str, Kind, Pascal, Ty, Loc, NumConcatenated);
1087 unsigned NumConcatenated,
1089 unsigned CharByteWidth) {
1090 void *Mem = Ctx.
Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
1091 1, NumConcatenated, Length * CharByteWidth),
1100 case Wide: OS <<
'L';
break;
1101 case UTF8: OS <<
"u8";
break;
1102 case UTF16: OS <<
'u';
break;
1103 case UTF32: OS <<
'U';
break;
1106 static const char Hex[] =
"0123456789ABCDEF";
1108 unsigned LastSlashX = getLength();
1109 for (
unsigned I = 0, N = getLength(); I != N; ++I) {
1110 switch (uint32_t Char = getCodeUnit(I)) {
1116 if (
getKind() == UTF16 && I != N - 1 && Char >= 0xd800 &&
1118 uint32_t Trail = getCodeUnit(I + 1);
1119 if (Trail >= 0xdc00 && Trail <= 0xdfff) {
1120 Char = 0x10000 + ((Char - 0xd800) << 10) + (Trail - 0xdc00);
1130 (Char >= 0xd800 && Char <= 0xdfff) || Char >= 0x110000) {
1134 while ((Char >> Shift) == 0)
1136 for (; Shift >= 0; Shift -= 4)
1137 OS << Hex[(Char >> Shift) & 15];
1144 << Hex[(Char >> 20) & 15]
1145 << Hex[(Char >> 16) & 15];
1148 OS << Hex[(Char >> 12) & 15]
1149 << Hex[(Char >> 8) & 15]
1150 << Hex[(Char >> 4) & 15]
1151 << Hex[(Char >> 0) & 15];
1157 if (LastSlashX + 1 == I) {
1159 case '0':
case '1':
case '2':
case '3':
case '4':
1160 case '5':
case '6':
case '7':
case '8':
case '9':
1161 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
1162 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
1167 assert(Char <= 0xff &&
1168 "Characters above 0xff should already have been handled.");
1174 << (char)(
'0' + ((Char >> 6) & 7))
1175 << (char)(
'0' + ((Char >> 3) & 7))
1176 << (char)(
'0' + ((Char >> 0) & 7));
1179 case '\\': OS <<
"\\\\";
break;
1180 case '"': OS <<
"\\\"";
break;
1181 case '\a': OS <<
"\\a";
break;
1182 case '\b': OS <<
"\\b";
break;
1183 case '\f': OS <<
"\\f";
break;
1184 case '\n': OS <<
"\\n";
break;
1185 case '\r': OS <<
"\\r";
break;
1186 case '\t': OS <<
"\\t";
break;
1187 case '\v': OS <<
"\\v";
break;
1212 const TargetInfo &Target,
unsigned *StartToken,
1213 unsigned *StartTokenByteOffset)
const {
1216 "Only narrow string literals are currently supported");
1221 unsigned StringOffset = 0;
1223 TokNo = *StartToken;
1224 if (StartTokenByteOffset) {
1225 StringOffset = *StartTokenByteOffset;
1226 ByteNo -= StringOffset;
1229 assert(TokNo < getNumConcatenated() &&
"Invalid byte number!");
1238 std::pair<FileID, unsigned> LocInfo =
1240 bool Invalid =
false;
1241 StringRef Buffer = SM.
getBufferData(LocInfo.first, &Invalid);
1243 if (StartTokenByteOffset !=
nullptr)
1244 *StartTokenByteOffset = StringOffset;
1245 if (StartToken !=
nullptr)
1246 *StartToken = TokNo;
1247 return StrTokSpellingLoc;
1250 const char *StrData = Buffer.data()+LocInfo.second;
1254 Buffer.begin(), StrData, Buffer.end());
1256 TheLexer.LexFromRawLexer(TheTok);
1263 if (ByteNo < TokNumBytes ||
1264 (ByteNo == TokNumBytes && TokNo == getNumConcatenated() - 1)) {
1269 if (StartTokenByteOffset !=
nullptr)
1270 *StartTokenByteOffset = StringOffset;
1271 if (StartToken !=
nullptr)
1272 *StartToken = TokNo;
1277 StringOffset += TokNumBytes;
1279 ByteNo -= TokNumBytes;
1287 #define UNARY_OPERATION(Name, Spelling) case UO_##Name: return Spelling; 1288 #include "clang/AST/OperationKinds.def" 1290 llvm_unreachable(
"Unknown unary operator");
1296 default: llvm_unreachable(
"No unary operator for overloaded function");
1297 case OO_PlusPlus:
return Postfix ? UO_PostInc : UO_PreInc;
1298 case OO_MinusMinus:
return Postfix ? UO_PostDec : UO_PreDec;
1299 case OO_Amp:
return UO_AddrOf;
1300 case OO_Star:
return UO_Deref;
1301 case OO_Plus:
return UO_Plus;
1302 case OO_Minus:
return UO_Minus;
1303 case OO_Tilde:
return UO_Not;
1304 case OO_Exclaim:
return UO_LNot;
1305 case OO_Coawait:
return UO_Coawait;
1311 case UO_PostInc:
case UO_PreInc:
return OO_PlusPlus;
1312 case UO_PostDec:
case UO_PreDec:
return OO_MinusMinus;
1313 case UO_AddrOf:
return OO_Amp;
1314 case UO_Deref:
return OO_Star;
1315 case UO_Plus:
return OO_Plus;
1316 case UO_Minus:
return OO_Minus;
1317 case UO_Not:
return OO_Tilde;
1318 case UO_LNot:
return OO_Exclaim;
1319 case UO_Coawait:
return OO_Coawait;
1336 RParenLoc(RParenLoc) {
1337 NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1338 unsigned NumPreArgs = PreArgs.size();
1340 assert((NumPreArgs ==
getNumPreArgs()) &&
"NumPreArgs overflow!");
1342 unsigned OffsetToTrailingObjects = offsetToTrailingObjects(SC);
1343 CallExprBits.OffsetToTrailingObjects = OffsetToTrailingObjects;
1344 assert((
CallExprBits.OffsetToTrailingObjects == OffsetToTrailingObjects) &&
1345 "OffsetToTrailingObjects overflow!");
1350 for (
unsigned I = 0; I != NumPreArgs; ++I) {
1351 updateDependenciesFromArg(PreArgs[I]);
1354 for (
unsigned I = 0; I != Args.size(); ++I) {
1355 updateDependenciesFromArg(Args[I]);
1358 for (
unsigned I = Args.size(); I != NumArgs; ++I) {
1365 :
Expr(SC, Empty), NumArgs(NumArgs) {
1367 assert((NumPreArgs ==
getNumPreArgs()) &&
"NumPreArgs overflow!");
1369 unsigned OffsetToTrailingObjects = offsetToTrailingObjects(SC);
1370 CallExprBits.OffsetToTrailingObjects = OffsetToTrailingObjects;
1371 assert((
CallExprBits.OffsetToTrailingObjects == OffsetToTrailingObjects) &&
1372 "OffsetToTrailingObjects overflow!");
1379 unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1380 unsigned SizeOfTrailingObjects =
1384 return new (Mem)
CallExpr(CallExprClass, Fn, {}, Args, Ty, VK,
1385 RParenLoc, MinNumArgs,
UsesADL);
1391 assert(!(reinterpret_cast<uintptr_t>(Mem) %
alignof(
CallExpr)) &&
1392 "Misaligned memory in CallExpr::CreateTemporary!");
1393 return new (Mem)
CallExpr(CallExprClass, Fn, {}, {}, Ty,
1399 unsigned SizeOfTrailingObjects =
1403 return new (Mem)
CallExpr(CallExprClass, 0, NumArgs, Empty);
1406 unsigned CallExpr::offsetToTrailingObjects(
StmtClass SC) {
1410 case CXXOperatorCallExprClass:
1412 case CXXMemberCallExprClass:
1414 case UserDefinedLiteralClass:
1416 case CUDAKernelCallExprClass:
1419 llvm_unreachable(
"unexpected class deriving from CallExpr!");
1423 void CallExpr::updateDependenciesFromArg(
Expr *Arg) {
1429 ExprBits.InstantiationDependent =
true;
1431 ExprBits.ContainsUnexpandedParameterPack =
true;
1438 = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE)) {
1444 if (BO->isPtrMemOp())
1446 }
else if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(CEE)) {
1447 if (UO->getOpcode() == UO_Deref)
1450 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE))
1451 return DRE->getDecl();
1452 if (
MemberExpr *ME = dyn_cast<MemberExpr>(CEE))
1453 return ME->getMemberDecl();
1454 if (
auto *BE = dyn_cast<BlockExpr>(CEE))
1455 return BE->getBlockDecl();
1498 if (isa<CXXPseudoDestructorExpr>(Callee->
IgnoreParens()))
1513 if (
const auto *A = TD->getAttr<WarnUnusedResultAttr>())
1519 return D ? D->
getAttr<WarnUnusedResultAttr>() :
nullptr;
1523 if (isa<CXXOperatorCallExpr>(
this))
1524 return cast<CXXOperatorCallExpr>(
this)->
getBeginLoc();
1532 if (isa<CXXOperatorCallExpr>(
this))
1533 return cast<CXXOperatorCallExpr>(
this)->
getEndLoc();
1548 totalSizeToAlloc<OffsetOfNode, Expr *>(comps.size(), exprs.size()));
1550 return new (Mem)
OffsetOfExpr(C, type, OperatorLoc, tsi, comps, exprs,
1555 unsigned numComps,
unsigned numExprs) {
1557 C.
Allocate(totalSizeToAlloc<OffsetOfNode, Expr *>(numComps, numExprs));
1570 OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
1571 NumComps(comps.size()), NumExprs(exprs.size())
1573 for (
unsigned i = 0;
i != comps.size(); ++
i) {
1574 setComponent(
i, comps[
i]);
1577 for (
unsigned i = 0;
i != exprs.size(); ++
i) {
1581 ExprBits.ContainsUnexpandedParameterPack =
true;
1583 setIndexExpr(
i, exprs[
i]);
1590 return getField()->getIdentifier();
1603 OpLoc(op), RParenLoc(rp) {
1615 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
1617 else if (
const auto *ME = dyn_cast<MemberExpr>(E))
1618 D = ME->getMemberDecl();
1622 if (I->isAlignmentDependent()) {
1641 Base(Base), MemberDecl(MemberDecl), MemberDNLoc(NameInfo.
getInfo()),
1642 MemberLoc(NameInfo.
getLoc()) {
1659 bool HasQualOrFound = QualifierLoc || FoundDecl.
getDecl() != MemberDecl ||
1661 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
1665 HasQualOrFound ? 1 : 0, HasTemplateKWAndArgsInfo ? 1 : 0,
1666 TemplateArgs ? TemplateArgs->
size() : 0);
1670 NameInfo, T, VK, OK, NOUR);
1672 if (HasQualOrFound) {
1679 else if (QualifierLoc &&
1685 MemberExprNameQualifier *NQ =
1686 E->getTrailingObjects<MemberExprNameQualifier>();
1692 TemplateArgs || TemplateKWLoc.
isValid();
1695 bool Dependent =
false;
1696 bool InstantiationDependent =
false;
1697 bool ContainsUnexpandedParameterPack =
false;
1698 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1699 TemplateKWLoc, *TemplateArgs,
1701 InstantiationDependent, ContainsUnexpandedParameterPack);
1702 if (InstantiationDependent)
1704 }
else if (TemplateKWLoc.
isValid()) {
1705 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1713 bool HasQualifier,
bool HasFoundDecl,
1714 bool HasTemplateKWAndArgsInfo,
1715 unsigned NumTemplateArgs) {
1716 assert((!NumTemplateArgs || HasTemplateKWAndArgsInfo) &&
1717 "template args but no template arg info?");
1718 bool HasQualOrFound = HasQualifier || HasFoundDecl;
1722 HasTemplateKWAndArgsInfo ? 1 : 0,
1729 if (isImplicitAccess()) {
1731 return getQualifierLoc().getBeginLoc();
1739 return BaseStartLoc;
1744 if (hasExplicitTemplateArgs())
1745 EndLoc = getRAngleLoc();
1747 EndLoc = getBase()->getEndLoc();
1751 bool CastExpr::CastConsistency()
const {
1752 switch (getCastKind()) {
1753 case CK_DerivedToBase:
1754 case CK_UncheckedDerivedToBase:
1755 case CK_DerivedToBaseMemberPointer:
1756 case CK_BaseToDerived:
1757 case CK_BaseToDerivedMemberPointer:
1758 assert(!path_empty() &&
"Cast kind should have a base path!");
1761 case CK_CPointerToObjCPointerCast:
1762 assert(
getType()->isObjCObjectPointerType());
1763 assert(getSubExpr()->
getType()->isPointerType());
1764 goto CheckNoBasePath;
1766 case CK_BlockPointerToObjCPointerCast:
1767 assert(
getType()->isObjCObjectPointerType());
1768 assert(getSubExpr()->
getType()->isBlockPointerType());
1769 goto CheckNoBasePath;
1771 case CK_ReinterpretMemberPointer:
1772 assert(
getType()->isMemberPointerType());
1773 assert(getSubExpr()->
getType()->isMemberPointerType());
1774 goto CheckNoBasePath;
1780 if (!
getType()->isPointerType()) {
1781 assert(
getType()->isObjCObjectPointerType() ==
1782 getSubExpr()->
getType()->isObjCObjectPointerType());
1783 assert(
getType()->isBlockPointerType() ==
1784 getSubExpr()->
getType()->isBlockPointerType());
1786 goto CheckNoBasePath;
1788 case CK_AnyPointerToBlockPointerCast:
1789 assert(
getType()->isBlockPointerType());
1790 assert(getSubExpr()->
getType()->isAnyPointerType() &&
1791 !getSubExpr()->
getType()->isBlockPointerType());
1792 goto CheckNoBasePath;
1794 case CK_CopyAndAutoreleaseBlockObject:
1795 assert(
getType()->isBlockPointerType());
1796 assert(getSubExpr()->
getType()->isBlockPointerType());
1797 goto CheckNoBasePath;
1799 case CK_FunctionToPointerDecay:
1800 assert(
getType()->isPointerType());
1801 assert(getSubExpr()->
getType()->isFunctionType());
1802 goto CheckNoBasePath;
1804 case CK_AddressSpaceConversion: {
1806 auto SETy = getSubExpr()->getType();
1812 assert(!Ty.
isNull() && !SETy.isNull() &&
1814 goto CheckNoBasePath;
1819 case CK_ArrayToPointerDecay:
1820 case CK_NullToMemberPointer:
1821 case CK_NullToPointer:
1822 case CK_ConstructorConversion:
1823 case CK_IntegralToPointer:
1824 case CK_PointerToIntegral:
1826 case CK_VectorSplat:
1827 case CK_IntegralCast:
1828 case CK_BooleanToSignedIntegral:
1829 case CK_IntegralToFloating:
1830 case CK_FloatingToIntegral:
1831 case CK_FloatingCast:
1832 case CK_ObjCObjectLValueCast:
1833 case CK_FloatingRealToComplex:
1834 case CK_FloatingComplexToReal:
1835 case CK_FloatingComplexCast:
1836 case CK_FloatingComplexToIntegralComplex:
1837 case CK_IntegralRealToComplex:
1838 case CK_IntegralComplexToReal:
1839 case CK_IntegralComplexCast:
1840 case CK_IntegralComplexToFloatingComplex:
1841 case CK_ARCProduceObject:
1842 case CK_ARCConsumeObject:
1843 case CK_ARCReclaimReturnedObject:
1844 case CK_ARCExtendBlockObject:
1845 case CK_ZeroToOCLOpaqueType:
1846 case CK_IntToOCLSampler:
1847 case CK_FixedPointCast:
1848 case CK_FixedPointToIntegral:
1849 case CK_IntegralToFixedPoint:
1851 goto CheckNoBasePath;
1854 case CK_LValueToRValue:
1856 case CK_AtomicToNonAtomic:
1857 case CK_NonAtomicToAtomic:
1858 case CK_PointerToBoolean:
1859 case CK_IntegralToBoolean:
1860 case CK_FloatingToBoolean:
1861 case CK_MemberPointerToBoolean:
1862 case CK_FloatingComplexToBoolean:
1863 case CK_IntegralComplexToBoolean:
1864 case CK_LValueBitCast:
1865 case CK_LValueToRValueBitCast:
1866 case CK_UserDefinedConversion:
1867 case CK_BuiltinFnToFnPtr:
1868 case CK_FixedPointToBoolean:
1870 assert(path_empty() &&
"Cast kind should not have a base path!");
1878 #define CAST_OPERATION(Name) case CK_##Name: return #Name; 1879 #include "clang/AST/OperationKinds.def" 1881 llvm_unreachable(
"Unhandled cast kind!");
1885 const Expr *skipImplicitTemporary(
const Expr *E) {
1887 if (
auto *Materialize = dyn_cast<MaterializeTemporaryExpr>(E))
1888 E = Materialize->GetTemporaryExpr();
1891 if (
auto *Binder = dyn_cast<CXXBindTemporaryExpr>(E))
1892 E = Binder->getSubExpr();
1899 const Expr *SubExpr =
nullptr;
1902 SubExpr = skipImplicitTemporary(E->
getSubExpr());
1908 skipImplicitTemporary(cast<CXXConstructExpr>(SubExpr)->getArg(0));
1909 else if (E->
getCastKind() == CK_UserDefinedConversion) {
1910 assert((isa<CXXMemberCallExpr>(SubExpr) ||
1911 isa<BlockExpr>(SubExpr)) &&
1912 "Unexpected SubExpr for CK_UserDefinedConversion.");
1913 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
1914 SubExpr = MCE->getImplicitObjectArgument();
1919 }
while ((E = dyn_cast<ImplicitCastExpr>(SubExpr)));
1921 return const_cast<Expr*
>(SubExpr);
1925 const Expr *SubExpr =
nullptr;
1928 SubExpr = skipImplicitTemporary(E->getSubExpr());
1930 if (E->getCastKind() == CK_ConstructorConversion)
1931 return cast<CXXConstructExpr>(SubExpr)->getConstructor();
1933 if (E->getCastKind() == CK_UserDefinedConversion) {
1934 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
1935 return MCE->getMethodDecl();
1944 #define ABSTRACT_STMT(x) 1945 #define CASTEXPR(Type, Base) \ 1946 case Stmt::Type##Class: \ 1947 return static_cast<Type *>(this)->getTrailingObjects<CXXBaseSpecifier *>(); 1948 #define STMT(Type, Base) 1949 #include "clang/AST/StmtNodes.inc" 1951 llvm_unreachable(
"non-cast expressions not possible here");
1958 return getTargetFieldForToUnionCast(RD, opType);
1966 Field != FieldEnd; ++Field) {
1968 !Field->isUnnamedBitfield()) {
1979 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1980 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1983 assert((Kind != CK_LValueToRValue ||
1985 "invalid type for lvalue-to-rvalue conversion");
1989 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1995 unsigned PathSize) {
1996 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
2006 unsigned PathSize = (BasePath ? BasePath->size() : 0);
2007 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
2009 new (Buffer)
CStyleCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, R);
2011 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
2017 unsigned PathSize) {
2018 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
2026 #define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling; 2027 #include "clang/AST/OperationKinds.def" 2029 llvm_unreachable(
"Invalid OpCode!");
2035 default: llvm_unreachable(
"Not an overloadable binary operator");
2036 case OO_Plus:
return BO_Add;
2037 case OO_Minus:
return BO_Sub;
2038 case OO_Star:
return BO_Mul;
2039 case OO_Slash:
return BO_Div;
2040 case OO_Percent:
return BO_Rem;
2041 case OO_Caret:
return BO_Xor;
2042 case OO_Amp:
return BO_And;
2043 case OO_Pipe:
return BO_Or;
2044 case OO_Equal:
return BO_Assign;
2045 case OO_Spaceship:
return BO_Cmp;
2046 case OO_Less:
return BO_LT;
2047 case OO_Greater:
return BO_GT;
2048 case OO_PlusEqual:
return BO_AddAssign;
2049 case OO_MinusEqual:
return BO_SubAssign;
2050 case OO_StarEqual:
return BO_MulAssign;
2051 case OO_SlashEqual:
return BO_DivAssign;
2052 case OO_PercentEqual:
return BO_RemAssign;
2053 case OO_CaretEqual:
return BO_XorAssign;
2054 case OO_AmpEqual:
return BO_AndAssign;
2055 case OO_PipeEqual:
return BO_OrAssign;
2056 case OO_LessLess:
return BO_Shl;
2057 case OO_GreaterGreater:
return BO_Shr;
2058 case OO_LessLessEqual:
return BO_ShlAssign;
2059 case OO_GreaterGreaterEqual:
return BO_ShrAssign;
2060 case OO_EqualEqual:
return BO_EQ;
2061 case OO_ExclaimEqual:
return BO_NE;
2062 case OO_LessEqual:
return BO_LE;
2063 case OO_GreaterEqual:
return BO_GE;
2064 case OO_AmpAmp:
return BO_LAnd;
2065 case OO_PipePipe:
return BO_LOr;
2066 case OO_Comma:
return BO_Comma;
2067 case OO_ArrowStar:
return BO_PtrMemI;
2074 OO_Star, OO_Slash, OO_Percent,
2076 OO_LessLess, OO_GreaterGreater,
2078 OO_Less, OO_Greater, OO_LessEqual, OO_GreaterEqual,
2079 OO_EqualEqual, OO_ExclaimEqual,
2085 OO_Equal, OO_StarEqual,
2086 OO_SlashEqual, OO_PercentEqual,
2087 OO_PlusEqual, OO_MinusEqual,
2088 OO_LessLessEqual, OO_GreaterGreaterEqual,
2089 OO_AmpEqual, OO_CaretEqual,
2093 return OverOps[Opc];
2141 llvm_unreachable(
"unhandled case");
2149 BuiltinLoc(BLoc), RParenLoc(RParenLoc), ParentContext(ParentContext) {
2156 return "__builtin_FILE";
2158 return "__builtin_FUNCTION";
2160 return "__builtin_LINE";
2162 return "__builtin_COLUMN";
2164 llvm_unreachable(
"unexpected IdentKind!");
2168 const Expr *DefaultExpr)
const {
2173 Context) = [&]() -> std::pair<SourceLocation, const DeclContext *> {
2174 if (
auto *DIE = dyn_cast_or_null<CXXDefaultInitExpr>(DefaultExpr))
2175 return {DIE->getUsedLocation(), DIE->getUsedContext()};
2176 if (
auto *DAE = dyn_cast_or_null<CXXDefaultArgExpr>(DefaultExpr))
2177 return {DAE->getUsedLocation(), DAE->getUsedContext()};
2184 auto MakeStringLiteral = [&](StringRef Tmp) {
2188 LValuePathEntry Path[1] = {LValuePathEntry::ArrayIndex(0)};
2196 const Decl *CurDecl = dyn_cast_or_null<Decl>(Context);
2197 return MakeStringLiteral(
2210 llvm_unreachable(
"unhandled case");
2217 InitExprs(C, initExprs.size()),
2218 LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(nullptr,
true)
2221 for (
unsigned I = 0; I != initExprs.size(); ++I) {
2227 ExprBits.InstantiationDependent =
true;
2229 ExprBits.ContainsUnexpandedParameterPack =
true;
2232 InitExprs.
insert(C, InitExprs.
end(), initExprs.begin(), initExprs.end());
2236 if (NumInits > InitExprs.
size())
2237 InitExprs.
reserve(C, NumInits);
2241 InitExprs.
resize(C, NumInits,
nullptr);
2245 if (Init >= InitExprs.
size()) {
2246 InitExprs.
insert(C, InitExprs.
end(), Init - InitExprs.
size() + 1,
nullptr);
2251 Expr *
Result = cast_or_null<Expr>(InitExprs[Init]);
2258 ArrayFillerOrUnionFieldInit = filler;
2262 if (inits[
i] ==
nullptr)
2277 return isa<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init);
2281 assert(
isSemanticForm() &&
"syntactic form never semantically transparent");
2285 assert(
getNumInits() == 1 &&
"multiple inits in glvalue init list");
2304 assert(
isSyntacticForm() &&
"only test syntactic form as zero initializer");
2311 return Lit && Lit->
getValue() == 0;
2316 return SyntacticForm->getBeginLoc();
2321 E = InitExprs.
end();
2324 Beg = S->getBeginLoc();
2334 return SyntacticForm->getEndLoc();
2339 E = InitExprs.
rend();
2342 End = S->getEndLoc();
2354 return cast<BlockPointerType>(
getType())
2359 return TheBlock->getCaretLocation();
2362 return TheBlock->getBody();
2365 return TheBlock->getBody();
2393 case ParenExprClass:
2394 return cast<ParenExpr>(
this)->getSubExpr()->
2396 case GenericSelectionExprClass:
2397 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
2399 case CoawaitExprClass:
2400 case CoyieldExprClass:
2401 return cast<CoroutineSuspendExpr>(
this)->getResumeExpr()->
2403 case ChooseExprClass:
2404 return cast<ChooseExpr>(
this)->getChosenSubExpr()->
2406 case UnaryOperatorClass: {
2429 .isVolatileQualified())
2440 case BinaryOperatorClass: {
2452 if (IE->getValue() == 0)
2471 case CompoundAssignOperatorClass:
2472 case VAArgExprClass:
2473 case AtomicExprClass:
2476 case ConditionalOperatorClass: {
2480 const auto *Exp = cast<ConditionalOperator>(
this);
2481 return Exp->getLHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx) &&
2482 Exp->getRHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2484 case BinaryConditionalOperatorClass: {
2485 const auto *Exp = cast<BinaryConditionalOperator>(
this);
2486 return Exp->getFalseExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2489 case MemberExprClass:
2491 Loc = cast<MemberExpr>(
this)->getMemberLoc();
2493 R2 = cast<MemberExpr>(
this)->getBase()->getSourceRange();
2496 case ArraySubscriptExprClass:
2498 Loc = cast<ArraySubscriptExpr>(
this)->getRBracketLoc();
2499 R1 = cast<ArraySubscriptExpr>(
this)->getLHS()->getSourceRange();
2500 R2 = cast<ArraySubscriptExpr>(
this)->getRHS()->getSourceRange();
2503 case CXXOperatorCallExprClass: {
2515 case OO_ExclaimEqual:
2518 case OO_GreaterEqual:
2533 case CXXMemberCallExprClass:
2534 case UserDefinedLiteralClass: {
2536 const CallExpr *CE = cast<CallExpr>(
this);
2544 FD->hasAttr<PureAttr>() || FD->hasAttr<ConstAttr>()) {
2559 case UnresolvedLookupExprClass:
2560 case CXXUnresolvedConstructExprClass:
2563 case CXXTemporaryObjectExprClass:
2564 case CXXConstructExprClass: {
2566 if (Type->
hasAttr<WarnUnusedAttr>()) {
2576 case ObjCMessageExprClass: {
2589 if (MD->hasAttr<WarnUnusedResultAttr>()) {
2598 case ObjCPropertyRefExprClass:
2604 case PseudoObjectExprClass: {
2618 case StmtExprClass: {
2624 const CompoundStmt *CS = cast<StmtExpr>(
this)->getSubStmt();
2627 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2629 if (
const Expr *E = dyn_cast<Expr>(
Label->getSubStmt()))
2630 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2636 Loc = cast<StmtExpr>(
this)->getLParenLoc();
2640 case CXXFunctionalCastExprClass:
2641 case CStyleCastExprClass: {
2644 const CastExpr *CE = cast<CastExpr>(
this);
2650 if (!(DRE && isa<VarDecl>(DRE->
getDecl()) &&
2651 cast<VarDecl>(DRE->
getDecl())->hasLocalStorage()) &&
2662 if (CE->
getCastKind() == CK_ConstructorConversion)
2667 dyn_cast<CXXFunctionalCastExpr>(
this)) {
2668 Loc = CXXCE->getBeginLoc();
2669 R1 = CXXCE->getSubExpr()->getSourceRange();
2677 case ImplicitCastExprClass: {
2678 const CastExpr *ICE = cast<ImplicitCastExpr>(
this);
2687 case CXXDefaultArgExprClass:
2688 return (cast<CXXDefaultArgExpr>(
this)
2690 case CXXDefaultInitExprClass:
2691 return (cast<CXXDefaultInitExpr>(
this)
2694 case CXXNewExprClass:
2697 case CXXDeleteExprClass:
2699 case MaterializeTemporaryExprClass:
2700 return cast<MaterializeTemporaryExpr>(
this)->GetTemporaryExpr()
2701 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2702 case CXXBindTemporaryExprClass:
2703 return cast<CXXBindTemporaryExpr>(
this)->getSubExpr()
2704 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2705 case ExprWithCleanupsClass:
2706 return cast<ExprWithCleanups>(
this)->getSubExpr()
2707 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2718 case ObjCIvarRefExprClass:
2720 case Expr::UnaryOperatorClass:
2721 return cast<UnaryOperator>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2722 case ImplicitCastExprClass:
2723 return cast<ImplicitCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2724 case MaterializeTemporaryExprClass:
2725 return cast<MaterializeTemporaryExpr>(E)->GetTemporaryExpr()
2726 ->isOBJCGCCandidate(Ctx);
2727 case CStyleCastExprClass:
2728 return cast<CStyleCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2729 case DeclRefExprClass: {
2730 const Decl *D = cast<DeclRefExpr>(E)->getDecl();
2732 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2733 if (VD->hasGlobalStorage())
2743 case MemberExprClass: {
2747 case ArraySubscriptExprClass:
2748 return cast<ArraySubscriptExpr>(E)->getBase()->isOBJCGCCandidate(Ctx);
2766 if (
const MemberExpr *mem = dyn_cast<MemberExpr>(expr)) {
2767 assert(isa<CXXMethodDecl>(mem->getMemberDecl()));
2768 return mem->getMemberDecl()->getType();
2778 assert(isa<UnresolvedMemberExpr>(expr) || isa<CXXPseudoDestructorExpr>(expr));
2783 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
2784 return ICE->getSubExpr();
2786 if (
auto *FE = dyn_cast<FullExpr>(E))
2787 return FE->getSubExpr();
2800 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
2801 return MTE->GetTemporaryExpr();
2803 if (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
2804 return NTTP->getReplacement();
2810 if (
auto *CE = dyn_cast<CastExpr>(E))
2811 return CE->getSubExpr();
2813 if (
auto *FE = dyn_cast<FullExpr>(E))
2814 return FE->getSubExpr();
2816 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
2817 return MTE->GetTemporaryExpr();
2819 if (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
2820 return NTTP->getReplacement();
2828 if (
auto *CE = dyn_cast<CastExpr>(E))
2829 if (CE->getCastKind() != CK_LValueToRValue)
2836 if (
auto *CE = dyn_cast<CastExpr>(E))
2837 if (CE->getCastKind() == CK_DerivedToBase ||
2838 CE->getCastKind() == CK_UncheckedDerivedToBase ||
2839 CE->getCastKind() == CK_NoOp)
2840 return CE->getSubExpr();
2850 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
2851 return MTE->GetTemporaryExpr();
2853 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(E))
2854 return BTE->getSubExpr();
2860 if (
auto *PE = dyn_cast<ParenExpr>(E))
2861 return PE->getSubExpr();
2863 if (
auto *UO = dyn_cast<UnaryOperator>(E)) {
2864 if (UO->getOpcode() == UO_Extension)
2865 return UO->getSubExpr();
2868 else if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
2869 if (!GSE->isResultDependent())
2870 return GSE->getResultExpr();
2873 else if (
auto *CE = dyn_cast<ChooseExpr>(E)) {
2874 if (!CE->isConditionDependent())
2875 return CE->getChosenSubExpr();
2878 else if (
auto *CE = dyn_cast<ConstantExpr>(E))
2879 return CE->getSubExpr();
2885 if (
auto *CE = dyn_cast<CastExpr>(E)) {
2888 Expr *SubExpr = CE->getSubExpr();
2889 bool IsIdentityCast =
2891 bool IsSameWidthCast =
2897 if (IsIdentityCast || IsSameWidthCast)
2901 else if (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
2902 return NTTP->getReplacement();
2908 template <
typename FnTy,
typename... FnTys>
2916 template <
typename... FnTys>
2918 Expr *LastE =
nullptr;
2919 while (E != LastE) {
2952 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(
this)) {
2953 if (MCE->getMethodDecl() && isa<CXXConversionDecl>(MCE->getMethodDecl()))
2954 return MCE->getImplicitObjectArgument();
2976 const Expr *E =
this;
2978 E = M->GetTemporaryExpr();
2981 E = ICE->getSubExprAsWritten();
2983 return isa<CXXDefaultArgExpr>(E);
2990 E = M->GetTemporaryExpr();
2993 if (ICE->getCastKind() == CK_NoOp)
2994 E = ICE->getSubExpr();
3000 E = BE->getSubExpr();
3003 if (ICE->getCastKind() == CK_NoOp)
3004 E = ICE->getSubExpr();
3023 if (!isa<ObjCPropertyRefExpr>(E))
3031 if (isa<ImplicitCastExpr>(E)) {
3032 switch (cast<ImplicitCastExpr>(E)->getCastKind()) {
3033 case CK_DerivedToBase:
3034 case CK_UncheckedDerivedToBase:
3042 if (isa<MemberExpr>(E))
3046 if (BO->isPtrMemOp())
3050 if (isa<OpaqueValueExpr>(E))
3057 const Expr *E =
this;
3062 E =
Paren->getSubExpr();
3067 if (ICE->getCastKind() == CK_NoOp ||
3068 ICE->getCastKind() == CK_LValueToRValue ||
3069 ICE->getCastKind() == CK_DerivedToBase ||
3070 ICE->getCastKind() == CK_UncheckedDerivedToBase) {
3071 E = ICE->getSubExpr();
3076 if (
const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) {
3077 if (UnOp->getOpcode() == UO_Extension) {
3078 E = UnOp->getSubExpr();
3084 = dyn_cast<MaterializeTemporaryExpr>(E)) {
3085 E = M->GetTemporaryExpr();
3092 if (
const CXXThisExpr *This = dyn_cast<CXXThisExpr>(E))
3093 return This->isImplicit();
3101 for (
unsigned I = 0; I < Exprs.size(); ++I)
3109 const Expr **Culprit)
const {
3111 "Expression evaluator can't be called on a dependent expression.");
3133 case StringLiteralClass:
3134 case ObjCEncodeExprClass:
3136 case CXXTemporaryObjectExprClass:
3137 case CXXConstructExprClass: {
3146 assert(CE->
getNumArgs() == 1 &&
"trivial ctor with > 1 argument");
3152 case ConstantExprClass: {
3155 const Expr *Exp = cast<ConstantExpr>(
this)->getSubExpr();
3158 case CompoundLiteralExprClass: {
3162 const Expr *Exp = cast<CompoundLiteralExpr>(
this)->getInitializer();
3165 case DesignatedInitUpdateExprClass: {
3170 case InitListExprClass: {
3172 assert(ILE->
isSemanticForm() &&
"InitListExpr must be in semantic form");
3175 for (
unsigned i = 0;
i < numInits;
i++) {
3183 unsigned ElementNo = 0;
3185 for (
const auto *Field : RD->
fields()) {
3191 if (Field->isUnnamedBitfield())
3196 if (Field->isBitField()) {
3205 bool RefType = Field->getType()->isReferenceType();
3216 case ImplicitValueInitExprClass:
3217 case NoInitExprClass:
3219 case ParenExprClass:
3220 return cast<ParenExpr>(
this)->getSubExpr()
3221 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3222 case GenericSelectionExprClass:
3223 return cast<GenericSelectionExpr>(
this)->getResultExpr()
3224 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3225 case ChooseExprClass:
3226 if (cast<ChooseExpr>(
this)->isConditionDependent()) {
3231 return cast<ChooseExpr>(
this)->getChosenSubExpr()
3233 case UnaryOperatorClass: {
3239 case CXXFunctionalCastExprClass:
3240 case CXXStaticCastExprClass:
3241 case ImplicitCastExprClass:
3242 case CStyleCastExprClass:
3243 case ObjCBridgedCastExprClass:
3244 case CXXDynamicCastExprClass:
3245 case CXXReinterpretCastExprClass:
3246 case CXXConstCastExprClass: {
3247 const CastExpr *CE = cast<CastExpr>(
this);
3261 case MaterializeTemporaryExprClass:
3262 return cast<MaterializeTemporaryExpr>(
this)->GetTemporaryExpr()
3263 ->isConstantInitializer(Ctx,
false, Culprit);
3265 case SubstNonTypeTemplateParmExprClass:
3266 return cast<SubstNonTypeTemplateParmExpr>(
this)->getReplacement()
3267 ->isConstantInitializer(Ctx,
false, Culprit);
3268 case CXXDefaultArgExprClass:
3269 return cast<CXXDefaultArgExpr>(
this)->getExpr()
3270 ->isConstantInitializer(Ctx,
false, Culprit);
3271 case CXXDefaultInitExprClass:
3272 return cast<CXXDefaultInitExpr>(
this)->getExpr()
3273 ->isConstantInitializer(Ctx,
false, Culprit);
3287 if (!FD || (FD->
getBuiltinID() != Builtin::BI__assume &&
3291 const Expr* Arg = getArg(0);
3301 const bool IncludePossibleEffects;
3305 explicit SideEffectFinder(
const ASTContext &Context,
bool IncludePossible)
3306 : Inherited(Context),
3307 IncludePossibleEffects(IncludePossible),
HasSideEffects(
false) { }
3311 void VisitExpr(
const Expr *E) {
3312 if (!HasSideEffects &&
3314 HasSideEffects =
true;
3320 bool IncludePossibleEffects)
const {
3324 if (!IncludePossibleEffects &&
getExprLoc().isMacroID())
3328 return IncludePossibleEffects;
3332 #define ABSTRACT_STMT(Type) 3333 #define STMT(Type, Base) case Type##Class: 3334 #define EXPR(Type, Base) 3335 #include "clang/AST/StmtNodes.inc" 3336 llvm_unreachable(
"unexpected Expr kind");
3338 case DependentScopeDeclRefExprClass:
3339 case CXXUnresolvedConstructExprClass:
3340 case CXXDependentScopeMemberExprClass:
3341 case UnresolvedLookupExprClass:
3342 case UnresolvedMemberExprClass:
3343 case PackExpansionExprClass:
3344 case SubstNonTypeTemplateParmPackExprClass:
3345 case FunctionParmPackExprClass:
3347 case CXXFoldExprClass:
3348 llvm_unreachable(
"shouldn't see dependent / unresolved nodes here");
3350 case DeclRefExprClass:
3351 case ObjCIvarRefExprClass:
3352 case PredefinedExprClass:
3353 case IntegerLiteralClass:
3354 case FixedPointLiteralClass:
3355 case FloatingLiteralClass:
3356 case ImaginaryLiteralClass:
3357 case StringLiteralClass:
3358 case CharacterLiteralClass:
3359 case OffsetOfExprClass:
3360 case ImplicitValueInitExprClass:
3361 case UnaryExprOrTypeTraitExprClass:
3362 case AddrLabelExprClass:
3363 case GNUNullExprClass:
3364 case ArrayInitIndexExprClass:
3365 case NoInitExprClass:
3366 case CXXBoolLiteralExprClass:
3367 case CXXNullPtrLiteralExprClass:
3368 case CXXThisExprClass:
3369 case CXXScalarValueInitExprClass:
3370 case TypeTraitExprClass:
3371 case ArrayTypeTraitExprClass:
3372 case ExpressionTraitExprClass:
3373 case CXXNoexceptExprClass:
3374 case SizeOfPackExprClass:
3375 case ObjCStringLiteralClass:
3376 case ObjCEncodeExprClass:
3377 case ObjCBoolLiteralExprClass:
3378 case ObjCAvailabilityCheckExprClass:
3379 case CXXUuidofExprClass:
3380 case OpaqueValueExprClass:
3381 case SourceLocExprClass:
3385 case ConstantExprClass:
3387 return cast<ConstantExpr>(
this)->getSubExpr()->HasSideEffects(
3388 Ctx, IncludePossibleEffects);
3391 case CXXOperatorCallExprClass:
3392 case CXXMemberCallExprClass:
3393 case CUDAKernelCallExprClass:
3394 case UserDefinedLiteralClass: {
3398 const Decl *FD = cast<CallExpr>(
this)->getCalleeDecl();
3399 bool IsPure = FD && (FD->
hasAttr<ConstAttr>() || FD->
hasAttr<PureAttr>());
3400 if (IsPure || !IncludePossibleEffects)
3405 case BlockExprClass:
3406 case CXXBindTemporaryExprClass:
3407 if (!IncludePossibleEffects)
3411 case MSPropertyRefExprClass:
3412 case MSPropertySubscriptExprClass:
3413 case CompoundAssignOperatorClass:
3414 case VAArgExprClass:
3415 case AtomicExprClass:
3416 case CXXThrowExprClass:
3417 case CXXNewExprClass:
3418 case CXXDeleteExprClass:
3419 case CoawaitExprClass:
3420 case DependentCoawaitExprClass:
3421 case CoyieldExprClass:
3425 case StmtExprClass: {
3427 SideEffectFinder Finder(Ctx, IncludePossibleEffects);
3428 Finder.Visit(cast<StmtExpr>(
this)->getSubStmt());
3429 return Finder.hasSideEffects();
3432 case ExprWithCleanupsClass:
3433 if (IncludePossibleEffects)
3434 if (cast<ExprWithCleanups>(
this)->cleanupsHaveSideEffects())
3438 case ParenExprClass:
3439 case ArraySubscriptExprClass:
3440 case OMPArraySectionExprClass:
3441 case MemberExprClass:
3442 case ConditionalOperatorClass:
3443 case BinaryConditionalOperatorClass:
3444 case CompoundLiteralExprClass:
3445 case ExtVectorElementExprClass:
3446 case DesignatedInitExprClass:
3447 case DesignatedInitUpdateExprClass:
3448 case ArrayInitLoopExprClass:
3449 case ParenListExprClass:
3450 case CXXPseudoDestructorExprClass:
3451 case CXXStdInitializerListExprClass:
3452 case SubstNonTypeTemplateParmExprClass:
3453 case MaterializeTemporaryExprClass:
3454 case ShuffleVectorExprClass:
3455 case ConvertVectorExprClass:
3456 case AsTypeExprClass:
3460 case UnaryOperatorClass:
3461 if (cast<UnaryOperator>(
this)->isIncrementDecrementOp())
3465 case BinaryOperatorClass:
3466 if (cast<BinaryOperator>(
this)->isAssignmentOp())
3470 case InitListExprClass:
3473 if (E->HasSideEffects(Ctx, IncludePossibleEffects))
3477 case GenericSelectionExprClass:
3478 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
3481 case ChooseExprClass:
3482 return cast<ChooseExpr>(
this)->getChosenSubExpr()->HasSideEffects(
3483 Ctx, IncludePossibleEffects);
3485 case CXXDefaultArgExprClass:
3486 return cast<CXXDefaultArgExpr>(
this)->getExpr()->HasSideEffects(
3487 Ctx, IncludePossibleEffects);
3489 case CXXDefaultInitExprClass: {
3490 const FieldDecl *FD = cast<CXXDefaultInitExpr>(
this)->getField();
3492 return E->HasSideEffects(Ctx, IncludePossibleEffects);
3497 case CXXDynamicCastExprClass: {
3505 case ImplicitCastExprClass:
3506 case CStyleCastExprClass:
3507 case CXXStaticCastExprClass:
3508 case CXXReinterpretCastExprClass:
3509 case CXXConstCastExprClass:
3510 case CXXFunctionalCastExprClass:
3511 case BuiltinBitCastExprClass: {
3516 if (!IncludePossibleEffects)
3519 const CastExpr *CE = cast<CastExpr>(
this);
3526 case CXXTypeidExprClass:
3529 return cast<CXXTypeidExpr>(
this)->isPotentiallyEvaluated();
3531 case CXXConstructExprClass:
3532 case CXXTemporaryObjectExprClass: {
3541 case CXXInheritedCtorInitExprClass: {
3542 const auto *ICIE = cast<CXXInheritedCtorInitExpr>(
this);
3543 if (!ICIE->getConstructor()->isTrivial() && IncludePossibleEffects)
3548 case LambdaExprClass: {
3549 const LambdaExpr *LE = cast<LambdaExpr>(
this);
3551 if (E->HasSideEffects(Ctx, IncludePossibleEffects))
3556 case PseudoObjectExprClass: {
3563 const Expr *Subexpr = *I;
3565 Subexpr = OVE->getSourceExpr();
3572 case ObjCBoxedExprClass:
3573 case ObjCArrayLiteralClass:
3574 case ObjCDictionaryLiteralClass:
3575 case ObjCSelectorExprClass:
3576 case ObjCProtocolExprClass:
3577 case ObjCIsaExprClass:
3578 case ObjCIndirectCopyRestoreExprClass:
3579 case ObjCSubscriptRefExprClass:
3580 case ObjCBridgedCastExprClass:
3581 case ObjCMessageExprClass:
3582 case ObjCPropertyRefExprClass:
3584 if (IncludePossibleEffects)
3592 cast<Expr>(SubStmt)->HasSideEffects(Ctx, IncludePossibleEffects))
3607 explicit NonTrivialCallFinder(
const ASTContext &Context)
3608 : Inherited(Context), NonTrivial(
false) { }
3612 void VisitCallExpr(
const CallExpr *E) {
3614 = dyn_cast_or_null<const CXXMethodDecl>(E->
getCalleeDecl())) {
3615 if (Method->isTrivial()) {
3617 Inherited::VisitStmt(E);
3628 Inherited::VisitStmt(E);
3637 Inherited::VisitStmt(E);
3647 NonTrivialCallFinder Finder(Ctx);
3649 return Finder.hasNonTrivialCall();
3664 llvm_unreachable(
"Unexpected value dependent expression!");
3695 CE->getSubExpr()->getType()->isIntegerType())
3696 return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3699 }
else if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(
this)) {
3701 return ICE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3702 }
else if (
const ParenExpr *PE = dyn_cast<ParenExpr>(
this)) {
3705 return PE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3707 dyn_cast<GenericSelectionExpr>(
this)) {
3708 if (GE->isResultDependent())
3710 return GE->getResultExpr()->isNullPointerConstant(Ctx, NPC);
3711 }
else if (
const ChooseExpr *CE = dyn_cast<ChooseExpr>(
this)) {
3712 if (CE->isConditionDependent())
3714 return CE->getChosenSubExpr()->isNullPointerConstant(Ctx, NPC);
3716 = dyn_cast<CXXDefaultArgExpr>(
this)) {
3718 return DefaultArg->getExpr()->isNullPointerConstant(Ctx, NPC);
3720 = dyn_cast<CXXDefaultInitExpr>(
this)) {
3722 return DefaultInit->getExpr()->isNullPointerConstant(Ctx, NPC);
3723 }
else if (isa<GNUNullExpr>(
this)) {
3727 = dyn_cast<MaterializeTemporaryExpr>(
this)) {
3728 return M->GetTemporaryExpr()->isNullPointerConstant(Ctx, NPC);
3729 }
else if (
const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(
this)) {
3730 if (
const Expr *Source = OVE->getSourceExpr())
3731 return Source->isNullPointerConstant(Ctx, NPC);
3735 if (
getType()->isNullPtrType())
3740 UT && UT->getDecl()->hasAttr<TransparentUnionAttr>())
3742 const Expr *InitExpr = CLE->getInitializer();
3743 if (
const InitListExpr *ILE = dyn_cast<InitListExpr>(InitExpr))
3747 if (!
getType()->isIntegerType() ||
3770 if (isa<IntegerLiteral>(
this))
3778 const Expr *E =
this;
3782 "expression is not a property reference");
3785 if (BO->getOpcode() == BO_Comma) {
3794 return cast<ObjCPropertyRefExpr>(E);
3819 if (ICE->getCastKind() == CK_LValueToRValue ||
3820 (ICE->getValueKind() !=
VK_RValue && ICE->getCastKind() == CK_NoOp))
3826 if (
MemberExpr *MemRef = dyn_cast<MemberExpr>(E))
3827 if (
FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
3828 if (Field->isBitField())
3837 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E)) {
3838 if (
FieldDecl *Field = dyn_cast<FieldDecl>(DeclRef->getDecl()))
3839 if (Field->isBitField())
3842 if (
BindingDecl *BD = dyn_cast<BindingDecl>(DeclRef->getDecl()))
3843 if (
Expr *E = BD->getBinding())
3848 if (BinOp->isAssignmentOp() && BinOp->getLHS())
3849 return BinOp->getLHS()->getSourceBitField();
3851 if (BinOp->getOpcode() == BO_Comma && BinOp->getRHS())
3852 return BinOp->getRHS()->getSourceBitField();
3856 if (UnOp->isPrefix() && UnOp->isIncrementDecrementOp())
3857 return UnOp->getSubExpr()->getSourceBitField();
3868 ICE->getCastKind() == CK_NoOp)
3877 if (isa<ExtVectorElementExpr>(E))
3880 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
3881 if (
auto *BD = dyn_cast<BindingDecl>(DRE->getDecl()))
3882 if (
auto *E = BD->getBinding())
3891 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
3892 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
3894 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
3903 return getBase()->getType()->isPointerType();
3908 return VT->getNumElements();
3916 StringRef Comp = Accessor->getName();
3919 if (Comp ==
"hi" || Comp ==
"lo" || Comp ==
"even" || Comp ==
"odd")
3923 if (Comp[0] ==
's' || Comp[0] ==
'S')
3924 Comp = Comp.substr(1);
3926 for (
unsigned i = 0, e = Comp.size();
i != e; ++
i)
3927 if (Comp.substr(
i + 1).find(Comp[
i]) != StringRef::npos)
3936 StringRef Comp = Accessor->getName();
3937 bool isNumericAccessor =
false;
3938 if (Comp[0] ==
's' || Comp[0] ==
'S') {
3939 Comp = Comp.substr(1);
3940 isNumericAccessor =
true;
3943 bool isHi = Comp ==
"hi";
3944 bool isLo = Comp ==
"lo";
3945 bool isEven = Comp ==
"even";
3946 bool isOdd = Comp ==
"odd";
3948 for (
unsigned i = 0, e = getNumElements();
i != e; ++
i) {
3962 Elts.push_back(Index);
3970 Type->isDependentType(), Type->isDependentType(),
3971 Type->isInstantiationDependentType(),
3973 BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size())
3975 SubExprs =
new (
C)
Stmt*[args.size()];
3976 for (
unsigned i = 0;
i != args.size();
i++) {
3982 ExprBits.InstantiationDependent =
true;
3984 ExprBits.ContainsUnexpandedParameterPack =
true;
3986 SubExprs[
i] = args[
i];
3993 this->NumExprs = Exprs.size();
3994 SubExprs =
new (
C)
Stmt*[NumExprs];
3995 memcpy(SubExprs, Exprs.data(),
sizeof(
Expr *) * Exprs.size());
3998 GenericSelectionExpr::GenericSelectionExpr(
4002 bool ContainsUnexpandedParameterPack,
unsigned ResultIndex)
4003 :
Expr(GenericSelectionExprClass, AssocExprs[ResultIndex]->
getType(),
4009 ContainsUnexpandedParameterPack),
4010 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
4011 DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4012 assert(AssocTypes.size() == AssocExprs.size() &&
4013 "Must have the same number of association expressions" 4014 " and TypeSourceInfo!");
4015 assert(ResultIndex < NumAssocs &&
"ResultIndex is out-of-bounds!");
4018 getTrailingObjects<Stmt *>()[ControllingIndex] = ControllingExpr;
4019 std::copy(AssocExprs.begin(), AssocExprs.end(),
4020 getTrailingObjects<Stmt *>() + AssocExprStartIndex);
4021 std::copy(AssocTypes.begin(), AssocTypes.end(),
4022 getTrailingObjects<TypeSourceInfo *>());
4025 GenericSelectionExpr::GenericSelectionExpr(
4029 bool ContainsUnexpandedParameterPack)
4034 true, ContainsUnexpandedParameterPack),
4035 NumAssocs(AssocExprs.size()), ResultIndex(ResultDependentIndex),
4036 DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4037 assert(AssocTypes.size() == AssocExprs.size() &&
4038 "Must have the same number of association expressions" 4039 " and TypeSourceInfo!");
4042 getTrailingObjects<Stmt *>()[ControllingIndex] = ControllingExpr;
4043 std::copy(AssocExprs.begin(), AssocExprs.end(),
4044 getTrailingObjects<Stmt *>() + AssocExprStartIndex);
4045 std::copy(AssocTypes.begin(), AssocTypes.end(),
4046 getTrailingObjects<TypeSourceInfo *>());
4049 GenericSelectionExpr::GenericSelectionExpr(
EmptyShell Empty,
unsigned NumAssocs)
4050 :
Expr(GenericSelectionExprClass, Empty), NumAssocs(NumAssocs) {}
4056 bool ContainsUnexpandedParameterPack,
unsigned ResultIndex) {
4057 unsigned NumAssocs = AssocExprs.size();
4059 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4062 Context, GenericLoc, ControllingExpr, AssocTypes, AssocExprs, DefaultLoc,
4063 RParenLoc, ContainsUnexpandedParameterPack, ResultIndex);
4070 bool ContainsUnexpandedParameterPack) {
4071 unsigned NumAssocs = AssocExprs.size();
4073 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4076 Context, GenericLoc, ControllingExpr, AssocTypes, AssocExprs, DefaultLoc,
4077 RParenLoc, ContainsUnexpandedParameterPack);
4082 unsigned NumAssocs) {
4084 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4095 if (Field.NameOrField & 0x01)
4096 return reinterpret_cast<IdentifierInfo *
>(Field.NameOrField&~0x01);
4098 return getField()->getIdentifier();
4107 :
Expr(DesignatedInitExprClass, Ty,
4112 EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
4113 NumDesignators(Designators.size()), NumSubExprs(IndexExprs.size() + 1) {
4114 this->Designators =
new (
C)
Designator[NumDesignators];
4122 unsigned IndexIdx = 0;
4123 for (
unsigned I = 0; I != NumDesignators; ++I) {
4124 this->Designators[I] = Designators[I];
4126 if (this->Designators[I].isArrayDesignator()) {
4128 Expr *Index = IndexExprs[IndexIdx];
4132 ExprBits.InstantiationDependent =
true;
4135 ExprBits.ContainsUnexpandedParameterPack =
true;
4138 *Child++ = IndexExprs[IndexIdx++];
4139 }
else if (this->Designators[I].isArrayRangeDesignator()) {
4141 Expr *Start = IndexExprs[IndexIdx];
4142 Expr *
End = IndexExprs[IndexIdx + 1];
4146 ExprBits.InstantiationDependent =
true;
4149 ExprBits.InstantiationDependent =
true;
4155 ExprBits.ContainsUnexpandedParameterPack =
true;
4158 *Child++ = IndexExprs[IndexIdx++];
4159 *Child++ = IndexExprs[IndexIdx++];
4163 assert(IndexIdx == IndexExprs.size() &&
"Wrong number of index expressions");
4171 bool UsesColonSyntax,
Expr *Init) {
4172 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(IndexExprs.size() + 1),
4175 ColonOrEqualLoc, UsesColonSyntax,
4180 unsigned NumIndexExprs) {
4181 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(NumIndexExprs + 1),
4188 unsigned NumDesigs) {
4190 NumDesignators = NumDesigs;
4191 for (
unsigned I = 0; I != NumDesigs; ++I)
4192 Designators[I] = Desigs[I];
4219 return getInit()->getEndLoc();
4229 "Requires array range designator");
4235 "Requires array range designator");
4244 unsigned NumNewDesignators = Last -
First;
4245 if (NumNewDesignators == 0) {
4246 std::copy_backward(Designators + Idx + 1,
4247 Designators + NumDesignators,
4249 --NumNewDesignators;
4251 }
else if (NumNewDesignators == 1) {
4252 Designators[Idx] = *
First;
4257 =
new (
C)
Designator[NumDesignators - 1 + NumNewDesignators];
4258 std::copy(Designators, Designators + Idx, NewDesignators);
4259 std::copy(First, Last, NewDesignators + Idx);
4260 std::copy(Designators + Idx + 1, Designators + NumDesignators,
4261 NewDesignators + Idx + NumNewDesignators);
4262 Designators = NewDesignators;
4263 NumDesignators = NumDesignators - 1 + NumNewDesignators;
4270 BaseAndUpdaterExprs[0] = baseExpr;
4274 BaseAndUpdaterExprs[1] = ILE;
4289 LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
4292 for (
unsigned I = 0, N = Exprs.size(); I != N; ++I) {
4298 ExprBits.InstantiationDependent =
true;
4300 ExprBits.ContainsUnexpandedParameterPack =
true;
4302 getTrailingObjects<Stmt *>()[I] = Exprs[I];
4306 ParenListExpr::ParenListExpr(
EmptyShell Empty,
unsigned NumExprs)
4307 :
Expr(ParenListExprClass, Empty) {
4315 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(Exprs.size()),
4317 return new (Mem)
ParenListExpr(LParenLoc, Exprs, RParenLoc);
4321 unsigned NumExprs) {
4329 e = ewc->getSubExpr();
4331 e = m->GetTemporaryExpr();
4332 e = cast<CXXConstructExpr>(e)->getArg(0);
4334 e = ice->getSubExpr();
4335 return cast<OpaqueValueExpr>(e);
4340 unsigned numSemanticExprs) {
4342 Context.
Allocate(totalSizeToAlloc<Expr *>(1 + numSemanticExprs),
4347 PseudoObjectExpr::PseudoObjectExpr(
EmptyShell shell,
unsigned numSemanticExprs)
4348 :
Expr(PseudoObjectExprClass, shell) {
4354 unsigned resultIndex) {
4355 assert(syntax &&
"no syntactic expression!");
4356 assert(semantics.size() &&
"no semantic expressions!");
4360 if (resultIndex == NoResult) {
4364 assert(resultIndex < semantics.size());
4365 type = semantics[resultIndex]->getType();
4366 VK = semantics[resultIndex]->getValueKind();
4370 void *buffer = C.
Allocate(totalSizeToAlloc<Expr *>(semantics.size() + 1),
4378 unsigned resultIndex)
4380 false,
false,
false,
false) {
4384 for (
unsigned i = 0, e = semantics.size() + 1;
i != e; ++
i) {
4385 Expr *E = (
i == 0 ? syntax : semantics[
i-1]);
4386 getSubExprsBuffer()[
i] = E;
4393 ExprBits.InstantiationDependent =
true;
4395 ExprBits.ContainsUnexpandedParameterPack =
true;
4397 if (isa<OpaqueValueExpr>(E))
4398 assert(cast<OpaqueValueExpr>(E)->getSourceExpr() !=
nullptr &&
4399 "opaque-value semantic expressions for pseudo-object " 4400 "operations must have sources");
4419 if (isArgumentType()) {
4421 dyn_cast<VariableArrayType>(getArgumentType().getTypePtr()))
4432 NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op)
4434 assert(args.size() ==
getNumSubExprs(op) &&
"wrong number of subexpressions");
4435 for (
unsigned i = 0;
i != args.size();
i++) {
4441 ExprBits.InstantiationDependent =
true;
4443 ExprBits.ContainsUnexpandedParameterPack =
true;
4445 SubExprs[
i] = args[
i];
4451 case AO__c11_atomic_init:
4452 case AO__opencl_atomic_init:
4453 case AO__c11_atomic_load:
4454 case AO__atomic_load_n:
4457 case AO__opencl_atomic_load:
4458 case AO__c11_atomic_store:
4459 case AO__c11_atomic_exchange:
4460 case AO__atomic_load:
4461 case AO__atomic_store:
4462 case AO__atomic_store_n:
4463 case AO__atomic_exchange_n:
4464 case AO__c11_atomic_fetch_add:
4465 case AO__c11_atomic_fetch_sub:
4466 case AO__c11_atomic_fetch_and:
4467 case AO__c11_atomic_fetch_or:
4468 case AO__c11_atomic_fetch_xor:
4469 case AO__atomic_fetch_add:
4470 case AO__atomic_fetch_sub:
4471 case AO__atomic_fetch_and:
4472 case AO__atomic_fetch_or:
4473 case AO__atomic_fetch_xor:
4474 case AO__atomic_fetch_nand:
4475 case AO__atomic_add_fetch:
4476 case AO__atomic_sub_fetch:
4477 case AO__atomic_and_fetch:
4478 case AO__atomic_or_fetch:
4479 case AO__atomic_xor_fetch:
4480 case AO__atomic_nand_fetch:
4481 case AO__atomic_fetch_min:
4482 case AO__atomic_fetch_max:
4485 case AO__opencl_atomic_store:
4486 case AO__opencl_atomic_exchange:
4487 case AO__opencl_atomic_fetch_add:
4488 case AO__opencl_atomic_fetch_sub:
4489 case AO__opencl_atomic_fetch_and:
4490 case AO__opencl_atomic_fetch_or:
4491 case AO__opencl_atomic_fetch_xor:
4492 case AO__opencl_atomic_fetch_min:
4493 case AO__opencl_atomic_fetch_max:
4494 case AO__atomic_exchange:
4497 case AO__c11_atomic_compare_exchange_strong:
4498 case AO__c11_atomic_compare_exchange_weak:
4501 case AO__opencl_atomic_compare_exchange_strong:
4502 case AO__opencl_atomic_compare_exchange_weak:
4503 case AO__atomic_compare_exchange:
4504 case AO__atomic_compare_exchange_n:
4507 llvm_unreachable(
"unknown atomic op");
4513 return AT->getValueType();
4518 unsigned ArraySectionCount = 0;
4519 while (
auto *OASE = dyn_cast<OMPArraySectionExpr>(Base->
IgnoreParens())) {
4520 Base = OASE->getBase();
4521 ++ArraySectionCount;
4525 Base = ASE->getBase();
4526 ++ArraySectionCount;
4529 auto OriginalTy = Base->
getType();
4530 if (
auto *DRE = dyn_cast<DeclRefExpr>(Base))
4531 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl()))
4532 OriginalTy = PVD->getOriginalType().getNonReferenceType();
4534 for (
unsigned Cnt = 0; Cnt < ArraySectionCount; ++Cnt) {
4535 if (OriginalTy->isAnyPointerType())
4538 assert (OriginalTy->isArrayType());
child_iterator child_begin()
CallExpr(StmtClass SC, Expr *Fn, ArrayRef< Expr *> PreArgs, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, unsigned MinNumArgs, ADLCallKind UsesADL)
Build a call expression, assuming that appropriate storage has been allocated for the trailing object...
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.
ConstantExprBitfields ConstantExprBits
SourceLocation getBeginLoc() const LLVM_READONLY
static Expr * IgnoreImpCastsExtraSingleStep(Expr *E)
static Expr * IgnoreNoopCastsSingleStep(const ASTContext &Ctx, Expr *E)
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.
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
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...
ResultStorageKind
Describes the kind of result that can be trail-allocated.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
const DeclarationNameLoc & getInfo() const
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
static Decl * castFromDeclContext(const DeclContext *)
unsigned FieldLoc
The location of the field name in the designated initializer.
const Expr * getInit(unsigned Init) const
const DeclContext * getParentContext() const
If the SourceLocExpr has been resolved return the subexpression representing the resolved value...
static ResultStorageKind getStorageKind(const APValue &Value)
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...
static CallExpr * CreateTemporary(void *Mem, Expr *Fn, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, ADLCallKind UsesADL=NotADL)
Create a temporary call expression with no arguments in the memory pointed to by Mem.
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
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.
static unsigned sizeOfTrailingObjects(unsigned NumPreArgs, unsigned NumArgs)
Return the size in bytes needed for the trailing objects.
Decl - This represents one declaration (or definition), e.g.
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.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
bool isSemanticForm() const
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list...
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.
SourceLocation getEndLoc() const LLVM_READONLY
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
NamedDecl * getParam(unsigned Idx)
SourceLocation getLParenLoc() const
const TargetInfo & getTargetInfo() const
A container of type source information.
SourceLocation getLocation() const
bool containsDuplicateElements() const
containsDuplicateElements - Return true if any element access is repeated.
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...
const Attr * getUnusedResultAttr(const ASTContext &Ctx) const
Returns the WarnUnusedResultAttr that is either declared on the called function, or its return type d...
Expr * ignoreParenBaseCasts() LLVM_READONLY
Skip past any parentheses and derived-to-base casts until reaching a fixed point. ...
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.
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
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const T * getAs() const
Member-template getAs<specific type>'.
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.
static PredefinedExpr * CreateEmpty(const ASTContext &Ctx, bool HasFunctionName)
Create an empty PredefinedExpr.
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)
static void AssertResultStorageKind(ConstantExpr::ResultStorageKind Kind)
Defines the clang::Expr interface and subclasses for C++ expressions.
The collection of all-type qualifiers we support.
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.
static constexpr ADLCallKind UsesADL
Used for GCC's __alignof.
unsigned getChar32Width() const
getChar32Width/Align - Return the size of 'char32_t' for this target, in bits.
FullExpr - Represents a "full-expression" node.
field_range fields() const
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
SourceLocation getBeginLoc() const LLVM_READONLY
NameKind getNameKind() const
Determine what kind of name this is.
Represents a member of a struct/union/class.
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.
static Expr * IgnoreLValueCastsSingleStep(Expr *E)
bool isReferenceType() const
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
Token - This structure provides full information about a lexed token.
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
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
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsBooleanCondition - Return true if this is a constant which we can fold and convert to a boo...
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
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr *> Exprs, SourceLocation RParenLoc)
Create a paren list.
Describes an C or C++ initializer list.
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
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 (&).
A convenient class for passing around template argument information.
static Expr * IgnoreCastsSingleStep(Expr *E)
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
static QualType getDecayedSourceLocExprType(const ASTContext &Ctx, SourceLocExpr::IdentKind Kind)
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.
SourceLocExpr(const ASTContext &Ctx, IdentKind Type, SourceLocation BLoc, SourceLocation RParenLoc, DeclContext *Context)
bool isBoundMemberFunction(ASTContext &Ctx) const
Returns true if this expression is a bound member function.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
StringKind
StringLiteral is followed by several trailing objects.
field_iterator field_begin() const
SourceLocation getCaretLocation() const
IdentKind getIdentKind() 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'.
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name, with source-location information.
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.
bool needsCleanup() const
Returns whether the object performed allocations.
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.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
Expression is a GNU-style __null constant.
bool isExplicitSpecialization() const
const Stmt * getBody() const
A binding in a decomposition declaration.
bool isUnevaluated(unsigned ID) const
Returns true if this builtin does not perform the side-effects of its arguments.
void MoveIntoResult(APValue &Value, const ASTContext &Context)
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)
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point...
bool isObjCSelfExpr() const
Check if this expression is the ObjC 'self' implicit parameter.
static MemberExpr * Create(const ASTContext &C, Expr *Base, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *MemberDecl, DeclAccessPair FoundDecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, QualType T, ExprValueKind VK, ExprObjectKind OK, NonOdrUseReason NOUR)
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>".
PredefinedExprBitfields PredefinedExprBits
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.
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.
bool EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsLValue - Evaluate an expression to see if we can fold it to an lvalue with link time known ...
StringRef getBuiltinStr() const
Return a string representing the name of the specific builtin function.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
InitListExpr * getUpdater() const
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
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...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumConcatenated)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function)...
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
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.
A non-discriminated union of a base, field, or array index.
static Expr * IgnoreExprNodesImpl(Expr *E)
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
static Expr * IgnoreImpCastsSingleStep(Expr *E)
SourceLocation getEndLoc() const LLVM_READONLY
const T * castAs() const
Member-template castAs<specific type>.
unsigned getLine() const
Return the presumed line number of this location.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
void setTypeDependent(bool TD)
Set whether this expression is type-dependent or not.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Represents a C++ destructor within a class.
bool isFieldDesignator() const
unsigned getNumInits() const
bool isNullPtrType() const
const Expr * skipRValueSubobjectAdjustments() const
field_iterator field_end() const
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
DeclContext * getDeclContext()
bool hasQualifier() const
Determine whether this declaration reference was preceded by a C++ nested-name-specifier, e.g., N::foo.
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).
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
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...
llvm::APSInt getResultAsAPSInt() const
void addDestruction(T *Ptr) const
If T isn't trivially destructible, calls AddDeallocation to register it for destruction.
StringLiteralBitfields StringLiteralBits
DeclContext * getParent()
getParent - Returns the containing DeclContext.
static PredefinedExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType FNTy, IdentKind IK, StringLiteral *SL)
Create a PredefinedExpr.
An expression that sends a message to the given Objective-C object or class.
Represents an unpacked "presumed" location which can be presented to the user.
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.
SourceLocation getBeginLoc() const LLVM_READONLY
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.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
ImplicitParamDecl * getSelfDecl() const
SourceRange getSourceRange() const
SourceLocation getEndLoc() const LLVM_READONLY
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.
APValue getAPValueResult() const
unsigned getWCharWidth() const
getWCharWidth/Align - Return the size of 'wchar_t' for this target, in bits.
RecordDecl * getDecl() const
const char * getFilename() const
Return the presumed filename of this location.
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Expr * IgnoreCasts() LLVM_READONLY
Skip past any casts which might surround this expression until reaching a fixed point.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Expr * IgnoreConversionOperator() LLVM_READONLY
Skip conversion operators.
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...
ParenListExprBitfields ParenListExprBits
static StringRef getIdentKindName(IdentKind IK)
This object has an indeterminate value (C++ [basic.indet]).
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...
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
unsigned getColumn() const
Return the presumed column number of this location.
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.
StringLiteral * getPredefinedStringLiteralFromCache(StringRef Key) const
Return a string representing the human readable name for the specified function declaration or file n...
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)
DeclarationName getName() const
getName - Returns the embedded declaration name.
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
Represents the declaration of a struct/union/class/enum.
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
llvm::iterator_range< capture_init_iterator > capture_inits()
Retrieve the initialization expressions for this lambda's captures.
static StringLiteral * CreateEmpty(const ASTContext &Ctx, unsigned NumConcatenated, unsigned Length, unsigned CharByteWidth)
Construct an empty string literal.
GenericSelectionExprBitfields GenericSelectionExprBits
static QualType getUnderlyingType(const SubRegion *R)
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
void FixedPointValueToString(SmallVectorImpl< char > &Str, llvm::APSInt Val, unsigned Scale)
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
static std::string ComputeName(IdentKind IK, const Decl *CurrentDecl)
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...
APValue EvaluateInContext(const ASTContext &Ctx, const Expr *DefaultExpr) const
Return the result of evaluating this SourceLocExpr in the specified (and possibly null) default argum...
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...
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.
static DesignatedInitExpr * CreateEmpty(const ASTContext &C, unsigned NumIndexExprs)
Used for C's _Alignof and C++'s alignof.
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.
MemberExprBitfields MemberExprBits
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...
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.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
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.
static GenericSelectionExpr * CreateEmpty(const ASTContext &Context, unsigned NumAssocs)
Create an empty generic selection expression for deserialization.
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
[C99 6.4.2.2] - A predefined identifier such as func.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static Expr * IgnoreParensSingleStep(Expr *E)
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.
static Expr * IgnoreBaseCastsSingleStep(Expr *E)
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Decl * getReferencedDeclOfCallee()
A field designator, e.g., ".x".
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
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo *> AssocTypes, ArrayRef< Expr *> AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression.
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
Return 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...
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.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
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
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * getArrayRangeEnd(const Designator &D) const
llvm::APInt getValue() const
unsigned getNumSubExprs() const
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
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point...
Not an overloaded operator.
bool isIncompleteArrayType() const
DeclarationNameInfo getNameInfo() 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.
QualType getStringLiteralArrayType(QualType EltTy, unsigned Length) const
Return a type for a constant array for a string literal of the specified element type and length...
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
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
Represents a call to a CUDA kernel function.
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, NonOdrUseReason NOUR=NOUR_None)
bool isFunctionType() const
static ImplicitCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize)
Expr * IgnoreParenLValueCasts() LLVM_READONLY
Skip past any parentheses and lvalue casts which might surround this expression until reaching a fixe...
Expr * getArg(unsigned Arg)
Return the specified argument.
static ConstantExpr * CreateEmpty(const ASTContext &Context, ResultStorageKind StorageKind, EmptyShell Empty)
NamedDecl * getConversionFunction() const
If this cast applies a user-defined conversion, retrieve the conversion function that it invokes...
SourceLocation getEnd() const
UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits
CharSourceRange getExpansionRange(SourceLocation Loc) const
Given a SourceLocation object, return the range of tokens covered by the expansion in the ultimate fi...
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
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.
SourceManager & getSourceManager()
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).
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
Expression is a Null pointer constant built from a literal zero.
ValueKind getKind() const
void Deallocate(void *Ptr) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
CallingConv getCallConv() const
Represents a C++ struct/union/class.
static MemberExpr * CreateEmpty(const ASTContext &Context, bool HasQualifier, bool HasFoundDecl, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
bool isSyntacticForm() const
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
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]).
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
There is no such object (it's outside its lifetime).
bool hasUnusedResultAttr(const ASTContext &Ctx) const
Returns true if this call expression should warn on unused results.
Builtin::Context & BuiltinInfo
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
static ParenListExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumExprs)
Create an empty paren list.
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
void SetResult(APValue Value, const ASTContext &Context)
void setPreArg(unsigned I, Stmt *PreArg)
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.
SourceLocExprBitfields SourceLocExprBits
void reserveInits(const ASTContext &C, unsigned NumInits)
Reserve space for some number of initializers.
static Decl::Kind getKind(const Decl *D)
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
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
Return the number of arguments to the constructor call.
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.
SourceLocation getEndLoc() const LLVM_READONLY
static int getAccessorIdx(char c, bool isNumericAccessor)
QualType getValueType() const
Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY
Skip past any parenthese and casts which do not change the value (including ptr->int casts of the sam...
static CallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, EmptyShell Empty)
Create an empty call expression, for deserialization.
double getValueAsApproximateDouble() const
getValueAsApproximateDouble - This returns the value as an inaccurate double.
static Expr * IgnoreExprNodes(Expr *E, FnTys &&... Fns)
Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *, Recursively apply each of the f...
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.
void removeAddressSpace()
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()...
Attr - This represents one attribute.
static Expr * IgnoreImplicitSingleStep(Expr *E)
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
Skip past any parentheses which might surround this expression until reaching a fixed point...
CanQualType UnsignedIntTy
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