35 #include "llvm/Support/ErrorHandling.h"
36 #include "llvm/Support/Format.h"
37 #include "llvm/Support/raw_ostream.h"
41 using namespace clang;
49 if (
auto *BO = dyn_cast<BinaryOperator>(E)) {
50 if (BO->getOpcode() == BO_Comma) {
57 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
58 E = MTE->getSubExpr();
79 return cast<CXXRecordDecl>(D);
89 if (
const auto *CE = dyn_cast<CastExpr>(E)) {
90 if ((CE->getCastKind() == CK_DerivedToBase ||
91 CE->getCastKind() == CK_UncheckedDerivedToBase) &&
100 if (CE->getCastKind() == CK_NoOp) {
101 E = CE->getSubExpr();
104 }
else if (
const auto *ME = dyn_cast<MemberExpr>(E)) {
105 if (!ME->isArrow()) {
106 assert(ME->getBase()->getType()->getAsRecordDecl());
107 if (
const auto *Field = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
108 if (!Field->isBitField() && !Field->getType()->isReferenceType()) {
115 }
else if (
const auto *BO = dyn_cast<BinaryOperator>(E)) {
116 if (BO->getOpcode() == BO_PtrMemD) {
117 assert(BO->getRHS()->isPRValue());
123 if (BO->getOpcode() == BO_Comma) {
124 CommaLHSs.push_back(BO->getLHS());
145 switch (UO->getOpcode()) {
147 return UO->getSubExpr()->isKnownToHaveBooleanValue(Semantic);
159 return CE->getSubExpr()->isKnownToHaveBooleanValue(Semantic);
162 switch (BO->getOpcode()) {
163 default:
return false;
178 return BO->getLHS()->isKnownToHaveBooleanValue(Semantic) &&
179 BO->getRHS()->isKnownToHaveBooleanValue(Semantic);
183 return BO->getRHS()->isKnownToHaveBooleanValue(Semantic);
188 return CO->getTrueExpr()->isKnownToHaveBooleanValue(Semantic) &&
189 CO->getFalseExpr()->isKnownToHaveBooleanValue(Semantic);
191 if (isa<ObjCBoolLiteralExpr>(E))
194 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(E))
195 return OVE->getSourceExpr()->isKnownToHaveBooleanValue(Semantic);
198 if (!Semantic && FD->getType()->isUnsignedIntegerType() &&
199 !FD->getBitWidth()->isValueDependent() &&
200 FD->getBitWidthValue(FD->getASTContext()) == 1)
209 bool IgnoreTemplateOrMacroSubstitution)
const {
211 const Decl *D =
nullptr;
213 if (
const auto *ME = dyn_cast<MemberExpr>(E))
214 D = ME->getMemberDecl();
215 else if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
217 else if (
const auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
221 StrictFlexArraysLevel,
222 IgnoreTemplateOrMacroSubstitution);
232 if (
Value.isMemberPointer())
233 return Value.getMemberPointerDecl();
235 if (
Value.isLValue() &&
Value.getLValueOffset().isZero())
249 template <
class E,
class T>
252 return static_cast<const E*
>(
expr)->getExprLoc();
262 return static_cast<const E *
>(
expr)->getBeginLoc();
270 const auto *ED = cast<EnumDecl>(ECD->getDeclContext());
271 if (ED->isCompleteDefinition())
280 #define ABSTRACT_STMT(type)
281 #define STMT(type, base) \
282 case Stmt::type##Class: break;
283 #define EXPR(type, base) \
284 case Stmt::type##Class: return getExprLocImpl<type>(this, &type::getExprLoc);
285 #include "clang/AST/StmtNodes.inc"
287 llvm_unreachable(
"unknown expression kind");
298 "Invalid StorageKind Value");
308 if (!
Value.getInt().needsCleanup())
324 bool IsImmediateInvocation)
325 :
FullExpr(ConstantExprClass, SubExpr) {
334 ::new (getTrailingObjects<APValue>())
APValue();
339 bool IsImmediateInvocation) {
340 assert(!isa<ConstantExpr>(E));
343 unsigned Size = totalSizeToAlloc<APValue, uint64_t>(
347 return new (Mem)
ConstantExpr(E, StorageKind, IsImmediateInvocation);
354 Self->SetResult(Result, Context);
358 ConstantExpr::ConstantExpr(EmptyShell Empty,
360 :
FullExpr(ConstantExprClass, Empty) {
364 ::new (getTrailingObjects<APValue>())
APValue();
371 unsigned Size = totalSizeToAlloc<APValue, uint64_t>(
380 "Invalid storage for this value kind");
386 Int64Result() = *
Value.getInt().getRawData();
395 APValueResult() = std::move(
Value);
398 llvm_unreachable(
"Invalid ResultKind Bits");
404 return APValueResult().
getInt();
409 llvm_unreachable(
"invalid Accessor");
417 return APValueResult();
427 llvm_unreachable(
"invalid ResultKind");
431 bool RefersToEnclosingVariableOrCapture,
QualType T,
441 RefersToEnclosingVariableOrCapture;
442 DeclRefExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter =
false;
449 DeclRefExpr::DeclRefExpr(
const ASTContext &Ctx,
452 bool RefersToEnclosingVariableOrCapture,
461 new (getTrailingObjects<NestedNameSpecifierLoc>())
465 *getTrailingObjects<NamedDecl *>() = FoundD;
467 = (TemplateArgs || TemplateKWLoc.
isValid()) ? 1 : 0;
469 RefersToEnclosingVariableOrCapture;
470 DeclRefExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter =
false;
474 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
475 TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
477 assert(!(Deps & TemplateArgumentDependence::Dependent) &&
478 "built a DeclRefExpr with dependent template args");
479 }
else if (TemplateKWLoc.
isValid()) {
480 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
491 bool RefersToEnclosingVariableOrCapture,
496 return Create(Context, QualifierLoc, TemplateKWLoc, D,
497 RefersToEnclosingVariableOrCapture,
499 T, VK, FoundD, TemplateArgs, NOUR);
505 bool RefersToEnclosingVariableOrCapture,
515 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
519 QualifierLoc ? 1 : 0, FoundD ? 1 : 0,
520 HasTemplateKWAndArgsInfo ? 1 : 0,
521 TemplateArgs ? TemplateArgs->
size() : 0);
524 return new (Mem)
DeclRefExpr(Context, QualifierLoc, TemplateKWLoc, D,
525 RefersToEnclosingVariableOrCapture, NameInfo,
526 FoundD, TemplateArgs,
T, VK, NOUR);
532 bool HasTemplateKWAndArgsInfo,
533 unsigned NumTemplateArgs) {
534 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
538 HasQualifier ? 1 : 0, HasFoundDecl ? 1 : 0, HasTemplateKWAndArgsInfo,
546 if (
getType()->isUndeducedType())
562 SYCLUniqueStableNameExpr::SYCLUniqueStableNameExpr(
SourceLocation OpLoc,
568 OpLoc(OpLoc), LParen(LParen), RParen(RParen) {
569 setTypeSourceInfo(TSI);
573 SYCLUniqueStableNameExpr::SYCLUniqueStableNameExpr(EmptyShell Empty,
597 static std::optional<unsigned>
599 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
601 return RD->getDeviceLambdaManglingNumber();
612 llvm::raw_string_ostream Out(Buffer);
613 Ctx->mangleCanonicalTypeName(Ty, Out);
618 SYCLUniqueStableIdExpr::SYCLUniqueStableIdExpr(EmptyShell Empty,
622 SYCLUniqueStableIdExpr::SYCLUniqueStableIdExpr(
SourceLocation OpLoc,
627 OpLoc(OpLoc), LParen(LParen), RParen(RParen), DRE(E) {
648 "Can't compute name of uninstantiated value");
651 auto *VD = cast<VarDecl>(DR->getDecl());
663 llvm::raw_string_ostream Out(Buffer);
677 assert((getIdentKind() == IK) &&
678 "IdentKind do not fit in PredefinedExprBitfields!");
679 bool HasFunctionName = SL !=
nullptr;
688 PredefinedExpr::PredefinedExpr(EmptyShell Empty,
bool HasFunctionName)
689 :
Expr(PredefinedExprClass, Empty) {
696 bool HasFunctionName = SL !=
nullptr;
697 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
703 bool HasFunctionName) {
704 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
714 return "__FUNCTION__";
716 return "__FUNCDNAME__";
718 return "L__FUNCTION__";
720 return "__PRETTY_FUNCTION__";
722 return "__FUNCSIG__";
724 return "L__FUNCSIG__";
728 llvm_unreachable(
"Unknown ident kind for PredefinedExpr");
734 const Decl *CurrentDecl,
735 bool ForceElaboratedPrinting) {
739 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(CurrentDecl)) {
740 std::unique_ptr<MangleContext> MC;
743 if (MC->shouldMangleDeclName(ND)) {
745 llvm::raw_svector_ostream Out(Buffer);
751 else if (ND->hasAttr<CUDAGlobalAttr>())
755 MC->mangleName(GD, Out);
757 if (!Buffer.empty() && Buffer.front() ==
'\01')
758 return std::string(Buffer.substr(1));
759 return std::string(Buffer);
761 return std::string(ND->getIdentifier()->getName());
765 if (isa<BlockDecl>(CurrentDecl)) {
770 if (DC->isFileContext())
774 llvm::raw_svector_ostream Out(Buffer);
775 if (
auto *DCBlock = dyn_cast<BlockDecl>(DC))
778 else if (
auto *DCDecl = dyn_cast<Decl>(DC))
780 return std::string(Out.str());
782 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
784 bool IsFuncOrFunctionInNonMSVCCompatEnv =
788 bool IsLFunctionInMSVCCommpatEnv =
790 bool IsFuncOrFunctionOrLFunctionOrFuncDName =
795 if ((ForceElaboratedPrinting &&
796 (IsFuncOrFunctionInNonMSVCCompatEnv || IsLFunctionInMSVCCommpatEnv)) ||
797 (!ForceElaboratedPrinting && IsFuncOrFunctionOrLFunctionOrFuncDName))
798 return FD->getNameAsString();
801 llvm::raw_svector_ostream Out(Name);
813 std::string remapPath(StringRef Path)
const override {
816 return std::string(p);
828 llvm::raw_string_ostream POut(Proto);
835 if (FD->hasWrittenPrototype())
836 FT = dyn_cast<FunctionProtoType>(AFT);
841 case CC_C: POut <<
"__cdecl ";
break;
852 FD->printQualifiedName(POut, Policy);
857 return std::string(Name);
862 for (
unsigned i = 0, e =
Decl->getNumParams(); i != e; ++i) {
864 POut <<
Decl->getParamDecl(i)->getType().stream(Policy);
867 if (FT->isVariadic()) {
868 if (FD->getNumParams()) POut <<
", ";
873 !
Decl->getNumParams()) {
880 assert(FT &&
"We must have a written prototype in this case.");
883 if (FT->isVolatile())
895 while (Ctx && isa<NamedDecl>(Ctx)) {
897 = dyn_cast<ClassTemplateSpecializationDecl>(Ctx);
899 Specs.push_back(Spec);
903 std::string TemplateParams;
904 llvm::raw_string_ostream TOut(TemplateParams);
907 D->getSpecializedTemplate()->getTemplateParameters();
909 assert(Params->
size() == Args.
size());
910 for (
unsigned i = 0, numParams = Params->
size(); i != numParams; ++i) {
912 if (Param.empty())
continue;
913 TOut << Param <<
" = ";
922 = FD->getTemplateSpecializationInfo();
927 assert(Params->
size() == Args->
size());
928 for (
unsigned i = 0, e = Params->
size(); i != e; ++i) {
930 if (Param.empty())
continue;
931 TOut << Param <<
" = ";
932 Args->
get(i).
print(Policy, TOut,
true);
938 if (!TemplateParams.empty()) {
940 TemplateParams.resize(TemplateParams.size() - 2);
941 POut <<
" [" << TemplateParams <<
"]";
950 if (isa<CXXMethodDecl>(FD) &&
951 cast<CXXMethodDecl>(FD)->getParent()->isLambda())
952 Proto =
"auto " + Proto;
953 else if (FT && FT->getReturnType()->getAs<
DecltypeType>())
958 else if (!isa<CXXConstructorDecl>(FD) && !isa<CXXDestructorDecl>(FD))
963 return std::string(Name);
965 if (
const CapturedDecl *CD = dyn_cast<CapturedDecl>(CurrentDecl)) {
969 if (DC->isFunctionOrMethod() && (DC->getDeclKind() != Decl::Captured)) {
973 llvm_unreachable(
"CapturedDecl not inside a function or method");
975 if (
const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(CurrentDecl)) {
977 llvm::raw_svector_ostream Out(Name);
978 Out << (MD->isInstanceMethod() ?
'-' :
'+');
987 dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext()))
988 Out <<
'(' << *CID <<
')';
991 MD->getSelector().print(Out);
994 return std::string(Name);
996 if (isa<TranslationUnitDecl>(CurrentDecl) &&
1006 if (hasAllocation())
1009 BitWidth = Val.getBitWidth();
1010 unsigned NumWords = Val.getNumWords();
1011 const uint64_t* Words = Val.getRawData();
1014 std::copy(Words, Words + NumWords,
pVal);
1015 }
else if (NumWords == 1)
1024 assert(
type->isIntegerType() &&
"Illegal type in IntegerLiteral");
1025 assert(
V.getBitWidth() == C.getIntWidth(
type) &&
1026 "Integer type is not the correct size for constant.");
1047 assert(
type->isFixedPointType() &&
"Illegal type in FixedPointLiteral");
1048 assert(
V.getBitWidth() == C.getTypeInfo(
type).Width &&
1049 "Fixed point type is not the correct size for constant.");
1073 S, llvm::APSInt::getUnsigned(
getValue().getZExtValue()), Scale);
1074 return std::string(S);
1096 StringRef Escaped = escapeCStyle<EscapeChar::Single>(Val);
1097 if (!Escaped.empty()) {
1098 OS <<
"'" << Escaped <<
"'";
1107 OS <<
"'" << (char)Val <<
"'";
1109 OS <<
"'\\x" << llvm::format(
"%02x", Val) <<
"'";
1110 else if (Val <= 0xFFFF)
1111 OS <<
"'\\u" << llvm::format(
"%04x", Val) <<
"'";
1113 OS <<
"'\\U" << llvm::format(
"%08x", Val) <<
"'";
1120 setSemantics(
V.getSemantics());
1126 FloatingLiteral::FloatingLiteral(
const ASTContext &C, EmptyShell Empty)
1127 :
Expr(FloatingLiteralClass, Empty) {
1128 setRawSemantics(llvm::APFloatBase::S_IEEEhalf);
1149 V.convert(llvm::APFloat::IEEEdouble(), llvm::APFloat::rmNearestTiesToEven,
1151 return V.convertToDouble();
1156 unsigned CharByteWidth = 0;
1160 CharByteWidth =
Target.getCharWidth();
1163 CharByteWidth =
Target.getWCharWidth();
1166 CharByteWidth =
Target.getChar16Width();
1169 CharByteWidth =
Target.getChar32Width();
1172 return sizeof(char);
1174 assert((CharByteWidth & 7) == 0 &&
"Assumes character size is byte multiple");
1176 assert((CharByteWidth == 1 || CharByteWidth == 2 || CharByteWidth == 4) &&
1177 "The only supported character byte widths are 1,2 and 4!");
1178 return CharByteWidth;
1181 StringLiteral::StringLiteral(
const ASTContext &Ctx, StringRef Str,
1184 unsigned NumConcatenated)
1187 unsigned Length = Str.size();
1194 "StringLiteral must be of constant array type!");
1196 unsigned ByteLength = Str.size();
1197 assert((ByteLength % CharByteWidth == 0) &&
1198 "The size of the data must be a multiple of CharByteWidth!");
1203 switch (CharByteWidth) {
1205 Length = ByteLength;
1208 Length = ByteLength / 2;
1211 Length = ByteLength / 4;
1214 llvm_unreachable(
"Unsupported character width!");
1220 assert(!Pascal &&
"Can't make an unevaluated Pascal string");
1225 *getTrailingObjects<unsigned>() = Length;
1229 std::memcpy(getTrailingObjects<SourceLocation>(), Loc,
1233 std::memcpy(getTrailingObjects<char>(), Str.data(), Str.size());
1238 StringLiteral::StringLiteral(EmptyShell Empty,
unsigned NumConcatenated,
1239 unsigned Length,
unsigned CharByteWidth)
1240 :
Expr(StringLiteralClass, Empty) {
1243 *getTrailingObjects<unsigned>() = Length;
1249 unsigned NumConcatenated) {
1250 void *Mem = Ctx.
Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
1251 1, NumConcatenated, Str.size()),
1258 unsigned NumConcatenated,
1260 unsigned CharByteWidth) {
1261 void *Mem = Ctx.
Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
1262 1, NumConcatenated, Length * CharByteWidth),
1287 static const char Hex[] =
"0123456789ABCDEF";
1290 for (
unsigned I = 0, N =
getLength(); I != N; ++I) {
1292 StringRef Escaped = escapeCStyle<EscapeChar::Double>(Char);
1293 if (Escaped.empty()) {
1299 Char >= 0xd800 && Char <= 0xdbff) {
1301 if (Trail >= 0xdc00 && Trail <= 0xdfff) {
1302 Char = 0x10000 + ((Char - 0xd800) << 10) + (Trail - 0xdc00);
1312 (Char >= 0xd800 && Char <= 0xdfff) || Char >= 0x110000) {
1316 while ((Char >>
Shift) == 0)
1319 OS << Hex[(Char >>
Shift) & 15];
1326 << Hex[(Char >> 20) & 15]
1327 << Hex[(Char >> 16) & 15];
1330 OS << Hex[(Char >> 12) & 15]
1331 << Hex[(Char >> 8) & 15]
1332 << Hex[(Char >> 4) & 15]
1333 << Hex[(Char >> 0) & 15];
1339 if (LastSlashX + 1 == I) {
1341 case '0':
case '1':
case '2':
case '3':
case '4':
1342 case '5':
case '6':
case '7':
case '8':
case '9':
1343 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
1344 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
1349 assert(Char <= 0xff &&
1350 "Characters above 0xff should already have been handled.");
1356 << (char)(
'0' + ((Char >> 6) & 7))
1357 << (char)(
'0' + ((Char >> 3) & 7))
1358 << (char)(
'0' + ((Char >> 0) & 7));
1387 unsigned *StartTokenByteOffset)
const {
1391 "Only narrow string literals are currently supported");
1396 unsigned StringOffset = 0;
1398 TokNo = *StartToken;
1399 if (StartTokenByteOffset) {
1400 StringOffset = *StartTokenByteOffset;
1401 ByteNo -= StringOffset;
1413 std::pair<FileID, unsigned> LocInfo =
1414 SM.getDecomposedLoc(StrTokSpellingLoc);
1415 bool Invalid =
false;
1416 StringRef Buffer =
SM.getBufferData(LocInfo.first, &Invalid);
1418 if (StartTokenByteOffset !=
nullptr)
1419 *StartTokenByteOffset = StringOffset;
1420 if (StartToken !=
nullptr)
1421 *StartToken = TokNo;
1422 return StrTokSpellingLoc;
1425 const char *StrData = Buffer.data()+LocInfo.second;
1428 Lexer TheLexer(
SM.getLocForStartOfFile(LocInfo.first), Features,
1429 Buffer.begin(), StrData, Buffer.end());
1438 if (ByteNo < TokNumBytes ||
1444 if (StartTokenByteOffset !=
nullptr)
1445 *StartTokenByteOffset = StringOffset;
1446 if (StartToken !=
nullptr)
1447 *StartToken = TokNo;
1452 StringOffset += TokNumBytes;
1454 ByteNo -= TokNumBytes;
1462 #define UNARY_OPERATION(Name, Spelling) case UO_##Name: return Spelling;
1463 #include "clang/AST/OperationKinds.def"
1465 llvm_unreachable(
"Unknown unary operator");
1471 default: llvm_unreachable(
"No unary operator for overloaded function");
1472 case OO_PlusPlus:
return Postfix ? UO_PostInc : UO_PreInc;
1473 case OO_MinusMinus:
return Postfix ? UO_PostDec : UO_PreDec;
1474 case OO_Amp:
return UO_AddrOf;
1475 case OO_Star:
return UO_Deref;
1476 case OO_Plus:
return UO_Plus;
1477 case OO_Minus:
return UO_Minus;
1478 case OO_Tilde:
return UO_Not;
1479 case OO_Exclaim:
return UO_LNot;
1480 case OO_Coawait:
return UO_Coawait;
1486 case UO_PostInc:
case UO_PreInc:
return OO_PlusPlus;
1487 case UO_PostDec:
case UO_PreDec:
return OO_MinusMinus;
1488 case UO_AddrOf:
return OO_Amp;
1489 case UO_Deref:
return OO_Star;
1490 case UO_Plus:
return OO_Plus;
1491 case UO_Minus:
return OO_Minus;
1492 case UO_Not:
return OO_Tilde;
1493 case UO_LNot:
return OO_Exclaim;
1494 case UO_Coawait:
return OO_Coawait;
1509 NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1510 unsigned NumPreArgs = PreArgs.size();
1512 assert((NumPreArgs ==
getNumPreArgs()) &&
"NumPreArgs overflow!");
1514 unsigned OffsetToTrailingObjects = offsetToTrailingObjects(SC);
1515 CallExprBits.OffsetToTrailingObjects = OffsetToTrailingObjects;
1516 assert((
CallExprBits.OffsetToTrailingObjects == OffsetToTrailingObjects) &&
1517 "OffsetToTrailingObjects overflow!");
1522 for (
unsigned I = 0; I != NumPreArgs; ++I)
1524 for (
unsigned I = 0; I != Args.size(); ++I)
1526 for (
unsigned I = Args.size(); I != NumArgs; ++I)
1538 :
Expr(SC, Empty), NumArgs(NumArgs) {
1540 assert((NumPreArgs ==
getNumPreArgs()) &&
"NumPreArgs overflow!");
1542 unsigned OffsetToTrailingObjects = offsetToTrailingObjects(SC);
1543 CallExprBits.OffsetToTrailingObjects = OffsetToTrailingObjects;
1544 assert((
CallExprBits.OffsetToTrailingObjects == OffsetToTrailingObjects) &&
1545 "OffsetToTrailingObjects overflow!");
1554 unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1559 return new (Mem)
CallExpr(CallExprClass, Fn, {}, Args, Ty, VK,
1560 RParenLoc, FPFeatures, MinNumArgs,
UsesADL);
1567 "Misaligned memory in CallExpr::CreateTemporary!");
1568 return new (Mem)
CallExpr(CallExprClass, Fn, {}, {}, Ty,
1575 unsigned SizeOfTrailingObjects =
1580 CallExpr(CallExprClass, 0, NumArgs, HasFPFeatures, Empty);
1583 unsigned CallExpr::offsetToTrailingObjects(StmtClass SC) {
1587 case CXXOperatorCallExprClass:
1589 case CXXMemberCallExprClass:
1591 case UserDefinedLiteralClass:
1593 case CUDAKernelCallExprClass:
1596 llvm_unreachable(
"unexpected class deriving from CallExpr!");
1603 while (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE))
1608 if (
auto *BO = dyn_cast<BinaryOperator>(CEE)) {
1609 if (BO->isPtrMemOp()) {
1613 }
else if (
auto *UO = dyn_cast<UnaryOperator>(CEE)) {
1614 if (UO->getOpcode() == UO_Deref || UO->getOpcode() == UO_AddrOf ||
1615 UO->getOpcode() == UO_Plus) {
1623 if (
auto *DRE = dyn_cast<DeclRefExpr>(CEE))
1624 return DRE->getDecl();
1625 if (
auto *ME = dyn_cast<MemberExpr>(CEE))
1626 return ME->getMemberDecl();
1627 if (
auto *BE = dyn_cast<BlockExpr>(CEE))
1628 return BE->getBlockDecl();
1636 return FDecl ? FDecl->getBuiltinID() : 0;
1647 QualType CalleeType = Callee->getType();
1653 if (isa<CXXPseudoDestructorExpr>(Callee->IgnoreParens()))
1656 if (isa<UnresolvedMemberExpr>(Callee->IgnoreParens()))
1661 assert(!CalleeType.
isNull());
1679 if (
const auto *A = TD->getAttr<WarnUnusedResultAttr>())
1683 TD = TD->desugar()->getAs<TypedefType>())
1684 if (
const auto *A = TD->getDecl()->getAttr<WarnUnusedResultAttr>())
1690 return D ? D->
getAttr<WarnUnusedResultAttr>() :
nullptr;
1694 if (
const auto *OCE = dyn_cast<CXXOperatorCallExpr>(
this))
1695 return OCE->getBeginLoc();
1703 if (
const auto *OCE = dyn_cast<CXXOperatorCallExpr>(
this))
1704 return OCE->getEndLoc();
1718 void *Mem = C.Allocate(
1719 totalSizeToAlloc<OffsetOfNode, Expr *>(comps.size(), exprs.size()));
1726 unsigned numComps,
unsigned numExprs) {
1728 C.Allocate(totalSizeToAlloc<OffsetOfNode, Expr *>(numComps, numExprs));
1737 OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
1738 NumComps(comps.size()), NumExprs(exprs.size()) {
1739 for (
unsigned i = 0; i != comps.size(); ++i)
1741 for (
unsigned i = 0; i != exprs.size(); ++i)
1759 OpLoc(op), RParenLoc(rp) {
1760 assert(ExprKind <=
UETT_Last &&
"invalid enum value!");
1763 "UnaryExprOrTypeTraitExprBits.Kind overflow!");
1777 :
Expr(MemberExprClass,
T, VK, OK),
Base(
Base), MemberDecl(MemberDecl),
1778 MemberDNLoc(NameInfo.
getInfo()), MemberLoc(NameInfo.getLoc()) {
1784 FoundDecl.getDecl() != MemberDecl ||
1787 TemplateArgs || TemplateKWLoc.
isValid();
1793 new (getTrailingObjects<NestedNameSpecifierLoc>())
1796 *getTrailingObjects<DeclAccessPair>() = FoundDecl;
1799 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1800 TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
1802 }
else if (TemplateKWLoc.
isValid()) {
1803 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1816 bool HasFoundDecl = FoundDecl.getDecl() != MemberDecl ||
1818 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
1822 HasQualifier, HasFoundDecl, HasTemplateKWAndArgsInfo,
1823 TemplateArgs ? TemplateArgs->
size() : 0);
1825 void *Mem = C.Allocate(Size,
alignof(
MemberExpr));
1826 return new (Mem)
MemberExpr(
Base, IsArrow, OperatorLoc, QualifierLoc,
1827 TemplateKWLoc, MemberDecl, FoundDecl, NameInfo,
1828 TemplateArgs,
T, VK, OK, NOUR);
1832 bool HasQualifier,
bool HasFoundDecl,
1833 bool HasTemplateKWAndArgsInfo,
1834 unsigned NumTemplateArgs) {
1835 assert((!NumTemplateArgs || HasTemplateKWAndArgsInfo) &&
1836 "template args but no template arg info?");
1840 HasQualifier, HasFoundDecl, HasTemplateKWAndArgsInfo,
1848 if (
getType()->isUndeducedType())
1864 return BaseStartLoc;
1876 bool CastExpr::CastConsistency()
const {
1878 case CK_DerivedToBase:
1879 case CK_UncheckedDerivedToBase:
1880 case CK_DerivedToBaseMemberPointer:
1881 case CK_BaseToDerived:
1882 case CK_BaseToDerivedMemberPointer:
1883 assert(!
path_empty() &&
"Cast kind should have a base path!");
1886 case CK_CPointerToObjCPointerCast:
1887 assert(
getType()->isObjCObjectPointerType());
1889 goto CheckNoBasePath;
1891 case CK_BlockPointerToObjCPointerCast:
1892 assert(
getType()->isObjCObjectPointerType());
1894 goto CheckNoBasePath;
1896 case CK_ReinterpretMemberPointer:
1897 assert(
getType()->isMemberPointerType());
1899 goto CheckNoBasePath;
1905 if (!
getType()->isPointerType()) {
1906 assert(
getType()->isObjCObjectPointerType() ==
1908 assert(
getType()->isBlockPointerType() ==
1911 goto CheckNoBasePath;
1913 case CK_AnyPointerToBlockPointerCast:
1914 assert(
getType()->isBlockPointerType());
1917 goto CheckNoBasePath;
1919 case CK_CopyAndAutoreleaseBlockObject:
1920 assert(
getType()->isBlockPointerType());
1922 goto CheckNoBasePath;
1924 case CK_FunctionToPointerDecay:
1925 assert(
getType()->isPointerType());
1927 goto CheckNoBasePath;
1929 case CK_AddressSpaceConversion: {
1938 (!Ty.
isNull() && !SETy.isNull() &&
1940 goto CheckNoBasePath;
1945 case CK_ArrayToPointerDecay:
1946 case CK_NullToMemberPointer:
1947 case CK_NullToPointer:
1948 case CK_ConstructorConversion:
1949 case CK_IntegralToPointer:
1950 case CK_PointerToIntegral:
1952 case CK_VectorSplat:
1953 case CK_IntegralCast:
1954 case CK_BooleanToSignedIntegral:
1955 case CK_IntegralToFloating:
1956 case CK_FloatingToIntegral:
1957 case CK_FloatingCast:
1958 case CK_ObjCObjectLValueCast:
1959 case CK_FloatingRealToComplex:
1960 case CK_FloatingComplexToReal:
1961 case CK_FloatingComplexCast:
1962 case CK_FloatingComplexToIntegralComplex:
1963 case CK_IntegralRealToComplex:
1964 case CK_IntegralComplexToReal:
1965 case CK_IntegralComplexCast:
1966 case CK_IntegralComplexToFloatingComplex:
1967 case CK_ARCProduceObject:
1968 case CK_ARCConsumeObject:
1969 case CK_ARCReclaimReturnedObject:
1970 case CK_ARCExtendBlockObject:
1971 case CK_ZeroToOCLOpaqueType:
1972 case CK_IntToOCLSampler:
1973 case CK_FloatingToFixedPoint:
1974 case CK_FixedPointToFloating:
1975 case CK_FixedPointCast:
1976 case CK_FixedPointToIntegral:
1977 case CK_IntegralToFixedPoint:
1979 case CK_HLSLVectorTruncation:
1981 goto CheckNoBasePath;
1984 case CK_LValueToRValue:
1986 case CK_AtomicToNonAtomic:
1987 case CK_NonAtomicToAtomic:
1988 case CK_PointerToBoolean:
1989 case CK_IntegralToBoolean:
1990 case CK_FloatingToBoolean:
1991 case CK_MemberPointerToBoolean:
1992 case CK_FloatingComplexToBoolean:
1993 case CK_IntegralComplexToBoolean:
1994 case CK_LValueBitCast:
1995 case CK_LValueToRValueBitCast:
1996 case CK_UserDefinedConversion:
1997 case CK_BuiltinFnToFnPtr:
1998 case CK_FixedPointToBoolean:
1999 case CK_HLSLArrayRValue:
2001 assert(
path_empty() &&
"Cast kind should not have a base path!");
2009 #define CAST_OPERATION(Name) case CK_##Name: return #Name;
2010 #include "clang/AST/OperationKinds.def"
2012 llvm_unreachable(
"Unhandled cast kind!");
2018 static Expr *ignoreImplicitSemaNodes(
Expr *E) {
2019 if (
auto *Materialize = dyn_cast<MaterializeTemporaryExpr>(E))
2020 return Materialize->getSubExpr();
2022 if (
auto *Binder = dyn_cast<CXXBindTemporaryExpr>(E))
2023 return Binder->getSubExpr();
2025 if (
auto *Full = dyn_cast<FullExpr>(E))
2026 return Full->getSubExpr();
2028 if (
auto *CPLIE = dyn_cast<CXXParenListInitExpr>(E);
2029 CPLIE && CPLIE->getInitExprs().size() == 1)
2030 return CPLIE->getInitExprs()[0];
2037 const Expr *SubExpr =
nullptr;
2039 for (
const CastExpr *E =
this; E; E = dyn_cast<ImplicitCastExpr>(SubExpr)) {
2044 if (E->getCastKind() == CK_ConstructorConversion) {
2046 ignoreImplicitSemaNodes);
2047 }
else if (E->getCastKind() == CK_UserDefinedConversion) {
2048 assert((isa<CXXMemberCallExpr>(SubExpr) || isa<BlockExpr>(SubExpr)) &&
2049 "Unexpected SubExpr for CK_UserDefinedConversion.");
2050 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
2051 SubExpr = MCE->getImplicitObjectArgument();
2055 return const_cast<Expr *
>(SubExpr);
2059 const Expr *SubExpr =
nullptr;
2061 for (
const CastExpr *E =
this; E; E = dyn_cast<ImplicitCastExpr>(SubExpr)) {
2064 if (E->getCastKind() == CK_ConstructorConversion)
2065 return cast<CXXConstructExpr>(SubExpr)->getConstructor();
2067 if (E->getCastKind() == CK_UserDefinedConversion) {
2068 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
2069 return MCE->getMethodDecl();
2078 #define ABSTRACT_STMT(x)
2079 #define CASTEXPR(Type, Base) \
2080 case Stmt::Type##Class: \
2081 return static_cast<Type *>(this)->getTrailingObjects<CXXBaseSpecifier *>();
2082 #define STMT(Type, Base)
2083 #include "clang/AST/StmtNodes.inc"
2085 llvm_unreachable(
"non-cast expressions not possible here");
2100 Field != FieldEnd; ++Field) {
2102 !Field->isUnnamedBitField()) {
2112 case ImplicitCastExprClass:
2114 ->getTrailingObjects<FPOptionsOverride>();
2115 case CStyleCastExprClass:
2117 ->getTrailingObjects<FPOptionsOverride>();
2118 case CXXFunctionalCastExprClass:
2120 ->getTrailingObjects<FPOptionsOverride>();
2121 case CXXStaticCastExprClass:
2123 ->getTrailingObjects<FPOptionsOverride>();
2125 llvm_unreachable(
"Cast does not have FPFeatures");
2134 unsigned PathSize = (BasePath ? BasePath->size() : 0);
2136 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
2140 assert((
Kind != CK_LValueToRValue ||
2142 "invalid type for lvalue-to-rvalue conversion");
2146 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
2153 bool HasFPFeatures) {
2155 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
2156 PathSize, HasFPFeatures));
2166 unsigned PathSize = (BasePath ? BasePath->size() : 0);
2168 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
2171 new (Buffer)
CStyleCastExpr(
T, VK, K, Op, PathSize, FPO, WrittenTy, L, R);
2173 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
2180 bool HasFPFeatures) {
2182 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
2183 PathSize, HasFPFeatures));
2191 #define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling;
2192 #include "clang/AST/OperationKinds.def"
2194 llvm_unreachable(
"Invalid OpCode!");
2200 default: llvm_unreachable(
"Not an overloadable binary operator");
2201 case OO_Plus:
return BO_Add;
2202 case OO_Minus:
return BO_Sub;
2203 case OO_Star:
return BO_Mul;
2204 case OO_Slash:
return BO_Div;
2205 case OO_Percent:
return BO_Rem;
2206 case OO_Caret:
return BO_Xor;
2207 case OO_Amp:
return BO_And;
2208 case OO_Pipe:
return BO_Or;
2209 case OO_Equal:
return BO_Assign;
2210 case OO_Spaceship:
return BO_Cmp;
2211 case OO_Less:
return BO_LT;
2212 case OO_Greater:
return BO_GT;
2213 case OO_PlusEqual:
return BO_AddAssign;
2214 case OO_MinusEqual:
return BO_SubAssign;
2215 case OO_StarEqual:
return BO_MulAssign;
2216 case OO_SlashEqual:
return BO_DivAssign;
2217 case OO_PercentEqual:
return BO_RemAssign;
2218 case OO_CaretEqual:
return BO_XorAssign;
2219 case OO_AmpEqual:
return BO_AndAssign;
2220 case OO_PipeEqual:
return BO_OrAssign;
2221 case OO_LessLess:
return BO_Shl;
2222 case OO_GreaterGreater:
return BO_Shr;
2223 case OO_LessLessEqual:
return BO_ShlAssign;
2224 case OO_GreaterGreaterEqual:
return BO_ShrAssign;
2225 case OO_EqualEqual:
return BO_EQ;
2226 case OO_ExclaimEqual:
return BO_NE;
2227 case OO_LessEqual:
return BO_LE;
2228 case OO_GreaterEqual:
return BO_GE;
2229 case OO_AmpAmp:
return BO_LAnd;
2230 case OO_PipePipe:
return BO_LOr;
2231 case OO_Comma:
return BO_Comma;
2232 case OO_ArrowStar:
return BO_PtrMemI;
2239 OO_Star, OO_Slash, OO_Percent,
2241 OO_LessLess, OO_GreaterGreater,
2243 OO_Less, OO_Greater, OO_LessEqual, OO_GreaterEqual,
2244 OO_EqualEqual, OO_ExclaimEqual,
2250 OO_Equal, OO_StarEqual,
2251 OO_SlashEqual, OO_PercentEqual,
2252 OO_PlusEqual, OO_MinusEqual,
2253 OO_LessLessEqual, OO_GreaterGreaterEqual,
2254 OO_AmpEqual, OO_CaretEqual,
2258 return OverOps[Opc];
2300 BuiltinLoc(BLoc), RParenLoc(RParenLoc), ParentContext(ParentContext) {
2308 return "__builtin_FILE";
2310 return "__builtin_FILE_NAME";
2312 return "__builtin_FUNCTION";
2314 return "__builtin_FUNCSIG";
2316 return "__builtin_LINE";
2318 return "__builtin_COLUMN";
2320 return "__builtin_source_location";
2322 llvm_unreachable(
"unexpected IdentKind!");
2326 const Expr *DefaultExpr)
const {
2330 if (
const auto *DIE = dyn_cast_if_present<CXXDefaultInitExpr>(DefaultExpr)) {
2331 Loc = DIE->getUsedLocation();
2332 Context = DIE->getUsedContext();
2333 }
else if (
const auto *DAE =
2334 dyn_cast_if_present<CXXDefaultArgExpr>(DefaultExpr)) {
2335 Loc = DAE->getUsedLocation();
2336 Context = DAE->getUsedContext();
2345 auto MakeStringLiteral = [&](StringRef Tmp) {
2349 LValuePathEntry Path[1] = {LValuePathEntry::ArrayIndex(0)};
2360 return MakeStringLiteral(
FileName);
2366 return MakeStringLiteral(Path);
2370 const auto *CurDecl = dyn_cast<Decl>(Context);
2374 return MakeStringLiteral(
2394 StringRef Name = F->getName();
2395 if (Name ==
"_M_file_name") {
2399 Value.getStructField(F->getFieldIndex()) = MakeStringLiteral(Path);
2400 }
else if (Name ==
"_M_function_name") {
2403 const auto *CurDecl = dyn_cast<Decl>(Context);
2404 Value.getStructField(F->getFieldIndex()) = MakeStringLiteral(
2405 CurDecl && !isa<TranslationUnitDecl>(CurDecl)
2409 }
else if (Name ==
"_M_line") {
2411 Value.getStructField(F->getFieldIndex()) =
APValue(IntVal);
2412 }
else if (Name ==
"_M_column") {
2414 Value.getStructField(F->getFieldIndex()) =
APValue(IntVal);
2425 llvm_unreachable(
"unhandled case");
2431 InitExprs(C, initExprs.size()), LBraceLoc(lbraceloc),
2432 RBraceLoc(rbraceloc), AltForm(nullptr,
true) {
2434 InitExprs.
insert(C, InitExprs.
end(), initExprs.begin(), initExprs.end());
2440 if (NumInits > InitExprs.
size())
2441 InitExprs.
reserve(C, NumInits);
2445 InitExprs.
resize(C, NumInits,
nullptr);
2449 if (Init >= InitExprs.
size()) {
2450 InitExprs.
insert(C, InitExprs.
end(), Init - InitExprs.
size() + 1,
nullptr);
2455 Expr *Result = cast_or_null<Expr>(InitExprs[Init]);
2462 ArrayFillerOrUnionFieldInit = filler;
2465 for (
unsigned i = 0, e =
getNumInits(); i != e; ++i)
2466 if (
inits[i] ==
nullptr)
2480 Init = Init->IgnoreParenImpCasts();
2481 return isa<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init);
2485 assert(
isSemanticForm() &&
"syntactic form never semantically transparent");
2489 assert(
getNumInits() == 1 &&
"multiple inits in glvalue init list");
2508 assert(
isSyntacticForm() &&
"only test syntactic form as zero initializer");
2515 return Lit && Lit->
getValue() == 0;
2520 return SyntacticForm->getBeginLoc();
2525 E = InitExprs.
end();
2528 Beg = S->getBeginLoc();
2538 return SyntacticForm->getEndLoc();
2542 for (
Stmt *S : llvm::reverse(InitExprs)) {
2544 End = S->getEndLoc();
2556 return cast<BlockPointerType>(
getType())
2587 if (isa<DeclRefExpr>(E))
2591 if (isa<ArraySubscriptExpr>(E))
2595 if (isa<MemberExpr>(E))
2599 if (
auto *UO = dyn_cast<UnaryOperator>(E))
2600 if (UO->getOpcode() == UO_Deref)
2603 if (
auto *BO = dyn_cast<BinaryOperator>(E)) {
2605 if (BO->isPtrMemOp())
2609 if (BO->getOpcode() == BO_Comma)
2610 return BO->getRHS()->isReadIfDiscardedInCPlusPlus11();
2615 if (
auto *CO = dyn_cast<ConditionalOperator>(E))
2616 return CO->getTrueExpr()->isReadIfDiscardedInCPlusPlus11() &&
2617 CO->getFalseExpr()->isReadIfDiscardedInCPlusPlus11();
2620 dyn_cast<BinaryConditionalOperator>(E)) {
2621 if (
auto *OVE = dyn_cast<OpaqueValueExpr>(BCO->getTrueExpr()))
2622 return OVE->getSourceExpr()->isReadIfDiscardedInCPlusPlus11() &&
2623 BCO->getFalseExpr()->isReadIfDiscardedInCPlusPlus11();
2627 if (isa<ObjCIvarRefExpr>(E))
2629 if (
const auto *POE = dyn_cast<PseudoObjectExpr>(E)) {
2630 if (isa<ObjCPropertyRefExpr, ObjCSubscriptRefExpr>(POE->getSyntacticForm()))
2657 case ParenExprClass:
2658 return cast<ParenExpr>(
this)->getSubExpr()->
2660 case GenericSelectionExprClass:
2661 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
2663 case CoawaitExprClass:
2664 case CoyieldExprClass:
2665 return cast<CoroutineSuspendExpr>(
this)->getResumeExpr()->
2667 case ChooseExprClass:
2668 return cast<ChooseExpr>(
this)->getChosenSubExpr()->
2670 case UnaryOperatorClass: {
2704 case BinaryOperatorClass: {
2716 if (IE->getValue() == 0)
2735 case CompoundAssignOperatorClass:
2736 case VAArgExprClass:
2737 case AtomicExprClass:
2740 case ConditionalOperatorClass: {
2744 const auto *Exp = cast<ConditionalOperator>(
this);
2745 return Exp->getLHS()->isUnusedResultAWarning(WarnE,
Loc, R1, R2, Ctx) &&
2746 Exp->getRHS()->isUnusedResultAWarning(WarnE,
Loc, R1, R2, Ctx);
2748 case BinaryConditionalOperatorClass: {
2749 const auto *Exp = cast<BinaryConditionalOperator>(
this);
2750 return Exp->getFalseExpr()->isUnusedResultAWarning(WarnE,
Loc, R1, R2, Ctx);
2753 case MemberExprClass:
2755 Loc = cast<MemberExpr>(
this)->getMemberLoc();
2757 R2 = cast<MemberExpr>(
this)->getBase()->getSourceRange();
2760 case ArraySubscriptExprClass:
2762 Loc = cast<ArraySubscriptExpr>(
this)->getRBracketLoc();
2763 R1 = cast<ArraySubscriptExpr>(
this)->getLHS()->getSourceRange();
2764 R2 = cast<ArraySubscriptExpr>(
this)->getRHS()->getSourceRange();
2767 case CXXOperatorCallExprClass: {
2779 case OO_ExclaimEqual:
2782 case OO_GreaterEqual:
2797 case CXXMemberCallExprClass:
2798 case UserDefinedLiteralClass: {
2800 const CallExpr *CE = cast<CallExpr>(
this);
2808 FD->hasAttr<PureAttr>() || FD->hasAttr<ConstAttr>()) {
2823 case UnresolvedLookupExprClass:
2824 case CXXUnresolvedConstructExprClass:
2825 case RecoveryExprClass:
2828 case CXXTemporaryObjectExprClass:
2829 case CXXConstructExprClass: {
2831 const auto *WarnURAttr =
Type->getAttr<WarnUnusedResultAttr>();
2833 (WarnURAttr && WarnURAttr->IsCXX11NoDiscard())) {
2841 const auto *CE = cast<CXXConstructExpr>(
this);
2843 const auto *WarnURAttr = Ctor->getAttr<WarnUnusedResultAttr>();
2844 if (WarnURAttr && WarnURAttr->IsCXX11NoDiscard()) {
2849 if (
unsigned NumArgs = CE->getNumArgs())
2851 CE->getArg(NumArgs - 1)->getEndLoc());
2859 case ObjCMessageExprClass: {
2872 if (MD->hasAttr<WarnUnusedResultAttr>()) {
2881 case ObjCPropertyRefExprClass:
2882 case ObjCSubscriptRefExprClass:
2888 case PseudoObjectExprClass: {
2889 const auto *POE = cast<PseudoObjectExpr>(
this);
2892 if (isa<ObjCPropertyRefExpr, ObjCSubscriptRefExpr>(
2893 POE->getSyntacticForm())) {
2901 if (
auto *BO = dyn_cast<BinaryOperator>(POE->getSyntacticForm()))
2902 if (BO->isAssignmentOp())
2904 if (
auto *UO = dyn_cast<UnaryOperator>(POE->getSyntacticForm()))
2905 if (UO->isIncrementDecrementOp())
2909 const Expr *Result = POE->getResultExpr();
2910 return Result && Result->isUnusedResultAWarning(WarnE,
Loc, R1, R2, Ctx);
2913 case StmtExprClass: {
2919 const CompoundStmt *CS = cast<StmtExpr>(
this)->getSubStmt();
2924 if (
const Expr *E = dyn_cast<Expr>(
Label->getSubStmt()))
2931 Loc = cast<StmtExpr>(
this)->getLParenLoc();
2935 case CXXFunctionalCastExprClass:
2936 case CStyleCastExprClass: {
2943 const CastExpr *CE = cast<CastExpr>(
this);
2950 if (
auto *DRE = dyn_cast<DeclRefExpr>(SubE))
2951 if (
auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
2952 if (!VD->isExternallyVisible())
2968 if (CE->
getCastKind() == CK_ConstructorConversion)
2975 dyn_cast<CXXFunctionalCastExpr>(
this)) {
2976 Loc = CXXCE->getBeginLoc();
2977 R1 = CXXCE->getSubExpr()->getSourceRange();
2985 case ImplicitCastExprClass: {
2986 const CastExpr *ICE = cast<ImplicitCastExpr>(
this);
2995 case CXXDefaultArgExprClass:
2996 return (cast<CXXDefaultArgExpr>(
this)
2998 case CXXDefaultInitExprClass:
2999 return (cast<CXXDefaultInitExpr>(
this)
3002 case CXXNewExprClass:
3005 case CXXDeleteExprClass:
3007 case MaterializeTemporaryExprClass:
3008 return cast<MaterializeTemporaryExpr>(
this)
3010 ->isUnusedResultAWarning(WarnE,
Loc, R1, R2, Ctx);
3011 case CXXBindTemporaryExprClass:
3012 return cast<CXXBindTemporaryExpr>(
this)->getSubExpr()
3013 ->isUnusedResultAWarning(WarnE,
Loc, R1, R2, Ctx);
3014 case ExprWithCleanupsClass:
3015 return cast<ExprWithCleanups>(
this)->getSubExpr()
3016 ->isUnusedResultAWarning(WarnE,
Loc, R1, R2, Ctx);
3027 case ObjCIvarRefExprClass:
3029 case Expr::UnaryOperatorClass:
3030 return cast<UnaryOperator>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
3031 case ImplicitCastExprClass:
3032 return cast<ImplicitCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
3033 case MaterializeTemporaryExprClass:
3034 return cast<MaterializeTemporaryExpr>(E)->getSubExpr()->isOBJCGCCandidate(
3036 case CStyleCastExprClass:
3037 return cast<CStyleCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
3038 case DeclRefExprClass: {
3039 const Decl *D = cast<DeclRefExpr>(E)->getDecl();
3041 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
3042 if (VD->hasGlobalStorage())
3052 case MemberExprClass: {
3056 case ArraySubscriptExprClass:
3057 return cast<ArraySubscriptExpr>(E)->getBase()->isOBJCGCCandidate(Ctx);
3068 assert(
expr->hasPlaceholderType(BuiltinType::BoundMember));
3076 assert(isa<CXXMethodDecl>(mem->getMemberDecl()));
3077 return mem->getMemberDecl()->getType();
3083 assert(
type->isFunctionType());
3087 assert(isa<UnresolvedMemberExpr>(
expr) || isa<CXXPseudoDestructorExpr>(
expr));
3121 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(
this)) {
3122 if (MCE->getMethodDecl() && isa<CXXConversionDecl>(MCE->getMethodDecl()))
3123 return MCE->getImplicitObjectArgument();
3139 auto IgnoreNoopCastsSingleStep = [&Ctx](
Expr *E) {
3140 if (
auto *CE = dyn_cast<CastExpr>(E)) {
3143 Expr *SubExpr = CE->getSubExpr();
3144 bool IsIdentityCast =
3153 if (IsIdentityCast || IsSameWidthCast)
3155 }
else if (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
3156 return NTTP->getReplacement();
3161 IgnoreNoopCastsSingleStep);
3166 if (
auto *
Cast = dyn_cast<CXXFunctionalCastExpr>(E)) {
3167 auto *SE =
Cast->getSubExpr();
3172 if (
auto *C = dyn_cast<CXXConstructExpr>(E)) {
3173 auto NumArgs = C->getNumArgs();
3175 (NumArgs > 1 && isa<CXXDefaultArgExpr>(C->getArg(1)))) {
3176 Expr *A = C->getArg(0);
3183 auto IgnoreImplicitMemberCallSingleStep = [](
Expr *E) {
3184 if (
auto *C = dyn_cast<CXXMemberCallExpr>(E)) {
3185 Expr *ExprNode = C->getImplicitObjectArgument();
3189 if (
auto *PE = dyn_cast<ParenExpr>(ExprNode)) {
3190 if (PE->getSourceRange() == C->getSourceRange()) {
3191 return cast<Expr>(PE);
3203 IgnoreImplicitMemberCallSingleStep);
3207 const Expr *E =
this;
3209 E = M->getSubExpr();
3212 E = ICE->getSubExprAsWritten();
3214 return isa<CXXDefaultArgExpr>(E);
3221 E = M->getSubExpr();
3224 if (ICE->getCastKind() == CK_NoOp)
3225 E = ICE->getSubExpr();
3231 E = BE->getSubExpr();
3234 if (ICE->getCastKind() == CK_NoOp)
3235 E = ICE->getSubExpr();
3246 if (!C.hasSameUnqualifiedType(
getType(), C.getTypeDeclType(TempTy)))
3254 if (!isa<ObjCPropertyRefExpr>(E))
3262 if (isa<ImplicitCastExpr>(E)) {
3263 switch (cast<ImplicitCastExpr>(E)->getCastKind()) {
3264 case CK_DerivedToBase:
3265 case CK_UncheckedDerivedToBase:
3273 if (isa<MemberExpr>(E))
3277 if (BO->isPtrMemOp())
3281 if (isa<OpaqueValueExpr>(E))
3288 const Expr *E =
this;
3293 E =
Paren->getSubExpr();
3298 if (ICE->getCastKind() == CK_NoOp ||
3299 ICE->getCastKind() == CK_LValueToRValue ||
3300 ICE->getCastKind() == CK_DerivedToBase ||
3301 ICE->getCastKind() == CK_UncheckedDerivedToBase) {
3302 E = ICE->getSubExpr();
3307 if (
const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) {
3308 if (UnOp->getOpcode() == UO_Extension) {
3309 E = UnOp->getSubExpr();
3315 = dyn_cast<MaterializeTemporaryExpr>(E)) {
3316 E = M->getSubExpr();
3324 return This->isImplicit();
3332 for (
unsigned I = 0; I < Exprs.size(); ++I)
3340 const Expr **Culprit)
const {
3342 "Expression evaluator can't be called on a dependent expression.");
3354 if (
auto *EWC = dyn_cast<ExprWithCleanups>(
this))
3355 return EWC->getSubExpr()->isConstantInitializer(Ctx,
true, Culprit);
3356 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(
this))
3357 return MTE->getSubExpr()->isConstantInitializer(Ctx,
false, Culprit);
3368 case Stmt::ExprWithCleanupsClass:
3370 Ctx, IsForRef, Culprit);
3371 case StringLiteralClass:
3372 case ObjCEncodeExprClass:
3374 case CXXTemporaryObjectExprClass:
3375 case CXXConstructExprClass: {
3384 assert(CE->
getNumArgs() == 1 &&
"trivial ctor with > 1 argument");
3390 case ConstantExprClass: {
3393 const Expr *Exp = cast<ConstantExpr>(
this)->getSubExpr();
3396 case CompoundLiteralExprClass: {
3400 const Expr *Exp = cast<CompoundLiteralExpr>(
this)->getInitializer();
3403 case DesignatedInitUpdateExprClass: {
3408 case InitListExprClass: {
3416 assert(ILE->
isSemanticForm() &&
"InitListExpr must be in semantic form");
3419 for (
unsigned i = 0; i < numInits; i++) {
3427 unsigned ElementNo = 0;
3432 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
3433 for (
unsigned i = 0, e = CXXRD->getNumBases(); i < e; i++) {
3434 if (ElementNo < ILE->getNumInits()) {
3442 for (
const auto *Field : RD->
fields()) {
3448 if (Field->isUnnamedBitField())
3451 if (ElementNo < ILE->getNumInits()) {
3453 if (Field->isBitField()) {
3462 bool RefType = Field->getType()->isReferenceType();
3473 case ImplicitValueInitExprClass:
3474 case NoInitExprClass:
3476 case ParenExprClass:
3477 return cast<ParenExpr>(
this)->getSubExpr()
3478 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3479 case GenericSelectionExprClass:
3480 return cast<GenericSelectionExpr>(
this)->getResultExpr()
3481 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3482 case ChooseExprClass:
3483 if (cast<ChooseExpr>(
this)->isConditionDependent()) {
3488 return cast<ChooseExpr>(
this)->getChosenSubExpr()
3490 case UnaryOperatorClass: {
3496 case PackIndexingExprClass: {
3497 return cast<PackIndexingExpr>(
this)
3499 ->isConstantInitializer(Ctx,
false, Culprit);
3501 case CXXFunctionalCastExprClass:
3502 case CXXStaticCastExprClass:
3503 case ImplicitCastExprClass:
3504 case CStyleCastExprClass:
3505 case ObjCBridgedCastExprClass:
3506 case CXXDynamicCastExprClass:
3507 case CXXReinterpretCastExprClass:
3508 case CXXAddrspaceCastExprClass:
3509 case CXXConstCastExprClass: {
3510 const CastExpr *CE = cast<CastExpr>(
this);
3525 case MaterializeTemporaryExprClass:
3526 return cast<MaterializeTemporaryExpr>(
this)
3528 ->isConstantInitializer(Ctx,
false, Culprit);
3530 case SubstNonTypeTemplateParmExprClass:
3531 return cast<SubstNonTypeTemplateParmExpr>(
this)->getReplacement()
3532 ->isConstantInitializer(Ctx,
false, Culprit);
3533 case CXXDefaultArgExprClass:
3534 return cast<CXXDefaultArgExpr>(
this)->getExpr()
3535 ->isConstantInitializer(Ctx,
false, Culprit);
3536 case CXXDefaultInitExprClass:
3537 return cast<CXXDefaultInitExpr>(
this)->getExpr()
3538 ->isConstantInitializer(Ctx,
false, Culprit);
3552 if (BuiltinID != Builtin::BI__assume &&
3553 BuiltinID != Builtin::BI__builtin_assume)
3570 const bool IncludePossibleEffects;
3571 bool HasSideEffects;
3574 explicit SideEffectFinder(
const ASTContext &Context,
bool IncludePossible)
3575 : Inherited(Context),
3576 IncludePossibleEffects(IncludePossible), HasSideEffects(
false) { }
3580 void VisitDecl(
const Decl *D) {
3586 if (
auto *VD = dyn_cast<VarDecl>(D)) {
3588 if (IncludePossibleEffects && VD->isThisDeclarationADefinition() &&
3589 VD->needsDestruction(Context))
3590 HasSideEffects =
true;
3594 void VisitDeclStmt(
const DeclStmt *DS) {
3595 for (
auto *D : DS->
decls())
3597 Inherited::VisitDeclStmt(DS);
3600 void VisitExpr(
const Expr *E) {
3601 if (!HasSideEffects &&
3603 HasSideEffects =
true;
3609 bool IncludePossibleEffects)
const {
3613 if (!IncludePossibleEffects &&
getExprLoc().isMacroID())
3618 #define ABSTRACT_STMT(Type)
3619 #define STMT(Type, Base) case Type##Class:
3620 #define EXPR(Type, Base)
3621 #include "clang/AST/StmtNodes.inc"
3622 llvm_unreachable(
"unexpected Expr kind");
3624 case DependentScopeDeclRefExprClass:
3625 case CXXUnresolvedConstructExprClass:
3626 case CXXDependentScopeMemberExprClass:
3627 case UnresolvedLookupExprClass:
3628 case UnresolvedMemberExprClass:
3629 case PackExpansionExprClass:
3630 case SubstNonTypeTemplateParmPackExprClass:
3631 case FunctionParmPackExprClass:
3633 case RecoveryExprClass:
3634 case CXXFoldExprClass:
3636 return IncludePossibleEffects;
3638 case DeclRefExprClass:
3639 case ObjCIvarRefExprClass:
3640 case PredefinedExprClass:
3641 case IntegerLiteralClass:
3642 case FixedPointLiteralClass:
3643 case FloatingLiteralClass:
3644 case ImaginaryLiteralClass:
3645 case StringLiteralClass:
3646 case CharacterLiteralClass:
3647 case OffsetOfExprClass:
3648 case ImplicitValueInitExprClass:
3649 case UnaryExprOrTypeTraitExprClass:
3650 case AddrLabelExprClass:
3651 case GNUNullExprClass:
3652 case ArrayInitIndexExprClass:
3653 case NoInitExprClass:
3654 case CXXBoolLiteralExprClass:
3655 case CXXNullPtrLiteralExprClass:
3656 case CXXThisExprClass:
3657 case CXXScalarValueInitExprClass:
3658 case TypeTraitExprClass:
3659 case ArrayTypeTraitExprClass:
3660 case ExpressionTraitExprClass:
3661 case CXXNoexceptExprClass:
3662 case SizeOfPackExprClass:
3663 case ObjCStringLiteralClass:
3664 case ObjCEncodeExprClass:
3665 case ObjCBoolLiteralExprClass:
3666 case ObjCAvailabilityCheckExprClass:
3667 case CXXUuidofExprClass:
3668 case OpaqueValueExprClass:
3669 case SourceLocExprClass:
3670 case ConceptSpecializationExprClass:
3671 case RequiresExprClass:
3672 case SYCLBuiltinNumFieldsExprClass:
3673 case SYCLBuiltinFieldTypeExprClass:
3674 case SYCLBuiltinNumBasesExprClass:
3675 case SYCLBuiltinBaseTypeExprClass:
3676 case SYCLUniqueStableNameExprClass:
3677 case SYCLUniqueStableIdExprClass:
3681 case PackIndexingExprClass:
3682 return cast<PackIndexingExpr>(
this)->getSelectedExpr()->HasSideEffects(
3683 Ctx, IncludePossibleEffects);
3684 case ConstantExprClass:
3686 return cast<ConstantExpr>(
this)->getSubExpr()->HasSideEffects(
3687 Ctx, IncludePossibleEffects);
3690 case CXXOperatorCallExprClass:
3691 case CXXMemberCallExprClass:
3692 case CUDAKernelCallExprClass:
3693 case UserDefinedLiteralClass: {
3697 const Decl *FD = cast<CallExpr>(
this)->getCalleeDecl();
3698 bool IsPure = FD && (FD->
hasAttr<ConstAttr>() || FD->
hasAttr<PureAttr>());
3699 if (IsPure || !IncludePossibleEffects)
3704 case BlockExprClass:
3705 case CXXBindTemporaryExprClass:
3706 if (!IncludePossibleEffects)
3710 case MSPropertyRefExprClass:
3711 case MSPropertySubscriptExprClass:
3712 case CompoundAssignOperatorClass:
3713 case VAArgExprClass:
3714 case AtomicExprClass:
3715 case CXXThrowExprClass:
3716 case CXXNewExprClass:
3717 case CXXDeleteExprClass:
3718 case CoawaitExprClass:
3719 case DependentCoawaitExprClass:
3720 case CoyieldExprClass:
3724 case StmtExprClass: {
3726 SideEffectFinder Finder(Ctx, IncludePossibleEffects);
3727 Finder.Visit(cast<StmtExpr>(
this)->getSubStmt());
3728 return Finder.hasSideEffects();
3731 case ExprWithCleanupsClass:
3732 if (IncludePossibleEffects)
3733 if (cast<ExprWithCleanups>(
this)->cleanupsHaveSideEffects())
3737 case ParenExprClass:
3738 case ArraySubscriptExprClass:
3739 case MatrixSubscriptExprClass:
3740 case ArraySectionExprClass:
3741 case OMPArrayShapingExprClass:
3742 case OMPIteratorExprClass:
3743 case MemberExprClass:
3744 case ConditionalOperatorClass:
3745 case BinaryConditionalOperatorClass:
3746 case CompoundLiteralExprClass:
3747 case ExtVectorElementExprClass:
3748 case DesignatedInitExprClass:
3749 case DesignatedInitUpdateExprClass:
3750 case ArrayInitLoopExprClass:
3751 case ParenListExprClass:
3752 case CXXPseudoDestructorExprClass:
3753 case CXXRewrittenBinaryOperatorClass:
3754 case CXXStdInitializerListExprClass:
3755 case SubstNonTypeTemplateParmExprClass:
3756 case MaterializeTemporaryExprClass:
3757 case ShuffleVectorExprClass:
3758 case ConvertVectorExprClass:
3759 case AsTypeExprClass:
3760 case CXXParenListInitExprClass:
3764 case UnaryOperatorClass:
3765 if (cast<UnaryOperator>(
this)->isIncrementDecrementOp())
3769 case BinaryOperatorClass:
3770 if (cast<BinaryOperator>(
this)->isAssignmentOp())
3774 case InitListExprClass:
3776 if (
const Expr *E = cast<InitListExpr>(
this)->getArrayFiller())
3781 case GenericSelectionExprClass:
3782 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
3785 case ChooseExprClass:
3786 return cast<ChooseExpr>(
this)->getChosenSubExpr()->HasSideEffects(
3787 Ctx, IncludePossibleEffects);
3789 case CXXDefaultArgExprClass:
3790 return cast<CXXDefaultArgExpr>(
this)->getExpr()->HasSideEffects(
3791 Ctx, IncludePossibleEffects);
3793 case CXXDefaultInitExprClass: {
3794 const FieldDecl *FD = cast<CXXDefaultInitExpr>(
this)->getField();
3801 case CXXDynamicCastExprClass: {
3809 case ImplicitCastExprClass:
3810 case CStyleCastExprClass:
3811 case CXXStaticCastExprClass:
3812 case CXXReinterpretCastExprClass:
3813 case CXXConstCastExprClass:
3814 case CXXAddrspaceCastExprClass:
3815 case CXXFunctionalCastExprClass:
3816 case BuiltinBitCastExprClass: {
3821 if (!IncludePossibleEffects)
3824 const CastExpr *CE = cast<CastExpr>(
this);
3831 case CXXTypeidExprClass:
3834 return cast<CXXTypeidExpr>(
this)->isPotentiallyEvaluated();
3836 case CXXConstructExprClass:
3837 case CXXTemporaryObjectExprClass: {
3846 case CXXInheritedCtorInitExprClass: {
3847 const auto *ICIE = cast<CXXInheritedCtorInitExpr>(
this);
3848 if (!ICIE->getConstructor()->isTrivial() && IncludePossibleEffects)
3853 case LambdaExprClass: {
3855 for (
Expr *E :
LE->capture_inits())
3861 case PseudoObjectExprClass: {
3868 const Expr *Subexpr = *I;
3870 Subexpr = OVE->getSourceExpr();
3877 case ObjCBoxedExprClass:
3878 case ObjCArrayLiteralClass:
3879 case ObjCDictionaryLiteralClass:
3880 case ObjCSelectorExprClass:
3881 case ObjCProtocolExprClass:
3882 case ObjCIsaExprClass:
3883 case ObjCIndirectCopyRestoreExprClass:
3884 case ObjCSubscriptRefExprClass:
3885 case ObjCBridgedCastExprClass:
3886 case ObjCMessageExprClass:
3887 case ObjCPropertyRefExprClass:
3889 if (IncludePossibleEffects)
3897 cast<Expr>(SubStmt)->
HasSideEffects(Ctx, IncludePossibleEffects))
3904 if (
auto Call = dyn_cast<CallExpr>(
this))
3905 return Call->getFPFeaturesInEffect(LO);
3906 if (
auto UO = dyn_cast<UnaryOperator>(
this))
3907 return UO->getFPFeaturesInEffect(LO);
3908 if (
auto BO = dyn_cast<BinaryOperator>(
this))
3909 return BO->getFPFeaturesInEffect(LO);
3910 if (
auto Cast = dyn_cast<CastExpr>(
this))
3911 return Cast->getFPFeaturesInEffect(LO);
3924 explicit NonTrivialCallFinder(
const ASTContext &Context)
3925 : Inherited(Context), NonTrivial(
false) { }
3927 bool hasNonTrivialCall()
const {
return NonTrivial; }
3929 void VisitCallExpr(
const CallExpr *E) {
3931 = dyn_cast_or_null<const CXXMethodDecl>(E->
getCalleeDecl())) {
3932 if (Method->isTrivial()) {
3934 Inherited::VisitStmt(E);
3945 Inherited::VisitStmt(E);
3957 if (DtorDecl->isTrivial()) {
3958 Inherited::VisitStmt(E);
3969 NonTrivialCallFinder Finder(Ctx);
3971 return Finder.hasNonTrivialCall();
3989 llvm_unreachable(
"Unexpected value dependent expression!");
4017 CE->getSubExpr()->getType()->isIntegerType())
4018 return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
4021 }
else if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(
this)) {
4023 return ICE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
4024 }
else if (
const ParenExpr *PE = dyn_cast<ParenExpr>(
this)) {
4027 return PE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
4029 dyn_cast<GenericSelectionExpr>(
this)) {
4030 if (
GE->isResultDependent())
4032 return GE->getResultExpr()->isNullPointerConstant(Ctx, NPC);
4033 }
else if (
const ChooseExpr *CE = dyn_cast<ChooseExpr>(
this)) {
4034 if (CE->isConditionDependent())
4036 return CE->getChosenSubExpr()->isNullPointerConstant(Ctx, NPC);
4038 = dyn_cast<CXXDefaultArgExpr>(
this)) {
4040 return DefaultArg->getExpr()->isNullPointerConstant(Ctx, NPC);
4042 = dyn_cast<CXXDefaultInitExpr>(
this)) {
4044 return DefaultInit->getExpr()->isNullPointerConstant(Ctx, NPC);
4045 }
else if (isa<GNUNullExpr>(
this)) {
4049 = dyn_cast<MaterializeTemporaryExpr>(
this)) {
4050 return M->getSubExpr()->isNullPointerConstant(Ctx, NPC);
4051 }
else if (
const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(
this)) {
4052 if (
const Expr *Source = OVE->getSourceExpr())
4053 return Source->isNullPointerConstant(Ctx, NPC);
4062 if (
getType()->isNullPtrType())
4067 UT && UT->getDecl()->hasAttr<TransparentUnionAttr>())
4069 const Expr *InitExpr = CLE->getInitializer();
4070 if (
const InitListExpr *ILE = dyn_cast<InitListExpr>(InitExpr))
4074 if (!
getType()->isIntegerType() ||
4097 if (isa<IntegerLiteral>(
this))
4105 const Expr *E =
this;
4108 "expression is not a property reference");
4111 if (BO->getOpcode() == BO_Comma) {
4120 return cast<ObjCPropertyRefExpr>(E);
4126 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E);
4145 if (ICE->getCastKind() == CK_LValueToRValue ||
4146 (ICE->isGLValue() && ICE->getCastKind() == CK_NoOp))
4152 if (
MemberExpr *MemRef = dyn_cast<MemberExpr>(E))
4153 if (
FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
4154 if (Field->isBitField())
4163 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E)) {
4164 if (
FieldDecl *Field = dyn_cast<FieldDecl>(DeclRef->getDecl()))
4165 if (Field->isBitField())
4168 if (
BindingDecl *BD = dyn_cast<BindingDecl>(DeclRef->getDecl()))
4169 if (
Expr *E = BD->getBinding())
4174 if (BinOp->isAssignmentOp() && BinOp->getLHS())
4175 return BinOp->getLHS()->getSourceBitField();
4177 if (BinOp->getOpcode() == BO_Comma && BinOp->getRHS())
4178 return BinOp->getRHS()->getSourceBitField();
4182 if (UnOp->isPrefix() && UnOp->isIncrementDecrementOp())
4183 return UnOp->getSubExpr()->getSourceBitField();
4190 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
4191 return dyn_cast<EnumConstantDecl>(DRE->getDecl());
4200 if (ICE->isGLValue() && ICE->getCastKind() == CK_NoOp)
4209 if (isa<ExtVectorElementExpr>(E))
4212 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
4213 if (
auto *BD = dyn_cast<BindingDecl>(DRE->getDecl()))
4214 if (
auto *E = BD->getBinding())
4223 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
4224 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
4226 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
4242 case CXXThisExprClass:
4244 case DeclRefExprClass: {
4247 const auto *DRE1 = cast<DeclRefExpr>(E1);
4248 const auto *DRE2 = cast<DeclRefExpr>(E2);
4249 return DRE1->isPRValue() && DRE2->isPRValue() &&
4250 DRE1->getDecl() == DRE2->getDecl();
4252 case ImplicitCastExprClass: {
4255 const auto *ICE1 = dyn_cast<ImplicitCastExpr>(E1);
4256 const auto *ICE2 = dyn_cast<ImplicitCastExpr>(E2);
4259 if (ICE1->getCastKind() != ICE2->getCastKind())
4264 if (ICE1->getCastKind() == CK_LValueToRValue ||
4265 ICE1->getCastKind() == CK_ArrayToPointerDecay ||
4266 ICE1->getCastKind() == CK_FunctionToPointerDecay) {
4271 const auto *DRE1 = dyn_cast<DeclRefExpr>(E1);
4272 const auto *DRE2 = dyn_cast<DeclRefExpr>(E2);
4276 const auto *Ivar1 = dyn_cast<ObjCIvarRefExpr>(E1);
4277 const auto *Ivar2 = dyn_cast<ObjCIvarRefExpr>(E2);
4278 if (Ivar1 && Ivar2) {
4279 return Ivar1->isFreeIvar() && Ivar2->isFreeIvar() &&
4283 const auto *Array1 = dyn_cast<ArraySubscriptExpr>(E1);
4284 const auto *Array2 = dyn_cast<ArraySubscriptExpr>(E2);
4285 if (Array1 && Array2) {
4289 auto Idx1 = Array1->getIdx();
4290 auto Idx2 = Array2->getIdx();
4291 const auto Integer1 = dyn_cast<IntegerLiteral>(Idx1);
4292 const auto Integer2 = dyn_cast<IntegerLiteral>(Idx2);
4293 if (Integer1 && Integer2) {
4294 if (!llvm::APInt::isSameValue(Integer1->getValue(),
4295 Integer2->getValue()))
4306 while (isa<MemberExpr>(E1) && isa<MemberExpr>(E2)) {
4307 const auto *ME1 = cast<MemberExpr>(E1);
4308 const auto *ME2 = cast<MemberExpr>(E2);
4311 if (
const auto *D = dyn_cast<VarDecl>(ME1->getMemberDecl()))
4312 if (D->isStaticDataMember())
4318 if (isa<CXXThisExpr>(E1) && isa<CXXThisExpr>(E2))
4324 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
4325 return DRE->getDecl();
4326 if (
const auto *ME = dyn_cast<MemberExpr>(E))
4327 return ME->getMemberDecl();
4346 return VT->getNumElements();
4361 if (
Comp[0] ==
's' ||
Comp[0] ==
'S')
4364 for (
unsigned i = 0, e =
Comp.size(); i != e; ++i)
4365 if (
Comp.substr(i + 1).contains(
Comp[i]))
4375 bool isNumericAccessor =
false;
4376 if (
Comp[0] ==
's' ||
Comp[0] ==
'S') {
4378 isNumericAccessor =
true;
4381 bool isHi =
Comp ==
"hi";
4382 bool isLo =
Comp ==
"lo";
4383 bool isEven =
Comp ==
"even";
4384 bool isOdd =
Comp ==
"odd";
4400 Elts.push_back(Index);
4408 BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size()) {
4409 SubExprs =
new (C)
Stmt*[args.size()];
4410 for (
unsigned i = 0; i != args.size(); i++)
4411 SubExprs[i] = args[i];
4417 if (SubExprs) C.Deallocate(SubExprs);
4419 this->NumExprs = Exprs.size();
4420 SubExprs =
new (C)
Stmt*[NumExprs];
4421 memcpy(SubExprs, Exprs.data(),
sizeof(
Expr *) * Exprs.size());
4424 GenericSelectionExpr::GenericSelectionExpr(
4428 bool ContainsUnexpandedParameterPack,
unsigned ResultIndex)
4429 :
Expr(GenericSelectionExprClass, AssocExprs[ResultIndex]->getType(),
4430 AssocExprs[ResultIndex]->getValueKind(),
4431 AssocExprs[ResultIndex]->getObjectKind()),
4432 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
4433 IsExprPredicate(
true), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4434 assert(AssocTypes.size() == AssocExprs.size() &&
4435 "Must have the same number of association expressions"
4436 " and TypeSourceInfo!");
4437 assert(ResultIndex < NumAssocs &&
"ResultIndex is out-of-bounds!");
4440 getTrailingObjects<Stmt *>()[getIndexOfControllingExpression()] =
4442 std::copy(AssocExprs.begin(), AssocExprs.end(),
4443 getTrailingObjects<Stmt *>() + getIndexOfStartOfAssociatedExprs());
4444 std::copy(AssocTypes.begin(), AssocTypes.end(),
4445 getTrailingObjects<TypeSourceInfo *>() +
4446 getIndexOfStartOfAssociatedTypes());
4451 GenericSelectionExpr::GenericSelectionExpr(
4456 unsigned ResultIndex)
4457 :
Expr(GenericSelectionExprClass, AssocExprs[ResultIndex]->getType(),
4458 AssocExprs[ResultIndex]->getValueKind(),
4459 AssocExprs[ResultIndex]->getObjectKind()),
4460 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
4461 IsExprPredicate(
false), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4462 assert(AssocTypes.size() == AssocExprs.size() &&
4463 "Must have the same number of association expressions"
4464 " and TypeSourceInfo!");
4465 assert(ResultIndex < NumAssocs &&
"ResultIndex is out-of-bounds!");
4468 getTrailingObjects<TypeSourceInfo *>()[getIndexOfControllingType()] =
4470 std::copy(AssocExprs.begin(), AssocExprs.end(),
4471 getTrailingObjects<Stmt *>() + getIndexOfStartOfAssociatedExprs());
4472 std::copy(AssocTypes.begin(), AssocTypes.end(),
4473 getTrailingObjects<TypeSourceInfo *>() +
4474 getIndexOfStartOfAssociatedTypes());
4479 GenericSelectionExpr::GenericSelectionExpr(
4483 bool ContainsUnexpandedParameterPack)
4484 :
Expr(GenericSelectionExprClass, Context.DependentTy,
VK_PRValue,
4486 NumAssocs(AssocExprs.size()), ResultIndex(ResultDependentIndex),
4487 IsExprPredicate(
true), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4488 assert(AssocTypes.size() == AssocExprs.size() &&
4489 "Must have the same number of association expressions"
4490 " and TypeSourceInfo!");
4493 getTrailingObjects<Stmt *>()[getIndexOfControllingExpression()] =
4495 std::copy(AssocExprs.begin(), AssocExprs.end(),
4496 getTrailingObjects<Stmt *>() + getIndexOfStartOfAssociatedExprs());
4497 std::copy(AssocTypes.begin(), AssocTypes.end(),
4498 getTrailingObjects<TypeSourceInfo *>() +
4499 getIndexOfStartOfAssociatedTypes());
4504 GenericSelectionExpr::GenericSelectionExpr(
4509 :
Expr(GenericSelectionExprClass, Context.DependentTy,
VK_PRValue,
4511 NumAssocs(AssocExprs.size()), ResultIndex(ResultDependentIndex),
4512 IsExprPredicate(
false), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4513 assert(AssocTypes.size() == AssocExprs.size() &&
4514 "Must have the same number of association expressions"
4515 " and TypeSourceInfo!");
4518 getTrailingObjects<TypeSourceInfo *>()[getIndexOfControllingType()] =
4520 std::copy(AssocExprs.begin(), AssocExprs.end(),
4521 getTrailingObjects<Stmt *>() + getIndexOfStartOfAssociatedExprs());
4522 std::copy(AssocTypes.begin(), AssocTypes.end(),
4523 getTrailingObjects<TypeSourceInfo *>() +
4524 getIndexOfStartOfAssociatedTypes());
4529 GenericSelectionExpr::GenericSelectionExpr(EmptyShell Empty,
unsigned NumAssocs)
4530 :
Expr(GenericSelectionExprClass, Empty), NumAssocs(NumAssocs) {}
4536 bool ContainsUnexpandedParameterPack,
unsigned ResultIndex) {
4537 unsigned NumAssocs = AssocExprs.size();
4539 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4542 Context, GenericLoc, ControllingExpr, AssocTypes, AssocExprs, DefaultLoc,
4543 RParenLoc, ContainsUnexpandedParameterPack, ResultIndex);
4550 bool ContainsUnexpandedParameterPack) {
4551 unsigned NumAssocs = AssocExprs.size();
4553 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4556 Context, GenericLoc, ControllingExpr, AssocTypes, AssocExprs, DefaultLoc,
4557 RParenLoc, ContainsUnexpandedParameterPack);
4565 unsigned ResultIndex) {
4566 unsigned NumAssocs = AssocExprs.size();
4568 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4571 Context, GenericLoc, ControllingType, AssocTypes, AssocExprs, DefaultLoc,
4572 RParenLoc, ContainsUnexpandedParameterPack, ResultIndex);
4579 SourceLocation RParenLoc,
bool ContainsUnexpandedParameterPack) {
4580 unsigned NumAssocs = AssocExprs.size();
4582 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4585 Context, GenericLoc, ControllingType, AssocTypes, AssocExprs, DefaultLoc,
4586 RParenLoc, ContainsUnexpandedParameterPack);
4591 unsigned NumAssocs) {
4593 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4616 EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
4617 NumDesignators(Designators.
size()), NumSubExprs(IndexExprs.
size() + 1) {
4618 this->Designators =
new (C)
Designator[NumDesignators];
4626 unsigned IndexIdx = 0;
4627 for (
unsigned I = 0; I != NumDesignators; ++I) {
4628 this->Designators[I] = Designators[I];
4631 *Child++ = IndexExprs[IndexIdx++];
4634 *Child++ = IndexExprs[IndexIdx++];
4635 *Child++ = IndexExprs[IndexIdx++];
4639 assert(IndexIdx == IndexExprs.size() &&
"Wrong number of index expressions");
4648 bool UsesColonSyntax,
Expr *Init) {
4649 void *Mem = C.Allocate(totalSizeToAlloc<Stmt *>(IndexExprs.size() + 1),
4652 ColonOrEqualLoc, UsesColonSyntax,
4657 unsigned NumIndexExprs) {
4658 void *Mem = C.Allocate(totalSizeToAlloc<Stmt *>(NumIndexExprs + 1),
4665 unsigned NumDesigs) {
4667 NumDesignators = NumDesigs;
4668 for (
unsigned I = 0; I != NumDesigs; ++I)
4669 Designators[I] = Desigs[I];
4683 if (
First.isFieldDesignator()) {
4686 for (
unsigned int i = 0; i < DIE->size(); i++) {
4694 return First.getLBracketLoc();
4721 unsigned NumNewDesignators =
Last -
First;
4722 if (NumNewDesignators == 0) {
4723 std::copy_backward(Designators + Idx + 1,
4724 Designators + NumDesignators,
4726 --NumNewDesignators;
4729 if (NumNewDesignators == 1) {
4730 Designators[Idx] = *
First;
4735 =
new (C)
Designator[NumDesignators - 1 + NumNewDesignators];
4736 std::copy(Designators, Designators + Idx, NewDesignators);
4737 std::copy(
First,
Last, NewDesignators + Idx);
4738 std::copy(Designators + Idx + 1, Designators + NumDesignators,
4739 NewDesignators + Idx + NumNewDesignators);
4740 Designators = NewDesignators;
4741 NumDesignators = NumDesignators - 1 + NumNewDesignators;
4750 BaseAndUpdaterExprs[0] = baseExpr;
4753 new (C)
InitListExpr(C, lBraceLoc, std::nullopt, rBraceLoc);
4755 BaseAndUpdaterExprs[1] = ILE;
4772 LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
4775 for (
unsigned I = 0, N = Exprs.size(); I != N; ++I)
4776 getTrailingObjects<Stmt *>()[I] = Exprs[I];
4780 ParenListExpr::ParenListExpr(EmptyShell Empty,
unsigned NumExprs)
4781 :
Expr(ParenListExprClass, Empty) {
4789 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(Exprs.size()),
4791 return new (Mem)
ParenListExpr(LParenLoc, Exprs, RParenLoc);
4795 unsigned NumExprs) {
4805 :
Expr(BinaryOperatorClass, ResTy, VK, OK) {
4808 "Use CompoundAssignOperator for compound assignments");
4810 SubExprs[LHS] = lhs;
4811 SubExprs[RHS] = rhs;
4822 :
Expr(CompoundAssignOperatorClass, ResTy, VK, OK) {
4825 "Use CompoundAssignOperator for compound assignments");
4827 SubExprs[LHS] = lhs;
4828 SubExprs[RHS] = rhs;
4836 bool HasFPFeatures) {
4853 BinaryOperator(C, lhs, rhs, opc, ResTy, VK, OK, opLoc, FPFeatures);
4876 CompLHSType, CompResultType);
4880 bool hasFPFeatures) {
4881 void *Mem = C.Allocate(totalSizeToAlloc<FPOptionsOverride>(hasFPFeatures),
4890 :
Expr(UnaryOperatorClass,
type, VK, OK), Val(input) {
4906 unsigned Size = totalSizeToAlloc<FPOptionsOverride>(HasFPFeatures);
4914 e = ewc->getSubExpr();
4916 e = m->getSubExpr();
4917 e = cast<CXXConstructExpr>(e)->getArg(0);
4919 e = ice->getSubExpr();
4920 return cast<OpaqueValueExpr>(e);
4925 unsigned numSemanticExprs) {
4927 Context.
Allocate(totalSizeToAlloc<Expr *>(1 + numSemanticExprs),
4932 PseudoObjectExpr::PseudoObjectExpr(EmptyShell shell,
unsigned numSemanticExprs)
4933 :
Expr(PseudoObjectExprClass, shell) {
4939 unsigned resultIndex) {
4940 assert(syntax &&
"no syntactic expression!");
4941 assert(
semantics.size() &&
"no semantic expressions!");
4951 VK =
semantics[resultIndex]->getValueKind();
4955 void *buffer = C.Allocate(totalSizeToAlloc<Expr *>(
semantics.size() + 1),
4963 unsigned resultIndex)
4968 for (
unsigned i = 0, e =
semantics.size() + 1; i != e; ++i) {
4970 getSubExprsBuffer()[i] = E;
4972 if (isa<OpaqueValueExpr>(E))
4973 assert(cast<OpaqueValueExpr>(E)->getSourceExpr() !=
nullptr &&
4974 "opaque-value semantic expressions for pseudo-object "
4975 "operations must have sources");
5008 NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op) {
5009 assert(args.size() ==
getNumSubExprs(op) &&
"wrong number of subexpressions");
5010 for (
unsigned i = 0; i != args.size(); i++)
5011 SubExprs[i] = args[i];
5017 case AO__c11_atomic_init:
5018 case AO__opencl_atomic_init:
5019 case AO__c11_atomic_load:
5020 case AO__atomic_load_n:
5023 case AO__scoped_atomic_load_n:
5024 case AO__opencl_atomic_load:
5025 case AO__hip_atomic_load:
5026 case AO__c11_atomic_store:
5027 case AO__c11_atomic_exchange:
5028 case AO__atomic_load:
5029 case AO__atomic_store:
5030 case AO__atomic_store_n:
5031 case AO__atomic_exchange_n:
5032 case AO__c11_atomic_fetch_add:
5033 case AO__c11_atomic_fetch_sub:
5034 case AO__c11_atomic_fetch_and:
5035 case AO__c11_atomic_fetch_or:
5036 case AO__c11_atomic_fetch_xor:
5037 case AO__c11_atomic_fetch_nand:
5038 case AO__c11_atomic_fetch_max:
5039 case AO__c11_atomic_fetch_min:
5040 case AO__atomic_fetch_add:
5041 case AO__atomic_fetch_sub:
5042 case AO__atomic_fetch_and:
5043 case AO__atomic_fetch_or:
5044 case AO__atomic_fetch_xor:
5045 case AO__atomic_fetch_nand:
5046 case AO__atomic_add_fetch:
5047 case AO__atomic_sub_fetch:
5048 case AO__atomic_and_fetch:
5049 case AO__atomic_or_fetch:
5050 case AO__atomic_xor_fetch:
5051 case AO__atomic_nand_fetch:
5052 case AO__atomic_min_fetch:
5053 case AO__atomic_max_fetch:
5054 case AO__atomic_fetch_min:
5055 case AO__atomic_fetch_max:
5058 case AO__scoped_atomic_load:
5059 case AO__scoped_atomic_store:
5060 case AO__scoped_atomic_store_n:
5061 case AO__scoped_atomic_fetch_add:
5062 case AO__scoped_atomic_fetch_sub:
5063 case AO__scoped_atomic_fetch_and:
5064 case AO__scoped_atomic_fetch_or:
5065 case AO__scoped_atomic_fetch_xor:
5066 case AO__scoped_atomic_fetch_nand:
5067 case AO__scoped_atomic_add_fetch:
5068 case AO__scoped_atomic_sub_fetch:
5069 case AO__scoped_atomic_and_fetch:
5070 case AO__scoped_atomic_or_fetch:
5071 case AO__scoped_atomic_xor_fetch:
5072 case AO__scoped_atomic_nand_fetch:
5073 case AO__scoped_atomic_min_fetch:
5074 case AO__scoped_atomic_max_fetch:
5075 case AO__scoped_atomic_fetch_min:
5076 case AO__scoped_atomic_fetch_max:
5077 case AO__scoped_atomic_exchange_n:
5078 case AO__hip_atomic_exchange:
5079 case AO__hip_atomic_fetch_add:
5080 case AO__hip_atomic_fetch_sub:
5081 case AO__hip_atomic_fetch_and:
5082 case AO__hip_atomic_fetch_or:
5083 case AO__hip_atomic_fetch_xor:
5084 case AO__hip_atomic_fetch_min:
5085 case AO__hip_atomic_fetch_max:
5086 case AO__opencl_atomic_store:
5087 case AO__hip_atomic_store:
5088 case AO__opencl_atomic_exchange:
5089 case AO__opencl_atomic_fetch_add:
5090 case AO__opencl_atomic_fetch_sub:
5091 case AO__opencl_atomic_fetch_and:
5092 case AO__opencl_atomic_fetch_or:
5093 case AO__opencl_atomic_fetch_xor:
5094 case AO__opencl_atomic_fetch_min:
5095 case AO__opencl_atomic_fetch_max:
5096 case AO__atomic_exchange:
5099 case AO__scoped_atomic_exchange:
5100 case AO__c11_atomic_compare_exchange_strong:
5101 case AO__c11_atomic_compare_exchange_weak:
5103 case AO__hip_atomic_compare_exchange_strong:
5104 case AO__opencl_atomic_compare_exchange_strong:
5105 case AO__opencl_atomic_compare_exchange_weak:
5106 case AO__hip_atomic_compare_exchange_weak:
5107 case AO__atomic_compare_exchange:
5108 case AO__atomic_compare_exchange_n:
5111 case AO__scoped_atomic_compare_exchange:
5112 case AO__scoped_atomic_compare_exchange_n:
5115 llvm_unreachable(
"unknown atomic op");
5121 return AT->getValueType();
5126 unsigned ArraySectionCount = 0;
5127 while (
auto *OASE = dyn_cast<ArraySectionExpr>(
Base->IgnoreParens())) {
5128 Base = OASE->getBase();
5129 ++ArraySectionCount;
5132 dyn_cast<ArraySubscriptExpr>(
Base->IgnoreParenImpCasts())) {
5133 Base = ASE->getBase();
5134 ++ArraySectionCount;
5136 Base =
Base->IgnoreParenImpCasts();
5137 auto OriginalTy =
Base->getType();
5138 if (
auto *DRE = dyn_cast<DeclRefExpr>(
Base))
5139 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl()))
5140 OriginalTy = PVD->getOriginalType().getNonReferenceType();
5142 for (
unsigned Cnt = 0; Cnt < ArraySectionCount; ++Cnt) {
5143 if (OriginalTy->isAnyPointerType())
5144 OriginalTy = OriginalTy->getPointeeType();
5145 else if (OriginalTy->isArrayType())
5146 OriginalTy = OriginalTy->castAsArrayTypeUnsafe()->getElementType();
5155 :
Expr(RecoveryExprClass,
T.getNonReferenceType(),
5156 T->isDependentType() ?
VK_LValue : getValueKindForType(
T),
5158 BeginLoc(BeginLoc), EndLoc(EndLoc), NumExprs(SubExprs.size()) {
5159 assert(!
T.isNull());
5160 assert(!llvm::is_contained(SubExprs,
nullptr));
5162 llvm::copy(SubExprs, getTrailingObjects<Expr *>());
5170 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Expr *>(SubExprs.size()),
5172 return new (Mem)
RecoveryExpr(Ctx,
T, BeginLoc, EndLoc, SubExprs);
5176 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Expr *>(NumSubExprs),
5183 NumDims == Dims.size() &&
5184 "Preallocated number of dimensions is different from the provided one.");
5185 llvm::copy(Dims, getTrailingObjects<Expr *>());
5190 NumDims == BR.size() &&
5191 "Preallocated number of dimensions is different from the provided one.");
5192 llvm::copy(BR, getTrailingObjects<SourceRange>());
5195 OMPArrayShapingExpr::OMPArrayShapingExpr(
QualType ExprTy,
Expr *Op,
5199 RPLoc(R), NumDims(Dims.size()) {
5201 setDimensions(Dims);
5210 assert(Dims.size() == BracketRanges.size() &&
5211 "Different number of dimensions and brackets ranges.");
5213 totalSizeToAlloc<Expr *, SourceRange>(Dims.size() + 1, Dims.size()),
5216 E->setBracketsRanges(BracketRanges);
5223 totalSizeToAlloc<Expr *, SourceRange>(NumDims + 1, NumDims),
5228 void OMPIteratorExpr::setIteratorDeclaration(
unsigned I,
Decl *D) {
5229 assert(I < NumIterators &&
5230 "Idx is greater or equal the number of iterators definitions.");
5231 getTrailingObjects<Decl *>()[I] = D;
5235 assert(I < NumIterators &&
5236 "Idx is greater or equal the number of iterators definitions.");
5239 static_cast<int>(RangeLocOffset::AssignLoc)] =
Loc;
5242 void OMPIteratorExpr::setIteratorRange(
unsigned I,
Expr *
Begin,
5246 assert(I < NumIterators &&
5247 "Idx is greater or equal the number of iterators definitions.");
5248 getTrailingObjects<Expr *>()[I *
static_cast<int>(RangeExprOffset::Total) +
5249 static_cast<int>(RangeExprOffset::Begin)] =
5251 getTrailingObjects<Expr *>()[I *
static_cast<int>(RangeExprOffset::Total) +
5252 static_cast<int>(RangeExprOffset::End)] = End;
5253 getTrailingObjects<Expr *>()[I *
static_cast<int>(RangeExprOffset::Total) +
5254 static_cast<int>(RangeExprOffset::Step)] = Step;
5257 static_cast<int>(RangeLocOffset::FirstColonLoc)] =
5261 static_cast<int>(RangeLocOffset::SecondColonLoc)] =
5266 return getTrailingObjects<Decl *>()[I];
5272 getTrailingObjects<Expr *>()[I *
static_cast<int>(
5273 RangeExprOffset::Total) +
5274 static_cast<int>(RangeExprOffset::Begin)];
5276 getTrailingObjects<Expr *>()[I *
static_cast<int>(
5277 RangeExprOffset::Total) +
5278 static_cast<int>(RangeExprOffset::End)];
5280 getTrailingObjects<Expr *>()[I *
static_cast<int>(
5281 RangeExprOffset::Total) +
5282 static_cast<int>(RangeExprOffset::Step)];
5287 return getTrailingObjects<
5289 static_cast<int>(RangeLocOffset::AssignLoc)];
5293 return getTrailingObjects<
5295 static_cast<int>(RangeLocOffset::FirstColonLoc)];
5299 return getTrailingObjects<
5301 static_cast<int>(RangeLocOffset::SecondColonLoc)];
5305 getTrailingObjects<OMPIteratorHelperData>()[I] = D;
5309 return getTrailingObjects<OMPIteratorHelperData>()[I];
5313 return getTrailingObjects<OMPIteratorHelperData>()[I];
5316 OMPIteratorExpr::OMPIteratorExpr(
5321 IteratorKwLoc(IteratorKwLoc), LPLoc(L), RPLoc(R),
5322 NumIterators(
Data.size()) {
5323 for (
unsigned I = 0, E =
Data.size(); I < E; ++I) {
5324 const IteratorDefinition &D =
Data[I];
5325 setIteratorDeclaration(I, D.IteratorDecl);
5326 setAssignmentLoc(I, D.AssignmentLoc);
5327 setIteratorRange(I, D.Range.Begin, D.ColonLoc, D.Range.End,
5328 D.SecondColonLoc, D.Range.Step);
5329 setHelper(I, Helpers[I]);
5340 assert(
Data.size() == Helpers.size() &&
5341 "Data and helpers must have the same size.");
5343 totalSizeToAlloc<Decl *, Expr *, SourceLocation, OMPIteratorHelperData>(
5344 Data.size(),
Data.size() *
static_cast<int>(RangeExprOffset::Total),
5345 Data.size() *
static_cast<int>(RangeLocOffset::Total),
5352 unsigned NumIterators) {
5354 totalSizeToAlloc<Decl *, Expr *, SourceLocation, OMPIteratorHelperData>(
5355 NumIterators, NumIterators *
static_cast<int>(RangeExprOffset::Total),
5356 NumIterators *
static_cast<int>(RangeLocOffset::Total), NumIterators),
Defines the clang::ASTContext interface.
static bool isBooleanType(QualType Ty)
static Expr * IgnoreImplicitConstructorSingleStep(Expr *E)
Defines enum values for all the target-independent builtin functions.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
static void AssertResultStorageKind(ConstantResultStorageKind Kind)
static std::optional< unsigned > UniqueStableNameDiscriminator(ASTContext &, const NamedDecl *ND)
static const Expr * skipTemporaryBindingsNoOpCastsAndParens(const Expr *E)
Skip over any no-op casts and any temporary-binding expressions.
llvm::MachO::Target Target
Defines the clang::Preprocessor interface.
static QualType getUnderlyingType(const SubRegion *R)
static bool isRecordType(QualType T)
Defines the SourceManager interface.
static const TypeInfo & getInfo(unsigned id)
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
void setValue(const ASTContext &C, const llvm::APInt &Val)
llvm::APInt getValue() const
uint64_t * pVal
Used to store the >64 bits integer value.
uint64_t VAL
Used to store the <= 64 bits integer value.
void setIntValue(const ASTContext &C, const llvm::APInt &Val)
A non-discriminated union of a base, field, or array index.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
static APValue IndeterminateValue()
@ Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
@ None
There is no such object (it's outside its lifetime).
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
MangleContext * createMangleContext(const TargetInfo *T=nullptr)
If T is null pointer, assume the target in ASTContext.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
void * Allocate(size_t Size, unsigned Align=8) const
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Builtin::Context & BuiltinInfo
const ConstantArrayType * getAsConstantArrayType(QualType T) const
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
const LangOptions & getLangOpts() const
TypeInfo getTypeInfo(const Type *T) const
Get the size and alignment of the specified complete type in bits.
LangAS getDefaultOpenCLPointeeAddrSpace()
Returns default address space based on OpenCL version and enabled features.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedIntTy
const TargetInfo & getTargetInfo() const
llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const
Make an APSInt of the appropriate width and signedness for the given Value and integer Type.
StringLiteral * getPredefinedStringLiteralFromCache(StringRef Key) const
Return a string representing the human readable name for the specified function declaration or file n...
DiagnosticsEngine & getDiagnostics() const
UnnamedGlobalConstantDecl * getUnnamedGlobalConstantDecl(QualType Ty, const APValue &Value) const
Return a declaration for a uniquified anonymous global constant corresponding to a given APValue.
void addDestruction(T *Ptr) const
If T isn't trivially destructible, calls AddDeallocation to register it for destruction.
void resize(const ASTContext &C, unsigned N, const T &NV)
iterator insert(const ASTContext &C, iterator I, const T &Elt)
void reserve(const ASTContext &C, unsigned N)
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
QualType getValueType() const
AtomicExpr(SourceLocation BLoc, ArrayRef< Expr * > args, QualType t, AtomicOp op, SourceLocation RP)
unsigned getNumSubExprs() const
Attr - This represents one attribute.
A builtin binary operation expression such as "x + y" or "x <= y".
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
StringRef getOpcodeStr() const
SourceLocation getOperatorLoc() const
bool hasStoredFPFeatures() const
bool isCompoundAssignmentOp() const
static unsigned sizeOfTrailingObjects(bool HasFPFeatures)
Return the size in bytes needed for the trailing objects.
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
static BinaryOperator * CreateEmpty(const ASTContext &C, bool hasFPFeatures)
static bool isAssignmentOp(Opcode Opc)
static bool isNullPointerArithmeticExtension(ASTContext &Ctx, Opcode Opc, const Expr *LHS, const Expr *RHS)
Return true if a binary operator using the specified opcode and operands would match the 'p = (i8*)nu...
void setStoredFPFeatures(FPOptionsOverride F)
Set FPFeatures in trailing storage, used only by Serialization.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
BinaryOperator(const ASTContext &Ctx, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
Build a binary operator, assuming that appropriate storage has been allocated for the trailing object...
A binding in a decomposition declaration.
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
SourceLocation getCaretLocation() const
SourceLocation getCaretLocation() const
const Stmt * getBody() const
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
bool isUnevaluated(unsigned ID) const
Returns true if this builtin does not perform the side-effects of its arguments.
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
static CStyleCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures)
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
SourceLocation getLParenLoc() const
Represents a call to a CUDA kernel function.
Represents a base class of a C++ class.
Represents binding an expression to a temporary.
CXXTemporary * getTemporary()
Represents a call to a C++ constructor.
Expr * getArg(unsigned Arg)
Return the specified argument.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Represents a C++ constructor within a class.
A default argument (C++ [dcl.fct.default]).
A use of a default initializer in a constructor or in aggregate initialization.
Represents a C++ destructor within a class.
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr....
Represents a call to a member function that may be written either with member call syntax (e....
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
A call to an overloaded operator written using operator syntax.
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
SourceRange getSourceRange() const
Represents a C++ struct/union/class.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
A C++ static_cast expression (C++ [expr.static.cast]).
const CXXDestructorDecl * getDestructor() const
Represents the this expression in C++.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
bool hasStoredFPFeatures() const
static unsigned sizeOfTrailingObjects(unsigned NumPreArgs, unsigned NumArgs, bool HasFPFeatures)
Return the size in bytes needed for the trailing objects.
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
SourceLocation getBeginLoc() const LLVM_READONLY
unsigned getBuiltinCallee() const
getBuiltinCallee - If this is a call to a builtin, return the builtin ID of the callee.
static CallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Create an empty call expression, for deserialization.
bool isCallToStdMove() const
SourceLocation getEndLoc() const LLVM_READONLY
void setPreArg(unsigned I, Stmt *PreArg)
void computeDependence()
Compute and set dependence bits.
void setStoredFPFeatures(FPOptionsOverride F)
Set FPOptionsOverride in trailing storage. Used only by Serialization.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
CallExpr(StmtClass SC, Expr *Fn, ArrayRef< Expr * > PreArgs, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs, ADLCallKind UsesADL)
Build a call expression, assuming that appropriate storage has been allocated for the trailing object...
SourceLocation getRParenLoc() const
static constexpr ADLCallKind UsesADL
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 isBuiltinAssumeFalse(const ASTContext &Ctx) const
Return true if this is a call to __assume() or __builtin_assume() with a non-value-dependent constant...
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
const Attr * getUnusedResultAttr(const ASTContext &Ctx) const
Returns the WarnUnusedResultAttr that is either declared on the called function, or its return type d...
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...
unsigned getNumPreArgs() const
bool hasUnusedResultAttr(const ASTContext &Ctx) const
Returns true if this call expression should warn on unused results.
QualType withConst() const
Retrieves a version of this type with const applied.
bool isVolatileQualified() const
Represents the body of a CapturedStmt, and serves as its DeclContext.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
FPOptionsOverride * getTrailingFPFeatures()
Return a pointer to the trailing FPOptions.
NamedDecl * getConversionFunction() const
If this cast applies a user-defined conversion, retrieve the conversion function that it invokes.
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
CastKind getCastKind() const
bool hasStoredFPFeatures() const
static const FieldDecl * getTargetFieldForToUnionCast(QualType unionType, QualType opType)
const char * getCastKindName() const
SourceLocation getEnd() const
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
void setValue(unsigned Val)
static void print(unsigned val, CharacterLiteralKind Kind, raw_ostream &OS)
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Represents a class template specialization, which refers to a class template with a given set of temp...
bool isExplicitSpecialization() const
CompoundAssignOperator - For compound assignments (e.g.
static CompoundAssignOperator * CreateEmpty(const ASTContext &C, bool hasFPFeatures)
static CompoundAssignOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures, QualType CompLHSType=QualType(), QualType CompResultType=QualType())
CompoundLiteralExpr - [C99 6.5.2.5].
CompoundStmt - This represents a group of statements like { stmt stmt }.
ConditionalOperator - The ?: ternary operator.
ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
APValue getAPValueResult() const
static ConstantResultStorageKind getStorageKind(const APValue &Value)
void MoveIntoResult(APValue &Value, const ASTContext &Context)
llvm::APSInt getResultAsAPSInt() const
ConstantResultStorageKind getResultStorageKind() const
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
static ConstantExpr * CreateEmpty(const ASTContext &Context, ConstantResultStorageKind StorageKind)
A POD class for pairing a NamedDecl* with an access specifier.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
A reference to a declared variable, function, enum, etc.
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list.
void setDecl(ValueDecl *NewD)
static DeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasQualifier, bool HasFoundDecl, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Construct an empty declaration reference expression.
SourceLocation getBeginLoc() const LLVM_READONLY
DeclarationNameInfo getNameInfo() const
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
bool hasQualifier() const
Determine whether this declaration reference was preceded by a C++ nested-name-specifier,...
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name,...
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Decl - This represents one declaration (or definition), e.g.
ASTContext & getASTContext() const LLVM_READONLY
static Decl * castFromDeclContext(const DeclContext *)
AccessSpecifier getAccess() const
static bool isFlexibleArrayMemberLike(ASTContext &Context, const Decl *D, QualType Ty, LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel, bool IgnoreTemplateOrMacroSubstitution)
Whether it resembles a flexible array member.
DeclContext * getDeclContext()
DeclarationNameLoc - Additional source/type location info for a declaration name.
Represents the type decltype(expr) (C++11).
Represents a single C99 designator.
FieldDecl * getFieldDecl() const
unsigned getArrayIndex() const
SourceRange getSourceRange() const LLVM_READONLY
bool isFieldDesignator() const
SourceLocation getBeginLoc() const LLVM_READONLY
struct FieldDesignatorInfo FieldInfo
A field designator, e.g., ".x".
bool isArrayRangeDesignator() const
bool isArrayDesignator() const
SourceLocation getFieldLoc() const
const IdentifierInfo * getFieldName() const
SourceLocation getDotLoc() const
Represents a C99 designated initializer expression.
static DesignatedInitExpr * CreateEmpty(const ASTContext &C, unsigned NumIndexExprs)
Expr * getArrayRangeEnd(const Designator &D) const
Expr * getInit() const
Retrieve the initializer value.
SourceRange getDesignatorsSourceRange() const
Expr * getArrayRangeStart(const Designator &D) const
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).
static DesignatedInitExpr * Create(const ASTContext &C, llvm::ArrayRef< Designator > Designators, ArrayRef< Expr * > IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
Expr * getSubExpr(unsigned Idx) const
Expr * getArrayIndex(const Designator &D) const
unsigned size() const
Returns the number of designators in this initializer.
SourceLocation getBeginLoc() const LLVM_READONLY
void setDesignators(const ASTContext &C, const Designator *Desigs, unsigned NumDesigs)
Designator * getDesignator(unsigned Idx)
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
DesignatedInitUpdateExpr(const ASTContext &C, SourceLocation lBraceLoc, Expr *baseExprs, SourceLocation rBraceLoc)
SourceLocation getEndLoc() const LLVM_READONLY
InitListExpr * getUpdater() const
An instance of this object exists for each enum constant that is defined.
ExplicitCastExpr - An explicit cast written in the source code.
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
This represents one expression.
bool EvaluateAsInt(EvalResult &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects, bool InConstantContext=false) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer,...
EnumConstantDecl * getEnumConstantDecl()
If this expression refers to an enum constant, retrieve its declaration.
bool isReadIfDiscardedInCPlusPlus11() const
Determine whether an lvalue-to-rvalue conversion should implicitly be applied to this expression if i...
Expr * IgnoreParenNoopCasts(const ASTContext &Ctx) LLVM_READONLY
Skip past any parentheses and casts which do not change the value (including ptr->int casts of the sa...
@ SE_AllowUndefinedBehavior
Allow UB that we can give a value, but not arbitrary unmodeled side effects.
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
bool isImplicitCXXThis() const
Whether this expression is an implicit reference to 'this' in C++.
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
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...
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
Expr * IgnoreParenLValueCasts() LLVM_READONLY
Skip past any parentheses and lvalue casts which might surround this expression until reaching a fixe...
FPOptions getFPFeaturesInEffect(const LangOptions &LO) const
Returns the set of floating point options that apply to this expression.
const CXXRecordDecl * getBestDynamicClassType() const
For an expression of class type or pointer to class type, return the most derived class decl the expr...
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Expr * IgnoreConversionOperatorSingleStep() LLVM_READONLY
Skip conversion operators.
bool containsErrors() const
Whether this expression contains subexpressions which had errors, e.g.
bool isObjCSelfExpr() const
Check if this expression is the ObjC 'self' implicit parameter.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsLValue - Evaluate an expression to see if we can fold it to an lvalue with link time known ...
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...
Expr * IgnoreParenBaseCasts() LLVM_READONLY
Skip past any parentheses and derived-to-base casts until reaching a fixed point.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
const Expr * skipRValueSubobjectAdjustments() const
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
NullPointerConstantValueDependence
Enumeration used to describe how isNullPointerConstant() should cope with value-dependent expressions...
@ NPC_ValueDependentIsNull
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
@ NPC_NeverValueDependent
Specifies that the expression should never be value-dependent.
@ NPC_ValueDependentIsNotNull
Specifies that a value-dependent expression should be considered to never be a null pointer constant.
Expr * IgnoreUnlessSpelledInSource()
Skip past any invisible AST nodes which might surround this statement, such as ExprWithCleanups or Im...
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Expr * IgnoreCasts() LLVM_READONLY
Skip past any casts which might surround this expression until reaching a fixed point.
Decl * getReferencedDeclOfCallee()
Expr * IgnoreImplicitAsWritten() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
bool EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required to be a constant expression.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
const Expr * getBestDynamicClassTypeExpr() const
Get the inner expression that determines the best dynamic class.
bool isIntegerConstantExpr(const ASTContext &Ctx, SourceLocation *Loc=nullptr) const
Expr * IgnoreImpCasts() LLVM_READONLY
Skip past any implicit casts which might surround this expression until reaching a fixed point.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant().
@ NPCK_ZeroExpression
Expression is a Null pointer constant built from a zero integer expression that is not a simple,...
@ NPCK_ZeroLiteral
Expression is a Null pointer constant built from a literal zero.
@ NPCK_CXX11_nullptr
Expression is a C++11 nullptr.
@ NPCK_GNUNull
Expression is a GNU-style __null constant.
@ NPCK_NotNull
Expression is not a Null pointer constant.
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx, bool InConstantContext=false) const
EvaluateAsBooleanCondition - Return true if this is a constant which we can fold and convert to a boo...
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant.
QualType getEnumCoercedType(const ASTContext &Ctx) const
If this expression is an enumeration constant, return the enumeration type under which said constant ...
bool isBoundMemberFunction(ASTContext &Ctx) const
Returns true if this expression is a bound member function.
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,...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
static bool isSameComparisonOperand(const Expr *E1, const Expr *E2)
Checks that the two Expr's will refer to the same value as a comparison operand.
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
bool isFlexibleArrayMemberLike(ASTContext &Context, LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel, bool IgnoreTemplateOrMacroSubstitution=false) const
Check whether this array fits the idiom of a flexible array member, depending on the value of -fstric...
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
bool hasNonTrivialCall(const ASTContext &Ctx) const
Determine whether this expression involves a call to any function that is not trivial.
bool refersToGlobalRegisterVar() const
Returns whether this expression refers to a global register variable.
bool isCXX98IntegralConstantExpr(const ASTContext &Ctx) const
isCXX98IntegralConstantExpr - Return true if this expression is an integral constant expression in C+...
const ValueDecl * getAsBuiltinConstantDeclRef(const ASTContext &Context) const
If this expression is an unambiguous reference to a single declaration, in the style of __builtin_fun...
bool isOBJCGCCandidate(ASTContext &Ctx) const
isOBJCGCCandidate - Return true if this expression may be used in a read/ write barrier.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
bool isKnownToHaveBooleanValue(bool Semantic=true) const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
void setDependence(ExprDependence Deps)
Each concrete expr subclass is expected to compute its dependence and call this in the constructor.
const ObjCPropertyRefExpr * getObjCProperty() const
If this expression is an l-value for an Objective C property, find the underlying property reference ...
bool containsDuplicateElements() const
containsDuplicateElements - Return true if any element access is repeated.
const Expr * getBase() const
bool isArrow() const
isArrow - Return true if the base expression is a pointer to vector, return false if the base express...
void getEncodedElementAccess(SmallVectorImpl< uint32_t > &Elts) const
getEncodedElementAccess - Encode the elements accessed into an llvm aggregate Constant of ConstantInt...
unsigned getNumElements() const
getNumElements - Get the number of components being selected.
static int getAccessorIdx(char c, bool isNumericAccessor)
Represents difference between two FPOptions values.
bool requiresTrailingStorage() const
static FPOptions defaultWithoutTrailingStorage(const LangOptions &LO)
Return the default value of FPOptions that's used when trailing storage isn't required.
Represents a member of a struct/union/class.
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
bool isBitField() const
Determines whether this field is a bitfield.
static FixedPointLiteral * Create(const ASTContext &C, EmptyShell Empty)
Returns an empty fixed-point literal.
std::string getValueAsString(unsigned Radix) const
static FixedPointLiteral * CreateFromRawInt(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l, unsigned Scale)
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
double getValueAsApproximateDouble() const
getValueAsApproximateDouble - This returns the value as an inaccurate double.
llvm::APFloat getValue() const
FullExpr - Represents a "full-expression" node.
Represents a function declaration or definition.
FunctionDecl * getTemplateInstantiationPattern(bool ForDefinition=true) const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Represents a prototype with parameter type info, e.g.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
bool isExplicitSpecialization() const
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
FunctionType - C99 6.7.5.3 - Function Declarators.
CallingConv getCallConv() const
QualType getReturnType() const
Represents a C11 generic selection.
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression accepting an expression predicate.
static GenericSelectionExpr * CreateEmpty(const ASTContext &Context, unsigned NumAssocs)
Create an empty generic selection expression for deserialization.
GlobalDecl - represents a global declaration.
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
static ImplicitCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures)
Describes an C or C++ initializer list.
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
InitListExpr(const ASTContext &C, SourceLocation lbraceloc, ArrayRef< Expr * > initExprs, SourceLocation rbraceloc)
bool isTransparent() const
Is this a transparent initializer list (that is, an InitListExpr that is purely syntactic,...
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
bool isStringLiteralInit() const
Is this an initializer for an array of characters, initialized by a string literal or an @encode?
unsigned getNumInits() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isSemanticForm() const
void setInit(unsigned Init, Expr *expr)
const Expr * getInit(unsigned Init) const
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...
ArrayRef< Expr * > inits()
void setArrayFiller(Expr *filler)
Expr ** getInits()
Retrieve the set of initializers.
bool isIdiomaticZeroInitializer(const LangOptions &LangOpts) const
Is this the zero initializer {0} in a language which considers it idiomatic?
SourceLocation getEndLoc() const LLVM_READONLY
bool isSyntacticForm() const
void sawArrayRangeDesignator(bool ARD=true)
InitListExpr * getSyntacticForm() const
void reserveInits(const ASTContext &C, unsigned NumInits)
Reserve space for some number of initializers.
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'.
static ItaniumMangleContext * create(ASTContext &Context, DiagnosticsEngine &Diags, bool IsAux=false)
LabelStmt - Represents a label, which has a substatement.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
StrictFlexArraysLevelKind
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
std::string SYCLUniquePrefix
A driver-provided unique string for this translation unit that is used to generate unique names for S...
void remapPathPrefix(SmallVectorImpl< char > &Path) const
Remap path prefix according to -fmacro-prefix-path option.
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens.
bool LexFromRawLexer(Token &Result)
LexFromRawLexer - Lex a token from a designated raw lexer (one with no associated preprocessor object...
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,...
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
static MemberExpr * CreateEmpty(const ASTContext &Context, bool HasQualifier, bool HasFoundDecl, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
void setMemberDecl(ValueDecl *D)
NestedNameSpecifierLoc getQualifierLoc() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name,...
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
static MemberExpr * Create(const ASTContext &C, Expr *Base, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *MemberDecl, DeclAccessPair FoundDecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, QualType T, ExprValueKind VK, ExprObjectKind OK, NonOdrUseReason NOUR)
bool isImplicitAccess() const
Determine whether the base of this explicit is implicit.
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
A pointer to member type per C++ 8.3.3 - Pointers to members.
This represents a decl that may have a name.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
bool isExternallyVisible() const
A C++ nested-name-specifier augmented with source location information.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
bool hasQualifier() const
Evaluates true when this nested-name-specifier location is non-empty.
An explicit cast in C or a C-style cast in C++, which uses the syntax ([s1][s2]......
static OMPArrayShapingExpr * CreateEmpty(const ASTContext &Context, unsigned NumDims)
static OMPArrayShapingExpr * Create(const ASTContext &Context, QualType T, Expr *Op, SourceLocation L, SourceLocation R, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > BracketRanges)
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
static OMPIteratorExpr * Create(const ASTContext &Context, QualType T, SourceLocation IteratorKwLoc, SourceLocation L, SourceLocation R, ArrayRef< IteratorDefinition > Data, ArrayRef< OMPIteratorHelperData > Helpers)
static OMPIteratorExpr * CreateEmpty(const ASTContext &Context, unsigned NumIterators)
SourceLocation getSecondColonLoc(unsigned I) const
Gets the location of the second ':' (if any) in the range for the given iteratori definition.
SourceLocation getColonLoc(unsigned I) const
Gets the location of the first ':' in the range for the given iterator definition.
IteratorRange getIteratorRange(unsigned I)
Gets the iterator range for the given iterator.
OMPIteratorHelperData & getHelper(unsigned I)
Fetches helper data for the specified iteration space.
SourceLocation getAssignLoc(unsigned I) const
Gets the location of '=' for the given iterator definition.
Decl * getIteratorDecl(unsigned I)
Gets the iterator declaration for the given iterator.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Represents an ObjC class declaration.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
An expression that sends a message to the given Objective-C object or class.
ObjCMethodFamily getMethodFamily() const
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
const ObjCMethodDecl * getMethodDecl() const
ObjCMethodDecl - Represents an instance or class method declaration.
ImplicitParamDecl * getSelfDecl() const
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
static OffsetOfExpr * CreateEmpty(const ASTContext &C, unsigned NumComps, unsigned NumExprs)
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr * > exprs, SourceLocation RParenLoc)
void setIndexExpr(unsigned Idx, Expr *E)
void setComponent(unsigned Idx, OffsetOfNode ON)
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
FieldDecl * getField() const
For a field offsetof node, returns the field.
@ Identifier
A field in a dependent type, known only by its name.
Kind getKind() const
Determine what kind of offsetof node this is.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
static const OpaqueValueExpr * findInCopyConstruct(const Expr *expr)
Given an expression which invokes a copy constructor — i.e.
ParenExpr - This represents a parethesized expression, e.g.
static ParenListExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumExprs)
Create an empty paren list.
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr * > Exprs, SourceLocation RParenLoc)
Create a paren list.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
[C99 6.4.2.2] - A predefined identifier such as func.
static PredefinedExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType FNTy, PredefinedIdentKind IK, bool IsTransparent, StringLiteral *SL)
Create a PredefinedExpr.
StringRef getIdentKindName() const
static PredefinedExpr * CreateEmpty(const ASTContext &Ctx, bool HasFunctionName)
Create an empty PredefinedExpr.
static std::string ComputeName(PredefinedIdentKind IK, const Decl *CurrentDecl, bool ForceElaboratedPrinting=false)
static void processPathToFileName(SmallVectorImpl< char > &FileName, const PresumedLoc &PLoc, const LangOptions &LangOpts, const TargetInfo &TI)
static void processPathForFileMacro(SmallVectorImpl< char > &Path, const LangOptions &LangOpts, const TargetInfo &TI)
Represents an unpacked "presumed" location which can be presented to the user.
unsigned getColumn() const
Return the presumed column number of this location.
const char * getFilename() const
Return the presumed filename of this location.
unsigned getLine() const
Return the presumed line number of this location.
Callbacks to use to customize the behavior of the pretty-printer.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
semantics_iterator semantics_end()
semantics_iterator semantics_begin()
const Expr *const * const_semantics_iterator
ArrayRef< Expr * > semantics()
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr * > semantic, unsigned resultIndex)
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
LangAS getAddressSpace() const
Return the address space of this type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
QualType getCanonicalType() const
The collection of all-type qualifiers we support.
void removeAddressSpace()
Represents a struct/union/class.
field_iterator field_end() const
field_range fields() const
field_iterator field_begin() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
static RecoveryExpr * Create(ASTContext &Ctx, QualType T, SourceLocation BeginLoc, SourceLocation EndLoc, ArrayRef< Expr * > SubExprs)
static RecoveryExpr * CreateEmpty(ASTContext &Ctx, unsigned NumSubExprs)
static SYCLUniqueStableIdExpr * CreateEmpty(const ASTContext &Ctx)
std::string ComputeName(ASTContext &Context) const
static SYCLUniqueStableIdExpr * Create(const ASTContext &Ctx, SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, Expr *E)
TypeSourceInfo * getTypeSourceInfo()
static SYCLUniqueStableNameExpr * Create(const ASTContext &Ctx, SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
std::string ComputeName(ASTContext &Context) const
static SYCLUniqueStableNameExpr * CreateEmpty(const ASTContext &Ctx)
void setExprs(const ASTContext &C, ArrayRef< Expr * > Exprs)
ShuffleVectorExpr(const ASTContext &C, ArrayRef< Expr * > args, QualType Type, SourceLocation BLoc, SourceLocation RP)
const DeclContext * getParentContext() const
If the SourceLocExpr has been resolved return the subexpression representing the resolved value.
APValue EvaluateInContext(const ASTContext &Ctx, const Expr *DefaultExpr) const
Return the result of evaluating this SourceLocExpr in the specified (and possibly null) default argum...
SourceLocExpr(const ASTContext &Ctx, SourceLocIdentKind Type, QualType ResultTy, SourceLocation BLoc, SourceLocation RParenLoc, DeclContext *Context)
SourceLocation getLocation() const
StringRef getBuiltinStr() const
Return a string representing the name of the specific builtin function.
SourceLocIdentKind getIdentKind() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
CharSourceRange getExpansionRange(SourceLocation Loc) const
Given a SourceLocation object, return the range of tokens covered by the expansion in the ultimate fi...
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits
GenericSelectionExprBitfields GenericSelectionExprBits
ParenListExprBitfields ParenListExprBits
CallExprBitfields CallExprBits
FloatingLiteralBitfields FloatingLiteralBits
child_iterator child_begin()
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
UnaryOperatorBitfields UnaryOperatorBits
SourceLocExprBitfields SourceLocExprBits
ConstantExprBitfields ConstantExprBits
llvm::iterator_range< child_iterator > child_range
StringLiteralBitfields StringLiteralBits
MemberExprBitfields MemberExprBits
DeclRefExprBitfields DeclRefExprBits
ConstStmtIterator const_child_iterator
PredefinedExprBitfields PredefinedExprBits
SourceLocation getBeginLoc() const LLVM_READONLY
BinaryOperatorBitfields BinaryOperatorBits
PseudoObjectExprBitfields PseudoObjectExprBits
llvm::iterator_range< const_child_iterator > const_child_range
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
unsigned getOffsetOfStringByte(const Token &TheTok, unsigned ByteNo) const
getOffsetOfStringByte - This function returns the offset of the specified byte of the string data rep...
unsigned GetStringLength() const
StringLiteral - This represents a string literal expression, e.g.
SourceLocation getStrTokenLoc(unsigned TokNum) const
Get one of the string literal token.
unsigned getLength() const
StringLiteralKind getKind() const
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...
uint32_t getCodeUnit(size_t i) const
void outputString(raw_ostream &OS) const
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringLiteralKind 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 StringLiteral * CreateEmpty(const ASTContext &Ctx, unsigned NumConcatenated, unsigned Length, unsigned CharByteWidth)
Construct an empty string literal.
unsigned getNumConcatenated() const
getNumConcatenated - Get the number of string literal tokens that were concatenated in translation ph...
Represents the declaration of a struct/union/class/enum.
Exposes information about the current target.
A convenient class for passing around template argument information.
A template argument list.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
Location wrapper for a TemplateArgument.
void print(const PrintingPolicy &Policy, raw_ostream &Out, bool IncludeType) const
Print this template argument to the given output stream.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
static bool shouldIncludeTypeForArgument(const PrintingPolicy &Policy, const TemplateParameterList *TPL, unsigned Idx)
Token - This structure provides full information about a lexed token.
A container of type source information.
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBooleanType() const
bool hasAttr(attr::Kind AK) const
Determine whether this type had the specified attribute applied to it (looking through top-level type...
bool isPointerType() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
bool isReferenceType() const
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that the type refers to.
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isVectorType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
bool isRecordType() const
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
QualType getArgumentType() const
bool isArgumentType() const
UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, TypeSourceInfo *TInfo, QualType resultType, SourceLocation op, SourceLocation rp)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
bool hasStoredFPFeatures() const
Is FPFeatures in Trailing Storage?
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode.
Expr * getSubExpr() const
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
void setStoredFPFeatures(FPOptionsOverride F)
Set FPFeatures in trailing storage, used by Serialization & ASTImporter.
UnaryOperator(const ASTContext &Ctx, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
static UnaryOperator * CreateEmpty(const ASTContext &C, bool hasFPFeatures)
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to,...
An artificial decl, representing a global anonymous constant value which is uniquified by value withi...
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit....
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
Defines the clang::TargetInfo interface.
constexpr XRayInstrMask None
bool hasSideEffects(Expr *E, ASTContext &Ctx)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
bool This(InterpState &S, CodePtr OpPC)
bool LE(InterpState &S, CodePtr OpPC)
bool Comp(InterpState &S, CodePtr OpPC)
1) Pops the value from the stack.
bool Cast(InterpState &S, CodePtr OpPC)
bool GE(InterpState &S, CodePtr OpPC)
constexpr bool isIntegralType(PrimType T)
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
ConstantResultStorageKind
Describes the kind of result that can be tail-allocated.
@ Ctor_Base
Base object ctor.
LLVM_READONLY bool isPrintable(unsigned char c)
Return true if this character is an ASCII printable character; that is, a character that should take ...
Expr * IgnoreParensOnlySingleStep(Expr *E)
Expr * IgnoreCastsSingleStep(Expr *E)
Expr * IgnoreBaseCastsSingleStep(Expr *E)
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
@ RQ_LValue
An lvalue ref-qualifier was provided (&).
@ RQ_RValue
An rvalue ref-qualifier was provided (&&).
StmtIterator cast_away_const(const ConstStmtIterator &RHS)
Expr * IgnoreParensSingleStep(Expr *E)
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
@ OK_Ordinary
An ordinary object is located at an address in memory.
Expr * IgnoreImplicitAsWrittenSingleStep(Expr *E)
ExprDependence computeDependence(FullExpr *E)
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Expr * IgnoreImplicitCastsSingleStep(Expr *E)
@ Dtor_Base
Base object dtor.
Expr * IgnoreExprNodes(Expr *E, FnTys &&... Fns)
Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *, Recursively apply each of the f...
CastKind
CastKind - The kind of operation required for a conversion.
void FixedPointValueToString(SmallVectorImpl< char > &Str, llvm::APSInt Val, unsigned Scale)
Expr * IgnoreImplicitCastsExtraSingleStep(Expr *E)
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
const FunctionProtoType * T
Expr * IgnoreLValueCastsSingleStep(Expr *E)
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Expr * IgnoreImplicitSingleStep(Expr *E)
@ PrettyFunctionNoVirtual
The same as PrettyFunction, except that the 'virtual' keyword is omitted for virtual member functions...
NonOdrUseReason
The reason why a DeclRefExpr does not constitute an odr-use.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceLocation getEndLoc() const LLVM_READONLY
EvalResult is a struct with detailed info about an evaluated expression.
APValue Val
Val - This is the value the expression can be folded to.
Iterator range representation begin:end[:step].
Helper expressions and declaration for OMPIteratorExpr class for each iteration space.
Describes how types, statements, expressions, and declarations should be printed.
unsigned SuppressTagKeyword
Whether type printing should skip printing the tag keyword.
const PrintingCallbacks * Callbacks
Callbacks to use to allow the behavior of printing to be customized.
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....
An adjustment to be made to the temporary created when emitting a reference binding,...