30 #include "llvm/Support/ErrorHandling.h" 31 #include "llvm/Support/raw_ostream.h" 34 using namespace clang;
42 if (
auto *BO = dyn_cast<BinaryOperator>(E)) {
43 if (BO->getOpcode() == BO_Comma) {
50 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
51 E = MTE->GetTemporaryExpr();
72 return cast<CXXRecordDecl>(D);
82 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
83 if ((CE->getCastKind() == CK_DerivedToBase ||
84 CE->getCastKind() == CK_UncheckedDerivedToBase) &&
93 if (CE->getCastKind() == CK_NoOp) {
97 }
else if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
99 assert(ME->getBase()->getType()->isRecordType());
100 if (
FieldDecl *Field = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
101 if (!Field->isBitField() && !Field->getType()->isReferenceType()) {
108 }
else if (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
109 if (BO->getOpcode() == BO_PtrMemD) {
110 assert(BO->getRHS()->isRValue());
116 }
else if (BO->getOpcode() == BO_Comma) {
117 CommaLHSs.push_back(BO->getLHS());
142 switch (UO->getOpcode()) {
144 return UO->getSubExpr()->isKnownToHaveBooleanValue();
155 return CE->getSubExpr()->isKnownToHaveBooleanValue();
158 switch (BO->getOpcode()) {
159 default:
return false;
174 return BO->getLHS()->isKnownToHaveBooleanValue() &&
175 BO->getRHS()->isKnownToHaveBooleanValue();
179 return BO->getRHS()->isKnownToHaveBooleanValue();
184 return CO->getTrueExpr()->isKnownToHaveBooleanValue() &&
185 CO->getFalseExpr()->isKnownToHaveBooleanValue();
197 template <
class E,
class T>
217 #define ABSTRACT_STMT(type) 218 #define STMT(type, base) \ 219 case Stmt::type##Class: break; 220 #define EXPR(type, base) \ 221 case Stmt::type##Class: return getExprLocImpl<type>(this, &type::getExprLoc); 222 #include "clang/AST/StmtNodes.inc" 224 llvm_unreachable(
"unknown expression kind");
236 bool &ValueDependent,
237 bool &InstantiationDependent) {
238 TypeDependent =
false;
239 ValueDependent =
false;
240 InstantiationDependent =
false;
253 TypeDependent =
true;
254 ValueDependent =
true;
255 InstantiationDependent =
true;
258 InstantiationDependent =
true;
266 TypeDependent =
true;
267 ValueDependent =
true;
268 InstantiationDependent =
true;
273 InstantiationDependent =
true;
277 if (isa<NonTypeTemplateParmDecl>(D)) {
278 ValueDependent =
true;
279 InstantiationDependent =
true;
290 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
292 Var->getType()->isLiteralType(Ctx) :
293 Var->getType()->isIntegralOrEnumerationType()) &&
294 (Var->getType().isConstQualified() ||
295 Var->getType()->isReferenceType())) {
296 if (
const Expr *Init = Var->getAnyInitializer())
297 if (Init->isValueDependent()) {
298 ValueDependent =
true;
299 InstantiationDependent =
true;
306 if (Var->isStaticDataMember() &&
307 Var->getDeclContext()->isDependentContext()) {
308 ValueDependent =
true;
309 InstantiationDependent =
true;
312 TypeDependent =
true;
322 ValueDependent =
true;
323 InstantiationDependent =
true;
327 void DeclRefExpr::computeDependence(
const ASTContext &Ctx) {
328 bool TypeDependent =
false;
329 bool ValueDependent =
false;
330 bool InstantiationDependent =
false;
332 ValueDependent, InstantiationDependent);
334 ExprBits.TypeDependent |= TypeDependent;
335 ExprBits.ValueDependent |= ValueDependent;
336 ExprBits.InstantiationDependent |= InstantiationDependent;
339 if (getDecl()->isParameterPack())
340 ExprBits.ContainsUnexpandedParameterPack =
true;
344 bool RefersToEnclosingVariableOrCapture,
QualType T,
348 D(D), DNLoc(LocInfo) {
354 RefersToEnclosingVariableOrCapture;
356 computeDependence(Ctx);
359 DeclRefExpr::DeclRefExpr(
const ASTContext &Ctx,
362 bool RefersToEnclosingVariableOrCapture,
366 :
Expr(DeclRefExprClass, T, VK,
OK_Ordinary,
false,
false,
false,
false),
367 D(D), DNLoc(NameInfo.
getInfo()) {
371 new (getTrailingObjects<NestedNameSpecifierLoc>())
374 if (NNS->isInstantiationDependent())
375 ExprBits.InstantiationDependent =
true;
376 if (NNS->containsUnexpandedParameterPack())
377 ExprBits.ContainsUnexpandedParameterPack =
true;
381 *getTrailingObjects<NamedDecl *>() = FoundD;
383 = (TemplateArgs || TemplateKWLoc.
isValid()) ? 1 : 0;
385 RefersToEnclosingVariableOrCapture;
387 bool Dependent =
false;
388 bool InstantiationDependent =
false;
389 bool ContainsUnexpandedParameterPack =
false;
390 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
391 TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
392 Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
393 assert(!Dependent &&
"built a DeclRefExpr with dependent template args");
394 ExprBits.InstantiationDependent |= InstantiationDependent;
395 ExprBits.ContainsUnexpandedParameterPack |= ContainsUnexpandedParameterPack;
396 }
else if (TemplateKWLoc.
isValid()) {
397 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
402 computeDependence(Ctx);
409 bool RefersToEnclosingVariableOrCapture,
415 return Create(Context, QualifierLoc, TemplateKWLoc, D,
416 RefersToEnclosingVariableOrCapture,
418 T, VK, FoundD, TemplateArgs);
425 bool RefersToEnclosingVariableOrCapture,
435 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
439 QualifierLoc ? 1 : 0, FoundD ? 1 : 0,
440 HasTemplateKWAndArgsInfo ? 1 : 0,
441 TemplateArgs ? TemplateArgs->
size() : 0);
444 return new (Mem)
DeclRefExpr(Context, QualifierLoc, TemplateKWLoc, D,
445 RefersToEnclosingVariableOrCapture,
446 NameInfo, FoundD, TemplateArgs, T, VK);
452 bool HasTemplateKWAndArgsInfo,
453 unsigned NumTemplateArgs) {
454 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
458 HasQualifier ? 1 : 0, HasFoundDecl ? 1 : 0, HasTemplateKWAndArgsInfo,
482 assert((getIdentKind() == IK) &&
483 "IdentKind do not fit in PredefinedExprBitfields!");
484 bool HasFunctionName = SL !=
nullptr;
491 PredefinedExpr::PredefinedExpr(
EmptyShell Empty,
bool HasFunctionName)
492 :
Expr(PredefinedExprClass, Empty) {
499 bool HasFunctionName = SL !=
nullptr;
500 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
506 bool HasFunctionName) {
507 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
517 return "__FUNCTION__";
519 return "__FUNCDNAME__";
521 return "L__FUNCTION__";
523 return "__PRETTY_FUNCTION__";
525 return "__FUNCSIG__";
527 return "L__FUNCSIG__";
528 case PrettyFunctionNoVirtual:
531 llvm_unreachable(
"Unknown ident kind for PredefinedExpr");
540 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(CurrentDecl)) {
541 std::unique_ptr<MangleContext> MC;
544 if (MC->shouldMangleDeclName(ND)) {
546 llvm::raw_svector_ostream Out(Buffer);
552 MC->mangleName(ND, Out);
554 if (!Buffer.empty() && Buffer.front() ==
'\01')
555 return Buffer.substr(1);
558 return ND->getIdentifier()->getName();
562 if (isa<BlockDecl>(CurrentDecl)) {
567 if (DC->isFileContext())
571 llvm::raw_svector_ostream Out(Buffer);
572 if (
auto *DCBlock = dyn_cast<BlockDecl>(DC))
574 Out << ComputeName(IK, DCBlock);
575 else if (
auto *DCDecl = dyn_cast<Decl>(DC))
576 Out << ComputeName(IK, DCDecl) <<
"_block_invoke";
579 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
580 if (IK != PrettyFunction && IK != PrettyFunctionNoVirtual &&
581 IK != FuncSig && IK != LFuncSig)
582 return FD->getNameAsString();
585 llvm::raw_svector_ostream Out(Name);
588 if (MD->isVirtual() && IK != PrettyFunctionNoVirtual)
596 llvm::raw_string_ostream POut(Proto);
603 if (FD->hasWrittenPrototype())
604 FT = dyn_cast<FunctionProtoType>(AFT);
606 if (IK == FuncSig || IK == LFuncSig) {
608 case CC_C: POut <<
"__cdecl ";
break;
619 FD->printQualifiedName(POut, Policy);
623 for (
unsigned i = 0, e = Decl->
getNumParams(); i != e; ++i) {
628 if (FT->isVariadic()) {
629 if (FD->getNumParams()) POut <<
", ";
631 }
else if ((IK == FuncSig || IK == LFuncSig ||
640 assert(FT &&
"We must have a written prototype in this case.");
643 if (FT->isVolatile())
655 while (Ctx && isa<NamedDecl>(Ctx)) {
659 Specs.push_back(Spec);
663 std::string TemplateParams;
664 llvm::raw_string_ostream TOut(TemplateParams);
665 for (SpecsTy::reverse_iterator I = Specs.rbegin(), E = Specs.rend();
668 = (*I)->getSpecializedTemplate()->getTemplateParameters();
670 assert(Params->
size() == Args.
size());
671 for (
unsigned i = 0, numParams = Params->
size(); i != numParams; ++i) {
673 if (Param.empty())
continue;
674 TOut << Param <<
" = ";
681 = FD->getTemplateSpecializationInfo();
686 assert(Params->
size() == Args->
size());
687 for (
unsigned i = 0, e = Params->
size(); i != e; ++i) {
689 if (Param.empty())
continue;
690 TOut << Param <<
" = ";
697 if (!TemplateParams.empty()) {
699 TemplateParams.resize(TemplateParams.size() - 2);
700 POut <<
" [" << TemplateParams <<
"]";
709 if (isa<CXXMethodDecl>(FD) &&
710 cast<CXXMethodDecl>(FD)->getParent()->isLambda())
711 Proto =
"auto " + Proto;
712 else if (FT && FT->getReturnType()->getAs<
DecltypeType>())
717 else if (!isa<CXXConstructorDecl>(FD) && !isa<CXXDestructorDecl>(FD))
722 return Name.str().str();
724 if (
const CapturedDecl *CD = dyn_cast<CapturedDecl>(CurrentDecl)) {
728 if (DC->isFunctionOrMethod() && (DC->getDeclKind() != Decl::Captured)) {
730 return ComputeName(IK, D);
732 llvm_unreachable(
"CapturedDecl not inside a function or method");
734 if (
const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(CurrentDecl)) {
736 llvm::raw_svector_ostream Out(Name);
737 Out << (MD->isInstanceMethod() ?
'-' :
'+');
746 dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext()))
747 Out <<
'(' << *CID <<
')';
750 MD->getSelector().print(Out);
753 return Name.str().str();
755 if (isa<TranslationUnitDecl>(CurrentDecl) && IK == PrettyFunction) {
763 const llvm::APInt &Val) {
767 BitWidth = Val.getBitWidth();
768 unsigned NumWords = Val.getNumWords();
769 const uint64_t* Words = Val.getRawData();
771 pVal =
new (
C) uint64_t[NumWords];
772 std::copy(Words, Words + NumWords, pVal);
773 }
else if (NumWords == 1)
779 IntegerLiteral::IntegerLiteral(
const ASTContext &
C,
const llvm::APInt &V,
784 assert(type->
isIntegerType() &&
"Illegal type in IntegerLiteral");
786 "Integer type is not the correct size for constant.");
801 FixedPointLiteral::FixedPointLiteral(
const ASTContext &
C,
const llvm::APInt &V,
806 Loc(l), Scale(Scale) {
809 "Fixed point type is not the correct size for constant.");
814 const llvm::APInt &V,
827 S, llvm::APSInt::getUnsigned(
getValue().getZExtValue()), Scale);
831 FloatingLiteral::FloatingLiteral(
const ASTContext &
C,
const llvm::APFloat &V,
834 false,
false), Loc(L) {
835 setSemantics(V.getSemantics());
841 :
Expr(FloatingLiteralClass, Empty) {
860 return llvm::APFloat::IEEEhalf();
862 return llvm::APFloat::IEEEsingle();
864 return llvm::APFloat::IEEEdouble();
866 return llvm::APFloat::x87DoubleExtended();
868 return llvm::APFloat::IEEEquad();
870 return llvm::APFloat::PPCDoubleDouble();
872 llvm_unreachable(
"Unrecognised floating semantics");
876 if (&Sem == &llvm::APFloat::IEEEhalf())
878 else if (&Sem == &llvm::APFloat::IEEEsingle())
880 else if (&Sem == &llvm::APFloat::IEEEdouble())
882 else if (&Sem == &llvm::APFloat::x87DoubleExtended())
884 else if (&Sem == &llvm::APFloat::IEEEquad())
886 else if (&Sem == &llvm::APFloat::PPCDoubleDouble())
889 llvm_unreachable(
"Unknown floating semantics");
898 V.convert(llvm::APFloat::IEEEdouble(), llvm::APFloat::rmNearestTiesToEven,
900 return V.convertToDouble();
905 unsigned CharByteWidth = 0;
921 assert((CharByteWidth & 7) == 0 &&
"Assumes character size is byte multiple");
923 assert((CharByteWidth == 1 || CharByteWidth == 2 || CharByteWidth == 4) &&
924 "The only supported character byte widths are 1,2 and 4!");
925 return CharByteWidth;
928 StringLiteral::StringLiteral(
const ASTContext &Ctx, StringRef Str,
931 unsigned NumConcatenated)
935 "StringLiteral must be of constant array type!");
937 unsigned ByteLength = Str.size();
938 assert((ByteLength % CharByteWidth == 0) &&
939 "The size of the data must be a multiple of CharByteWidth!");
945 switch (CharByteWidth) {
950 Length = ByteLength / 2;
953 Length = ByteLength / 4;
956 llvm_unreachable(
"Unsupported character width!");
963 *getTrailingObjects<unsigned>() = Length;
967 std::memcpy(getTrailingObjects<SourceLocation>(), Loc,
971 std::memcpy(getTrailingObjects<char>(), Str.data(), ByteLength);
974 StringLiteral::StringLiteral(
EmptyShell Empty,
unsigned NumConcatenated,
975 unsigned Length,
unsigned CharByteWidth)
976 :
Expr(StringLiteralClass, Empty) {
979 *getTrailingObjects<unsigned>() = Length;
985 unsigned NumConcatenated) {
986 void *Mem = Ctx.
Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
987 1, NumConcatenated, Str.size()),
990 StringLiteral(Ctx, Str, Kind, Pascal, Ty, Loc, NumConcatenated);
994 unsigned NumConcatenated,
996 unsigned CharByteWidth) {
997 void *Mem = Ctx.
Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
998 1, NumConcatenated, Length * CharByteWidth),
1007 case Wide: OS <<
'L';
break;
1008 case UTF8: OS <<
"u8";
break;
1009 case UTF16: OS <<
'u';
break;
1010 case UTF32: OS <<
'U';
break;
1013 static const char Hex[] =
"0123456789ABCDEF";
1015 unsigned LastSlashX = getLength();
1016 for (
unsigned I = 0, N = getLength(); I != N; ++I) {
1017 switch (uint32_t Char = getCodeUnit(I)) {
1023 if (
getKind() == UTF16 && I != N - 1 && Char >= 0xd800 &&
1025 uint32_t Trail = getCodeUnit(I + 1);
1026 if (Trail >= 0xdc00 && Trail <= 0xdfff) {
1027 Char = 0x10000 + ((Char - 0xd800) << 10) + (Trail - 0xdc00);
1037 (Char >= 0xd800 && Char <= 0xdfff) || Char >= 0x110000) {
1041 while ((Char >> Shift) == 0)
1043 for (; Shift >= 0; Shift -= 4)
1044 OS << Hex[(Char >> Shift) & 15];
1051 << Hex[(Char >> 20) & 15]
1052 << Hex[(Char >> 16) & 15];
1055 OS << Hex[(Char >> 12) & 15]
1056 << Hex[(Char >> 8) & 15]
1057 << Hex[(Char >> 4) & 15]
1058 << Hex[(Char >> 0) & 15];
1064 if (LastSlashX + 1 == I) {
1066 case '0':
case '1':
case '2':
case '3':
case '4':
1067 case '5':
case '6':
case '7':
case '8':
case '9':
1068 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
1069 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
1074 assert(Char <= 0xff &&
1075 "Characters above 0xff should already have been handled.");
1081 << (char)(
'0' + ((Char >> 6) & 7))
1082 << (char)(
'0' + ((Char >> 3) & 7))
1083 << (char)(
'0' + ((Char >> 0) & 7));
1086 case '\\': OS <<
"\\\\";
break;
1087 case '"': OS <<
"\\\"";
break;
1088 case '\a': OS <<
"\\a";
break;
1089 case '\b': OS <<
"\\b";
break;
1090 case '\f': OS <<
"\\f";
break;
1091 case '\n': OS <<
"\\n";
break;
1092 case '\r': OS <<
"\\r";
break;
1093 case '\t': OS <<
"\\t";
break;
1094 case '\v': OS <<
"\\v";
break;
1119 const TargetInfo &Target,
unsigned *StartToken,
1120 unsigned *StartTokenByteOffset)
const {
1123 "Only narrow string literals are currently supported");
1128 unsigned StringOffset = 0;
1130 TokNo = *StartToken;
1131 if (StartTokenByteOffset) {
1132 StringOffset = *StartTokenByteOffset;
1133 ByteNo -= StringOffset;
1136 assert(TokNo < getNumConcatenated() &&
"Invalid byte number!");
1145 std::pair<FileID, unsigned> LocInfo =
1147 bool Invalid =
false;
1148 StringRef Buffer = SM.
getBufferData(LocInfo.first, &Invalid);
1150 if (StartTokenByteOffset !=
nullptr)
1151 *StartTokenByteOffset = StringOffset;
1152 if (StartToken !=
nullptr)
1153 *StartToken = TokNo;
1154 return StrTokSpellingLoc;
1157 const char *StrData = Buffer.data()+LocInfo.second;
1161 Buffer.begin(), StrData, Buffer.end());
1163 TheLexer.LexFromRawLexer(TheTok);
1170 if (ByteNo < TokNumBytes ||
1171 (ByteNo == TokNumBytes && TokNo == getNumConcatenated() - 1)) {
1176 if (StartTokenByteOffset !=
nullptr)
1177 *StartTokenByteOffset = StringOffset;
1178 if (StartToken !=
nullptr)
1179 *StartToken = TokNo;
1184 StringOffset += TokNumBytes;
1186 ByteNo -= TokNumBytes;
1194 #define UNARY_OPERATION(Name, Spelling) case UO_##Name: return Spelling; 1195 #include "clang/AST/OperationKinds.def" 1197 llvm_unreachable(
"Unknown unary operator");
1203 default: llvm_unreachable(
"No unary operator for overloaded function");
1204 case OO_PlusPlus:
return Postfix ? UO_PostInc : UO_PreInc;
1205 case OO_MinusMinus:
return Postfix ? UO_PostDec : UO_PreDec;
1206 case OO_Amp:
return UO_AddrOf;
1207 case OO_Star:
return UO_Deref;
1208 case OO_Plus:
return UO_Plus;
1209 case OO_Minus:
return UO_Minus;
1210 case OO_Tilde:
return UO_Not;
1211 case OO_Exclaim:
return UO_LNot;
1212 case OO_Coawait:
return UO_Coawait;
1218 case UO_PostInc:
case UO_PreInc:
return OO_PlusPlus;
1219 case UO_PostDec:
case UO_PreDec:
return OO_MinusMinus;
1220 case UO_AddrOf:
return OO_Amp;
1221 case UO_Deref:
return OO_Star;
1222 case UO_Plus:
return OO_Plus;
1223 case UO_Minus:
return OO_Minus;
1224 case UO_Not:
return OO_Tilde;
1225 case UO_LNot:
return OO_Exclaim;
1226 case UO_Coawait:
return OO_Coawait;
1243 RParenLoc(RParenLoc) {
1244 NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1245 unsigned NumPreArgs = PreArgs.size();
1247 assert((NumPreArgs ==
getNumPreArgs()) &&
"NumPreArgs overflow!");
1249 unsigned OffsetToTrailingObjects = offsetToTrailingObjects(SC);
1250 CallExprBits.OffsetToTrailingObjects = OffsetToTrailingObjects;
1251 assert((
CallExprBits.OffsetToTrailingObjects == OffsetToTrailingObjects) &&
1252 "OffsetToTrailingObjects overflow!");
1257 for (
unsigned I = 0; I != NumPreArgs; ++I) {
1258 updateDependenciesFromArg(PreArgs[I]);
1261 for (
unsigned I = 0; I != Args.size(); ++I) {
1262 updateDependenciesFromArg(Args[I]);
1265 for (
unsigned I = Args.size(); I != NumArgs; ++I) {
1272 :
Expr(SC, Empty), NumArgs(NumArgs) {
1274 assert((NumPreArgs ==
getNumPreArgs()) &&
"NumPreArgs overflow!");
1276 unsigned OffsetToTrailingObjects = offsetToTrailingObjects(SC);
1277 CallExprBits.OffsetToTrailingObjects = OffsetToTrailingObjects;
1278 assert((
CallExprBits.OffsetToTrailingObjects == OffsetToTrailingObjects) &&
1279 "OffsetToTrailingObjects overflow!");
1286 unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1287 unsigned SizeOfTrailingObjects =
1291 return new (Mem)
CallExpr(CallExprClass, Fn, {}, Args, Ty, VK,
1292 RParenLoc, MinNumArgs,
UsesADL);
1298 assert(!(reinterpret_cast<uintptr_t>(Mem) %
alignof(
CallExpr)) &&
1299 "Misaligned memory in CallExpr::CreateTemporary!");
1300 return new (Mem)
CallExpr(CallExprClass, Fn, {}, {}, Ty,
1306 unsigned SizeOfTrailingObjects =
1310 return new (Mem)
CallExpr(CallExprClass, 0, NumArgs, Empty);
1313 unsigned CallExpr::offsetToTrailingObjects(
StmtClass SC) {
1317 case CXXOperatorCallExprClass:
1319 case CXXMemberCallExprClass:
1321 case UserDefinedLiteralClass:
1323 case CUDAKernelCallExprClass:
1326 llvm_unreachable(
"unexpected class deriving from CallExpr!");
1330 void CallExpr::updateDependenciesFromArg(
Expr *Arg) {
1336 ExprBits.InstantiationDependent =
true;
1338 ExprBits.ContainsUnexpandedParameterPack =
true;
1345 = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE)) {
1351 if (BO->isPtrMemOp())
1353 }
else if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(CEE)) {
1354 if (UO->getOpcode() == UO_Deref)
1357 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE))
1358 return DRE->getDecl();
1359 if (
MemberExpr *ME = dyn_cast<MemberExpr>(CEE))
1360 return ME->getMemberDecl();
1403 if (isa<CXXPseudoDestructorExpr>(Callee->
IgnoreParens()))
1418 if (
const auto *A = TD->getAttr<WarnUnusedResultAttr>())
1424 return D ? D->
getAttr<WarnUnusedResultAttr>() :
nullptr;
1428 if (isa<CXXOperatorCallExpr>(
this))
1429 return cast<CXXOperatorCallExpr>(
this)->
getBeginLoc();
1437 if (isa<CXXOperatorCallExpr>(
this))
1438 return cast<CXXOperatorCallExpr>(
this)->
getEndLoc();
1453 totalSizeToAlloc<OffsetOfNode, Expr *>(comps.size(), exprs.size()));
1455 return new (Mem)
OffsetOfExpr(C, type, OperatorLoc, tsi, comps, exprs,
1460 unsigned numComps,
unsigned numExprs) {
1462 C.
Allocate(totalSizeToAlloc<OffsetOfNode, Expr *>(numComps, numExprs));
1475 OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
1476 NumComps(comps.size()), NumExprs(exprs.size())
1478 for (
unsigned i = 0; i != comps.size(); ++i) {
1479 setComponent(i, comps[i]);
1482 for (
unsigned i = 0; i != exprs.size(); ++i) {
1486 ExprBits.ContainsUnexpandedParameterPack =
true;
1488 setIndexExpr(i, exprs[i]);
1495 return getField()->getIdentifier();
1508 OpLoc(op), RParenLoc(rp) {
1520 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
1522 else if (
const auto *ME = dyn_cast<MemberExpr>(E))
1523 D = ME->getMemberDecl();
1527 if (I->isAlignmentDependent()) {
1545 bool hasQualOrFound = (QualifierLoc ||
1546 founddecl.
getDecl() != memberdecl ||
1549 bool HasTemplateKWAndArgsInfo = targs || TemplateKWLoc.
isValid();
1553 HasTemplateKWAndArgsInfo ? 1 : 0,
1554 targs ? targs->
size() : 0);
1558 MemberExpr(base, isarrow, OperatorLoc, memberdecl, nameinfo, ty, vk, ok);
1560 if (hasQualOrFound) {
1567 else if (QualifierLoc &&
1573 MemberExprNameQualifier *NQ =
1574 E->getTrailingObjects<MemberExprNameQualifier>();
1580 (targs || TemplateKWLoc.
isValid());
1583 bool Dependent =
false;
1584 bool InstantiationDependent =
false;
1585 bool ContainsUnexpandedParameterPack =
false;
1586 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1588 Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
1589 if (InstantiationDependent)
1591 }
else if (TemplateKWLoc.
isValid()) {
1592 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1600 if (isImplicitAccess()) {
1602 return getQualifierLoc().getBeginLoc();
1610 return BaseStartLoc;
1615 if (hasExplicitTemplateArgs())
1616 EndLoc = getRAngleLoc();
1618 EndLoc = getBase()->getEndLoc();
1622 bool CastExpr::CastConsistency()
const {
1623 switch (getCastKind()) {
1624 case CK_DerivedToBase:
1625 case CK_UncheckedDerivedToBase:
1626 case CK_DerivedToBaseMemberPointer:
1627 case CK_BaseToDerived:
1628 case CK_BaseToDerivedMemberPointer:
1629 assert(!path_empty() &&
"Cast kind should have a base path!");
1632 case CK_CPointerToObjCPointerCast:
1633 assert(
getType()->isObjCObjectPointerType());
1634 assert(getSubExpr()->
getType()->isPointerType());
1635 goto CheckNoBasePath;
1637 case CK_BlockPointerToObjCPointerCast:
1638 assert(
getType()->isObjCObjectPointerType());
1639 assert(getSubExpr()->
getType()->isBlockPointerType());
1640 goto CheckNoBasePath;
1642 case CK_ReinterpretMemberPointer:
1643 assert(
getType()->isMemberPointerType());
1644 assert(getSubExpr()->
getType()->isMemberPointerType());
1645 goto CheckNoBasePath;
1651 if (!
getType()->isPointerType()) {
1652 assert(
getType()->isObjCObjectPointerType() ==
1653 getSubExpr()->
getType()->isObjCObjectPointerType());
1654 assert(
getType()->isBlockPointerType() ==
1655 getSubExpr()->
getType()->isBlockPointerType());
1657 goto CheckNoBasePath;
1659 case CK_AnyPointerToBlockPointerCast:
1660 assert(
getType()->isBlockPointerType());
1661 assert(getSubExpr()->
getType()->isAnyPointerType() &&
1662 !getSubExpr()->
getType()->isBlockPointerType());
1663 goto CheckNoBasePath;
1665 case CK_CopyAndAutoreleaseBlockObject:
1666 assert(
getType()->isBlockPointerType());
1667 assert(getSubExpr()->
getType()->isBlockPointerType());
1668 goto CheckNoBasePath;
1670 case CK_FunctionToPointerDecay:
1671 assert(
getType()->isPointerType());
1672 assert(getSubExpr()->
getType()->isFunctionType());
1673 goto CheckNoBasePath;
1675 case CK_AddressSpaceConversion: {
1677 auto SETy = getSubExpr()->getType();
1683 assert(!Ty.
isNull() && !SETy.isNull() &&
1685 goto CheckNoBasePath;
1690 case CK_ArrayToPointerDecay:
1691 case CK_NullToMemberPointer:
1692 case CK_NullToPointer:
1693 case CK_ConstructorConversion:
1694 case CK_IntegralToPointer:
1695 case CK_PointerToIntegral:
1697 case CK_VectorSplat:
1698 case CK_IntegralCast:
1699 case CK_BooleanToSignedIntegral:
1700 case CK_IntegralToFloating:
1701 case CK_FloatingToIntegral:
1702 case CK_FloatingCast:
1703 case CK_ObjCObjectLValueCast:
1704 case CK_FloatingRealToComplex:
1705 case CK_FloatingComplexToReal:
1706 case CK_FloatingComplexCast:
1707 case CK_FloatingComplexToIntegralComplex:
1708 case CK_IntegralRealToComplex:
1709 case CK_IntegralComplexToReal:
1710 case CK_IntegralComplexCast:
1711 case CK_IntegralComplexToFloatingComplex:
1712 case CK_ARCProduceObject:
1713 case CK_ARCConsumeObject:
1714 case CK_ARCReclaimReturnedObject:
1715 case CK_ARCExtendBlockObject:
1716 case CK_ZeroToOCLOpaqueType:
1717 case CK_IntToOCLSampler:
1718 case CK_FixedPointCast:
1720 goto CheckNoBasePath;
1723 case CK_LValueToRValue:
1725 case CK_AtomicToNonAtomic:
1726 case CK_NonAtomicToAtomic:
1727 case CK_PointerToBoolean:
1728 case CK_IntegralToBoolean:
1729 case CK_FloatingToBoolean:
1730 case CK_MemberPointerToBoolean:
1731 case CK_FloatingComplexToBoolean:
1732 case CK_IntegralComplexToBoolean:
1733 case CK_LValueBitCast:
1734 case CK_UserDefinedConversion:
1735 case CK_BuiltinFnToFnPtr:
1736 case CK_FixedPointToBoolean:
1738 assert(path_empty() &&
"Cast kind should not have a base path!");
1746 #define CAST_OPERATION(Name) case CK_##Name: return #Name; 1747 #include "clang/AST/OperationKinds.def" 1749 llvm_unreachable(
"Unhandled cast kind!");
1753 const Expr *skipImplicitTemporary(
const Expr *E) {
1755 if (
auto *Materialize = dyn_cast<MaterializeTemporaryExpr>(E))
1756 E = Materialize->GetTemporaryExpr();
1759 if (
auto *Binder = dyn_cast<CXXBindTemporaryExpr>(E))
1760 E = Binder->getSubExpr();
1767 const Expr *SubExpr =
nullptr;
1770 SubExpr = skipImplicitTemporary(E->
getSubExpr());
1776 skipImplicitTemporary(cast<CXXConstructExpr>(SubExpr)->getArg(0));
1777 else if (E->
getCastKind() == CK_UserDefinedConversion) {
1778 assert((isa<CXXMemberCallExpr>(SubExpr) ||
1779 isa<BlockExpr>(SubExpr)) &&
1780 "Unexpected SubExpr for CK_UserDefinedConversion.");
1781 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
1782 SubExpr = MCE->getImplicitObjectArgument();
1787 }
while ((E = dyn_cast<ImplicitCastExpr>(SubExpr)));
1789 return const_cast<Expr*
>(SubExpr);
1793 const Expr *SubExpr =
nullptr;
1796 SubExpr = skipImplicitTemporary(E->getSubExpr());
1798 if (E->getCastKind() == CK_ConstructorConversion)
1799 return cast<CXXConstructExpr>(SubExpr)->getConstructor();
1801 if (E->getCastKind() == CK_UserDefinedConversion) {
1802 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
1803 return MCE->getMethodDecl();
1812 #define ABSTRACT_STMT(x) 1813 #define CASTEXPR(Type, Base) \ 1814 case Stmt::Type##Class: \ 1815 return static_cast<Type *>(this)->getTrailingObjects<CXXBaseSpecifier *>(); 1816 #define STMT(Type, Base) 1817 #include "clang/AST/StmtNodes.inc" 1819 llvm_unreachable(
"non-cast expressions not possible here");
1826 return getTargetFieldForToUnionCast(RD, opType);
1834 Field != FieldEnd; ++Field) {
1836 !Field->isUnnamedBitfield()) {
1847 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1848 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1852 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1858 unsigned PathSize) {
1859 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1869 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1870 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1872 new (Buffer)
CStyleCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, R);
1874 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1880 unsigned PathSize) {
1881 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1889 #define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling; 1890 #include "clang/AST/OperationKinds.def" 1892 llvm_unreachable(
"Invalid OpCode!");
1898 default: llvm_unreachable(
"Not an overloadable binary operator");
1899 case OO_Plus:
return BO_Add;
1900 case OO_Minus:
return BO_Sub;
1901 case OO_Star:
return BO_Mul;
1902 case OO_Slash:
return BO_Div;
1903 case OO_Percent:
return BO_Rem;
1904 case OO_Caret:
return BO_Xor;
1905 case OO_Amp:
return BO_And;
1906 case OO_Pipe:
return BO_Or;
1907 case OO_Equal:
return BO_Assign;
1908 case OO_Spaceship:
return BO_Cmp;
1909 case OO_Less:
return BO_LT;
1910 case OO_Greater:
return BO_GT;
1911 case OO_PlusEqual:
return BO_AddAssign;
1912 case OO_MinusEqual:
return BO_SubAssign;
1913 case OO_StarEqual:
return BO_MulAssign;
1914 case OO_SlashEqual:
return BO_DivAssign;
1915 case OO_PercentEqual:
return BO_RemAssign;
1916 case OO_CaretEqual:
return BO_XorAssign;
1917 case OO_AmpEqual:
return BO_AndAssign;
1918 case OO_PipeEqual:
return BO_OrAssign;
1919 case OO_LessLess:
return BO_Shl;
1920 case OO_GreaterGreater:
return BO_Shr;
1921 case OO_LessLessEqual:
return BO_ShlAssign;
1922 case OO_GreaterGreaterEqual:
return BO_ShrAssign;
1923 case OO_EqualEqual:
return BO_EQ;
1924 case OO_ExclaimEqual:
return BO_NE;
1925 case OO_LessEqual:
return BO_LE;
1926 case OO_GreaterEqual:
return BO_GE;
1927 case OO_AmpAmp:
return BO_LAnd;
1928 case OO_PipePipe:
return BO_LOr;
1929 case OO_Comma:
return BO_Comma;
1930 case OO_ArrowStar:
return BO_PtrMemI;
1937 OO_Star, OO_Slash, OO_Percent,
1939 OO_LessLess, OO_GreaterGreater,
1941 OO_Less, OO_Greater, OO_LessEqual, OO_GreaterEqual,
1942 OO_EqualEqual, OO_ExclaimEqual,
1948 OO_Equal, OO_StarEqual,
1949 OO_SlashEqual, OO_PercentEqual,
1950 OO_PlusEqual, OO_MinusEqual,
1951 OO_LessLessEqual, OO_GreaterGreaterEqual,
1952 OO_AmpEqual, OO_CaretEqual,
1956 return OverOps[Opc];
1995 InitExprs(C, initExprs.size()),
1996 LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(nullptr,
true)
1999 for (
unsigned I = 0; I != initExprs.size(); ++I) {
2005 ExprBits.InstantiationDependent =
true;
2007 ExprBits.ContainsUnexpandedParameterPack =
true;
2010 InitExprs.
insert(C, InitExprs.
end(), initExprs.begin(), initExprs.end());
2014 if (NumInits > InitExprs.
size())
2015 InitExprs.
reserve(C, NumInits);
2019 InitExprs.
resize(C, NumInits,
nullptr);
2023 if (Init >= InitExprs.
size()) {
2024 InitExprs.
insert(C, InitExprs.
end(), Init - InitExprs.
size() + 1,
nullptr);
2029 Expr *
Result = cast_or_null<Expr>(InitExprs[Init]);
2036 ArrayFillerOrUnionFieldInit = filler;
2039 for (
unsigned i = 0, e =
getNumInits(); i != e; ++i)
2040 if (inits[i] ==
nullptr)
2055 return isa<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init);
2059 assert(
isSemanticForm() &&
"syntactic form never semantically transparent");
2063 assert(
getNumInits() == 1 &&
"multiple inits in glvalue init list");
2082 assert(
isSyntacticForm() &&
"only test syntactic form as zero initializer");
2089 return Lit && Lit->
getValue() == 0;
2094 return SyntacticForm->getBeginLoc();
2099 E = InitExprs.
end();
2102 Beg = S->getBeginLoc();
2112 return SyntacticForm->getEndLoc();
2117 E = InitExprs.
rend();
2120 End = S->getEndLoc();
2132 return cast<BlockPointerType>(
getType())
2137 return TheBlock->getCaretLocation();
2140 return TheBlock->getBody();
2143 return TheBlock->getBody();
2171 case ParenExprClass:
2172 return cast<ParenExpr>(
this)->getSubExpr()->
2174 case GenericSelectionExprClass:
2175 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
2177 case CoawaitExprClass:
2178 case CoyieldExprClass:
2179 return cast<CoroutineSuspendExpr>(
this)->getResumeExpr()->
2181 case ChooseExprClass:
2182 return cast<ChooseExpr>(
this)->getChosenSubExpr()->
2184 case UnaryOperatorClass: {
2207 .isVolatileQualified())
2218 case BinaryOperatorClass: {
2230 if (IE->getValue() == 0)
2249 case CompoundAssignOperatorClass:
2250 case VAArgExprClass:
2251 case AtomicExprClass:
2254 case ConditionalOperatorClass: {
2266 case MemberExprClass:
2268 Loc = cast<MemberExpr>(
this)->getMemberLoc();
2270 R2 = cast<MemberExpr>(
this)->getBase()->getSourceRange();
2273 case ArraySubscriptExprClass:
2275 Loc = cast<ArraySubscriptExpr>(
this)->getRBracketLoc();
2276 R1 = cast<ArraySubscriptExpr>(
this)->getLHS()->getSourceRange();
2277 R2 = cast<ArraySubscriptExpr>(
this)->getRHS()->getSourceRange();
2280 case CXXOperatorCallExprClass: {
2292 case OO_ExclaimEqual:
2295 case OO_GreaterEqual:
2310 case CXXMemberCallExprClass:
2311 case UserDefinedLiteralClass: {
2313 const CallExpr *CE = cast<CallExpr>(
this);
2321 FD->hasAttr<PureAttr>() || FD->hasAttr<ConstAttr>()) {
2336 case UnresolvedLookupExprClass:
2337 case CXXUnresolvedConstructExprClass:
2340 case CXXTemporaryObjectExprClass:
2341 case CXXConstructExprClass: {
2343 if (Type->
hasAttr<WarnUnusedAttr>()) {
2353 case ObjCMessageExprClass: {
2366 if (MD->hasAttr<WarnUnusedResultAttr>()) {
2375 case ObjCPropertyRefExprClass:
2381 case PseudoObjectExprClass: {
2395 case StmtExprClass: {
2401 const CompoundStmt *CS = cast<StmtExpr>(
this)->getSubStmt();
2404 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2406 if (
const Expr *E = dyn_cast<Expr>(
Label->getSubStmt()))
2407 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2413 Loc = cast<StmtExpr>(
this)->getLParenLoc();
2417 case CXXFunctionalCastExprClass:
2418 case CStyleCastExprClass: {
2421 const CastExpr *CE = cast<CastExpr>(
this);
2427 if (!(DRE && isa<VarDecl>(DRE->
getDecl()) &&
2428 cast<VarDecl>(DRE->
getDecl())->hasLocalStorage()) &&
2439 if (CE->
getCastKind() == CK_ConstructorConversion)
2444 dyn_cast<CXXFunctionalCastExpr>(
this)) {
2445 Loc = CXXCE->getBeginLoc();
2446 R1 = CXXCE->getSubExpr()->getSourceRange();
2454 case ImplicitCastExprClass: {
2455 const CastExpr *ICE = cast<ImplicitCastExpr>(
this);
2464 case CXXDefaultArgExprClass:
2465 return (cast<CXXDefaultArgExpr>(
this)
2467 case CXXDefaultInitExprClass:
2468 return (cast<CXXDefaultInitExpr>(
this)
2471 case CXXNewExprClass:
2474 case CXXDeleteExprClass:
2476 case MaterializeTemporaryExprClass:
2477 return cast<MaterializeTemporaryExpr>(
this)->GetTemporaryExpr()
2478 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2479 case CXXBindTemporaryExprClass:
2480 return cast<CXXBindTemporaryExpr>(
this)->getSubExpr()
2481 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2482 case ExprWithCleanupsClass:
2483 return cast<ExprWithCleanups>(
this)->getSubExpr()
2484 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2495 case ObjCIvarRefExprClass:
2497 case Expr::UnaryOperatorClass:
2498 return cast<UnaryOperator>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2499 case ImplicitCastExprClass:
2500 return cast<ImplicitCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2501 case MaterializeTemporaryExprClass:
2502 return cast<MaterializeTemporaryExpr>(E)->GetTemporaryExpr()
2503 ->isOBJCGCCandidate(Ctx);
2504 case CStyleCastExprClass:
2505 return cast<CStyleCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2506 case DeclRefExprClass: {
2507 const Decl *D = cast<DeclRefExpr>(E)->getDecl();
2509 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2510 if (VD->hasGlobalStorage())
2520 case MemberExprClass: {
2524 case ArraySubscriptExprClass:
2525 return cast<ArraySubscriptExpr>(E)->getBase()->isOBJCGCCandidate(Ctx);
2543 if (
const MemberExpr *mem = dyn_cast<MemberExpr>(expr)) {
2544 assert(isa<CXXMethodDecl>(mem->getMemberDecl()));
2545 return mem->getMemberDecl()->getType();
2555 assert(isa<UnresolvedMemberExpr>(expr) || isa<CXXPseudoDestructorExpr>(expr));
2562 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
2563 E = ICE->getSubExpr();
2564 else if (
auto *FE = dyn_cast<FullExpr>(E))
2565 E = FE->getSubExpr();
2574 Expr *LastE =
nullptr;
2575 while (E != LastE) {
2578 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E))
2579 E = ICE->getSubExpr();
2581 if (
auto *FE = dyn_cast<FullExpr>(E))
2582 E = FE->getSubExpr();
2584 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E))
2585 E = MTE->GetTemporaryExpr();
2587 if (
auto *BTE = dyn_cast<CXXBindTemporaryExpr>(E))
2588 E = BTE->getSubExpr();
2596 if (
auto *PE = dyn_cast<ParenExpr>(E)) {
2597 E = PE->getSubExpr();
2600 if (
auto *UO = dyn_cast<UnaryOperator>(E)) {
2601 if (UO->getOpcode() == UO_Extension) {
2602 E = UO->getSubExpr();
2606 if (
auto *GSE = dyn_cast<GenericSelectionExpr>(E)) {
2607 if (!GSE->isResultDependent()) {
2608 E = GSE->getResultExpr();
2612 if (
auto *CE = dyn_cast<ChooseExpr>(E)) {
2613 if (!CE->isConditionDependent()) {
2614 E = CE->getChosenSubExpr();
2618 if (
auto *CE = dyn_cast<ConstantExpr>(E)) {
2619 E = CE->getSubExpr();
2632 if (
auto *CE = dyn_cast<CastExpr>(E)) {
2633 E = CE->getSubExpr();
2636 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
2637 E = MTE->GetTemporaryExpr();
2640 if (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2641 E = NTTP->getReplacement();
2644 if (
auto *FE = dyn_cast<FullExpr>(E)) {
2645 E = FE->getSubExpr();
2655 if (
auto *CE = dyn_cast<CastExpr>(E)) {
2656 E = CE->getSubExpr();
2659 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
2660 E = MTE->GetTemporaryExpr();
2663 if (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2664 E = NTTP->getReplacement();
2667 if (
auto *FE = dyn_cast<FullExpr>(E)) {
2668 E = FE->getSubExpr();
2683 if (
auto *CE = dyn_cast<CastExpr>(E)) {
2684 if (CE->getCastKind() == CK_LValueToRValue) {
2685 E = CE->getSubExpr();
2688 }
else if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
2689 E = MTE->GetTemporaryExpr();
2691 }
else if (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2692 E = NTTP->getReplacement();
2694 }
else if (
auto *FE = dyn_cast<FullExpr>(E)) {
2695 E = FE->getSubExpr();
2707 if (
auto *CE = dyn_cast<CastExpr>(E)) {
2708 if (CE->getCastKind() == CK_DerivedToBase ||
2709 CE->getCastKind() == CK_UncheckedDerivedToBase ||
2710 CE->getCastKind() == CK_NoOp) {
2711 E = CE->getSubExpr();
2724 if (
auto *ICE = dyn_cast<ImplicitCastExpr>(E)) {
2725 E = ICE->getSubExpr();
2728 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
2729 E = MTE->GetTemporaryExpr();
2732 if (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2733 E = NTTP->getReplacement();
2741 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(
this)) {
2742 if (MCE->getMethodDecl() && isa<CXXConversionDecl>(MCE->getMethodDecl()))
2743 return MCE->getImplicitObjectArgument();
2756 if (
auto *CE = dyn_cast<CastExpr>(E)) {
2759 Expr *SE = CE->getSubExpr();
2776 if (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2777 E = NTTP->getReplacement();
2786 const Expr *E =
this;
2788 E = M->GetTemporaryExpr();
2791 E = ICE->getSubExprAsWritten();
2793 return isa<CXXDefaultArgExpr>(E);
2800 E = M->GetTemporaryExpr();
2803 if (ICE->getCastKind() == CK_NoOp)
2804 E = ICE->getSubExpr();
2810 E = BE->getSubExpr();
2813 if (ICE->getCastKind() == CK_NoOp)
2814 E = ICE->getSubExpr();
2833 if (!isa<ObjCPropertyRefExpr>(E))
2841 if (isa<ImplicitCastExpr>(E)) {
2842 switch (cast<ImplicitCastExpr>(E)->getCastKind()) {
2843 case CK_DerivedToBase:
2844 case CK_UncheckedDerivedToBase:
2852 if (isa<MemberExpr>(E))
2856 if (BO->isPtrMemOp())
2860 if (isa<OpaqueValueExpr>(E))
2867 const Expr *E =
this;
2872 E =
Paren->getSubExpr();
2877 if (ICE->getCastKind() == CK_NoOp ||
2878 ICE->getCastKind() == CK_LValueToRValue ||
2879 ICE->getCastKind() == CK_DerivedToBase ||
2880 ICE->getCastKind() == CK_UncheckedDerivedToBase) {
2881 E = ICE->getSubExpr();
2886 if (
const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) {
2887 if (UnOp->getOpcode() == UO_Extension) {
2888 E = UnOp->getSubExpr();
2894 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2895 E = M->GetTemporaryExpr();
2902 if (
const CXXThisExpr *This = dyn_cast<CXXThisExpr>(E))
2903 return This->isImplicit();
2911 for (
unsigned I = 0; I < Exprs.size(); ++I)
2919 const Expr **Culprit)
const {
2940 case StringLiteralClass:
2941 case ObjCEncodeExprClass:
2943 case CXXTemporaryObjectExprClass:
2944 case CXXConstructExprClass: {
2953 assert(CE->
getNumArgs() == 1 &&
"trivial ctor with > 1 argument");
2959 case ConstantExprClass: {
2962 const Expr *Exp = cast<ConstantExpr>(
this)->getSubExpr();
2965 case CompoundLiteralExprClass: {
2969 const Expr *Exp = cast<CompoundLiteralExpr>(
this)->getInitializer();
2972 case DesignatedInitUpdateExprClass: {
2977 case InitListExprClass: {
2981 for (
unsigned i = 0; i < numInits; i++) {
2989 unsigned ElementNo = 0;
2991 for (
const auto *Field : RD->
fields()) {
2997 if (Field->isUnnamedBitfield())
3002 if (Field->isBitField()) {
3011 bool RefType = Field->getType()->isReferenceType();
3022 case ImplicitValueInitExprClass:
3023 case NoInitExprClass:
3025 case ParenExprClass:
3026 return cast<ParenExpr>(
this)->getSubExpr()
3027 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3028 case GenericSelectionExprClass:
3029 return cast<GenericSelectionExpr>(
this)->getResultExpr()
3030 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3031 case ChooseExprClass:
3032 if (cast<ChooseExpr>(
this)->isConditionDependent()) {
3037 return cast<ChooseExpr>(
this)->getChosenSubExpr()
3039 case UnaryOperatorClass: {
3045 case CXXFunctionalCastExprClass:
3046 case CXXStaticCastExprClass:
3047 case ImplicitCastExprClass:
3048 case CStyleCastExprClass:
3049 case ObjCBridgedCastExprClass:
3050 case CXXDynamicCastExprClass:
3051 case CXXReinterpretCastExprClass:
3052 case CXXConstCastExprClass: {
3053 const CastExpr *CE = cast<CastExpr>(
this);
3067 case MaterializeTemporaryExprClass:
3068 return cast<MaterializeTemporaryExpr>(
this)->GetTemporaryExpr()
3069 ->isConstantInitializer(Ctx,
false, Culprit);
3071 case SubstNonTypeTemplateParmExprClass:
3072 return cast<SubstNonTypeTemplateParmExpr>(
this)->getReplacement()
3073 ->isConstantInitializer(Ctx,
false, Culprit);
3074 case CXXDefaultArgExprClass:
3075 return cast<CXXDefaultArgExpr>(
this)->getExpr()
3076 ->isConstantInitializer(Ctx,
false, Culprit);
3077 case CXXDefaultInitExprClass:
3078 return cast<CXXDefaultInitExpr>(
this)->getExpr()
3079 ->isConstantInitializer(Ctx,
false, Culprit);
3093 if (!FD || (FD->
getBuiltinID() != Builtin::BI__assume &&
3097 const Expr* Arg = getArg(0);
3107 const bool IncludePossibleEffects;
3111 explicit SideEffectFinder(
const ASTContext &Context,
bool IncludePossible)
3112 : Inherited(Context),
3113 IncludePossibleEffects(IncludePossible),
HasSideEffects(
false) { }
3117 void VisitExpr(
const Expr *E) {
3118 if (!HasSideEffects &&
3120 HasSideEffects =
true;
3126 bool IncludePossibleEffects)
const {
3130 if (!IncludePossibleEffects &&
getExprLoc().isMacroID())
3134 return IncludePossibleEffects;
3138 #define ABSTRACT_STMT(Type) 3139 #define STMT(Type, Base) case Type##Class: 3140 #define EXPR(Type, Base) 3141 #include "clang/AST/StmtNodes.inc" 3142 llvm_unreachable(
"unexpected Expr kind");
3144 case DependentScopeDeclRefExprClass:
3145 case CXXUnresolvedConstructExprClass:
3146 case CXXDependentScopeMemberExprClass:
3147 case UnresolvedLookupExprClass:
3148 case UnresolvedMemberExprClass:
3149 case PackExpansionExprClass:
3150 case SubstNonTypeTemplateParmPackExprClass:
3151 case FunctionParmPackExprClass:
3153 case CXXFoldExprClass:
3154 llvm_unreachable(
"shouldn't see dependent / unresolved nodes here");
3156 case DeclRefExprClass:
3157 case ObjCIvarRefExprClass:
3158 case PredefinedExprClass:
3159 case IntegerLiteralClass:
3160 case FixedPointLiteralClass:
3161 case FloatingLiteralClass:
3162 case ImaginaryLiteralClass:
3163 case StringLiteralClass:
3164 case CharacterLiteralClass:
3165 case OffsetOfExprClass:
3166 case ImplicitValueInitExprClass:
3167 case UnaryExprOrTypeTraitExprClass:
3168 case AddrLabelExprClass:
3169 case GNUNullExprClass:
3170 case ArrayInitIndexExprClass:
3171 case NoInitExprClass:
3172 case CXXBoolLiteralExprClass:
3173 case CXXNullPtrLiteralExprClass:
3174 case CXXThisExprClass:
3175 case CXXScalarValueInitExprClass:
3176 case TypeTraitExprClass:
3177 case ArrayTypeTraitExprClass:
3178 case ExpressionTraitExprClass:
3179 case CXXNoexceptExprClass:
3180 case SizeOfPackExprClass:
3181 case ObjCStringLiteralClass:
3182 case ObjCEncodeExprClass:
3183 case ObjCBoolLiteralExprClass:
3184 case ObjCAvailabilityCheckExprClass:
3185 case CXXUuidofExprClass:
3186 case OpaqueValueExprClass:
3190 case ConstantExprClass:
3192 return cast<ConstantExpr>(
this)->getSubExpr()->HasSideEffects(
3193 Ctx, IncludePossibleEffects);
3196 case CXXOperatorCallExprClass:
3197 case CXXMemberCallExprClass:
3198 case CUDAKernelCallExprClass:
3199 case UserDefinedLiteralClass: {
3203 const Decl *FD = cast<CallExpr>(
this)->getCalleeDecl();
3204 bool IsPure = FD && (FD->
hasAttr<ConstAttr>() || FD->
hasAttr<PureAttr>());
3205 if (IsPure || !IncludePossibleEffects)
3210 case BlockExprClass:
3211 case CXXBindTemporaryExprClass:
3212 if (!IncludePossibleEffects)
3216 case MSPropertyRefExprClass:
3217 case MSPropertySubscriptExprClass:
3218 case CompoundAssignOperatorClass:
3219 case VAArgExprClass:
3220 case AtomicExprClass:
3221 case CXXThrowExprClass:
3222 case CXXNewExprClass:
3223 case CXXDeleteExprClass:
3224 case CoawaitExprClass:
3225 case DependentCoawaitExprClass:
3226 case CoyieldExprClass:
3230 case StmtExprClass: {
3232 SideEffectFinder Finder(Ctx, IncludePossibleEffects);
3233 Finder.Visit(cast<StmtExpr>(
this)->getSubStmt());
3234 return Finder.hasSideEffects();
3237 case ExprWithCleanupsClass:
3238 if (IncludePossibleEffects)
3239 if (cast<ExprWithCleanups>(
this)->cleanupsHaveSideEffects())
3243 case ParenExprClass:
3244 case ArraySubscriptExprClass:
3245 case OMPArraySectionExprClass:
3246 case MemberExprClass:
3247 case ConditionalOperatorClass:
3248 case BinaryConditionalOperatorClass:
3249 case CompoundLiteralExprClass:
3250 case ExtVectorElementExprClass:
3251 case DesignatedInitExprClass:
3252 case DesignatedInitUpdateExprClass:
3253 case ArrayInitLoopExprClass:
3254 case ParenListExprClass:
3255 case CXXPseudoDestructorExprClass:
3256 case CXXStdInitializerListExprClass:
3257 case SubstNonTypeTemplateParmExprClass:
3258 case MaterializeTemporaryExprClass:
3259 case ShuffleVectorExprClass:
3260 case ConvertVectorExprClass:
3261 case AsTypeExprClass:
3265 case UnaryOperatorClass:
3266 if (cast<UnaryOperator>(
this)->isIncrementDecrementOp())
3270 case BinaryOperatorClass:
3271 if (cast<BinaryOperator>(
this)->isAssignmentOp())
3275 case InitListExprClass:
3278 if (E->HasSideEffects(Ctx, IncludePossibleEffects))
3282 case GenericSelectionExprClass:
3283 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
3286 case ChooseExprClass:
3287 return cast<ChooseExpr>(
this)->getChosenSubExpr()->HasSideEffects(
3288 Ctx, IncludePossibleEffects);
3290 case CXXDefaultArgExprClass:
3291 return cast<CXXDefaultArgExpr>(
this)->getExpr()->HasSideEffects(
3292 Ctx, IncludePossibleEffects);
3294 case CXXDefaultInitExprClass: {
3295 const FieldDecl *FD = cast<CXXDefaultInitExpr>(
this)->getField();
3297 return E->HasSideEffects(Ctx, IncludePossibleEffects);
3302 case CXXDynamicCastExprClass: {
3310 case ImplicitCastExprClass:
3311 case CStyleCastExprClass:
3312 case CXXStaticCastExprClass:
3313 case CXXReinterpretCastExprClass:
3314 case CXXConstCastExprClass:
3315 case CXXFunctionalCastExprClass: {
3320 if (!IncludePossibleEffects)
3323 const CastExpr *CE = cast<CastExpr>(
this);
3330 case CXXTypeidExprClass:
3333 return cast<CXXTypeidExpr>(
this)->isPotentiallyEvaluated();
3335 case CXXConstructExprClass:
3336 case CXXTemporaryObjectExprClass: {
3345 case CXXInheritedCtorInitExprClass: {
3346 const auto *ICIE = cast<CXXInheritedCtorInitExpr>(
this);
3347 if (!ICIE->getConstructor()->isTrivial() && IncludePossibleEffects)
3352 case LambdaExprClass: {
3353 const LambdaExpr *LE = cast<LambdaExpr>(
this);
3355 if (E->HasSideEffects(Ctx, IncludePossibleEffects))
3360 case PseudoObjectExprClass: {
3367 const Expr *Subexpr = *I;
3369 Subexpr = OVE->getSourceExpr();
3376 case ObjCBoxedExprClass:
3377 case ObjCArrayLiteralClass:
3378 case ObjCDictionaryLiteralClass:
3379 case ObjCSelectorExprClass:
3380 case ObjCProtocolExprClass:
3381 case ObjCIsaExprClass:
3382 case ObjCIndirectCopyRestoreExprClass:
3383 case ObjCSubscriptRefExprClass:
3384 case ObjCBridgedCastExprClass:
3385 case ObjCMessageExprClass:
3386 case ObjCPropertyRefExprClass:
3388 if (IncludePossibleEffects)
3396 cast<Expr>(SubStmt)->HasSideEffects(Ctx, IncludePossibleEffects))
3411 explicit NonTrivialCallFinder(
const ASTContext &Context)
3412 : Inherited(Context), NonTrivial(
false) { }
3416 void VisitCallExpr(
const CallExpr *E) {
3418 = dyn_cast_or_null<const CXXMethodDecl>(E->
getCalleeDecl())) {
3419 if (Method->isTrivial()) {
3421 Inherited::VisitStmt(E);
3432 Inherited::VisitStmt(E);
3441 Inherited::VisitStmt(E);
3451 NonTrivialCallFinder Finder(Ctx);
3453 return Finder.hasNonTrivialCall();
3468 llvm_unreachable(
"Unexpected value dependent expression!");
3499 CE->getSubExpr()->getType()->isIntegerType())
3500 return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3503 }
else if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(
this)) {
3505 return ICE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3506 }
else if (
const ParenExpr *PE = dyn_cast<ParenExpr>(
this)) {
3509 return PE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3511 dyn_cast<GenericSelectionExpr>(
this)) {
3512 if (GE->isResultDependent())
3514 return GE->getResultExpr()->isNullPointerConstant(Ctx, NPC);
3515 }
else if (
const ChooseExpr *CE = dyn_cast<ChooseExpr>(
this)) {
3516 if (CE->isConditionDependent())
3518 return CE->getChosenSubExpr()->isNullPointerConstant(Ctx, NPC);
3520 = dyn_cast<CXXDefaultArgExpr>(
this)) {
3522 return DefaultArg->getExpr()->isNullPointerConstant(Ctx, NPC);
3524 = dyn_cast<CXXDefaultInitExpr>(
this)) {
3526 return DefaultInit->getExpr()->isNullPointerConstant(Ctx, NPC);
3527 }
else if (isa<GNUNullExpr>(
this)) {
3531 = dyn_cast<MaterializeTemporaryExpr>(
this)) {
3532 return M->GetTemporaryExpr()->isNullPointerConstant(Ctx, NPC);
3533 }
else if (
const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(
this)) {
3534 if (
const Expr *Source = OVE->getSourceExpr())
3535 return Source->isNullPointerConstant(Ctx, NPC);
3539 if (
getType()->isNullPtrType())
3544 UT && UT->getDecl()->hasAttr<TransparentUnionAttr>())
3546 const Expr *InitExpr = CLE->getInitializer();
3547 if (
const InitListExpr *ILE = dyn_cast<InitListExpr>(InitExpr))
3551 if (!
getType()->isIntegerType() ||
3574 if (isa<IntegerLiteral>(
this))
3582 const Expr *E =
this;
3586 "expression is not a property reference");
3589 if (BO->getOpcode() == BO_Comma) {
3598 return cast<ObjCPropertyRefExpr>(E);
3623 if (ICE->getCastKind() == CK_LValueToRValue ||
3624 (ICE->getValueKind() !=
VK_RValue && ICE->getCastKind() == CK_NoOp))
3630 if (
MemberExpr *MemRef = dyn_cast<MemberExpr>(E))
3631 if (
FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
3632 if (Field->isBitField())
3641 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E)) {
3642 if (
FieldDecl *Field = dyn_cast<FieldDecl>(DeclRef->getDecl()))
3643 if (Field->isBitField())
3646 if (
BindingDecl *BD = dyn_cast<BindingDecl>(DeclRef->getDecl()))
3647 if (
Expr *E = BD->getBinding())
3652 if (BinOp->isAssignmentOp() && BinOp->getLHS())
3653 return BinOp->getLHS()->getSourceBitField();
3655 if (BinOp->getOpcode() == BO_Comma && BinOp->getRHS())
3656 return BinOp->getRHS()->getSourceBitField();
3660 if (UnOp->isPrefix() && UnOp->isIncrementDecrementOp())
3661 return UnOp->getSubExpr()->getSourceBitField();
3672 ICE->getCastKind() == CK_NoOp)
3681 if (isa<ExtVectorElementExpr>(E))
3684 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
3685 if (
auto *BD = dyn_cast<BindingDecl>(DRE->getDecl()))
3686 if (
auto *E = BD->getBinding())
3695 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
3696 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
3698 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
3707 return getBase()->getType()->isPointerType();
3712 return VT->getNumElements();
3720 StringRef Comp = Accessor->getName();
3723 if (Comp ==
"hi" || Comp ==
"lo" || Comp ==
"even" || Comp ==
"odd")
3727 if (Comp[0] ==
's' || Comp[0] ==
'S')
3728 Comp = Comp.substr(1);
3730 for (
unsigned i = 0, e = Comp.size(); i != e; ++i)
3731 if (Comp.substr(i + 1).find(Comp[i]) != StringRef::npos)
3740 StringRef Comp = Accessor->getName();
3741 bool isNumericAccessor =
false;
3742 if (Comp[0] ==
's' || Comp[0] ==
'S') {
3743 Comp = Comp.substr(1);
3744 isNumericAccessor =
true;
3747 bool isHi = Comp ==
"hi";
3748 bool isLo = Comp ==
"lo";
3749 bool isEven = Comp ==
"even";
3750 bool isOdd = Comp ==
"odd";
3752 for (
unsigned i = 0, e = getNumElements(); i != e; ++i) {
3766 Elts.push_back(Index);
3774 Type->isDependentType(), Type->isDependentType(),
3775 Type->isInstantiationDependentType(),
3777 BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size())
3779 SubExprs =
new (
C)
Stmt*[args.size()];
3780 for (
unsigned i = 0; i != args.size(); i++) {
3786 ExprBits.InstantiationDependent =
true;
3788 ExprBits.ContainsUnexpandedParameterPack =
true;
3790 SubExprs[i] = args[i];
3797 this->NumExprs = Exprs.size();
3798 SubExprs =
new (
C)
Stmt*[NumExprs];
3799 memcpy(SubExprs, Exprs.data(),
sizeof(
Expr *) * Exprs.size());
3802 GenericSelectionExpr::GenericSelectionExpr(
3806 bool ContainsUnexpandedParameterPack,
unsigned ResultIndex)
3807 :
Expr(GenericSelectionExprClass, AssocExprs[ResultIndex]->
getType(),
3813 ContainsUnexpandedParameterPack),
3814 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
3815 DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
3816 assert(AssocTypes.size() == AssocExprs.size() &&
3817 "Must have the same number of association expressions" 3818 " and TypeSourceInfo!");
3819 assert(ResultIndex < NumAssocs &&
"ResultIndex is out-of-bounds!");
3822 getTrailingObjects<Stmt *>()[ControllingIndex] = ControllingExpr;
3823 std::copy(AssocExprs.begin(), AssocExprs.end(),
3824 getTrailingObjects<Stmt *>() + AssocExprStartIndex);
3825 std::copy(AssocTypes.begin(), AssocTypes.end(),
3826 getTrailingObjects<TypeSourceInfo *>());
3829 GenericSelectionExpr::GenericSelectionExpr(
3833 bool ContainsUnexpandedParameterPack)
3838 true, ContainsUnexpandedParameterPack),
3839 NumAssocs(AssocExprs.size()), ResultIndex(ResultDependentIndex),
3840 DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
3841 assert(AssocTypes.size() == AssocExprs.size() &&
3842 "Must have the same number of association expressions" 3843 " and TypeSourceInfo!");
3846 getTrailingObjects<Stmt *>()[ControllingIndex] = ControllingExpr;
3847 std::copy(AssocExprs.begin(), AssocExprs.end(),
3848 getTrailingObjects<Stmt *>() + AssocExprStartIndex);
3849 std::copy(AssocTypes.begin(), AssocTypes.end(),
3850 getTrailingObjects<TypeSourceInfo *>());
3853 GenericSelectionExpr::GenericSelectionExpr(
EmptyShell Empty,
unsigned NumAssocs)
3854 :
Expr(GenericSelectionExprClass, Empty), NumAssocs(NumAssocs) {}
3860 bool ContainsUnexpandedParameterPack,
unsigned ResultIndex) {
3861 unsigned NumAssocs = AssocExprs.size();
3863 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
3866 Context, GenericLoc, ControllingExpr, AssocTypes, AssocExprs, DefaultLoc,
3867 RParenLoc, ContainsUnexpandedParameterPack, ResultIndex);
3874 bool ContainsUnexpandedParameterPack) {
3875 unsigned NumAssocs = AssocExprs.size();
3877 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
3880 Context, GenericLoc, ControllingExpr, AssocTypes, AssocExprs, DefaultLoc,
3881 RParenLoc, ContainsUnexpandedParameterPack);
3886 unsigned NumAssocs) {
3888 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
3899 if (Field.NameOrField & 0x01)
3900 return reinterpret_cast<IdentifierInfo *
>(Field.NameOrField&~0x01);
3902 return getField()->getIdentifier();
3911 :
Expr(DesignatedInitExprClass, Ty,
3916 EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
3917 NumDesignators(Designators.size()), NumSubExprs(IndexExprs.size() + 1) {
3918 this->Designators =
new (
C)
Designator[NumDesignators];
3926 unsigned IndexIdx = 0;
3927 for (
unsigned I = 0; I != NumDesignators; ++I) {
3928 this->Designators[I] = Designators[I];
3930 if (this->Designators[I].isArrayDesignator()) {
3932 Expr *Index = IndexExprs[IndexIdx];
3936 ExprBits.InstantiationDependent =
true;
3939 ExprBits.ContainsUnexpandedParameterPack =
true;
3942 *Child++ = IndexExprs[IndexIdx++];
3943 }
else if (this->Designators[I].isArrayRangeDesignator()) {
3945 Expr *Start = IndexExprs[IndexIdx];
3946 Expr *
End = IndexExprs[IndexIdx + 1];
3950 ExprBits.InstantiationDependent =
true;
3953 ExprBits.InstantiationDependent =
true;
3959 ExprBits.ContainsUnexpandedParameterPack =
true;
3962 *Child++ = IndexExprs[IndexIdx++];
3963 *Child++ = IndexExprs[IndexIdx++];
3967 assert(IndexIdx == IndexExprs.size() &&
"Wrong number of index expressions");
3975 bool UsesColonSyntax,
Expr *Init) {
3976 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(IndexExprs.size() + 1),
3979 ColonOrEqualLoc, UsesColonSyntax,
3984 unsigned NumIndexExprs) {
3985 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(NumIndexExprs + 1),
3992 unsigned NumDesigs) {
3994 NumDesignators = NumDesigs;
3995 for (
unsigned I = 0; I != NumDesigs; ++I)
3996 Designators[I] = Desigs[I];
4023 return getInit()->getEndLoc();
4033 "Requires array range designator");
4039 "Requires array range designator");
4048 unsigned NumNewDesignators = Last -
First;
4049 if (NumNewDesignators == 0) {
4050 std::copy_backward(Designators + Idx + 1,
4051 Designators + NumDesignators,
4053 --NumNewDesignators;
4055 }
else if (NumNewDesignators == 1) {
4056 Designators[Idx] = *
First;
4061 =
new (
C)
Designator[NumDesignators - 1 + NumNewDesignators];
4062 std::copy(Designators, Designators + Idx, NewDesignators);
4063 std::copy(First, Last, NewDesignators + Idx);
4064 std::copy(Designators + Idx + 1, Designators + NumDesignators,
4065 NewDesignators + Idx + NumNewDesignators);
4066 Designators = NewDesignators;
4067 NumDesignators = NumDesignators - 1 + NumNewDesignators;
4074 BaseAndUpdaterExprs[0] = baseExpr;
4078 BaseAndUpdaterExprs[1] = ILE;
4093 LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
4096 for (
unsigned I = 0, N = Exprs.size(); I != N; ++I) {
4102 ExprBits.InstantiationDependent =
true;
4104 ExprBits.ContainsUnexpandedParameterPack =
true;
4106 getTrailingObjects<Stmt *>()[I] = Exprs[I];
4110 ParenListExpr::ParenListExpr(
EmptyShell Empty,
unsigned NumExprs)
4111 :
Expr(ParenListExprClass, Empty) {
4119 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(Exprs.size()),
4121 return new (Mem)
ParenListExpr(LParenLoc, Exprs, RParenLoc);
4125 unsigned NumExprs) {
4133 e = ewc->getSubExpr();
4135 e = m->GetTemporaryExpr();
4136 e = cast<CXXConstructExpr>(e)->getArg(0);
4138 e = ice->getSubExpr();
4139 return cast<OpaqueValueExpr>(e);
4144 unsigned numSemanticExprs) {
4146 Context.
Allocate(totalSizeToAlloc<Expr *>(1 + numSemanticExprs),
4151 PseudoObjectExpr::PseudoObjectExpr(
EmptyShell shell,
unsigned numSemanticExprs)
4152 :
Expr(PseudoObjectExprClass, shell) {
4158 unsigned resultIndex) {
4159 assert(syntax &&
"no syntactic expression!");
4160 assert(semantics.size() &&
"no semantic expressions!");
4164 if (resultIndex == NoResult) {
4168 assert(resultIndex < semantics.size());
4169 type = semantics[resultIndex]->getType();
4170 VK = semantics[resultIndex]->getValueKind();
4174 void *buffer = C.
Allocate(totalSizeToAlloc<Expr *>(semantics.size() + 1),
4182 unsigned resultIndex)
4184 false,
false,
false,
false) {
4188 for (
unsigned i = 0, e = semantics.size() + 1; i != e; ++i) {
4189 Expr *E = (i == 0 ? syntax : semantics[i-1]);
4190 getSubExprsBuffer()[i] = E;
4197 ExprBits.InstantiationDependent =
true;
4199 ExprBits.ContainsUnexpandedParameterPack =
true;
4201 if (isa<OpaqueValueExpr>(E))
4202 assert(cast<OpaqueValueExpr>(E)->getSourceExpr() !=
nullptr &&
4203 "opaque-value semantic expressions for pseudo-object " 4204 "operations must have sources");
4223 if (isArgumentType()) {
4225 dyn_cast<VariableArrayType>(getArgumentType().getTypePtr()))
4236 NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op)
4238 assert(args.size() ==
getNumSubExprs(op) &&
"wrong number of subexpressions");
4239 for (
unsigned i = 0; i != args.size(); i++) {
4245 ExprBits.InstantiationDependent =
true;
4247 ExprBits.ContainsUnexpandedParameterPack =
true;
4249 SubExprs[i] = args[i];
4255 case AO__c11_atomic_init:
4256 case AO__opencl_atomic_init:
4257 case AO__c11_atomic_load:
4258 case AO__atomic_load_n:
4261 case AO__opencl_atomic_load:
4262 case AO__c11_atomic_store:
4263 case AO__c11_atomic_exchange:
4264 case AO__atomic_load:
4265 case AO__atomic_store:
4266 case AO__atomic_store_n:
4267 case AO__atomic_exchange_n:
4268 case AO__c11_atomic_fetch_add:
4269 case AO__c11_atomic_fetch_sub:
4270 case AO__c11_atomic_fetch_and:
4271 case AO__c11_atomic_fetch_or:
4272 case AO__c11_atomic_fetch_xor:
4273 case AO__atomic_fetch_add:
4274 case AO__atomic_fetch_sub:
4275 case AO__atomic_fetch_and:
4276 case AO__atomic_fetch_or:
4277 case AO__atomic_fetch_xor:
4278 case AO__atomic_fetch_nand:
4279 case AO__atomic_add_fetch:
4280 case AO__atomic_sub_fetch:
4281 case AO__atomic_and_fetch:
4282 case AO__atomic_or_fetch:
4283 case AO__atomic_xor_fetch:
4284 case AO__atomic_nand_fetch:
4285 case AO__atomic_fetch_min:
4286 case AO__atomic_fetch_max:
4289 case AO__opencl_atomic_store:
4290 case AO__opencl_atomic_exchange:
4291 case AO__opencl_atomic_fetch_add:
4292 case AO__opencl_atomic_fetch_sub:
4293 case AO__opencl_atomic_fetch_and:
4294 case AO__opencl_atomic_fetch_or:
4295 case AO__opencl_atomic_fetch_xor:
4296 case AO__opencl_atomic_fetch_min:
4297 case AO__opencl_atomic_fetch_max:
4298 case AO__atomic_exchange:
4301 case AO__c11_atomic_compare_exchange_strong:
4302 case AO__c11_atomic_compare_exchange_weak:
4305 case AO__opencl_atomic_compare_exchange_strong:
4306 case AO__opencl_atomic_compare_exchange_weak:
4307 case AO__atomic_compare_exchange:
4308 case AO__atomic_compare_exchange_n:
4311 llvm_unreachable(
"unknown atomic op");
4317 return AT->getValueType();
4322 unsigned ArraySectionCount = 0;
4323 while (
auto *OASE = dyn_cast<OMPArraySectionExpr>(Base->
IgnoreParens())) {
4324 Base = OASE->getBase();
4325 ++ArraySectionCount;
4329 Base = ASE->getBase();
4330 ++ArraySectionCount;
4333 auto OriginalTy = Base->
getType();
4334 if (
auto *DRE = dyn_cast<DeclRefExpr>(Base))
4335 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl()))
4336 OriginalTy = PVD->getOriginalType().getNonReferenceType();
4338 for (
unsigned Cnt = 0; Cnt < ArraySectionCount; ++Cnt) {
4339 if (OriginalTy->isAnyPointerType())
4342 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.
SourceLocation getBeginLoc() const LLVM_READONLY
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...
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.
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
static Decl * castFromDeclContext(const DeclContext *)
unsigned FieldLoc
The location of the field name in the designated initializer.
const Expr * getInit(unsigned Init) const
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
Stmt - This represents one statement.
DesignatedInitUpdateExpr(const ASTContext &C, SourceLocation lBraceLoc, Expr *baseExprs, SourceLocation rBraceLoc)
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
FunctionType - C99 6.7.5.3 - Function Declarators.
SourceLocation getLocationOfByte(unsigned ByteNo, const SourceManager &SM, const LangOptions &Features, const TargetInfo &Target, unsigned *StartToken=nullptr, unsigned *StartTokenByteOffset=nullptr) const
getLocationOfByte - Return a source location that points to the specified byte of this string literal...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
static CallExpr * CreateTemporary(void *Mem, Expr *Fn, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, ADLCallKind UsesADL=NotADL)
Create a temporary call expression with no arguments in the memory pointed to by Mem.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Defines the SourceManager interface.
bool hasNonTrivialCall(const ASTContext &Ctx) const
Determine whether this expression involves a call to any function that is not trivial.
bool isRecordType() const
reverse_iterator rbegin()
unsigned size() const
Retrieve the number of template arguments in this template argument list.
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
void setSemantics(const llvm::fltSemantics &Sem)
Set the APFloat semantics this literal uses.
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.
bool containsDuplicateElements() const
containsDuplicateElements - Return true if any element access is repeated.
unsigned getCharWidth() const
Represents a C++ constructor within a class.
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
const Attr * getUnusedResultAttr(const ASTContext &Ctx) const
Returns the WarnUnusedResultAttr that is either declared on the called function, or its return type d...
Expr * ignoreParenBaseCasts() LLVM_READONLY
Skip past any parentheses and derived-to-base casts until reaching a fixed point. ...
QualType getElementType() const
SourceLocation getEndLoc() const LLVM_READONLY
StringRef getBufferData(FileID FID, bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
static OffsetOfExpr * CreateEmpty(const ASTContext &C, unsigned NumComps, unsigned NumExprs)
static const OpaqueValueExpr * findInCopyConstruct(const Expr *expr)
Given an expression which invokes a copy constructor — i.e.
Represents a variable declaration or definition.
const ObjCPropertyRefExpr * getObjCProperty() const
If this expression is an l-value for an Objective C property, find the underlying property reference ...
CompoundLiteralExpr - [C99 6.5.2.5].
bool isEnumeralType() const
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const T * getAs() const
Member-template getAs<specific type>'.
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type...
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
void setInit(unsigned Init, Expr *expr)
ObjCMethodDecl - Represents an instance or class method declaration.
static PredefinedExpr * CreateEmpty(const ASTContext &Ctx, bool HasFunctionName)
Create an empty PredefinedExpr.
bool isIdiomaticZeroInitializer(const LangOptions &LangOpts) const
Is this the zero initializer {0} in a language which considers it idiomatic?
Stores a list of template parameters for a TemplateDecl and its derived classes.
static DeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasQualifier, bool HasFoundDecl, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Construct an empty declaration reference expression.
Describes how types, statements, expressions, and declarations should be printed. ...
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
static bool isAssignmentOp(Opcode Opc)
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.
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.
bool isReferenceType() const
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
Token - This structure provides full information about a lexed token.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
bool isArrow() const
isArrow - Return true if the base expression is a pointer to vector, return false if the base express...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
NestedNameSpecifierLoc QualifierLoc
The nested-name-specifier that qualifies the name, including source-location information.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
struct FieldDesignator Field
A field designator, e.g., ".x".
const Expr *const * const_semantics_iterator
ShuffleVectorExpr(const ASTContext &C, ArrayRef< Expr *> args, QualType Type, SourceLocation BLoc, SourceLocation RP)
Provides information about a function template specialization, which is a FunctionDecl that has been ...
StringRef getOpcodeStr() const
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...
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx) const
EvaluateAsBooleanCondition - Return true if this is a constant which we can fold and convert to a boo...
void setValue(const ASTContext &C, const llvm::APInt &Val)
static FixedPointLiteral * CreateFromRawInt(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l, unsigned Scale)
bool isBitField() const
Determines whether this field is a bitfield.
SourceLocation getEndLoc() const LLVM_READONLY
An lvalue ref-qualifier was provided (&).
A convenient class for passing around template argument information.
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
NullPointerConstantValueDependence
Enumeration used to describe how isNullPointerConstant() should cope with value-dependent expressions...
unsigned getNumPreArgs() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
static bool isRecordType(QualType T)
semantics_iterator semantics_end()
A builtin binary operation expression such as "x + y" or "x <= y".
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isBoundMemberFunction(ASTContext &Ctx) const
Returns true if this expression is a bound member function.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
StringKind
StringLiteral is followed by several trailing objects.
field_iterator field_begin() const
SourceLocation getCaretLocation() const
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.
An ordinary object is located at an address in memory.
Represents the body of a CapturedStmt, and serves as its DeclContext.
Represents an ObjC class declaration.
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Expression is a GNU-style __null constant.
bool isExplicitSpecialization() const
const Stmt * getBody() const
A binding in a decomposition declaration.
bool isUnevaluated(unsigned ID) const
Returns true if this builtin does not perform the side-effects of its arguments.
A default argument (C++ [dcl.fct.default]).
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
void setIntValue(const ASTContext &C, const llvm::APInt &Val)
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point...
bool isObjCSelfExpr() const
Check if this expression is the ObjC 'self' implicit parameter.
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.
bool EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsLValue - Evaluate an expression to see if we can fold it to an lvalue with link time known ...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
CastKind
CastKind - The kind of operation required for a conversion.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
Specifies that the expression should never be value-dependent.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
InitListExpr * getUpdater() const
void outputString(raw_ostream &OS) const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
ConstStmtIterator const_child_iterator
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Exposes information about the current target.
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
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.
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
SourceLocation getEndLoc() const LLVM_READONLY
const T * castAs() const
Member-template castAs<specific type>.
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.
Represents a C++ destructor within a class.
bool isFieldDesignator() const
unsigned getNumInits() const
const Expr * skipRValueSubobjectAdjustments() const
field_iterator field_end() const
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...
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.
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
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
SourceRange getSourceRange() const
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.
unsigned getWCharWidth() const
getWCharWidth/Align - Return the size of 'wchar_t' for this target, in bits.
RecordDecl * getDecl() const
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Expr * IgnoreCasts() LLVM_READONLY
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.
const llvm::fltSemantics & getSemantics() const
Return the APFloat semantics this literal uses.
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)
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...
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Encodes a location in the source.
QualType getReturnType() const
SourceLocation getOperatorLoc() const
PseudoObjectExprBitfields PseudoObjectExprBits
LangAS getAddressSpace() const
Return the address space of this type.
Expression is not a Null pointer constant.
Expr * getSubExpr() const
CastKind getCastKind() const
static const FieldDecl * getTargetFieldForToUnionCast(QualType unionType, QualType opType)
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...
SourceLocation getEndLoc() const LLVM_READONLY
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
AccessSpecifier getAccess() const
bool isKnownToHaveBooleanValue() const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
Expr ** getInits()
Retrieve the set of initializers.
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
static DesignatedInitExpr * CreateEmpty(const ASTContext &C, unsigned NumIndexExprs)
Used for C's _Alignof and C++'s alignof.
const CXXRecordDecl * getBestDynamicClassType() const
For an expression of class type or pointer to class type, return the most derived class decl the expr...
Expr * getArrayRangeStart(const Designator &D) const
const ObjCMethodDecl * getMethodDecl() const
bool isVectorType() const
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
An rvalue ref-qualifier was provided (&&).
unsigned LBracketLoc
The location of the '[' starting the array range designator.
MemberExprBitfields MemberExprBits
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
LLVM_READONLY bool isPrintable(unsigned char c)
Return true if this character is an ASCII printable character; that is, a character that should take ...
void sawArrayRangeDesignator(bool ARD=true)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
static MemberExpr * Create(const ASTContext &C, Expr *base, bool isarrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *memberdecl, DeclAccessPair founddecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *targs, QualType ty, ExprValueKind VK, ExprObjectKind OK)
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
A POD class for pairing a NamedDecl* with an access specifier.
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
void * Allocate(size_t Size, unsigned Align=8) const
Represents a C11 generic selection.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getDesignatorsSourceRange() const
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Dataflow Directional Tag Classes.
static GenericSelectionExpr * CreateEmpty(const ASTContext &Context, unsigned NumAssocs)
Create an empty generic selection expression for deserialization.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getBeginLoc() const LLVM_READONLY
[C99 6.4.2.2] - A predefined identifier such as func.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
EvalResult is a struct with detailed info about an evaluated expression.
bool hasSideEffects(Expr *E, ASTContext &Ctx)
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Decl * getReferencedDeclOfCallee()
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
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isBooleanType() const
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
void resize(const ASTContext &C, unsigned N, const T &NV)
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr *> semantic, unsigned resultIndex)
void setInstantiationDependent(bool ID)
Set whether this expression is instantiation-dependent or not.
Expression is a C++11 nullptr.
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
unsigned getNumElements() const
getNumElements - Get the number of components being selected.
semantics_iterator semantics_begin()
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
ExplicitCastExpr - An explicit cast written in the source code.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
Expr * IgnoreParenImpCasts() LLVM_READONLY
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.
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.
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.
NamedDecl * getConversionFunction() const
If this cast applies a user-defined conversion, retrieve the conversion function that it invokes...
UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits
Represents a base class of a C++ class.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
A use of a default initializer in a constructor or in aggregate initialization.
A template argument list.
static CStyleCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize)
static const Expr * skipTemporaryBindingsNoOpCastsAndParens(const Expr *E)
Skip over any no-op casts and any temporary-binding expressions.
bool refersToGlobalRegisterVar() const
Returns whether this expression refers to a global register variable.
bool isUnusedResultAWarning(const Expr *&WarnExpr, SourceLocation &Loc, SourceRange &R1, SourceRange &R2, ASTContext &Ctx) const
isUnusedResultAWarning - Return true if this immediate expression should be warned about if the resul...
void reserve(const ASTContext &C, unsigned N)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Expression is a Null pointer constant built from a literal zero.
void Deallocate(void *Ptr) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
CallingConv getCallConv() const
Represents a C++ struct/union/class.
bool isSyntacticForm() const
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr *> Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
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...
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.