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->getSubExpr();
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());
139 switch (UO->getOpcode()) {
141 return UO->getSubExpr()->isKnownToHaveBooleanValue(Semantic);
153 return CE->getSubExpr()->isKnownToHaveBooleanValue(Semantic);
156 switch (BO->getOpcode()) {
157 default:
return false;
172 return BO->getLHS()->isKnownToHaveBooleanValue(Semantic) &&
173 BO->getRHS()->isKnownToHaveBooleanValue(Semantic);
177 return BO->getRHS()->isKnownToHaveBooleanValue(Semantic);
182 return CO->getTrueExpr()->isKnownToHaveBooleanValue(Semantic) &&
183 CO->getFalseExpr()->isKnownToHaveBooleanValue(Semantic);
185 if (isa<ObjCBoolLiteralExpr>(E))
188 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(E))
189 return OVE->getSourceExpr()->isKnownToHaveBooleanValue(Semantic);
192 if (!Semantic && FD->getType()->isUnsignedIntegerType() &&
193 !FD->getBitWidth()->isValueDependent() &&
194 FD->getBitWidthValue(FD->getASTContext()) == 1)
207 template <
class E,
class T>
227 #define ABSTRACT_STMT(type) 228 #define STMT(type, base) \ 229 case Stmt::type##Class: break; 230 #define EXPR(type, base) \ 231 case Stmt::type##Class: return getExprLocImpl<type>(this, &type::getExprLoc); 232 #include "clang/AST/StmtNodes.inc" 234 llvm_unreachable(
"unknown expression kind");
244 "Invalid StorageKind Value");
254 if (!Value.
getInt().needsCleanup())
274 ::new (getTrailingObjects<APValue>())
APValue();
278 :
FullExpr(ConstantExprClass, subexpr) {
279 DefaultInit(StorageKind);
284 assert(!isa<ConstantExpr>(E));
286 unsigned Size = totalSizeToAlloc<APValue, uint64_t>(
303 :
FullExpr(ConstantExprClass, Empty) {
304 DefaultInit(StorageKind);
311 unsigned Size = totalSizeToAlloc<APValue, uint64_t>(
321 "Invalid storage for this value kind");
327 Int64Result() = *Value.
getInt().getRawData();
336 APValueResult() = std::move(Value);
339 llvm_unreachable(
"Invalid ResultKind Bits");
345 return APValueResult().getInt();
350 llvm_unreachable(
"invalid Accessor");
357 return APValueResult();
365 llvm_unreachable(
"invalid ResultKind");
373 bool &ValueDependent,
374 bool &InstantiationDependent) {
375 TypeDependent =
false;
376 ValueDependent =
false;
377 InstantiationDependent =
false;
390 TypeDependent =
true;
391 ValueDependent =
true;
392 InstantiationDependent =
true;
395 InstantiationDependent =
true;
403 TypeDependent =
true;
404 ValueDependent =
true;
405 InstantiationDependent =
true;
410 InstantiationDependent =
true;
414 if (isa<NonTypeTemplateParmDecl>(D)) {
415 ValueDependent =
true;
416 InstantiationDependent =
true;
427 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
429 Var->getType()->isLiteralType(Ctx) :
430 Var->getType()->isIntegralOrEnumerationType()) &&
431 (Var->getType().isConstQualified() ||
432 Var->getType()->isReferenceType())) {
433 if (
const Expr *Init = Var->getAnyInitializer())
434 if (Init->isValueDependent()) {
435 ValueDependent =
true;
436 InstantiationDependent =
true;
443 if (Var->isStaticDataMember() &&
444 Var->getDeclContext()->isDependentContext()) {
445 ValueDependent =
true;
446 InstantiationDependent =
true;
449 TypeDependent =
true;
459 ValueDependent =
true;
460 InstantiationDependent =
true;
464 void DeclRefExpr::computeDependence(
const ASTContext &Ctx) {
465 bool TypeDependent =
false;
466 bool ValueDependent =
false;
467 bool InstantiationDependent =
false;
469 ValueDependent, InstantiationDependent);
471 ExprBits.TypeDependent |= TypeDependent;
472 ExprBits.ValueDependent |= ValueDependent;
473 ExprBits.InstantiationDependent |= InstantiationDependent;
476 if (getDecl()->isParameterPack())
477 ExprBits.ContainsUnexpandedParameterPack =
true;
481 bool RefersToEnclosingVariableOrCapture,
QualType T,
486 D(D), DNLoc(LocInfo) {
492 RefersToEnclosingVariableOrCapture;
495 computeDependence(Ctx);
498 DeclRefExpr::DeclRefExpr(
const ASTContext &Ctx,
501 bool RefersToEnclosingVariableOrCapture,
505 :
Expr(DeclRefExprClass, T, VK,
OK_Ordinary,
false,
false,
false,
false),
506 D(D), DNLoc(NameInfo.
getInfo()) {
510 new (getTrailingObjects<NestedNameSpecifierLoc>())
513 if (NNS->isInstantiationDependent())
514 ExprBits.InstantiationDependent =
true;
515 if (NNS->containsUnexpandedParameterPack())
516 ExprBits.ContainsUnexpandedParameterPack =
true;
520 *getTrailingObjects<NamedDecl *>() = FoundD;
522 = (TemplateArgs || TemplateKWLoc.
isValid()) ? 1 : 0;
524 RefersToEnclosingVariableOrCapture;
527 bool Dependent =
false;
528 bool InstantiationDependent =
false;
529 bool ContainsUnexpandedParameterPack =
false;
530 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
531 TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
532 Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
533 assert(!Dependent &&
"built a DeclRefExpr with dependent template args");
534 ExprBits.InstantiationDependent |= InstantiationDependent;
535 ExprBits.ContainsUnexpandedParameterPack |= ContainsUnexpandedParameterPack;
536 }
else if (TemplateKWLoc.
isValid()) {
537 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
542 computeDependence(Ctx);
548 bool RefersToEnclosingVariableOrCapture,
553 return Create(Context, QualifierLoc, TemplateKWLoc, D,
554 RefersToEnclosingVariableOrCapture,
556 T, VK, FoundD, TemplateArgs, NOUR);
562 bool RefersToEnclosingVariableOrCapture,
572 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
576 QualifierLoc ? 1 : 0, FoundD ? 1 : 0,
577 HasTemplateKWAndArgsInfo ? 1 : 0,
578 TemplateArgs ? TemplateArgs->
size() : 0);
581 return new (Mem)
DeclRefExpr(Context, QualifierLoc, TemplateKWLoc, D,
582 RefersToEnclosingVariableOrCapture, NameInfo,
583 FoundD, TemplateArgs, T, VK, NOUR);
589 bool HasTemplateKWAndArgsInfo,
590 unsigned NumTemplateArgs) {
591 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
595 HasQualifier ? 1 : 0, HasFoundDecl ? 1 : 0, HasTemplateKWAndArgsInfo,
619 assert((getIdentKind() == IK) &&
620 "IdentKind do not fit in PredefinedExprBitfields!");
621 bool HasFunctionName = SL !=
nullptr;
628 PredefinedExpr::PredefinedExpr(
EmptyShell Empty,
bool HasFunctionName)
629 :
Expr(PredefinedExprClass, Empty) {
636 bool HasFunctionName = SL !=
nullptr;
637 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
643 bool HasFunctionName) {
644 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
654 return "__FUNCTION__";
656 return "__FUNCDNAME__";
658 return "L__FUNCTION__";
660 return "__PRETTY_FUNCTION__";
662 return "__FUNCSIG__";
664 return "L__FUNCSIG__";
665 case PrettyFunctionNoVirtual:
668 llvm_unreachable(
"Unknown ident kind for PredefinedExpr");
677 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(CurrentDecl)) {
678 std::unique_ptr<MangleContext> MC;
681 if (MC->shouldMangleDeclName(ND)) {
683 llvm::raw_svector_ostream Out(Buffer);
689 MC->mangleName(ND, Out);
691 if (!Buffer.empty() && Buffer.front() ==
'\01')
692 return Buffer.substr(1);
695 return ND->getIdentifier()->getName();
699 if (isa<BlockDecl>(CurrentDecl)) {
704 if (DC->isFileContext())
708 llvm::raw_svector_ostream Out(Buffer);
709 if (
auto *DCBlock = dyn_cast<BlockDecl>(DC))
711 Out << ComputeName(IK, DCBlock);
712 else if (
auto *DCDecl = dyn_cast<Decl>(DC))
713 Out << ComputeName(IK, DCDecl) <<
"_block_invoke";
716 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
717 if (IK != PrettyFunction && IK != PrettyFunctionNoVirtual &&
718 IK != FuncSig && IK != LFuncSig)
719 return FD->getNameAsString();
722 llvm::raw_svector_ostream Out(Name);
725 if (MD->isVirtual() && IK != PrettyFunctionNoVirtual)
733 llvm::raw_string_ostream POut(Proto);
740 if (FD->hasWrittenPrototype())
741 FT = dyn_cast<FunctionProtoType>(AFT);
743 if (IK == FuncSig || IK == LFuncSig) {
745 case CC_C: POut <<
"__cdecl ";
break;
756 FD->printQualifiedName(POut, Policy);
760 for (
unsigned i = 0, e = Decl->
getNumParams(); i != e; ++i) {
765 if (FT->isVariadic()) {
766 if (FD->getNumParams()) POut <<
", ";
768 }
else if ((IK == FuncSig || IK == LFuncSig ||
777 assert(FT &&
"We must have a written prototype in this case.");
780 if (FT->isVolatile())
792 while (Ctx && isa<NamedDecl>(Ctx)) {
796 Specs.push_back(Spec);
800 std::string TemplateParams;
801 llvm::raw_string_ostream TOut(TemplateParams);
802 for (SpecsTy::reverse_iterator I = Specs.rbegin(), E = Specs.rend();
805 = (*I)->getSpecializedTemplate()->getTemplateParameters();
807 assert(Params->
size() == Args.
size());
808 for (
unsigned i = 0, numParams = Params->
size(); i != numParams; ++i) {
810 if (Param.empty())
continue;
811 TOut << Param <<
" = ";
818 = FD->getTemplateSpecializationInfo();
823 assert(Params->
size() == Args->
size());
824 for (
unsigned i = 0, e = Params->
size(); i != e; ++i) {
826 if (Param.empty())
continue;
827 TOut << Param <<
" = ";
834 if (!TemplateParams.empty()) {
836 TemplateParams.resize(TemplateParams.size() - 2);
837 POut <<
" [" << TemplateParams <<
"]";
846 if (isa<CXXMethodDecl>(FD) &&
847 cast<CXXMethodDecl>(FD)->getParent()->isLambda())
848 Proto =
"auto " + Proto;
849 else if (FT && FT->getReturnType()->getAs<
DecltypeType>())
854 else if (!isa<CXXConstructorDecl>(FD) && !isa<CXXDestructorDecl>(FD))
859 return Name.str().str();
861 if (
const CapturedDecl *CD = dyn_cast<CapturedDecl>(CurrentDecl)) {
865 if (DC->isFunctionOrMethod() && (DC->getDeclKind() != Decl::Captured)) {
867 return ComputeName(IK, D);
869 llvm_unreachable(
"CapturedDecl not inside a function or method");
871 if (
const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(CurrentDecl)) {
873 llvm::raw_svector_ostream Out(Name);
874 Out << (MD->isInstanceMethod() ?
'-' :
'+');
883 dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext()))
884 Out <<
'(' << *CID <<
')';
887 MD->getSelector().print(Out);
890 return Name.str().str();
892 if (isa<TranslationUnitDecl>(CurrentDecl) && IK == PrettyFunction) {
904 BitWidth = Val.getBitWidth();
905 unsigned NumWords = Val.getNumWords();
906 const uint64_t* Words = Val.getRawData();
908 pVal =
new (
C) uint64_t[NumWords];
909 std::copy(Words, Words + NumWords, pVal);
910 }
else if (NumWords == 1)
921 assert(type->
isIntegerType() &&
"Illegal type in IntegerLiteral");
923 "Integer type is not the correct size for constant.");
943 Loc(l), Scale(Scale) {
946 "Fixed point type is not the correct size for constant.");
964 S, llvm::APSInt::getUnsigned(
getValue().getZExtValue()), Scale);
968 FloatingLiteral::FloatingLiteral(
const ASTContext &
C,
const llvm::APFloat &
V,
971 false,
false), Loc(L) {
972 setSemantics(
V.getSemantics());
978 :
Expr(FloatingLiteralClass, Empty) {
979 setRawSemantics(llvm::APFloatBase::S_IEEEhalf);
1000 V.convert(llvm::APFloat::IEEEdouble(), llvm::APFloat::rmNearestTiesToEven,
1002 return V.convertToDouble();
1007 unsigned CharByteWidth = 0;
1023 assert((CharByteWidth & 7) == 0 &&
"Assumes character size is byte multiple");
1025 assert((CharByteWidth == 1 || CharByteWidth == 2 || CharByteWidth == 4) &&
1026 "The only supported character byte widths are 1,2 and 4!");
1027 return CharByteWidth;
1030 StringLiteral::StringLiteral(
const ASTContext &Ctx, StringRef Str,
1033 unsigned NumConcatenated)
1037 "StringLiteral must be of constant array type!");
1039 unsigned ByteLength = Str.size();
1040 assert((ByteLength % CharByteWidth == 0) &&
1041 "The size of the data must be a multiple of CharByteWidth!");
1047 switch (CharByteWidth) {
1049 Length = ByteLength;
1052 Length = ByteLength / 2;
1055 Length = ByteLength / 4;
1058 llvm_unreachable(
"Unsupported character width!");
1065 *getTrailingObjects<unsigned>() = Length;
1069 std::memcpy(getTrailingObjects<SourceLocation>(), Loc,
1073 std::memcpy(getTrailingObjects<char>(), Str.data(), ByteLength);
1076 StringLiteral::StringLiteral(
EmptyShell Empty,
unsigned NumConcatenated,
1077 unsigned Length,
unsigned CharByteWidth)
1078 :
Expr(StringLiteralClass, Empty) {
1081 *getTrailingObjects<unsigned>() = Length;
1087 unsigned NumConcatenated) {
1088 void *Mem = Ctx.
Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
1089 1, NumConcatenated, Str.size()),
1092 StringLiteral(Ctx, Str, Kind, Pascal, Ty, Loc, NumConcatenated);
1096 unsigned NumConcatenated,
1098 unsigned CharByteWidth) {
1099 void *Mem = Ctx.
Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
1100 1, NumConcatenated, Length * CharByteWidth),
1109 case Wide: OS <<
'L';
break;
1110 case UTF8: OS <<
"u8";
break;
1111 case UTF16: OS <<
'u';
break;
1112 case UTF32: OS <<
'U';
break;
1115 static const char Hex[] =
"0123456789ABCDEF";
1117 unsigned LastSlashX = getLength();
1118 for (
unsigned I = 0, N = getLength(); I != N; ++I) {
1119 switch (uint32_t Char = getCodeUnit(I)) {
1125 if (
getKind() == UTF16 && I != N - 1 && Char >= 0xd800 &&
1127 uint32_t Trail = getCodeUnit(I + 1);
1128 if (Trail >= 0xdc00 && Trail <= 0xdfff) {
1129 Char = 0x10000 + ((Char - 0xd800) << 10) + (Trail - 0xdc00);
1139 (Char >= 0xd800 && Char <= 0xdfff) || Char >= 0x110000) {
1143 while ((Char >> Shift) == 0)
1145 for (; Shift >= 0; Shift -= 4)
1146 OS << Hex[(Char >> Shift) & 15];
1153 << Hex[(Char >> 20) & 15]
1154 << Hex[(Char >> 16) & 15];
1157 OS << Hex[(Char >> 12) & 15]
1158 << Hex[(Char >> 8) & 15]
1159 << Hex[(Char >> 4) & 15]
1160 << Hex[(Char >> 0) & 15];
1166 if (LastSlashX + 1 == I) {
1168 case '0':
case '1':
case '2':
case '3':
case '4':
1169 case '5':
case '6':
case '7':
case '8':
case '9':
1170 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
1171 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
1176 assert(Char <= 0xff &&
1177 "Characters above 0xff should already have been handled.");
1183 << (char)(
'0' + ((Char >> 6) & 7))
1184 << (char)(
'0' + ((Char >> 3) & 7))
1185 << (char)(
'0' + ((Char >> 0) & 7));
1188 case '\\': OS <<
"\\\\";
break;
1189 case '"': OS <<
"\\\"";
break;
1190 case '\a': OS <<
"\\a";
break;
1191 case '\b': OS <<
"\\b";
break;
1192 case '\f': OS <<
"\\f";
break;
1193 case '\n': OS <<
"\\n";
break;
1194 case '\r': OS <<
"\\r";
break;
1195 case '\t': OS <<
"\\t";
break;
1196 case '\v': OS <<
"\\v";
break;
1221 const TargetInfo &Target,
unsigned *StartToken,
1222 unsigned *StartTokenByteOffset)
const {
1225 "Only narrow string literals are currently supported");
1230 unsigned StringOffset = 0;
1232 TokNo = *StartToken;
1233 if (StartTokenByteOffset) {
1234 StringOffset = *StartTokenByteOffset;
1235 ByteNo -= StringOffset;
1238 assert(TokNo < getNumConcatenated() &&
"Invalid byte number!");
1247 std::pair<FileID, unsigned> LocInfo =
1249 bool Invalid =
false;
1250 StringRef Buffer = SM.
getBufferData(LocInfo.first, &Invalid);
1252 if (StartTokenByteOffset !=
nullptr)
1253 *StartTokenByteOffset = StringOffset;
1254 if (StartToken !=
nullptr)
1255 *StartToken = TokNo;
1256 return StrTokSpellingLoc;
1259 const char *StrData = Buffer.data()+LocInfo.second;
1263 Buffer.begin(), StrData, Buffer.end());
1265 TheLexer.LexFromRawLexer(TheTok);
1272 if (ByteNo < TokNumBytes ||
1273 (ByteNo == TokNumBytes && TokNo == getNumConcatenated() - 1)) {
1278 if (StartTokenByteOffset !=
nullptr)
1279 *StartTokenByteOffset = StringOffset;
1280 if (StartToken !=
nullptr)
1281 *StartToken = TokNo;
1286 StringOffset += TokNumBytes;
1288 ByteNo -= TokNumBytes;
1296 #define UNARY_OPERATION(Name, Spelling) case UO_##Name: return Spelling; 1297 #include "clang/AST/OperationKinds.def" 1299 llvm_unreachable(
"Unknown unary operator");
1305 default: llvm_unreachable(
"No unary operator for overloaded function");
1306 case OO_PlusPlus:
return Postfix ? UO_PostInc : UO_PreInc;
1307 case OO_MinusMinus:
return Postfix ? UO_PostDec : UO_PreDec;
1308 case OO_Amp:
return UO_AddrOf;
1309 case OO_Star:
return UO_Deref;
1310 case OO_Plus:
return UO_Plus;
1311 case OO_Minus:
return UO_Minus;
1312 case OO_Tilde:
return UO_Not;
1313 case OO_Exclaim:
return UO_LNot;
1314 case OO_Coawait:
return UO_Coawait;
1320 case UO_PostInc:
case UO_PreInc:
return OO_PlusPlus;
1321 case UO_PostDec:
case UO_PreDec:
return OO_MinusMinus;
1322 case UO_AddrOf:
return OO_Amp;
1323 case UO_Deref:
return OO_Star;
1324 case UO_Plus:
return OO_Plus;
1325 case UO_Minus:
return OO_Minus;
1326 case UO_Not:
return OO_Tilde;
1327 case UO_LNot:
return OO_Exclaim;
1328 case UO_Coawait:
return OO_Coawait;
1345 RParenLoc(RParenLoc) {
1346 NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1347 unsigned NumPreArgs = PreArgs.size();
1349 assert((NumPreArgs ==
getNumPreArgs()) &&
"NumPreArgs overflow!");
1351 unsigned OffsetToTrailingObjects = offsetToTrailingObjects(SC);
1352 CallExprBits.OffsetToTrailingObjects = OffsetToTrailingObjects;
1353 assert((
CallExprBits.OffsetToTrailingObjects == OffsetToTrailingObjects) &&
1354 "OffsetToTrailingObjects overflow!");
1359 for (
unsigned I = 0; I != NumPreArgs; ++I) {
1360 updateDependenciesFromArg(PreArgs[I]);
1363 for (
unsigned I = 0; I != Args.size(); ++I) {
1364 updateDependenciesFromArg(Args[I]);
1367 for (
unsigned I = Args.size(); I != NumArgs; ++I) {
1374 :
Expr(SC, Empty), NumArgs(NumArgs) {
1376 assert((NumPreArgs ==
getNumPreArgs()) &&
"NumPreArgs overflow!");
1378 unsigned OffsetToTrailingObjects = offsetToTrailingObjects(SC);
1379 CallExprBits.OffsetToTrailingObjects = OffsetToTrailingObjects;
1380 assert((
CallExprBits.OffsetToTrailingObjects == OffsetToTrailingObjects) &&
1381 "OffsetToTrailingObjects overflow!");
1388 unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1389 unsigned SizeOfTrailingObjects =
1393 return new (Mem)
CallExpr(CallExprClass, Fn, {}, Args, Ty, VK,
1394 RParenLoc, MinNumArgs,
UsesADL);
1400 assert(!(reinterpret_cast<uintptr_t>(Mem) %
alignof(
CallExpr)) &&
1401 "Misaligned memory in CallExpr::CreateTemporary!");
1402 return new (Mem)
CallExpr(CallExprClass, Fn, {}, {}, Ty,
1408 unsigned SizeOfTrailingObjects =
1412 return new (Mem)
CallExpr(CallExprClass, 0, NumArgs, Empty);
1415 unsigned CallExpr::offsetToTrailingObjects(
StmtClass SC) {
1419 case CXXOperatorCallExprClass:
1421 case CXXMemberCallExprClass:
1423 case UserDefinedLiteralClass:
1425 case CUDAKernelCallExprClass:
1428 llvm_unreachable(
"unexpected class deriving from CallExpr!");
1432 void CallExpr::updateDependenciesFromArg(
Expr *Arg) {
1438 ExprBits.InstantiationDependent =
true;
1440 ExprBits.ContainsUnexpandedParameterPack =
true;
1447 = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE)) {
1453 if (BO->isPtrMemOp())
1455 }
else if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(CEE)) {
1456 if (UO->getOpcode() == UO_Deref)
1459 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE))
1460 return DRE->getDecl();
1461 if (
MemberExpr *ME = dyn_cast<MemberExpr>(CEE))
1462 return ME->getMemberDecl();
1463 if (
auto *BE = dyn_cast<BlockExpr>(CEE))
1464 return BE->getBlockDecl();
1507 if (isa<CXXPseudoDestructorExpr>(Callee->
IgnoreParens()))
1522 if (
const auto *A = TD->getAttr<WarnUnusedResultAttr>())
1528 return D ? D->
getAttr<WarnUnusedResultAttr>() :
nullptr;
1532 if (isa<CXXOperatorCallExpr>(
this))
1533 return cast<CXXOperatorCallExpr>(
this)->
getBeginLoc();
1541 if (isa<CXXOperatorCallExpr>(
this))
1542 return cast<CXXOperatorCallExpr>(
this)->
getEndLoc();
1557 totalSizeToAlloc<OffsetOfNode, Expr *>(comps.size(), exprs.size()));
1559 return new (Mem)
OffsetOfExpr(C, type, OperatorLoc, tsi, comps, exprs,
1564 unsigned numComps,
unsigned numExprs) {
1566 C.
Allocate(totalSizeToAlloc<OffsetOfNode, Expr *>(numComps, numExprs));
1579 OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
1580 NumComps(comps.size()), NumExprs(exprs.size())
1582 for (
unsigned i = 0; i != comps.size(); ++i) {
1583 setComponent(i, comps[i]);
1586 for (
unsigned i = 0; i != exprs.size(); ++i) {
1590 ExprBits.ContainsUnexpandedParameterPack =
true;
1592 setIndexExpr(i, exprs[i]);
1599 return getField()->getIdentifier();
1612 OpLoc(op), RParenLoc(rp) {
1624 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
1626 else if (
const auto *ME = dyn_cast<MemberExpr>(E))
1627 D = ME->getMemberDecl();
1631 if (I->isAlignmentDependent()) {
1650 Base(Base), MemberDecl(MemberDecl), MemberDNLoc(NameInfo.
getInfo()),
1651 MemberLoc(NameInfo.
getLoc()) {
1668 bool HasQualOrFound = QualifierLoc || FoundDecl.
getDecl() != MemberDecl ||
1670 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
1674 HasQualOrFound ? 1 : 0, HasTemplateKWAndArgsInfo ? 1 : 0,
1675 TemplateArgs ? TemplateArgs->
size() : 0);
1679 NameInfo, T, VK, OK, NOUR);
1681 if (isa<FieldDecl>(MemberDecl)) {
1695 if (HasQualOrFound) {
1702 else if (QualifierLoc &&
1708 MemberExprNameQualifier *NQ =
1709 E->getTrailingObjects<MemberExprNameQualifier>();
1715 TemplateArgs || TemplateKWLoc.
isValid();
1718 bool Dependent =
false;
1719 bool InstantiationDependent =
false;
1720 bool ContainsUnexpandedParameterPack =
false;
1721 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1722 TemplateKWLoc, *TemplateArgs,
1724 InstantiationDependent, ContainsUnexpandedParameterPack);
1725 if (InstantiationDependent)
1727 }
else if (TemplateKWLoc.
isValid()) {
1728 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1736 bool HasQualifier,
bool HasFoundDecl,
1737 bool HasTemplateKWAndArgsInfo,
1738 unsigned NumTemplateArgs) {
1739 assert((!NumTemplateArgs || HasTemplateKWAndArgsInfo) &&
1740 "template args but no template arg info?");
1741 bool HasQualOrFound = HasQualifier || HasFoundDecl;
1745 HasTemplateKWAndArgsInfo ? 1 : 0,
1752 if (isImplicitAccess()) {
1754 return getQualifierLoc().getBeginLoc();
1762 return BaseStartLoc;
1767 if (hasExplicitTemplateArgs())
1768 EndLoc = getRAngleLoc();
1770 EndLoc = getBase()->getEndLoc();
1774 bool CastExpr::CastConsistency()
const {
1775 switch (getCastKind()) {
1776 case CK_DerivedToBase:
1777 case CK_UncheckedDerivedToBase:
1778 case CK_DerivedToBaseMemberPointer:
1779 case CK_BaseToDerived:
1780 case CK_BaseToDerivedMemberPointer:
1781 assert(!path_empty() &&
"Cast kind should have a base path!");
1784 case CK_CPointerToObjCPointerCast:
1785 assert(
getType()->isObjCObjectPointerType());
1786 assert(getSubExpr()->
getType()->isPointerType());
1787 goto CheckNoBasePath;
1789 case CK_BlockPointerToObjCPointerCast:
1790 assert(
getType()->isObjCObjectPointerType());
1791 assert(getSubExpr()->
getType()->isBlockPointerType());
1792 goto CheckNoBasePath;
1794 case CK_ReinterpretMemberPointer:
1795 assert(
getType()->isMemberPointerType());
1796 assert(getSubExpr()->
getType()->isMemberPointerType());
1797 goto CheckNoBasePath;
1803 if (!
getType()->isPointerType()) {
1804 assert(
getType()->isObjCObjectPointerType() ==
1805 getSubExpr()->
getType()->isObjCObjectPointerType());
1806 assert(
getType()->isBlockPointerType() ==
1807 getSubExpr()->
getType()->isBlockPointerType());
1809 goto CheckNoBasePath;
1811 case CK_AnyPointerToBlockPointerCast:
1812 assert(
getType()->isBlockPointerType());
1813 assert(getSubExpr()->
getType()->isAnyPointerType() &&
1814 !getSubExpr()->
getType()->isBlockPointerType());
1815 goto CheckNoBasePath;
1817 case CK_CopyAndAutoreleaseBlockObject:
1818 assert(
getType()->isBlockPointerType());
1819 assert(getSubExpr()->
getType()->isBlockPointerType());
1820 goto CheckNoBasePath;
1822 case CK_FunctionToPointerDecay:
1823 assert(
getType()->isPointerType());
1824 assert(getSubExpr()->
getType()->isFunctionType());
1825 goto CheckNoBasePath;
1827 case CK_AddressSpaceConversion: {
1829 auto SETy = getSubExpr()->getType();
1835 assert(!Ty.
isNull() && !SETy.isNull() &&
1837 goto CheckNoBasePath;
1842 case CK_ArrayToPointerDecay:
1843 case CK_NullToMemberPointer:
1844 case CK_NullToPointer:
1845 case CK_ConstructorConversion:
1846 case CK_IntegralToPointer:
1847 case CK_PointerToIntegral:
1849 case CK_VectorSplat:
1850 case CK_IntegralCast:
1851 case CK_BooleanToSignedIntegral:
1852 case CK_IntegralToFloating:
1853 case CK_FloatingToIntegral:
1854 case CK_FloatingCast:
1855 case CK_ObjCObjectLValueCast:
1856 case CK_FloatingRealToComplex:
1857 case CK_FloatingComplexToReal:
1858 case CK_FloatingComplexCast:
1859 case CK_FloatingComplexToIntegralComplex:
1860 case CK_IntegralRealToComplex:
1861 case CK_IntegralComplexToReal:
1862 case CK_IntegralComplexCast:
1863 case CK_IntegralComplexToFloatingComplex:
1864 case CK_ARCProduceObject:
1865 case CK_ARCConsumeObject:
1866 case CK_ARCReclaimReturnedObject:
1867 case CK_ARCExtendBlockObject:
1868 case CK_ZeroToOCLOpaqueType:
1869 case CK_IntToOCLSampler:
1870 case CK_FixedPointCast:
1871 case CK_FixedPointToIntegral:
1872 case CK_IntegralToFixedPoint:
1874 goto CheckNoBasePath;
1877 case CK_LValueToRValue:
1879 case CK_AtomicToNonAtomic:
1880 case CK_NonAtomicToAtomic:
1881 case CK_PointerToBoolean:
1882 case CK_IntegralToBoolean:
1883 case CK_FloatingToBoolean:
1884 case CK_MemberPointerToBoolean:
1885 case CK_FloatingComplexToBoolean:
1886 case CK_IntegralComplexToBoolean:
1887 case CK_LValueBitCast:
1888 case CK_LValueToRValueBitCast:
1889 case CK_UserDefinedConversion:
1890 case CK_BuiltinFnToFnPtr:
1891 case CK_FixedPointToBoolean:
1893 assert(path_empty() &&
"Cast kind should not have a base path!");
1901 #define CAST_OPERATION(Name) case CK_##Name: return #Name; 1902 #include "clang/AST/OperationKinds.def" 1904 llvm_unreachable(
"Unhandled cast kind!");
1908 const Expr *skipImplicitTemporary(
const Expr *E) {
1910 if (
auto *Materialize = dyn_cast<MaterializeTemporaryExpr>(E))
1911 E = Materialize->getSubExpr();
1914 if (
auto *Binder = dyn_cast<CXXBindTemporaryExpr>(E))
1915 E = Binder->getSubExpr();
1922 const Expr *SubExpr =
nullptr;
1925 SubExpr = skipImplicitTemporary(E->
getSubExpr());
1931 skipImplicitTemporary(cast<CXXConstructExpr>(SubExpr)->getArg(0));
1932 else if (E->
getCastKind() == CK_UserDefinedConversion) {
1933 assert((isa<CXXMemberCallExpr>(SubExpr) ||
1934 isa<BlockExpr>(SubExpr)) &&
1935 "Unexpected SubExpr for CK_UserDefinedConversion.");
1936 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
1937 SubExpr = MCE->getImplicitObjectArgument();
1942 }
while ((E = dyn_cast<ImplicitCastExpr>(SubExpr)));
1944 return const_cast<Expr*
>(SubExpr);
1948 const Expr *SubExpr =
nullptr;
1951 SubExpr = skipImplicitTemporary(E->getSubExpr());
1953 if (E->getCastKind() == CK_ConstructorConversion)
1954 return cast<CXXConstructExpr>(SubExpr)->getConstructor();
1956 if (E->getCastKind() == CK_UserDefinedConversion) {
1957 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
1958 return MCE->getMethodDecl();
1967 #define ABSTRACT_STMT(x) 1968 #define CASTEXPR(Type, Base) \ 1969 case Stmt::Type##Class: \ 1970 return static_cast<Type *>(this)->getTrailingObjects<CXXBaseSpecifier *>(); 1971 #define STMT(Type, Base) 1972 #include "clang/AST/StmtNodes.inc" 1974 llvm_unreachable(
"non-cast expressions not possible here");
1981 return getTargetFieldForToUnionCast(RD, opType);
1989 Field != FieldEnd; ++Field) {
1991 !Field->isUnnamedBitfield()) {
2002 unsigned PathSize = (BasePath ? BasePath->size() : 0);
2003 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
2006 assert((Kind != CK_LValueToRValue ||
2008 "invalid type for lvalue-to-rvalue conversion");
2012 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
2018 unsigned PathSize) {
2019 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
2029 unsigned PathSize = (BasePath ? BasePath->size() : 0);
2030 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
2032 new (Buffer)
CStyleCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, R);
2034 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
2040 unsigned PathSize) {
2041 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
2049 #define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling; 2050 #include "clang/AST/OperationKinds.def" 2052 llvm_unreachable(
"Invalid OpCode!");
2058 default: llvm_unreachable(
"Not an overloadable binary operator");
2059 case OO_Plus:
return BO_Add;
2060 case OO_Minus:
return BO_Sub;
2061 case OO_Star:
return BO_Mul;
2062 case OO_Slash:
return BO_Div;
2063 case OO_Percent:
return BO_Rem;
2064 case OO_Caret:
return BO_Xor;
2065 case OO_Amp:
return BO_And;
2066 case OO_Pipe:
return BO_Or;
2067 case OO_Equal:
return BO_Assign;
2068 case OO_Spaceship:
return BO_Cmp;
2069 case OO_Less:
return BO_LT;
2070 case OO_Greater:
return BO_GT;
2071 case OO_PlusEqual:
return BO_AddAssign;
2072 case OO_MinusEqual:
return BO_SubAssign;
2073 case OO_StarEqual:
return BO_MulAssign;
2074 case OO_SlashEqual:
return BO_DivAssign;
2075 case OO_PercentEqual:
return BO_RemAssign;
2076 case OO_CaretEqual:
return BO_XorAssign;
2077 case OO_AmpEqual:
return BO_AndAssign;
2078 case OO_PipeEqual:
return BO_OrAssign;
2079 case OO_LessLess:
return BO_Shl;
2080 case OO_GreaterGreater:
return BO_Shr;
2081 case OO_LessLessEqual:
return BO_ShlAssign;
2082 case OO_GreaterGreaterEqual:
return BO_ShrAssign;
2083 case OO_EqualEqual:
return BO_EQ;
2084 case OO_ExclaimEqual:
return BO_NE;
2085 case OO_LessEqual:
return BO_LE;
2086 case OO_GreaterEqual:
return BO_GE;
2087 case OO_AmpAmp:
return BO_LAnd;
2088 case OO_PipePipe:
return BO_LOr;
2089 case OO_Comma:
return BO_Comma;
2090 case OO_ArrowStar:
return BO_PtrMemI;
2097 OO_Star, OO_Slash, OO_Percent,
2099 OO_LessLess, OO_GreaterGreater,
2101 OO_Less, OO_Greater, OO_LessEqual, OO_GreaterEqual,
2102 OO_EqualEqual, OO_ExclaimEqual,
2108 OO_Equal, OO_StarEqual,
2109 OO_SlashEqual, OO_PercentEqual,
2110 OO_PlusEqual, OO_MinusEqual,
2111 OO_LessLessEqual, OO_GreaterGreaterEqual,
2112 OO_AmpEqual, OO_CaretEqual,
2116 return OverOps[Opc];
2164 llvm_unreachable(
"unhandled case");
2172 BuiltinLoc(BLoc), RParenLoc(RParenLoc), ParentContext(ParentContext) {
2179 return "__builtin_FILE";
2181 return "__builtin_FUNCTION";
2183 return "__builtin_LINE";
2185 return "__builtin_COLUMN";
2187 llvm_unreachable(
"unexpected IdentKind!");
2191 const Expr *DefaultExpr)
const {
2196 Context) = [&]() -> std::pair<SourceLocation, const DeclContext *> {
2197 if (
auto *DIE = dyn_cast_or_null<CXXDefaultInitExpr>(DefaultExpr))
2198 return {DIE->getUsedLocation(), DIE->getUsedContext()};
2199 if (
auto *DAE = dyn_cast_or_null<CXXDefaultArgExpr>(DefaultExpr))
2200 return {DAE->getUsedLocation(), DAE->getUsedContext()};
2207 auto MakeStringLiteral = [&](StringRef Tmp) {
2211 LValuePathEntry Path[1] = {LValuePathEntry::ArrayIndex(0)};
2219 const Decl *CurDecl = dyn_cast_or_null<Decl>(Context);
2220 return MakeStringLiteral(
2233 llvm_unreachable(
"unhandled case");
2240 InitExprs(C, initExprs.size()),
2241 LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(nullptr,
true)
2244 for (
unsigned I = 0; I != initExprs.size(); ++I) {
2250 ExprBits.InstantiationDependent =
true;
2252 ExprBits.ContainsUnexpandedParameterPack =
true;
2255 InitExprs.
insert(C, InitExprs.
end(), initExprs.begin(), initExprs.end());
2259 if (NumInits > InitExprs.
size())
2260 InitExprs.
reserve(C, NumInits);
2264 InitExprs.
resize(C, NumInits,
nullptr);
2268 if (Init >= InitExprs.
size()) {
2269 InitExprs.
insert(C, InitExprs.
end(), Init - InitExprs.
size() + 1,
nullptr);
2274 Expr *
Result = cast_or_null<Expr>(InitExprs[Init]);
2281 ArrayFillerOrUnionFieldInit = filler;
2284 for (
unsigned i = 0, e =
getNumInits(); i != e; ++i)
2285 if (inits[i] ==
nullptr)
2300 return isa<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init);
2304 assert(
isSemanticForm() &&
"syntactic form never semantically transparent");
2308 assert(
getNumInits() == 1 &&
"multiple inits in glvalue init list");
2327 assert(
isSyntacticForm() &&
"only test syntactic form as zero initializer");
2334 return Lit && Lit->
getValue() == 0;
2339 return SyntacticForm->getBeginLoc();
2344 E = InitExprs.
end();
2347 Beg = S->getBeginLoc();
2357 return SyntacticForm->getEndLoc();
2362 E = InitExprs.
rend();
2365 End = S->getEndLoc();
2377 return cast<BlockPointerType>(
getType())
2382 return TheBlock->getCaretLocation();
2385 return TheBlock->getBody();
2388 return TheBlock->getBody();
2416 case ParenExprClass:
2417 return cast<ParenExpr>(
this)->getSubExpr()->
2419 case GenericSelectionExprClass:
2420 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
2422 case CoawaitExprClass:
2423 case CoyieldExprClass:
2424 return cast<CoroutineSuspendExpr>(
this)->getResumeExpr()->
2426 case ChooseExprClass:
2427 return cast<ChooseExpr>(
this)->getChosenSubExpr()->
2429 case UnaryOperatorClass: {
2452 .isVolatileQualified())
2463 case BinaryOperatorClass: {
2475 if (IE->getValue() == 0)
2494 case CompoundAssignOperatorClass:
2495 case VAArgExprClass:
2496 case AtomicExprClass:
2499 case ConditionalOperatorClass: {
2503 const auto *Exp = cast<ConditionalOperator>(
this);
2504 return Exp->getLHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx) &&
2505 Exp->getRHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2507 case BinaryConditionalOperatorClass: {
2508 const auto *Exp = cast<BinaryConditionalOperator>(
this);
2509 return Exp->getFalseExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2512 case MemberExprClass:
2514 Loc = cast<MemberExpr>(
this)->getMemberLoc();
2516 R2 = cast<MemberExpr>(
this)->getBase()->getSourceRange();
2519 case ArraySubscriptExprClass:
2521 Loc = cast<ArraySubscriptExpr>(
this)->getRBracketLoc();
2522 R1 = cast<ArraySubscriptExpr>(
this)->getLHS()->getSourceRange();
2523 R2 = cast<ArraySubscriptExpr>(
this)->getRHS()->getSourceRange();
2526 case CXXOperatorCallExprClass: {
2538 case OO_ExclaimEqual:
2541 case OO_GreaterEqual:
2556 case CXXMemberCallExprClass:
2557 case UserDefinedLiteralClass: {
2559 const CallExpr *CE = cast<CallExpr>(
this);
2567 FD->hasAttr<PureAttr>() || FD->hasAttr<ConstAttr>()) {
2582 case UnresolvedLookupExprClass:
2583 case CXXUnresolvedConstructExprClass:
2586 case CXXTemporaryObjectExprClass:
2587 case CXXConstructExprClass: {
2589 const auto *WarnURAttr = Type->getAttr<WarnUnusedResultAttr>();
2590 if (Type->
hasAttr<WarnUnusedAttr>() ||
2591 (WarnURAttr && WarnURAttr->IsCXX11NoDiscard())) {
2599 const auto *CE = cast<CXXConstructExpr>(
this);
2601 const auto *WarnURAttr = Ctor->getAttr<WarnUnusedResultAttr>();
2602 if (WarnURAttr && WarnURAttr->IsCXX11NoDiscard()) {
2607 if (
unsigned NumArgs = CE->getNumArgs())
2609 CE->getArg(NumArgs - 1)->getEndLoc());
2617 case ObjCMessageExprClass: {
2630 if (MD->hasAttr<WarnUnusedResultAttr>()) {
2639 case ObjCPropertyRefExprClass:
2645 case PseudoObjectExprClass: {
2659 case StmtExprClass: {
2665 const CompoundStmt *CS = cast<StmtExpr>(
this)->getSubStmt();
2668 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2670 if (
const Expr *E = dyn_cast<Expr>(
Label->getSubStmt()))
2671 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2677 Loc = cast<StmtExpr>(
this)->getLParenLoc();
2681 case CXXFunctionalCastExprClass:
2682 case CStyleCastExprClass: {
2685 const CastExpr *CE = cast<CastExpr>(
this);
2691 if (!(DRE && isa<VarDecl>(DRE->
getDecl()) &&
2692 cast<VarDecl>(DRE->
getDecl())->hasLocalStorage()) &&
2703 if (CE->
getCastKind() == CK_ConstructorConversion)
2708 dyn_cast<CXXFunctionalCastExpr>(
this)) {
2709 Loc = CXXCE->getBeginLoc();
2710 R1 = CXXCE->getSubExpr()->getSourceRange();
2718 case ImplicitCastExprClass: {
2719 const CastExpr *ICE = cast<ImplicitCastExpr>(
this);
2728 case CXXDefaultArgExprClass:
2729 return (cast<CXXDefaultArgExpr>(
this)
2731 case CXXDefaultInitExprClass:
2732 return (cast<CXXDefaultInitExpr>(
this)
2735 case CXXNewExprClass:
2738 case CXXDeleteExprClass:
2740 case MaterializeTemporaryExprClass:
2741 return cast<MaterializeTemporaryExpr>(
this)
2743 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2744 case CXXBindTemporaryExprClass:
2745 return cast<CXXBindTemporaryExpr>(
this)->getSubExpr()
2746 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2747 case ExprWithCleanupsClass:
2748 return cast<ExprWithCleanups>(
this)->getSubExpr()
2749 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2760 case ObjCIvarRefExprClass:
2762 case Expr::UnaryOperatorClass:
2763 return cast<UnaryOperator>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2764 case ImplicitCastExprClass:
2765 return cast<ImplicitCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2766 case MaterializeTemporaryExprClass:
2767 return cast<MaterializeTemporaryExpr>(E)->getSubExpr()->isOBJCGCCandidate(
2769 case CStyleCastExprClass:
2770 return cast<CStyleCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2771 case DeclRefExprClass: {
2772 const Decl *D = cast<DeclRefExpr>(E)->getDecl();
2774 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2775 if (VD->hasGlobalStorage())
2785 case MemberExprClass: {
2789 case ArraySubscriptExprClass:
2790 return cast<ArraySubscriptExpr>(E)->getBase()->isOBJCGCCandidate(Ctx);
2808 if (
const MemberExpr *mem = dyn_cast<MemberExpr>(expr)) {
2809 assert(isa<CXXMethodDecl>(mem->getMemberDecl()));
2810 return mem->getMemberDecl()->getType();
2820 assert(isa<UnresolvedMemberExpr>(expr) || isa<CXXPseudoDestructorExpr>(expr));
2825 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
2826 return ICE->getSubExpr();
2828 if (
auto *FE = dyn_cast<FullExpr>(E))
2829 return FE->getSubExpr();
2842 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
2843 return MTE->getSubExpr();
2845 if (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
2846 return NTTP->getReplacement();
2852 if (
auto *CE = dyn_cast<CastExpr>(E))
2853 return CE->getSubExpr();
2855 if (
auto *FE = dyn_cast<FullExpr>(E))
2856 return FE->getSubExpr();
2858 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
2859 return MTE->getSubExpr();
2861 if (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
2862 return NTTP->getReplacement();
2870 if (
auto *CE = dyn_cast<CastExpr>(E))
2871 if (CE->getCastKind() != CK_LValueToRValue)
2878 if (
auto *CE = dyn_cast<CastExpr>(E))
2879 if (CE->getCastKind() == CK_DerivedToBase ||
2880 CE->getCastKind() == CK_UncheckedDerivedToBase ||
2881 CE->getCastKind() == CK_NoOp)
2882 return CE->getSubExpr();
2892 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
2893 return MTE->getSubExpr();
2895 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(E))
2896 return BTE->getSubExpr();
2902 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
2903 return ICE->getSubExprAsWritten();
2909 if (
auto *PE = dyn_cast<ParenExpr>(E))
2910 return PE->getSubExpr();
2912 if (
auto *UO = dyn_cast<UnaryOperator>(E)) {
2913 if (UO->getOpcode() == UO_Extension)
2914 return UO->getSubExpr();
2917 else if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
2918 if (!GSE->isResultDependent())
2919 return GSE->getResultExpr();
2922 else if (
auto *CE = dyn_cast<ChooseExpr>(E)) {
2923 if (!CE->isConditionDependent())
2924 return CE->getChosenSubExpr();
2927 else if (
auto *CE = dyn_cast<ConstantExpr>(E))
2928 return CE->getSubExpr();
2934 if (
auto *CE = dyn_cast<CastExpr>(E)) {
2937 Expr *SubExpr = CE->getSubExpr();
2938 bool IsIdentityCast =
2940 bool IsSameWidthCast =
2946 if (IsIdentityCast || IsSameWidthCast)
2950 else if (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
2951 return NTTP->getReplacement();
2957 template <
typename FnTy,
typename... FnTys>
2965 template <
typename... FnTys>
2967 Expr *LastE =
nullptr;
2968 while (E != LastE) {
3005 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(
this)) {
3006 if (MCE->getMethodDecl() && isa<CXXConversionDecl>(MCE->getMethodDecl()))
3007 return MCE->getImplicitObjectArgument();
3031 Expr *LastE =
nullptr;
3032 while (E != LastE) {
3038 if (
auto *C = dyn_cast<CXXConstructExpr>(E)) {
3039 if (C->getNumArgs() == 1) {
3040 Expr *A = C->getArg(0);
3046 if (
auto *C = dyn_cast<CXXMemberCallExpr>(E)) {
3047 Expr *ExprNode = C->getImplicitObjectArgument()->IgnoreParenImpCasts();
3057 const Expr *E =
this;
3059 E = M->getSubExpr();
3062 E = ICE->getSubExprAsWritten();
3064 return isa<CXXDefaultArgExpr>(E);
3071 E = M->getSubExpr();
3074 if (ICE->getCastKind() == CK_NoOp)
3075 E = ICE->getSubExpr();
3081 E = BE->getSubExpr();
3084 if (ICE->getCastKind() == CK_NoOp)
3085 E = ICE->getSubExpr();
3104 if (!isa<ObjCPropertyRefExpr>(E))
3112 if (isa<ImplicitCastExpr>(E)) {
3113 switch (cast<ImplicitCastExpr>(E)->getCastKind()) {
3114 case CK_DerivedToBase:
3115 case CK_UncheckedDerivedToBase:
3123 if (isa<MemberExpr>(E))
3127 if (BO->isPtrMemOp())
3131 if (isa<OpaqueValueExpr>(E))
3138 const Expr *E =
this;
3143 E =
Paren->getSubExpr();
3148 if (ICE->getCastKind() == CK_NoOp ||
3149 ICE->getCastKind() == CK_LValueToRValue ||
3150 ICE->getCastKind() == CK_DerivedToBase ||
3151 ICE->getCastKind() == CK_UncheckedDerivedToBase) {
3152 E = ICE->getSubExpr();
3157 if (
const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) {
3158 if (UnOp->getOpcode() == UO_Extension) {
3159 E = UnOp->getSubExpr();
3165 = dyn_cast<MaterializeTemporaryExpr>(E)) {
3166 E = M->getSubExpr();
3174 return This->isImplicit();
3182 for (
unsigned I = 0; I < Exprs.size(); ++I)
3190 const Expr **Culprit)
const {
3192 "Expression evaluator can't be called on a dependent expression.");
3214 case StringLiteralClass:
3215 case ObjCEncodeExprClass:
3217 case CXXTemporaryObjectExprClass:
3218 case CXXConstructExprClass: {
3227 assert(CE->
getNumArgs() == 1 &&
"trivial ctor with > 1 argument");
3233 case ConstantExprClass: {
3236 const Expr *Exp = cast<ConstantExpr>(
this)->getSubExpr();
3239 case CompoundLiteralExprClass: {
3243 const Expr *Exp = cast<CompoundLiteralExpr>(
this)->getInitializer();
3246 case DesignatedInitUpdateExprClass: {
3251 case InitListExprClass: {
3253 assert(ILE->
isSemanticForm() &&
"InitListExpr must be in semantic form");
3256 for (
unsigned i = 0; i < numInits; i++) {
3264 unsigned ElementNo = 0;
3266 for (
const auto *Field : RD->
fields()) {
3272 if (Field->isUnnamedBitfield())
3277 if (Field->isBitField()) {
3286 bool RefType = Field->getType()->isReferenceType();
3297 case ImplicitValueInitExprClass:
3298 case NoInitExprClass:
3300 case ParenExprClass:
3301 return cast<ParenExpr>(
this)->getSubExpr()
3302 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3303 case GenericSelectionExprClass:
3304 return cast<GenericSelectionExpr>(
this)->getResultExpr()
3305 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3306 case ChooseExprClass:
3307 if (cast<ChooseExpr>(
this)->isConditionDependent()) {
3312 return cast<ChooseExpr>(
this)->getChosenSubExpr()
3314 case UnaryOperatorClass: {
3320 case CXXFunctionalCastExprClass:
3321 case CXXStaticCastExprClass:
3322 case ImplicitCastExprClass:
3323 case CStyleCastExprClass:
3324 case ObjCBridgedCastExprClass:
3325 case CXXDynamicCastExprClass:
3326 case CXXReinterpretCastExprClass:
3327 case CXXConstCastExprClass: {
3328 const CastExpr *CE = cast<CastExpr>(
this);
3342 case MaterializeTemporaryExprClass:
3343 return cast<MaterializeTemporaryExpr>(
this)
3345 ->isConstantInitializer(Ctx,
false, Culprit);
3347 case SubstNonTypeTemplateParmExprClass:
3348 return cast<SubstNonTypeTemplateParmExpr>(
this)->getReplacement()
3349 ->isConstantInitializer(Ctx,
false, Culprit);
3350 case CXXDefaultArgExprClass:
3351 return cast<CXXDefaultArgExpr>(
this)->getExpr()
3352 ->isConstantInitializer(Ctx,
false, Culprit);
3353 case CXXDefaultInitExprClass:
3354 return cast<CXXDefaultInitExpr>(
this)->getExpr()
3355 ->isConstantInitializer(Ctx,
false, Culprit);
3369 if (!FD || (FD->
getBuiltinID() != Builtin::BI__assume &&
3373 const Expr* Arg = getArg(0);
3383 const bool IncludePossibleEffects;
3387 explicit SideEffectFinder(
const ASTContext &Context,
bool IncludePossible)
3388 : Inherited(Context),
3389 IncludePossibleEffects(IncludePossible),
HasSideEffects(
false) { }
3393 void VisitExpr(
const Expr *E) {
3394 if (!HasSideEffects &&
3396 HasSideEffects =
true;
3402 bool IncludePossibleEffects)
const {
3406 if (!IncludePossibleEffects &&
getExprLoc().isMacroID())
3410 return IncludePossibleEffects;
3414 #define ABSTRACT_STMT(Type) 3415 #define STMT(Type, Base) case Type##Class: 3416 #define EXPR(Type, Base) 3417 #include "clang/AST/StmtNodes.inc" 3418 llvm_unreachable(
"unexpected Expr kind");
3420 case DependentScopeDeclRefExprClass:
3421 case CXXUnresolvedConstructExprClass:
3422 case CXXDependentScopeMemberExprClass:
3423 case UnresolvedLookupExprClass:
3424 case UnresolvedMemberExprClass:
3425 case PackExpansionExprClass:
3426 case SubstNonTypeTemplateParmPackExprClass:
3427 case FunctionParmPackExprClass:
3429 case CXXFoldExprClass:
3430 llvm_unreachable(
"shouldn't see dependent / unresolved nodes here");
3432 case DeclRefExprClass:
3433 case ObjCIvarRefExprClass:
3434 case PredefinedExprClass:
3435 case IntegerLiteralClass:
3436 case FixedPointLiteralClass:
3437 case FloatingLiteralClass:
3438 case ImaginaryLiteralClass:
3439 case StringLiteralClass:
3440 case CharacterLiteralClass:
3441 case OffsetOfExprClass:
3442 case ImplicitValueInitExprClass:
3443 case UnaryExprOrTypeTraitExprClass:
3444 case AddrLabelExprClass:
3445 case GNUNullExprClass:
3446 case ArrayInitIndexExprClass:
3447 case NoInitExprClass:
3448 case CXXBoolLiteralExprClass:
3449 case CXXNullPtrLiteralExprClass:
3450 case CXXThisExprClass:
3451 case CXXScalarValueInitExprClass:
3452 case TypeTraitExprClass:
3453 case ArrayTypeTraitExprClass:
3454 case ExpressionTraitExprClass:
3455 case CXXNoexceptExprClass:
3456 case SizeOfPackExprClass:
3457 case ObjCStringLiteralClass:
3458 case ObjCEncodeExprClass:
3459 case ObjCBoolLiteralExprClass:
3460 case ObjCAvailabilityCheckExprClass:
3461 case CXXUuidofExprClass:
3462 case OpaqueValueExprClass:
3463 case SourceLocExprClass:
3464 case ConceptSpecializationExprClass:
3465 case RequiresExprClass:
3469 case ConstantExprClass:
3471 return cast<ConstantExpr>(
this)->getSubExpr()->HasSideEffects(
3472 Ctx, IncludePossibleEffects);
3475 case CXXOperatorCallExprClass:
3476 case CXXMemberCallExprClass:
3477 case CUDAKernelCallExprClass:
3478 case UserDefinedLiteralClass: {
3482 const Decl *FD = cast<CallExpr>(
this)->getCalleeDecl();
3483 bool IsPure = FD && (FD->
hasAttr<ConstAttr>() || FD->
hasAttr<PureAttr>());
3484 if (IsPure || !IncludePossibleEffects)
3489 case BlockExprClass:
3490 case CXXBindTemporaryExprClass:
3491 if (!IncludePossibleEffects)
3495 case MSPropertyRefExprClass:
3496 case MSPropertySubscriptExprClass:
3497 case CompoundAssignOperatorClass:
3498 case VAArgExprClass:
3499 case AtomicExprClass:
3500 case CXXThrowExprClass:
3501 case CXXNewExprClass:
3502 case CXXDeleteExprClass:
3503 case CoawaitExprClass:
3504 case DependentCoawaitExprClass:
3505 case CoyieldExprClass:
3509 case StmtExprClass: {
3511 SideEffectFinder Finder(Ctx, IncludePossibleEffects);
3512 Finder.Visit(cast<StmtExpr>(
this)->getSubStmt());
3513 return Finder.hasSideEffects();
3516 case ExprWithCleanupsClass:
3517 if (IncludePossibleEffects)
3518 if (cast<ExprWithCleanups>(
this)->cleanupsHaveSideEffects())
3522 case ParenExprClass:
3523 case ArraySubscriptExprClass:
3524 case OMPArraySectionExprClass:
3525 case MemberExprClass:
3526 case ConditionalOperatorClass:
3527 case BinaryConditionalOperatorClass:
3528 case CompoundLiteralExprClass:
3529 case ExtVectorElementExprClass:
3530 case DesignatedInitExprClass:
3531 case DesignatedInitUpdateExprClass:
3532 case ArrayInitLoopExprClass:
3533 case ParenListExprClass:
3534 case CXXPseudoDestructorExprClass:
3535 case CXXRewrittenBinaryOperatorClass:
3536 case CXXStdInitializerListExprClass:
3537 case SubstNonTypeTemplateParmExprClass:
3538 case MaterializeTemporaryExprClass:
3539 case ShuffleVectorExprClass:
3540 case ConvertVectorExprClass:
3541 case AsTypeExprClass:
3545 case UnaryOperatorClass:
3546 if (cast<UnaryOperator>(
this)->isIncrementDecrementOp())
3550 case BinaryOperatorClass:
3551 if (cast<BinaryOperator>(
this)->isAssignmentOp())
3555 case InitListExprClass:
3558 if (E->HasSideEffects(Ctx, IncludePossibleEffects))
3562 case GenericSelectionExprClass:
3563 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
3566 case ChooseExprClass:
3567 return cast<ChooseExpr>(
this)->getChosenSubExpr()->HasSideEffects(
3568 Ctx, IncludePossibleEffects);
3570 case CXXDefaultArgExprClass:
3571 return cast<CXXDefaultArgExpr>(
this)->getExpr()->HasSideEffects(
3572 Ctx, IncludePossibleEffects);
3574 case CXXDefaultInitExprClass: {
3575 const FieldDecl *FD = cast<CXXDefaultInitExpr>(
this)->getField();
3577 return E->HasSideEffects(Ctx, IncludePossibleEffects);
3582 case CXXDynamicCastExprClass: {
3590 case ImplicitCastExprClass:
3591 case CStyleCastExprClass:
3592 case CXXStaticCastExprClass:
3593 case CXXReinterpretCastExprClass:
3594 case CXXConstCastExprClass:
3595 case CXXFunctionalCastExprClass:
3596 case BuiltinBitCastExprClass: {
3601 if (!IncludePossibleEffects)
3604 const CastExpr *CE = cast<CastExpr>(
this);
3611 case CXXTypeidExprClass:
3614 return cast<CXXTypeidExpr>(
this)->isPotentiallyEvaluated();
3616 case CXXConstructExprClass:
3617 case CXXTemporaryObjectExprClass: {
3626 case CXXInheritedCtorInitExprClass: {
3627 const auto *ICIE = cast<CXXInheritedCtorInitExpr>(
this);
3628 if (!ICIE->getConstructor()->isTrivial() && IncludePossibleEffects)
3633 case LambdaExprClass: {
3636 if (E->HasSideEffects(Ctx, IncludePossibleEffects))
3641 case PseudoObjectExprClass: {
3648 const Expr *Subexpr = *I;
3650 Subexpr = OVE->getSourceExpr();
3657 case ObjCBoxedExprClass:
3658 case ObjCArrayLiteralClass:
3659 case ObjCDictionaryLiteralClass:
3660 case ObjCSelectorExprClass:
3661 case ObjCProtocolExprClass:
3662 case ObjCIsaExprClass:
3663 case ObjCIndirectCopyRestoreExprClass:
3664 case ObjCSubscriptRefExprClass:
3665 case ObjCBridgedCastExprClass:
3666 case ObjCMessageExprClass:
3667 case ObjCPropertyRefExprClass:
3669 if (IncludePossibleEffects)
3677 cast<Expr>(SubStmt)->HasSideEffects(Ctx, IncludePossibleEffects))
3692 explicit NonTrivialCallFinder(
const ASTContext &Context)
3693 : Inherited(Context), NonTrivial(
false) { }
3697 void VisitCallExpr(
const CallExpr *E) {
3699 = dyn_cast_or_null<const CXXMethodDecl>(E->
getCalleeDecl())) {
3700 if (Method->isTrivial()) {
3702 Inherited::VisitStmt(E);
3713 Inherited::VisitStmt(E);
3722 Inherited::VisitStmt(E);
3732 NonTrivialCallFinder Finder(Ctx);
3734 return Finder.hasNonTrivialCall();
3749 llvm_unreachable(
"Unexpected value dependent expression!");
3780 CE->getSubExpr()->getType()->isIntegerType())
3781 return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3784 }
else if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(
this)) {
3786 return ICE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3787 }
else if (
const ParenExpr *PE = dyn_cast<ParenExpr>(
this)) {
3790 return PE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3792 dyn_cast<GenericSelectionExpr>(
this)) {
3793 if (
GE->isResultDependent())
3795 return GE->getResultExpr()->isNullPointerConstant(Ctx, NPC);
3796 }
else if (
const ChooseExpr *CE = dyn_cast<ChooseExpr>(
this)) {
3797 if (CE->isConditionDependent())
3799 return CE->getChosenSubExpr()->isNullPointerConstant(Ctx, NPC);
3801 = dyn_cast<CXXDefaultArgExpr>(
this)) {
3803 return DefaultArg->getExpr()->isNullPointerConstant(Ctx, NPC);
3805 = dyn_cast<CXXDefaultInitExpr>(
this)) {
3807 return DefaultInit->getExpr()->isNullPointerConstant(Ctx, NPC);
3808 }
else if (isa<GNUNullExpr>(
this)) {
3812 = dyn_cast<MaterializeTemporaryExpr>(
this)) {
3813 return M->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3814 }
else if (
const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(
this)) {
3815 if (
const Expr *Source = OVE->getSourceExpr())
3816 return Source->isNullPointerConstant(Ctx, NPC);
3820 if (
getType()->isNullPtrType())
3825 UT && UT->getDecl()->hasAttr<TransparentUnionAttr>())
3827 const Expr *InitExpr = CLE->getInitializer();
3828 if (
const InitListExpr *ILE = dyn_cast<InitListExpr>(InitExpr))
3832 if (!
getType()->isIntegerType() ||
3855 if (isa<IntegerLiteral>(
this))
3863 const Expr *E =
this;
3867 "expression is not a property reference");
3870 if (BO->getOpcode() == BO_Comma) {
3879 return cast<ObjCPropertyRefExpr>(E);
3904 if (ICE->getCastKind() == CK_LValueToRValue ||
3905 (ICE->getValueKind() !=
VK_RValue && ICE->getCastKind() == CK_NoOp))
3911 if (
MemberExpr *MemRef = dyn_cast<MemberExpr>(E))
3912 if (
FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
3913 if (Field->isBitField())
3922 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E)) {
3923 if (
FieldDecl *Field = dyn_cast<FieldDecl>(DeclRef->getDecl()))
3924 if (Field->isBitField())
3927 if (
BindingDecl *BD = dyn_cast<BindingDecl>(DeclRef->getDecl()))
3928 if (
Expr *E = BD->getBinding())
3933 if (BinOp->isAssignmentOp() && BinOp->getLHS())
3934 return BinOp->getLHS()->getSourceBitField();
3936 if (BinOp->getOpcode() == BO_Comma && BinOp->getRHS())
3937 return BinOp->getRHS()->getSourceBitField();
3941 if (UnOp->isPrefix() && UnOp->isIncrementDecrementOp())
3942 return UnOp->getSubExpr()->getSourceBitField();
3953 ICE->getCastKind() == CK_NoOp)
3962 if (isa<ExtVectorElementExpr>(E))
3965 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
3966 if (
auto *BD = dyn_cast<BindingDecl>(DRE->getDecl()))
3967 if (
auto *E = BD->getBinding())
3976 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
3977 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
3979 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
3995 case CXXThisExprClass:
3997 case DeclRefExprClass: {
4000 const auto *DRE1 = cast<DeclRefExpr>(E1);
4001 const auto *DRE2 = cast<DeclRefExpr>(E2);
4002 return DRE1->
isRValue() && DRE2->isRValue() &&
4003 DRE1->getDecl() == DRE2->getDecl();
4005 case ImplicitCastExprClass: {
4012 if (ICE1->getCastKind() != ICE2->getCastKind())
4017 if (ICE1->getCastKind() == CK_LValueToRValue ||
4018 ICE1->getCastKind() == CK_ArrayToPointerDecay ||
4019 ICE1->getCastKind() == CK_FunctionToPointerDecay) {
4031 if (Ivar1 && Ivar2) {
4032 return Ivar1->
isFreeIvar() && Ivar2->isFreeIvar() &&
4038 if (Array1 && Array2) {
4042 auto Idx1 = Array1->
getIdx();
4043 auto Idx2 = Array2->getIdx();
4046 if (Integer1 && Integer2) {
4047 if (!llvm::APInt::isSameValue(Integer1->getValue(),
4048 Integer2->getValue()))
4059 while (isa<MemberExpr>(E1) && isa<MemberExpr>(E2)) {
4060 const auto *ME1 = cast<MemberExpr>(E1);
4061 const auto *ME2 = cast<MemberExpr>(E2);
4064 if (
const auto *D = dyn_cast<VarDecl>(ME1->getMemberDecl()))
4065 if (D->isStaticDataMember())
4071 if (isa<CXXThisExpr>(E1) && isa<CXXThisExpr>(E2))
4077 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
4078 return DRE->getDecl();
4079 if (
const auto *ME = dyn_cast<MemberExpr>(E))
4080 return ME->getMemberDecl();
4094 return getBase()->getType()->isPointerType();
4099 return VT->getNumElements();
4107 StringRef Comp = Accessor->getName();
4110 if (Comp ==
"hi" || Comp ==
"lo" || Comp ==
"even" || Comp ==
"odd")
4114 if (Comp[0] ==
's' || Comp[0] ==
'S')
4115 Comp = Comp.substr(1);
4117 for (
unsigned i = 0, e = Comp.size(); i != e; ++i)
4118 if (Comp.substr(i + 1).find(Comp[i]) != StringRef::npos)
4127 StringRef Comp = Accessor->getName();
4128 bool isNumericAccessor =
false;
4129 if (Comp[0] ==
's' || Comp[0] ==
'S') {
4130 Comp = Comp.substr(1);
4131 isNumericAccessor =
true;
4134 bool isHi = Comp ==
"hi";
4135 bool isLo = Comp ==
"lo";
4136 bool isEven = Comp ==
"even";
4137 bool isOdd = Comp ==
"odd";
4139 for (
unsigned i = 0, e = getNumElements(); i != e; ++i) {
4153 Elts.push_back(Index);
4161 Type->isDependentType(), Type->isDependentType(),
4162 Type->isInstantiationDependentType(),
4164 BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size())
4166 SubExprs =
new (
C)
Stmt*[args.size()];
4167 for (
unsigned i = 0; i != args.size(); i++) {
4173 ExprBits.InstantiationDependent =
true;
4175 ExprBits.ContainsUnexpandedParameterPack =
true;
4177 SubExprs[i] = args[i];
4184 this->NumExprs = Exprs.size();
4185 SubExprs =
new (
C)
Stmt*[NumExprs];
4186 memcpy(SubExprs, Exprs.data(),
sizeof(
Expr *) * Exprs.size());
4189 GenericSelectionExpr::GenericSelectionExpr(
4193 bool ContainsUnexpandedParameterPack,
unsigned ResultIndex)
4194 :
Expr(GenericSelectionExprClass, AssocExprs[ResultIndex]->
getType(),
4200 ContainsUnexpandedParameterPack),
4201 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
4202 DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4203 assert(AssocTypes.size() == AssocExprs.size() &&
4204 "Must have the same number of association expressions" 4205 " and TypeSourceInfo!");
4206 assert(ResultIndex < NumAssocs &&
"ResultIndex is out-of-bounds!");
4209 getTrailingObjects<Stmt *>()[ControllingIndex] = ControllingExpr;
4210 std::copy(AssocExprs.begin(), AssocExprs.end(),
4211 getTrailingObjects<Stmt *>() + AssocExprStartIndex);
4212 std::copy(AssocTypes.begin(), AssocTypes.end(),
4213 getTrailingObjects<TypeSourceInfo *>());
4216 GenericSelectionExpr::GenericSelectionExpr(
4220 bool ContainsUnexpandedParameterPack)
4225 true, ContainsUnexpandedParameterPack),
4226 NumAssocs(AssocExprs.size()), ResultIndex(ResultDependentIndex),
4227 DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4228 assert(AssocTypes.size() == AssocExprs.size() &&
4229 "Must have the same number of association expressions" 4230 " and TypeSourceInfo!");
4233 getTrailingObjects<Stmt *>()[ControllingIndex] = ControllingExpr;
4234 std::copy(AssocExprs.begin(), AssocExprs.end(),
4235 getTrailingObjects<Stmt *>() + AssocExprStartIndex);
4236 std::copy(AssocTypes.begin(), AssocTypes.end(),
4237 getTrailingObjects<TypeSourceInfo *>());
4240 GenericSelectionExpr::GenericSelectionExpr(
EmptyShell Empty,
unsigned NumAssocs)
4241 :
Expr(GenericSelectionExprClass, Empty), NumAssocs(NumAssocs) {}
4247 bool ContainsUnexpandedParameterPack,
unsigned ResultIndex) {
4248 unsigned NumAssocs = AssocExprs.size();
4250 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4253 Context, GenericLoc, ControllingExpr, AssocTypes, AssocExprs, DefaultLoc,
4254 RParenLoc, ContainsUnexpandedParameterPack, ResultIndex);
4261 bool ContainsUnexpandedParameterPack) {
4262 unsigned NumAssocs = AssocExprs.size();
4264 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4267 Context, GenericLoc, ControllingExpr, AssocTypes, AssocExprs, DefaultLoc,
4268 RParenLoc, ContainsUnexpandedParameterPack);
4273 unsigned NumAssocs) {
4275 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4286 if (Field.NameOrField & 0x01)
4287 return reinterpret_cast<IdentifierInfo *
>(Field.NameOrField&~0x01);
4289 return getField()->getIdentifier();
4298 :
Expr(DesignatedInitExprClass, Ty,
4303 EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
4304 NumDesignators(Designators.size()), NumSubExprs(IndexExprs.size() + 1) {
4305 this->Designators =
new (
C)
Designator[NumDesignators];
4313 unsigned IndexIdx = 0;
4314 for (
unsigned I = 0; I != NumDesignators; ++I) {
4315 this->Designators[I] = Designators[I];
4317 if (this->Designators[I].isArrayDesignator()) {
4319 Expr *Index = IndexExprs[IndexIdx];
4323 ExprBits.InstantiationDependent =
true;
4326 ExprBits.ContainsUnexpandedParameterPack =
true;
4329 *Child++ = IndexExprs[IndexIdx++];
4330 }
else if (this->Designators[I].isArrayRangeDesignator()) {
4332 Expr *Start = IndexExprs[IndexIdx];
4333 Expr *
End = IndexExprs[IndexIdx + 1];
4337 ExprBits.InstantiationDependent =
true;
4340 ExprBits.InstantiationDependent =
true;
4346 ExprBits.ContainsUnexpandedParameterPack =
true;
4349 *Child++ = IndexExprs[IndexIdx++];
4350 *Child++ = IndexExprs[IndexIdx++];
4354 assert(IndexIdx == IndexExprs.size() &&
"Wrong number of index expressions");
4362 bool UsesColonSyntax,
Expr *Init) {
4363 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(IndexExprs.size() + 1),
4366 ColonOrEqualLoc, UsesColonSyntax,
4371 unsigned NumIndexExprs) {
4372 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(NumIndexExprs + 1),
4379 unsigned NumDesigs) {
4381 NumDesignators = NumDesigs;
4382 for (
unsigned I = 0; I != NumDesigs; ++I)
4383 Designators[I] = Desigs[I];
4410 return getInit()->getEndLoc();
4420 "Requires array range designator");
4426 "Requires array range designator");
4435 unsigned NumNewDesignators = Last -
First;
4436 if (NumNewDesignators == 0) {
4437 std::copy_backward(Designators + Idx + 1,
4438 Designators + NumDesignators,
4440 --NumNewDesignators;
4442 }
else if (NumNewDesignators == 1) {
4443 Designators[Idx] = *
First;
4448 =
new (
C)
Designator[NumDesignators - 1 + NumNewDesignators];
4449 std::copy(Designators, Designators + Idx, NewDesignators);
4450 std::copy(First, Last, NewDesignators + Idx);
4451 std::copy(Designators + Idx + 1, Designators + NumDesignators,
4452 NewDesignators + Idx + NumNewDesignators);
4453 Designators = NewDesignators;
4454 NumDesignators = NumDesignators - 1 + NumNewDesignators;
4461 BaseAndUpdaterExprs[0] = baseExpr;
4465 BaseAndUpdaterExprs[1] = ILE;
4480 LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
4483 for (
unsigned I = 0, N = Exprs.size(); I != N; ++I) {
4489 ExprBits.InstantiationDependent =
true;
4491 ExprBits.ContainsUnexpandedParameterPack =
true;
4493 getTrailingObjects<Stmt *>()[I] = Exprs[I];
4497 ParenListExpr::ParenListExpr(
EmptyShell Empty,
unsigned NumExprs)
4498 :
Expr(ParenListExprClass, Empty) {
4506 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(Exprs.size()),
4508 return new (Mem)
ParenListExpr(LParenLoc, Exprs, RParenLoc);
4512 unsigned NumExprs) {
4520 e = ewc->getSubExpr();
4522 e = m->getSubExpr();
4523 e = cast<CXXConstructExpr>(e)->getArg(0);
4525 e = ice->getSubExpr();
4526 return cast<OpaqueValueExpr>(e);
4531 unsigned numSemanticExprs) {
4533 Context.
Allocate(totalSizeToAlloc<Expr *>(1 + numSemanticExprs),
4538 PseudoObjectExpr::PseudoObjectExpr(
EmptyShell shell,
unsigned numSemanticExprs)
4539 :
Expr(PseudoObjectExprClass, shell) {
4545 unsigned resultIndex) {
4546 assert(syntax &&
"no syntactic expression!");
4547 assert(semantics.size() &&
"no semantic expressions!");
4551 if (resultIndex == NoResult) {
4555 assert(resultIndex < semantics.size());
4556 type = semantics[resultIndex]->getType();
4557 VK = semantics[resultIndex]->getValueKind();
4561 void *buffer = C.
Allocate(totalSizeToAlloc<Expr *>(semantics.size() + 1),
4569 unsigned resultIndex)
4571 false,
false,
false,
false) {
4575 for (
unsigned i = 0, e = semantics.size() + 1; i != e; ++i) {
4576 Expr *E = (i == 0 ? syntax : semantics[i-1]);
4577 getSubExprsBuffer()[i] = E;
4584 ExprBits.InstantiationDependent =
true;
4586 ExprBits.ContainsUnexpandedParameterPack =
true;
4588 if (isa<OpaqueValueExpr>(E))
4589 assert(cast<OpaqueValueExpr>(E)->getSourceExpr() !=
nullptr &&
4590 "opaque-value semantic expressions for pseudo-object " 4591 "operations must have sources");
4610 if (isArgumentType()) {
4612 dyn_cast<VariableArrayType>(getArgumentType().getTypePtr()))
4623 NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op)
4625 assert(args.size() ==
getNumSubExprs(op) &&
"wrong number of subexpressions");
4626 for (
unsigned i = 0; i != args.size(); i++) {
4632 ExprBits.InstantiationDependent =
true;
4634 ExprBits.ContainsUnexpandedParameterPack =
true;
4636 SubExprs[i] = args[i];
4642 case AO__c11_atomic_init:
4643 case AO__opencl_atomic_init:
4644 case AO__c11_atomic_load:
4645 case AO__atomic_load_n:
4648 case AO__opencl_atomic_load:
4649 case AO__c11_atomic_store:
4650 case AO__c11_atomic_exchange:
4651 case AO__atomic_load:
4652 case AO__atomic_store:
4653 case AO__atomic_store_n:
4654 case AO__atomic_exchange_n:
4655 case AO__c11_atomic_fetch_add:
4656 case AO__c11_atomic_fetch_sub:
4657 case AO__c11_atomic_fetch_and:
4658 case AO__c11_atomic_fetch_or:
4659 case AO__c11_atomic_fetch_xor:
4660 case AO__c11_atomic_fetch_max:
4661 case AO__c11_atomic_fetch_min:
4662 case AO__atomic_fetch_add:
4663 case AO__atomic_fetch_sub:
4664 case AO__atomic_fetch_and:
4665 case AO__atomic_fetch_or:
4666 case AO__atomic_fetch_xor:
4667 case AO__atomic_fetch_nand:
4668 case AO__atomic_add_fetch:
4669 case AO__atomic_sub_fetch:
4670 case AO__atomic_and_fetch:
4671 case AO__atomic_or_fetch:
4672 case AO__atomic_xor_fetch:
4673 case AO__atomic_nand_fetch:
4674 case AO__atomic_min_fetch:
4675 case AO__atomic_max_fetch:
4676 case AO__atomic_fetch_min:
4677 case AO__atomic_fetch_max:
4680 case AO__opencl_atomic_store:
4681 case AO__opencl_atomic_exchange:
4682 case AO__opencl_atomic_fetch_add:
4683 case AO__opencl_atomic_fetch_sub:
4684 case AO__opencl_atomic_fetch_and:
4685 case AO__opencl_atomic_fetch_or:
4686 case AO__opencl_atomic_fetch_xor:
4687 case AO__opencl_atomic_fetch_min:
4688 case AO__opencl_atomic_fetch_max:
4689 case AO__atomic_exchange:
4692 case AO__c11_atomic_compare_exchange_strong:
4693 case AO__c11_atomic_compare_exchange_weak:
4696 case AO__opencl_atomic_compare_exchange_strong:
4697 case AO__opencl_atomic_compare_exchange_weak:
4698 case AO__atomic_compare_exchange:
4699 case AO__atomic_compare_exchange_n:
4702 llvm_unreachable(
"unknown atomic op");
4708 return AT->getValueType();
4713 unsigned ArraySectionCount = 0;
4714 while (
auto *OASE = dyn_cast<OMPArraySectionExpr>(Base->
IgnoreParens())) {
4715 Base = OASE->getBase();
4716 ++ArraySectionCount;
4720 Base = ASE->getBase();
4721 ++ArraySectionCount;
4724 auto OriginalTy = Base->
getType();
4725 if (
auto *DRE = dyn_cast<DeclRefExpr>(Base))
4726 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl()))
4727 OriginalTy = PVD->getOriginalType().getNonReferenceType();
4729 for (
unsigned Cnt = 0; Cnt < ArraySectionCount; ++Cnt) {
4730 if (OriginalTy->isAnyPointerType())
4733 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.
Expr * getBitWidth() const
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.
Expr * IgnoreUnlessSpelledInSource()
Skip past any invisble AST nodes which might surround this statement, such as ExprWithCleanups or Imp...
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>'.
bool This(InterpState &S, CodePtr OpPC)
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.
bool GE(InterpState &S, CodePtr OpPC)
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
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
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...
static Expr * IgnoreImplicitAsWrittenSingleStep(Expr *E)
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
static bool isSameComparisonOperand(const Expr *E1, const Expr *E2)
Checks that the two Expr's will refer to the same value as a comparison operand.
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
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
bool isCurrentInstantiation(const DeclContext *CurContext) const
Determine whether this dependent class is a current instantiation, when viewed from within the given ...
SourceRange getDesignatorsSourceRange() const
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
bool isKnownToHaveBooleanValue(bool Semantic=true) const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
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.
bool LE(InterpState &S, CodePtr OpPC)
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).
Expr * IgnoreImplicitAsWritten() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point...
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