31 #include "llvm/Support/ErrorHandling.h" 32 #include "llvm/Support/raw_ostream.h" 35 using namespace clang;
43 if (
auto *BO = dyn_cast<BinaryOperator>(E)) {
44 if (BO->getOpcode() == BO_Comma) {
51 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
52 E = MTE->GetTemporaryExpr();
73 return cast<CXXRecordDecl>(D);
83 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
84 if ((CE->getCastKind() == CK_DerivedToBase ||
85 CE->getCastKind() == CK_UncheckedDerivedToBase) &&
94 if (CE->getCastKind() == CK_NoOp) {
98 }
else if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
100 assert(ME->getBase()->getType()->isRecordType());
101 if (
FieldDecl *Field = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
102 if (!Field->isBitField() && !Field->getType()->isReferenceType()) {
109 }
else if (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
110 if (BO->getOpcode() == BO_PtrMemD) {
111 assert(BO->getRHS()->isRValue());
117 }
else if (BO->getOpcode() == BO_Comma) {
118 CommaLHSs.push_back(BO->getLHS());
143 switch (UO->getOpcode()) {
145 return UO->getSubExpr()->isKnownToHaveBooleanValue();
156 return CE->getSubExpr()->isKnownToHaveBooleanValue();
159 switch (BO->getOpcode()) {
160 default:
return false;
175 return BO->getLHS()->isKnownToHaveBooleanValue() &&
176 BO->getRHS()->isKnownToHaveBooleanValue();
180 return BO->getRHS()->isKnownToHaveBooleanValue();
185 return CO->getTrueExpr()->isKnownToHaveBooleanValue() &&
186 CO->getFalseExpr()->isKnownToHaveBooleanValue();
198 template <
class E,
class T>
218 #define ABSTRACT_STMT(type) 219 #define STMT(type, base) \ 220 case Stmt::type##Class: break; 221 #define EXPR(type, base) \ 222 case Stmt::type##Class: return getExprLocImpl<type>(this, &type::getExprLoc); 223 #include "clang/AST/StmtNodes.inc" 225 llvm_unreachable(
"unknown expression kind");
237 bool &ValueDependent,
238 bool &InstantiationDependent) {
239 TypeDependent =
false;
240 ValueDependent =
false;
241 InstantiationDependent =
false;
254 TypeDependent =
true;
255 ValueDependent =
true;
256 InstantiationDependent =
true;
259 InstantiationDependent =
true;
267 TypeDependent =
true;
268 ValueDependent =
true;
269 InstantiationDependent =
true;
274 InstantiationDependent =
true;
278 if (isa<NonTypeTemplateParmDecl>(D)) {
279 ValueDependent =
true;
280 InstantiationDependent =
true;
291 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
293 Var->getType()->isLiteralType(Ctx) :
294 Var->getType()->isIntegralOrEnumerationType()) &&
295 (Var->getType().isConstQualified() ||
296 Var->getType()->isReferenceType())) {
297 if (
const Expr *Init = Var->getAnyInitializer())
298 if (Init->isValueDependent()) {
299 ValueDependent =
true;
300 InstantiationDependent =
true;
307 if (Var->isStaticDataMember() &&
308 Var->getDeclContext()->isDependentContext()) {
309 ValueDependent =
true;
310 InstantiationDependent =
true;
313 TypeDependent =
true;
323 ValueDependent =
true;
324 InstantiationDependent =
true;
328 void DeclRefExpr::computeDependence(
const ASTContext &Ctx) {
329 bool TypeDependent =
false;
330 bool ValueDependent =
false;
331 bool InstantiationDependent =
false;
333 ValueDependent, InstantiationDependent);
335 ExprBits.TypeDependent |= TypeDependent;
336 ExprBits.ValueDependent |= ValueDependent;
337 ExprBits.InstantiationDependent |= InstantiationDependent;
340 if (getDecl()->isParameterPack())
341 ExprBits.ContainsUnexpandedParameterPack =
true;
345 bool RefersToEnclosingVariableOrCapture,
QualType T,
349 D(D), DNLoc(LocInfo) {
355 RefersToEnclosingVariableOrCapture;
357 computeDependence(Ctx);
360 DeclRefExpr::DeclRefExpr(
const ASTContext &Ctx,
363 bool RefersToEnclosingVariableOrCapture,
367 :
Expr(DeclRefExprClass, T, VK,
OK_Ordinary,
false,
false,
false,
false),
368 D(D), DNLoc(NameInfo.
getInfo()) {
372 new (getTrailingObjects<NestedNameSpecifierLoc>())
375 if (NNS->isInstantiationDependent())
376 ExprBits.InstantiationDependent =
true;
377 if (NNS->containsUnexpandedParameterPack())
378 ExprBits.ContainsUnexpandedParameterPack =
true;
382 *getTrailingObjects<NamedDecl *>() = FoundD;
384 = (TemplateArgs || TemplateKWLoc.
isValid()) ? 1 : 0;
386 RefersToEnclosingVariableOrCapture;
388 bool Dependent =
false;
389 bool InstantiationDependent =
false;
390 bool ContainsUnexpandedParameterPack =
false;
391 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
392 TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
393 Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
394 assert(!Dependent &&
"built a DeclRefExpr with dependent template args");
395 ExprBits.InstantiationDependent |= InstantiationDependent;
396 ExprBits.ContainsUnexpandedParameterPack |= ContainsUnexpandedParameterPack;
397 }
else if (TemplateKWLoc.
isValid()) {
398 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
403 computeDependence(Ctx);
410 bool RefersToEnclosingVariableOrCapture,
416 return Create(Context, QualifierLoc, TemplateKWLoc, D,
417 RefersToEnclosingVariableOrCapture,
419 T, VK, FoundD, TemplateArgs);
426 bool RefersToEnclosingVariableOrCapture,
436 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
440 QualifierLoc ? 1 : 0, FoundD ? 1 : 0,
441 HasTemplateKWAndArgsInfo ? 1 : 0,
442 TemplateArgs ? TemplateArgs->
size() : 0);
445 return new (Mem)
DeclRefExpr(Context, QualifierLoc, TemplateKWLoc, D,
446 RefersToEnclosingVariableOrCapture,
447 NameInfo, FoundD, TemplateArgs, T, VK);
453 bool HasTemplateKWAndArgsInfo,
454 unsigned NumTemplateArgs) {
455 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
459 HasQualifier ? 1 : 0, HasFoundDecl ? 1 : 0, HasTemplateKWAndArgsInfo,
483 assert((getIdentKind() == IK) &&
484 "IdentKind do not fit in PredefinedExprBitfields!");
485 bool HasFunctionName = SL !=
nullptr;
492 PredefinedExpr::PredefinedExpr(
EmptyShell Empty,
bool HasFunctionName)
493 :
Expr(PredefinedExprClass, Empty) {
500 bool HasFunctionName = SL !=
nullptr;
501 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
507 bool HasFunctionName) {
508 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
518 return "__FUNCTION__";
520 return "__FUNCDNAME__";
522 return "L__FUNCTION__";
524 return "__PRETTY_FUNCTION__";
526 return "__FUNCSIG__";
528 return "L__FUNCSIG__";
529 case PrettyFunctionNoVirtual:
532 llvm_unreachable(
"Unknown ident kind for PredefinedExpr");
541 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(CurrentDecl)) {
542 std::unique_ptr<MangleContext> MC;
545 if (MC->shouldMangleDeclName(ND)) {
547 llvm::raw_svector_ostream Out(Buffer);
553 MC->mangleName(ND, Out);
555 if (!Buffer.empty() && Buffer.front() ==
'\01')
556 return Buffer.substr(1);
559 return ND->getIdentifier()->getName();
563 if (isa<BlockDecl>(CurrentDecl)) {
568 if (DC->isFileContext())
572 llvm::raw_svector_ostream Out(Buffer);
573 if (
auto *DCBlock = dyn_cast<BlockDecl>(DC))
575 Out << ComputeName(IK, DCBlock);
576 else if (
auto *DCDecl = dyn_cast<Decl>(DC))
577 Out << ComputeName(IK, DCDecl) <<
"_block_invoke";
580 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
581 if (IK != PrettyFunction && IK != PrettyFunctionNoVirtual &&
582 IK != FuncSig && IK != LFuncSig)
583 return FD->getNameAsString();
586 llvm::raw_svector_ostream Out(Name);
589 if (MD->isVirtual() && IK != PrettyFunctionNoVirtual)
597 llvm::raw_string_ostream POut(Proto);
604 if (FD->hasWrittenPrototype())
605 FT = dyn_cast<FunctionProtoType>(AFT);
607 if (IK == FuncSig || IK == LFuncSig) {
609 case CC_C: POut <<
"__cdecl ";
break;
620 FD->printQualifiedName(POut, Policy);
624 for (
unsigned i = 0, e = Decl->
getNumParams(); i != e; ++i) {
629 if (FT->isVariadic()) {
630 if (FD->getNumParams()) POut <<
", ";
632 }
else if ((IK == FuncSig || IK == LFuncSig ||
641 assert(FT &&
"We must have a written prototype in this case.");
644 if (FT->isVolatile())
656 while (Ctx && isa<NamedDecl>(Ctx)) {
660 Specs.push_back(Spec);
664 std::string TemplateParams;
665 llvm::raw_string_ostream TOut(TemplateParams);
666 for (SpecsTy::reverse_iterator I = Specs.rbegin(), E = Specs.rend();
669 = (*I)->getSpecializedTemplate()->getTemplateParameters();
671 assert(Params->
size() == Args.
size());
672 for (
unsigned i = 0, numParams = Params->
size(); i != numParams; ++i) {
674 if (Param.empty())
continue;
675 TOut << Param <<
" = ";
682 = FD->getTemplateSpecializationInfo();
687 assert(Params->
size() == Args->
size());
688 for (
unsigned i = 0, e = Params->
size(); i != e; ++i) {
690 if (Param.empty())
continue;
691 TOut << Param <<
" = ";
698 if (!TemplateParams.empty()) {
700 TemplateParams.resize(TemplateParams.size() - 2);
701 POut <<
" [" << TemplateParams <<
"]";
710 if (isa<CXXMethodDecl>(FD) &&
711 cast<CXXMethodDecl>(FD)->getParent()->isLambda())
712 Proto =
"auto " + Proto;
713 else if (FT && FT->getReturnType()->getAs<
DecltypeType>())
718 else if (!isa<CXXConstructorDecl>(FD) && !isa<CXXDestructorDecl>(FD))
723 return Name.str().str();
725 if (
const CapturedDecl *CD = dyn_cast<CapturedDecl>(CurrentDecl)) {
729 if (DC->isFunctionOrMethod() && (DC->getDeclKind() != Decl::Captured)) {
731 return ComputeName(IK, D);
733 llvm_unreachable(
"CapturedDecl not inside a function or method");
735 if (
const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(CurrentDecl)) {
737 llvm::raw_svector_ostream Out(Name);
738 Out << (MD->isInstanceMethod() ?
'-' :
'+');
747 dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext()))
748 Out <<
'(' << *CID <<
')';
751 MD->getSelector().print(Out);
754 return Name.str().str();
756 if (isa<TranslationUnitDecl>(CurrentDecl) && IK == PrettyFunction) {
764 const llvm::APInt &Val) {
768 BitWidth = Val.getBitWidth();
769 unsigned NumWords = Val.getNumWords();
770 const uint64_t* Words = Val.getRawData();
772 pVal =
new (
C) uint64_t[NumWords];
773 std::copy(Words, Words + NumWords, pVal);
774 }
else if (NumWords == 1)
780 IntegerLiteral::IntegerLiteral(
const ASTContext &
C,
const llvm::APInt &V,
785 assert(type->
isIntegerType() &&
"Illegal type in IntegerLiteral");
787 "Integer type is not the correct size for constant.");
802 FixedPointLiteral::FixedPointLiteral(
const ASTContext &
C,
const llvm::APInt &V,
807 Loc(l), Scale(Scale) {
810 "Fixed point type is not the correct size for constant.");
815 const llvm::APInt &V,
828 S, llvm::APSInt::getUnsigned(
getValue().getZExtValue()), Scale);
832 FloatingLiteral::FloatingLiteral(
const ASTContext &
C,
const llvm::APFloat &V,
835 false,
false), Loc(L) {
836 setSemantics(V.getSemantics());
842 :
Expr(FloatingLiteralClass, Empty) {
861 return llvm::APFloat::IEEEhalf();
863 return llvm::APFloat::IEEEsingle();
865 return llvm::APFloat::IEEEdouble();
867 return llvm::APFloat::x87DoubleExtended();
869 return llvm::APFloat::IEEEquad();
871 return llvm::APFloat::PPCDoubleDouble();
873 llvm_unreachable(
"Unrecognised floating semantics");
877 if (&Sem == &llvm::APFloat::IEEEhalf())
879 else if (&Sem == &llvm::APFloat::IEEEsingle())
881 else if (&Sem == &llvm::APFloat::IEEEdouble())
883 else if (&Sem == &llvm::APFloat::x87DoubleExtended())
885 else if (&Sem == &llvm::APFloat::IEEEquad())
887 else if (&Sem == &llvm::APFloat::PPCDoubleDouble())
890 llvm_unreachable(
"Unknown floating semantics");
899 V.convert(llvm::APFloat::IEEEdouble(), llvm::APFloat::rmNearestTiesToEven,
901 return V.convertToDouble();
906 unsigned CharByteWidth = 0;
922 assert((CharByteWidth & 7) == 0 &&
"Assumes character size is byte multiple");
924 assert((CharByteWidth == 1 || CharByteWidth == 2 || CharByteWidth == 4) &&
925 "The only supported character byte widths are 1,2 and 4!");
926 return CharByteWidth;
929 StringLiteral::StringLiteral(
const ASTContext &Ctx, StringRef Str,
932 unsigned NumConcatenated)
936 "StringLiteral must be of constant array type!");
938 unsigned ByteLength = Str.size();
939 assert((ByteLength % CharByteWidth == 0) &&
940 "The size of the data must be a multiple of CharByteWidth!");
946 switch (CharByteWidth) {
951 Length = ByteLength / 2;
954 Length = ByteLength / 4;
957 llvm_unreachable(
"Unsupported character width!");
964 *getTrailingObjects<unsigned>() = Length;
968 std::memcpy(getTrailingObjects<SourceLocation>(), Loc,
972 std::memcpy(getTrailingObjects<char>(), Str.data(), ByteLength);
975 StringLiteral::StringLiteral(
EmptyShell Empty,
unsigned NumConcatenated,
976 unsigned Length,
unsigned CharByteWidth)
977 :
Expr(StringLiteralClass, Empty) {
980 *getTrailingObjects<unsigned>() = Length;
986 unsigned NumConcatenated) {
987 void *Mem = Ctx.
Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
988 1, NumConcatenated, Str.size()),
991 StringLiteral(Ctx, Str, Kind, Pascal, Ty, Loc, NumConcatenated);
995 unsigned NumConcatenated,
997 unsigned CharByteWidth) {
998 void *Mem = Ctx.
Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
999 1, NumConcatenated, Length * CharByteWidth),
1008 case Wide: OS <<
'L';
break;
1009 case UTF8: OS <<
"u8";
break;
1010 case UTF16: OS <<
'u';
break;
1011 case UTF32: OS <<
'U';
break;
1014 static const char Hex[] =
"0123456789ABCDEF";
1016 unsigned LastSlashX = getLength();
1017 for (
unsigned I = 0, N = getLength(); I != N; ++I) {
1018 switch (uint32_t Char = getCodeUnit(I)) {
1024 if (
getKind() == UTF16 && I != N - 1 && Char >= 0xd800 &&
1026 uint32_t Trail = getCodeUnit(I + 1);
1027 if (Trail >= 0xdc00 && Trail <= 0xdfff) {
1028 Char = 0x10000 + ((Char - 0xd800) << 10) + (Trail - 0xdc00);
1038 (Char >= 0xd800 && Char <= 0xdfff) || Char >= 0x110000) {
1042 while ((Char >> Shift) == 0)
1044 for (; Shift >= 0; Shift -= 4)
1045 OS << Hex[(Char >> Shift) & 15];
1052 << Hex[(Char >> 20) & 15]
1053 << Hex[(Char >> 16) & 15];
1056 OS << Hex[(Char >> 12) & 15]
1057 << Hex[(Char >> 8) & 15]
1058 << Hex[(Char >> 4) & 15]
1059 << Hex[(Char >> 0) & 15];
1065 if (LastSlashX + 1 == I) {
1067 case '0':
case '1':
case '2':
case '3':
case '4':
1068 case '5':
case '6':
case '7':
case '8':
case '9':
1069 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
1070 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
1075 assert(Char <= 0xff &&
1076 "Characters above 0xff should already have been handled.");
1082 << (char)(
'0' + ((Char >> 6) & 7))
1083 << (char)(
'0' + ((Char >> 3) & 7))
1084 << (char)(
'0' + ((Char >> 0) & 7));
1087 case '\\': OS <<
"\\\\";
break;
1088 case '"': OS <<
"\\\"";
break;
1089 case '\a': OS <<
"\\a";
break;
1090 case '\b': OS <<
"\\b";
break;
1091 case '\f': OS <<
"\\f";
break;
1092 case '\n': OS <<
"\\n";
break;
1093 case '\r': OS <<
"\\r";
break;
1094 case '\t': OS <<
"\\t";
break;
1095 case '\v': OS <<
"\\v";
break;
1120 const TargetInfo &Target,
unsigned *StartToken,
1121 unsigned *StartTokenByteOffset)
const {
1124 "Only narrow string literals are currently supported");
1129 unsigned StringOffset = 0;
1131 TokNo = *StartToken;
1132 if (StartTokenByteOffset) {
1133 StringOffset = *StartTokenByteOffset;
1134 ByteNo -= StringOffset;
1137 assert(TokNo < getNumConcatenated() &&
"Invalid byte number!");
1146 std::pair<FileID, unsigned> LocInfo =
1148 bool Invalid =
false;
1149 StringRef Buffer = SM.
getBufferData(LocInfo.first, &Invalid);
1151 if (StartTokenByteOffset !=
nullptr)
1152 *StartTokenByteOffset = StringOffset;
1153 if (StartToken !=
nullptr)
1154 *StartToken = TokNo;
1155 return StrTokSpellingLoc;
1158 const char *StrData = Buffer.data()+LocInfo.second;
1162 Buffer.begin(), StrData, Buffer.end());
1164 TheLexer.LexFromRawLexer(TheTok);
1171 if (ByteNo < TokNumBytes ||
1172 (ByteNo == TokNumBytes && TokNo == getNumConcatenated() - 1)) {
1177 if (StartTokenByteOffset !=
nullptr)
1178 *StartTokenByteOffset = StringOffset;
1179 if (StartToken !=
nullptr)
1180 *StartToken = TokNo;
1185 StringOffset += TokNumBytes;
1187 ByteNo -= TokNumBytes;
1195 #define UNARY_OPERATION(Name, Spelling) case UO_##Name: return Spelling; 1196 #include "clang/AST/OperationKinds.def" 1198 llvm_unreachable(
"Unknown unary operator");
1204 default: llvm_unreachable(
"No unary operator for overloaded function");
1205 case OO_PlusPlus:
return Postfix ? UO_PostInc : UO_PreInc;
1206 case OO_MinusMinus:
return Postfix ? UO_PostDec : UO_PreDec;
1207 case OO_Amp:
return UO_AddrOf;
1208 case OO_Star:
return UO_Deref;
1209 case OO_Plus:
return UO_Plus;
1210 case OO_Minus:
return UO_Minus;
1211 case OO_Tilde:
return UO_Not;
1212 case OO_Exclaim:
return UO_LNot;
1213 case OO_Coawait:
return UO_Coawait;
1219 case UO_PostInc:
case UO_PreInc:
return OO_PlusPlus;
1220 case UO_PostDec:
case UO_PreDec:
return OO_MinusMinus;
1221 case UO_AddrOf:
return OO_Amp;
1222 case UO_Deref:
return OO_Star;
1223 case UO_Plus:
return OO_Plus;
1224 case UO_Minus:
return OO_Minus;
1225 case UO_Not:
return OO_Tilde;
1226 case UO_LNot:
return OO_Exclaim;
1227 case UO_Coawait:
return OO_Coawait;
1244 RParenLoc(RParenLoc) {
1245 NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1246 unsigned NumPreArgs = PreArgs.size();
1248 assert((NumPreArgs ==
getNumPreArgs()) &&
"NumPreArgs overflow!");
1250 unsigned OffsetToTrailingObjects = offsetToTrailingObjects(SC);
1251 CallExprBits.OffsetToTrailingObjects = OffsetToTrailingObjects;
1252 assert((
CallExprBits.OffsetToTrailingObjects == OffsetToTrailingObjects) &&
1253 "OffsetToTrailingObjects overflow!");
1258 for (
unsigned I = 0; I != NumPreArgs; ++I) {
1259 updateDependenciesFromArg(PreArgs[I]);
1262 for (
unsigned I = 0; I != Args.size(); ++I) {
1263 updateDependenciesFromArg(Args[I]);
1266 for (
unsigned I = Args.size(); I != NumArgs; ++I) {
1273 :
Expr(SC, Empty), NumArgs(NumArgs) {
1275 assert((NumPreArgs ==
getNumPreArgs()) &&
"NumPreArgs overflow!");
1277 unsigned OffsetToTrailingObjects = offsetToTrailingObjects(SC);
1278 CallExprBits.OffsetToTrailingObjects = OffsetToTrailingObjects;
1279 assert((
CallExprBits.OffsetToTrailingObjects == OffsetToTrailingObjects) &&
1280 "OffsetToTrailingObjects overflow!");
1287 unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1288 unsigned SizeOfTrailingObjects =
1292 return new (Mem)
CallExpr(CallExprClass, Fn, {}, Args, Ty, VK,
1293 RParenLoc, MinNumArgs,
UsesADL);
1299 assert(!(reinterpret_cast<uintptr_t>(Mem) %
alignof(
CallExpr)) &&
1300 "Misaligned memory in CallExpr::CreateTemporary!");
1301 return new (Mem)
CallExpr(CallExprClass, Fn, {}, {}, Ty,
1307 unsigned SizeOfTrailingObjects =
1311 return new (Mem)
CallExpr(CallExprClass, 0, NumArgs, Empty);
1314 unsigned CallExpr::offsetToTrailingObjects(
StmtClass SC) {
1318 case CXXOperatorCallExprClass:
1320 case CXXMemberCallExprClass:
1322 case UserDefinedLiteralClass:
1324 case CUDAKernelCallExprClass:
1327 llvm_unreachable(
"unexpected class deriving from CallExpr!");
1331 void CallExpr::updateDependenciesFromArg(
Expr *Arg) {
1337 ExprBits.InstantiationDependent =
true;
1339 ExprBits.ContainsUnexpandedParameterPack =
true;
1346 = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE)) {
1352 if (BO->isPtrMemOp())
1354 }
else if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(CEE)) {
1355 if (UO->getOpcode() == UO_Deref)
1358 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE))
1359 return DRE->getDecl();
1360 if (
MemberExpr *ME = dyn_cast<MemberExpr>(CEE))
1361 return ME->getMemberDecl();
1404 if (isa<CXXPseudoDestructorExpr>(Callee->
IgnoreParens()))
1419 if (
const auto *A = TD->getAttr<WarnUnusedResultAttr>())
1425 return D ? D->
getAttr<WarnUnusedResultAttr>() :
nullptr;
1429 if (isa<CXXOperatorCallExpr>(
this))
1430 return cast<CXXOperatorCallExpr>(
this)->
getBeginLoc();
1438 if (isa<CXXOperatorCallExpr>(
this))
1439 return cast<CXXOperatorCallExpr>(
this)->
getEndLoc();
1454 totalSizeToAlloc<OffsetOfNode, Expr *>(comps.size(), exprs.size()));
1456 return new (Mem)
OffsetOfExpr(C, type, OperatorLoc, tsi, comps, exprs,
1461 unsigned numComps,
unsigned numExprs) {
1463 C.
Allocate(totalSizeToAlloc<OffsetOfNode, Expr *>(numComps, numExprs));
1476 OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
1477 NumComps(comps.size()), NumExprs(exprs.size())
1479 for (
unsigned i = 0; i != comps.size(); ++i) {
1480 setComponent(i, comps[i]);
1483 for (
unsigned i = 0; i != exprs.size(); ++i) {
1487 ExprBits.ContainsUnexpandedParameterPack =
true;
1489 setIndexExpr(i, exprs[i]);
1496 return getField()->getIdentifier();
1509 OpLoc(op), RParenLoc(rp) {
1521 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
1523 else if (
const auto *ME = dyn_cast<MemberExpr>(E))
1524 D = ME->getMemberDecl();
1528 if (I->isAlignmentDependent()) {
1546 bool hasQualOrFound = (QualifierLoc ||
1547 founddecl.
getDecl() != memberdecl ||
1550 bool HasTemplateKWAndArgsInfo = targs || TemplateKWLoc.
isValid();
1554 HasTemplateKWAndArgsInfo ? 1 : 0,
1555 targs ? targs->
size() : 0);
1559 MemberExpr(base, isarrow, OperatorLoc, memberdecl, nameinfo, ty, vk, ok);
1561 if (hasQualOrFound) {
1568 else if (QualifierLoc &&
1574 MemberExprNameQualifier *NQ =
1575 E->getTrailingObjects<MemberExprNameQualifier>();
1581 (targs || TemplateKWLoc.
isValid());
1584 bool Dependent =
false;
1585 bool InstantiationDependent =
false;
1586 bool ContainsUnexpandedParameterPack =
false;
1587 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1589 Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
1590 if (InstantiationDependent)
1592 }
else if (TemplateKWLoc.
isValid()) {
1593 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1601 if (isImplicitAccess()) {
1603 return getQualifierLoc().getBeginLoc();
1611 return BaseStartLoc;
1616 if (hasExplicitTemplateArgs())
1617 EndLoc = getRAngleLoc();
1619 EndLoc = getBase()->getEndLoc();
1623 bool CastExpr::CastConsistency()
const {
1624 switch (getCastKind()) {
1625 case CK_DerivedToBase:
1626 case CK_UncheckedDerivedToBase:
1627 case CK_DerivedToBaseMemberPointer:
1628 case CK_BaseToDerived:
1629 case CK_BaseToDerivedMemberPointer:
1630 assert(!path_empty() &&
"Cast kind should have a base path!");
1633 case CK_CPointerToObjCPointerCast:
1634 assert(
getType()->isObjCObjectPointerType());
1635 assert(getSubExpr()->
getType()->isPointerType());
1636 goto CheckNoBasePath;
1638 case CK_BlockPointerToObjCPointerCast:
1639 assert(
getType()->isObjCObjectPointerType());
1640 assert(getSubExpr()->
getType()->isBlockPointerType());
1641 goto CheckNoBasePath;
1643 case CK_ReinterpretMemberPointer:
1644 assert(
getType()->isMemberPointerType());
1645 assert(getSubExpr()->
getType()->isMemberPointerType());
1646 goto CheckNoBasePath;
1652 if (!
getType()->isPointerType()) {
1653 assert(
getType()->isObjCObjectPointerType() ==
1654 getSubExpr()->
getType()->isObjCObjectPointerType());
1655 assert(
getType()->isBlockPointerType() ==
1656 getSubExpr()->
getType()->isBlockPointerType());
1658 goto CheckNoBasePath;
1660 case CK_AnyPointerToBlockPointerCast:
1661 assert(
getType()->isBlockPointerType());
1662 assert(getSubExpr()->
getType()->isAnyPointerType() &&
1663 !getSubExpr()->
getType()->isBlockPointerType());
1664 goto CheckNoBasePath;
1666 case CK_CopyAndAutoreleaseBlockObject:
1667 assert(
getType()->isBlockPointerType());
1668 assert(getSubExpr()->
getType()->isBlockPointerType());
1669 goto CheckNoBasePath;
1671 case CK_FunctionToPointerDecay:
1672 assert(
getType()->isPointerType());
1673 assert(getSubExpr()->
getType()->isFunctionType());
1674 goto CheckNoBasePath;
1676 case CK_AddressSpaceConversion: {
1678 auto SETy = getSubExpr()->getType();
1684 assert(!Ty.
isNull() && !SETy.isNull() &&
1686 goto CheckNoBasePath;
1691 case CK_ArrayToPointerDecay:
1692 case CK_NullToMemberPointer:
1693 case CK_NullToPointer:
1694 case CK_ConstructorConversion:
1695 case CK_IntegralToPointer:
1696 case CK_PointerToIntegral:
1698 case CK_VectorSplat:
1699 case CK_IntegralCast:
1700 case CK_BooleanToSignedIntegral:
1701 case CK_IntegralToFloating:
1702 case CK_FloatingToIntegral:
1703 case CK_FloatingCast:
1704 case CK_ObjCObjectLValueCast:
1705 case CK_FloatingRealToComplex:
1706 case CK_FloatingComplexToReal:
1707 case CK_FloatingComplexCast:
1708 case CK_FloatingComplexToIntegralComplex:
1709 case CK_IntegralRealToComplex:
1710 case CK_IntegralComplexToReal:
1711 case CK_IntegralComplexCast:
1712 case CK_IntegralComplexToFloatingComplex:
1713 case CK_ARCProduceObject:
1714 case CK_ARCConsumeObject:
1715 case CK_ARCReclaimReturnedObject:
1716 case CK_ARCExtendBlockObject:
1717 case CK_ZeroToOCLOpaqueType:
1718 case CK_IntToOCLSampler:
1719 case CK_FixedPointCast:
1721 goto CheckNoBasePath;
1724 case CK_LValueToRValue:
1726 case CK_AtomicToNonAtomic:
1727 case CK_NonAtomicToAtomic:
1728 case CK_PointerToBoolean:
1729 case CK_IntegralToBoolean:
1730 case CK_FloatingToBoolean:
1731 case CK_MemberPointerToBoolean:
1732 case CK_FloatingComplexToBoolean:
1733 case CK_IntegralComplexToBoolean:
1734 case CK_LValueBitCast:
1735 case CK_UserDefinedConversion:
1736 case CK_BuiltinFnToFnPtr:
1737 case CK_FixedPointToBoolean:
1739 assert(path_empty() &&
"Cast kind should not have a base path!");
1747 #define CAST_OPERATION(Name) case CK_##Name: return #Name; 1748 #include "clang/AST/OperationKinds.def" 1750 llvm_unreachable(
"Unhandled cast kind!");
1754 const Expr *skipImplicitTemporary(
const Expr *E) {
1756 if (
auto *Materialize = dyn_cast<MaterializeTemporaryExpr>(E))
1757 E = Materialize->GetTemporaryExpr();
1760 if (
auto *Binder = dyn_cast<CXXBindTemporaryExpr>(E))
1761 E = Binder->getSubExpr();
1768 const Expr *SubExpr =
nullptr;
1771 SubExpr = skipImplicitTemporary(E->
getSubExpr());
1777 skipImplicitTemporary(cast<CXXConstructExpr>(SubExpr)->getArg(0));
1778 else if (E->
getCastKind() == CK_UserDefinedConversion) {
1779 assert((isa<CXXMemberCallExpr>(SubExpr) ||
1780 isa<BlockExpr>(SubExpr)) &&
1781 "Unexpected SubExpr for CK_UserDefinedConversion.");
1782 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
1783 SubExpr = MCE->getImplicitObjectArgument();
1788 }
while ((E = dyn_cast<ImplicitCastExpr>(SubExpr)));
1790 return const_cast<Expr*
>(SubExpr);
1794 const Expr *SubExpr =
nullptr;
1797 SubExpr = skipImplicitTemporary(E->getSubExpr());
1799 if (E->getCastKind() == CK_ConstructorConversion)
1800 return cast<CXXConstructExpr>(SubExpr)->getConstructor();
1802 if (E->getCastKind() == CK_UserDefinedConversion) {
1803 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
1804 return MCE->getMethodDecl();
1813 #define ABSTRACT_STMT(x) 1814 #define CASTEXPR(Type, Base) \ 1815 case Stmt::Type##Class: \ 1816 return static_cast<Type *>(this)->getTrailingObjects<CXXBaseSpecifier *>(); 1817 #define STMT(Type, Base) 1818 #include "clang/AST/StmtNodes.inc" 1820 llvm_unreachable(
"non-cast expressions not possible here");
1827 return getTargetFieldForToUnionCast(RD, opType);
1835 Field != FieldEnd; ++Field) {
1837 !Field->isUnnamedBitfield()) {
1848 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1849 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1853 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1859 unsigned PathSize) {
1860 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1870 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1871 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1873 new (Buffer)
CStyleCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, R);
1875 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1881 unsigned PathSize) {
1882 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1890 #define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling; 1891 #include "clang/AST/OperationKinds.def" 1893 llvm_unreachable(
"Invalid OpCode!");
1899 default: llvm_unreachable(
"Not an overloadable binary operator");
1900 case OO_Plus:
return BO_Add;
1901 case OO_Minus:
return BO_Sub;
1902 case OO_Star:
return BO_Mul;
1903 case OO_Slash:
return BO_Div;
1904 case OO_Percent:
return BO_Rem;
1905 case OO_Caret:
return BO_Xor;
1906 case OO_Amp:
return BO_And;
1907 case OO_Pipe:
return BO_Or;
1908 case OO_Equal:
return BO_Assign;
1909 case OO_Spaceship:
return BO_Cmp;
1910 case OO_Less:
return BO_LT;
1911 case OO_Greater:
return BO_GT;
1912 case OO_PlusEqual:
return BO_AddAssign;
1913 case OO_MinusEqual:
return BO_SubAssign;
1914 case OO_StarEqual:
return BO_MulAssign;
1915 case OO_SlashEqual:
return BO_DivAssign;
1916 case OO_PercentEqual:
return BO_RemAssign;
1917 case OO_CaretEqual:
return BO_XorAssign;
1918 case OO_AmpEqual:
return BO_AndAssign;
1919 case OO_PipeEqual:
return BO_OrAssign;
1920 case OO_LessLess:
return BO_Shl;
1921 case OO_GreaterGreater:
return BO_Shr;
1922 case OO_LessLessEqual:
return BO_ShlAssign;
1923 case OO_GreaterGreaterEqual:
return BO_ShrAssign;
1924 case OO_EqualEqual:
return BO_EQ;
1925 case OO_ExclaimEqual:
return BO_NE;
1926 case OO_LessEqual:
return BO_LE;
1927 case OO_GreaterEqual:
return BO_GE;
1928 case OO_AmpAmp:
return BO_LAnd;
1929 case OO_PipePipe:
return BO_LOr;
1930 case OO_Comma:
return BO_Comma;
1931 case OO_ArrowStar:
return BO_PtrMemI;
1938 OO_Star, OO_Slash, OO_Percent,
1940 OO_LessLess, OO_GreaterGreater,
1942 OO_Less, OO_Greater, OO_LessEqual, OO_GreaterEqual,
1943 OO_EqualEqual, OO_ExclaimEqual,
1949 OO_Equal, OO_StarEqual,
1950 OO_SlashEqual, OO_PercentEqual,
1951 OO_PlusEqual, OO_MinusEqual,
1952 OO_LessLessEqual, OO_GreaterGreaterEqual,
1953 OO_AmpEqual, OO_CaretEqual,
1957 return OverOps[Opc];
1996 InitExprs(C, initExprs.size()),
1997 LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(nullptr,
true)
2000 for (
unsigned I = 0; I != initExprs.size(); ++I) {
2006 ExprBits.InstantiationDependent =
true;
2008 ExprBits.ContainsUnexpandedParameterPack =
true;
2011 InitExprs.
insert(C, InitExprs.
end(), initExprs.begin(), initExprs.end());
2015 if (NumInits > InitExprs.
size())
2016 InitExprs.
reserve(C, NumInits);
2020 InitExprs.
resize(C, NumInits,
nullptr);
2024 if (Init >= InitExprs.
size()) {
2025 InitExprs.
insert(C, InitExprs.
end(), Init - InitExprs.
size() + 1,
nullptr);
2030 Expr *
Result = cast_or_null<Expr>(InitExprs[Init]);
2037 ArrayFillerOrUnionFieldInit = filler;
2040 for (
unsigned i = 0, e =
getNumInits(); i != e; ++i)
2041 if (inits[i] ==
nullptr)
2056 return isa<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init);
2060 assert(
isSemanticForm() &&
"syntactic form never semantically transparent");
2064 assert(
getNumInits() == 1 &&
"multiple inits in glvalue init list");
2083 assert(
isSyntacticForm() &&
"only test syntactic form as zero initializer");
2090 return Lit && Lit->
getValue() == 0;
2095 return SyntacticForm->getBeginLoc();
2100 E = InitExprs.
end();
2103 Beg = S->getBeginLoc();
2113 return SyntacticForm->getEndLoc();
2118 E = InitExprs.
rend();
2121 End = S->getEndLoc();
2133 return cast<BlockPointerType>(
getType())
2138 return TheBlock->getCaretLocation();
2141 return TheBlock->getBody();
2144 return TheBlock->getBody();
2172 case ParenExprClass:
2173 return cast<ParenExpr>(
this)->getSubExpr()->
2175 case GenericSelectionExprClass:
2176 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
2178 case CoawaitExprClass:
2179 case CoyieldExprClass:
2180 return cast<CoroutineSuspendExpr>(
this)->getResumeExpr()->
2182 case ChooseExprClass:
2183 return cast<ChooseExpr>(
this)->getChosenSubExpr()->
2185 case UnaryOperatorClass: {
2208 .isVolatileQualified())
2219 case BinaryOperatorClass: {
2231 if (IE->getValue() == 0)
2250 case CompoundAssignOperatorClass:
2251 case VAArgExprClass:
2252 case AtomicExprClass:
2255 case ConditionalOperatorClass: {
2267 case MemberExprClass:
2269 Loc = cast<MemberExpr>(
this)->getMemberLoc();
2271 R2 = cast<MemberExpr>(
this)->getBase()->getSourceRange();
2274 case ArraySubscriptExprClass:
2276 Loc = cast<ArraySubscriptExpr>(
this)->getRBracketLoc();
2277 R1 = cast<ArraySubscriptExpr>(
this)->getLHS()->getSourceRange();
2278 R2 = cast<ArraySubscriptExpr>(
this)->getRHS()->getSourceRange();
2281 case CXXOperatorCallExprClass: {
2293 case OO_ExclaimEqual:
2296 case OO_GreaterEqual:
2311 case CXXMemberCallExprClass:
2312 case UserDefinedLiteralClass: {
2314 const CallExpr *CE = cast<CallExpr>(
this);
2322 FD->hasAttr<PureAttr>() || FD->hasAttr<ConstAttr>()) {
2337 case UnresolvedLookupExprClass:
2338 case CXXUnresolvedConstructExprClass:
2341 case CXXTemporaryObjectExprClass:
2342 case CXXConstructExprClass: {
2344 if (Type->
hasAttr<WarnUnusedAttr>()) {
2354 case ObjCMessageExprClass: {
2367 if (MD->hasAttr<WarnUnusedResultAttr>()) {
2376 case ObjCPropertyRefExprClass:
2382 case PseudoObjectExprClass: {
2396 case StmtExprClass: {
2402 const CompoundStmt *CS = cast<StmtExpr>(
this)->getSubStmt();
2405 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2407 if (
const Expr *E = dyn_cast<Expr>(
Label->getSubStmt()))
2408 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2414 Loc = cast<StmtExpr>(
this)->getLParenLoc();
2418 case CXXFunctionalCastExprClass:
2419 case CStyleCastExprClass: {
2422 const CastExpr *CE = cast<CastExpr>(
this);
2428 if (!(DRE && isa<VarDecl>(DRE->
getDecl()) &&
2429 cast<VarDecl>(DRE->
getDecl())->hasLocalStorage()) &&
2440 if (CE->
getCastKind() == CK_ConstructorConversion)
2445 dyn_cast<CXXFunctionalCastExpr>(
this)) {
2446 Loc = CXXCE->getBeginLoc();
2447 R1 = CXXCE->getSubExpr()->getSourceRange();
2455 case ImplicitCastExprClass: {
2456 const CastExpr *ICE = cast<ImplicitCastExpr>(
this);
2465 case CXXDefaultArgExprClass:
2466 return (cast<CXXDefaultArgExpr>(
this)
2468 case CXXDefaultInitExprClass:
2469 return (cast<CXXDefaultInitExpr>(
this)
2472 case CXXNewExprClass:
2475 case CXXDeleteExprClass:
2477 case MaterializeTemporaryExprClass:
2478 return cast<MaterializeTemporaryExpr>(
this)->GetTemporaryExpr()
2479 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2480 case CXXBindTemporaryExprClass:
2481 return cast<CXXBindTemporaryExpr>(
this)->getSubExpr()
2482 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2483 case ExprWithCleanupsClass:
2484 return cast<ExprWithCleanups>(
this)->getSubExpr()
2485 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2496 case ObjCIvarRefExprClass:
2498 case Expr::UnaryOperatorClass:
2499 return cast<UnaryOperator>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2500 case ImplicitCastExprClass:
2501 return cast<ImplicitCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2502 case MaterializeTemporaryExprClass:
2503 return cast<MaterializeTemporaryExpr>(E)->GetTemporaryExpr()
2504 ->isOBJCGCCandidate(Ctx);
2505 case CStyleCastExprClass:
2506 return cast<CStyleCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2507 case DeclRefExprClass: {
2508 const Decl *D = cast<DeclRefExpr>(E)->getDecl();
2510 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2511 if (VD->hasGlobalStorage())
2521 case MemberExprClass: {
2525 case ArraySubscriptExprClass:
2526 return cast<ArraySubscriptExpr>(E)->getBase()->isOBJCGCCandidate(Ctx);
2544 if (
const MemberExpr *mem = dyn_cast<MemberExpr>(expr)) {
2545 assert(isa<CXXMethodDecl>(mem->getMemberDecl()));
2546 return mem->getMemberDecl()->getType();
2556 assert(isa<UnresolvedMemberExpr>(expr) || isa<CXXPseudoDestructorExpr>(expr));
2564 E =
P->getSubExpr();
2568 if (
P->getOpcode() == UO_Extension) {
2569 E =
P->getSubExpr();
2574 if (!
P->isResultDependent()) {
2575 E =
P->getResultExpr();
2580 if (!
P->isConditionDependent()) {
2581 E =
P->getChosenSubExpr();
2586 E = CE->getSubExpr();
2599 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2600 E =
P->getSubExpr();
2604 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2605 E = Materialize->GetTemporaryExpr();
2609 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2610 E = NTTP->getReplacement();
2613 if (
FullExpr *FE = dyn_cast<FullExpr>(E)) {
2614 E = FE->getSubExpr();
2624 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2625 E =
P->getSubExpr();
2629 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2630 E = Materialize->GetTemporaryExpr();
2634 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2635 E = NTTP->getReplacement();
2638 if (
FullExpr *FE = dyn_cast<FullExpr>(E)) {
2639 E = FE->getSubExpr();
2654 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2655 if (
P->getCastKind() == CK_LValueToRValue) {
2656 E =
P->getSubExpr();
2660 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2661 E = Materialize->GetTemporaryExpr();
2664 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2665 E = NTTP->getReplacement();
2667 }
else if (
FullExpr *FE = dyn_cast<FullExpr>(E)) {
2668 E = FE->getSubExpr();
2680 if (
CastExpr *CE = dyn_cast<CastExpr>(E)) {
2681 if (CE->getCastKind() == CK_DerivedToBase ||
2682 CE->getCastKind() == CK_UncheckedDerivedToBase ||
2683 CE->getCastKind() == CK_NoOp) {
2684 E = CE->getSubExpr();
2698 E =
P->getSubExpr();
2702 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2703 E = Materialize->GetTemporaryExpr();
2707 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2708 E = NTTP->getReplacement();
2717 if (MCE->getMethodDecl() && isa<CXXConversionDecl>(MCE->getMethodDecl()))
2718 return MCE->getImplicitObjectArgument();
2731 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2734 Expr *SE =
P->getSubExpr();
2752 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2753 E = NTTP->getReplacement();
2762 const Expr *E =
this;
2764 E = M->GetTemporaryExpr();
2767 E = ICE->getSubExprAsWritten();
2769 return isa<CXXDefaultArgExpr>(E);
2776 E = M->GetTemporaryExpr();
2779 if (ICE->getCastKind() == CK_NoOp)
2780 E = ICE->getSubExpr();
2786 E = BE->getSubExpr();
2789 if (ICE->getCastKind() == CK_NoOp)
2790 E = ICE->getSubExpr();
2809 if (!isa<ObjCPropertyRefExpr>(E))
2817 if (isa<ImplicitCastExpr>(E)) {
2818 switch (cast<ImplicitCastExpr>(E)->getCastKind()) {
2819 case CK_DerivedToBase:
2820 case CK_UncheckedDerivedToBase:
2828 if (isa<MemberExpr>(E))
2832 if (BO->isPtrMemOp())
2836 if (isa<OpaqueValueExpr>(E))
2843 const Expr *E =
this;
2848 E =
Paren->getSubExpr();
2853 if (ICE->getCastKind() == CK_NoOp ||
2854 ICE->getCastKind() == CK_LValueToRValue ||
2855 ICE->getCastKind() == CK_DerivedToBase ||
2856 ICE->getCastKind() == CK_UncheckedDerivedToBase) {
2857 E = ICE->getSubExpr();
2862 if (
const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) {
2863 if (UnOp->getOpcode() == UO_Extension) {
2864 E = UnOp->getSubExpr();
2870 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2871 E = M->GetTemporaryExpr();
2878 if (
const CXXThisExpr *This = dyn_cast<CXXThisExpr>(E))
2879 return This->isImplicit();
2887 for (
unsigned I = 0; I < Exprs.size(); ++I)
2895 const Expr **Culprit)
const {
2916 case StringLiteralClass:
2917 case ObjCEncodeExprClass:
2919 case CXXTemporaryObjectExprClass:
2920 case CXXConstructExprClass: {
2929 assert(CE->
getNumArgs() == 1 &&
"trivial ctor with > 1 argument");
2935 case ConstantExprClass: {
2938 const Expr *Exp = cast<ConstantExpr>(
this)->getSubExpr();
2941 case CompoundLiteralExprClass: {
2945 const Expr *Exp = cast<CompoundLiteralExpr>(
this)->getInitializer();
2948 case DesignatedInitUpdateExprClass: {
2953 case InitListExprClass: {
2957 for (
unsigned i = 0; i < numInits; i++) {
2965 unsigned ElementNo = 0;
2967 for (
const auto *Field : RD->
fields()) {
2973 if (Field->isUnnamedBitfield())
2978 if (Field->isBitField()) {
2987 bool RefType = Field->getType()->isReferenceType();
2998 case ImplicitValueInitExprClass:
2999 case NoInitExprClass:
3001 case ParenExprClass:
3002 return cast<ParenExpr>(
this)->getSubExpr()
3003 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3004 case GenericSelectionExprClass:
3005 return cast<GenericSelectionExpr>(
this)->getResultExpr()
3006 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3007 case ChooseExprClass:
3008 if (cast<ChooseExpr>(
this)->isConditionDependent()) {
3013 return cast<ChooseExpr>(
this)->getChosenSubExpr()
3015 case UnaryOperatorClass: {
3021 case CXXFunctionalCastExprClass:
3022 case CXXStaticCastExprClass:
3023 case ImplicitCastExprClass:
3024 case CStyleCastExprClass:
3025 case ObjCBridgedCastExprClass:
3026 case CXXDynamicCastExprClass:
3027 case CXXReinterpretCastExprClass:
3028 case CXXConstCastExprClass: {
3029 const CastExpr *CE = cast<CastExpr>(
this);
3043 case MaterializeTemporaryExprClass:
3044 return cast<MaterializeTemporaryExpr>(
this)->GetTemporaryExpr()
3045 ->isConstantInitializer(Ctx,
false, Culprit);
3047 case SubstNonTypeTemplateParmExprClass:
3048 return cast<SubstNonTypeTemplateParmExpr>(
this)->getReplacement()
3049 ->isConstantInitializer(Ctx,
false, Culprit);
3050 case CXXDefaultArgExprClass:
3051 return cast<CXXDefaultArgExpr>(
this)->getExpr()
3052 ->isConstantInitializer(Ctx,
false, Culprit);
3053 case CXXDefaultInitExprClass:
3054 return cast<CXXDefaultInitExpr>(
this)->getExpr()
3055 ->isConstantInitializer(Ctx,
false, Culprit);
3069 if (!FD || (FD->
getBuiltinID() != Builtin::BI__assume &&
3073 const Expr* Arg = getArg(0);
3083 const bool IncludePossibleEffects;
3087 explicit SideEffectFinder(
const ASTContext &Context,
bool IncludePossible)
3088 : Inherited(Context),
3089 IncludePossibleEffects(IncludePossible),
HasSideEffects(
false) { }
3093 void VisitExpr(
const Expr *E) {
3094 if (!HasSideEffects &&
3096 HasSideEffects =
true;
3102 bool IncludePossibleEffects)
const {
3106 if (!IncludePossibleEffects &&
getExprLoc().isMacroID())
3110 return IncludePossibleEffects;
3114 #define ABSTRACT_STMT(Type) 3115 #define STMT(Type, Base) case Type##Class: 3116 #define EXPR(Type, Base) 3117 #include "clang/AST/StmtNodes.inc" 3118 llvm_unreachable(
"unexpected Expr kind");
3120 case DependentScopeDeclRefExprClass:
3121 case CXXUnresolvedConstructExprClass:
3122 case CXXDependentScopeMemberExprClass:
3123 case UnresolvedLookupExprClass:
3124 case UnresolvedMemberExprClass:
3125 case PackExpansionExprClass:
3126 case SubstNonTypeTemplateParmPackExprClass:
3127 case FunctionParmPackExprClass:
3129 case CXXFoldExprClass:
3130 llvm_unreachable(
"shouldn't see dependent / unresolved nodes here");
3132 case DeclRefExprClass:
3133 case ObjCIvarRefExprClass:
3134 case PredefinedExprClass:
3135 case IntegerLiteralClass:
3136 case FixedPointLiteralClass:
3137 case FloatingLiteralClass:
3138 case ImaginaryLiteralClass:
3139 case StringLiteralClass:
3140 case CharacterLiteralClass:
3141 case OffsetOfExprClass:
3142 case ImplicitValueInitExprClass:
3143 case UnaryExprOrTypeTraitExprClass:
3144 case AddrLabelExprClass:
3145 case GNUNullExprClass:
3146 case ArrayInitIndexExprClass:
3147 case NoInitExprClass:
3148 case CXXBoolLiteralExprClass:
3149 case CXXNullPtrLiteralExprClass:
3150 case CXXThisExprClass:
3151 case CXXScalarValueInitExprClass:
3152 case TypeTraitExprClass:
3153 case ArrayTypeTraitExprClass:
3154 case ExpressionTraitExprClass:
3155 case CXXNoexceptExprClass:
3156 case SizeOfPackExprClass:
3157 case ObjCStringLiteralClass:
3158 case ObjCEncodeExprClass:
3159 case ObjCBoolLiteralExprClass:
3160 case ObjCAvailabilityCheckExprClass:
3161 case CXXUuidofExprClass:
3162 case OpaqueValueExprClass:
3166 case ConstantExprClass:
3168 return cast<ConstantExpr>(
this)->getSubExpr()->HasSideEffects(
3169 Ctx, IncludePossibleEffects);
3172 case CXXOperatorCallExprClass:
3173 case CXXMemberCallExprClass:
3174 case CUDAKernelCallExprClass:
3175 case UserDefinedLiteralClass: {
3179 const Decl *FD = cast<CallExpr>(
this)->getCalleeDecl();
3180 bool IsPure = FD && (FD->
hasAttr<ConstAttr>() || FD->
hasAttr<PureAttr>());
3181 if (IsPure || !IncludePossibleEffects)
3186 case BlockExprClass:
3187 case CXXBindTemporaryExprClass:
3188 if (!IncludePossibleEffects)
3192 case MSPropertyRefExprClass:
3193 case MSPropertySubscriptExprClass:
3194 case CompoundAssignOperatorClass:
3195 case VAArgExprClass:
3196 case AtomicExprClass:
3197 case CXXThrowExprClass:
3198 case CXXNewExprClass:
3199 case CXXDeleteExprClass:
3200 case CoawaitExprClass:
3201 case DependentCoawaitExprClass:
3202 case CoyieldExprClass:
3206 case StmtExprClass: {
3208 SideEffectFinder Finder(Ctx, IncludePossibleEffects);
3209 Finder.Visit(cast<StmtExpr>(
this)->getSubStmt());
3210 return Finder.hasSideEffects();
3213 case ExprWithCleanupsClass:
3214 if (IncludePossibleEffects)
3215 if (cast<ExprWithCleanups>(
this)->cleanupsHaveSideEffects())
3219 case ParenExprClass:
3220 case ArraySubscriptExprClass:
3221 case OMPArraySectionExprClass:
3222 case MemberExprClass:
3223 case ConditionalOperatorClass:
3224 case BinaryConditionalOperatorClass:
3225 case CompoundLiteralExprClass:
3226 case ExtVectorElementExprClass:
3227 case DesignatedInitExprClass:
3228 case DesignatedInitUpdateExprClass:
3229 case ArrayInitLoopExprClass:
3230 case ParenListExprClass:
3231 case CXXPseudoDestructorExprClass:
3232 case CXXStdInitializerListExprClass:
3233 case SubstNonTypeTemplateParmExprClass:
3234 case MaterializeTemporaryExprClass:
3235 case ShuffleVectorExprClass:
3236 case ConvertVectorExprClass:
3237 case AsTypeExprClass:
3241 case UnaryOperatorClass:
3242 if (cast<UnaryOperator>(
this)->isIncrementDecrementOp())
3246 case BinaryOperatorClass:
3247 if (cast<BinaryOperator>(
this)->isAssignmentOp())
3251 case InitListExprClass:
3254 if (E->HasSideEffects(Ctx, IncludePossibleEffects))
3258 case GenericSelectionExprClass:
3259 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
3262 case ChooseExprClass:
3263 return cast<ChooseExpr>(
this)->getChosenSubExpr()->HasSideEffects(
3264 Ctx, IncludePossibleEffects);
3266 case CXXDefaultArgExprClass:
3267 return cast<CXXDefaultArgExpr>(
this)->getExpr()->HasSideEffects(
3268 Ctx, IncludePossibleEffects);
3270 case CXXDefaultInitExprClass: {
3271 const FieldDecl *FD = cast<CXXDefaultInitExpr>(
this)->getField();
3273 return E->HasSideEffects(Ctx, IncludePossibleEffects);
3278 case CXXDynamicCastExprClass: {
3286 case ImplicitCastExprClass:
3287 case CStyleCastExprClass:
3288 case CXXStaticCastExprClass:
3289 case CXXReinterpretCastExprClass:
3290 case CXXConstCastExprClass:
3291 case CXXFunctionalCastExprClass: {
3296 if (!IncludePossibleEffects)
3299 const CastExpr *CE = cast<CastExpr>(
this);
3306 case CXXTypeidExprClass:
3309 return cast<CXXTypeidExpr>(
this)->isPotentiallyEvaluated();
3311 case CXXConstructExprClass:
3312 case CXXTemporaryObjectExprClass: {
3321 case CXXInheritedCtorInitExprClass: {
3322 const auto *ICIE = cast<CXXInheritedCtorInitExpr>(
this);
3323 if (!ICIE->getConstructor()->isTrivial() && IncludePossibleEffects)
3328 case LambdaExprClass: {
3329 const LambdaExpr *LE = cast<LambdaExpr>(
this);
3331 if (E->HasSideEffects(Ctx, IncludePossibleEffects))
3336 case PseudoObjectExprClass: {
3343 const Expr *Subexpr = *I;
3345 Subexpr = OVE->getSourceExpr();
3352 case ObjCBoxedExprClass:
3353 case ObjCArrayLiteralClass:
3354 case ObjCDictionaryLiteralClass:
3355 case ObjCSelectorExprClass:
3356 case ObjCProtocolExprClass:
3357 case ObjCIsaExprClass:
3358 case ObjCIndirectCopyRestoreExprClass:
3359 case ObjCSubscriptRefExprClass:
3360 case ObjCBridgedCastExprClass:
3361 case ObjCMessageExprClass:
3362 case ObjCPropertyRefExprClass:
3364 if (IncludePossibleEffects)
3372 cast<Expr>(SubStmt)->HasSideEffects(Ctx, IncludePossibleEffects))
3387 explicit NonTrivialCallFinder(
const ASTContext &Context)
3388 : Inherited(Context), NonTrivial(
false) { }
3392 void VisitCallExpr(
const CallExpr *E) {
3394 = dyn_cast_or_null<const CXXMethodDecl>(E->
getCalleeDecl())) {
3395 if (Method->isTrivial()) {
3397 Inherited::VisitStmt(E);
3408 Inherited::VisitStmt(E);
3417 Inherited::VisitStmt(E);
3427 NonTrivialCallFinder Finder(Ctx);
3429 return Finder.hasNonTrivialCall();
3444 llvm_unreachable(
"Unexpected value dependent expression!");
3475 CE->getSubExpr()->getType()->isIntegerType())
3476 return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3479 }
else if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(
this)) {
3481 return ICE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3482 }
else if (
const ParenExpr *PE = dyn_cast<ParenExpr>(
this)) {
3485 return PE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3487 dyn_cast<GenericSelectionExpr>(
this)) {
3488 if (GE->isResultDependent())
3490 return GE->getResultExpr()->isNullPointerConstant(Ctx, NPC);
3491 }
else if (
const ChooseExpr *CE = dyn_cast<ChooseExpr>(
this)) {
3492 if (CE->isConditionDependent())
3494 return CE->getChosenSubExpr()->isNullPointerConstant(Ctx, NPC);
3496 = dyn_cast<CXXDefaultArgExpr>(
this)) {
3498 return DefaultArg->getExpr()->isNullPointerConstant(Ctx, NPC);
3500 = dyn_cast<CXXDefaultInitExpr>(
this)) {
3502 return DefaultInit->getExpr()->isNullPointerConstant(Ctx, NPC);
3503 }
else if (isa<GNUNullExpr>(
this)) {
3507 = dyn_cast<MaterializeTemporaryExpr>(
this)) {
3508 return M->GetTemporaryExpr()->isNullPointerConstant(Ctx, NPC);
3509 }
else if (
const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(
this)) {
3510 if (
const Expr *Source = OVE->getSourceExpr())
3511 return Source->isNullPointerConstant(Ctx, NPC);
3515 if (
getType()->isNullPtrType())
3520 UT && UT->getDecl()->hasAttr<TransparentUnionAttr>())
3522 const Expr *InitExpr = CLE->getInitializer();
3523 if (
const InitListExpr *ILE = dyn_cast<InitListExpr>(InitExpr))
3527 if (!
getType()->isIntegerType() ||
3550 if (isa<IntegerLiteral>(
this))
3558 const Expr *E =
this;
3562 "expression is not a property reference");
3565 if (BO->getOpcode() == BO_Comma) {
3574 return cast<ObjCPropertyRefExpr>(E);
3599 if (ICE->getCastKind() == CK_LValueToRValue ||
3600 (ICE->getValueKind() !=
VK_RValue && ICE->getCastKind() == CK_NoOp))
3606 if (
MemberExpr *MemRef = dyn_cast<MemberExpr>(E))
3607 if (
FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
3608 if (Field->isBitField())
3617 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E)) {
3618 if (
FieldDecl *Field = dyn_cast<FieldDecl>(DeclRef->getDecl()))
3619 if (Field->isBitField())
3622 if (
BindingDecl *BD = dyn_cast<BindingDecl>(DeclRef->getDecl()))
3623 if (
Expr *E = BD->getBinding())
3628 if (BinOp->isAssignmentOp() && BinOp->getLHS())
3629 return BinOp->getLHS()->getSourceBitField();
3631 if (BinOp->getOpcode() == BO_Comma && BinOp->getRHS())
3632 return BinOp->getRHS()->getSourceBitField();
3636 if (UnOp->isPrefix() && UnOp->isIncrementDecrementOp())
3637 return UnOp->getSubExpr()->getSourceBitField();
3648 ICE->getCastKind() == CK_NoOp)
3657 if (isa<ExtVectorElementExpr>(E))
3660 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
3661 if (
auto *BD = dyn_cast<BindingDecl>(DRE->getDecl()))
3662 if (
auto *E = BD->getBinding())
3671 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
3672 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
3674 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
3683 return getBase()->getType()->isPointerType();
3688 return VT->getNumElements();
3696 StringRef Comp = Accessor->getName();
3699 if (Comp ==
"hi" || Comp ==
"lo" || Comp ==
"even" || Comp ==
"odd")
3703 if (Comp[0] ==
's' || Comp[0] ==
'S')
3704 Comp = Comp.substr(1);
3706 for (
unsigned i = 0, e = Comp.size(); i != e; ++i)
3707 if (Comp.substr(i + 1).find(Comp[i]) != StringRef::npos)
3716 StringRef Comp = Accessor->getName();
3717 bool isNumericAccessor =
false;
3718 if (Comp[0] ==
's' || Comp[0] ==
'S') {
3719 Comp = Comp.substr(1);
3720 isNumericAccessor =
true;
3723 bool isHi = Comp ==
"hi";
3724 bool isLo = Comp ==
"lo";
3725 bool isEven = Comp ==
"even";
3726 bool isOdd = Comp ==
"odd";
3728 for (
unsigned i = 0, e = getNumElements(); i != e; ++i) {
3742 Elts.push_back(Index);
3750 Type->isDependentType(), Type->isDependentType(),
3751 Type->isInstantiationDependentType(),
3753 BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size())
3755 SubExprs =
new (
C)
Stmt*[args.size()];
3756 for (
unsigned i = 0; i != args.size(); i++) {
3762 ExprBits.InstantiationDependent =
true;
3764 ExprBits.ContainsUnexpandedParameterPack =
true;
3766 SubExprs[i] = args[i];
3773 this->NumExprs = Exprs.size();
3774 SubExprs =
new (
C)
Stmt*[NumExprs];
3775 memcpy(SubExprs, Exprs.data(),
sizeof(
Expr *) * Exprs.size());
3784 bool ContainsUnexpandedParameterPack,
3785 unsigned ResultIndex)
3786 :
Expr(GenericSelectionExprClass,
3787 AssocExprs[ResultIndex]->
getType(),
3793 ContainsUnexpandedParameterPack),
3795 SubExprs(new (Context)
Stmt*[END_EXPR+AssocExprs.size()]),
3796 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
3797 GenericLoc(GenericLoc), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
3798 SubExprs[CONTROLLING] = ControllingExpr;
3799 assert(AssocTypes.size() == AssocExprs.size());
3800 std::copy(AssocTypes.begin(), AssocTypes.end(), this->AssocTypes);
3801 std::copy(AssocExprs.begin(), AssocExprs.end(), SubExprs+END_EXPR);
3810 bool ContainsUnexpandedParameterPack)
3811 :
Expr(GenericSelectionExprClass,
3812 Context.DependentTy,
3818 ContainsUnexpandedParameterPack),
3820 SubExprs(new (Context)
Stmt*[END_EXPR+AssocExprs.size()]),
3821 NumAssocs(AssocExprs.size()), ResultIndex(-1U), GenericLoc(GenericLoc),
3822 DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
3823 SubExprs[CONTROLLING] = ControllingExpr;
3824 assert(AssocTypes.size() == AssocExprs.size());
3825 std::copy(AssocTypes.begin(), AssocTypes.end(), this->AssocTypes);
3826 std::copy(AssocExprs.begin(), AssocExprs.end(), SubExprs+END_EXPR);
3835 if (Field.NameOrField & 0x01)
3836 return reinterpret_cast<IdentifierInfo *
>(Field.NameOrField&~0x01);
3838 return getField()->getIdentifier();
3847 :
Expr(DesignatedInitExprClass, Ty,
3852 EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
3853 NumDesignators(Designators.size()), NumSubExprs(IndexExprs.size() + 1) {
3854 this->Designators =
new (
C)
Designator[NumDesignators];
3862 unsigned IndexIdx = 0;
3863 for (
unsigned I = 0; I != NumDesignators; ++I) {
3864 this->Designators[I] = Designators[I];
3866 if (this->Designators[I].isArrayDesignator()) {
3868 Expr *Index = IndexExprs[IndexIdx];
3872 ExprBits.InstantiationDependent =
true;
3875 ExprBits.ContainsUnexpandedParameterPack =
true;
3878 *Child++ = IndexExprs[IndexIdx++];
3879 }
else if (this->Designators[I].isArrayRangeDesignator()) {
3881 Expr *Start = IndexExprs[IndexIdx];
3882 Expr *
End = IndexExprs[IndexIdx + 1];
3886 ExprBits.InstantiationDependent =
true;
3889 ExprBits.InstantiationDependent =
true;
3895 ExprBits.ContainsUnexpandedParameterPack =
true;
3898 *Child++ = IndexExprs[IndexIdx++];
3899 *Child++ = IndexExprs[IndexIdx++];
3903 assert(IndexIdx == IndexExprs.size() &&
"Wrong number of index expressions");
3911 bool UsesColonSyntax,
Expr *Init) {
3912 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(IndexExprs.size() + 1),
3915 ColonOrEqualLoc, UsesColonSyntax,
3920 unsigned NumIndexExprs) {
3921 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(NumIndexExprs + 1),
3928 unsigned NumDesigs) {
3930 NumDesignators = NumDesigs;
3931 for (
unsigned I = 0; I != NumDesigs; ++I)
3932 Designators[I] = Desigs[I];
3959 return getInit()->getEndLoc();
3969 "Requires array range designator");
3975 "Requires array range designator");
3984 unsigned NumNewDesignators = Last -
First;
3985 if (NumNewDesignators == 0) {
3986 std::copy_backward(Designators + Idx + 1,
3987 Designators + NumDesignators,
3989 --NumNewDesignators;
3991 }
else if (NumNewDesignators == 1) {
3992 Designators[Idx] = *
First;
3997 =
new (
C)
Designator[NumDesignators - 1 + NumNewDesignators];
3998 std::copy(Designators, Designators + Idx, NewDesignators);
3999 std::copy(First, Last, NewDesignators + Idx);
4000 std::copy(Designators + Idx + 1, Designators + NumDesignators,
4001 NewDesignators + Idx + NumNewDesignators);
4002 Designators = NewDesignators;
4003 NumDesignators = NumDesignators - 1 + NumNewDesignators;
4010 BaseAndUpdaterExprs[0] = baseExpr;
4014 BaseAndUpdaterExprs[1] = ILE;
4029 LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
4032 for (
unsigned I = 0, N = Exprs.size(); I != N; ++I) {
4038 ExprBits.InstantiationDependent =
true;
4040 ExprBits.ContainsUnexpandedParameterPack =
true;
4042 getTrailingObjects<Stmt *>()[I] = Exprs[I];
4046 ParenListExpr::ParenListExpr(
EmptyShell Empty,
unsigned NumExprs)
4047 :
Expr(ParenListExprClass, Empty) {
4055 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(Exprs.size()),
4057 return new (Mem)
ParenListExpr(LParenLoc, Exprs, RParenLoc);
4061 unsigned NumExprs) {
4069 e = ewc->getSubExpr();
4071 e = m->GetTemporaryExpr();
4072 e = cast<CXXConstructExpr>(e)->getArg(0);
4074 e = ice->getSubExpr();
4075 return cast<OpaqueValueExpr>(e);
4080 unsigned numSemanticExprs) {
4082 Context.
Allocate(totalSizeToAlloc<Expr *>(1 + numSemanticExprs),
4087 PseudoObjectExpr::PseudoObjectExpr(
EmptyShell shell,
unsigned numSemanticExprs)
4088 :
Expr(PseudoObjectExprClass, shell) {
4094 unsigned resultIndex) {
4095 assert(syntax &&
"no syntactic expression!");
4096 assert(semantics.size() &&
"no semantic expressions!");
4100 if (resultIndex == NoResult) {
4104 assert(resultIndex < semantics.size());
4105 type = semantics[resultIndex]->getType();
4106 VK = semantics[resultIndex]->getValueKind();
4110 void *buffer = C.
Allocate(totalSizeToAlloc<Expr *>(semantics.size() + 1),
4118 unsigned resultIndex)
4120 false,
false,
false,
false) {
4124 for (
unsigned i = 0, e = semantics.size() + 1; i != e; ++i) {
4125 Expr *E = (i == 0 ? syntax : semantics[i-1]);
4126 getSubExprsBuffer()[i] = E;
4133 ExprBits.InstantiationDependent =
true;
4135 ExprBits.ContainsUnexpandedParameterPack =
true;
4137 if (isa<OpaqueValueExpr>(E))
4138 assert(cast<OpaqueValueExpr>(E)->getSourceExpr() !=
nullptr &&
4139 "opaque-value semantic expressions for pseudo-object " 4140 "operations must have sources");
4159 if (isArgumentType()) {
4161 dyn_cast<VariableArrayType>(getArgumentType().getTypePtr()))
4172 NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op)
4174 assert(args.size() ==
getNumSubExprs(op) &&
"wrong number of subexpressions");
4175 for (
unsigned i = 0; i != args.size(); i++) {
4181 ExprBits.InstantiationDependent =
true;
4183 ExprBits.ContainsUnexpandedParameterPack =
true;
4185 SubExprs[i] = args[i];
4191 case AO__c11_atomic_init:
4192 case AO__opencl_atomic_init:
4193 case AO__c11_atomic_load:
4194 case AO__atomic_load_n:
4197 case AO__opencl_atomic_load:
4198 case AO__c11_atomic_store:
4199 case AO__c11_atomic_exchange:
4200 case AO__atomic_load:
4201 case AO__atomic_store:
4202 case AO__atomic_store_n:
4203 case AO__atomic_exchange_n:
4204 case AO__c11_atomic_fetch_add:
4205 case AO__c11_atomic_fetch_sub:
4206 case AO__c11_atomic_fetch_and:
4207 case AO__c11_atomic_fetch_or:
4208 case AO__c11_atomic_fetch_xor:
4209 case AO__atomic_fetch_add:
4210 case AO__atomic_fetch_sub:
4211 case AO__atomic_fetch_and:
4212 case AO__atomic_fetch_or:
4213 case AO__atomic_fetch_xor:
4214 case AO__atomic_fetch_nand:
4215 case AO__atomic_add_fetch:
4216 case AO__atomic_sub_fetch:
4217 case AO__atomic_and_fetch:
4218 case AO__atomic_or_fetch:
4219 case AO__atomic_xor_fetch:
4220 case AO__atomic_nand_fetch:
4221 case AO__atomic_fetch_min:
4222 case AO__atomic_fetch_max:
4225 case AO__opencl_atomic_store:
4226 case AO__opencl_atomic_exchange:
4227 case AO__opencl_atomic_fetch_add:
4228 case AO__opencl_atomic_fetch_sub:
4229 case AO__opencl_atomic_fetch_and:
4230 case AO__opencl_atomic_fetch_or:
4231 case AO__opencl_atomic_fetch_xor:
4232 case AO__opencl_atomic_fetch_min:
4233 case AO__opencl_atomic_fetch_max:
4234 case AO__atomic_exchange:
4237 case AO__c11_atomic_compare_exchange_strong:
4238 case AO__c11_atomic_compare_exchange_weak:
4241 case AO__opencl_atomic_compare_exchange_strong:
4242 case AO__opencl_atomic_compare_exchange_weak:
4243 case AO__atomic_compare_exchange:
4244 case AO__atomic_compare_exchange_n:
4247 llvm_unreachable(
"unknown atomic op");
4253 return AT->getValueType();
4258 unsigned ArraySectionCount = 0;
4259 while (
auto *OASE = dyn_cast<OMPArraySectionExpr>(Base->
IgnoreParens())) {
4260 Base = OASE->getBase();
4261 ++ArraySectionCount;
4265 Base = ASE->getBase();
4266 ++ArraySectionCount;
4269 auto OriginalTy = Base->
getType();
4270 if (
auto *DRE = dyn_cast<DeclRefExpr>(Base))
4271 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl()))
4272 OriginalTy = PVD->getOriginalType().getNonReferenceType();
4274 for (
unsigned Cnt = 0; Cnt < ArraySectionCount; ++Cnt) {
4275 if (OriginalTy->isAnyPointerType())
4278 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
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
Ignore parentheses and derived-to-base casts.
QualType getElementType() const
SourceLocation getEndLoc() const LLVM_READONLY
StringRef getBufferData(FileID FID, bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
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>'.
MangleContext * createMangleContext()
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type...
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
void setInit(unsigned Init, Expr *expr)
ObjCMethodDecl - Represents an instance or class method declaration.
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.
FullExpr - Represents a "full-expression" node.
field_range fields() const
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
SourceLocation getBeginLoc() const LLVM_READONLY
NameKind getNameKind() const
Determine what kind of name this is.
Represents a member of a struct/union/class.
static DesignatedInitExpr * Create(const ASTContext &C, llvm::ArrayRef< Designator > Designators, ArrayRef< Expr *> IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
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
IgnoreParenCasts - Ignore parentheses and casts.
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)
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 ...
Expr * IgnoreParenNoopCasts(ASTContext &Ctx) LLVM_READONLY
IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the value (including ptr->int ...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
CastKind
CastKind - The kind of operation required for a conversion.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
Specifies that the expression should never be value-dependent.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
InitListExpr * getUpdater() const
ConstantExpr - An expression that occurs in a constant context.
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
Ignore casts. Strip off any CastExprs, returning their operand.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
const llvm::fltSemantics & getSemantics() const
Return the APFloat semantics this literal uses.
Expr * IgnoreConversionOperator() LLVM_READONLY
IgnoreConversionOperator - Ignore conversion operator.
AtomicExpr(SourceLocation BLoc, ArrayRef< Expr *> args, QualType t, AtomicOp op, SourceLocation RP)
unsigned DotLoc
The location of the '.' in the designated initializer.
UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, TypeSourceInfo *TInfo, QualType resultType, SourceLocation op, SourceLocation rp)
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
void ExpandDesignator(const ASTContext &C, unsigned Idx, const Designator *First, const Designator *Last)
Replaces the designator at index Idx with the series of designators in [First, Last).
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
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.
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.
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
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
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
Expr * getArrayRangeEnd(const Designator &D) const
llvm::APInt getValue() const
unsigned getNumSubExprs() const
GenericSelectionExpr(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo *> AssocTypes, ArrayRef< Expr *> AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
SourceLocation getBeginLoc() const LLVM_READONLY
bool isStringLiteralInit() const
struct ArrayOrRangeDesignator ArrayOrRange
An array or GNU array-range designator, e.g., "[9]" or "[10..15]".
unsigned getIntWidth(QualType T) const
Not an overloaded operator.
bool isIncompleteArrayType() const
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
Ignore parentheses and lvalue casts.
Expr * getArg(unsigned Arg)
Return the specified argument.
NamedDecl * getConversionFunction() const
If this cast applies a user-defined conversion, retrieve the conversion function that it invokes...
UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits
Represents a base class of a C++ class.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
A use of a default initializer in a constructor or in aggregate initialization.
A template argument list.
static CStyleCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize)
static const Expr * skipTemporaryBindingsNoOpCastsAndParens(const Expr *E)
Skip over any no-op casts and any temporary-binding expressions.
bool refersToGlobalRegisterVar() const
Returns whether this expression refers to a global register variable.
bool isUnusedResultAWarning(const Expr *&WarnExpr, SourceLocation &Loc, SourceRange &R1, SourceRange &R2, ASTContext &Ctx) const
isUnusedResultAWarning - Return true if this immediate expression should be warned about if the resul...
void reserve(const ASTContext &C, unsigned N)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Expression is a Null pointer constant built from a literal zero.
void Deallocate(void *Ptr) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
CallingConv getCallConv() const
Represents a C++ struct/union/class.
bool isSyntacticForm() const
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr *> Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
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.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
bool isBuiltinAssumeFalse(const ASTContext &Ctx) const
Return true if this is a call to __assume() or __builtin_assume() with a non-value-dependent constant...
Designator * getDesignator(unsigned Idx)
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
void reserveInits(const ASTContext &C, unsigned NumInits)
Reserve space for some number of initializers.
static Decl::Kind getKind(const Decl *D)
DeclAccessPair FoundDecl
The DeclAccessPair through which the MemberDecl was found due to name qualifiers. ...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isEvaluatable(const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
isEvaluatable - Call EvaluateAsRValue to see if this expression can be constant folded without side-e...
std::reverse_iterator< const_iterator > const_reverse_iterator
SourceLocation getBeginLoc() const LLVM_READONLY
A reference to a declared variable, function, enum, etc.
bool isPointerType() const
CallExprBitfields CallExprBits
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
bool isOBJCGCCandidate(ASTContext &Ctx) const
isOBJCGCCandidate - Return true if this expression may be used in a read/ write barrier.
An l-value expression is a reference to an object with independent storage.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
A trivial tuple used to represent a source range.
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
SourceLocation getBeginLoc() const LLVM_READONLY
This represents a decl that may have a name.
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Represents a C array with a specified size that is not an integer-constant-expression.
SourceLocation getEndLoc() const LLVM_READONLY
static int getAccessorIdx(char c, bool isNumericAccessor)
QualType getValueType() const
static CallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, EmptyShell Empty)
Create an empty call expression, for deserialization.
double getValueAsApproximateDouble() const
getValueAsApproximateDouble - This returns the value as an inaccurate double.
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
void removeAddressSpace()
const LangOptions & getLangOpts() const
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
IdentifierInfo * getFieldName() const
This class handles loading and caching of source files into memory.
InitListExpr * getSyntacticForm() const
Defines enum values for all the target-independent builtin functions.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
Attr - This represents one attribute.
QualType getType() const
Return the type wrapped by this type source info.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
SourceRange getSourceRange() const LLVM_READONLY