37#include "llvm/Support/ErrorHandling.h"
38#include "llvm/Support/Format.h"
39#include "llvm/Support/raw_ostream.h"
51 if (
auto *BO = dyn_cast<BinaryOperator>(E)) {
52 if (BO->getOpcode() == BO_Comma) {
59 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
60 E = MTE->getSubExpr();
77 DerivedType = ATy->getElementType();
92 if (
const auto *CE = dyn_cast<CastExpr>(E)) {
93 if ((CE->getCastKind() == CK_DerivedToBase ||
94 CE->getCastKind() == CK_UncheckedDerivedToBase) &&
102 if (CE->getCastKind() == CK_NoOp) {
103 E = CE->getSubExpr();
106 }
else if (
const auto *ME = dyn_cast<MemberExpr>(E)) {
107 if (!ME->isArrow()) {
108 assert(ME->getBase()->getType()->getAsRecordDecl());
109 if (
const auto *Field = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
110 if (!Field->isBitField() && !Field->getType()->isReferenceType()) {
117 }
else if (
const auto *BO = dyn_cast<BinaryOperator>(E)) {
118 if (BO->getOpcode() == BO_PtrMemD) {
119 assert(BO->getRHS()->isPRValue());
125 if (BO->getOpcode() == BO_Comma) {
126 CommaLHSs.push_back(BO->getLHS());
148 BIT && BIT->
isUnsigned() && BIT->getNumBits() == 1)
152 switch (UO->getOpcode()) {
154 return UO->getSubExpr()->isKnownToHaveBooleanValue(Semantic);
166 return CE->getSubExpr()->isKnownToHaveBooleanValue(Semantic);
169 switch (BO->getOpcode()) {
170 default:
return false;
185 return BO->getLHS()->isKnownToHaveBooleanValue(Semantic) &&
186 BO->getRHS()->isKnownToHaveBooleanValue(Semantic);
190 return BO->getRHS()->isKnownToHaveBooleanValue(Semantic);
195 return CO->getTrueExpr()->isKnownToHaveBooleanValue(Semantic) &&
196 CO->getFalseExpr()->isKnownToHaveBooleanValue(Semantic);
201 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(E))
202 return OVE->getSourceExpr()->isKnownToHaveBooleanValue(Semantic);
205 if (!Semantic && FD->getType()->isUnsignedIntegerType() &&
206 !FD->getBitWidth()->isValueDependent() && FD->getBitWidthValue() == 1)
215 bool IgnoreTemplateOrMacroSubstitution)
const {
217 const Decl *D =
nullptr;
219 if (
const auto *ME = dyn_cast<MemberExpr>(E))
220 D = ME->getMemberDecl();
221 else if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
223 else if (
const auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
227 StrictFlexArraysLevel,
228 IgnoreTemplateOrMacroSubstitution);
238 if (
Value.isMemberPointer())
239 return Value.getMemberPointerDecl();
241 if (
Value.isLValue() &&
Value.getLValueOffset().isZero())
255 template <
class E,
class T>
258 return static_cast<const E*
>(
expr)->getExprLoc();
268 return static_cast<const E *
>(
expr)->getBeginLoc();
277 if (ED->isCompleteDefinition())
286#define ABSTRACT_STMT(type)
287#define STMT(type, base) \
288 case Stmt::type##Class: break;
289#define EXPR(type, base) \
290 case Stmt::type##Class: return getExprLocImpl<type>(this, &type::getExprLoc);
291#include "clang/AST/StmtNodes.inc"
293 llvm_unreachable(
"unknown expression kind");
304 "Invalid StorageKind Value");
314 if (!
Value.getInt().needsCleanup())
324 if (
T->isIntegralOrEnumerationType() && Context.getTypeInfo(
T).Width <= 64)
330 bool IsImmediateInvocation)
331 :
FullExpr(ConstantExprClass, SubExpr) {
340 ::new (getTrailingObjects<APValue>())
APValue();
345 bool IsImmediateInvocation) {
349 unsigned Size = totalSizeToAlloc<APValue, uint64_t>(
352 void *Mem = Context.Allocate(Size,
alignof(ConstantExpr));
353 return new (Mem) ConstantExpr(E, StorageKind, IsImmediateInvocation);
359 ConstantExpr *
Self =
Create(Context, E, StorageKind);
364ConstantExpr::ConstantExpr(EmptyShell
Empty,
370 ::new (getTrailingObjects<APValue>())
APValue();
377 unsigned Size = totalSizeToAlloc<APValue, uint64_t>(
380 void *Mem = Context.Allocate(Size,
alignof(ConstantExpr));
381 return new (Mem) ConstantExpr(
EmptyShell(), StorageKind);
386 "Invalid storage for this value kind");
392 Int64Result() = *
Value.getInt().getRawData();
399 Context.addDestruction(&APValueResult());
401 APValueResult() = std::move(
Value);
404 llvm_unreachable(
"Invalid ResultKind Bits");
410 return APValueResult().getInt();
415 llvm_unreachable(
"invalid Accessor");
423 return APValueResult();
433 llvm_unreachable(
"invalid ResultKind");
437 bool RefersToEnclosingVariableOrCapture,
QualType T,
447 RefersToEnclosingVariableOrCapture;
448 DeclRefExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter =
false;
455DeclRefExpr::DeclRefExpr(
const ASTContext &Ctx,
458 bool RefersToEnclosingVariableOrCapture,
467 new (getTrailingObjects<NestedNameSpecifierLoc>())
471 *getTrailingObjects<NamedDecl *>() = FoundD;
473 = (TemplateArgs || TemplateKWLoc.
isValid()) ? 1 : 0;
475 RefersToEnclosingVariableOrCapture;
476 DeclRefExprBits.CapturedByCopyInLambdaWithExplicitObjectParameter =
false;
479 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
480 TemplateKWLoc, *TemplateArgs,
481 getTrailingObjects<TemplateArgumentLoc>());
483 auto Deps = TemplateArgumentDependence::None;
485 Deps |= Loc.getArgument().getDependence();
486 assert(!(Deps & TemplateArgumentDependence::Dependent) &&
487 "built a DeclRefExpr with dependent template args");
489 }
else if (TemplateKWLoc.
isValid()) {
490 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
501 bool RefersToEnclosingVariableOrCapture,
506 return Create(Context, QualifierLoc, TemplateKWLoc, D,
507 RefersToEnclosingVariableOrCapture,
509 T,
VK, FoundD, TemplateArgs, NOUR);
515 bool RefersToEnclosingVariableOrCapture,
525 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
529 QualifierLoc ? 1 : 0, FoundD ? 1 : 0,
530 HasTemplateKWAndArgsInfo ? 1 : 0,
531 TemplateArgs ? TemplateArgs->
size() : 0);
533 void *Mem = Context.Allocate(Size,
alignof(DeclRefExpr));
534 return new (Mem) DeclRefExpr(Context, QualifierLoc, TemplateKWLoc, D,
535 RefersToEnclosingVariableOrCapture, NameInfo,
536 FoundD, TemplateArgs,
T,
VK, NOUR);
542 bool HasTemplateKWAndArgsInfo,
543 unsigned NumTemplateArgs) {
544 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
548 HasQualifier ? 1 : 0, HasFoundDecl ? 1 : 0, HasTemplateKWAndArgsInfo,
550 void *Mem = Context.Allocate(Size,
alignof(DeclRefExpr));
556 if (
getType()->isUndeducedType())
567SYCLUniqueStableNameExpr::SYCLUniqueStableNameExpr(
SourceLocation OpLoc,
573 OpLoc(OpLoc), LParen(LParen), RParen(RParen) {
574 setTypeSourceInfo(TSI);
578SYCLUniqueStableNameExpr::SYCLUniqueStableNameExpr(EmptyShell
Empty,
588 SYCLUniqueStableNameExpr(OpLoc, LParen, RParen, ResultTy, TSI);
594 return new (Ctx) SYCLUniqueStableNameExpr(
EmptyShell(), ResultTy);
606 if (
const auto *RD = dyn_cast<CXXRecordDecl>(ND))
607 return RD->getDeviceLambdaManglingNumber();
612 Context, Context.getDiagnostics(), MangleCallback)};
616 llvm::raw_string_ostream Out(Buffer);
617 Ctx->mangleCanonicalTypeName(Ty, Out);
627 assert((getIdentKind() == IK) &&
628 "IdentKind do not fit in PredefinedExprBitfields!");
629 bool HasFunctionName = SL !=
nullptr;
638PredefinedExpr::PredefinedExpr(EmptyShell
Empty,
bool HasFunctionName)
646 bool HasFunctionName = SL !=
nullptr;
647 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
648 alignof(PredefinedExpr));
649 return new (Mem) PredefinedExpr(L, FNTy, IK, IsTransparent, SL);
653 bool HasFunctionName) {
654 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(HasFunctionName),
655 alignof(PredefinedExpr));
656 return new (Mem) PredefinedExpr(
EmptyShell(), HasFunctionName);
664 return "__FUNCTION__";
666 return "__FUNCDNAME__";
668 return "L__FUNCTION__";
670 return "__PRETTY_FUNCTION__";
672 return "__FUNCSIG__";
674 return "L__FUNCSIG__";
678 llvm_unreachable(
"Unknown ident kind for PredefinedExpr");
684 const Decl *CurrentDecl,
685 bool ForceElaboratedPrinting) {
689 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(CurrentDecl)) {
690 std::unique_ptr<MangleContext> MC;
691 MC.reset(Context.createMangleContext());
693 if (MC->shouldMangleDeclName(ND)) {
695 llvm::raw_svector_ostream Out(Buffer);
701 else if (
auto FD = dyn_cast<FunctionDecl>(ND)) {
705 MC->mangleName(GD, Out);
707 if (!Buffer.empty() && Buffer.front() ==
'\01')
708 return std::string(Buffer.substr(1));
709 return std::string(Buffer);
711 return std::string(ND->getIdentifier()->getName());
720 if (DC->isFileContext())
724 llvm::raw_svector_ostream Out(Buffer);
725 if (
auto *DCBlock = dyn_cast<BlockDecl>(DC))
728 else if (
auto *DCDecl = dyn_cast<Decl>(DC))
730 return std::string(Out.str());
732 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
733 const auto &LO = Context.getLangOpts();
734 bool IsFuncOrFunctionInNonMSVCCompatEnv =
736 IK == PredefinedIdentKind ::Function) &&
738 bool IsLFunctionInMSVCCommpatEnv =
740 bool IsFuncOrFunctionOrLFunctionOrFuncDName =
745 if ((ForceElaboratedPrinting &&
746 (IsFuncOrFunctionInNonMSVCCompatEnv || IsLFunctionInMSVCCommpatEnv)) ||
747 (!ForceElaboratedPrinting && IsFuncOrFunctionOrLFunctionOrFuncDName))
748 return FD->getNameAsString();
751 llvm::raw_svector_ostream Out(Name);
756 if (MD->isStatic() && !ForceElaboratedPrinting)
763 std::string remapPath(StringRef Path)
const override {
766 return std::string(p);
773 PrettyCallbacks PrettyCB(Context.getLangOpts());
778 llvm::raw_string_ostream POut(Proto);
787 const Type *Ty =
Decl->getType().getTypePtrOrNull();
793 if (FD->hasWrittenPrototype())
794 FT = dyn_cast<FunctionProtoType>(AFT);
799 case CC_C: POut <<
"__cdecl ";
break;
810 FD->printQualifiedName(POut, Policy);
814 return std::string(Name);
819 for (
unsigned i = 0, e =
Decl->getNumParams(); i != e; ++i) {
821 POut <<
Decl->getParamDecl(i)->getType().stream(Policy);
824 if (FT->isVariadic()) {
825 if (FD->getNumParams()) POut <<
", ";
829 !Context.getLangOpts().CPlusPlus) &&
830 !
Decl->getNumParams()) {
837 assert(FT &&
"We must have a written prototype in this case.");
840 if (FT->isVolatile())
852 while (isa_and_nonnull<NamedDecl>(Ctx)) {
854 = dyn_cast<ClassTemplateSpecializationDecl>(Ctx);
856 Specs.push_back(Spec);
860 std::string TemplateParams;
861 llvm::raw_string_ostream TOut(TemplateParams);
864 D->getSpecializedTemplate()->getTemplateParameters();
866 assert(Params->
size() == Args.
size());
867 for (
unsigned i = 0, numParams = Params->
size(); i != numParams; ++i) {
869 if (Param.empty())
continue;
870 TOut << Param <<
" = ";
879 = FD->getTemplateSpecializationInfo();
884 assert(Params->
size() == Args->
size());
885 for (
unsigned i = 0, e = Params->
size(); i != e; ++i) {
887 if (Param.empty())
continue;
888 TOut << Param <<
" = ";
889 Args->
get(i).
print(Policy, TOut,
true);
894 if (!TemplateParams.empty()) {
896 TemplateParams.resize(TemplateParams.size() - 2);
897 POut <<
" [" << TemplateParams <<
"]";
905 Proto =
"auto " + Proto;
906 else if (FT && FT->getReturnType()->getAs<DecltypeType>())
908 ->getAs<DecltypeType>()
916 return std::string(Name);
918 if (
const CapturedDecl *CD = dyn_cast<CapturedDecl>(CurrentDecl)) {
922 if (DC->isFunctionOrMethod() && (DC->getDeclKind() != Decl::Captured)) {
926 llvm_unreachable(
"CapturedDecl not inside a function or method");
928 if (
const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(CurrentDecl)) {
930 llvm::raw_svector_ostream Out(Name);
931 Out << (MD->isInstanceMethod() ?
'-' :
'+');
940 dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext()))
941 Out <<
'(' << *CID <<
')';
944 MD->getSelector().print(Out);
947 return std::string(Name);
958 const llvm::APInt &Val) {
963 unsigned NumWords = Val.getNumWords();
964 const uint64_t* Words = Val.getRawData();
966 pVal =
new (
C) uint64_t[NumWords];
967 std::copy(Words, Words + NumWords,
pVal);
968 }
else if (NumWords == 1)
974IntegerLiteral::IntegerLiteral(
const ASTContext &
C,
const llvm::APInt &
V,
977 assert(
type->isIntegerType() &&
"Illegal type in IntegerLiteral");
978 assert(
V.getBitWidth() ==
C.getIntWidth(
type) &&
979 "Integer type is not the correct size for constant.");
987 return new (
C) IntegerLiteral(
C,
V,
type, l);
992 return new (
C) IntegerLiteral(
Empty);
995FixedPointLiteral::FixedPointLiteral(
const ASTContext &
C,
const llvm::APInt &
V,
1000 assert(
type->isFixedPointType() &&
"Illegal type in FixedPointLiteral");
1001 assert(
V.getBitWidth() ==
C.getTypeInfo(
type).Width &&
1002 "Fixed point type is not the correct size for constant.");
1008 const llvm::APInt &
V,
1012 return new (
C) FixedPointLiteral(
C,
V,
type, l, Scale);
1017 return new (
C) FixedPointLiteral(
Empty);
1026 S, llvm::APSInt::getUnsigned(
getValue().getZExtValue()), Scale);
1027 return std::string(S);
1050 if (!Escaped.empty()) {
1051 OS <<
"'" << Escaped <<
"'";
1060 OS <<
"'" << (char)Val <<
"'";
1062 OS <<
"'\\x" << llvm::format(
"%02x", Val) <<
"'";
1063 else if (Val <= 0xFFFF)
1064 OS <<
"'\\u" << llvm::format(
"%04x", Val) <<
"'";
1066 OS <<
"'\\U" << llvm::format(
"%08x", Val) <<
"'";
1070FloatingLiteral::FloatingLiteral(
const ASTContext &
C,
const llvm::APFloat &
V,
1073 setSemantics(
V.getSemantics());
1081 setRawSemantics(llvm::APFloatBase::S_IEEEhalf);
1088 return new (
C) FloatingLiteral(
C,
V, isexact,
Type, L);
1093 return new (
C) FloatingLiteral(
C,
Empty);
1102 V.convert(llvm::APFloat::IEEEdouble(), llvm::APFloat::rmNearestTiesToEven,
1104 return V.convertToDouble();
1109 unsigned CharByteWidth = 0;
1114 CharByteWidth =
Target.getCharWidth();
1117 CharByteWidth =
Target.getWCharWidth();
1120 CharByteWidth =
Target.getChar16Width();
1123 CharByteWidth =
Target.getChar32Width();
1126 return sizeof(char);
1128 assert((CharByteWidth & 7) == 0 &&
"Assumes character size is byte multiple");
1130 assert((CharByteWidth == 1 || CharByteWidth == 2 || CharByteWidth == 4) &&
1131 "The only supported character byte widths are 1,2 and 4!");
1132 return CharByteWidth;
1135StringLiteral::StringLiteral(
const ASTContext &Ctx, StringRef Str,
1140 unsigned Length = Str.size();
1147 "StringLiteral must be of constant array type!");
1148 unsigned CharByteWidth = mapCharByteWidth(Ctx.
getTargetInfo(), Kind);
1149 unsigned ByteLength = Str.size();
1150 assert((ByteLength % CharByteWidth == 0) &&
1151 "The size of the data must be a multiple of CharByteWidth!");
1156 switch (CharByteWidth) {
1158 Length = ByteLength;
1161 Length = ByteLength / 2;
1164 Length = ByteLength / 4;
1167 llvm_unreachable(
"Unsupported character width!");
1173 assert(!Pascal &&
"Can't make an unevaluated Pascal string");
1178 *getTrailingObjects<unsigned>() = Length;
1182 llvm::copy(Locs, getTrailingObjects<SourceLocation>());
1185 llvm::copy(Str, getTrailingObjects<char>());
1190StringLiteral::StringLiteral(EmptyShell
Empty,
unsigned NumConcatenated,
1191 unsigned Length,
unsigned CharByteWidth)
1195 *getTrailingObjects<unsigned>() = Length;
1202 void *Mem = Ctx.
Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
1203 1, Locs.size(), Str.size()),
1204 alignof(StringLiteral));
1205 return new (Mem) StringLiteral(Ctx, Str, Kind, Pascal, Ty, Locs);
1209 unsigned NumConcatenated,
1211 unsigned CharByteWidth) {
1212 void *Mem = Ctx.
Allocate(totalSizeToAlloc<unsigned, SourceLocation, char>(
1213 1, NumConcatenated, Length * CharByteWidth),
1214 alignof(StringLiteral));
1216 StringLiteral(
EmptyShell(), NumConcatenated, Length, CharByteWidth);
1239 static const char Hex[] =
"0123456789ABCDEF";
1242 for (
unsigned I = 0, N =
getLength(); I != N; ++I) {
1245 if (Escaped.empty()) {
1251 Char >= 0xd800 && Char <= 0xdbff) {
1253 if (Trail >= 0xdc00 && Trail <= 0xdfff) {
1254 Char = 0x10000 + ((Char - 0xd800) << 10) + (Trail - 0xdc00);
1264 (Char >= 0xd800 && Char <= 0xdfff) || Char >= 0x110000) {
1268 while ((Char >> Shift) == 0)
1270 for (; Shift >= 0; Shift -= 4)
1271 OS << Hex[(Char >> Shift) & 15];
1278 << Hex[(Char >> 20) & 15]
1279 << Hex[(Char >> 16) & 15];
1282 OS << Hex[(Char >> 12) & 15]
1283 << Hex[(Char >> 8) & 15]
1284 << Hex[(Char >> 4) & 15]
1285 << Hex[(Char >> 0) & 15];
1291 if (LastSlashX + 1 == I) {
1293 case '0':
case '1':
case '2':
case '3':
case '4':
1294 case '5':
case '6':
case '7':
case '8':
case '9':
1295 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
1296 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
1301 assert(Char <= 0xff &&
1302 "Characters above 0xff should already have been handled.");
1308 << (char)(
'0' + ((Char >> 6) & 7))
1309 << (char)(
'0' + ((Char >> 3) & 7))
1310 << (char)(
'0' + ((Char >> 0) & 7));
1339 unsigned *StartTokenByteOffset)
const {
1348 "Only narrow string literals are currently supported");
1353 unsigned StringOffset = 0;
1355 TokNo = *StartToken;
1356 if (StartTokenByteOffset) {
1357 StringOffset = *StartTokenByteOffset;
1358 ByteNo -= StringOffset;
1374 if (StartTokenByteOffset !=
nullptr)
1375 *StartTokenByteOffset = StringOffset;
1376 if (StartToken !=
nullptr)
1377 *StartToken = TokNo;
1378 return StrTokSpellingLoc;
1381 const char *StrData = Buffer.data()+LocInfo.second;
1385 Buffer.begin(), StrData, Buffer.end());
1394 if (ByteNo < TokNumBytes ||
1400 if (StartTokenByteOffset !=
nullptr)
1401 *StartTokenByteOffset = StringOffset;
1402 if (StartToken !=
nullptr)
1403 *StartToken = TokNo;
1408 StringOffset += TokNumBytes;
1410 ByteNo -= TokNumBytes;
1416 if (StartIndex > Length)
1417 return std::nullopt;
1420 StringRef::size_type Pos =
getString().substr(StartIndex).find(
'\0');
1421 if (Pos == StringRef::npos)
1422 return Length - StartIndex;
1427 for (
unsigned I = StartIndex; I != Length; ++I) {
1440#define UNARY_OPERATION(Name, Spelling) case UO_##Name: return Spelling;
1441#include "clang/AST/OperationKinds.def"
1443 llvm_unreachable(
"Unknown unary operator");
1449 default: llvm_unreachable(
"No unary operator for overloaded function");
1450 case OO_PlusPlus:
return Postfix ? UO_PostInc : UO_PreInc;
1451 case OO_MinusMinus:
return Postfix ? UO_PostDec : UO_PreDec;
1452 case OO_Amp:
return UO_AddrOf;
1453 case OO_Star:
return UO_Deref;
1454 case OO_Plus:
return UO_Plus;
1455 case OO_Minus:
return UO_Minus;
1456 case OO_Tilde:
return UO_Not;
1457 case OO_Exclaim:
return UO_LNot;
1458 case OO_Coawait:
return UO_Coawait;
1464 case UO_PostInc:
case UO_PreInc:
return OO_PlusPlus;
1465 case UO_PostDec:
case UO_PreDec:
return OO_MinusMinus;
1466 case UO_AddrOf:
return OO_Amp;
1467 case UO_Deref:
return OO_Star;
1468 case UO_Plus:
return OO_Plus;
1469 case UO_Minus:
return OO_Minus;
1470 case UO_Not:
return OO_Tilde;
1471 case UO_LNot:
return OO_Exclaim;
1472 case UO_Coawait:
return OO_Coawait;
1484 case Expr::CallExprClass:
1486 case Expr::CXXOperatorCallExprClass:
1488 case Expr::CXXMemberCallExprClass:
1490 case Expr::UserDefinedLiteralClass:
1492 case Expr::CUDAKernelCallExprClass:
1495 llvm_unreachable(
"unexpected class deriving from CallExpr!");
1503 "we assume CXXOperatorCallExpr is at most 32 bytes");
1510 NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1511 unsigned NumPreArgs = PreArgs.size();
1513 assert((NumPreArgs ==
getNumPreArgs()) &&
"NumPreArgs overflow!");
1515 "This CallExpr subclass is too big or unsupported");
1520 for (
unsigned I = 0; I != NumPreArgs; ++I)
1522 for (
unsigned I = 0; I != Args.size(); ++I)
1524 for (
unsigned I = Args.size(); I != NumArgs; ++I)
1531 CallExprBits.ExplicitObjectMemFunUsingMemberSyntax =
false;
1542 assert((NumPreArgs ==
getNumPreArgs()) &&
"NumPreArgs overflow!");
1545 CallExprBits.ExplicitObjectMemFunUsingMemberSyntax =
false;
1554 unsigned NumArgs = std::max<unsigned>(Args.size(), MinNumArgs);
1561 new (Mem)
CallExpr(CallExprClass, Fn, {}, Args, Ty,
VK,
1562 RParenLoc, FPFeatures, MinNumArgs,
UsesADL);
1563 E->updateTrailingSourceLoc();
1569 unsigned SizeOfTrailingObjects =
1585 if (
auto *DRE = dyn_cast<DeclRefExpr>(CEE))
1586 return DRE->getDecl();
1588 if (
auto *ME = dyn_cast<MemberExpr>(CEE))
1589 return ME->getMemberDecl();
1593 while (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE))
1598 if (
auto *BO = dyn_cast<BinaryOperator>(CEE)) {
1599 if (BO->isPtrMemOp()) {
1603 }
else if (
auto *UO = dyn_cast<UnaryOperator>(CEE)) {
1604 if (UO->getOpcode() == UO_Deref || UO->getOpcode() == UO_AddrOf ||
1605 UO->getOpcode() == UO_Plus) {
1613 if (
auto *DRE = dyn_cast<DeclRefExpr>(CEE))
1614 return DRE->getDecl();
1615 if (
auto *ME = dyn_cast<MemberExpr>(CEE))
1616 return ME->getMemberDecl();
1617 if (
auto *BE = dyn_cast<BlockExpr>(CEE))
1618 return BE->getBlockDecl();
1626 return FDecl ? FDecl->getBuiltinID() : 0;
1637 QualType CalleeType = Callee->getType();
1651 assert(!CalleeType.
isNull());
1667std::pair<const NamedDecl *, const WarnUnusedResultAttr *>
1670 if (Callee !=
nullptr)
1671 if (
const auto *A = Callee->getAttr<WarnUnusedResultAttr>())
1672 return {
nullptr, A};
1677 if (
const auto *A = TD->getAttr<WarnUnusedResultAttr>())
1682 if (
const auto *A = TD->getDecl()->getAttr<WarnUnusedResultAttr>())
1683 return {TD->getDecl(), A};
1684 return {
nullptr,
nullptr};
1693 void *Mem =
C.Allocate(
1694 totalSizeToAlloc<OffsetOfNode, Expr *>(comps.size(), exprs.size()));
1696 return new (Mem) OffsetOfExpr(
C,
type, OperatorLoc, tsi, comps, exprs,
1701 unsigned numComps,
unsigned numExprs) {
1703 C.Allocate(totalSizeToAlloc<OffsetOfNode, Expr *>(numComps, numExprs));
1704 return new (Mem) OffsetOfExpr(numComps, numExprs);
1712 OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
1713 NumComps(comps.size()), NumExprs(exprs.size()) {
1714 for (
unsigned i = 0; i != comps.size(); ++i)
1716 for (
unsigned i = 0; i != exprs.size(); ++i)
1731 UnaryExprOrTypeTrait ExprKind,
Expr *E,
QualType resultType,
1734 OpLoc(op), RParenLoc(rp) {
1735 assert(ExprKind <= UETT_Last &&
"invalid enum value!");
1738 "UnaryExprOrTypeTraitExprBits.Kind overflow!");
1752 :
Expr(MemberExprClass,
T,
VK, OK),
Base(
Base), MemberDecl(MemberDecl),
1753 MemberDNLoc(NameInfo.
getInfo()), MemberLoc(NameInfo.getLoc()) {
1759 FoundDecl.
getDecl() != MemberDecl ||
1762 TemplateArgs || TemplateKWLoc.
isValid();
1768 new (getTrailingObjects<NestedNameSpecifierLoc>())
1771 *getTrailingObjects<DeclAccessPair>() = FoundDecl;
1773 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1774 TemplateKWLoc, *TemplateArgs,
1775 getTrailingObjects<TemplateArgumentLoc>());
1776 }
else if (TemplateKWLoc.
isValid()) {
1777 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1790 bool HasFoundDecl = FoundDecl.
getDecl() != MemberDecl ||
1791 FoundDecl.
getAccess() != MemberDecl->getAccess();
1792 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
1796 HasQualifier, HasFoundDecl, HasTemplateKWAndArgsInfo,
1797 TemplateArgs ? TemplateArgs->
size() : 0);
1799 void *Mem =
C.Allocate(Size,
alignof(MemberExpr));
1800 return new (Mem) MemberExpr(Base, IsArrow, OperatorLoc, QualifierLoc,
1801 TemplateKWLoc, MemberDecl, FoundDecl, NameInfo,
1802 TemplateArgs,
T,
VK, OK, NOUR);
1806 bool HasQualifier,
bool HasFoundDecl,
1807 bool HasTemplateKWAndArgsInfo,
1808 unsigned NumTemplateArgs) {
1809 assert((!NumTemplateArgs || HasTemplateKWAndArgsInfo) &&
1810 "template args but no template arg info?");
1814 HasQualifier, HasFoundDecl, HasTemplateKWAndArgsInfo,
1816 void *Mem = Context.Allocate(Size,
alignof(MemberExpr));
1822 if (
getType()->isUndeducedType())
1838 return BaseStartLoc;
1850bool CastExpr::CastConsistency()
const {
1852 case CK_DerivedToBase:
1853 case CK_UncheckedDerivedToBase:
1854 case CK_DerivedToBaseMemberPointer:
1855 case CK_BaseToDerived:
1856 case CK_BaseToDerivedMemberPointer:
1857 assert(!
path_empty() &&
"Cast kind should have a base path!");
1860 case CK_CPointerToObjCPointerCast:
1861 assert(
getType()->isObjCObjectPointerType());
1863 goto CheckNoBasePath;
1865 case CK_BlockPointerToObjCPointerCast:
1866 assert(
getType()->isObjCObjectPointerType());
1868 goto CheckNoBasePath;
1870 case CK_ReinterpretMemberPointer:
1871 assert(
getType()->isMemberPointerType());
1873 goto CheckNoBasePath;
1879 if (!
getType()->isPointerType()) {
1880 assert(
getType()->isObjCObjectPointerType() ==
1882 assert(
getType()->isBlockPointerType() ==
1885 goto CheckNoBasePath;
1887 case CK_AnyPointerToBlockPointerCast:
1888 assert(
getType()->isBlockPointerType());
1891 goto CheckNoBasePath;
1893 case CK_CopyAndAutoreleaseBlockObject:
1894 assert(
getType()->isBlockPointerType());
1896 goto CheckNoBasePath;
1898 case CK_FunctionToPointerDecay:
1899 assert(
getType()->isPointerType());
1901 goto CheckNoBasePath;
1903 case CK_AddressSpaceConversion: {
1912 (!Ty.
isNull() && !SETy.isNull() &&
1914 goto CheckNoBasePath;
1919 case CK_ArrayToPointerDecay:
1920 case CK_NullToMemberPointer:
1921 case CK_NullToPointer:
1922 case CK_ConstructorConversion:
1923 case CK_IntegralToPointer:
1924 case CK_PointerToIntegral:
1926 case CK_VectorSplat:
1927 case CK_IntegralCast:
1928 case CK_BooleanToSignedIntegral:
1929 case CK_IntegralToFloating:
1930 case CK_FloatingToIntegral:
1931 case CK_FloatingCast:
1932 case CK_ObjCObjectLValueCast:
1933 case CK_FloatingRealToComplex:
1934 case CK_FloatingComplexToReal:
1935 case CK_FloatingComplexCast:
1936 case CK_FloatingComplexToIntegralComplex:
1937 case CK_IntegralRealToComplex:
1938 case CK_IntegralComplexToReal:
1939 case CK_IntegralComplexCast:
1940 case CK_IntegralComplexToFloatingComplex:
1941 case CK_ARCProduceObject:
1942 case CK_ARCConsumeObject:
1943 case CK_ARCReclaimReturnedObject:
1944 case CK_ARCExtendBlockObject:
1945 case CK_ZeroToOCLOpaqueType:
1946 case CK_IntToOCLSampler:
1947 case CK_FloatingToFixedPoint:
1948 case CK_FixedPointToFloating:
1949 case CK_FixedPointCast:
1950 case CK_FixedPointToIntegral:
1951 case CK_IntegralToFixedPoint:
1954 goto CheckNoBasePath;
1957 case CK_LValueToRValue:
1959 case CK_AtomicToNonAtomic:
1960 case CK_NonAtomicToAtomic:
1961 case CK_PointerToBoolean:
1962 case CK_IntegralToBoolean:
1963 case CK_FloatingToBoolean:
1964 case CK_MemberPointerToBoolean:
1965 case CK_FloatingComplexToBoolean:
1966 case CK_IntegralComplexToBoolean:
1967 case CK_LValueBitCast:
1968 case CK_LValueToRValueBitCast:
1969 case CK_UserDefinedConversion:
1970 case CK_BuiltinFnToFnPtr:
1971 case CK_FixedPointToBoolean:
1972 case CK_HLSLArrayRValue:
1973 case CK_HLSLVectorTruncation:
1974 case CK_HLSLMatrixTruncation:
1975 case CK_HLSLElementwiseCast:
1976 case CK_HLSLAggregateSplatCast:
1978 assert(
path_empty() &&
"Cast kind should not have a base path!");
1986#define CAST_OPERATION(Name) case CK_##Name: return #Name;
1987#include "clang/AST/OperationKinds.def"
1989 llvm_unreachable(
"Unhandled cast kind!");
1995static Expr *ignoreImplicitSemaNodes(
Expr *E) {
1996 if (
auto *Materialize = dyn_cast<MaterializeTemporaryExpr>(E))
1997 return Materialize->getSubExpr();
1999 if (
auto *Binder = dyn_cast<CXXBindTemporaryExpr>(E))
2000 return Binder->getSubExpr();
2002 if (
auto *
Full = dyn_cast<FullExpr>(E))
2003 return Full->getSubExpr();
2005 if (
auto *CPLIE = dyn_cast<CXXParenListInitExpr>(E);
2006 CPLIE && CPLIE->getInitExprs().size() == 1)
2007 return CPLIE->getInitExprs()[0];
2014 const Expr *SubExpr =
nullptr;
2016 for (
const CastExpr *E =
this; E; E = dyn_cast<ImplicitCastExpr>(SubExpr)) {
2021 if (E->getCastKind() == CK_ConstructorConversion) {
2023 ignoreImplicitSemaNodes);
2024 }
else if (E->getCastKind() == CK_UserDefinedConversion) {
2026 "Unexpected SubExpr for CK_UserDefinedConversion.");
2027 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
2028 SubExpr = MCE->getImplicitObjectArgument();
2032 return const_cast<Expr *
>(SubExpr);
2036 const Expr *SubExpr =
nullptr;
2038 for (
const CastExpr *E =
this; E; E = dyn_cast<ImplicitCastExpr>(SubExpr)) {
2041 if (E->getCastKind() == CK_ConstructorConversion)
2044 if (E->getCastKind() == CK_UserDefinedConversion) {
2045 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr))
2046 return MCE->getMethodDecl();
2055#define ABSTRACT_STMT(x)
2056#define CASTEXPR(Type, Base) \
2057 case Stmt::Type##Class: \
2058 return static_cast<Type *>(this) \
2059 ->getTrailingObjectsNonStrict<CXXBaseSpecifier *>();
2060#define STMT(Type, Base)
2061#include "clang/AST/StmtNodes.inc"
2063 llvm_unreachable(
"non-cast expressions not possible here");
2077 Field != FieldEnd; ++Field) {
2079 !Field->isUnnamedBitField()) {
2089 case ImplicitCastExprClass:
2091 ->getTrailingObjects<FPOptionsOverride>();
2092 case CStyleCastExprClass:
2094 ->getTrailingObjects<FPOptionsOverride>();
2095 case CXXFunctionalCastExprClass:
2097 ->getTrailingObjects<FPOptionsOverride>();
2098 case CXXStaticCastExprClass:
2100 ->getTrailingObjects<FPOptionsOverride>();
2102 llvm_unreachable(
"Cast does not have FPFeatures");
2111 unsigned PathSize = (BasePath ? BasePath->size() : 0);
2113 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
2117 assert((Kind != CK_LValueToRValue ||
2118 !(
T->isNullPtrType() ||
2119 (
T->getAsCXXRecordDecl() && !
C.getLangOpts().HLSL))) &&
2120 "invalid type for lvalue-to-rvalue conversion");
2121 ImplicitCastExpr *E =
2122 new (Buffer) ImplicitCastExpr(
T, Kind, Operand, PathSize, FPO,
VK);
2124 llvm::uninitialized_copy(*BasePath,
2131 bool HasFPFeatures) {
2133 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
2134 PathSize, HasFPFeatures));
2135 return new (Buffer) ImplicitCastExpr(
EmptyShell(), PathSize, HasFPFeatures);
2144 unsigned PathSize = (BasePath ? BasePath->size() : 0);
2146 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
2149 new (Buffer) CStyleCastExpr(
T,
VK, K, Op, PathSize, FPO, WrittenTy, L, R);
2151 llvm::uninitialized_copy(*BasePath,
2158 bool HasFPFeatures) {
2160 C.Allocate(totalSizeToAlloc<CXXBaseSpecifier *, FPOptionsOverride>(
2161 PathSize, HasFPFeatures));
2162 return new (Buffer) CStyleCastExpr(
EmptyShell(), PathSize, HasFPFeatures);
2169#define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling;
2170#include "clang/AST/OperationKinds.def"
2172 llvm_unreachable(
"Invalid OpCode!");
2178 default: llvm_unreachable(
"Not an overloadable binary operator");
2179 case OO_Plus:
return BO_Add;
2180 case OO_Minus:
return BO_Sub;
2181 case OO_Star:
return BO_Mul;
2182 case OO_Slash:
return BO_Div;
2183 case OO_Percent:
return BO_Rem;
2184 case OO_Caret:
return BO_Xor;
2185 case OO_Amp:
return BO_And;
2186 case OO_Pipe:
return BO_Or;
2187 case OO_Equal:
return BO_Assign;
2188 case OO_Spaceship:
return BO_Cmp;
2189 case OO_Less:
return BO_LT;
2190 case OO_Greater:
return BO_GT;
2191 case OO_PlusEqual:
return BO_AddAssign;
2192 case OO_MinusEqual:
return BO_SubAssign;
2193 case OO_StarEqual:
return BO_MulAssign;
2194 case OO_SlashEqual:
return BO_DivAssign;
2195 case OO_PercentEqual:
return BO_RemAssign;
2196 case OO_CaretEqual:
return BO_XorAssign;
2197 case OO_AmpEqual:
return BO_AndAssign;
2198 case OO_PipeEqual:
return BO_OrAssign;
2199 case OO_LessLess:
return BO_Shl;
2200 case OO_GreaterGreater:
return BO_Shr;
2201 case OO_LessLessEqual:
return BO_ShlAssign;
2202 case OO_GreaterGreaterEqual:
return BO_ShrAssign;
2203 case OO_EqualEqual:
return BO_EQ;
2204 case OO_ExclaimEqual:
return BO_NE;
2205 case OO_LessEqual:
return BO_LE;
2206 case OO_GreaterEqual:
return BO_GE;
2207 case OO_AmpAmp:
return BO_LAnd;
2208 case OO_PipePipe:
return BO_LOr;
2209 case OO_Comma:
return BO_Comma;
2210 case OO_ArrowStar:
return BO_PtrMemI;
2217 OO_Star, OO_Slash, OO_Percent,
2219 OO_LessLess, OO_GreaterGreater,
2221 OO_Less, OO_Greater, OO_LessEqual, OO_GreaterEqual,
2222 OO_EqualEqual, OO_ExclaimEqual,
2228 OO_Equal, OO_StarEqual,
2229 OO_SlashEqual, OO_PercentEqual,
2230 OO_PlusEqual, OO_MinusEqual,
2231 OO_LessLessEqual, OO_GreaterGreaterEqual,
2232 OO_AmpEqual, OO_CaretEqual,
2236 return OverOps[Opc];
2248 if (LHS->getType()->isPointerType()) {
2249 if (!RHS->getType()->isIntegerType())
2252 }
else if (RHS->getType()->isPointerType()) {
2253 if (!LHS->getType()->isIntegerType())
2265 if (!Select->getCond()->EvaluateAsBooleanCondition(
EvalResult, Ctx))
2267 PExp =
EvalResult ? Select->getTrueExpr() : Select->getFalseExpr();
2288 BuiltinLoc(BLoc), RParenLoc(RParenLoc), ParentContext(ParentContext) {
2292 ? ExprDependence::ValueInstantiation
2293 : ExprDependence::None);
2299 return "__builtin_FILE";
2301 return "__builtin_FILE_NAME";
2303 return "__builtin_FUNCTION";
2305 return "__builtin_FUNCSIG";
2307 return "__builtin_LINE";
2309 return "__builtin_COLUMN";
2311 return "__builtin_source_location";
2313 llvm_unreachable(
"unexpected IdentKind!");
2317 const Expr *DefaultExpr)
const {
2321 if (
const auto *DIE = dyn_cast_if_present<CXXDefaultInitExpr>(DefaultExpr)) {
2322 Loc = DIE->getUsedLocation();
2323 Context = DIE->getUsedContext();
2324 }
else if (
const auto *DAE =
2325 dyn_cast_if_present<CXXDefaultArgExpr>(DefaultExpr)) {
2326 Loc = DAE->getUsedLocation();
2327 Context = DAE->getUsedContext();
2338 if (
const auto *D = dyn_cast<CXXMethodDecl>(Context);
2340 Context = D->getParent()->getParent();
2345 auto MakeStringLiteral = [&](StringRef Tmp) {
2349 LValuePathEntry Path[1] = {LValuePathEntry::ArrayIndex(0)};
2360 return MakeStringLiteral(
FileName);
2366 return MakeStringLiteral(Path);
2370 const auto *CurDecl = dyn_cast<Decl>(Context);
2374 return MakeStringLiteral(
2394 StringRef Name = F->getName();
2395 if (Name ==
"_M_file_name") {
2399 Value.getStructField(F->getFieldIndex()) = MakeStringLiteral(Path);
2400 }
else if (Name ==
"_M_function_name") {
2403 const auto *CurDecl = dyn_cast<Decl>(Context);
2404 Value.getStructField(F->getFieldIndex()) = MakeStringLiteral(
2409 }
else if (Name ==
"_M_line") {
2411 Value.getStructField(F->getFieldIndex()) =
APValue(IntVal);
2412 }
else if (Name ==
"_M_column") {
2414 Value.getStructField(F->getFieldIndex()) =
APValue(IntVal);
2425 llvm_unreachable(
"unhandled case");
2430 unsigned NumOfElements)
2432 EmbedKeywordLoc(Loc), Ctx(&Ctx), Data(Data), Begin(Begin),
2433 NumOfElements(NumOfElements) {
2436 Ctx, llvm::APInt::getZero(Ctx.getTypeSize(
getType())),
getType(), Loc);
2437 assert(
getType()->isSignedIntegerType() &&
"IntTy should be signed");
2444 InitExprs(
C, initExprs.size()), LBraceLoc(lbraceloc),
2447 InitExprs.insert(
C, InitExprs.end(), initExprs.begin(), initExprs.end());
2454 if (NumInits > InitExprs.size())
2455 InitExprs.reserve(
C, NumInits);
2459 InitExprs.resize(
C, NumInits,
nullptr);
2463 if (
Init >= InitExprs.size()) {
2464 InitExprs.insert(
C, InitExprs.end(),
Init - InitExprs.size() + 1,
nullptr);
2476 ArrayFillerOrUnionFieldInit = filler;
2479 for (
unsigned i = 0, e =
getNumInits(); i != e; ++i)
2480 if (
inits[i] ==
nullptr)
2494 Init =
Init->IgnoreParenImpCasts();
2499 assert(
isSemanticForm() &&
"syntactic form never semantically transparent");
2503 assert(
getNumInits() == 1 &&
"multiple inits in glvalue init list");
2522 assert(
isSyntacticForm() &&
"only test syntactic form as zero initializer");
2529 return Lit && Lit->
getValue() == 0;
2534 return SyntacticForm->getBeginLoc();
2539 E = InitExprs.end();
2542 Beg = S->getBeginLoc();
2552 return SyntacticForm->getEndLoc();
2556 for (
Stmt *S : llvm::reverse(InitExprs)) {
2558 End = S->getEndLoc();
2575 return TheBlock->getCaretLocation();
2594 const auto *Ref = dyn_cast<DeclRefExpr>(Unwrapped);
2598 return isa_and_nonnull<DecompositionDecl>(Ref->getDecl());
2625 if (
auto *UO = dyn_cast<UnaryOperator>(E))
2626 if (UO->getOpcode() == UO_Deref)
2629 if (
auto *BO = dyn_cast<BinaryOperator>(E)) {
2631 if (BO->isPtrMemOp())
2635 if (BO->getOpcode() == BO_Comma)
2636 return BO->getRHS()->isReadIfDiscardedInCPlusPlus11();
2641 if (
auto *CO = dyn_cast<ConditionalOperator>(E))
2642 return CO->getTrueExpr()->isReadIfDiscardedInCPlusPlus11() &&
2643 CO->getFalseExpr()->isReadIfDiscardedInCPlusPlus11();
2646 dyn_cast<BinaryConditionalOperator>(E)) {
2647 if (
auto *OVE = dyn_cast<OpaqueValueExpr>(BCO->getTrueExpr()))
2648 return OVE->getSourceExpr()->isReadIfDiscardedInCPlusPlus11() &&
2649 BCO->getFalseExpr()->isReadIfDiscardedInCPlusPlus11();
2655 if (
const auto *POE = dyn_cast<PseudoObjectExpr>(E)) {
2683 case ParenExprClass:
2686 case GenericSelectionExprClass:
2689 case CoawaitExprClass:
2690 case CoyieldExprClass:
2693 case ChooseExprClass:
2696 case UnaryOperatorClass: {
2730 case BinaryOperatorClass: {
2742 if (IE->getValue() == 0)
2761 case CompoundAssignOperatorClass:
2762 case VAArgExprClass:
2763 case AtomicExprClass:
2766 case ConditionalOperatorClass: {
2771 return Exp->getLHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx) &&
2772 Exp->getRHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2774 case BinaryConditionalOperatorClass: {
2776 return Exp->getFalseExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2779 case MemberExprClass:
2786 case ArraySubscriptExprClass:
2793 case CXXOperatorCallExprClass: {
2805 case OO_ExclaimEqual:
2808 case OO_GreaterEqual:
2823 case CXXMemberCallExprClass:
2824 case UserDefinedLiteralClass: {
2848 case UnresolvedLookupExprClass:
2849 case CXXUnresolvedConstructExprClass:
2850 case RecoveryExprClass:
2853 case CXXTemporaryObjectExprClass:
2854 case CXXConstructExprClass: {
2859 CE->hasUnusedResultAttr(Ctx)) {
2864 if (
unsigned NumArgs = CE->getNumArgs())
2866 CE->getArg(NumArgs - 1)->getEndLoc());
2872 case ObjCMessageExprClass: {
2893 case ObjCPropertyRefExprClass:
2894 case ObjCSubscriptRefExprClass:
2900 case PseudoObjectExprClass: {
2905 POE->getSyntacticForm())) {
2913 if (
auto *BO = dyn_cast<BinaryOperator>(POE->getSyntacticForm()))
2914 if (BO->isAssignmentOp())
2916 if (
auto *UO = dyn_cast<UnaryOperator>(POE->getSyntacticForm()))
2917 if (UO->isIncrementDecrementOp())
2922 return Result &&
Result->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2925 case StmtExprClass: {
2936 if (
const Expr *E = dyn_cast<Expr>(Label->getSubStmt()))
2947 case CXXFunctionalCastExprClass:
2948 case CStyleCastExprClass: {
2962 if (
auto *DRE = dyn_cast<DeclRefExpr>(SubE))
2963 if (
auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
2964 if (!VD->isExternallyVisible())
2980 if (CE->
getCastKind() == CK_ConstructorConversion)
2987 dyn_cast<CXXFunctionalCastExpr>(
this)) {
2988 Loc = CXXCE->getBeginLoc();
2989 R1 = CXXCE->getSubExpr()->getSourceRange();
2997 case ImplicitCastExprClass: {
3007 case CXXDefaultArgExprClass:
3010 case CXXDefaultInitExprClass:
3014 case CXXNewExprClass:
3017 case CXXDeleteExprClass:
3019 case MaterializeTemporaryExprClass:
3022 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
3023 case CXXBindTemporaryExprClass:
3025 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
3026 case ExprWithCleanupsClass:
3028 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
3029 case OpaqueValueExprClass:
3031 WarnE, Loc, R1, R2, Ctx);
3042 case ObjCIvarRefExprClass:
3044 case Expr::UnaryOperatorClass:
3046 case ImplicitCastExprClass:
3048 case MaterializeTemporaryExprClass:
3051 case CStyleCastExprClass:
3053 case DeclRefExprClass: {
3056 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
3057 if (VD->hasGlobalStorage())
3062 return T->isPointerType() &&
3067 case MemberExprClass: {
3071 case ArraySubscriptExprClass:
3083 assert(
expr->hasPlaceholderType(BuiltinType::BoundMember));
3092 return mem->getMemberDecl()->getType();
3098 assert(
type->isFunctionType());
3136 if (
auto *MCE = dyn_cast<CXXMemberCallExpr>(
this)) {
3137 if (isa_and_nonnull<CXXConversionDecl>(MCE->getMethodDecl()))
3138 return MCE->getImplicitObjectArgument();
3154 auto IgnoreNoopCastsSingleStep = [&Ctx](
Expr *E) {
3155 if (
auto *CE = dyn_cast<CastExpr>(E)) {
3158 Expr *SubExpr = CE->getSubExpr();
3159 bool IsIdentityCast =
3161 bool IsSameWidthCast = (E->
getType()->isPointerType() ||
3163 (SubExpr->
getType()->isPointerType() ||
3168 if (IsIdentityCast || IsSameWidthCast)
3170 }
else if (
auto *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(E))
3171 return NTTP->getReplacement();
3176 IgnoreNoopCastsSingleStep);
3181 if (
auto *Cast = dyn_cast<CXXFunctionalCastExpr>(E)) {
3182 auto *SE = Cast->getSubExpr();
3187 if (
auto *
C = dyn_cast<CXXConstructExpr>(E)) {
3188 auto NumArgs =
C->getNumArgs();
3191 Expr *A =
C->getArg(0);
3198 auto IgnoreImplicitMemberCallSingleStep = [](
Expr *E) {
3199 if (
auto *
C = dyn_cast<CXXMemberCallExpr>(E)) {
3200 Expr *ExprNode =
C->getImplicitObjectArgument();
3204 if (
auto *PE = dyn_cast<ParenExpr>(ExprNode)) {
3205 if (PE->getSourceRange() ==
C->getSourceRange()) {
3218 auto IgnoreImplicitCallSingleStep = [](
Expr *E) {
3219 auto *
C = dyn_cast<CallExpr>(E);
3226 unsigned NumArgs =
C->getNumArgs();
3230 Expr *A =
C->getArg(0);
3247 IgnoreImplicitMemberCallSingleStep, IgnoreImplicitCallSingleStep);
3251 const Expr *E =
this;
3253 E = M->getSubExpr();
3256 E = ICE->getSubExprAsWritten();
3265 E = M->getSubExpr();
3268 if (ICE->getCastKind() == CK_NoOp)
3269 E = ICE->getSubExpr();
3275 E = BE->getSubExpr();
3278 if (ICE->getCastKind() == CK_NoOp)
3279 E = ICE->getSubExpr();
3290 if (!
C.hasSameUnqualifiedType(
getType(),
C.getCanonicalTagType(TempTy)))
3306 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(E)) {
3307 switch (ICE->getCastKind()) {
3308 case CK_DerivedToBase:
3309 case CK_UncheckedDerivedToBase:
3320 if (
const auto *BO = dyn_cast<BinaryOperator>(E))
3321 if (BO->isPtrMemOp())
3332 const Expr *E =
this;
3337 E =
Paren->getSubExpr();
3342 if (ICE->getCastKind() == CK_NoOp ||
3343 ICE->getCastKind() == CK_LValueToRValue ||
3344 ICE->getCastKind() == CK_DerivedToBase ||
3345 ICE->getCastKind() == CK_UncheckedDerivedToBase) {
3346 E = ICE->getSubExpr();
3351 if (
const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) {
3352 if (UnOp->getOpcode() == UO_Extension) {
3353 E = UnOp->getSubExpr();
3359 = dyn_cast<MaterializeTemporaryExpr>(E)) {
3360 E = M->getSubExpr();
3368 return This->isImplicit();
3376 for (
unsigned I = 0; I < Exprs.size(); ++I)
3384 const Expr **Culprit)
const {
3386 "Expression evaluator can't be called on a dependent expression.");
3398 if (
auto *EWC = dyn_cast<ExprWithCleanups>(
this))
3399 return EWC->getSubExpr()->isConstantInitializer(Ctx,
true, Culprit);
3400 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(
this))
3401 return MTE->getSubExpr()->isConstantInitializer(Ctx,
false, Culprit);
3412 case Stmt::ExprWithCleanupsClass:
3414 Ctx, IsForRef, Culprit);
3415 case StringLiteralClass:
3416 case ObjCEncodeExprClass:
3418 case CXXTemporaryObjectExprClass:
3419 case CXXConstructExprClass: {
3428 assert(CE->
getNumArgs() == 1 &&
"trivial ctor with > 1 argument");
3434 case ConstantExprClass: {
3440 case CompoundLiteralExprClass: {
3447 case DesignatedInitUpdateExprClass: {
3452 case InitListExprClass: {
3460 assert(ILE->
isSemanticForm() &&
"InitListExpr must be in semantic form");
3467 for (
unsigned i = 0; i < numInits; i++) {
3475 unsigned ElementNo = 0;
3480 if (
const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
3481 for (
unsigned i = 0, e = CXXRD->getNumBases(); i < e; i++) {
3482 if (ElementNo < ILE->getNumInits()) {
3490 for (
const auto *Field : RD->fields()) {
3496 if (Field->isUnnamedBitField())
3499 if (ElementNo < ILE->getNumInits()) {
3501 if (Field->isBitField()) {
3510 bool RefType = Field->getType()->isReferenceType();
3521 case ImplicitValueInitExprClass:
3522 case NoInitExprClass:
3524 case ParenExprClass:
3526 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3527 case GenericSelectionExprClass:
3529 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3530 case ChooseExprClass:
3537 ->isConstantInitializer(Ctx, IsForRef, Culprit);
3538 case UnaryOperatorClass: {
3544 case ObjCBoxedExprClass: {
3550 case ObjCArrayLiteralClass: {
3556 case ObjCDictionaryLiteralClass: {
3562 case PackIndexingExprClass: {
3565 ->isConstantInitializer(Ctx,
false, Culprit);
3567 case CXXFunctionalCastExprClass:
3568 case CXXStaticCastExprClass:
3569 case ImplicitCastExprClass:
3570 case CStyleCastExprClass:
3571 case ObjCBridgedCastExprClass:
3572 case CXXDynamicCastExprClass:
3573 case CXXReinterpretCastExprClass:
3574 case CXXAddrspaceCastExprClass:
3575 case CXXConstCastExprClass: {
3586 CE->
getCastKind() == CK_ARCReclaimReturnedObject ||
3592 case MaterializeTemporaryExprClass:
3595 ->isConstantInitializer(Ctx,
false, Culprit);
3597 case SubstNonTypeTemplateParmExprClass:
3599 ->isConstantInitializer(Ctx,
false, Culprit);
3600 case CXXDefaultArgExprClass:
3602 ->isConstantInitializer(Ctx,
false, Culprit);
3603 case CXXDefaultInitExprClass:
3605 ->isConstantInitializer(Ctx,
false, Culprit);
3619 if (BuiltinID != Builtin::BI__assume &&
3620 BuiltinID != Builtin::BI__builtin_assume)
3631 return DirectCallee->getAttr<AllocSizeAttr>();
3633 return IndirectCallee->getAttr<AllocSizeAttr>();
3637std::optional<llvm::APInt>
3641 assert(AllocSize && AllocSize->getElemSizeParam().isValid());
3642 unsigned SizeArgNo = AllocSize->getElemSizeParam().getASTIndex();
3645 return std::nullopt;
3647 auto EvaluateAsSizeT = [&](
const Expr *E, llvm::APSInt &Into) {
3653 if (Into.isNegative() || !Into.isIntN(BitsInSizeT))
3655 Into = Into.extOrTrunc(BitsInSizeT);
3659 llvm::APSInt SizeOfElem;
3660 if (!EvaluateAsSizeT(
getArg(SizeArgNo), SizeOfElem))
3661 return std::nullopt;
3663 if (!AllocSize->getNumElemsParam().isValid())
3666 llvm::APSInt NumberOfElems;
3667 unsigned NumArgNo = AllocSize->getNumElemsParam().getASTIndex();
3668 if (!EvaluateAsSizeT(
getArg(NumArgNo), NumberOfElems))
3669 return std::nullopt;
3672 llvm::APInt BytesAvailable = SizeOfElem.umul_ov(NumberOfElems, Overflow);
3674 return std::nullopt;
3676 return BytesAvailable;
3687 const bool IncludePossibleEffects;
3688 bool HasSideEffects;
3691 explicit SideEffectFinder(
const ASTContext &Context,
bool IncludePossible)
3692 : Inherited(Context),
3693 IncludePossibleEffects(IncludePossible), HasSideEffects(
false) { }
3695 bool hasSideEffects()
const {
return HasSideEffects; }
3697 void VisitDecl(
const Decl *D) {
3703 if (
auto *VD = dyn_cast<VarDecl>(D)) {
3705 if (IncludePossibleEffects && VD->isThisDeclarationADefinition() &&
3706 VD->needsDestruction(Context))
3707 HasSideEffects =
true;
3711 void VisitDeclStmt(
const DeclStmt *DS) {
3712 for (
auto *D : DS->
decls())
3714 Inherited::VisitDeclStmt(DS);
3717 void VisitExpr(
const Expr *E) {
3718 if (!HasSideEffects &&
3720 HasSideEffects =
true;
3726 bool IncludePossibleEffects)
const {
3730 if (!IncludePossibleEffects &&
getExprLoc().isMacroID())
3735#define ABSTRACT_STMT(Type)
3736#define STMT(Type, Base) case Type##Class:
3737#define EXPR(Type, Base)
3738#include "clang/AST/StmtNodes.inc"
3739 llvm_unreachable(
"unexpected Expr kind");
3741 case DependentScopeDeclRefExprClass:
3742 case DependentTemplateIdExprClass:
3743 case CXXUnresolvedConstructExprClass:
3744 case CXXDependentScopeMemberExprClass:
3745 case UnresolvedLookupExprClass:
3746 case UnresolvedMemberExprClass:
3747 case PackExpansionExprClass:
3748 case SubstNonTypeTemplateParmPackExprClass:
3749 case FunctionParmPackExprClass:
3750 case RecoveryExprClass:
3751 case CXXFoldExprClass:
3752 case CXXExpansionSelectExprClass:
3754 return IncludePossibleEffects;
3756 case DeclRefExprClass:
3757 case ObjCIvarRefExprClass:
3758 case PredefinedExprClass:
3759 case IntegerLiteralClass:
3760 case FixedPointLiteralClass:
3761 case FloatingLiteralClass:
3762 case ImaginaryLiteralClass:
3763 case StringLiteralClass:
3764 case CharacterLiteralClass:
3765 case OffsetOfExprClass:
3766 case ImplicitValueInitExprClass:
3767 case UnaryExprOrTypeTraitExprClass:
3768 case AddrLabelExprClass:
3769 case GNUNullExprClass:
3770 case ArrayInitIndexExprClass:
3771 case NoInitExprClass:
3772 case CXXBoolLiteralExprClass:
3773 case CXXNullPtrLiteralExprClass:
3774 case CXXThisExprClass:
3775 case CXXScalarValueInitExprClass:
3776 case TypeTraitExprClass:
3777 case ArrayTypeTraitExprClass:
3778 case ExpressionTraitExprClass:
3779 case CXXNoexceptExprClass:
3780 case SizeOfPackExprClass:
3781 case ObjCStringLiteralClass:
3782 case ObjCEncodeExprClass:
3783 case ObjCBoolLiteralExprClass:
3784 case ObjCAvailabilityCheckExprClass:
3785 case CXXUuidofExprClass:
3786 case OpaqueValueExprClass:
3787 case SourceLocExprClass:
3788 case EmbedExprClass:
3789 case ConceptSpecializationExprClass:
3790 case RequiresExprClass:
3791 case SYCLUniqueStableNameExprClass:
3792 case PackIndexingExprClass:
3793 case HLSLOutArgExprClass:
3794 case OpenACCAsteriskSizeExprClass:
3795 case CXXReflectExprClass:
3799 case ConstantExprClass:
3802 Ctx, IncludePossibleEffects);
3805 case CXXOperatorCallExprClass:
3806 case CXXMemberCallExprClass:
3807 case CUDAKernelCallExprClass:
3808 case UserDefinedLiteralClass: {
3813 bool IsPure = FD && (FD->
hasAttr<ConstAttr>() || FD->
hasAttr<PureAttr>());
3814 if (IsPure || !IncludePossibleEffects)
3819 case BlockExprClass:
3820 case CXXBindTemporaryExprClass:
3821 if (!IncludePossibleEffects)
3825 case MSPropertyRefExprClass:
3826 case MSPropertySubscriptExprClass:
3827 case CompoundAssignOperatorClass:
3828 case VAArgExprClass:
3829 case AtomicExprClass:
3830 case CXXThrowExprClass:
3831 case CXXNewExprClass:
3832 case CXXDeleteExprClass:
3833 case CoawaitExprClass:
3834 case DependentCoawaitExprClass:
3835 case CoyieldExprClass:
3839 case StmtExprClass: {
3841 SideEffectFinder Finder(Ctx, IncludePossibleEffects);
3843 return Finder.hasSideEffects();
3846 case ExprWithCleanupsClass:
3847 if (IncludePossibleEffects)
3852 case ParenExprClass:
3853 case ArraySubscriptExprClass:
3854 case MatrixSingleSubscriptExprClass:
3855 case MatrixSubscriptExprClass:
3856 case ArraySectionExprClass:
3857 case OMPArrayShapingExprClass:
3858 case OMPIteratorExprClass:
3859 case MemberExprClass:
3860 case ConditionalOperatorClass:
3861 case BinaryConditionalOperatorClass:
3862 case CompoundLiteralExprClass:
3863 case ExtVectorElementExprClass:
3864 case MatrixElementExprClass:
3865 case DesignatedInitExprClass:
3866 case DesignatedInitUpdateExprClass:
3867 case ArrayInitLoopExprClass:
3868 case ParenListExprClass:
3869 case CXXPseudoDestructorExprClass:
3870 case CXXRewrittenBinaryOperatorClass:
3871 case CXXStdInitializerListExprClass:
3872 case SubstNonTypeTemplateParmExprClass:
3873 case MaterializeTemporaryExprClass:
3874 case ShuffleVectorExprClass:
3875 case ConvertVectorExprClass:
3876 case AsTypeExprClass:
3877 case CXXParenListInitExprClass:
3881 case UnaryOperatorClass:
3886 case BinaryOperatorClass:
3891 case InitListExprClass:
3898 case GenericSelectionExprClass:
3900 Ctx, IncludePossibleEffects);
3902 case ChooseExprClass:
3904 Ctx, IncludePossibleEffects);
3906 case CXXDefaultArgExprClass:
3908 Ctx, IncludePossibleEffects);
3910 case CXXDefaultInitExprClass: {
3918 case CXXDynamicCastExprClass: {
3926 case ImplicitCastExprClass:
3927 case CStyleCastExprClass:
3928 case CXXStaticCastExprClass:
3929 case CXXReinterpretCastExprClass:
3930 case CXXConstCastExprClass:
3931 case CXXAddrspaceCastExprClass:
3932 case CXXFunctionalCastExprClass:
3933 case BuiltinBitCastExprClass: {
3938 if (!IncludePossibleEffects)
3948 case CXXTypeidExprClass: {
3950 if (!TE->isPotentiallyEvaluated())
3955 if (IncludePossibleEffects && TE->hasNullCheck())
3961 case CXXConstructExprClass:
3962 case CXXTemporaryObjectExprClass: {
3971 case CXXInheritedCtorInitExprClass: {
3973 if (!ICIE->getConstructor()->isTrivial() && IncludePossibleEffects)
3978 case LambdaExprClass: {
3980 for (
Expr *E : LE->capture_inits())
3986 case PseudoObjectExprClass: {
3993 const Expr *Subexpr = *I;
3995 Subexpr = OVE->getSourceExpr();
4002 case ObjCBoxedExprClass:
4003 case ObjCArrayLiteralClass:
4004 case ObjCDictionaryLiteralClass:
4005 case ObjCSelectorExprClass:
4006 case ObjCProtocolExprClass:
4007 case ObjCIsaExprClass:
4008 case ObjCIndirectCopyRestoreExprClass:
4009 case ObjCSubscriptRefExprClass:
4010 case ObjCBridgedCastExprClass:
4011 case ObjCMessageExprClass:
4012 case ObjCPropertyRefExprClass:
4014 if (IncludePossibleEffects)
4029 if (
auto Call = dyn_cast<CallExpr>(
this))
4030 return Call->getFPFeaturesInEffect(LO);
4031 if (
auto UO = dyn_cast<UnaryOperator>(
this))
4032 return UO->getFPFeaturesInEffect(LO);
4033 if (
auto BO = dyn_cast<BinaryOperator>(
this))
4034 return BO->getFPFeaturesInEffect(LO);
4035 if (
auto Cast = dyn_cast<CastExpr>(
this))
4036 return Cast->getFPFeaturesInEffect(LO);
4037 if (
auto ConvertVector = dyn_cast<ConvertVectorExpr>(
this))
4038 return ConvertVector->getFPFeaturesInEffect(LO);
4051 explicit NonTrivialCallFinder(
const ASTContext &Context)
4052 : Inherited(Context), NonTrivial(
false) { }
4054 bool hasNonTrivialCall()
const {
return NonTrivial; }
4056 void VisitCallExpr(
const CallExpr *E) {
4057 if (
const CXXMethodDecl *
Method
4058 = dyn_cast_or_null<const CXXMethodDecl>(E->
getCalleeDecl())) {
4059 if (
Method->isTrivial()) {
4061 Inherited::VisitStmt(E);
4069 void VisitCXXConstructExpr(
const CXXConstructExpr *E) {
4072 Inherited::VisitStmt(E);
4079 void VisitCXXBindTemporaryExpr(
const CXXBindTemporaryExpr *E) {
4082 if (
const CXXDestructorDecl *DtorDecl =
4084 if (DtorDecl->isTrivial()) {
4085 Inherited::VisitStmt(E);
4096 NonTrivialCallFinder Finder(Ctx);
4098 return Finder.hasNonTrivialCall();
4116 llvm_unreachable(
"Unexpected value dependent expression!");
4144 CE->getSubExpr()->getType()->isIntegerType())
4145 return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
4148 }
else if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(
this)) {
4150 return ICE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
4151 }
else if (
const ParenExpr *PE = dyn_cast<ParenExpr>(
this)) {
4154 return PE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
4156 dyn_cast<GenericSelectionExpr>(
this)) {
4157 if (GE->isResultDependent())
4159 return GE->getResultExpr()->isNullPointerConstant(Ctx, NPC);
4160 }
else if (
const ChooseExpr *CE = dyn_cast<ChooseExpr>(
this)) {
4161 if (CE->isConditionDependent())
4163 return CE->getChosenSubExpr()->isNullPointerConstant(Ctx, NPC);
4165 = dyn_cast<CXXDefaultArgExpr>(
this)) {
4167 return DefaultArg->getExpr()->isNullPointerConstant(Ctx, NPC);
4169 = dyn_cast<CXXDefaultInitExpr>(
this)) {
4171 return DefaultInit->getExpr()->isNullPointerConstant(Ctx, NPC);
4176 = dyn_cast<MaterializeTemporaryExpr>(
this)) {
4177 return M->getSubExpr()->isNullPointerConstant(Ctx, NPC);
4178 }
else if (
const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(
this)) {
4179 if (
const Expr *Source = OVE->getSourceExpr())
4180 return Source->isNullPointerConstant(Ctx, NPC);
4189 if (
getType()->isNullPtrType())
4192 if (
const RecordType *UT =
getType()->getAsUnionType())
4194 UT->getDecl()->getMostRecentDecl()->hasAttr<TransparentUnionAttr>())
4196 const Expr *InitExpr = CLE->getInitializer();
4197 if (
const InitListExpr *ILE = dyn_cast<InitListExpr>(InitExpr))
4198 return ILE->getInit(0)->isNullPointerConstant(Ctx, NPC);
4201 if (!
getType()->isIntegerType() ||
4232 const Expr *E =
this;
4235 "expression is not a property reference");
4238 if (BO->getOpcode() == BO_Comma) {
4253 const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E);
4261 const ObjCMethodDecl *M = dyn_cast<ObjCMethodDecl>(Param->getDeclContext());
4272 if (ICE->getCastKind() == CK_LValueToRValue ||
4273 (ICE->isGLValue() && ICE->getCastKind() == CK_NoOp))
4279 if (
StmtExpr *SE = dyn_cast<StmtExpr>(E)) {
4282 if (
Expr *EX = VS->getExprStmt())
4283 return EX->getSourceBitField();
4286 if (
MemberExpr *MemRef = dyn_cast<MemberExpr>(E))
4287 if (
FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
4288 if (Field->isBitField())
4297 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E)) {
4298 if (
FieldDecl *Field = dyn_cast<FieldDecl>(DeclRef->getDecl()))
4299 if (Field->isBitField())
4302 if (
BindingDecl *BD = dyn_cast<BindingDecl>(DeclRef->getDecl()))
4303 if (
Expr *E = BD->getBinding())
4308 if (BinOp->isAssignmentOp() && BinOp->getLHS())
4309 return BinOp->getLHS()->getSourceBitField();
4311 if (BinOp->getOpcode() == BO_Comma && BinOp->getRHS())
4312 return BinOp->getRHS()->getSourceBitField();
4316 if (UnOp->isPrefix() && UnOp->isIncrementDecrementOp())
4317 return UnOp->getSubExpr()->getSourceBitField();
4324 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
4325 return dyn_cast<EnumConstantDecl>(DRE->getDecl());
4334 if (ICE->isGLValue() && ICE->getCastKind() == CK_NoOp)
4341 return ASE->getBase()->getType()->isVectorType();
4346 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
4347 if (
auto *BD = dyn_cast<BindingDecl>(DRE->getDecl()))
4348 if (
auto *E = BD->getBinding())
4357 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
4358 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
4360 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
4376 case CXXThisExprClass:
4378 case DeclRefExprClass: {
4384 if (DRE1->getDecl() != DRE2->getDecl())
4387 if ((DRE1->isPRValue() && DRE2->isPRValue()) ||
4388 (DRE1->isLValue() && DRE2->isLValue()))
4393 case ImplicitCastExprClass: {
4396 const auto *ICE1 = dyn_cast<ImplicitCastExpr>(E1);
4397 const auto *ICE2 = dyn_cast<ImplicitCastExpr>(E2);
4400 if (ICE1->getCastKind() != ICE2->getCastKind())
4402 ICE2->IgnoreParenImpCasts());
4406 if (ICE1->getCastKind() == CK_LValueToRValue ||
4407 ICE1->getCastKind() == CK_ArrayToPointerDecay ||
4408 ICE1->getCastKind() == CK_FunctionToPointerDecay) {
4413 const auto *DRE1 = dyn_cast<DeclRefExpr>(E1);
4414 const auto *DRE2 = dyn_cast<DeclRefExpr>(E2);
4418 const auto *Ivar1 = dyn_cast<ObjCIvarRefExpr>(E1);
4419 const auto *Ivar2 = dyn_cast<ObjCIvarRefExpr>(E2);
4420 if (Ivar1 && Ivar2) {
4421 return Ivar1->isFreeIvar() && Ivar2->isFreeIvar() &&
4425 const auto *Array1 = dyn_cast<ArraySubscriptExpr>(E1);
4426 const auto *Array2 = dyn_cast<ArraySubscriptExpr>(E2);
4427 if (Array1 && Array2) {
4431 auto Idx1 = Array1->getIdx();
4432 auto Idx2 = Array2->getIdx();
4433 const auto Integer1 = dyn_cast<IntegerLiteral>(Idx1);
4434 const auto Integer2 = dyn_cast<IntegerLiteral>(Idx2);
4435 if (Integer1 && Integer2) {
4436 if (!llvm::APInt::isSameValue(Integer1->getValue(),
4437 Integer2->getValue()))
4453 if (
const auto *D = dyn_cast<VarDecl>(ME1->getMemberDecl()))
4454 if (D->isStaticDataMember())
4466 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
4467 return DRE->getDecl();
4468 if (
const auto *ME = dyn_cast<MemberExpr>(E))
4469 return ME->getMemberDecl();
4488 return VT->getNumElements();
4493 if (
const auto *MT =
getType()->getAs<ConstantMatrixType>())
4494 return MT->getNumElementsFlattened();
4503 StringRef Comp =
Accessor->getName();
4506 if (Comp ==
"hi" || Comp ==
"lo" || Comp ==
"even" || Comp ==
"odd")
4510 if (Comp[0] ==
's' || Comp[0] ==
'S')
4511 Comp = Comp.substr(1);
4513 for (
unsigned i = 0, e = Comp.size(); i != e; ++i)
4514 if (Comp.substr(i + 1).contains(Comp[i]))
4521struct MatrixAccessorFormat {
4522 bool IsZeroIndexed =
false;
4523 unsigned ChunkLen = 0;
4526static MatrixAccessorFormat GetHLSLMatrixAccessorFormat(StringRef Comp) {
4527 assert(!Comp.empty() && Comp[0] ==
'_' &&
"invalid matrix accessor");
4529 MatrixAccessorFormat F;
4530 if (Comp.size() >= 2 && Comp[0] ==
'_' && Comp[1] ==
'm') {
4531 F.IsZeroIndexed =
true;
4534 F.IsZeroIndexed =
false;
4538 assert(F.ChunkLen != 0 &&
"unrecognized matrix swizzle format");
4539 assert(
Comp.size() % F.ChunkLen == 0 &&
4540 "matrix swizzle accessor has invalid length");
4544template <
typename Fn>
4545static bool ForEachMatrixAccessorIndex(StringRef Comp,
4547 auto Format = GetHLSLMatrixAccessorFormat(Comp);
4549 for (
unsigned I = 0, E =
Comp.size(); I < E; I += Format.ChunkLen) {
4550 unsigned Row = 0, Col = 0;
4551 unsigned ZeroIndexOffset =
static_cast<unsigned>(Format.IsZeroIndexed);
4552 unsigned OneIndexOffset =
static_cast<unsigned>(!Format.IsZeroIndexed);
4553 Row =
static_cast<unsigned>(
Comp[I + ZeroIndexOffset + 1] -
'0') -
4555 Col =
static_cast<unsigned>(
Comp[I + ZeroIndexOffset + 2] -
'0') -
4558 assert(Row < MT->getNumRows() && Col < MT->getNumColumns() &&
4559 "matrix swizzle index out of bounds");
4577 StringRef Comp =
Accessor->getName();
4581 bool HasDup =
false;
4582 ForEachMatrixAccessorIndex(Comp, MT, [&](
unsigned Index) ->
bool {
4597 StringRef Comp =
Accessor->getName();
4598 bool isNumericAccessor =
false;
4599 if (Comp[0] ==
's' || Comp[0] ==
'S') {
4600 Comp = Comp.substr(1);
4601 isNumericAccessor =
true;
4604 bool isHi = Comp ==
"hi";
4605 bool isLo = Comp ==
"lo";
4606 bool isEven = Comp ==
"even";
4607 bool isOdd = Comp ==
"odd";
4623 Elts.push_back(Index);
4629 StringRef Comp =
Accessor->getName();
4631 ForEachMatrixAccessorIndex(Comp, MT, [&](
unsigned Index) ->
bool {
4632 Elts.push_back(Index);
4641 BuiltinLoc(BLoc), RParenLoc(RP) {
4643 SubExprs =
new (
C)
Stmt*[args.size()];
4644 for (
unsigned i = 0; i != args.size(); i++)
4645 SubExprs[i] = args[i];
4651 if (SubExprs)
C.Deallocate(SubExprs);
4655 llvm::copy(Exprs, SubExprs);
4658GenericSelectionExpr::GenericSelectionExpr(
4662 bool ContainsUnexpandedParameterPack,
unsigned ResultIndex)
4663 :
Expr(GenericSelectionExprClass, AssocExprs[ResultIndex]->
getType(),
4664 AssocExprs[ResultIndex]->getValueKind(),
4665 AssocExprs[ResultIndex]->getObjectKind()),
4666 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
4667 IsExprPredicate(
true), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4668 assert(AssocTypes.size() == AssocExprs.size() &&
4669 "Must have the same number of association expressions"
4670 " and TypeSourceInfo!");
4671 assert(ResultIndex < NumAssocs &&
"ResultIndex is out-of-bounds!");
4674 getTrailingObjects<Stmt *>()[getIndexOfControllingExpression()] =
4676 llvm::copy(AssocExprs,
4677 getTrailingObjects<Stmt *>() + getIndexOfStartOfAssociatedExprs());
4678 llvm::copy(AssocTypes, getTrailingObjects<TypeSourceInfo *>() +
4679 getIndexOfStartOfAssociatedTypes());
4684GenericSelectionExpr::GenericSelectionExpr(
4689 unsigned ResultIndex)
4690 :
Expr(GenericSelectionExprClass, AssocExprs[ResultIndex]->
getType(),
4691 AssocExprs[ResultIndex]->getValueKind(),
4692 AssocExprs[ResultIndex]->getObjectKind()),
4693 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
4694 IsExprPredicate(
false), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4695 assert(AssocTypes.size() == AssocExprs.size() &&
4696 "Must have the same number of association expressions"
4697 " and TypeSourceInfo!");
4698 assert(ResultIndex < NumAssocs &&
"ResultIndex is out-of-bounds!");
4701 getTrailingObjects<TypeSourceInfo *>()[getIndexOfControllingType()] =
4703 llvm::copy(AssocExprs,
4704 getTrailingObjects<Stmt *>() + getIndexOfStartOfAssociatedExprs());
4705 llvm::copy(AssocTypes, getTrailingObjects<TypeSourceInfo *>() +
4706 getIndexOfStartOfAssociatedTypes());
4711GenericSelectionExpr::GenericSelectionExpr(
4715 bool ContainsUnexpandedParameterPack)
4716 :
Expr(GenericSelectionExprClass, Context.DependentTy,
VK_PRValue,
4718 NumAssocs(AssocExprs.size()), ResultIndex(ResultDependentIndex),
4719 IsExprPredicate(
true), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4720 assert(AssocTypes.size() == AssocExprs.size() &&
4721 "Must have the same number of association expressions"
4722 " and TypeSourceInfo!");
4725 getTrailingObjects<Stmt *>()[getIndexOfControllingExpression()] =
4727 llvm::copy(AssocExprs,
4728 getTrailingObjects<Stmt *>() + getIndexOfStartOfAssociatedExprs());
4729 llvm::copy(AssocTypes, getTrailingObjects<TypeSourceInfo *>() +
4730 getIndexOfStartOfAssociatedTypes());
4735GenericSelectionExpr::GenericSelectionExpr(
4740 :
Expr(GenericSelectionExprClass, Context.DependentTy,
VK_PRValue,
4742 NumAssocs(AssocExprs.size()), ResultIndex(ResultDependentIndex),
4743 IsExprPredicate(
false), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
4744 assert(AssocTypes.size() == AssocExprs.size() &&
4745 "Must have the same number of association expressions"
4746 " and TypeSourceInfo!");
4749 getTrailingObjects<TypeSourceInfo *>()[getIndexOfControllingType()] =
4751 llvm::copy(AssocExprs,
4752 getTrailingObjects<Stmt *>() + getIndexOfStartOfAssociatedExprs());
4753 llvm::copy(AssocTypes, getTrailingObjects<TypeSourceInfo *>() +
4754 getIndexOfStartOfAssociatedTypes());
4759GenericSelectionExpr::GenericSelectionExpr(EmptyShell
Empty,
unsigned NumAssocs)
4760 :
Expr(GenericSelectionExprClass,
Empty), NumAssocs(NumAssocs) {}
4766 bool ContainsUnexpandedParameterPack,
unsigned ResultIndex) {
4767 unsigned NumAssocs = AssocExprs.size();
4768 void *Mem = Context.Allocate(
4769 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4770 alignof(GenericSelectionExpr));
4771 return new (Mem) GenericSelectionExpr(
4772 Context, GenericLoc, ControllingExpr, AssocTypes, AssocExprs, DefaultLoc,
4773 RParenLoc, ContainsUnexpandedParameterPack, ResultIndex);
4780 bool ContainsUnexpandedParameterPack) {
4781 unsigned NumAssocs = AssocExprs.size();
4782 void *Mem = Context.Allocate(
4783 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4784 alignof(GenericSelectionExpr));
4785 return new (Mem) GenericSelectionExpr(
4786 Context, GenericLoc, ControllingExpr, AssocTypes, AssocExprs, DefaultLoc,
4787 RParenLoc, ContainsUnexpandedParameterPack);
4795 unsigned ResultIndex) {
4796 unsigned NumAssocs = AssocExprs.size();
4797 void *Mem = Context.Allocate(
4798 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4799 alignof(GenericSelectionExpr));
4800 return new (Mem) GenericSelectionExpr(
4801 Context, GenericLoc, ControllingType, AssocTypes, AssocExprs, DefaultLoc,
4802 RParenLoc, ContainsUnexpandedParameterPack, ResultIndex);
4809 SourceLocation RParenLoc,
bool ContainsUnexpandedParameterPack) {
4810 unsigned NumAssocs = AssocExprs.size();
4811 void *Mem = Context.Allocate(
4812 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4813 alignof(GenericSelectionExpr));
4814 return new (Mem) GenericSelectionExpr(
4815 Context, GenericLoc, ControllingType, AssocTypes, AssocExprs, DefaultLoc,
4816 RParenLoc, ContainsUnexpandedParameterPack);
4821 unsigned NumAssocs) {
4822 void *Mem = Context.Allocate(
4823 totalSizeToAlloc<Stmt *, TypeSourceInfo *>(1 + NumAssocs, NumAssocs),
4824 alignof(GenericSelectionExpr));
4825 return new (Mem) GenericSelectionExpr(
EmptyShell(), NumAssocs);
4846 EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
4847 NumDesignators(Designators.
size()), NumSubExprs(IndexExprs.
size() + 1) {
4848 this->Designators =
new (
C)
Designator[NumDesignators];
4856 unsigned IndexIdx = 0;
4857 for (
unsigned I = 0; I != NumDesignators; ++I) {
4858 this->Designators[I] = Designators[I];
4861 *Child++ = IndexExprs[IndexIdx++];
4864 *Child++ = IndexExprs[IndexIdx++];
4865 *Child++ = IndexExprs[IndexIdx++];
4869 assert(IndexIdx == IndexExprs.size() &&
"Wrong number of index expressions");
4877 bool UsesColonSyntax,
4879 void *Mem =
C.Allocate(totalSizeToAlloc<Stmt *>(IndexExprs.size() + 1),
4880 alignof(DesignatedInitExpr));
4881 return new (Mem) DesignatedInitExpr(
C,
C.VoidTy, Designators,
4882 ColonOrEqualLoc, UsesColonSyntax,
4887 unsigned NumIndexExprs) {
4888 void *Mem =
C.Allocate(totalSizeToAlloc<Stmt *>(NumIndexExprs + 1),
4889 alignof(DesignatedInitExpr));
4890 return new (Mem) DesignatedInitExpr(NumIndexExprs + 1);
4895 unsigned NumDesigs) {
4897 NumDesignators = NumDesigs;
4898 for (
unsigned I = 0; I != NumDesigs; ++I)
4899 Designators[I] = Desigs[I];
4903 DesignatedInitExpr *DIE =
const_cast<DesignatedInitExpr*
>(
this);
4911 auto *DIE =
const_cast<DesignatedInitExpr *
>(
this);
4913 if (
First.isFieldDesignator()) {
4916 for (
unsigned int i = 0; i < DIE->size(); i++) {
4924 return First.getLBracketLoc();
4951 unsigned NumNewDesignators =
Last -
First;
4952 if (NumNewDesignators == 0) {
4953 std::copy_backward(Designators + Idx + 1,
4954 Designators + NumDesignators,
4956 --NumNewDesignators;
4959 if (NumNewDesignators == 1) {
4960 Designators[Idx] = *
First;
4965 =
new (
C)
Designator[NumDesignators - 1 + NumNewDesignators];
4966 std::copy(Designators, Designators + Idx, NewDesignators);
4967 std::copy(
First,
Last, NewDesignators + Idx);
4968 std::copy(Designators + Idx + 1, Designators + NumDesignators,
4969 NewDesignators + Idx + NumNewDesignators);
4970 Designators = NewDesignators;
4971 NumDesignators = NumDesignators - 1 + NumNewDesignators;
4980 BaseAndUpdaterExprs[0] = baseExpr;
4985 BaseAndUpdaterExprs[1] = ILE;
5002 LParenLoc(LParenLoc), RParenLoc(RParenLoc) {
5004 llvm::copy(Exprs, getTrailingObjects());
5008ParenListExpr::ParenListExpr(EmptyShell
Empty,
unsigned NumExprs)
5017 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Stmt *>(Exprs.size()),
5018 alignof(ParenListExpr));
5019 return new (Mem) ParenListExpr(LParenLoc, Exprs, RParenLoc);
5023 unsigned NumExprs) {
5025 Ctx.
Allocate(totalSizeToAlloc<Stmt *>(NumExprs),
alignof(ParenListExpr));
5026 return new (Mem) ParenListExpr(
EmptyShell(), NumExprs);
5033static std::optional<BinaryOperator *>
5038 ComparedTo = E->
getRHS();
5041 ComparedTo = E->
getLHS();
5046 const Expr *AddLHS =
nullptr, *AddRHS =
nullptr;
5049 if (BO && BO->
getOpcode() == clang::BO_Add) {
5055 if (!AddLHS || !AddRHS)
5058 const Decl *LHSDecl, *RHSDecl, *OtherDecl;
5061 RHSDecl = AddRHS->IgnoreParenImpCasts()->getReferencedDeclOfCallee();
5067 if (!LHSDecl && !RHSDecl)
5070 if ((LHSDecl && LHSDecl == OtherDecl && LHSDecl != RHSDecl) ||
5071 (RHSDecl && RHSDecl == OtherDecl && RHSDecl != LHSDecl))
5093 Result.value()->setExcludedOverflowPattern(
true);
5100 :
Expr(BinaryOperatorClass, ResTy,
VK, OK) {
5103 "Use CompoundAssignOperator for compound assignments");
5106 SubExprs[LHS] = lhs;
5107 SubExprs[RHS] = rhs;
5119 :
Expr(CompoundAssignOperatorClass, ResTy,
VK, OK) {
5123 "Use CompoundAssignOperator for compound assignments");
5125 SubExprs[LHS] = lhs;
5126 SubExprs[RHS] = rhs;
5134 bool HasFPFeatures) {
5157 void *Mem =
C.Allocate(
sizeof(CompoundAssignOperator) +
Extra,
5158 alignof(CompoundAssignOperator));
5159 return new (Mem) CompoundAssignOperator(
C,
EmptyShell(), HasFPFeatures);
5170 void *Mem =
C.Allocate(
sizeof(CompoundAssignOperator) +
Extra,
5171 alignof(CompoundAssignOperator));
5173 CompoundAssignOperator(
C, lhs, rhs, opc, ResTy,
VK, OK, opLoc, FPFeatures,
5174 CompLHSType, CompResultType);
5178 bool hasFPFeatures) {
5179 void *Mem =
C.Allocate(totalSizeToAlloc<FPOptionsOverride>(hasFPFeatures),
5188 :
Expr(UnaryOperatorClass,
type,
VK, OK), Val(input) {
5204 unsigned Size = totalSizeToAlloc<FPOptionsOverride>(HasFPFeatures);
5212 e = ewc->getSubExpr();
5214 e = m->getSubExpr();
5217 e = ice->getSubExpr();
5223 unsigned numSemanticExprs) {
5225 Context.Allocate(totalSizeToAlloc<Expr *>(1 + numSemanticExprs),
5226 alignof(PseudoObjectExpr));
5227 return new(buffer) PseudoObjectExpr(sh, numSemanticExprs);
5230PseudoObjectExpr::PseudoObjectExpr(EmptyShell shell,
unsigned numSemanticExprs)
5231 :
Expr(PseudoObjectExprClass, shell) {
5237 unsigned resultIndex) {
5238 assert(
syntax &&
"no syntactic expression!");
5239 assert(
semantics.size() &&
"no semantic expressions!");
5253 void *buffer =
C.Allocate(totalSizeToAlloc<Expr *>(
semantics.size() + 1),
5254 alignof(PseudoObjectExpr));
5261 unsigned resultIndex)
5274 "opaque-value semantic expressions for pseudo-object "
5275 "operations must have sources");
5277 llvm::copy(
semantics, Trail.drop_front().begin());
5308 NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op) {
5309 assert(args.size() ==
getNumSubExprs(op) &&
"wrong number of subexpressions");
5310 for (
unsigned i = 0; i != args.size(); i++)
5311 SubExprs[i] = args[i];
5317 case AO__c11_atomic_init:
5318 case AO__opencl_atomic_init:
5319 case AO__c11_atomic_load:
5320 case AO__atomic_load_n:
5321 case AO__atomic_test_and_set:
5322 case AO__atomic_clear:
5325 case AO__scoped_atomic_load_n:
5326 case AO__opencl_atomic_load:
5327 case AO__hip_atomic_load:
5328 case AO__c11_atomic_store:
5329 case AO__c11_atomic_exchange:
5330 case AO__atomic_load:
5331 case AO__atomic_store:
5332 case AO__atomic_store_n:
5333 case AO__atomic_exchange_n:
5334 case AO__c11_atomic_fetch_add:
5335 case AO__c11_atomic_fetch_sub:
5336 case AO__c11_atomic_fetch_and:
5337 case AO__c11_atomic_fetch_or:
5338 case AO__c11_atomic_fetch_xor:
5339 case AO__c11_atomic_fetch_nand:
5340 case AO__c11_atomic_fetch_max:
5341 case AO__c11_atomic_fetch_min:
5342 case AO__atomic_fetch_add:
5343 case AO__atomic_fetch_sub:
5344 case AO__atomic_fetch_and:
5345 case AO__atomic_fetch_or:
5346 case AO__atomic_fetch_xor:
5347 case AO__atomic_fetch_nand:
5348 case AO__atomic_add_fetch:
5349 case AO__atomic_sub_fetch:
5350 case AO__atomic_and_fetch:
5351 case AO__atomic_or_fetch:
5352 case AO__atomic_xor_fetch:
5353 case AO__atomic_nand_fetch:
5354 case AO__atomic_min_fetch:
5355 case AO__atomic_max_fetch:
5356 case AO__atomic_fetch_min:
5357 case AO__atomic_fetch_max:
5358 case AO__atomic_fetch_fminimum:
5359 case AO__atomic_fetch_fmaximum:
5360 case AO__atomic_fetch_fminimum_num:
5361 case AO__atomic_fetch_fmaximum_num:
5362 case AO__atomic_fetch_uinc:
5363 case AO__atomic_fetch_udec:
5366 case AO__scoped_atomic_load:
5367 case AO__scoped_atomic_store:
5368 case AO__scoped_atomic_store_n:
5369 case AO__scoped_atomic_fetch_add:
5370 case AO__scoped_atomic_fetch_sub:
5371 case AO__scoped_atomic_fetch_and:
5372 case AO__scoped_atomic_fetch_or:
5373 case AO__scoped_atomic_fetch_xor:
5374 case AO__scoped_atomic_fetch_nand:
5375 case AO__scoped_atomic_add_fetch:
5376 case AO__scoped_atomic_sub_fetch:
5377 case AO__scoped_atomic_and_fetch:
5378 case AO__scoped_atomic_or_fetch:
5379 case AO__scoped_atomic_xor_fetch:
5380 case AO__scoped_atomic_nand_fetch:
5381 case AO__scoped_atomic_min_fetch:
5382 case AO__scoped_atomic_max_fetch:
5383 case AO__scoped_atomic_fetch_min:
5384 case AO__scoped_atomic_fetch_max:
5385 case AO__scoped_atomic_fetch_fminimum:
5386 case AO__scoped_atomic_fetch_fmaximum:
5387 case AO__scoped_atomic_fetch_fminimum_num:
5388 case AO__scoped_atomic_fetch_fmaximum_num:
5389 case AO__scoped_atomic_exchange_n:
5390 case AO__scoped_atomic_fetch_uinc:
5391 case AO__scoped_atomic_fetch_udec:
5392 case AO__hip_atomic_exchange:
5393 case AO__hip_atomic_fetch_add:
5394 case AO__hip_atomic_fetch_sub:
5395 case AO__hip_atomic_fetch_and:
5396 case AO__hip_atomic_fetch_or:
5397 case AO__hip_atomic_fetch_xor:
5398 case AO__hip_atomic_fetch_min:
5399 case AO__hip_atomic_fetch_max:
5400 case AO__opencl_atomic_store:
5401 case AO__hip_atomic_store:
5402 case AO__opencl_atomic_exchange:
5403 case AO__opencl_atomic_fetch_add:
5404 case AO__opencl_atomic_fetch_sub:
5405 case AO__opencl_atomic_fetch_and:
5406 case AO__opencl_atomic_fetch_or:
5407 case AO__opencl_atomic_fetch_xor:
5408 case AO__opencl_atomic_fetch_min:
5409 case AO__opencl_atomic_fetch_max:
5410 case AO__atomic_exchange:
5413 case AO__scoped_atomic_exchange:
5414 case AO__c11_atomic_compare_exchange_strong:
5415 case AO__c11_atomic_compare_exchange_weak:
5417 case AO__hip_atomic_compare_exchange_strong:
5418 case AO__opencl_atomic_compare_exchange_strong:
5419 case AO__opencl_atomic_compare_exchange_weak:
5420 case AO__hip_atomic_compare_exchange_weak:
5421 case AO__atomic_compare_exchange:
5422 case AO__atomic_compare_exchange_n:
5425 case AO__scoped_atomic_compare_exchange:
5426 case AO__scoped_atomic_compare_exchange_n:
5429 llvm_unreachable(
"unknown atomic op");
5435 return AT->getValueType();
5440 unsigned ArraySectionCount = 0;
5441 while (
auto *OASE = dyn_cast<ArraySectionExpr>(
Base->IgnoreParens())) {
5442 Base = OASE->getBase();
5443 ++ArraySectionCount;
5446 dyn_cast<ArraySubscriptExpr>(
Base->IgnoreParenImpCasts())) {
5447 Base = ASE->getBase();
5448 ++ArraySectionCount;
5450 Base =
Base->IgnoreParenImpCasts();
5451 auto OriginalTy =
Base->getType();
5452 if (
auto *DRE = dyn_cast<DeclRefExpr>(
Base))
5453 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl()))
5454 OriginalTy = PVD->getOriginalType().getNonReferenceType();
5456 for (
unsigned Cnt = 0; Cnt < ArraySectionCount; ++Cnt) {
5457 if (OriginalTy->isAnyPointerType())
5458 OriginalTy = OriginalTy->getPointeeType();
5459 else if (OriginalTy->isArrayType())
5460 OriginalTy = OriginalTy->castAsArrayTypeUnsafe()->getElementType();
5472 BaseTy = ASE->getElementType();
5489 return ASE->getElementType();
5496 :
Expr(RecoveryExprClass,
T.getNonReferenceType(),
5497 T->isDependentType() ?
VK_LValue : getValueKindForType(
T),
5499 BeginLoc(BeginLoc), EndLoc(EndLoc), NumExprs(SubExprs.size()) {
5500 assert(!
T.isNull());
5501 assert(!llvm::is_contained(SubExprs,
nullptr));
5503 llvm::copy(SubExprs, getTrailingObjects());
5511 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Expr *>(SubExprs.size()),
5512 alignof(RecoveryExpr));
5513 return new (Mem) RecoveryExpr(Ctx,
T, BeginLoc, EndLoc, SubExprs);
5517 void *Mem = Ctx.
Allocate(totalSizeToAlloc<Expr *>(NumSubExprs),
5518 alignof(RecoveryExpr));
5519 return new (Mem) RecoveryExpr(
EmptyShell(), NumSubExprs);
5524 NumDims == Dims.size() &&
5525 "Preallocated number of dimensions is different from the provided one.");
5526 llvm::copy(Dims, getTrailingObjects<Expr *>());
5531 NumDims == BR.size() &&
5532 "Preallocated number of dimensions is different from the provided one.");
5533 llvm::copy(BR, getTrailingObjects<SourceRange>());
5536OMPArrayShapingExpr::OMPArrayShapingExpr(
QualType ExprTy,
Expr *Op,
5540 RPLoc(
R), NumDims(Dims.size()) {
5542 setDimensions(Dims);
5551 assert(Dims.size() == BracketRanges.size() &&
5552 "Different number of dimensions and brackets ranges.");
5553 void *Mem = Context.Allocate(
5554 totalSizeToAlloc<Expr *, SourceRange>(Dims.size() + 1, Dims.size()),
5555 alignof(OMPArrayShapingExpr));
5556 auto *E =
new (Mem) OMPArrayShapingExpr(
T, Op, L, R, Dims);
5557 E->setBracketsRanges(BracketRanges);
5563 void *Mem = Context.Allocate(
5564 totalSizeToAlloc<Expr *, SourceRange>(NumDims + 1, NumDims),
5565 alignof(OMPArrayShapingExpr));
5566 return new (Mem) OMPArrayShapingExpr(
EmptyShell(), NumDims);
5569void OMPIteratorExpr::setIteratorDeclaration(
unsigned I,
Decl *D) {
5570 getTrailingObjects<Decl *>(NumIterators)[I] = D;
5573void OMPIteratorExpr::setAssignmentLoc(
unsigned I,
SourceLocation Loc) {
5574 assert(I < NumIterators &&
5575 "Idx is greater or equal the number of iterators definitions.");
5578 static_cast<int>(RangeLocOffset::AssignLoc)] = Loc;
5581void OMPIteratorExpr::setIteratorRange(
unsigned I,
Expr *Begin,
5585 assert(I < NumIterators &&
5586 "Idx is greater or equal the number of iterators definitions.");
5587 getTrailingObjects<Expr *>()[I *
static_cast<int>(RangeExprOffset::Total) +
5588 static_cast<int>(RangeExprOffset::Begin)] =
5590 getTrailingObjects<Expr *>()[I *
static_cast<int>(RangeExprOffset::Total) +
5591 static_cast<int>(RangeExprOffset::End)] = End;
5592 getTrailingObjects<Expr *>()[I *
static_cast<int>(RangeExprOffset::Total) +
5593 static_cast<int>(RangeExprOffset::Step)] = Step;
5595 SourceLocation>()[I *
static_cast<int>(RangeLocOffset::Total) +
5596 static_cast<int>(RangeLocOffset::FirstColonLoc)] =
5599 SourceLocation>()[I *
static_cast<int>(RangeLocOffset::Total) +
5600 static_cast<int>(RangeLocOffset::SecondColonLoc)] =
5605 return getTrailingObjects<Decl *>()[I];
5611 getTrailingObjects<Expr *>()[I *
static_cast<int>(
5612 RangeExprOffset::Total) +
5613 static_cast<int>(RangeExprOffset::Begin)];
5615 getTrailingObjects<Expr *>()[I *
static_cast<int>(
5616 RangeExprOffset::Total) +
5617 static_cast<int>(RangeExprOffset::End)];
5619 getTrailingObjects<Expr *>()[I *
static_cast<int>(
5620 RangeExprOffset::Total) +
5621 static_cast<int>(RangeExprOffset::Step)];
5626 return getTrailingObjects<
5628 static_cast<int>(RangeLocOffset::AssignLoc)];
5632 return getTrailingObjects<
5634 static_cast<int>(RangeLocOffset::FirstColonLoc)];
5638 return getTrailingObjects<
5640 static_cast<int>(RangeLocOffset::SecondColonLoc)];
5644 getTrailingObjects<OMPIteratorHelperData>()[I] = D;
5648 return getTrailingObjects<OMPIteratorHelperData>()[I];
5652 return getTrailingObjects<OMPIteratorHelperData>()[I];
5655OMPIteratorExpr::OMPIteratorExpr(
5660 IteratorKwLoc(IteratorKwLoc), LPLoc(L), RPLoc(R),
5661 NumIterators(
Data.size()) {
5662 for (
unsigned I = 0, E =
Data.size(); I < E; ++I) {
5663 const IteratorDefinition &D = Data[I];
5664 setIteratorDeclaration(I, D.IteratorDecl);
5665 setAssignmentLoc(I, D.AssignmentLoc);
5666 setIteratorRange(I, D.Range.Begin, D.ColonLoc, D.Range.End,
5667 D.SecondColonLoc, D.Range.Step);
5668 setHelper(I, Helpers[I]);
5679 assert(
Data.size() == Helpers.size() &&
5680 "Data and helpers must have the same size.");
5681 void *Mem = Context.Allocate(
5682 totalSizeToAlloc<Decl *, Expr *, SourceLocation, OMPIteratorHelperData>(
5683 Data.size(),
Data.size() *
static_cast<int>(RangeExprOffset::Total),
5684 Data.size() *
static_cast<int>(RangeLocOffset::Total),
5686 alignof(OMPIteratorExpr));
5687 return new (Mem) OMPIteratorExpr(
T, IteratorKwLoc, L, R,
Data, Helpers);
5691 unsigned NumIterators) {
5692 void *Mem = Context.Allocate(
5693 totalSizeToAlloc<Decl *, Expr *, SourceLocation, OMPIteratorHelperData>(
5694 NumIterators, NumIterators *
static_cast<int>(RangeExprOffset::Total),
5695 NumIterators *
static_cast<int>(RangeLocOffset::Total), NumIterators),
5696 alignof(OMPIteratorExpr));
5697 return new (Mem) OMPIteratorExpr(
EmptyShell(), NumIterators);
5704 return new (
C) HLSLOutArgExpr(Ty,
Base, OpV, WB, IsInOut);
5713 return new (
C) OpenACCAsteriskSizeExpr(Loc,
C.IntTy);
5718 return new (
C) OpenACCAsteriskSizeExpr({},
C.IntTy);
5722 bool hasFPFeatures) {
5723 void *Mem =
C.Allocate(totalSizeToAlloc<FPOptionsOverride>(hasFPFeatures),
5724 alignof(ConvertVectorExpr));
5725 return new (Mem) ConvertVectorExpr(hasFPFeatures,
EmptyShell());
5733 unsigned Size = totalSizeToAlloc<FPOptionsOverride>(HasFPFeatures);
5734 void *Mem =
C.Allocate(Size,
alignof(ConvertVectorExpr));
5735 return new (Mem) ConvertVectorExpr(SrcExpr, TI, DstType,
VK, OK, BuiltinLoc,
5736 RParenLoc, FPFeatures);
5742 StaticValue =
new (Ctx)
APValue;
5745 return *StaticValue;
5749 assert(StaticValue);
5750 return *StaticValue;
5756class StructFieldAccessVisitor
5758 bool AddrOfSeen =
false;
5761 const Expr *ArrayIndex =
nullptr;
5778 ArrayIndex = E->
getIdx();
5782 const Expr *VisitCastExpr(
const CastExpr *E) {
5787 const Expr *VisitParenExpr(
const ParenExpr *E) {
5790 const Expr *VisitUnaryAddrOf(
const UnaryOperator *E) {
5794 const Expr *VisitUnaryDeref(
const UnaryOperator *E) {
5798 const Expr *VisitBinaryOperator(
const BinaryOperator *Op) {
5805 const Expr **OutArrayIndex,
5807 StructFieldAccessVisitor
V;
5810 *OutArrayIndex =
V.ArrayIndex;
5811 if (OutArrayElementTy)
5812 *OutArrayElementTy =
V.ArrayElementTy;
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 bool IsDecompositionDeclRefExpr(const Expr *E)
Helper to determine wether E is a CXXConstructExpr constructing a DecompositionDecl.
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.
Result
Implement __builtin_bit_cast and related operations.
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)
C Language Family Type Representation.
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
static CanQualType getCanonicalType(QualType T)
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.
LangAS getDefaultOpenCLPointeeAddrSpace()
Returns default address space based on OpenCL version and enabled features.
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...
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
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const Stmt ** const_iterator
QualType getElementType() const
Return the effective 'element' type of this array section.
Expr * getBase()
Get base of the array section.
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
QualType getBaseType() const
Returns the effective 'type' of the base of this 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
static unsigned getNumSubExprs(AtomicOp Op)
Determine the number of arguments the specified atomic builtin should have.
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
static bool isCommaOp(Opcode Opc)
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...
BinaryOperatorKind Opcode
A binding in a decomposition declaration.
A fixed int type of a specified bitwidth.
SourceLocation getCaretLocation() const
const Stmt * getBody() const
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
bool isUnevaluated(unsigned ID) const
Returns true if this builtin does not perform the side-effects of its arguments.
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....
static CStyleCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize, bool HasFPFeatures)
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
SourceLocation getLParenLoc() const
Represents a call to a CUDA kernel function.
Represents a base class of a C++ class.
Represents binding an expression to a temporary.
CXXTemporary * getTemporary()
Represents a call to a C++ constructor.
Expr * getArg(unsigned Arg)
Return the specified argument.
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]).
const CXXDestructorDecl * getDestructor() const
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 unsigned sizeToAllocateForCallExprSubclass(unsigned SizeOfTrailingObjects)
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)
CastExpr(StmtClass SC, QualType ty, ExprValueKind VK, const CastKind kind, Expr *op, unsigned BasePathSize, bool HasFPFeatures)
const char * getCastKindName() const
SourceLocation getEnd() const
static CharUnits 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 ?
ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
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)
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumElementsFlattened() const
Returns the number of elements required to embed the matrix into a vector.
unsigned getFlattenedIndex(unsigned Row, unsigned Column, bool IsRowMajor=false) const
Returns the flattened index of a matrix element located at row Row, and column Column.
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.
NamedDecl * getDecl() const
AccessSpecifier getAccess() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
A reference to a declared variable, function, enum, etc.
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list.
void setDecl(ValueDecl *NewD)
static DeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasQualifier, bool HasFoundDecl, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Construct an empty declaration reference expression.
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...
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 a single C99 designator.
unsigned getArrayIndex() const
SourceRange getSourceRange() const LLVM_READONLY
bool isFieldDesignator() const
SourceLocation getBeginLoc() const LLVM_READONLY
struct FieldDesignatorInfo FieldInfo
A field designator, e.g., ".x".
bool isArrayRangeDesignator() const
FieldDecl * getFieldDecl() const
bool isArrayDesignator() const
SourceLocation getFieldLoc() const
const IdentifierInfo * getFieldName() const
SourceLocation getDotLoc() const
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
const Expr * getBase() const
IdentifierInfo * Accessor
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) 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 isConstantInitializer(ASTContext &Ctx, bool ForRef=false, const Expr **Culprit=nullptr) const
Returns true if this expression can be emitted to IR as a constant, and thus can be used as a constan...
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.
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...
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.
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.
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.
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
InitListExpr(const ASTContext &C, SourceLocation lbraceloc, ArrayRef< Expr * > initExprs, SourceLocation rbraceloc, bool isExplicit)
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() const
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.
bool containsDuplicateElements() const
containsDuplicateElements - Return true if any element access is repeated.
void getEncodedElementAccess(SmallVectorImpl< uint32_t > &Elts) const
getEncodedElementAccess - Encode the elements accessed into an llvm aggregate Constant of ConstantInt...
unsigned getNumElements() const
getNumElements - Get the number of components being selected.
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.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
ObjCBoxedExpr - used for generalized expression boxing.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
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
bool isExpressibleAsConstantInitializer() const
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
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)
const IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
FieldDecl * getField() const
For a field offsetof node, returns the field.
@ Identifier
A field in a dependent type, known only by its name.
Kind getKind() const
Determine what kind of offsetof node this is.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
static const OpaqueValueExpr * findInCopyConstruct(const Expr *expr)
Given an expression which invokes a copy constructor — i.e.
OpaqueValueExpr(SourceLocation Loc, QualType T, ExprValueKind VK, ExprObjectKind OK=OK_Ordinary, Expr *SourceExpr=nullptr)
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.
const Expr * getSubExpr() const
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
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
specific_decl_iterator< FieldDecl > field_iterator
field_iterator field_begin() const
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.
FileIDAndOffset getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.
StringRef getBufferData(FileID FID, bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID.
CharSourceRange getExpansionRange(SourceLocation Loc) const
Given a SourceLocation object, return the range of tokens covered by the expansion in the ultimate fi...
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
A trivial tuple used to represent a source range.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits
GenericSelectionExprBitfields GenericSelectionExprBits
InitListExprBitfields InitListExprBits
ParenListExprBitfields ParenListExprBits
StmtIterator child_iterator
Child Iterators: All subclasses must implement 'children' to permit easy iteration over the substatem...
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.
UnsignedOrNone findZeroCodeUnit(unsigned StartIndex=0) const
Scan the string literal contents for a code unit with value 0.
SourceLocation getStrTokenLoc(unsigned TokNum) const
Get one of the string literal token.
unsigned getLength() const
uint32_t getCodeUnit(size_t I) const
Return the code unit at the given position.
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
Return a source location that points to the specified byte of this string literal.
void outputString(raw_ostream &OS) const
Prints the contents of the string to OS.
StringRef getString() const
static StringLiteral * CreateEmpty(const ASTContext &Ctx, unsigned NumConcatenated, unsigned Length, unsigned CharByteWidth)
Construct an empty string literal.
unsigned getNumConcatenated() const
Get the number of string literal tokens that were concatenated in translation phase #6 to form this s...
unsigned getCharByteWidth() const
Represents the declaration of a struct/union/class/enum.
Exposes information about the current target.
A convenient class for passing around template argument information.
ArrayRef< TemplateArgumentLoc > arguments() const
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,...
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type.
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 isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
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 isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool isAnyPointerType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
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 statement that could possibly have a value and type.
Stmt(StmtClass SC, EmptyShell)
Construct an empty statement.
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 clang::Expr * ExprTy
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
bool Comp(InterpState &S)
1) Pops the value from the stack.
Top level wrappers for InstallAPI frontend operations.
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.
bool isa(CodeGen::Address addr)
LLVM_READONLY bool isPrintable(unsigned char c)
Return true if this character is an ASCII printable character; that is, a character that should take ...
const Expr * findStructFieldAccess(const Expr *E, const Expr **OutArrayIndex=nullptr, QualType *OutArrayElementTy=nullptr)
Walk E through parens, implicit casts, unary &/*, array subscripts and comma operators to find the he...
LLVM_READONLY auto escapeCStyle(CharT Ch) -> StringRef
Return C-style escaped string for special characters, or an empty string if there is no such mapping.
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.
std::pair< FileID, unsigned > FileIDAndOffset
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'.
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
Expr * IgnoreImplicitCastsExtraSingleStep(Expr *E)
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Result
The result type of a method or function.
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
Expr * IgnoreImplicitCastsSingleStep(Expr *E)
@ Dtor_Base
Base object dtor.
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)
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
Expr * IgnoreImplicitAsWrittenSingleStep(Expr *E)
Expr * IgnoreCastsSingleStep(Expr *E)
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
@ Full
Match, but we didn't check for full match.
U cast(CodeGen::Address addr)
Expr * IgnoreLValueCastsSingleStep(Expr *E)
bool isLambdaMethod(const DeclContext *DC)
ActionResult< Expr * > ExprResult
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,...