35#include "llvm/Support/ErrorHandling.h"
36#include "llvm/Support/Format.h"
37#include "llvm/Support/raw_ostream.h"
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();
87 if (
const auto *CE = dyn_cast<CastExpr>(
E)) {
88 if ((CE->getCastKind() == CK_DerivedToBase ||
89 CE->getCastKind() == CK_UncheckedDerivedToBase) &&
97 if (CE->getCastKind() == CK_NoOp) {
101 }
else if (
const auto *ME = dyn_cast<MemberExpr>(
E)) {
102 if (!ME->isArrow()) {
103 assert(ME->getBase()->getType()->getAsRecordDecl());
104 if (
const auto *Field = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
105 if (!Field->isBitField() && !Field->getType()->isReferenceType()) {
112 }
else if (
const auto *BO = dyn_cast<BinaryOperator>(
E)) {
113 if (BO->getOpcode() == BO_PtrMemD) {
114 assert(BO->getRHS()->isPRValue());
120 if (BO->getOpcode() == BO_Comma) {
121 CommaLHSs.push_back(BO->getLHS());
142 switch (UO->getOpcode()) {
144 return UO->getSubExpr()->isKnownToHaveBooleanValue(Semantic);
156 return CE->getSubExpr()->isKnownToHaveBooleanValue(Semantic);
159 switch (BO->getOpcode()) {
160 default:
return false;
175 return BO->getLHS()->isKnownToHaveBooleanValue(Semantic) &&
176 BO->getRHS()->isKnownToHaveBooleanValue(Semantic);
180 return BO->getRHS()->isKnownToHaveBooleanValue(Semantic);
185 return CO->getTrueExpr()->isKnownToHaveBooleanValue(Semantic) &&
186 CO->getFalseExpr()->isKnownToHaveBooleanValue(Semantic);
188 if (isa<ObjCBoolLiteralExpr>(
E))
191 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(
E))
192 return OVE->getSourceExpr()->isKnownToHaveBooleanValue(Semantic);
195 if (!Semantic && FD->getType()->isUnsignedIntegerType() &&
196 !FD->getBitWidth()->isValueDependent() && FD->getBitWidthValue() == 1)
205 bool IgnoreTemplateOrMacroSubstitution)
const {
207 const Decl *
D =
nullptr;
209 if (
const auto *ME = dyn_cast<MemberExpr>(
E))
210 D = ME->getMemberDecl();
211 else if (
const auto *DRE = dyn_cast<DeclRefExpr>(
E))
213 else if (
const auto *IRE = dyn_cast<ObjCIvarRefExpr>(
E))
217 StrictFlexArraysLevel,
218 IgnoreTemplateOrMacroSubstitution);
228 if (
Value.isMemberPointer())
229 return Value.getMemberPointerDecl();
231 if (
Value.isLValue() &&
Value.getLValueOffset().isZero())
245 template <
class E,
class T>
248 return static_cast<const E*
>(
expr)->getExprLoc();
258 return static_cast<const E *
>(
expr)->getBeginLoc();
266 const auto *ED = cast<EnumDecl>(ECD->getDeclContext());
267 if (ED->isCompleteDefinition())
276#define ABSTRACT_STMT(type)
277#define STMT(type, base) \
278 case Stmt::type##Class: break;
279#define EXPR(type, base) \
280 case Stmt::type##Class: return getExprLocImpl<type>(this, &type::getExprLoc);
281#include "clang/AST/StmtNodes.inc"
283 llvm_unreachable(
"unknown expression kind");
294 "Invalid StorageKind Value");
304 if (!
Value.getInt().needsCleanup())
320 bool IsImmediateInvocation)
321 :
FullExpr(ConstantExprClass, SubExpr) {
330 ::new (getTrailingObjects<APValue>())
APValue();
335 bool IsImmediateInvocation) {
336 assert(!isa<ConstantExpr>(
E));
339 unsigned Size = totalSizeToAlloc<APValue, uint64_t>(
343 return new (Mem)
ConstantExpr(
E, StorageKind, IsImmediateInvocation);
354ConstantExpr::ConstantExpr(EmptyShell
Empty,
360 ::new (getTrailingObjects<APValue>())
APValue();
367 unsigned Size = totalSizeToAlloc<APValue, uint64_t>(
376 "Invalid storage for this value kind");
382 Int64Result() = *
Value.getInt().getRawData();
391 APValueResult() = std::move(
Value);
394 llvm_unreachable(
"Invalid ResultKind Bits");
400 return APValueResult().
getInt();
405 llvm_unreachable(
"invalid Accessor");
413 return APValueResult();
423 llvm_unreachable(
"invalid ResultKind");
427 bool RefersToEnclosingVariableOrCapture,
QualType T,
437 RefersToEnclosingVariableOrCapture;
438 DeclRefExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter =
false;
445DeclRefExpr::DeclRefExpr(
const ASTContext &Ctx,
448 bool RefersToEnclosingVariableOrCapture,
457 new (getTrailingObjects<NestedNameSpecifierLoc>())
461 *getTrailingObjects<NamedDecl *>() = FoundD;
463 = (TemplateArgs || TemplateKWLoc.
isValid()) ? 1 : 0;
465 RefersToEnclosingVariableOrCapture;
466 DeclRefExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter =
false;
469 auto Deps = TemplateArgumentDependence::None;
470 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
471 TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
473 assert(!(Deps & TemplateArgumentDependence::Dependent) &&
474 "built a DeclRefExpr with dependent template args");
475 }
else if (TemplateKWLoc.
isValid()) {
476 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
487 bool RefersToEnclosingVariableOrCapture,
492 return Create(Context, QualifierLoc, TemplateKWLoc,
D,
493 RefersToEnclosingVariableOrCapture,
495 T,
VK, FoundD, TemplateArgs, NOUR);
501 bool RefersToEnclosingVariableOrCapture,
511 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
515 QualifierLoc ? 1 : 0, FoundD ? 1 : 0,
516 HasTemplateKWAndArgsInfo ? 1 : 0,
517 TemplateArgs ? TemplateArgs->
size() : 0);
520 return new (Mem)
DeclRefExpr(Context, QualifierLoc, TemplateKWLoc,
D,
521 RefersToEnclosingVariableOrCapture, NameInfo,
522 FoundD, TemplateArgs,
T,
VK, NOUR);
528 bool HasTemplateKWAndArgsInfo,
529 unsigned NumTemplateArgs) {
530 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
534 HasQualifier ? 1 : 0, HasFoundDecl ? 1 : 0, HasTemplateKWAndArgsInfo,
542 if (
getType()->isUndeducedType())
553SYCLUniqueStableNameExpr::SYCLUniqueStableNameExpr(
SourceLocation OpLoc,
559 OpLoc(OpLoc), LParen(LParen), RParen(RParen) {
560 setTypeSourceInfo(TSI);
564SYCLUniqueStableNameExpr::SYCLUniqueStableNameExpr(EmptyShell
Empty,
592 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
593 return RD->getDeviceLambdaManglingNumber();
602 llvm::raw_string_ostream Out(Buffer);
603 Ctx->mangleCanonicalTypeName(Ty, Out);
613 assert((getIdentKind() == IK) &&
614 "IdentKind do not fit in PredefinedExprBitfields!");
615 bool HasFunctionName = SL !=
nullptr;
624PredefinedExpr::PredefinedExpr(EmptyShell
Empty,
bool HasFunctionName)
632 bool HasFunctionName = SL !=
nullptr;
633 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
639 bool HasFunctionName) {
640 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
650 return "__FUNCTION__";
652 return "__FUNCDNAME__";
654 return "L__FUNCTION__";
656 return "__PRETTY_FUNCTION__";
658 return "__FUNCSIG__";
660 return "L__FUNCSIG__";
664 llvm_unreachable(
"Unknown ident kind for PredefinedExpr");
670 const Decl *CurrentDecl,
671 bool ForceElaboratedPrinting) {
675 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(CurrentDecl)) {
676 std::unique_ptr<MangleContext> MC;
679 if (MC->shouldMangleDeclName(ND)) {
681 llvm::raw_svector_ostream Out(Buffer);
687 else if (
auto FD = dyn_cast<FunctionDecl>(ND)) {
691 MC->mangleName(GD, Out);
693 if (!Buffer.empty() && Buffer.front() ==
'\01')
694 return std::string(Buffer.substr(1));
695 return std::string(Buffer);
697 return std::string(ND->getIdentifier()->getName());
701 if (isa<BlockDecl>(CurrentDecl)) {
706 if (DC->isFileContext())
710 llvm::raw_svector_ostream Out(Buffer);
711 if (
auto *DCBlock = dyn_cast<BlockDecl>(DC))
714 else if (
auto *DCDecl = dyn_cast<Decl>(DC))
716 return std::string(Out.str());
718 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
720 bool IsFuncOrFunctionInNonMSVCCompatEnv =
722 IK == PredefinedIdentKind ::Function) &&
724 bool IsLFunctionInMSVCCommpatEnv =
726 bool IsFuncOrFunctionOrLFunctionOrFuncDName =
731 if ((ForceElaboratedPrinting &&
732 (IsFuncOrFunctionInNonMSVCCompatEnv || IsLFunctionInMSVCCommpatEnv)) ||
733 (!ForceElaboratedPrinting && IsFuncOrFunctionOrLFunctionOrFuncDName))
734 return FD->getNameAsString();
737 llvm::raw_svector_ostream Out(Name);
742 if (MD->isStatic() && !ForceElaboratedPrinting)
749 std::string remapPath(StringRef
Path)
const override {
752 return std::string(p);
764 llvm::raw_string_ostream POut(Proto);
773 const Type *Ty =
Decl->getType().getTypePtrOrNull();
779 if (FD->hasWrittenPrototype())
780 FT = dyn_cast<FunctionProtoType>(AFT);
785 case CC_C: POut <<
"__cdecl ";
break;
796 FD->printQualifiedName(POut, Policy);
800 return std::string(Name);
805 for (
unsigned i = 0, e =
Decl->getNumParams(); i != e; ++i) {
807 POut <<
Decl->getParamDecl(i)->getType().stream(Policy);
810 if (FT->isVariadic()) {
811 if (FD->getNumParams()) POut <<
", ";
816 !
Decl->getNumParams()) {
823 assert(FT &&
"We must have a written prototype in this case.");
826 if (FT->isVolatile())
838 while (isa_and_nonnull<NamedDecl>(Ctx)) {
840 = dyn_cast<ClassTemplateSpecializationDecl>(Ctx);
842 Specs.push_back(Spec);
843 Ctx = Ctx->getParent();
846 std::string TemplateParams;
847 llvm::raw_string_ostream TOut(TemplateParams);
850 D->getSpecializedTemplate()->getTemplateParameters();
852 assert(Params->
size() == Args.
size());
853 for (
unsigned i = 0, numParams = Params->
size(); i != numParams; ++i) {
855 if (Param.empty())
continue;
856 TOut << Param <<
" = ";
865 = FD->getTemplateSpecializationInfo();
870 assert(Params->
size() == Args->
size());
871 for (
unsigned i = 0, e = Params->
size(); i != e; ++i) {
873 if (Param.empty())
continue;
874 TOut << Param <<
" = ";
875 Args->
get(i).
print(Policy, TOut,
true);
880 if (!TemplateParams.empty()) {
882 TemplateParams.resize(TemplateParams.size() - 2);
883 POut <<
" [" << TemplateParams <<
"]";
891 Proto =
"auto " + Proto;
892 else if (FT && FT->getReturnType()->getAs<
DecltypeType>())
897 else if (!isa<CXXConstructorDecl>(FD) && !isa<CXXDestructorDecl>(FD))
902 return std::string(Name);
904 if (
const CapturedDecl *CD = dyn_cast<CapturedDecl>(CurrentDecl)) {
908 if (DC->isFunctionOrMethod() && (DC->getDeclKind() != Decl::Captured)) {
912 llvm_unreachable(
"CapturedDecl not inside a function or method");
914 if (
const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(CurrentDecl)) {
916 llvm::raw_svector_ostream Out(Name);
917 Out << (MD->isInstanceMethod() ?
'-' :
'+');
926 dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext()))
927 Out <<
'(' << *CID <<
')';
930 MD->getSelector().print(Out);
933 return std::string(Name);
935 if (isa<TranslationUnitDecl>(CurrentDecl) &&
944 const llvm::APInt &Val) {
949 unsigned NumWords = Val.getNumWords();
950 const uint64_t* Words = Val.getRawData();
952 pVal =
new (
C) uint64_t[NumWords];
953 std::copy(Words, Words + NumWords,
pVal);
954 }
else if (NumWords == 1)
960IntegerLiteral::IntegerLiteral(
const ASTContext &
C,
const llvm::APInt &
V,
963 assert(
type->isIntegerType() &&
"Illegal type in IntegerLiteral");
964 assert(
V.getBitWidth() ==
C.getIntWidth(
type) &&
965 "Integer type is not the correct size for constant.");
981FixedPointLiteral::FixedPointLiteral(
const ASTContext &
C,
const llvm::APInt &
V,
986 assert(
type->isFixedPointType() &&
"Illegal type in FixedPointLiteral");
987 assert(
V.getBitWidth() ==
C.getTypeInfo(
type).Width &&
988 "Fixed point type is not the correct size for constant.");
994 const llvm::APInt &
V,
1012 S, llvm::APSInt::getUnsigned(
getValue().getZExtValue()), Scale);
1013 return std::string(S);
1035 StringRef Escaped = escapeCStyle<EscapeChar::Single>(Val);
1036 if (!Escaped.empty()) {
1037 OS <<
"'" << Escaped <<
"'";
1046 OS <<
"'" << (char)Val <<
"'";
1048 OS <<
"'\\x" << llvm::format(
"%02x", Val) <<
"'";
1049 else if (Val <= 0xFFFF)
1050 OS <<
"'\\u" << llvm::format(
"%04x", Val) <<
"'";
1052 OS <<
"'\\U" << llvm::format(
"%08x", Val) <<
"'";
1056FloatingLiteral::FloatingLiteral(
const ASTContext &
C,
const llvm::APFloat &
V,
1059 setSemantics(
V.getSemantics());
1067 setRawSemantics(llvm::APFloatBase::S_IEEEhalf);
1088 V.convert(llvm::APFloat::IEEEdouble(), llvm::APFloat::rmNearestTiesToEven,
1090 return V.convertToDouble();
1095 unsigned CharByteWidth = 0;
1100 CharByteWidth =
Target.getCharWidth();
1103 CharByteWidth =
Target.getWCharWidth();
1106 CharByteWidth =
Target.getChar16Width();
1109 CharByteWidth =
Target.getChar32Width();
1112 return sizeof(char);
1114 assert((CharByteWidth & 7) == 0 &&
"Assumes character size is byte multiple");
1116 assert((CharByteWidth == 1 || CharByteWidth == 2 || CharByteWidth == 4) &&
1117 "The only supported character byte widths are 1,2 and 4!");
1118 return CharByteWidth;
1121StringLiteral::StringLiteral(
const ASTContext &Ctx, StringRef Str,
1126 unsigned Length = Str.size();
1133 "StringLiteral must be of constant array type!");
1134 unsigned CharByteWidth = mapCharByteWidth(Ctx.
getTargetInfo(), Kind);
1135 unsigned ByteLength = Str.size();
1136 assert((ByteLength % CharByteWidth == 0) &&
1137 "The size of the data must be a multiple of CharByteWidth!");
1142 switch (CharByteWidth) {
1144 Length = ByteLength;
1147 Length = ByteLength / 2;
1150 Length = ByteLength / 4;
1153 llvm_unreachable(
"Unsupported character width!");
1159 assert(!Pascal &&
"Can't make an unevaluated Pascal string");
1164 *getTrailingObjects<unsigned>() = Length;
1168 llvm::copy(Locs, getTrailingObjects<SourceLocation>());
1171 llvm::copy(Str, getTrailingObjects<char>());
1176StringLiteral::StringLiteral(EmptyShell
Empty,
unsigned NumConcatenated,
1177 unsigned Length,
unsigned CharByteWidth)
1181 *getTrailingObjects<unsigned>() = Length;
1188 void *Mem = Ctx.
Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
1189 1, Locs.size(), Str.size()),
1191 return new (Mem)
StringLiteral(Ctx, Str, Kind, Pascal, Ty, Locs);
1195 unsigned NumConcatenated,
1197 unsigned CharByteWidth) {
1198 void *Mem = Ctx.
Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
1199 1, NumConcatenated, Length * CharByteWidth),
1225 static const char Hex[] =
"0123456789ABCDEF";
1228 for (
unsigned I = 0, N =
getLength(); I != N; ++I) {
1230 StringRef Escaped = escapeCStyle<EscapeChar::Double>(Char);
1231 if (Escaped.empty()) {
1237 Char >= 0xd800 && Char <= 0xdbff) {
1239 if (Trail >= 0xdc00 && Trail <= 0xdfff) {
1240 Char = 0x10000 + ((Char - 0xd800) << 10) + (Trail - 0xdc00);
1250 (Char >= 0xd800 && Char <= 0xdfff) || Char >= 0x110000) {
1254 while ((Char >> Shift) == 0)
1256 for (; Shift >= 0; Shift -= 4)
1257 OS << Hex[(Char >> Shift) & 15];
1264 << Hex[(Char >> 20) & 15]
1265 << Hex[(Char >> 16) & 15];
1268 OS << Hex[(Char >> 12) & 15]
1269 << Hex[(Char >> 8) & 15]
1270 << Hex[(Char >> 4) & 15]
1271 << Hex[(Char >> 0) & 15];
1277 if (LastSlashX + 1 == I) {
1279 case '0':
case '1':
case '2':
case '3':
case '4':
1280 case '5':
case '6':
case '7':
case '8':
case '9':
1281 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
1282 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
1287 assert(Char <= 0xff &&
1288 "Characters above 0xff should already have been handled.");
1294 << (char)(
'0' + ((Char >> 6) & 7))
1295 << (char)(
'0' + ((Char >> 3) & 7))
1296 << (char)(
'0' + ((Char >> 0) & 7));
1325 unsigned *StartTokenByteOffset)
const {
1334 "Only narrow string literals are currently supported");
1339 unsigned StringOffset = 0;
1341 TokNo = *StartToken;
1342 if (StartTokenByteOffset) {
1343 StringOffset = *StartTokenByteOffset;
1344 ByteNo -= StringOffset;
1358 StringRef Buffer =
SM.getBufferData(LocInfo.first, &
Invalid);
1360 if (StartTokenByteOffset !=
nullptr)
1361 *StartTokenByteOffset = StringOffset;
1362 if (StartToken !=
nullptr)
1363 *StartToken = TokNo;
1364 return StrTokSpellingLoc;
1367 const char *StrData = Buffer.data()+LocInfo.second;
1370 Lexer TheLexer(
SM.getLocForStartOfFile(LocInfo.first), Features,
1371 Buffer.begin(), StrData, Buffer.end());
1380 if (ByteNo < TokNumBytes ||
1386 if (StartTokenByteOffset !=
nullptr)
1387 *StartTokenByteOffset = StringOffset;
1388 if (StartToken !=
nullptr)
1389 *StartToken = TokNo;
1394 StringOffset += TokNumBytes;
1396 ByteNo -= TokNumBytes;
1404#define UNARY_OPERATION(Name, Spelling) case UO_##Name: return Spelling;
1405#include "clang/AST/OperationKinds.def"
1407 llvm_unreachable(
"Unknown unary operator");
1413 default: llvm_unreachable(
"No unary operator for overloaded function");
1414 case OO_PlusPlus:
return Postfix ? UO_PostInc : UO_PreInc;
1415 case OO_MinusMinus:
return Postfix ? UO_PostDec : UO_PreDec;
1416 case OO_Amp:
return UO_AddrOf;
1417 case OO_Star:
return UO_Deref;
1418 case OO_Plus:
return UO_Plus;
1419 case OO_Minus:
return UO_Minus;
1420 case OO_Tilde:
return UO_Not;
1421 case OO_Exclaim:
return UO_LNot;
1422 case OO_Coawait:
return UO_Coawait;
1428 case UO_PostInc:
case UO_PreInc:
return OO_PlusPlus;
1429 case UO_PostDec:
case UO_PreDec:
return OO_MinusMinus;
1430 case UO_AddrOf:
return OO_Amp;
1431 case UO_Deref:
return OO_Star;
1432 case UO_Plus:
return OO_Plus;
1433 case UO_Minus:
return OO_Minus;
1434 case UO_Not:
return OO_Tilde;
1435 case UO_LNot:
return OO_Exclaim;
1436 case UO_Coawait:
return OO_Coawait;
1448 case Expr::CallExprClass:
1450 case Expr::CXXOperatorCallExprClass:
1452 case Expr::CXXMemberCallExprClass:
1454 case Expr::UserDefinedLiteralClass:
1456 case Expr::CUDAKernelCallExprClass:
1459 llvm_unreachable(
"unexpected class deriving from CallExpr!");
1467 "we assume CXXOperatorCallExpr is at most 32 bytes");
1474 NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1475 unsigned NumPreArgs = PreArgs.size();
1477 assert((NumPreArgs ==
getNumPreArgs()) &&
"NumPreArgs overflow!");
1479 "This CallExpr subclass is too big or unsupported");
1484 for (
unsigned I = 0; I != NumPreArgs; ++I)
1486 for (
unsigned I = 0; I != Args.size(); ++I)
1488 for (
unsigned I = Args.size(); I != NumArgs; ++I)
1495 CallExprBits.ExplicitObjectMemFunUsingMemberSyntax =
false;
1506 assert((NumPreArgs ==
getNumPreArgs()) &&
"NumPreArgs overflow!");
1509 CallExprBits.ExplicitObjectMemFunUsingMemberSyntax =
false;
1518 unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1522 sizeToAllocateForCallExprSubclass<CallExpr>(SizeOfTrailingObjects),
1525 new (Mem)
CallExpr(CallExprClass, Fn, {}, Args, Ty,
VK,
1526 RParenLoc, FPFeatures, MinNumArgs,
UsesADL);
1527 E->updateTrailingSourceLoc();
1533 unsigned SizeOfTrailingObjects =
1536 sizeToAllocateForCallExprSubclass<CallExpr>(SizeOfTrailingObjects),
1549 if (
auto *DRE = dyn_cast<DeclRefExpr>(CEE))
1550 return DRE->getDecl();
1552 if (
auto *ME = dyn_cast<MemberExpr>(CEE))
1553 return ME->getMemberDecl();
1557 while (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE))
1562 if (
auto *BO = dyn_cast<BinaryOperator>(CEE)) {
1563 if (BO->isPtrMemOp()) {
1567 }
else if (
auto *UO = dyn_cast<UnaryOperator>(CEE)) {
1568 if (UO->getOpcode() == UO_Deref || UO->getOpcode() == UO_AddrOf ||
1569 UO->getOpcode() == UO_Plus) {
1577 if (
auto *DRE = dyn_cast<DeclRefExpr>(CEE))
1578 return DRE->getDecl();
1579 if (
auto *ME = dyn_cast<MemberExpr>(CEE))
1580 return ME->getMemberDecl();
1581 if (
auto *BE = dyn_cast<BlockExpr>(CEE))
1582 return BE->getBlockDecl();
1590 return FDecl ? FDecl->getBuiltinID() : 0;
1601 QualType CalleeType = Callee->getType();
1607 if (isa<CXXPseudoDestructorExpr>(Callee->IgnoreParens()))
1610 if (isa<UnresolvedMemberExpr>(Callee->IgnoreParens()))
1615 assert(!CalleeType.
isNull());
1629std::pair<const NamedDecl *, const WarnUnusedResultAttr *>
1632 if (Callee !=
nullptr)
1633 if (
const auto *A = Callee->getAttr<WarnUnusedResultAttr>())
1634 return {
nullptr, A};
1639 if (
const auto *A = TD->getAttr<WarnUnusedResultAttr>())
1644 if (
const auto *A = TD->getDecl()->getAttr<WarnUnusedResultAttr>())
1645 return {TD->getDecl(), A};
1646 return {
nullptr,
nullptr};
1655 void *Mem =
C.Allocate(
1656 totalSizeToAlloc<OffsetOfNode, Expr *>(comps.size(), exprs.size()));
1663 unsigned numComps,
unsigned numExprs) {
1665 C.Allocate(totalSizeToAlloc<OffsetOfNode, Expr *>(numComps, numExprs));
1674 OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
1675 NumComps(comps.size()), NumExprs(exprs.size()) {
1676 for (
unsigned i = 0; i != comps.size(); ++i)
1678 for (
unsigned i = 0; i != exprs.size(); ++i)
1696 OpLoc(op), RParenLoc(rp) {
1697 assert(ExprKind <=
UETT_Last &&
"invalid enum value!");
1700 "UnaryExprOrTypeTraitExprBits.Kind overflow!");
1714 :
Expr(MemberExprClass,
T,
VK, OK),
Base(
Base), MemberDecl(MemberDecl),
1715 MemberDNLoc(NameInfo.
getInfo()), MemberLoc(NameInfo.getLoc()) {
1721 FoundDecl.getDecl() != MemberDecl ||
1724 TemplateArgs || TemplateKWLoc.
isValid();
1730 new (getTrailingObjects<NestedNameSpecifierLoc>())
1733 *getTrailingObjects<DeclAccessPair>() = FoundDecl;
1735 auto Deps = TemplateArgumentDependence::None;
1736 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1737 TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
1739 }
else if (TemplateKWLoc.
isValid()) {
1740 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1753 bool HasFoundDecl = FoundDecl.getDecl() != MemberDecl ||
1755 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
1759 HasQualifier, HasFoundDecl, HasTemplateKWAndArgsInfo,
1760 TemplateArgs ? TemplateArgs->
size() : 0);
1762 void *Mem =
C.Allocate(Size,
alignof(
MemberExpr));
1763 return new (Mem)
MemberExpr(
Base, IsArrow, OperatorLoc, QualifierLoc,
1764 TemplateKWLoc, MemberDecl, FoundDecl, NameInfo,
1765 TemplateArgs,
T,
VK, OK, NOUR);
1769 bool HasQualifier,
bool HasFoundDecl,
1770 bool HasTemplateKWAndArgsInfo,
1771 unsigned NumTemplateArgs) {
1772 assert((!NumTemplateArgs || HasTemplateKWAndArgsInfo) &&
1773 "template args but no template arg info?");
1777 HasQualifier, HasFoundDecl, HasTemplateKWAndArgsInfo,
1785 if (
getType()->isUndeducedType())
1801 return BaseStartLoc;
1813bool CastExpr::CastConsistency()
const {
1815 case CK_DerivedToBase:
1816 case CK_UncheckedDerivedToBase:
1817 case CK_DerivedToBaseMemberPointer:
1818 case CK_BaseToDerived:
1819 case CK_BaseToDerivedMemberPointer:
1820 assert(!
path_empty() &&
"Cast kind should have a base path!");
1823 case CK_CPointerToObjCPointerCast:
1824 assert(
getType()->isObjCObjectPointerType());
1826 goto CheckNoBasePath;
1828 case CK_BlockPointerToObjCPointerCast:
1829 assert(
getType()->isObjCObjectPointerType());
1831 goto CheckNoBasePath;
1833 case CK_ReinterpretMemberPointer:
1834 assert(
getType()->isMemberPointerType());
1836 goto CheckNoBasePath;
1842 if (!
getType()->isPointerType()) {
1843 assert(
getType()->isObjCObjectPointerType() ==
1845 assert(
getType()->isBlockPointerType() ==
1848 goto CheckNoBasePath;
1850 case CK_AnyPointerToBlockPointerCast:
1851 assert(
getType()->isBlockPointerType());
1854 goto CheckNoBasePath;
1856 case CK_CopyAndAutoreleaseBlockObject:
1857 assert(
getType()->isBlockPointerType());
1859 goto CheckNoBasePath;
1861 case CK_FunctionToPointerDecay:
1862 assert(
getType()->isPointerType());
1864 goto CheckNoBasePath;
1866 case CK_AddressSpaceConversion: {
1875 (!Ty.
isNull() && !SETy.isNull() &&
1877 goto CheckNoBasePath;
1882 case CK_ArrayToPointerDecay:
1883 case CK_NullToMemberPointer:
1884 case CK_NullToPointer:
1885 case CK_ConstructorConversion:
1886 case CK_IntegralToPointer:
1887 case CK_PointerToIntegral:
1889 case CK_VectorSplat:
1890 case CK_IntegralCast:
1891 case CK_BooleanToSignedIntegral:
1892 case CK_IntegralToFloating:
1893 case CK_FloatingToIntegral:
1894 case CK_FloatingCast:
1895 case CK_ObjCObjectLValueCast:
1896 case CK_FloatingRealToComplex:
1897 case CK_FloatingComplexToReal:
1898 case CK_FloatingComplexCast:
1899 case CK_FloatingComplexToIntegralComplex:
1900 case CK_IntegralRealToComplex:
1901 case CK_IntegralComplexToReal:
1902 case CK_IntegralComplexCast:
1903 case CK_IntegralComplexToFloatingComplex:
1904 case CK_ARCProduceObject:
1905 case CK_ARCConsumeObject:
1906 case CK_ARCReclaimReturnedObject:
1907 case CK_ARCExtendBlockObject:
1908 case CK_ZeroToOCLOpaqueType:
1909 case CK_IntToOCLSampler:
1910 case CK_FloatingToFixedPoint:
1911 case CK_FixedPointToFloating:
1912 case CK_FixedPointCast:
1913 case CK_FixedPointToIntegral:
1914 case CK_IntegralToFixedPoint:
1917 goto CheckNoBasePath;
1920 case CK_LValueToRValue:
1922 case CK_AtomicToNonAtomic:
1923 case CK_NonAtomicToAtomic:
1924 case CK_PointerToBoolean:
1925 case CK_IntegralToBoolean:
1926 case CK_FloatingToBoolean:
1927 case CK_MemberPointerToBoolean:
1928 case CK_FloatingComplexToBoolean:
1929 case CK_IntegralComplexToBoolean:
1930 case CK_LValueBitCast:
1931 case CK_LValueToRValueBitCast:
1932 case CK_UserDefinedConversion:
1933 case CK_BuiltinFnToFnPtr:
1934 case CK_FixedPointToBoolean:
1935 case CK_HLSLArrayRValue:
1936 case CK_HLSLVectorTruncation:
1937 case CK_HLSLElementwiseCast:
1938 case CK_HLSLAggregateSplatCast:
1940 assert(
path_empty() &&
"Cast kind should not have a base path!");
1948#define CAST_OPERATION(Name) case CK_##Name: return #Name;
1949#include "clang/AST/OperationKinds.def"
1951 llvm_unreachable(
"Unhandled cast kind!");
1957static Expr *ignoreImplicitSemaNodes(
Expr *
E) {
1958 if (
auto *Materialize = dyn_cast<MaterializeTemporaryExpr>(
E))
1959 return Materialize->getSubExpr();
1961 if (
auto *Binder = dyn_cast<CXXBindTemporaryExpr>(
E))
1962 return Binder->getSubExpr();
1964 if (
auto *Full = dyn_cast<FullExpr>(
E))
1965 return Full->getSubExpr();
1967 if (
auto *CPLIE = dyn_cast<CXXParenListInitExpr>(
E);
1968 CPLIE && CPLIE->getInitExprs().size() == 1)
1969 return CPLIE->getInitExprs()[0];
1976 const Expr *SubExpr =
nullptr;
1978 for (
const CastExpr *
E =
this;
E;
E = dyn_cast<ImplicitCastExpr>(SubExpr)) {
1983 if (
E->getCastKind() == CK_ConstructorConversion) {
1985 ignoreImplicitSemaNodes);
1986 }
else if (
E->getCastKind() == CK_UserDefinedConversion) {
1987 assert((isa<CallExpr, BlockExpr>(SubExpr)) &&
1988 "Unexpected SubExpr for CK_UserDefinedConversion.");
1989 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
1990 SubExpr = MCE->getImplicitObjectArgument();
1994 return const_cast<Expr *
>(SubExpr);
1998 const Expr *SubExpr =
nullptr;
2000 for (
const CastExpr *
E =
this;
E;
E = dyn_cast<ImplicitCastExpr>(SubExpr)) {
2003 if (
E->getCastKind() == CK_ConstructorConversion)
2004 return cast<CXXConstructExpr>(SubExpr)->getConstructor();
2006 if (
E->getCastKind() == CK_UserDefinedConversion) {
2007 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
2008 return MCE->getMethodDecl();
2017#define ABSTRACT_STMT(x)
2018#define CASTEXPR(Type, Base) \
2019 case Stmt::Type##Class: \
2020 return static_cast<Type *>(this) \
2021 ->getTrailingObjectsNonStrict<CXXBaseSpecifier *>();
2022#define STMT(Type, Base)
2023#include "clang/AST/StmtNodes.inc"
2025 llvm_unreachable(
"non-cast expressions not possible here");
2039 Field != FieldEnd; ++Field) {
2041 !Field->isUnnamedBitField()) {
2051 case ImplicitCastExprClass:
2053 ->getTrailingObjects<FPOptionsOverride>();
2054 case CStyleCastExprClass:
2056 ->getTrailingObjects<FPOptionsOverride>();
2057 case CXXFunctionalCastExprClass:
2059 ->getTrailingObjects<FPOptionsOverride>();
2060 case CXXStaticCastExprClass:
2062 ->getTrailingObjects<FPOptionsOverride>();
2064 llvm_unreachable(
"Cast does not have FPFeatures");
2073 unsigned PathSize = (BasePath ? BasePath->size() : 0);
2075 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
2079 assert((Kind != CK_LValueToRValue ||
2081 "invalid type for lvalue-to-rvalue conversion");
2085 llvm::uninitialized_copy(*BasePath,
2092 bool HasFPFeatures) {
2094 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
2095 PathSize, HasFPFeatures));
2105 unsigned PathSize = (BasePath ? BasePath->size() : 0);
2107 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
2112 llvm::uninitialized_copy(*BasePath,
2119 bool HasFPFeatures) {
2121 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
2122 PathSize, HasFPFeatures));
2130#define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling;
2131#include "clang/AST/OperationKinds.def"
2133 llvm_unreachable(
"Invalid OpCode!");
2139 default: llvm_unreachable(
"Not an overloadable binary operator");
2140 case OO_Plus:
return BO_Add;
2141 case OO_Minus:
return BO_Sub;
2142 case OO_Star:
return BO_Mul;
2143 case OO_Slash:
return BO_Div;
2144 case OO_Percent:
return BO_Rem;
2145 case OO_Caret:
return BO_Xor;
2146 case OO_Amp:
return BO_And;
2147 case OO_Pipe:
return BO_Or;
2148 case OO_Equal:
return BO_Assign;
2149 case OO_Spaceship:
return BO_Cmp;
2150 case OO_Less:
return BO_LT;
2151 case OO_Greater:
return BO_GT;
2152 case OO_PlusEqual:
return BO_AddAssign;
2153 case OO_MinusEqual:
return BO_SubAssign;
2154 case OO_StarEqual:
return BO_MulAssign;
2155 case OO_SlashEqual:
return BO_DivAssign;
2156 case OO_PercentEqual:
return BO_RemAssign;
2157 case OO_CaretEqual:
return BO_XorAssign;
2158 case OO_AmpEqual:
return BO_AndAssign;
2159 case OO_PipeEqual:
return BO_OrAssign;
2160 case OO_LessLess:
return BO_Shl;
2161 case OO_GreaterGreater:
return BO_Shr;
2162 case OO_LessLessEqual:
return BO_ShlAssign;
2163 case OO_GreaterGreaterEqual:
return BO_ShrAssign;
2164 case OO_EqualEqual:
return BO_EQ;
2165 case OO_ExclaimEqual:
return BO_NE;
2166 case OO_LessEqual:
return BO_LE;
2167 case OO_GreaterEqual:
return BO_GE;
2168 case OO_AmpAmp:
return BO_LAnd;
2169 case OO_PipePipe:
return BO_LOr;
2170 case OO_Comma:
return BO_Comma;
2171 case OO_ArrowStar:
return BO_PtrMemI;
2178 OO_Star, OO_Slash, OO_Percent,
2180 OO_LessLess, OO_GreaterGreater,
2182 OO_Less, OO_Greater, OO_LessEqual, OO_GreaterEqual,
2183 OO_EqualEqual, OO_ExclaimEqual,
2189 OO_Equal, OO_StarEqual,
2190 OO_SlashEqual, OO_PercentEqual,
2191 OO_PlusEqual, OO_MinusEqual,
2192 OO_LessLessEqual, OO_GreaterGreaterEqual,
2193 OO_AmpEqual, OO_CaretEqual,
2197 return OverOps[Opc];
2226 if (!Select->getCond()->EvaluateAsBooleanCondition(
EvalResult, Ctx))
2228 PExp =
EvalResult ? Select->getTrueExpr() : Select->getFalseExpr();
2249 BuiltinLoc(BLoc), RParenLoc(RParenLoc), ParentContext(ParentContext) {
2253 ? ExprDependence::Value
2254 : ExprDependence::None);
2260 return "__builtin_FILE";
2262 return "__builtin_FILE_NAME";
2264 return "__builtin_FUNCTION";
2266 return "__builtin_FUNCSIG";
2268 return "__builtin_LINE";
2270 return "__builtin_COLUMN";
2272 return "__builtin_source_location";
2274 llvm_unreachable(
"unexpected IdentKind!");
2278 const Expr *DefaultExpr)
const {
2282 if (
const auto *DIE = dyn_cast_if_present<CXXDefaultInitExpr>(DefaultExpr)) {
2283 Loc = DIE->getUsedLocation();
2284 Context = DIE->getUsedContext();
2285 }
else if (
const auto *DAE =
2286 dyn_cast_if_present<CXXDefaultArgExpr>(DefaultExpr)) {
2287 Loc = DAE->getUsedLocation();
2288 Context = DAE->getUsedContext();
2299 if (
const auto *
D = dyn_cast<CXXMethodDecl>(Context);
2301 Context =
D->getParent()->getParent();
2306 auto MakeStringLiteral = [&](StringRef Tmp) {
2310 LValuePathEntry
Path[1] = {LValuePathEntry::ArrayIndex(0)};
2321 return MakeStringLiteral(
FileName);
2327 return MakeStringLiteral(
Path);
2331 const auto *CurDecl = dyn_cast<Decl>(Context);
2335 return MakeStringLiteral(
2355 StringRef Name = F->getName();
2356 if (Name ==
"_M_file_name") {
2360 Value.getStructField(F->getFieldIndex()) = MakeStringLiteral(
Path);
2361 }
else if (Name ==
"_M_function_name") {
2364 const auto *CurDecl = dyn_cast<Decl>(Context);
2365 Value.getStructField(F->getFieldIndex()) = MakeStringLiteral(
2366 CurDecl && !isa<TranslationUnitDecl>(CurDecl)
2370 }
else if (Name ==
"_M_line") {
2372 Value.getStructField(F->getFieldIndex()) =
APValue(IntVal);
2373 }
else if (Name ==
"_M_column") {
2375 Value.getStructField(F->getFieldIndex()) =
APValue(IntVal);
2386 llvm_unreachable(
"unhandled case");
2391 unsigned NumOfElements)
2394 NumOfElements(NumOfElements) {
2398 assert(
getType()->isSignedIntegerType() &&
"IntTy should be signed");
2404 InitExprs(
C, initExprs.size()), LBraceLoc(lbraceloc),
2405 RBraceLoc(rbraceloc), AltForm(nullptr,
true) {
2407 InitExprs.
insert(
C, InitExprs.
end(), initExprs.begin(), initExprs.end());
2413 if (NumInits > InitExprs.
size())
2418 InitExprs.
resize(
C, NumInits,
nullptr);
2435 ArrayFillerOrUnionFieldInit = filler;
2438 for (
unsigned i = 0, e =
getNumInits(); i != e; ++i)
2439 if (
inits[i] ==
nullptr)
2453 Init =
Init->IgnoreParenImpCasts();
2454 return isa<StringLiteral>(
Init) || isa<ObjCEncodeExpr>(
Init);
2458 assert(
isSemanticForm() &&
"syntactic form never semantically transparent");
2462 assert(
getNumInits() == 1 &&
"multiple inits in glvalue init list");
2481 assert(
isSyntacticForm() &&
"only test syntactic form as zero initializer");
2488 return Lit && Lit->
getValue() == 0;
2493 return SyntacticForm->getBeginLoc();
2498 E = InitExprs.
end();
2501 Beg = S->getBeginLoc();
2511 return SyntacticForm->getEndLoc();
2513 if (End.isInvalid()) {
2515 for (
Stmt *S : llvm::reverse(InitExprs)) {
2517 End = S->getEndLoc();
2529 return cast<BlockPointerType>(
getType())
2560 if (isa<DeclRefExpr>(
E))
2564 if (isa<ArraySubscriptExpr>(
E))
2568 if (isa<MemberExpr>(
E))
2572 if (
auto *UO = dyn_cast<UnaryOperator>(
E))
2573 if (UO->getOpcode() == UO_Deref)
2576 if (
auto *BO = dyn_cast<BinaryOperator>(
E)) {
2578 if (BO->isPtrMemOp())
2582 if (BO->getOpcode() == BO_Comma)
2583 return BO->getRHS()->isReadIfDiscardedInCPlusPlus11();
2588 if (
auto *CO = dyn_cast<ConditionalOperator>(
E))
2589 return CO->getTrueExpr()->isReadIfDiscardedInCPlusPlus11() &&
2590 CO->getFalseExpr()->isReadIfDiscardedInCPlusPlus11();
2593 dyn_cast<BinaryConditionalOperator>(
E)) {
2594 if (
auto *OVE = dyn_cast<OpaqueValueExpr>(BCO->getTrueExpr()))
2595 return OVE->getSourceExpr()->isReadIfDiscardedInCPlusPlus11() &&
2596 BCO->getFalseExpr()->isReadIfDiscardedInCPlusPlus11();
2600 if (isa<ObjCIvarRefExpr>(
E))
2602 if (
const auto *POE = dyn_cast<PseudoObjectExpr>(
E)) {
2603 if (isa<ObjCPropertyRefExpr, ObjCSubscriptRefExpr>(POE->getSyntacticForm()))
2630 case ParenExprClass:
2631 return cast<ParenExpr>(
this)->getSubExpr()->
2633 case GenericSelectionExprClass:
2634 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
2636 case CoawaitExprClass:
2637 case CoyieldExprClass:
2638 return cast<CoroutineSuspendExpr>(
this)->getResumeExpr()->
2640 case ChooseExprClass:
2641 return cast<ChooseExpr>(
this)->getChosenSubExpr()->
2643 case UnaryOperatorClass: {
2677 case BinaryOperatorClass: {
2689 if (IE->getValue() == 0)
2708 case CompoundAssignOperatorClass:
2709 case VAArgExprClass:
2710 case AtomicExprClass:
2713 case ConditionalOperatorClass: {
2717 const auto *Exp = cast<ConditionalOperator>(
this);
2718 return Exp->getLHS()->isUnusedResultAWarning(WarnE,
Loc, R1, R2, Ctx) &&
2719 Exp->getRHS()->isUnusedResultAWarning(WarnE,
Loc, R1, R2, Ctx);
2721 case BinaryConditionalOperatorClass: {
2722 const auto *Exp = cast<BinaryConditionalOperator>(
this);
2723 return Exp->getFalseExpr()->isUnusedResultAWarning(WarnE,
Loc, R1, R2, Ctx);
2726 case MemberExprClass:
2728 Loc = cast<MemberExpr>(
this)->getMemberLoc();
2730 R2 = cast<MemberExpr>(
this)->getBase()->getSourceRange();
2733 case ArraySubscriptExprClass:
2735 Loc = cast<ArraySubscriptExpr>(
this)->getRBracketLoc();
2736 R1 = cast<ArraySubscriptExpr>(
this)->getLHS()->getSourceRange();
2737 R2 = cast<ArraySubscriptExpr>(
this)->getRHS()->getSourceRange();
2740 case CXXOperatorCallExprClass: {
2752 case OO_ExclaimEqual:
2755 case OO_GreaterEqual:
2770 case CXXMemberCallExprClass:
2771 case UserDefinedLiteralClass: {
2773 const CallExpr *CE = cast<CallExpr>(
this);
2795 case UnresolvedLookupExprClass:
2796 case CXXUnresolvedConstructExprClass:
2797 case RecoveryExprClass:
2800 case CXXTemporaryObjectExprClass:
2801 case CXXConstructExprClass: {
2802 const auto *CE = cast<CXXConstructExpr>(
this);
2806 CE->hasUnusedResultAttr(Ctx)) {
2811 if (
unsigned NumArgs = CE->getNumArgs())
2813 CE->getArg(NumArgs - 1)->getEndLoc());
2819 case ObjCMessageExprClass: {
2840 case ObjCPropertyRefExprClass:
2841 case ObjCSubscriptRefExprClass:
2847 case PseudoObjectExprClass: {
2848 const auto *POE = cast<PseudoObjectExpr>(
this);
2851 if (isa<ObjCPropertyRefExpr, ObjCSubscriptRefExpr>(
2852 POE->getSyntacticForm())) {
2860 if (
auto *BO = dyn_cast<BinaryOperator>(POE->getSyntacticForm()))
2861 if (BO->isAssignmentOp())
2863 if (
auto *UO = dyn_cast<UnaryOperator>(POE->getSyntacticForm()))
2864 if (UO->isIncrementDecrementOp())
2869 return Result &&
Result->isUnusedResultAWarning(WarnE,
Loc, R1, R2, Ctx);
2872 case StmtExprClass: {
2878 const CompoundStmt *CS = cast<StmtExpr>(
this)->getSubStmt();
2883 if (
const Expr *
E = dyn_cast<Expr>(
Label->getSubStmt()))
2890 Loc = cast<StmtExpr>(
this)->getLParenLoc();
2894 case CXXFunctionalCastExprClass:
2895 case CStyleCastExprClass: {
2902 const CastExpr *CE = cast<CastExpr>(
this);
2909 if (
auto *DRE = dyn_cast<DeclRefExpr>(SubE))
2910 if (
auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
2911 if (!VD->isExternallyVisible())
2927 if (CE->
getCastKind() == CK_ConstructorConversion)
2934 dyn_cast<CXXFunctionalCastExpr>(
this)) {
2935 Loc = CXXCE->getBeginLoc();
2936 R1 = CXXCE->getSubExpr()->getSourceRange();
2944 case ImplicitCastExprClass: {
2945 const CastExpr *ICE = cast<ImplicitCastExpr>(
this);
2954 case CXXDefaultArgExprClass:
2955 return (cast<CXXDefaultArgExpr>(
this)
2957 case CXXDefaultInitExprClass:
2958 return (cast<CXXDefaultInitExpr>(
this)
2961 case CXXNewExprClass:
2964 case CXXDeleteExprClass:
2966 case MaterializeTemporaryExprClass:
2967 return cast<MaterializeTemporaryExpr>(
this)
2969 ->isUnusedResultAWarning(WarnE,
Loc, R1, R2, Ctx);
2970 case CXXBindTemporaryExprClass:
2971 return cast<CXXBindTemporaryExpr>(
this)->getSubExpr()
2972 ->isUnusedResultAWarning(WarnE,
Loc, R1, R2, Ctx);
2973 case ExprWithCleanupsClass:
2974 return cast<ExprWithCleanups>(
this)->getSubExpr()
2975 ->isUnusedResultAWarning(WarnE,
Loc, R1, R2, Ctx);
2976 case OpaqueValueExprClass:
2977 return cast<OpaqueValueExpr>(
this)->getSourceExpr()->isUnusedResultAWarning(
2978 WarnE,
Loc, R1, R2, Ctx);
2989 case ObjCIvarRefExprClass:
2991 case Expr::UnaryOperatorClass:
2992 return cast<UnaryOperator>(
E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2993 case ImplicitCastExprClass:
2994 return cast<ImplicitCastExpr>(
E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2995 case MaterializeTemporaryExprClass:
2996 return cast<MaterializeTemporaryExpr>(
E)->getSubExpr()->isOBJCGCCandidate(
2998 case CStyleCastExprClass:
2999 return cast<CStyleCastExpr>(
E)->getSubExpr()->isOBJCGCCandidate(Ctx);
3000 case DeclRefExprClass: {
3001 const Decl *
D = cast<DeclRefExpr>(
E)->getDecl();
3003 if (
const VarDecl *VD = dyn_cast<VarDecl>(
D)) {
3004 if (VD->hasGlobalStorage())
3014 case MemberExprClass: {
3018 case ArraySubscriptExprClass:
3019 return cast<ArraySubscriptExpr>(
E)->getBase()->isOBJCGCCandidate(Ctx);
3030 assert(
expr->hasPlaceholderType(BuiltinType::BoundMember));
3038 assert(isa<CXXMethodDecl>(mem->getMemberDecl()));
3039 return mem->getMemberDecl()->getType();
3045 assert(
type->isFunctionType());
3049 assert(isa<UnresolvedMemberExpr>(
expr) || isa<CXXPseudoDestructorExpr>(
expr));
3083 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(
this)) {
3084 if (isa_and_nonnull<CXXConversionDecl>(MCE->getMethodDecl()))
3085 return MCE->getImplicitObjectArgument();
3101 auto IgnoreNoopCastsSingleStep = [&Ctx](
Expr *
E) {
3102 if (
auto *CE = dyn_cast<CastExpr>(
E)) {
3105 Expr *SubExpr = CE->getSubExpr();
3106 bool IsIdentityCast =
3115 if (IsIdentityCast || IsSameWidthCast)
3117 }
else if (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(
E))
3118 return NTTP->getReplacement();
3123 IgnoreNoopCastsSingleStep);
3128 if (
auto *Cast = dyn_cast<CXXFunctionalCastExpr>(
E)) {
3129 auto *SE = Cast->getSubExpr();
3134 if (
auto *
C = dyn_cast<CXXConstructExpr>(
E)) {
3135 auto NumArgs =
C->getNumArgs();
3137 (NumArgs > 1 && isa<CXXDefaultArgExpr>(
C->getArg(1)))) {
3138 Expr *A =
C->getArg(0);
3145 auto IgnoreImplicitMemberCallSingleStep = [](
Expr *
E) {
3146 if (
auto *
C = dyn_cast<CXXMemberCallExpr>(
E)) {
3147 Expr *ExprNode =
C->getImplicitObjectArgument();
3151 if (
auto *PE = dyn_cast<ParenExpr>(ExprNode)) {
3152 if (PE->getSourceRange() ==
C->getSourceRange()) {
3153 return cast<Expr>(PE);
3165 IgnoreImplicitMemberCallSingleStep);
3169 const Expr *
E =
this;
3171 E = M->getSubExpr();
3174 E = ICE->getSubExprAsWritten();
3176 return isa<CXXDefaultArgExpr>(
E);
3183 E = M->getSubExpr();
3186 if (ICE->getCastKind() == CK_NoOp)
3187 E = ICE->getSubExpr();
3193 E = BE->getSubExpr();
3196 if (ICE->getCastKind() == CK_NoOp)
3197 E = ICE->getSubExpr();
3208 if (!
C.hasSameUnqualifiedType(
getType(),
C.getCanonicalTagType(TempTy)))
3216 if (!isa<ObjCPropertyRefExpr>(
E))
3224 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(
E)) {
3225 switch (ICE->getCastKind()) {
3226 case CK_DerivedToBase:
3227 case CK_UncheckedDerivedToBase:
3235 if (isa<MemberExpr>(
E))
3238 if (
const auto *BO = dyn_cast<BinaryOperator>(
E))
3239 if (BO->isPtrMemOp())
3243 if (isa<OpaqueValueExpr>(
E))
3250 const Expr *
E =
this;
3260 if (ICE->getCastKind() == CK_NoOp ||
3261 ICE->getCastKind() == CK_LValueToRValue ||
3262 ICE->getCastKind() == CK_DerivedToBase ||
3263 ICE->getCastKind() == CK_UncheckedDerivedToBase) {
3264 E = ICE->getSubExpr();
3270 if (UnOp->getOpcode() == UO_Extension) {
3271 E = UnOp->getSubExpr();
3277 = dyn_cast<MaterializeTemporaryExpr>(
E)) {
3278 E = M->getSubExpr();
3286 return This->isImplicit();
3294 for (
unsigned I = 0; I < Exprs.size(); ++I)
3302 const Expr **Culprit)
const {
3304 "Expression evaluator can't be called on a dependent expression.");
3316 if (
auto *EWC = dyn_cast<ExprWithCleanups>(
this))
3317 return EWC->getSubExpr()->isConstantInitializer(Ctx,
true, Culprit);
3318 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(
this))
3319 return MTE->getSubExpr()->isConstantInitializer(Ctx,
false, Culprit);
3330 case Stmt::ExprWithCleanupsClass:
3332 Ctx, IsForRef, Culprit);
3333 case StringLiteralClass:
3334 case ObjCEncodeExprClass:
3336 case CXXTemporaryObjectExprClass:
3337 case CXXConstructExprClass: {
3346 assert(CE->
getNumArgs() == 1 &&
"trivial ctor with > 1 argument");
3352 case ConstantExprClass: {
3355 const Expr *Exp = cast<ConstantExpr>(
this)->getSubExpr();
3358 case CompoundLiteralExprClass: {
3362 const Expr *Exp = cast<CompoundLiteralExpr>(
this)->getInitializer();
3365 case DesignatedInitUpdateExprClass: {
3370 case InitListExprClass: {
3378 assert(ILE->
isSemanticForm() &&
"InitListExpr must be in semantic form");
3385 for (
unsigned i = 0; i < numInits; i++) {
3393 unsigned ElementNo = 0;
3398 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
3399 for (
unsigned i = 0, e = CXXRD->getNumBases(); i < e; i++) {
3400 if (ElementNo < ILE->getNumInits()) {
3408 for (
const auto *Field : RD->fields()) {
3414 if (Field->isUnnamedBitField())
3417 if (ElementNo < ILE->getNumInits()) {
3419 if (Field->isBitField()) {
3428 bool RefType = Field->getType()->isReferenceType();
3439 case ImplicitValueInitExprClass:
3440 case NoInitExprClass:
3442 case ParenExprClass:
3443 return cast<ParenExpr>(
this)->getSubExpr()
3444 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3445 case GenericSelectionExprClass:
3446 return cast<GenericSelectionExpr>(
this)->getResultExpr()
3447 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3448 case ChooseExprClass:
3449 if (cast<ChooseExpr>(
this)->isConditionDependent()) {
3454 return cast<ChooseExpr>(
this)->getChosenSubExpr()
3456 case UnaryOperatorClass: {
3462 case PackIndexingExprClass: {
3463 return cast<PackIndexingExpr>(
this)
3465 ->isConstantInitializer(Ctx,
false, Culprit);
3467 case CXXFunctionalCastExprClass:
3468 case CXXStaticCastExprClass:
3469 case ImplicitCastExprClass:
3470 case CStyleCastExprClass:
3471 case ObjCBridgedCastExprClass:
3472 case CXXDynamicCastExprClass:
3473 case CXXReinterpretCastExprClass:
3474 case CXXAddrspaceCastExprClass:
3475 case CXXConstCastExprClass: {
3476 const CastExpr *CE = cast<CastExpr>(
this);
3491 case MaterializeTemporaryExprClass:
3492 return cast<MaterializeTemporaryExpr>(
this)
3494 ->isConstantInitializer(Ctx,
false, Culprit);
3496 case SubstNonTypeTemplateParmExprClass:
3497 return cast<SubstNonTypeTemplateParmExpr>(
this)->getReplacement()
3498 ->isConstantInitializer(Ctx,
false, Culprit);
3499 case CXXDefaultArgExprClass:
3500 return cast<CXXDefaultArgExpr>(
this)->getExpr()
3501 ->isConstantInitializer(Ctx,
false, Culprit);
3502 case CXXDefaultInitExprClass:
3503 return cast<CXXDefaultInitExpr>(
this)->getExpr()
3504 ->isConstantInitializer(Ctx,
false, Culprit);
3518 if (BuiltinID != Builtin::BI__assume &&
3519 BuiltinID != Builtin::BI__builtin_assume)
3530 return DirectCallee->getAttr<AllocSizeAttr>();
3532 return IndirectCallee->getAttr<AllocSizeAttr>();
3536std::optional<llvm::APInt>
3540 assert(AllocSize && AllocSize->getElemSizeParam().isValid());
3541 unsigned SizeArgNo = AllocSize->getElemSizeParam().getASTIndex();
3544 return std::nullopt;
3546 auto EvaluateAsSizeT = [&](
const Expr *
E, llvm::APSInt &Into) {
3552 if (Into.isNegative() || !Into.isIntN(BitsInSizeT))
3554 Into = Into.zext(BitsInSizeT);
3558 llvm::APSInt SizeOfElem;
3559 if (!EvaluateAsSizeT(
getArg(SizeArgNo), SizeOfElem))
3560 return std::nullopt;
3562 if (!AllocSize->getNumElemsParam().isValid())
3565 llvm::APSInt NumberOfElems;
3566 unsigned NumArgNo = AllocSize->getNumElemsParam().getASTIndex();
3567 if (!EvaluateAsSizeT(
getArg(NumArgNo), NumberOfElems))
3568 return std::nullopt;
3571 llvm::APInt BytesAvailable = SizeOfElem.umul_ov(NumberOfElems, Overflow);
3573 return std::nullopt;
3575 return BytesAvailable;
3586 const bool IncludePossibleEffects;
3587 bool HasSideEffects;
3590 explicit SideEffectFinder(
const ASTContext &Context,
bool IncludePossible)
3591 : Inherited(Context),
3592 IncludePossibleEffects(IncludePossible), HasSideEffects(
false) { }
3594 bool hasSideEffects()
const {
return HasSideEffects; }
3596 void VisitDecl(
const Decl *
D) {
3602 if (
auto *VD = dyn_cast<VarDecl>(
D)) {
3604 if (IncludePossibleEffects && VD->isThisDeclarationADefinition() &&
3605 VD->needsDestruction(Context))
3606 HasSideEffects =
true;
3610 void VisitDeclStmt(
const DeclStmt *DS) {
3611 for (
auto *
D : DS->
decls())
3613 Inherited::VisitDeclStmt(DS);
3616 void VisitExpr(
const Expr *
E) {
3617 if (!HasSideEffects &&
3619 HasSideEffects =
true;
3625 bool IncludePossibleEffects)
const {
3629 if (!IncludePossibleEffects &&
getExprLoc().isMacroID())
3634 #define ABSTRACT_STMT(Type)
3635 #define STMT(Type, Base) case Type##Class:
3636 #define EXPR(Type, Base)
3637 #include "clang/AST/StmtNodes.inc"
3638 llvm_unreachable(
"unexpected Expr kind");
3640 case DependentScopeDeclRefExprClass:
3641 case CXXUnresolvedConstructExprClass:
3642 case CXXDependentScopeMemberExprClass:
3643 case UnresolvedLookupExprClass:
3644 case UnresolvedMemberExprClass:
3645 case PackExpansionExprClass:
3646 case SubstNonTypeTemplateParmPackExprClass:
3647 case FunctionParmPackExprClass:
3648 case RecoveryExprClass:
3649 case CXXFoldExprClass:
3651 return IncludePossibleEffects;
3653 case DeclRefExprClass:
3654 case ObjCIvarRefExprClass:
3655 case PredefinedExprClass:
3656 case IntegerLiteralClass:
3657 case FixedPointLiteralClass:
3658 case FloatingLiteralClass:
3659 case ImaginaryLiteralClass:
3660 case StringLiteralClass:
3661 case CharacterLiteralClass:
3662 case OffsetOfExprClass:
3663 case ImplicitValueInitExprClass:
3664 case UnaryExprOrTypeTraitExprClass:
3665 case AddrLabelExprClass:
3666 case GNUNullExprClass:
3667 case ArrayInitIndexExprClass:
3668 case NoInitExprClass:
3669 case CXXBoolLiteralExprClass:
3670 case CXXNullPtrLiteralExprClass:
3671 case CXXThisExprClass:
3672 case CXXScalarValueInitExprClass:
3673 case TypeTraitExprClass:
3674 case ArrayTypeTraitExprClass:
3675 case ExpressionTraitExprClass:
3676 case CXXNoexceptExprClass:
3677 case SizeOfPackExprClass:
3678 case ObjCStringLiteralClass:
3679 case ObjCEncodeExprClass:
3680 case ObjCBoolLiteralExprClass:
3681 case ObjCAvailabilityCheckExprClass:
3682 case CXXUuidofExprClass:
3683 case OpaqueValueExprClass:
3684 case SourceLocExprClass:
3685 case EmbedExprClass:
3686 case ConceptSpecializationExprClass:
3687 case RequiresExprClass:
3688 case SYCLUniqueStableNameExprClass:
3689 case PackIndexingExprClass:
3690 case HLSLOutArgExprClass:
3691 case OpenACCAsteriskSizeExprClass:
3695 case ConstantExprClass:
3697 return cast<ConstantExpr>(
this)->getSubExpr()->HasSideEffects(
3698 Ctx, IncludePossibleEffects);
3701 case CXXOperatorCallExprClass:
3702 case CXXMemberCallExprClass:
3703 case CUDAKernelCallExprClass:
3704 case UserDefinedLiteralClass: {
3708 const Decl *FD = cast<CallExpr>(
this)->getCalleeDecl();
3709 bool IsPure = FD && (FD->
hasAttr<ConstAttr>() || FD->
hasAttr<PureAttr>());
3710 if (IsPure || !IncludePossibleEffects)
3715 case BlockExprClass:
3716 case CXXBindTemporaryExprClass:
3717 if (!IncludePossibleEffects)
3721 case MSPropertyRefExprClass:
3722 case MSPropertySubscriptExprClass:
3723 case CompoundAssignOperatorClass:
3724 case VAArgExprClass:
3725 case AtomicExprClass:
3726 case CXXThrowExprClass:
3727 case CXXNewExprClass:
3728 case CXXDeleteExprClass:
3729 case CoawaitExprClass:
3730 case DependentCoawaitExprClass:
3731 case CoyieldExprClass:
3735 case StmtExprClass: {
3737 SideEffectFinder Finder(Ctx, IncludePossibleEffects);
3738 Finder.Visit(cast<StmtExpr>(
this)->getSubStmt());
3739 return Finder.hasSideEffects();
3742 case ExprWithCleanupsClass:
3743 if (IncludePossibleEffects)
3744 if (cast<ExprWithCleanups>(
this)->cleanupsHaveSideEffects())
3748 case ParenExprClass:
3749 case ArraySubscriptExprClass:
3750 case MatrixSubscriptExprClass:
3751 case ArraySectionExprClass:
3752 case OMPArrayShapingExprClass:
3753 case OMPIteratorExprClass:
3754 case MemberExprClass:
3755 case ConditionalOperatorClass:
3756 case BinaryConditionalOperatorClass:
3757 case CompoundLiteralExprClass:
3758 case ExtVectorElementExprClass:
3759 case DesignatedInitExprClass:
3760 case DesignatedInitUpdateExprClass:
3761 case ArrayInitLoopExprClass:
3762 case ParenListExprClass:
3763 case CXXPseudoDestructorExprClass:
3764 case CXXRewrittenBinaryOperatorClass:
3765 case CXXStdInitializerListExprClass:
3766 case SubstNonTypeTemplateParmExprClass:
3767 case MaterializeTemporaryExprClass:
3768 case ShuffleVectorExprClass:
3769 case ConvertVectorExprClass:
3770 case AsTypeExprClass:
3771 case CXXParenListInitExprClass:
3775 case UnaryOperatorClass:
3776 if (cast<UnaryOperator>(
this)->isIncrementDecrementOp())
3780 case BinaryOperatorClass:
3781 if (cast<BinaryOperator>(
this)->isAssignmentOp())
3785 case InitListExprClass:
3787 if (
const Expr *
E = cast<InitListExpr>(
this)->getArrayFiller())
3792 case GenericSelectionExprClass:
3793 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
3796 case ChooseExprClass:
3797 return cast<ChooseExpr>(
this)->getChosenSubExpr()->HasSideEffects(
3798 Ctx, IncludePossibleEffects);
3800 case CXXDefaultArgExprClass:
3801 return cast<CXXDefaultArgExpr>(
this)->getExpr()->HasSideEffects(
3802 Ctx, IncludePossibleEffects);
3804 case CXXDefaultInitExprClass: {
3805 const FieldDecl *FD = cast<CXXDefaultInitExpr>(
this)->getField();
3812 case CXXDynamicCastExprClass: {
3820 case ImplicitCastExprClass:
3821 case CStyleCastExprClass:
3822 case CXXStaticCastExprClass:
3823 case CXXReinterpretCastExprClass:
3824 case CXXConstCastExprClass:
3825 case CXXAddrspaceCastExprClass:
3826 case CXXFunctionalCastExprClass:
3827 case BuiltinBitCastExprClass: {
3832 if (!IncludePossibleEffects)
3835 const CastExpr *CE = cast<CastExpr>(
this);
3842 case CXXTypeidExprClass: {
3843 const auto *TE = cast<CXXTypeidExpr>(
this);
3844 if (!TE->isPotentiallyEvaluated())
3849 if (IncludePossibleEffects && TE->hasNullCheck())
3855 case CXXConstructExprClass:
3856 case CXXTemporaryObjectExprClass: {
3865 case CXXInheritedCtorInitExprClass: {
3866 const auto *ICIE = cast<CXXInheritedCtorInitExpr>(
this);
3867 if (!ICIE->getConstructor()->isTrivial() && IncludePossibleEffects)
3872 case LambdaExprClass: {
3873 const LambdaExpr *LE = cast<LambdaExpr>(
this);
3874 for (
Expr *
E : LE->capture_inits())
3880 case PseudoObjectExprClass: {
3887 const Expr *Subexpr = *I;
3889 Subexpr = OVE->getSourceExpr();
3896 case ObjCBoxedExprClass:
3897 case ObjCArrayLiteralClass:
3898 case ObjCDictionaryLiteralClass:
3899 case ObjCSelectorExprClass:
3900 case ObjCProtocolExprClass:
3901 case ObjCIsaExprClass:
3902 case ObjCIndirectCopyRestoreExprClass:
3903 case ObjCSubscriptRefExprClass:
3904 case ObjCBridgedCastExprClass:
3905 case ObjCMessageExprClass:
3906 case ObjCPropertyRefExprClass:
3908 if (IncludePossibleEffects)
3916 cast<Expr>(SubStmt)->
HasSideEffects(Ctx, IncludePossibleEffects))
3923 if (
auto Call = dyn_cast<CallExpr>(
this))
3924 return Call->getFPFeaturesInEffect(LO);
3925 if (
auto UO = dyn_cast<UnaryOperator>(
this))
3926 return UO->getFPFeaturesInEffect(LO);
3927 if (
auto BO = dyn_cast<BinaryOperator>(
this))
3928 return BO->getFPFeaturesInEffect(LO);
3929 if (
auto Cast = dyn_cast<CastExpr>(
this))
3930 return Cast->getFPFeaturesInEffect(LO);
3931 if (
auto ConvertVector = dyn_cast<ConvertVectorExpr>(
this))
3932 return ConvertVector->getFPFeaturesInEffect(LO);
3945 explicit NonTrivialCallFinder(
const ASTContext &Context)
3946 : Inherited(Context), NonTrivial(
false) { }
3948 bool hasNonTrivialCall()
const {
return NonTrivial; }
3952 = dyn_cast_or_null<const CXXMethodDecl>(
E->getCalleeDecl())) {
3953 if (
Method->isTrivial()) {
3955 Inherited::VisitStmt(
E);
3964 if (
E->getConstructor()->isTrivial()) {
3966 Inherited::VisitStmt(
E);
3977 E->getTemporary()->getDestructor()) {
3978 if (DtorDecl->isTrivial()) {
3979 Inherited::VisitStmt(
E);
3990 NonTrivialCallFinder Finder(Ctx);
3992 return Finder.hasNonTrivialCall();
4010 llvm_unreachable(
"Unexpected value dependent expression!");
4038 CE->getSubExpr()->getType()->isIntegerType())
4039 return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
4042 }
else if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(
this)) {
4044 return ICE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
4045 }
else if (
const ParenExpr *PE = dyn_cast<ParenExpr>(
this)) {
4048 return PE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
4050 dyn_cast<GenericSelectionExpr>(
this)) {
4051 if (GE->isResultDependent())
4053 return GE->getResultExpr()->isNullPointerConstant(Ctx, NPC);
4054 }
else if (
const ChooseExpr *CE = dyn_cast<ChooseExpr>(
this)) {
4055 if (CE->isConditionDependent())
4057 return CE->getChosenSubExpr()->isNullPointerConstant(Ctx, NPC);
4059 = dyn_cast<CXXDefaultArgExpr>(
this)) {
4061 return DefaultArg->getExpr()->isNullPointerConstant(Ctx, NPC);
4063 = dyn_cast<CXXDefaultInitExpr>(
this)) {
4065 return DefaultInit->getExpr()->isNullPointerConstant(Ctx, NPC);
4066 }
else if (isa<GNUNullExpr>(
this)) {
4070 = dyn_cast<MaterializeTemporaryExpr>(
this)) {
4071 return M->getSubExpr()->isNullPointerConstant(Ctx, NPC);
4072 }
else if (
const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(
this)) {
4073 if (
const Expr *Source = OVE->getSourceExpr())
4074 return Source->isNullPointerConstant(Ctx, NPC);
4083 if (
getType()->isNullPtrType())
4088 UT->getOriginalDecl()
4089 ->getMostRecentDecl()
4090 ->hasAttr<TransparentUnionAttr>())
4092 const Expr *InitExpr = CLE->getInitializer();
4093 if (
const InitListExpr *ILE = dyn_cast<InitListExpr>(InitExpr))
4097 if (!
getType()->isIntegerType() ||
4120 if (isa<IntegerLiteral>(
this))
4128 const Expr *
E =
this;
4131 "expression is not a property reference");
4134 if (BO->getOpcode() == BO_Comma) {
4143 return cast<ObjCPropertyRefExpr>(
E);
4168 if (ICE->getCastKind() == CK_LValueToRValue ||
4169 (ICE->isGLValue() && ICE->getCastKind() == CK_NoOp))
4176 if (
FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
4177 if (Field->isBitField())
4187 if (
FieldDecl *Field = dyn_cast<FieldDecl>(DeclRef->getDecl()))
4188 if (Field->isBitField())
4191 if (
BindingDecl *BD = dyn_cast<BindingDecl>(DeclRef->getDecl()))
4192 if (
Expr *
E = BD->getBinding())
4197 if (BinOp->isAssignmentOp() && BinOp->getLHS())
4198 return BinOp->getLHS()->getSourceBitField();
4200 if (BinOp->getOpcode() == BO_Comma && BinOp->getRHS())
4201 return BinOp->getRHS()->getSourceBitField();
4205 if (UnOp->isPrefix() && UnOp->isIncrementDecrementOp())
4206 return UnOp->getSubExpr()->getSourceBitField();
4213 if (
auto *DRE = dyn_cast<DeclRefExpr>(
E))
4214 return dyn_cast<EnumConstantDecl>(DRE->getDecl());
4223 if (ICE->isGLValue() && ICE->getCastKind() == CK_NoOp)
4232 if (isa<ExtVectorElementExpr>(
E))
4235 if (
auto *DRE = dyn_cast<DeclRefExpr>(
E))
4236 if (
auto *BD = dyn_cast<BindingDecl>(DRE->getDecl()))
4237 if (
auto *
E = BD->getBinding())
4247 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
4249 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
4265 case CXXThisExprClass:
4267 case DeclRefExprClass: {
4270 const auto *DRE1 = cast<DeclRefExpr>(E1);
4271 const auto *DRE2 = cast<DeclRefExpr>(E2);
4273 if (DRE1->getDecl() != DRE2->getDecl())
4276 if ((DRE1->isPRValue() && DRE2->isPRValue()) ||
4277 (DRE1->isLValue() && DRE2->isLValue()))
4282 case ImplicitCastExprClass: {
4285 const auto *ICE1 = dyn_cast<ImplicitCastExpr>(E1);
4286 const auto *ICE2 = dyn_cast<ImplicitCastExpr>(E2);
4289 if (ICE1->getCastKind() != ICE2->getCastKind())
4291 ICE2->IgnoreParenImpCasts());
4295 if (ICE1->getCastKind() == CK_LValueToRValue ||
4296 ICE1->getCastKind() == CK_ArrayToPointerDecay ||
4297 ICE1->getCastKind() == CK_FunctionToPointerDecay) {
4302 const auto *DRE1 = dyn_cast<DeclRefExpr>(E1);
4303 const auto *DRE2 = dyn_cast<DeclRefExpr>(E2);
4307 const auto *Ivar1 = dyn_cast<ObjCIvarRefExpr>(E1);
4308 const auto *Ivar2 = dyn_cast<ObjCIvarRefExpr>(E2);
4309 if (Ivar1 && Ivar2) {
4310 return Ivar1->isFreeIvar() && Ivar2->isFreeIvar() &&
4314 const auto *Array1 = dyn_cast<ArraySubscriptExpr>(E1);
4315 const auto *Array2 = dyn_cast<ArraySubscriptExpr>(E2);
4316 if (Array1 && Array2) {
4320 auto Idx1 = Array1->getIdx();
4321 auto Idx2 = Array2->getIdx();
4322 const auto Integer1 = dyn_cast<IntegerLiteral>(Idx1);
4323 const auto Integer2 = dyn_cast<IntegerLiteral>(Idx2);
4324 if (Integer1 && Integer2) {
4325 if (!llvm::APInt::isSameValue(Integer1->getValue(),
4326 Integer2->getValue()))
4337 while (isa<MemberExpr>(E1) && isa<MemberExpr>(E2)) {
4338 const auto *ME1 = cast<MemberExpr>(E1);
4339 const auto *ME2 = cast<MemberExpr>(E2);
4342 if (
const auto *
D = dyn_cast<VarDecl>(ME1->getMemberDecl()))
4343 if (
D->isStaticDataMember())
4349 if (isa<CXXThisExpr>(E1) && isa<CXXThisExpr>(E2))
4355 if (
const auto *DRE = dyn_cast<DeclRefExpr>(
E))
4356 return DRE->getDecl();
4357 if (
const auto *ME = dyn_cast<MemberExpr>(
E))
4358 return ME->getMemberDecl();
4377 return VT->getNumElements();
4385 StringRef Comp = Accessor->
getName();
4388 if (Comp ==
"hi" || Comp ==
"lo" || Comp ==
"even" || Comp ==
"odd")
4392 if (Comp[0] ==
's' || Comp[0] ==
'S')
4393 Comp = Comp.substr(1);
4395 for (
unsigned i = 0, e = Comp.size(); i != e; ++i)
4396 if (Comp.substr(i + 1).contains(Comp[i]))
4405 StringRef Comp = Accessor->
getName();
4406 bool isNumericAccessor =
false;
4407 if (Comp[0] ==
's' || Comp[0] ==
'S') {
4408 Comp = Comp.substr(1);
4409 isNumericAccessor =
true;
4412 bool isHi = Comp ==
"hi";
4413 bool isLo = Comp ==
"lo";
4414 bool isEven = Comp ==
"even";
4415 bool isOdd = Comp ==
"odd";
4431 Elts.push_back(Index);
4439 BuiltinLoc(BLoc), RParenLoc(RP) {
4441 SubExprs =
new (
C)
Stmt*[args.size()];
4442 for (
unsigned i = 0; i != args.size(); i++)
4443 SubExprs[i] = args[i];
4449 if (SubExprs)
C.Deallocate(SubExprs);
4453 llvm::copy(Exprs, SubExprs);
4456GenericSelectionExpr::GenericSelectionExpr(
4460 bool ContainsUnexpandedParameterPack,
unsigned ResultIndex)
4461 :
Expr(GenericSelectionExprClass, AssocExprs[ResultIndex]->getType(),
4462 AssocExprs[ResultIndex]->getValueKind(),
4463 AssocExprs[ResultIndex]->getObjectKind()),
4464 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
4465 IsExprPredicate(
true), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4466 assert(AssocTypes.size() == AssocExprs.size() &&
4467 "Must have the same number of association expressions"
4468 " and TypeSourceInfo!");
4469 assert(ResultIndex < NumAssocs &&
"ResultIndex is out-of-bounds!");
4472 getTrailingObjects<Stmt *>()[getIndexOfControllingExpression()] =
4474 llvm::copy(AssocExprs,
4475 getTrailingObjects<Stmt *>() + getIndexOfStartOfAssociatedExprs());
4476 llvm::copy(AssocTypes, getTrailingObjects<TypeSourceInfo *>() +
4477 getIndexOfStartOfAssociatedTypes());
4482GenericSelectionExpr::GenericSelectionExpr(
4487 unsigned ResultIndex)
4488 :
Expr(GenericSelectionExprClass, AssocExprs[ResultIndex]->getType(),
4489 AssocExprs[ResultIndex]->getValueKind(),
4490 AssocExprs[ResultIndex]->getObjectKind()),
4491 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
4492 IsExprPredicate(
false), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4493 assert(AssocTypes.size() == AssocExprs.size() &&
4494 "Must have the same number of association expressions"
4495 " and TypeSourceInfo!");
4496 assert(ResultIndex < NumAssocs &&
"ResultIndex is out-of-bounds!");
4499 getTrailingObjects<TypeSourceInfo *>()[getIndexOfControllingType()] =
4501 llvm::copy(AssocExprs,
4502 getTrailingObjects<Stmt *>() + getIndexOfStartOfAssociatedExprs());
4503 llvm::copy(AssocTypes, getTrailingObjects<TypeSourceInfo *>() +
4504 getIndexOfStartOfAssociatedTypes());
4509GenericSelectionExpr::GenericSelectionExpr(
4513 bool ContainsUnexpandedParameterPack)
4514 :
Expr(GenericSelectionExprClass, Context.DependentTy,
VK_PRValue,
4516 NumAssocs(AssocExprs.size()), ResultIndex(ResultDependentIndex),
4517 IsExprPredicate(
true), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4518 assert(AssocTypes.size() == AssocExprs.size() &&
4519 "Must have the same number of association expressions"
4520 " and TypeSourceInfo!");
4523 getTrailingObjects<Stmt *>()[getIndexOfControllingExpression()] =
4525 llvm::copy(AssocExprs,
4526 getTrailingObjects<Stmt *>() + getIndexOfStartOfAssociatedExprs());
4527 llvm::copy(AssocTypes, getTrailingObjects<TypeSourceInfo *>() +
4528 getIndexOfStartOfAssociatedTypes());
4533GenericSelectionExpr::GenericSelectionExpr(
4538 :
Expr(GenericSelectionExprClass, Context.DependentTy,
VK_PRValue,
4540 NumAssocs(AssocExprs.size()), ResultIndex(ResultDependentIndex),
4541 IsExprPredicate(
false), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4542 assert(AssocTypes.size() == AssocExprs.size() &&
4543 "Must have the same number of association expressions"
4544 " and TypeSourceInfo!");
4547 getTrailingObjects<TypeSourceInfo *>()[getIndexOfControllingType()] =
4549 llvm::copy(AssocExprs,
4550 getTrailingObjects<Stmt *>() + getIndexOfStartOfAssociatedExprs());
4551 llvm::copy(AssocTypes, getTrailingObjects<TypeSourceInfo *>() +
4552 getIndexOfStartOfAssociatedTypes());
4557GenericSelectionExpr::GenericSelectionExpr(EmptyShell
Empty,
unsigned NumAssocs)
4558 :
Expr(GenericSelectionExprClass,
Empty), NumAssocs(NumAssocs) {}
4564 bool ContainsUnexpandedParameterPack,
unsigned ResultIndex) {
4565 unsigned NumAssocs = AssocExprs.size();
4567 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4570 Context, GenericLoc, ControllingExpr, AssocTypes, AssocExprs, DefaultLoc,
4571 RParenLoc, ContainsUnexpandedParameterPack, ResultIndex);
4578 bool ContainsUnexpandedParameterPack) {
4579 unsigned NumAssocs = AssocExprs.size();
4581 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4584 Context, GenericLoc, ControllingExpr, AssocTypes, AssocExprs, DefaultLoc,
4585 RParenLoc, ContainsUnexpandedParameterPack);
4593 unsigned ResultIndex) {
4594 unsigned NumAssocs = AssocExprs.size();
4596 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4599 Context, GenericLoc, ControllingType, AssocTypes, AssocExprs, DefaultLoc,
4600 RParenLoc, ContainsUnexpandedParameterPack, ResultIndex);
4607 SourceLocation RParenLoc,
bool ContainsUnexpandedParameterPack) {
4608 unsigned NumAssocs = AssocExprs.size();
4610 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4613 Context, GenericLoc, ControllingType, AssocTypes, AssocExprs, DefaultLoc,
4614 RParenLoc, ContainsUnexpandedParameterPack);
4619 unsigned NumAssocs) {
4621 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4644 EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
4645 NumDesignators(Designators.
size()), NumSubExprs(IndexExprs.
size() + 1) {
4646 this->Designators =
new (
C)
Designator[NumDesignators];
4654 unsigned IndexIdx = 0;
4655 for (
unsigned I = 0; I != NumDesignators; ++I) {
4656 this->Designators[I] = Designators[I];
4659 *Child++ = IndexExprs[IndexIdx++];
4662 *Child++ = IndexExprs[IndexIdx++];
4663 *Child++ = IndexExprs[IndexIdx++];
4667 assert(IndexIdx == IndexExprs.size() &&
"Wrong number of index expressions");
4675 bool UsesColonSyntax,
4677 void *Mem =
C.Allocate(totalSizeToAlloc<Stmt *>(IndexExprs.size() + 1),
4680 ColonOrEqualLoc, UsesColonSyntax,
4685 unsigned NumIndexExprs) {
4686 void *Mem =
C.Allocate(totalSizeToAlloc<Stmt *>(NumIndexExprs + 1),
4693 unsigned NumDesigs) {
4695 NumDesignators = NumDesigs;
4696 for (
unsigned I = 0; I != NumDesigs; ++I)
4697 Designators[I] = Desigs[I];
4711 if (
First.isFieldDesignator()) {
4714 for (
unsigned int i = 0; i < DIE->size(); i++) {
4722 return First.getLBracketLoc();
4730 assert(
D.isArrayDesignator() &&
"Requires array designator");
4735 assert(
D.isArrayRangeDesignator() &&
"Requires array range designator");
4740 assert(
D.isArrayRangeDesignator() &&
"Requires array range designator");
4749 unsigned NumNewDesignators =
Last -
First;
4750 if (NumNewDesignators == 0) {
4751 std::copy_backward(Designators + Idx + 1,
4752 Designators + NumDesignators,
4754 --NumNewDesignators;
4757 if (NumNewDesignators == 1) {
4758 Designators[Idx] = *
First;
4763 =
new (
C)
Designator[NumDesignators - 1 + NumNewDesignators];
4764 std::copy(Designators, Designators + Idx, NewDesignators);
4765 std::copy(
First,
Last, NewDesignators + Idx);
4766 std::copy(Designators + Idx + 1, Designators + NumDesignators,
4767 NewDesignators + Idx + NumNewDesignators);
4768 Designators = NewDesignators;
4769 NumDesignators = NumDesignators - 1 + NumNewDesignators;
4778 BaseAndUpdaterExprs[0] = baseExpr;
4782 BaseAndUpdaterExprs[1] = ILE;
4799 LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
4801 llvm::copy(Exprs, getTrailingObjects());
4805ParenListExpr::ParenListExpr(EmptyShell
Empty,
unsigned NumExprs)
4814 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(Exprs.size()),
4816 return new (Mem)
ParenListExpr(LParenLoc, Exprs, RParenLoc);
4820 unsigned NumExprs) {
4830static std::optional<BinaryOperator *>
4833 if (
E->getOpcode() == BO_LT) {
4835 ComparedTo =
E->getRHS();
4836 }
else if (
E->getOpcode() == BO_GT) {
4838 ComparedTo =
E->getLHS();
4843 const Expr *AddLHS =
nullptr, *AddRHS =
nullptr;
4846 if (BO && BO->
getOpcode() == clang::BO_Add) {
4852 if (!AddLHS || !AddRHS)
4855 const Decl *LHSDecl, *RHSDecl, *OtherDecl;
4858 RHSDecl = AddRHS->IgnoreParenImpCasts()->getReferencedDeclOfCallee();
4864 if (!LHSDecl && !RHSDecl)
4867 if ((LHSDecl && LHSDecl == OtherDecl && LHSDecl != RHSDecl) ||
4868 (RHSDecl && RHSDecl == OtherDecl && RHSDecl != LHSDecl))
4890 Result.value()->setExcludedOverflowPattern(
true);
4897 :
Expr(BinaryOperatorClass, ResTy,
VK, OK) {
4900 "Use CompoundAssignOperator for compound assignments");
4903 SubExprs[LHS] = lhs;
4904 SubExprs[RHS] = rhs;
4916 :
Expr(CompoundAssignOperatorClass, ResTy,
VK, OK) {
4920 "Use CompoundAssignOperator for compound assignments");
4922 SubExprs[LHS] = lhs;
4923 SubExprs[RHS] = rhs;
4931 bool HasFPFeatures) {
4971 CompLHSType, CompResultType);
4975 bool hasFPFeatures) {
4976 void *Mem =
C.Allocate(totalSizeToAlloc<FPOptionsOverride>(hasFPFeatures),
4985 :
Expr(UnaryOperatorClass,
type,
VK, OK), Val(input) {
5001 unsigned Size = totalSizeToAlloc<FPOptionsOverride>(HasFPFeatures);
5009 e = ewc->getSubExpr();
5011 e = m->getSubExpr();
5012 e = cast<CXXConstructExpr>(e)->getArg(0);
5014 e = ice->getSubExpr();
5015 return cast<OpaqueValueExpr>(e);
5020 unsigned numSemanticExprs) {
5022 Context.
Allocate(totalSizeToAlloc<Expr *>(1 + numSemanticExprs),
5027PseudoObjectExpr::PseudoObjectExpr(EmptyShell shell,
unsigned numSemanticExprs)
5028 :
Expr(PseudoObjectExprClass, shell) {
5034 unsigned resultIndex) {
5035 assert(syntax &&
"no syntactic expression!");
5036 assert(
semantics.size() &&
"no semantic expressions!");
5050 void *buffer =
C.Allocate(totalSizeToAlloc<Expr *>(
semantics.size() + 1),
5058 unsigned resultIndex)
5067 return !isa<OpaqueValueExpr>(
E) ||
5068 cast<OpaqueValueExpr>(
E)->getSourceExpr() !=
5071 "opaque-value semantic expressions for pseudo-object "
5072 "operations must have sources");
5074 llvm::copy(
semantics, Trail.drop_front().begin());
5105 NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op) {
5106 assert(args.size() ==
getNumSubExprs(op) &&
"wrong number of subexpressions");
5107 for (
unsigned i = 0; i != args.size(); i++)
5108 SubExprs[i] = args[i];
5114 case AO__c11_atomic_init:
5115 case AO__opencl_atomic_init:
5116 case AO__c11_atomic_load:
5117 case AO__atomic_load_n:
5118 case AO__atomic_test_and_set:
5119 case AO__atomic_clear:
5122 case AO__scoped_atomic_load_n:
5123 case AO__opencl_atomic_load:
5124 case AO__hip_atomic_load:
5125 case AO__c11_atomic_store:
5126 case AO__c11_atomic_exchange:
5127 case AO__atomic_load:
5128 case AO__atomic_store:
5129 case AO__atomic_store_n:
5130 case AO__atomic_exchange_n:
5131 case AO__c11_atomic_fetch_add:
5132 case AO__c11_atomic_fetch_sub:
5133 case AO__c11_atomic_fetch_and:
5134 case AO__c11_atomic_fetch_or:
5135 case AO__c11_atomic_fetch_xor:
5136 case AO__c11_atomic_fetch_nand:
5137 case AO__c11_atomic_fetch_max:
5138 case AO__c11_atomic_fetch_min:
5139 case AO__atomic_fetch_add:
5140 case AO__atomic_fetch_sub:
5141 case AO__atomic_fetch_and:
5142 case AO__atomic_fetch_or:
5143 case AO__atomic_fetch_xor:
5144 case AO__atomic_fetch_nand:
5145 case AO__atomic_add_fetch:
5146 case AO__atomic_sub_fetch:
5147 case AO__atomic_and_fetch:
5148 case AO__atomic_or_fetch:
5149 case AO__atomic_xor_fetch:
5150 case AO__atomic_nand_fetch:
5151 case AO__atomic_min_fetch:
5152 case AO__atomic_max_fetch:
5153 case AO__atomic_fetch_min:
5154 case AO__atomic_fetch_max:
5157 case AO__scoped_atomic_load:
5158 case AO__scoped_atomic_store:
5159 case AO__scoped_atomic_store_n:
5160 case AO__scoped_atomic_fetch_add:
5161 case AO__scoped_atomic_fetch_sub:
5162 case AO__scoped_atomic_fetch_and:
5163 case AO__scoped_atomic_fetch_or:
5164 case AO__scoped_atomic_fetch_xor:
5165 case AO__scoped_atomic_fetch_nand:
5166 case AO__scoped_atomic_add_fetch:
5167 case AO__scoped_atomic_sub_fetch:
5168 case AO__scoped_atomic_and_fetch:
5169 case AO__scoped_atomic_or_fetch:
5170 case AO__scoped_atomic_xor_fetch:
5171 case AO__scoped_atomic_nand_fetch:
5172 case AO__scoped_atomic_min_fetch:
5173 case AO__scoped_atomic_max_fetch:
5174 case AO__scoped_atomic_fetch_min:
5175 case AO__scoped_atomic_fetch_max:
5176 case AO__scoped_atomic_exchange_n:
5177 case AO__hip_atomic_exchange:
5178 case AO__hip_atomic_fetch_add:
5179 case AO__hip_atomic_fetch_sub:
5180 case AO__hip_atomic_fetch_and:
5181 case AO__hip_atomic_fetch_or:
5182 case AO__hip_atomic_fetch_xor:
5183 case AO__hip_atomic_fetch_min:
5184 case AO__hip_atomic_fetch_max:
5185 case AO__opencl_atomic_store:
5186 case AO__hip_atomic_store:
5187 case AO__opencl_atomic_exchange:
5188 case AO__opencl_atomic_fetch_add:
5189 case AO__opencl_atomic_fetch_sub:
5190 case AO__opencl_atomic_fetch_and:
5191 case AO__opencl_atomic_fetch_or:
5192 case AO__opencl_atomic_fetch_xor:
5193 case AO__opencl_atomic_fetch_min:
5194 case AO__opencl_atomic_fetch_max:
5195 case AO__atomic_exchange:
5198 case AO__scoped_atomic_exchange:
5199 case AO__c11_atomic_compare_exchange_strong:
5200 case AO__c11_atomic_compare_exchange_weak:
5202 case AO__hip_atomic_compare_exchange_strong:
5203 case AO__opencl_atomic_compare_exchange_strong:
5204 case AO__opencl_atomic_compare_exchange_weak:
5205 case AO__hip_atomic_compare_exchange_weak:
5206 case AO__atomic_compare_exchange:
5207 case AO__atomic_compare_exchange_n:
5210 case AO__scoped_atomic_compare_exchange:
5211 case AO__scoped_atomic_compare_exchange_n:
5214 llvm_unreachable(
"unknown atomic op");
5220 return AT->getValueType();
5225 unsigned ArraySectionCount = 0;
5226 while (
auto *OASE = dyn_cast<ArraySectionExpr>(
Base->IgnoreParens())) {
5227 Base = OASE->getBase();
5228 ++ArraySectionCount;
5231 dyn_cast<ArraySubscriptExpr>(
Base->IgnoreParenImpCasts())) {
5232 Base = ASE->getBase();
5233 ++ArraySectionCount;
5235 Base =
Base->IgnoreParenImpCasts();
5236 auto OriginalTy =
Base->getType();
5237 if (
auto *DRE = dyn_cast<DeclRefExpr>(
Base))
5238 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl()))
5239 OriginalTy = PVD->getOriginalType().getNonReferenceType();
5241 for (
unsigned Cnt = 0; Cnt < ArraySectionCount; ++Cnt) {
5242 if (OriginalTy->isAnyPointerType())
5243 OriginalTy = OriginalTy->getPointeeType();
5244 else if (OriginalTy->isArrayType())
5245 OriginalTy = OriginalTy->castAsArrayTypeUnsafe()->getElementType();
5254 :
Expr(RecoveryExprClass,
T.getNonReferenceType(),
5255 T->isDependentType() ?
VK_LValue : getValueKindForType(
T),
5257 BeginLoc(BeginLoc), EndLoc(EndLoc), NumExprs(SubExprs.size()) {
5258 assert(!
T.isNull());
5259 assert(!llvm::is_contained(SubExprs,
nullptr));
5261 llvm::copy(SubExprs, getTrailingObjects());
5269 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Expr *>(SubExprs.size()),
5271 return new (Mem)
RecoveryExpr(Ctx,
T, BeginLoc, EndLoc, SubExprs);
5275 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Expr *>(NumSubExprs),
5282 NumDims == Dims.size() &&
5283 "Preallocated number of dimensions is different from the provided one.");
5284 llvm::copy(Dims, getTrailingObjects<Expr *>());
5289 NumDims == BR.size() &&
5290 "Preallocated number of dimensions is different from the provided one.");
5291 llvm::copy(BR, getTrailingObjects<SourceRange>());
5294OMPArrayShapingExpr::OMPArrayShapingExpr(
QualType ExprTy,
Expr *Op,
5298 RPLoc(R), NumDims(Dims.size()) {
5300 setDimensions(Dims);
5309 assert(Dims.size() == BracketRanges.size() &&
5310 "Different number of dimensions and brackets ranges.");
5312 totalSizeToAlloc<Expr *, SourceRange>(Dims.size() + 1, Dims.size()),
5315 E->setBracketsRanges(BracketRanges);
5322 totalSizeToAlloc<Expr *, SourceRange>(NumDims + 1, NumDims),
5327void OMPIteratorExpr::setIteratorDeclaration(
unsigned I,
Decl *
D) {
5328 getTrailingObjects<Decl *>(NumIterators)[I] =
D;
5332 assert(I < NumIterators &&
5333 "Idx is greater or equal the number of iterators definitions.");
5336 static_cast<int>(RangeLocOffset::AssignLoc)] =
Loc;
5339void OMPIteratorExpr::setIteratorRange(
unsigned I,
Expr *
Begin,
5343 assert(I < NumIterators &&
5344 "Idx is greater or equal the number of iterators definitions.");
5345 getTrailingObjects<Expr *>()[I *
static_cast<int>(RangeExprOffset::Total) +
5346 static_cast<int>(RangeExprOffset::Begin)] =
5348 getTrailingObjects<Expr *>()[I *
static_cast<int>(RangeExprOffset::Total) +
5349 static_cast<int>(RangeExprOffset::End)] = End;
5350 getTrailingObjects<Expr *>()[I *
static_cast<int>(RangeExprOffset::Total) +
5351 static_cast<int>(RangeExprOffset::Step)] = Step;
5354 static_cast<int>(RangeLocOffset::FirstColonLoc)] =
5358 static_cast<int>(RangeLocOffset::SecondColonLoc)] =
5363 return getTrailingObjects<Decl *>()[I];
5369 getTrailingObjects<Expr *>()[I *
static_cast<int>(
5370 RangeExprOffset::Total) +
5371 static_cast<int>(RangeExprOffset::Begin)];
5373 getTrailingObjects<Expr *>()[I *
static_cast<int>(
5374 RangeExprOffset::Total) +
5375 static_cast<int>(RangeExprOffset::End)];
5377 getTrailingObjects<Expr *>()[I *
static_cast<int>(
5378 RangeExprOffset::Total) +
5379 static_cast<int>(RangeExprOffset::Step)];
5384 return getTrailingObjects<
5386 static_cast<int>(RangeLocOffset::AssignLoc)];
5390 return getTrailingObjects<
5392 static_cast<int>(RangeLocOffset::FirstColonLoc)];
5396 return getTrailingObjects<
5398 static_cast<int>(RangeLocOffset::SecondColonLoc)];
5402 getTrailingObjects<OMPIteratorHelperData>()[I] =
D;
5406 return getTrailingObjects<OMPIteratorHelperData>()[I];
5410 return getTrailingObjects<OMPIteratorHelperData>()[I];
5413OMPIteratorExpr::OMPIteratorExpr(
5418 IteratorKwLoc(IteratorKwLoc), LPLoc(L), RPLoc(R),
5419 NumIterators(
Data.size()) {
5420 for (
unsigned I = 0,
E =
Data.size(); I <
E; ++I) {
5421 const IteratorDefinition &
D =
Data[I];
5422 setIteratorDeclaration(I,
D.IteratorDecl);
5423 setAssignmentLoc(I,
D.AssignmentLoc);
5424 setIteratorRange(I,
D.Range.Begin,
D.ColonLoc,
D.Range.End,
5425 D.SecondColonLoc,
D.Range.Step);
5426 setHelper(I, Helpers[I]);
5437 assert(
Data.size() == Helpers.size() &&
5438 "Data and helpers must have the same size.");
5440 totalSizeToAlloc<Decl *, Expr *, SourceLocation, OMPIteratorHelperData>(
5441 Data.size(),
Data.size() *
static_cast<int>(RangeExprOffset::Total),
5442 Data.size() *
static_cast<int>(RangeLocOffset::Total),
5449 unsigned NumIterators) {
5451 totalSizeToAlloc<Decl *, Expr *, SourceLocation, OMPIteratorHelperData>(
5452 NumIterators, NumIterators *
static_cast<int>(RangeExprOffset::Total),
5453 NumIterators *
static_cast<int>(RangeLocOffset::Total), NumIterators),
5480 bool hasFPFeatures) {
5481 void *Mem =
C.Allocate(totalSizeToAlloc<FPOptionsOverride>(hasFPFeatures),
5491 unsigned Size = totalSizeToAlloc<FPOptionsOverride>(HasFPFeatures);
5494 RParenLoc, FPFeatures);
5500 StaticValue =
new (Ctx)
APValue;
5503 return *StaticValue;
5507 assert(StaticValue);
5508 return *StaticValue;
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
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 const Expr * skipTemporaryBindingsNoOpCastsAndParens(const Expr *E)
Skip over any no-op casts and any temporary-binding expressions.
static unsigned SizeOfCallExprInstance(Expr::StmtClass SC)
static void AssertResultStorageKind(ConstantResultStorageKind Kind)
static void computeOverflowPatternExclusion(const ASTContext &Ctx, const BinaryOperator *E)
Compute and set the OverflowPatternExclusion bit based on whether the BinaryOperator expression match...
static std::optional< BinaryOperator * > getOverflowPatternBinOp(const BinaryOperator *E)
Certain overflow-dependent code patterns can have their integer overflow sanitization disabled.
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 QualType getPointeeType(const MemRegion *R)
static const TypeInfo & getInfo(unsigned id)
a trap message and trap category.
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()
const ConstantArrayType * getAsConstantArrayType(QualType T) const
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.
Builtin::Context & BuiltinInfo
const LangOptions & getLangOpts() const
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
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.
void * Allocate(size_t Size, unsigned Align=8) const
CanQualType UnsignedIntTy
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
QualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
UnnamedGlobalConstantDecl * getUnnamedGlobalConstantDecl(QualType Ty, const APValue &Value) const
Return a declaration for a uniquified anonymous global constant corresponding to a given APValue.
const TargetInfo & getTargetInfo() const
void addDestruction(T *Ptr) const
If T isn't trivially destructible, calls AddDeallocation to register it for destruction.
CanQualType getCanonicalTagType(const TagDecl *TD) const
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
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.
Represents a call to a C++ constructor.
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
unsigned getNumArgs() const
Return the number of arguments to the constructor 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]).
Represents the this expression in C++.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool hasStoredFPFeatures() const
std::optional< llvm::APInt > evaluateBytesReturnedByAllocSizeCall(const ASTContext &Ctx) const
Evaluates the total size in bytes allocated by calling a function decorated with alloc_size.
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.
const AllocSizeAttr * getCalleeAllocSizeAttr() const
Try to get the alloc_size attribute of the callee. May return null.
unsigned getBuiltinCallee() const
getBuiltinCallee - If this is a call to a builtin, return the builtin ID of the callee.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
static CallExpr * CreateEmpty(const ASTContext &Ctx, unsigned NumArgs, bool HasFPFeatures, EmptyShell Empty)
Create an empty call expression, for deserialization.
bool isCallToStdMove() const
void setPreArg(unsigned I, Stmt *PreArg)
static constexpr unsigned OffsetToTrailingObjects
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.
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...
static constexpr ADLCallKind UsesADL
bool isBuiltinAssumeFalse(const ASTContext &Ctx) const
Return true if this is a call to __assume() or __builtin_assume() with a non-value-dependent constant...
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
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].
bool hasStaticStorage() const
APValue & getStaticValue() const
APValue & getOrCreateStaticValue(ASTContext &Ctx) const
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)
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
static ConvertVectorExpr * Create(const ASTContext &C, Expr *SrcExpr, TypeSourceInfo *TI, QualType DstType, ExprValueKind VK, ExprObjectKind OK, SourceLocation BuiltinLoc, SourceLocation RParenLoc, FPOptionsOverride FPFeatures)
static ConvertVectorExpr * CreateEmpty(const ASTContext &C, bool hasFPFeatures)
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.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
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.
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)
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.
static bool isFlexibleArrayMemberLike(const ASTContext &Context, const Decl *D, QualType Ty, LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel, bool IgnoreTemplateOrMacroSubstitution)
Whether it resembles a flexible array member.
ASTContext & getASTContext() const LLVM_READONLY
static Decl * castFromDeclContext(const DeclContext *)
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
DeclarationNameLoc - Additional source/type location info for a declaration name.
Represents the type decltype(expr) (C++11).
Represents a single C99 designator.
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
FieldDecl * getFieldDecl() 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 * getSubExpr(unsigned Idx) const
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).
Expr * getArrayIndex(const Designator &D) const
Designator * getDesignator(unsigned Idx)
Expr * getInit() const
Retrieve the initializer value.
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)
SourceLocation getEndLoc() const LLVM_READONLY
static DesignatedInitExpr * Create(const ASTContext &C, ArrayRef< Designator > Designators, ArrayRef< Expr * > IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
SourceLocation getBeginLoc() const LLVM_READONLY
DesignatedInitUpdateExpr(const ASTContext &C, SourceLocation lBraceLoc, Expr *baseExprs, SourceLocation rBraceLoc)
SourceLocation getEndLoc() const LLVM_READONLY
InitListExpr * getUpdater() const
EmbedExpr(const ASTContext &Ctx, SourceLocation Loc, EmbedDataStorage *Data, unsigned Begin, unsigned NumOfElements)
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...
bool isIntegerConstantExpr(const ASTContext &Ctx) const
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_AllowSideEffects
Allow any unmodeled side effect.
@ 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.
static std::pair< const NamedDecl *, const WarnUnusedResultAttr * > getUnusedResultAttrImpl(const Decl *Callee, QualType ReturnType)
Returns the WarnUnusedResultAttr that is declared on the callee or its return type declaration,...
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.
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 isFlexibleArrayMemberLike(const 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...
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.
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.
const Expr * getBestDynamicClassTypeExpr() const
Get the inner expression that determines the best dynamic class.
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.
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.
const Expr * skipRValueSubobjectAdjustments() const
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.
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...
const Expr * getBase() const
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
llvm::APInt getValue() const
Returns an internal integer representation of the literal.
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
TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
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.
This class represents temporary values used to represent inout and out arguments in HLSL.
static HLSLOutArgExpr * CreateEmpty(const ASTContext &Ctx)
static HLSLOutArgExpr * Create(const ASTContext &C, QualType Ty, OpaqueValueExpr *Base, OpaqueValueExpr *OpV, Expr *WB, bool IsInOut)
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.
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?
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
unsigned getNumInits() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isSemanticForm() const
void setInit(unsigned Init, Expr *expr)
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...
void setArrayFiller(Expr *filler)
InitListExpr * getSyntacticForm() const
const Expr * getInit(unsigned Init) const
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
ArrayRef< Expr * > inits()
void sawArrayRangeDesignator(bool ARD=true)
Expr ** getInits()
Retrieve the set of initializers.
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
@ AddUnsignedOverflowTest
if (a + b < a)
@ AddSignedOverflowTest
if (a + b < a)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isOverflowPatternExcluded(OverflowPatternExclusionKind Kind) const
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.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
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.
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.
bool hasUnusedResultAttr(ASTContext &Ctx) const
Returns true if this message send should warn on unused results.
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)
FieldDecl * getField() const
For a field offsetof node, returns the field.
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of 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.
This expression type represents an asterisk in an OpenACC Size-Expr, used in the 'tile' and 'gang' cl...
static OpenACCAsteriskSizeExpr * Create(const ASTContext &C, SourceLocation Loc)
static OpenACCAsteriskSizeExpr * CreateEmpty(const ASTContext &C)
ParenExpr - This represents a parenthesized 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
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr * > semantic, unsigned resultIndex)
ArrayRef< Expr * > semantics()
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...
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)
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)
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
const DeclContext * getParentContext() const
If the SourceLocExpr has been resolved return the subexpression representing the resolved value.
StringRef getBuiltinStr() const
Return a string representing the name of the specific builtin function.
static bool MayBeDependent(SourceLocIdentKind Kind)
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
ShuffleVectorExprBitfields ShuffleVectorExprBits
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
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind, bool Pascal, QualType Ty, ArrayRef< SourceLocation > Locs)
This is the "fully general" constructor that allows representation of strings formed from one or more...
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 * 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.
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 isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char,...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
CXXRecordDecl * castAsCXXRecordDecl() const
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.
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
RecordDecl * castAsRecordDecl() const
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type.
bool isVectorType() const
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
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.
Expr * getSubExpr() const
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.
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.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
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 ...
std::pair< FileID, unsigned > FileIDAndOffset
Expr * IgnoreExprNodes(Expr *E, FnTys &&... Fns)
Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *, Recursively apply each of the f...
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)
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.
ExprDependence computeDependence(FullExpr *E)
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Expr * IgnoreImplicitCastsExtraSingleStep(Expr *E)
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Result
The result type of a method or function.
Expr * IgnoreImplicitCastsSingleStep(Expr *E)
@ Dtor_Base
Base object dtor.
ActionResult< Expr * > ExprResult
CastKind
CastKind - The kind of operation required for a conversion.
void FixedPointValueToString(SmallVectorImpl< char > &Str, llvm::APSInt Val, unsigned Scale)
Expr * IgnoreImplicitSingleStep(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.
Expr * IgnoreParensSingleStep(Expr *E)
const FunctionProtoType * T
Expr * IgnoreImplicitAsWrittenSingleStep(Expr *E)
Expr * IgnoreCastsSingleStep(Expr *E)
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Expr * IgnoreLValueCastsSingleStep(Expr *E)
bool isLambdaMethod(const DeclContext *DC)
Expr * IgnoreParensOnlySingleStep(Expr *E)
@ PrettyFunctionNoVirtual
The same as PrettyFunction, except that the 'virtual' keyword is omitted for virtual member functions...
Expr * IgnoreBaseCastsSingleStep(Expr *E)
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 getEndLoc() const LLVM_READONLY
Stores data related to a single #embed directive.
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,...