32 #include "llvm/Support/ErrorHandling.h" 33 #include "llvm/Support/raw_ostream.h" 36 using namespace clang;
44 if (
auto *BO = dyn_cast<BinaryOperator>(E)) {
45 if (BO->getOpcode() == BO_Comma) {
52 if (
auto *MTE = dyn_cast<MaterializeTemporaryExpr>(E)) {
53 E = MTE->GetTemporaryExpr();
74 return cast<CXXRecordDecl>(D);
84 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
85 if ((CE->getCastKind() == CK_DerivedToBase ||
86 CE->getCastKind() == CK_UncheckedDerivedToBase) &&
95 if (CE->getCastKind() == CK_NoOp) {
99 }
else if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
100 if (!ME->isArrow()) {
101 assert(ME->getBase()->getType()->isRecordType());
102 if (
FieldDecl *Field = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
103 if (!Field->isBitField() && !Field->getType()->isReferenceType()) {
110 }
else if (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
111 if (BO->isPtrMemOp()) {
112 assert(BO->getRHS()->isRValue());
118 }
else if (BO->getOpcode() == BO_Comma) {
119 CommaLHSs.push_back(BO->getLHS());
144 switch (UO->getOpcode()) {
146 return UO->getSubExpr()->isKnownToHaveBooleanValue();
157 return CE->getSubExpr()->isKnownToHaveBooleanValue();
160 switch (BO->getOpcode()) {
161 default:
return false;
176 return BO->getLHS()->isKnownToHaveBooleanValue() &&
177 BO->getRHS()->isKnownToHaveBooleanValue();
181 return BO->getRHS()->isKnownToHaveBooleanValue();
186 return CO->getTrueExpr()->isKnownToHaveBooleanValue() &&
187 CO->getFalseExpr()->isKnownToHaveBooleanValue();
199 template <
class E,
class T>
219 #define ABSTRACT_STMT(type) 220 #define STMT(type, base) \ 221 case Stmt::type##Class: break; 222 #define EXPR(type, base) \ 223 case Stmt::type##Class: return getExprLocImpl<type>(this, &type::getExprLoc); 224 #include "clang/AST/StmtNodes.inc" 226 llvm_unreachable(
"unknown expression kind");
238 bool &ValueDependent,
239 bool &InstantiationDependent) {
240 TypeDependent =
false;
241 ValueDependent =
false;
242 InstantiationDependent =
false;
255 TypeDependent =
true;
256 ValueDependent =
true;
257 InstantiationDependent =
true;
260 InstantiationDependent =
true;
268 TypeDependent =
true;
269 ValueDependent =
true;
270 InstantiationDependent =
true;
275 InstantiationDependent =
true;
279 if (isa<NonTypeTemplateParmDecl>(D)) {
280 ValueDependent =
true;
281 InstantiationDependent =
true;
292 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
294 Var->getType()->isLiteralType(Ctx) :
295 Var->getType()->isIntegralOrEnumerationType()) &&
296 (Var->getType().isConstQualified() ||
297 Var->getType()->isReferenceType())) {
298 if (
const Expr *Init = Var->getAnyInitializer())
299 if (Init->isValueDependent()) {
300 ValueDependent =
true;
301 InstantiationDependent =
true;
308 if (Var->isStaticDataMember() &&
309 Var->getDeclContext()->isDependentContext()) {
310 ValueDependent =
true;
311 InstantiationDependent =
true;
314 TypeDependent =
true;
324 ValueDependent =
true;
325 InstantiationDependent =
true;
329 void DeclRefExpr::computeDependence(
const ASTContext &Ctx) {
330 bool TypeDependent =
false;
331 bool ValueDependent =
false;
332 bool InstantiationDependent =
false;
334 ValueDependent, InstantiationDependent);
336 ExprBits.TypeDependent |= TypeDependent;
337 ExprBits.ValueDependent |= ValueDependent;
338 ExprBits.InstantiationDependent |= InstantiationDependent;
341 if (getDecl()->isParameterPack())
342 ExprBits.ContainsUnexpandedParameterPack =
true;
345 DeclRefExpr::DeclRefExpr(
const ASTContext &Ctx,
348 ValueDecl *D,
bool RefersToEnclosingVariableOrCapture,
353 :
Expr(DeclRefExprClass, T, VK,
OK_Ordinary,
false,
false,
false,
false),
357 new (getTrailingObjects<NestedNameSpecifierLoc>())
360 if (NNS->isInstantiationDependent())
361 ExprBits.InstantiationDependent =
true;
362 if (NNS->containsUnexpandedParameterPack())
363 ExprBits.ContainsUnexpandedParameterPack =
true;
367 *getTrailingObjects<NamedDecl *>() = FoundD;
369 = (TemplateArgs || TemplateKWLoc.
isValid()) ? 1 : 0;
371 RefersToEnclosingVariableOrCapture;
373 bool Dependent =
false;
374 bool InstantiationDependent =
false;
375 bool ContainsUnexpandedParameterPack =
false;
376 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
377 TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
378 Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
379 assert(!Dependent &&
"built a DeclRefExpr with dependent template args");
380 ExprBits.InstantiationDependent |= InstantiationDependent;
381 ExprBits.ContainsUnexpandedParameterPack |= ContainsUnexpandedParameterPack;
382 }
else if (TemplateKWLoc.
isValid()) {
383 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
388 computeDependence(Ctx);
395 bool RefersToEnclosingVariableOrCapture,
401 return Create(Context, QualifierLoc, TemplateKWLoc, D,
402 RefersToEnclosingVariableOrCapture,
404 T, VK, FoundD, TemplateArgs);
411 bool RefersToEnclosingVariableOrCapture,
421 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
425 QualifierLoc ? 1 : 0, FoundD ? 1 : 0,
426 HasTemplateKWAndArgsInfo ? 1 : 0,
427 TemplateArgs ? TemplateArgs->
size() : 0);
430 return new (Mem)
DeclRefExpr(Context, QualifierLoc, TemplateKWLoc, D,
431 RefersToEnclosingVariableOrCapture,
432 NameInfo, FoundD, TemplateArgs, T, VK);
438 bool HasTemplateKWAndArgsInfo,
439 unsigned NumTemplateArgs) {
440 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
444 HasQualifier ? 1 : 0, HasFoundDecl ? 1 : 0, HasTemplateKWAndArgsInfo,
452 return getQualifierLoc().getBeginLoc();
453 return getNameInfo().getLocStart();
456 if (hasExplicitTemplateArgs())
457 return getRAngleLoc();
458 return getNameInfo().getLocEnd();
464 FNTy->isDependentType(), FNTy->isDependentType(),
465 FNTy->isInstantiationDependentType(),
467 Loc(L),
Type(IT), FnName(SL) {}
470 return cast_or_null<StringLiteral>(FnName);
478 return "__FUNCTION__";
480 return "__FUNCDNAME__";
482 return "L__FUNCTION__";
484 return "__PRETTY_FUNCTION__";
486 return "__FUNCSIG__";
490 llvm_unreachable(
"Unknown ident type for PredefinedExpr");
499 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(CurrentDecl)) {
500 std::unique_ptr<MangleContext> MC;
503 if (MC->shouldMangleDeclName(ND)) {
505 llvm::raw_svector_ostream Out(Buffer);
511 MC->mangleName(ND, Out);
513 if (!Buffer.empty() && Buffer.front() ==
'\01')
514 return Buffer.substr(1);
517 return ND->getIdentifier()->getName();
521 if (isa<BlockDecl>(CurrentDecl)) {
526 if (DC->isFileContext())
530 llvm::raw_svector_ostream Out(Buffer);
531 if (
auto *DCBlock = dyn_cast<BlockDecl>(DC))
534 else if (
auto *DCDecl = dyn_cast<Decl>(DC))
538 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
540 return FD->getNameAsString();
543 llvm::raw_svector_ostream Out(Name);
554 llvm::raw_string_ostream POut(Proto);
561 if (FD->hasWrittenPrototype())
562 FT = dyn_cast<FunctionProtoType>(AFT);
566 case CC_C: POut <<
"__cdecl ";
break;
577 FD->printQualifiedName(POut, Policy);
581 for (
unsigned i = 0, e = Decl->
getNumParams(); i != e; ++i) {
586 if (FT->isVariadic()) {
587 if (FD->getNumParams()) POut <<
", ";
597 assert(FT &&
"We must have a written prototype in this case.");
600 if (FT->isVolatile())
612 while (Ctx && isa<NamedDecl>(Ctx)) {
616 Specs.push_back(Spec);
620 std::string TemplateParams;
621 llvm::raw_string_ostream TOut(TemplateParams);
622 for (SpecsTy::reverse_iterator I = Specs.rbegin(), E = Specs.rend();
625 = (*I)->getSpecializedTemplate()->getTemplateParameters();
627 assert(Params->
size() == Args.
size());
628 for (
unsigned i = 0, numParams = Params->
size(); i != numParams; ++i) {
630 if (Param.empty())
continue;
631 TOut << Param <<
" = ";
638 = FD->getTemplateSpecializationInfo();
643 assert(Params->
size() == Args->
size());
644 for (
unsigned i = 0, e = Params->
size(); i != e; ++i) {
646 if (Param.empty())
continue;
647 TOut << Param <<
" = ";
654 if (!TemplateParams.empty()) {
656 TemplateParams.resize(TemplateParams.size() - 2);
657 POut <<
" [" << TemplateParams <<
"]";
666 if (isa<CXXMethodDecl>(FD) &&
667 cast<CXXMethodDecl>(FD)->getParent()->isLambda())
668 Proto =
"auto " + Proto;
669 else if (FT && FT->getReturnType()->getAs<
DecltypeType>())
674 else if (!isa<CXXConstructorDecl>(FD) && !isa<CXXDestructorDecl>(FD))
679 return Name.str().str();
681 if (
const CapturedDecl *CD = dyn_cast<CapturedDecl>(CurrentDecl)) {
685 if (DC->isFunctionOrMethod() && (DC->getDeclKind() != Decl::Captured)) {
689 llvm_unreachable(
"CapturedDecl not inside a function or method");
691 if (
const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(CurrentDecl)) {
693 llvm::raw_svector_ostream Out(Name);
694 Out << (MD->isInstanceMethod() ?
'-' :
'+');
703 dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext()))
704 Out <<
'(' << *CID <<
')';
707 MD->getSelector().print(Out);
710 return Name.str().str();
712 if (isa<TranslationUnitDecl>(CurrentDecl) && IT ==
PrettyFunction) {
720 const llvm::APInt &Val) {
724 BitWidth = Val.getBitWidth();
725 unsigned NumWords = Val.getNumWords();
726 const uint64_t* Words = Val.getRawData();
728 pVal =
new (
C) uint64_t[NumWords];
729 std::copy(Words, Words + NumWords, pVal);
730 }
else if (NumWords == 1)
736 IntegerLiteral::IntegerLiteral(
const ASTContext &
C,
const llvm::APInt &V,
741 assert(type->
isIntegerType() &&
"Illegal type in IntegerLiteral");
743 "Integer type is not the correct size for constant.");
758 FloatingLiteral::FloatingLiteral(
const ASTContext &
C,
const llvm::APFloat &V,
761 false,
false), Loc(L) {
762 setSemantics(V.getSemantics());
768 :
Expr(FloatingLiteralClass, Empty) {
787 return llvm::APFloat::IEEEhalf();
789 return llvm::APFloat::IEEEsingle();
791 return llvm::APFloat::IEEEdouble();
793 return llvm::APFloat::x87DoubleExtended();
795 return llvm::APFloat::IEEEquad();
797 return llvm::APFloat::PPCDoubleDouble();
799 llvm_unreachable(
"Unrecognised floating semantics");
803 if (&Sem == &llvm::APFloat::IEEEhalf())
805 else if (&Sem == &llvm::APFloat::IEEEsingle())
807 else if (&Sem == &llvm::APFloat::IEEEdouble())
809 else if (&Sem == &llvm::APFloat::x87DoubleExtended())
811 else if (&Sem == &llvm::APFloat::IEEEquad())
813 else if (&Sem == &llvm::APFloat::PPCDoubleDouble())
816 llvm_unreachable(
"Unknown floating semantics");
825 V.convert(llvm::APFloat::IEEEdouble(), llvm::APFloat::rmNearestTiesToEven,
827 return V.convertToDouble();
830 int StringLiteral::mapCharByteWidth(
TargetInfo const &target,StringKind k) {
831 int CharByteWidth = 0;
847 assert((CharByteWidth & 7) == 0 &&
"Assumes character size is byte multiple");
849 assert((CharByteWidth==1 || CharByteWidth==2 || CharByteWidth==4)
850 &&
"character byte widths supported are 1, 2, and 4 only");
851 return CharByteWidth;
859 "StringLiteral must be of constant array type!");
871 SL->TokLocs[0] = Loc[0];
872 SL->NumConcatenated = NumStrs;
875 memcpy(&SL->TokLocs[1], Loc+1,
sizeof(
SourceLocation)*(NumStrs-1));
885 SL->CharByteWidth = 0;
887 SL->NumConcatenated = NumStrs;
894 case Wide: OS <<
'L';
break;
895 case UTF8: OS <<
"u8";
break;
896 case UTF16: OS <<
'u';
break;
897 case UTF32: OS <<
'U';
break;
900 static const char Hex[] =
"0123456789ABCDEF";
902 unsigned LastSlashX = getLength();
903 for (
unsigned I = 0, N = getLength(); I != N; ++I) {
904 switch (uint32_t Char = getCodeUnit(I)) {
910 if (
getKind() == UTF16 && I != N - 1 && Char >= 0xd800 &&
912 uint32_t Trail = getCodeUnit(I + 1);
913 if (Trail >= 0xdc00 && Trail <= 0xdfff) {
914 Char = 0x10000 + ((Char - 0xd800) << 10) + (Trail - 0xdc00);
924 (Char >= 0xd800 && Char <= 0xdfff) || Char >= 0x110000) {
928 while ((Char >> Shift) == 0)
930 for (; Shift >= 0; Shift -= 4)
931 OS << Hex[(Char >> Shift) & 15];
938 << Hex[(Char >> 20) & 15]
939 << Hex[(Char >> 16) & 15];
942 OS << Hex[(Char >> 12) & 15]
943 << Hex[(Char >> 8) & 15]
944 << Hex[(Char >> 4) & 15]
945 << Hex[(Char >> 0) & 15];
951 if (LastSlashX + 1 == I) {
953 case '0':
case '1':
case '2':
case '3':
case '4':
954 case '5':
case '6':
case '7':
case '8':
case '9':
955 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
956 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
961 assert(Char <= 0xff &&
962 "Characters above 0xff should already have been handled.");
968 << (char)(
'0' + ((Char >> 6) & 7))
969 << (char)(
'0' + ((Char >> 3) & 7))
970 << (char)(
'0' + ((Char >> 0) & 7));
973 case '\\': OS <<
"\\\\";
break;
974 case '"': OS <<
"\\\"";
break;
975 case '\a': OS <<
"\\a";
break;
976 case '\b': OS <<
"\\b";
break;
977 case '\f': OS <<
"\\f";
break;
978 case '\n': OS <<
"\\n";
break;
979 case '\r': OS <<
"\\r";
break;
980 case '\t': OS <<
"\\t";
break;
981 case '\v': OS <<
"\\v";
break;
992 this->IsPascal = IsPascal;
995 assert((Str.size()%CharByteWidth == 0)
996 &&
"size of data must be multiple of CharByteWidth");
997 Length = Str.size()/CharByteWidth;
999 switch(CharByteWidth) {
1001 char *AStrData =
new (
C)
char[Length];
1002 std::memcpy(AStrData,Str.data(),Length*
sizeof(*AStrData));
1003 StrData.asChar = AStrData;
1007 uint16_t *AStrData =
new (
C) uint16_t[Length];
1008 std::memcpy(AStrData,Str.data(),Length*
sizeof(*AStrData));
1009 StrData.asUInt16 = AStrData;
1013 uint32_t *AStrData =
new (
C) uint32_t[Length];
1014 std::memcpy(AStrData,Str.data(),Length*
sizeof(*AStrData));
1015 StrData.asUInt32 = AStrData;
1019 llvm_unreachable(
"unsupported CharByteWidth");
1042 const TargetInfo &Target,
unsigned *StartToken,
1043 unsigned *StartTokenByteOffset)
const {
1045 "Only narrow string literals are currently supported");
1050 unsigned StringOffset = 0;
1052 TokNo = *StartToken;
1053 if (StartTokenByteOffset) {
1054 StringOffset = *StartTokenByteOffset;
1055 ByteNo -= StringOffset;
1058 assert(TokNo < getNumConcatenated() &&
"Invalid byte number!");
1067 std::pair<FileID, unsigned> LocInfo =
1069 bool Invalid =
false;
1070 StringRef Buffer = SM.
getBufferData(LocInfo.first, &Invalid);
1072 if (StartTokenByteOffset !=
nullptr)
1073 *StartTokenByteOffset = StringOffset;
1074 if (StartToken !=
nullptr)
1075 *StartToken = TokNo;
1076 return StrTokSpellingLoc;
1079 const char *StrData = Buffer.data()+LocInfo.second;
1083 Buffer.begin(), StrData, Buffer.end());
1085 TheLexer.LexFromRawLexer(TheTok);
1092 if (ByteNo < TokNumBytes ||
1093 (ByteNo == TokNumBytes && TokNo == getNumConcatenated() - 1)) {
1098 if (StartTokenByteOffset !=
nullptr)
1099 *StartTokenByteOffset = StringOffset;
1100 if (StartToken !=
nullptr)
1101 *StartToken = TokNo;
1106 StringOffset += TokNumBytes;
1108 ByteNo -= TokNumBytes;
1118 #define UNARY_OPERATION(Name, Spelling) case UO_##Name: return Spelling; 1119 #include "clang/AST/OperationKinds.def" 1121 llvm_unreachable(
"Unknown unary operator");
1127 default: llvm_unreachable(
"No unary operator for overloaded function");
1128 case OO_PlusPlus:
return Postfix ? UO_PostInc : UO_PreInc;
1129 case OO_MinusMinus:
return Postfix ? UO_PostDec : UO_PreDec;
1130 case OO_Amp:
return UO_AddrOf;
1131 case OO_Star:
return UO_Deref;
1132 case OO_Plus:
return UO_Plus;
1133 case OO_Minus:
return UO_Minus;
1134 case OO_Tilde:
return UO_Not;
1135 case OO_Exclaim:
return UO_LNot;
1136 case OO_Coawait:
return UO_Coawait;
1142 case UO_PostInc:
case UO_PreInc:
return OO_PlusPlus;
1143 case UO_PostDec:
case UO_PreDec:
return OO_MinusMinus;
1144 case UO_AddrOf:
return OO_Amp;
1145 case UO_Deref:
return OO_Star;
1146 case UO_Plus:
return OO_Plus;
1147 case UO_Minus:
return OO_Minus;
1148 case UO_Not:
return OO_Tilde;
1149 case UO_LNot:
return OO_Exclaim;
1150 case UO_Coawait:
return OO_Coawait;
1166 NumArgs(args.size()) {
1168 unsigned NumPreArgs = preargs.size();
1169 SubExprs =
new (
C)
Stmt *[args.size()+PREARGS_START+NumPreArgs];
1171 for (
unsigned i = 0; i != NumPreArgs; ++i) {
1172 updateDependenciesFromArg(preargs[i]);
1173 SubExprs[i+PREARGS_START] = preargs[i];
1175 for (
unsigned i = 0; i != args.size(); ++i) {
1176 updateDependenciesFromArg(args[i]);
1177 SubExprs[i+PREARGS_START+NumPreArgs] = args[i];
1181 RParenLoc = rparenloc;
1199 :
Expr(SC, Empty), SubExprs(nullptr), NumArgs(0) {
1201 SubExprs =
new (
C)
Stmt*[PREARGS_START+NumPreArgs]();
1205 void CallExpr::updateDependenciesFromArg(
Expr *Arg) {
1211 ExprBits.InstantiationDependent =
true;
1213 ExprBits.ContainsUnexpandedParameterPack =
true;
1228 = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE)) {
1234 if (BO->isPtrMemOp())
1236 }
else if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(CEE)) {
1237 if (UO->getOpcode() == UO_Deref)
1240 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE))
1241 return DRE->getDecl();
1242 if (
MemberExpr *ME = dyn_cast<MemberExpr>(CEE))
1243 return ME->getMemberDecl();
1257 this->NumArgs = NumArgs;
1263 Stmt **NewSubExprs =
new (
C)
Stmt*[NumArgs+PREARGS_START+NumPreArgs];
1265 for (
unsigned i = 0; i !=
getNumArgs()+PREARGS_START+NumPreArgs; ++i)
1266 NewSubExprs[i] = SubExprs[i];
1268 for (
unsigned i =
getNumArgs()+PREARGS_START+NumPreArgs;
1269 i != NumArgs+PREARGS_START+NumPreArgs; ++i)
1270 NewSubExprs[i] =
nullptr;
1273 SubExprs = NewSubExprs;
1274 this->NumArgs = NumArgs;
1315 if (isa<CXXPseudoDestructorExpr>(Callee->
IgnoreParens()))
1327 if (isa<CXXOperatorCallExpr>(
this))
1328 return cast<CXXOperatorCallExpr>(
this)->
getLocStart();
1336 if (isa<CXXOperatorCallExpr>(
this))
1337 return cast<CXXOperatorCallExpr>(
this)->
getLocEnd();
1352 totalSizeToAlloc<OffsetOfNode, Expr *>(comps.size(), exprs.size()));
1354 return new (Mem)
OffsetOfExpr(C, type, OperatorLoc, tsi, comps, exprs,
1359 unsigned numComps,
unsigned numExprs) {
1361 C.
Allocate(totalSizeToAlloc<OffsetOfNode, Expr *>(numComps, numExprs));
1374 OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
1375 NumComps(comps.size()), NumExprs(exprs.size())
1377 for (
unsigned i = 0; i != comps.size(); ++i) {
1378 setComponent(i, comps[i]);
1381 for (
unsigned i = 0; i != exprs.size(); ++i) {
1385 ExprBits.ContainsUnexpandedParameterPack =
true;
1387 setIndexExpr(i, exprs[i]);
1394 return getField()->getIdentifier();
1407 OpLoc(op), RParenLoc(rp) {
1419 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
1421 else if (
const auto *ME = dyn_cast<MemberExpr>(E))
1422 D = ME->getMemberDecl();
1426 if (I->isAlignmentDependent()) {
1444 bool hasQualOrFound = (QualifierLoc ||
1445 founddecl.
getDecl() != memberdecl ||
1448 bool HasTemplateKWAndArgsInfo = targs || TemplateKWLoc.
isValid();
1452 HasTemplateKWAndArgsInfo ? 1 : 0,
1453 targs ? targs->
size() : 0);
1457 MemberExpr(base, isarrow, OperatorLoc, memberdecl, nameinfo, ty, vk, ok);
1459 if (hasQualOrFound) {
1466 else if (QualifierLoc &&
1470 E->HasQualifierOrFoundDecl =
true;
1472 MemberExprNameQualifier *NQ =
1473 E->getTrailingObjects<MemberExprNameQualifier>();
1478 E->HasTemplateKWAndArgsInfo = (targs || TemplateKWLoc.
isValid());
1481 bool Dependent =
false;
1482 bool InstantiationDependent =
false;
1483 bool ContainsUnexpandedParameterPack =
false;
1484 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1486 Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
1487 if (InstantiationDependent)
1489 }
else if (TemplateKWLoc.
isValid()) {
1490 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1498 if (isImplicitAccess()) {
1500 return getQualifierLoc().getBeginLoc();
1508 return BaseStartLoc;
1513 if (hasExplicitTemplateArgs())
1514 EndLoc = getRAngleLoc();
1516 EndLoc = getBase()->getLocEnd();
1520 bool CastExpr::CastConsistency()
const {
1521 switch (getCastKind()) {
1522 case CK_DerivedToBase:
1523 case CK_UncheckedDerivedToBase:
1524 case CK_DerivedToBaseMemberPointer:
1525 case CK_BaseToDerived:
1526 case CK_BaseToDerivedMemberPointer:
1527 assert(!path_empty() &&
"Cast kind should have a base path!");
1530 case CK_CPointerToObjCPointerCast:
1531 assert(
getType()->isObjCObjectPointerType());
1532 assert(getSubExpr()->
getType()->isPointerType());
1533 goto CheckNoBasePath;
1535 case CK_BlockPointerToObjCPointerCast:
1536 assert(
getType()->isObjCObjectPointerType());
1537 assert(getSubExpr()->
getType()->isBlockPointerType());
1538 goto CheckNoBasePath;
1540 case CK_ReinterpretMemberPointer:
1541 assert(
getType()->isMemberPointerType());
1542 assert(getSubExpr()->
getType()->isMemberPointerType());
1543 goto CheckNoBasePath;
1549 if (!
getType()->isPointerType()) {
1550 assert(
getType()->isObjCObjectPointerType() ==
1551 getSubExpr()->
getType()->isObjCObjectPointerType());
1552 assert(
getType()->isBlockPointerType() ==
1553 getSubExpr()->
getType()->isBlockPointerType());
1555 goto CheckNoBasePath;
1557 case CK_AnyPointerToBlockPointerCast:
1558 assert(
getType()->isBlockPointerType());
1559 assert(getSubExpr()->
getType()->isAnyPointerType() &&
1560 !getSubExpr()->
getType()->isBlockPointerType());
1561 goto CheckNoBasePath;
1563 case CK_CopyAndAutoreleaseBlockObject:
1564 assert(
getType()->isBlockPointerType());
1565 assert(getSubExpr()->
getType()->isBlockPointerType());
1566 goto CheckNoBasePath;
1568 case CK_FunctionToPointerDecay:
1569 assert(
getType()->isPointerType());
1570 assert(getSubExpr()->
getType()->isFunctionType());
1571 goto CheckNoBasePath;
1573 case CK_AddressSpaceConversion:
1574 assert(
getType()->isPointerType() ||
getType()->isBlockPointerType());
1575 assert(getSubExpr()->
getType()->isPointerType() ||
1576 getSubExpr()->
getType()->isBlockPointerType());
1577 assert(
getType()->getPointeeType().getAddressSpace() !=
1578 getSubExpr()->
getType()->getPointeeType().getAddressSpace());
1583 case CK_ArrayToPointerDecay:
1584 case CK_NullToMemberPointer:
1585 case CK_NullToPointer:
1586 case CK_ConstructorConversion:
1587 case CK_IntegralToPointer:
1588 case CK_PointerToIntegral:
1590 case CK_VectorSplat:
1591 case CK_IntegralCast:
1592 case CK_BooleanToSignedIntegral:
1593 case CK_IntegralToFloating:
1594 case CK_FloatingToIntegral:
1595 case CK_FloatingCast:
1596 case CK_ObjCObjectLValueCast:
1597 case CK_FloatingRealToComplex:
1598 case CK_FloatingComplexToReal:
1599 case CK_FloatingComplexCast:
1600 case CK_FloatingComplexToIntegralComplex:
1601 case CK_IntegralRealToComplex:
1602 case CK_IntegralComplexToReal:
1603 case CK_IntegralComplexCast:
1604 case CK_IntegralComplexToFloatingComplex:
1605 case CK_ARCProduceObject:
1606 case CK_ARCConsumeObject:
1607 case CK_ARCReclaimReturnedObject:
1608 case CK_ARCExtendBlockObject:
1609 case CK_ZeroToOCLEvent:
1610 case CK_ZeroToOCLQueue:
1611 case CK_IntToOCLSampler:
1613 goto CheckNoBasePath;
1616 case CK_LValueToRValue:
1618 case CK_AtomicToNonAtomic:
1619 case CK_NonAtomicToAtomic:
1620 case CK_PointerToBoolean:
1621 case CK_IntegralToBoolean:
1622 case CK_FloatingToBoolean:
1623 case CK_MemberPointerToBoolean:
1624 case CK_FloatingComplexToBoolean:
1625 case CK_IntegralComplexToBoolean:
1626 case CK_LValueBitCast:
1627 case CK_UserDefinedConversion:
1628 case CK_BuiltinFnToFnPtr:
1630 assert(path_empty() &&
"Cast kind should not have a base path!");
1637 switch (getCastKind()) {
1638 #define CAST_OPERATION(Name) case CK_##Name: return #Name; 1639 #include "clang/AST/OperationKinds.def" 1641 llvm_unreachable(
"Unhandled cast kind!");
1648 = dyn_cast<MaterializeTemporaryExpr>(expr))
1649 expr = Materialize->GetTemporaryExpr();
1653 expr = Binder->getSubExpr();
1660 Expr *SubExpr =
nullptr;
1663 SubExpr = skipImplicitTemporary(E->
getSubExpr());
1669 skipImplicitTemporary(cast<CXXConstructExpr>(SubExpr)->getArg(0));
1670 else if (E->
getCastKind() == CK_UserDefinedConversion) {
1671 assert((isa<CXXMemberCallExpr>(SubExpr) ||
1672 isa<BlockExpr>(SubExpr)) &&
1673 "Unexpected SubExpr for CK_UserDefinedConversion.");
1674 if (isa<CXXMemberCallExpr>(SubExpr))
1675 SubExpr = cast<CXXMemberCallExpr>(SubExpr)->getImplicitObjectArgument();
1680 }
while ((E = dyn_cast<ImplicitCastExpr>(SubExpr)));
1687 #define ABSTRACT_STMT(x) 1688 #define CASTEXPR(Type, Base) \ 1689 case Stmt::Type##Class: \ 1690 return static_cast<Type *>(this)->getTrailingObjects<CXXBaseSpecifier *>(); 1691 #define STMT(Type, Base) 1692 #include "clang/AST/StmtNodes.inc" 1694 llvm_unreachable(
"non-cast expressions not possible here");
1701 return getTargetFieldForToUnionCast(RD, opType);
1709 Field != FieldEnd; ++Field) {
1711 !Field->isUnnamedBitfield()) {
1722 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1723 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1727 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1733 unsigned PathSize) {
1734 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1744 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1745 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1747 new (Buffer)
CStyleCastExpr(T, VK, K, Op, PathSize, WrittenTy, L, R);
1749 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1755 unsigned PathSize) {
1756 void *Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1764 #define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling; 1765 #include "clang/AST/OperationKinds.def" 1767 llvm_unreachable(
"Invalid OpCode!");
1773 default: llvm_unreachable(
"Not an overloadable binary operator");
1774 case OO_Plus:
return BO_Add;
1775 case OO_Minus:
return BO_Sub;
1776 case OO_Star:
return BO_Mul;
1777 case OO_Slash:
return BO_Div;
1778 case OO_Percent:
return BO_Rem;
1779 case OO_Caret:
return BO_Xor;
1780 case OO_Amp:
return BO_And;
1781 case OO_Pipe:
return BO_Or;
1782 case OO_Equal:
return BO_Assign;
1783 case OO_Spaceship:
return BO_Cmp;
1784 case OO_Less:
return BO_LT;
1785 case OO_Greater:
return BO_GT;
1786 case OO_PlusEqual:
return BO_AddAssign;
1787 case OO_MinusEqual:
return BO_SubAssign;
1788 case OO_StarEqual:
return BO_MulAssign;
1789 case OO_SlashEqual:
return BO_DivAssign;
1790 case OO_PercentEqual:
return BO_RemAssign;
1791 case OO_CaretEqual:
return BO_XorAssign;
1792 case OO_AmpEqual:
return BO_AndAssign;
1793 case OO_PipeEqual:
return BO_OrAssign;
1794 case OO_LessLess:
return BO_Shl;
1795 case OO_GreaterGreater:
return BO_Shr;
1796 case OO_LessLessEqual:
return BO_ShlAssign;
1797 case OO_GreaterGreaterEqual:
return BO_ShrAssign;
1798 case OO_EqualEqual:
return BO_EQ;
1799 case OO_ExclaimEqual:
return BO_NE;
1800 case OO_LessEqual:
return BO_LE;
1801 case OO_GreaterEqual:
return BO_GE;
1802 case OO_AmpAmp:
return BO_LAnd;
1803 case OO_PipePipe:
return BO_LOr;
1804 case OO_Comma:
return BO_Comma;
1805 case OO_ArrowStar:
return BO_PtrMemI;
1812 OO_Star, OO_Slash, OO_Percent,
1814 OO_LessLess, OO_GreaterGreater,
1816 OO_Less, OO_Greater, OO_LessEqual, OO_GreaterEqual,
1817 OO_EqualEqual, OO_ExclaimEqual,
1823 OO_Equal, OO_StarEqual,
1824 OO_SlashEqual, OO_PercentEqual,
1825 OO_PlusEqual, OO_MinusEqual,
1826 OO_LessLessEqual, OO_GreaterGreaterEqual,
1827 OO_AmpEqual, OO_CaretEqual,
1831 return OverOps[Opc];
1870 InitExprs(C, initExprs.size()),
1871 LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(nullptr,
true)
1874 for (
unsigned I = 0; I != initExprs.size(); ++I) {
1880 ExprBits.InstantiationDependent =
true;
1882 ExprBits.ContainsUnexpandedParameterPack =
true;
1885 InitExprs.
insert(C, InitExprs.
end(), initExprs.begin(), initExprs.end());
1889 if (NumInits > InitExprs.
size())
1890 InitExprs.
reserve(C, NumInits);
1894 InitExprs.
resize(C, NumInits,
nullptr);
1898 if (Init >= InitExprs.
size()) {
1899 InitExprs.
insert(C, InitExprs.
end(), Init - InitExprs.
size() + 1,
nullptr);
1904 Expr *
Result = cast_or_null<Expr>(InitExprs[Init]);
1911 ArrayFillerOrUnionFieldInit = filler;
1914 for (
unsigned i = 0, e =
getNumInits(); i != e; ++i)
1915 if (inits[i] ==
nullptr)
1930 return isa<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init);
1934 assert(
isSemanticForm() &&
"syntactic form never semantically transparent");
1938 assert(
getNumInits() == 1 &&
"multiple inits in glvalue init list");
1957 assert(
isSyntacticForm() &&
"only test syntactic form as zero initializer");
1964 return Lit && Lit->
getValue() == 0;
1969 return SyntacticForm->getLocStart();
1974 E = InitExprs.
end();
1977 Beg = S->getLocStart();
1987 return SyntacticForm->getLocEnd();
1992 E = InitExprs.
rend();
1995 End = S->getLocEnd();
2007 return cast<BlockPointerType>(
getType())
2012 return TheBlock->getCaretLocation();
2015 return TheBlock->getBody();
2018 return TheBlock->getBody();
2046 case ParenExprClass:
2047 return cast<ParenExpr>(
this)->getSubExpr()->
2049 case GenericSelectionExprClass:
2050 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
2052 case ChooseExprClass:
2053 return cast<ChooseExpr>(
this)->getChosenSubExpr()->
2055 case UnaryOperatorClass: {
2078 .isVolatileQualified())
2089 case BinaryOperatorClass: {
2101 if (IE->getValue() == 0)
2120 case CompoundAssignOperatorClass:
2121 case VAArgExprClass:
2122 case AtomicExprClass:
2125 case ConditionalOperatorClass: {
2137 case MemberExprClass:
2139 Loc = cast<MemberExpr>(
this)->getMemberLoc();
2141 R2 = cast<MemberExpr>(
this)->getBase()->getSourceRange();
2144 case ArraySubscriptExprClass:
2146 Loc = cast<ArraySubscriptExpr>(
this)->getRBracketLoc();
2147 R1 = cast<ArraySubscriptExpr>(
this)->getLHS()->getSourceRange();
2148 R2 = cast<ArraySubscriptExpr>(
this)->getRHS()->getSourceRange();
2151 case CXXOperatorCallExprClass: {
2163 case OO_ExclaimEqual:
2166 case OO_GreaterEqual:
2181 case CXXMemberCallExprClass:
2182 case UserDefinedLiteralClass: {
2184 const CallExpr *CE = cast<CallExpr>(
this);
2188 : FD->hasAttr<WarnUnusedResultAttr>();
2195 if (HasWarnUnusedResultAttr ||
2196 FD->hasAttr<PureAttr>() || FD->hasAttr<ConstAttr>()) {
2211 case UnresolvedLookupExprClass:
2212 case CXXUnresolvedConstructExprClass:
2215 case CXXTemporaryObjectExprClass:
2216 case CXXConstructExprClass: {
2218 if (Type->hasAttr<WarnUnusedAttr>()) {
2228 case ObjCMessageExprClass: {
2241 if (MD->hasAttr<WarnUnusedResultAttr>()) {
2250 case ObjCPropertyRefExprClass:
2256 case PseudoObjectExprClass: {
2270 case StmtExprClass: {
2276 const CompoundStmt *CS = cast<StmtExpr>(
this)->getSubStmt();
2279 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2281 if (
const Expr *E = dyn_cast<Expr>(
Label->getSubStmt()))
2282 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2288 Loc = cast<StmtExpr>(
this)->getLParenLoc();
2292 case CXXFunctionalCastExprClass:
2293 case CStyleCastExprClass: {
2296 const CastExpr *CE = cast<CastExpr>(
this);
2302 if (!(DRE && isa<VarDecl>(DRE->
getDecl()) &&
2303 cast<VarDecl>(DRE->
getDecl())->hasLocalStorage()) &&
2314 if (CE->
getCastKind() == CK_ConstructorConversion)
2319 dyn_cast<CXXFunctionalCastExpr>(
this)) {
2320 Loc = CXXCE->getLocStart();
2321 R1 = CXXCE->getSubExpr()->getSourceRange();
2329 case ImplicitCastExprClass: {
2330 const CastExpr *ICE = cast<ImplicitCastExpr>(
this);
2339 case CXXDefaultArgExprClass:
2340 return (cast<CXXDefaultArgExpr>(
this)
2342 case CXXDefaultInitExprClass:
2343 return (cast<CXXDefaultInitExpr>(
this)
2346 case CXXNewExprClass:
2349 case CXXDeleteExprClass:
2351 case MaterializeTemporaryExprClass:
2352 return cast<MaterializeTemporaryExpr>(
this)->GetTemporaryExpr()
2353 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2354 case CXXBindTemporaryExprClass:
2355 return cast<CXXBindTemporaryExpr>(
this)->getSubExpr()
2356 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2357 case ExprWithCleanupsClass:
2358 return cast<ExprWithCleanups>(
this)->getSubExpr()
2359 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2370 case ObjCIvarRefExprClass:
2372 case Expr::UnaryOperatorClass:
2373 return cast<UnaryOperator>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2374 case ImplicitCastExprClass:
2375 return cast<ImplicitCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2376 case MaterializeTemporaryExprClass:
2377 return cast<MaterializeTemporaryExpr>(E)->GetTemporaryExpr()
2378 ->isOBJCGCCandidate(Ctx);
2379 case CStyleCastExprClass:
2380 return cast<CStyleCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2381 case DeclRefExprClass: {
2382 const Decl *D = cast<DeclRefExpr>(E)->getDecl();
2384 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2385 if (VD->hasGlobalStorage())
2395 case MemberExprClass: {
2399 case ArraySubscriptExprClass:
2400 return cast<ArraySubscriptExpr>(E)->getBase()->isOBJCGCCandidate(Ctx);
2418 if (
const MemberExpr *mem = dyn_cast<MemberExpr>(expr)) {
2419 assert(isa<CXXMethodDecl>(mem->getMemberDecl()));
2420 return mem->getMemberDecl()->getType();
2430 assert(isa<UnresolvedMemberExpr>(expr) || isa<CXXPseudoDestructorExpr>(expr));
2438 E =
P->getSubExpr();
2442 if (
P->getOpcode() == UO_Extension) {
2443 E =
P->getSubExpr();
2448 if (!
P->isResultDependent()) {
2449 E =
P->getResultExpr();
2454 if (!
P->isConditionDependent()) {
2455 E =
P->getChosenSubExpr();
2469 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2470 E =
P->getSubExpr();
2474 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2475 E = Materialize->GetTemporaryExpr();
2479 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2480 E = NTTP->getReplacement();
2490 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2491 E =
P->getSubExpr();
2495 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2496 E = Materialize->GetTemporaryExpr();
2500 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2501 E = NTTP->getReplacement();
2516 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2517 if (
P->getCastKind() == CK_LValueToRValue) {
2518 E =
P->getSubExpr();
2522 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2523 E = Materialize->GetTemporaryExpr();
2526 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2527 E = NTTP->getReplacement();
2539 if (
CastExpr *CE = dyn_cast<CastExpr>(E)) {
2540 if (CE->getCastKind() == CK_DerivedToBase ||
2541 CE->getCastKind() == CK_UncheckedDerivedToBase ||
2542 CE->getCastKind() == CK_NoOp) {
2543 E = CE->getSubExpr();
2557 E =
P->getSubExpr();
2561 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2562 E = Materialize->GetTemporaryExpr();
2566 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2567 E = NTTP->getReplacement();
2576 if (MCE->getMethodDecl() && isa<CXXConversionDecl>(MCE->getMethodDecl()))
2577 return MCE->getImplicitObjectArgument();
2590 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2593 Expr *SE =
P->getSubExpr();
2611 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2612 E = NTTP->getReplacement();
2621 const Expr *E =
this;
2623 E = M->GetTemporaryExpr();
2626 E = ICE->getSubExprAsWritten();
2628 return isa<CXXDefaultArgExpr>(E);
2635 E = M->GetTemporaryExpr();
2638 if (ICE->getCastKind() == CK_NoOp)
2639 E = ICE->getSubExpr();
2645 E = BE->getSubExpr();
2648 if (ICE->getCastKind() == CK_NoOp)
2649 E = ICE->getSubExpr();
2668 if (!isa<ObjCPropertyRefExpr>(E))
2676 if (isa<ImplicitCastExpr>(E)) {
2677 switch (cast<ImplicitCastExpr>(E)->getCastKind()) {
2678 case CK_DerivedToBase:
2679 case CK_UncheckedDerivedToBase:
2687 if (isa<MemberExpr>(E))
2691 if (BO->isPtrMemOp())
2695 if (isa<OpaqueValueExpr>(E))
2702 const Expr *E =
this;
2707 E =
Paren->getSubExpr();
2712 if (ICE->getCastKind() == CK_NoOp ||
2713 ICE->getCastKind() == CK_LValueToRValue ||
2714 ICE->getCastKind() == CK_DerivedToBase ||
2715 ICE->getCastKind() == CK_UncheckedDerivedToBase) {
2716 E = ICE->getSubExpr();
2721 if (
const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) {
2722 if (UnOp->getOpcode() == UO_Extension) {
2723 E = UnOp->getSubExpr();
2729 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2730 E = M->GetTemporaryExpr();
2737 if (
const CXXThisExpr *This = dyn_cast<CXXThisExpr>(E))
2738 return This->isImplicit();
2746 for (
unsigned I = 0; I < Exprs.size(); ++I)
2754 const Expr **Culprit)
const {
2775 case StringLiteralClass:
2776 case ObjCEncodeExprClass:
2778 case CXXTemporaryObjectExprClass:
2779 case CXXConstructExprClass: {
2788 assert(CE->
getNumArgs() == 1 &&
"trivial ctor with > 1 argument");
2794 case CompoundLiteralExprClass: {
2798 const Expr *Exp = cast<CompoundLiteralExpr>(
this)->getInitializer();
2801 case DesignatedInitUpdateExprClass: {
2806 case InitListExprClass: {
2810 for (
unsigned i = 0; i < numInits; i++) {
2818 unsigned ElementNo = 0;
2820 for (
const auto *Field : RD->
fields()) {
2826 if (Field->isUnnamedBitfield())
2831 if (Field->isBitField()) {
2833 llvm::APSInt ResultTmp;
2840 bool RefType = Field->getType()->isReferenceType();
2851 case ImplicitValueInitExprClass:
2852 case NoInitExprClass:
2854 case ParenExprClass:
2855 return cast<ParenExpr>(
this)->getSubExpr()
2856 ->isConstantInitializer(Ctx, IsForRef, Culprit);
2857 case GenericSelectionExprClass:
2858 return cast<GenericSelectionExpr>(
this)->getResultExpr()
2859 ->isConstantInitializer(Ctx, IsForRef, Culprit);
2860 case ChooseExprClass:
2861 if (cast<ChooseExpr>(
this)->isConditionDependent()) {
2866 return cast<ChooseExpr>(
this)->getChosenSubExpr()
2868 case UnaryOperatorClass: {
2874 case CXXFunctionalCastExprClass:
2875 case CXXStaticCastExprClass:
2876 case ImplicitCastExprClass:
2877 case CStyleCastExprClass:
2878 case ObjCBridgedCastExprClass:
2879 case CXXDynamicCastExprClass:
2880 case CXXReinterpretCastExprClass:
2881 case CXXConstCastExprClass: {
2882 const CastExpr *CE = cast<CastExpr>(
this);
2896 case MaterializeTemporaryExprClass:
2897 return cast<MaterializeTemporaryExpr>(
this)->GetTemporaryExpr()
2898 ->isConstantInitializer(Ctx,
false, Culprit);
2900 case SubstNonTypeTemplateParmExprClass:
2901 return cast<SubstNonTypeTemplateParmExpr>(
this)->getReplacement()
2902 ->isConstantInitializer(Ctx,
false, Culprit);
2903 case CXXDefaultArgExprClass:
2904 return cast<CXXDefaultArgExpr>(
this)->getExpr()
2905 ->isConstantInitializer(Ctx,
false, Culprit);
2906 case CXXDefaultInitExprClass:
2907 return cast<CXXDefaultInitExpr>(
this)->getExpr()
2908 ->isConstantInitializer(Ctx,
false, Culprit);
2924 const bool IncludePossibleEffects;
2928 explicit SideEffectFinder(
const ASTContext &Context,
bool IncludePossible)
2929 : Inherited(Context),
2930 IncludePossibleEffects(IncludePossible),
HasSideEffects(
false) { }
2934 void VisitExpr(
const Expr *E) {
2935 if (!HasSideEffects &&
2937 HasSideEffects =
true;
2943 bool IncludePossibleEffects)
const {
2947 if (!IncludePossibleEffects &&
getExprLoc().isMacroID())
2951 return IncludePossibleEffects;
2955 #define ABSTRACT_STMT(Type) 2956 #define STMT(Type, Base) case Type##Class: 2957 #define EXPR(Type, Base) 2958 #include "clang/AST/StmtNodes.inc" 2959 llvm_unreachable(
"unexpected Expr kind");
2961 case DependentScopeDeclRefExprClass:
2962 case CXXUnresolvedConstructExprClass:
2963 case CXXDependentScopeMemberExprClass:
2964 case UnresolvedLookupExprClass:
2965 case UnresolvedMemberExprClass:
2966 case PackExpansionExprClass:
2967 case SubstNonTypeTemplateParmPackExprClass:
2968 case FunctionParmPackExprClass:
2970 case CXXFoldExprClass:
2971 llvm_unreachable(
"shouldn't see dependent / unresolved nodes here");
2973 case DeclRefExprClass:
2974 case ObjCIvarRefExprClass:
2975 case PredefinedExprClass:
2976 case IntegerLiteralClass:
2977 case FloatingLiteralClass:
2978 case ImaginaryLiteralClass:
2979 case StringLiteralClass:
2980 case CharacterLiteralClass:
2981 case OffsetOfExprClass:
2982 case ImplicitValueInitExprClass:
2983 case UnaryExprOrTypeTraitExprClass:
2984 case AddrLabelExprClass:
2985 case GNUNullExprClass:
2986 case ArrayInitIndexExprClass:
2987 case NoInitExprClass:
2988 case CXXBoolLiteralExprClass:
2989 case CXXNullPtrLiteralExprClass:
2990 case CXXThisExprClass:
2991 case CXXScalarValueInitExprClass:
2992 case TypeTraitExprClass:
2993 case ArrayTypeTraitExprClass:
2994 case ExpressionTraitExprClass:
2995 case CXXNoexceptExprClass:
2996 case SizeOfPackExprClass:
2997 case ObjCStringLiteralClass:
2998 case ObjCEncodeExprClass:
2999 case ObjCBoolLiteralExprClass:
3000 case ObjCAvailabilityCheckExprClass:
3001 case CXXUuidofExprClass:
3002 case OpaqueValueExprClass:
3007 case CXXOperatorCallExprClass:
3008 case CXXMemberCallExprClass:
3009 case CUDAKernelCallExprClass:
3010 case UserDefinedLiteralClass: {
3014 const Decl *FD = cast<CallExpr>(
this)->getCalleeDecl();
3015 bool IsPure = FD && (FD->
hasAttr<ConstAttr>() || FD->
hasAttr<PureAttr>());
3016 if (IsPure || !IncludePossibleEffects)
3021 case BlockExprClass:
3022 case CXXBindTemporaryExprClass:
3023 if (!IncludePossibleEffects)
3027 case MSPropertyRefExprClass:
3028 case MSPropertySubscriptExprClass:
3029 case CompoundAssignOperatorClass:
3030 case VAArgExprClass:
3031 case AtomicExprClass:
3032 case CXXThrowExprClass:
3033 case CXXNewExprClass:
3034 case CXXDeleteExprClass:
3035 case CoawaitExprClass:
3036 case DependentCoawaitExprClass:
3037 case CoyieldExprClass:
3041 case StmtExprClass: {
3043 SideEffectFinder Finder(Ctx, IncludePossibleEffects);
3044 Finder.Visit(cast<StmtExpr>(
this)->getSubStmt());
3045 return Finder.hasSideEffects();
3048 case ExprWithCleanupsClass:
3049 if (IncludePossibleEffects)
3050 if (cast<ExprWithCleanups>(
this)->cleanupsHaveSideEffects())
3054 case ParenExprClass:
3055 case ArraySubscriptExprClass:
3056 case OMPArraySectionExprClass:
3057 case MemberExprClass:
3058 case ConditionalOperatorClass:
3059 case BinaryConditionalOperatorClass:
3060 case CompoundLiteralExprClass:
3061 case ExtVectorElementExprClass:
3062 case DesignatedInitExprClass:
3063 case DesignatedInitUpdateExprClass:
3064 case ArrayInitLoopExprClass:
3065 case ParenListExprClass:
3066 case CXXPseudoDestructorExprClass:
3067 case CXXStdInitializerListExprClass:
3068 case SubstNonTypeTemplateParmExprClass:
3069 case MaterializeTemporaryExprClass:
3070 case ShuffleVectorExprClass:
3071 case ConvertVectorExprClass:
3072 case AsTypeExprClass:
3076 case UnaryOperatorClass:
3077 if (cast<UnaryOperator>(
this)->isIncrementDecrementOp())
3081 case BinaryOperatorClass:
3082 if (cast<BinaryOperator>(
this)->isAssignmentOp())
3086 case InitListExprClass:
3089 if (E->HasSideEffects(Ctx, IncludePossibleEffects))
3093 case GenericSelectionExprClass:
3094 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
3097 case ChooseExprClass:
3098 return cast<ChooseExpr>(
this)->getChosenSubExpr()->HasSideEffects(
3099 Ctx, IncludePossibleEffects);
3101 case CXXDefaultArgExprClass:
3102 return cast<CXXDefaultArgExpr>(
this)->getExpr()->HasSideEffects(
3103 Ctx, IncludePossibleEffects);
3105 case CXXDefaultInitExprClass: {
3106 const FieldDecl *FD = cast<CXXDefaultInitExpr>(
this)->getField();
3108 return E->HasSideEffects(Ctx, IncludePossibleEffects);
3113 case CXXDynamicCastExprClass: {
3121 case ImplicitCastExprClass:
3122 case CStyleCastExprClass:
3123 case CXXStaticCastExprClass:
3124 case CXXReinterpretCastExprClass:
3125 case CXXConstCastExprClass:
3126 case CXXFunctionalCastExprClass: {
3131 if (!IncludePossibleEffects)
3134 const CastExpr *CE = cast<CastExpr>(
this);
3141 case CXXTypeidExprClass:
3144 return cast<CXXTypeidExpr>(
this)->isPotentiallyEvaluated();
3146 case CXXConstructExprClass:
3147 case CXXTemporaryObjectExprClass: {
3156 case CXXInheritedCtorInitExprClass: {
3157 const auto *ICIE = cast<CXXInheritedCtorInitExpr>(
this);
3158 if (!ICIE->getConstructor()->isTrivial() && IncludePossibleEffects)
3163 case LambdaExprClass: {
3164 const LambdaExpr *LE = cast<LambdaExpr>(
this);
3174 case PseudoObjectExprClass: {
3181 const Expr *Subexpr = *I;
3183 Subexpr = OVE->getSourceExpr();
3190 case ObjCBoxedExprClass:
3191 case ObjCArrayLiteralClass:
3192 case ObjCDictionaryLiteralClass:
3193 case ObjCSelectorExprClass:
3194 case ObjCProtocolExprClass:
3195 case ObjCIsaExprClass:
3196 case ObjCIndirectCopyRestoreExprClass:
3197 case ObjCSubscriptRefExprClass:
3198 case ObjCBridgedCastExprClass:
3199 case ObjCMessageExprClass:
3200 case ObjCPropertyRefExprClass:
3202 if (IncludePossibleEffects)
3210 cast<Expr>(SubStmt)->HasSideEffects(Ctx, IncludePossibleEffects))
3225 explicit NonTrivialCallFinder(
const ASTContext &Context)
3226 : Inherited(Context), NonTrivial(
false) { }
3230 void VisitCallExpr(
const CallExpr *E) {
3232 = dyn_cast_or_null<const CXXMethodDecl>(E->
getCalleeDecl())) {
3233 if (Method->isTrivial()) {
3235 Inherited::VisitStmt(E);
3246 Inherited::VisitStmt(E);
3255 Inherited::VisitStmt(E);
3265 NonTrivialCallFinder Finder(Ctx);
3267 return Finder.hasNonTrivialCall();
3282 llvm_unreachable(
"Unexpected value dependent expression!");
3304 bool PointeeHasDefaultAS =
3312 if (PointeeHasDefaultAS && Pointee->
isVoidType() &&
3313 CE->getSubExpr()->getType()->isIntegerType())
3314 return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3317 }
else if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(
this)) {
3319 return ICE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3320 }
else if (
const ParenExpr *PE = dyn_cast<ParenExpr>(
this)) {
3323 return PE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3325 dyn_cast<GenericSelectionExpr>(
this)) {
3326 if (GE->isResultDependent())
3328 return GE->getResultExpr()->isNullPointerConstant(Ctx, NPC);
3329 }
else if (
const ChooseExpr *CE = dyn_cast<ChooseExpr>(
this)) {
3330 if (CE->isConditionDependent())
3332 return CE->getChosenSubExpr()->isNullPointerConstant(Ctx, NPC);
3334 = dyn_cast<CXXDefaultArgExpr>(
this)) {
3336 return DefaultArg->getExpr()->isNullPointerConstant(Ctx, NPC);
3338 = dyn_cast<CXXDefaultInitExpr>(
this)) {
3340 return DefaultInit->getExpr()->isNullPointerConstant(Ctx, NPC);
3341 }
else if (isa<GNUNullExpr>(
this)) {
3345 = dyn_cast<MaterializeTemporaryExpr>(
this)) {
3346 return M->GetTemporaryExpr()->isNullPointerConstant(Ctx, NPC);
3347 }
else if (
const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(
this)) {
3348 if (
const Expr *Source = OVE->getSourceExpr())
3349 return Source->isNullPointerConstant(Ctx, NPC);
3353 if (
getType()->isNullPtrType())
3358 UT && UT->getDecl()->hasAttr<TransparentUnionAttr>())
3360 const Expr *InitExpr = CLE->getInitializer();
3361 if (
const InitListExpr *ILE = dyn_cast<InitListExpr>(InitExpr))
3365 if (!
getType()->isIntegerType() ||
3388 if (isa<IntegerLiteral>(
this))
3396 const Expr *E =
this;
3400 "expression is not a property reference");
3403 if (BO->getOpcode() == BO_Comma) {
3412 return cast<ObjCPropertyRefExpr>(E);
3437 if (ICE->getCastKind() == CK_LValueToRValue ||
3438 (ICE->getValueKind() !=
VK_RValue && ICE->getCastKind() == CK_NoOp))
3444 if (
MemberExpr *MemRef = dyn_cast<MemberExpr>(E))
3445 if (
FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
3446 if (Field->isBitField())
3450 if (
FieldDecl *Ivar = dyn_cast<FieldDecl>(IvarRef->getDecl()))
3451 if (Ivar->isBitField())
3454 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E)) {
3455 if (
FieldDecl *Field = dyn_cast<FieldDecl>(DeclRef->getDecl()))
3456 if (Field->isBitField())
3459 if (
BindingDecl *BD = dyn_cast<BindingDecl>(DeclRef->getDecl()))
3460 if (
Expr *E = BD->getBinding())
3465 if (BinOp->isAssignmentOp() && BinOp->getLHS())
3466 return BinOp->getLHS()->getSourceBitField();
3468 if (BinOp->getOpcode() == BO_Comma && BinOp->getRHS())
3469 return BinOp->getRHS()->getSourceBitField();
3473 if (UnOp->isPrefix() && UnOp->isIncrementDecrementOp())
3474 return UnOp->getSubExpr()->getSourceBitField();
3485 ICE->getCastKind() == CK_NoOp)
3494 if (isa<ExtVectorElementExpr>(E))
3497 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
3498 if (
auto *BD = dyn_cast<BindingDecl>(DRE->getDecl()))
3499 if (
auto *E = BD->getBinding())
3508 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
3509 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
3511 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
3520 return getBase()->getType()->isPointerType();
3525 return VT->getNumElements();
3533 StringRef Comp = Accessor->getName();
3536 if (Comp ==
"hi" || Comp ==
"lo" || Comp ==
"even" || Comp ==
"odd")
3540 if (Comp[0] ==
's' || Comp[0] ==
'S')
3541 Comp = Comp.substr(1);
3543 for (
unsigned i = 0, e = Comp.size(); i != e; ++i)
3544 if (Comp.substr(i + 1).find(Comp[i]) != StringRef::npos)
3553 StringRef Comp = Accessor->getName();
3554 bool isNumericAccessor =
false;
3555 if (Comp[0] ==
's' || Comp[0] ==
'S') {
3556 Comp = Comp.substr(1);
3557 isNumericAccessor =
true;
3560 bool isHi = Comp ==
"hi";
3561 bool isLo = Comp ==
"lo";
3562 bool isEven = Comp ==
"even";
3563 bool isOdd = Comp ==
"odd";
3565 for (
unsigned i = 0, e = getNumElements(); i != e; ++i) {
3579 Elts.push_back(Index);
3587 Type->isDependentType(), Type->isDependentType(),
3588 Type->isInstantiationDependentType(),
3590 BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size())
3592 SubExprs =
new (
C)
Stmt*[args.size()];
3593 for (
unsigned i = 0; i != args.size(); i++) {
3599 ExprBits.InstantiationDependent =
true;
3601 ExprBits.ContainsUnexpandedParameterPack =
true;
3603 SubExprs[i] = args[i];
3610 this->NumExprs = Exprs.size();
3611 SubExprs =
new (
C)
Stmt*[NumExprs];
3612 memcpy(SubExprs, Exprs.data(),
sizeof(
Expr *) * Exprs.size());
3621 bool ContainsUnexpandedParameterPack,
3622 unsigned ResultIndex)
3623 :
Expr(GenericSelectionExprClass,
3624 AssocExprs[ResultIndex]->
getType(),
3630 ContainsUnexpandedParameterPack),
3632 SubExprs(new (Context)
Stmt*[END_EXPR+AssocExprs.size()]),
3633 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
3634 GenericLoc(GenericLoc), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
3635 SubExprs[CONTROLLING] = ControllingExpr;
3636 assert(AssocTypes.size() == AssocExprs.size());
3637 std::copy(AssocTypes.begin(), AssocTypes.end(), this->AssocTypes);
3638 std::copy(AssocExprs.begin(), AssocExprs.end(), SubExprs+END_EXPR);
3647 bool ContainsUnexpandedParameterPack)
3648 :
Expr(GenericSelectionExprClass,
3649 Context.DependentTy,
3655 ContainsUnexpandedParameterPack),
3657 SubExprs(new (Context)
Stmt*[END_EXPR+AssocExprs.size()]),
3658 NumAssocs(AssocExprs.size()), ResultIndex(-1U), GenericLoc(GenericLoc),
3659 DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
3660 SubExprs[CONTROLLING] = ControllingExpr;
3661 assert(AssocTypes.size() == AssocExprs.size());
3662 std::copy(AssocTypes.begin(), AssocTypes.end(), this->AssocTypes);
3663 std::copy(AssocExprs.begin(), AssocExprs.end(), SubExprs+END_EXPR);
3672 if (Field.NameOrField & 0x01)
3673 return reinterpret_cast<IdentifierInfo *
>(Field.NameOrField&~0x01);
3675 return getField()->getIdentifier();
3684 :
Expr(DesignatedInitExprClass, Ty,
3689 EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
3690 NumDesignators(Designators.size()), NumSubExprs(IndexExprs.size() + 1) {
3691 this->Designators =
new (
C)
Designator[NumDesignators];
3699 unsigned IndexIdx = 0;
3700 for (
unsigned I = 0; I != NumDesignators; ++I) {
3701 this->Designators[I] = Designators[I];
3703 if (this->Designators[I].isArrayDesignator()) {
3705 Expr *Index = IndexExprs[IndexIdx];
3709 ExprBits.InstantiationDependent =
true;
3712 ExprBits.ContainsUnexpandedParameterPack =
true;
3715 *Child++ = IndexExprs[IndexIdx++];
3716 }
else if (this->Designators[I].isArrayRangeDesignator()) {
3718 Expr *Start = IndexExprs[IndexIdx];
3719 Expr *
End = IndexExprs[IndexIdx + 1];
3723 ExprBits.InstantiationDependent =
true;
3726 ExprBits.InstantiationDependent =
true;
3732 ExprBits.ContainsUnexpandedParameterPack =
true;
3735 *Child++ = IndexExprs[IndexIdx++];
3736 *Child++ = IndexExprs[IndexIdx++];
3740 assert(IndexIdx == IndexExprs.size() &&
"Wrong number of index expressions");
3748 bool UsesColonSyntax,
Expr *Init) {
3749 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(IndexExprs.size() + 1),
3752 ColonOrEqualLoc, UsesColonSyntax,
3757 unsigned NumIndexExprs) {
3758 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(NumIndexExprs + 1),
3765 unsigned NumDesigs) {
3767 NumDesignators = NumDesigs;
3768 for (
unsigned I = 0; I != NumDesigs; ++I)
3769 Designators[I] = Desigs[I];
3796 return getInit()->getLocEnd();
3806 "Requires array range designator");
3812 "Requires array range designator");
3821 unsigned NumNewDesignators = Last - First;
3822 if (NumNewDesignators == 0) {
3823 std::copy_backward(Designators + Idx + 1,
3824 Designators + NumDesignators,
3826 --NumNewDesignators;
3828 }
else if (NumNewDesignators == 1) {
3829 Designators[Idx] = *First;
3834 =
new (
C)
Designator[NumDesignators - 1 + NumNewDesignators];
3835 std::copy(Designators, Designators + Idx, NewDesignators);
3836 std::copy(First, Last, NewDesignators + Idx);
3837 std::copy(Designators + Idx + 1, Designators + NumDesignators,
3838 NewDesignators + Idx + NumNewDesignators);
3839 Designators = NewDesignators;
3840 NumDesignators = NumDesignators - 1 + NumNewDesignators;
3847 BaseAndUpdaterExprs[0] = baseExpr;
3851 BaseAndUpdaterExprs[1] = ILE;
3867 NumExprs(exprs.size()), LParenLoc(lparenloc), RParenLoc(rparenloc) {
3868 Exprs =
new (
C)
Stmt*[exprs.size()];
3869 for (
unsigned i = 0; i != exprs.size(); ++i) {
3875 ExprBits.InstantiationDependent =
true;
3877 ExprBits.ContainsUnexpandedParameterPack =
true;
3879 Exprs[i] = exprs[i];
3885 e = ewc->getSubExpr();
3887 e = m->GetTemporaryExpr();
3888 e = cast<CXXConstructExpr>(e)->getArg(0);
3890 e = ice->getSubExpr();
3891 return cast<OpaqueValueExpr>(e);
3896 unsigned numSemanticExprs) {
3898 Context.
Allocate(totalSizeToAlloc<Expr *>(1 + numSemanticExprs),
3903 PseudoObjectExpr::PseudoObjectExpr(
EmptyShell shell,
unsigned numSemanticExprs)
3904 :
Expr(PseudoObjectExprClass, shell) {
3910 unsigned resultIndex) {
3911 assert(syntax &&
"no syntactic expression!");
3912 assert(semantics.size() &&
"no semantic expressions!");
3916 if (resultIndex == NoResult) {
3920 assert(resultIndex < semantics.size());
3921 type = semantics[resultIndex]->getType();
3922 VK = semantics[resultIndex]->getValueKind();
3926 void *buffer = C.
Allocate(totalSizeToAlloc<Expr *>(semantics.size() + 1),
3934 unsigned resultIndex)
3936 false,
false,
false,
false) {
3940 for (
unsigned i = 0, e = semantics.size() + 1; i != e; ++i) {
3941 Expr *E = (i == 0 ? syntax : semantics[i-1]);
3942 getSubExprsBuffer()[i] = E;
3949 ExprBits.InstantiationDependent =
true;
3951 ExprBits.ContainsUnexpandedParameterPack =
true;
3953 if (isa<OpaqueValueExpr>(E))
3954 assert(cast<OpaqueValueExpr>(E)->getSourceExpr() !=
nullptr &&
3955 "opaque-value semantic expressions for pseudo-object " 3956 "operations must have sources");
3975 if (isArgumentType()) {
3977 dyn_cast<VariableArrayType>(getArgumentType().getTypePtr()))
3988 NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op)
3990 assert(args.size() ==
getNumSubExprs(op) &&
"wrong number of subexpressions");
3991 for (
unsigned i = 0; i != args.size(); i++) {
3997 ExprBits.InstantiationDependent =
true;
3999 ExprBits.ContainsUnexpandedParameterPack =
true;
4001 SubExprs[i] = args[i];
4007 case AO__c11_atomic_init:
4008 case AO__opencl_atomic_init:
4009 case AO__c11_atomic_load:
4010 case AO__atomic_load_n:
4013 case AO__opencl_atomic_load:
4014 case AO__c11_atomic_store:
4015 case AO__c11_atomic_exchange:
4016 case AO__atomic_load:
4017 case AO__atomic_store:
4018 case AO__atomic_store_n:
4019 case AO__atomic_exchange_n:
4020 case AO__c11_atomic_fetch_add:
4021 case AO__c11_atomic_fetch_sub:
4022 case AO__c11_atomic_fetch_and:
4023 case AO__c11_atomic_fetch_or:
4024 case AO__c11_atomic_fetch_xor:
4025 case AO__atomic_fetch_add:
4026 case AO__atomic_fetch_sub:
4027 case AO__atomic_fetch_and:
4028 case AO__atomic_fetch_or:
4029 case AO__atomic_fetch_xor:
4030 case AO__atomic_fetch_nand:
4031 case AO__atomic_add_fetch:
4032 case AO__atomic_sub_fetch:
4033 case AO__atomic_and_fetch:
4034 case AO__atomic_or_fetch:
4035 case AO__atomic_xor_fetch:
4036 case AO__atomic_nand_fetch:
4039 case AO__opencl_atomic_store:
4040 case AO__opencl_atomic_exchange:
4041 case AO__opencl_atomic_fetch_add:
4042 case AO__opencl_atomic_fetch_sub:
4043 case AO__opencl_atomic_fetch_and:
4044 case AO__opencl_atomic_fetch_or:
4045 case AO__opencl_atomic_fetch_xor:
4046 case AO__opencl_atomic_fetch_min:
4047 case AO__opencl_atomic_fetch_max:
4048 case AO__atomic_exchange:
4051 case AO__c11_atomic_compare_exchange_strong:
4052 case AO__c11_atomic_compare_exchange_weak:
4055 case AO__opencl_atomic_compare_exchange_strong:
4056 case AO__opencl_atomic_compare_exchange_weak:
4057 case AO__atomic_compare_exchange:
4058 case AO__atomic_compare_exchange_n:
4061 llvm_unreachable(
"unknown atomic op");
4067 return AT->getValueType();
4072 unsigned ArraySectionCount = 0;
4073 while (
auto *OASE = dyn_cast<OMPArraySectionExpr>(Base->
IgnoreParens())) {
4074 Base = OASE->getBase();
4075 ++ArraySectionCount;
4079 Base = ASE->getBase();
4080 ++ArraySectionCount;
4083 auto OriginalTy = Base->
getType();
4084 if (
auto *DRE = dyn_cast<DeclRefExpr>(Base))
4085 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl()))
4086 OriginalTy = PVD->getOriginalType().getNonReferenceType();
4088 for (
unsigned Cnt = 0; Cnt < ArraySectionCount; ++Cnt) {
4089 if (OriginalTy->isAnyPointerType())
4092 assert (OriginalTy->isArrayType());
child_iterator child_begin()
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
A call to an overloaded operator written using operator syntax.
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
Represents a single C99 designator.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
void setValueDependent(bool VD)
Set whether this expression is value-dependent or not.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
Defines the clang::ASTContext interface.
static std::string ComputeName(IdentType IT, const Decl *CurrentDecl)
const CXXDestructorDecl * getDestructor() const
An instance of this class is created to represent a function declaration or definition.
Expr * getArrayIndex(const Designator &D) const
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D, QualType T, bool &TypeDependent, bool &ValueDependent, bool &InstantiationDependent)
Compute the type-, value-, and instantiation-dependence of a declaration reference based on the decla...
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens...
SourceLocation getRParenLoc() const
void setArrayFiller(Expr *filler)
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
A (possibly-)qualified type.
unsigned getOffsetOfStringByte(const Token &TheTok, unsigned ByteNo) const
getOffsetOfStringByte - This function returns the offset of the specified byte of the string data rep...
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
static StringLiteral * CreateEmpty(const ASTContext &C, unsigned NumStrs)
Construct an empty string literal.
const DeclarationNameLoc & getInfo() const
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
static Decl * castFromDeclContext(const DeclContext *)
unsigned FieldLoc
The location of the field name in the designated initializer.
SourceLocation getLocEnd() const LLVM_READONLY
const Expr * getInit(unsigned Init) const
Stmt - This represents one statement.
DesignatedInitUpdateExpr(const ASTContext &C, SourceLocation lBraceLoc, Expr *baseExprs, SourceLocation rBraceLoc)
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
FunctionType - C99 6.7.5.3 - Function Declarators.
SourceLocation getLocationOfByte(unsigned ByteNo, const SourceManager &SM, const LangOptions &Features, const TargetInfo &Target, unsigned *StartToken=nullptr, unsigned *StartTokenByteOffset=nullptr) const
getLocationOfByte - Return a source location that points to the specified byte of this string literal...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Defines the SourceManager interface.
bool hasNonTrivialCall(const ASTContext &Ctx) const
Determine whether this expression involves a call to any function that is not trivial.
bool isRecordType() const
reverse_iterator rbegin()
unsigned size() const
Retrieve the number of template arguments in this template argument list.
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
void setSemantics(const llvm::fltSemantics &Sem)
Set the APFloat semantics this literal uses.
Decl - This represents one declaration (or definition), e.g.
bool hasUnusedResultAttr() const
Returns true if this function or its return type has the warn_unused_result attribute.
FloatingLiteralBitfields FloatingLiteralBits
void getEncodedElementAccess(SmallVectorImpl< uint32_t > &Elts) const
getEncodedElementAccess - Encode the elements accessed into an llvm aggregate Constant of ConstantInt...
bool isTransparent() const
Is this a transparent initializer list (that is, an InitListExpr that is purely syntactic, and whose semantics are that of the sole contained initializer)?
Defines the C++ template declaration subclasses.
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
iterator insert(const ASTContext &C, iterator I, const T &Elt)
ParenExpr - This represents a parethesized expression, e.g.
NamedDecl * getDecl() const
bool isExplicitSpecialization() const
The base class of the type hierarchy.
bool isSemanticForm() const
llvm::iterator_range< child_iterator > child_range
Represents an array type, per C99 6.7.5.2 - Array Declarators.
DeclRefExprBitfields DeclRefExprBits
Represents a call to a C++ constructor.
NamedDecl * getParam(unsigned Idx)
SourceLocation getLParenLoc() const
const TargetInfo & getTargetInfo() const
A container of type source information.
bool containsDuplicateElements() const
containsDuplicateElements - Return true if any element access is repeated.
static StringLiteral * Create(const ASTContext &C, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumStrs)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
CallExpr(const ASTContext &C, StmtClass SC, Expr *fn, ArrayRef< Expr *> preargs, ArrayRef< Expr *> args, QualType t, ExprValueKind VK, SourceLocation rparenloc)
Describes the capture of a variable or of this, or of a C++1y init-capture.
unsigned getCharWidth() const
Represents a C++ constructor within a class.
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Expr * ignoreParenBaseCasts() LLVM_READONLY
Ignore parentheses and derived-to-base casts.
QualType getElementType() const
StringRef getBufferData(FileID FID, bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
static OffsetOfExpr * CreateEmpty(const ASTContext &C, unsigned NumComps, unsigned NumExprs)
static const OpaqueValueExpr * findInCopyConstruct(const Expr *expr)
Given an expression which invokes a copy constructor — i.e.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
const ObjCPropertyRefExpr * getObjCProperty() const
If this expression is an l-value for an Objective C property, find the underlying property reference ...
CompoundLiteralExpr - [C99 6.5.2.5].
bool isEnumeralType() const
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const T * getAs() const
Member-template getAs<specific type>'.
MangleContext * createMangleContext()
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type...
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
void setInit(unsigned Init, Expr *expr)
ObjCMethodDecl - Represents an instance or class method declaration.
PredefinedExpr(SourceLocation L, QualType FNTy, IdentType IT, StringLiteral *SL)
bool isIdiomaticZeroInitializer(const LangOptions &LangOpts) const
Is this the zero initializer {0} in a language which considers it idiomatic?
Stores a list of template parameters for a TemplateDecl and its derived classes.
static DeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasQualifier, bool HasFoundDecl, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Construct an empty declaration reference expression.
Describes how types, statements, expressions, and declarations should be printed. ...
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
static bool isAssignmentOp(Opcode Opc)
Defines the clang::Expr interface and subclasses for C++ expressions.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
LabelStmt - Represents a label, which has a substatement.
RecordDecl - Represents a struct/union/class.
Represents a C99 designated initializer expression.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
One of these records is kept for each identifier that is lexed.
Represents a class template specialization, which refers to a class template with a given set of temp...
unsigned GetStringLength() const
const Expr * getBestDynamicClassTypeExpr() const
Get the inner expression that determines the best dynamic class.
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
StmtIterator cast_away_const(const ConstStmtIterator &RHS)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
unsigned getChar32Width() const
getChar32Width/Align - Return the size of 'char32_t' for this target, in bits.
field_range fields() const
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
void setNumArgs(const ASTContext &C, unsigned NumArgs)
setNumArgs - This changes the number of arguments present in this call.
static DesignatedInitExpr * Create(const ASTContext &C, llvm::ArrayRef< Designator > Designators, ArrayRef< Expr *> IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
bool isReferenceType() const
Token - This structure provides full information about a lexed token.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
bool isArrow() const
isArrow - Return true if the base expression is a pointer to vector, return false if the base express...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
NestedNameSpecifierLoc QualifierLoc
The nested-name-specifier that qualifies the name, including source-location information.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
struct FieldDesignator Field
A field designator, e.g., ".x".
const Expr *const * const_semantics_iterator
ShuffleVectorExpr(const ASTContext &C, ArrayRef< Expr *> args, QualType Type, SourceLocation BLoc, SourceLocation RP)
Provides information about a function template specialization, which is a FunctionDecl that has been ...
StringRef getOpcodeStr() const
Describes an C or C++ initializer list.
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
void setValue(const ASTContext &C, const llvm::APInt &Val)
An lvalue ref-qualifier was provided (&).
< Capturing the *this object by copy
A convenient class for passing around template argument information.
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
NullPointerConstantValueDependence
Enumeration used to describe how isNullPointerConstant() should cope with value-dependent expressions...
unsigned getNumPreArgs() const
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
static bool isRecordType(QualType T)
semantics_iterator semantics_end()
A builtin binary operation expression such as "x + y" or "x <= y".
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isBoundMemberFunction(ASTContext &Ctx) const
Returns true if this expression is a bound member function.
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
const char * getCastKindName() const
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
field_iterator field_begin() const
SourceLocation getCaretLocation() const
static bool isBooleanType(QualType Ty)
An adjustment to be made to the temporary created when emitting a reference binding, which accesses a particular subobject of that temporary.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Represents binding an expression to a temporary.
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
CXXTemporary * getTemporary()
bool isCXX98IntegralConstantExpr(const ASTContext &Ctx) const
isCXX98IntegralConstantExpr - Return true if this expression is an integral constant expression in C+...
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
An ordinary object is located at an address in memory.
This represents the body of a CapturedStmt, and serves as its DeclContext.
Represents an ObjC class declaration.
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Character, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token...
Expression is a GNU-style __null constant.
bool isExplicitSpecialization() const
const Stmt * getBody() const
A binding in a decomposition declaration.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
bool isUnevaluated(unsigned ID) const
Returns true if this builtin does not perform the side-effects of its arguments.
A default argument (C++ [dcl.fct.default]).
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
void setIntValue(const ASTContext &C, const llvm::APInt &Val)
bool isObjCSelfExpr() const
Check if this expression is the ObjC 'self' implicit parameter.
ParenListExpr(const ASTContext &C, SourceLocation lparenloc, ArrayRef< Expr *> exprs, SourceLocation rparenloc)
Represents the this expression in C++.
static bool isNullPointerArithmeticExtension(ASTContext &Ctx, Opcode Opc, Expr *LHS, Expr *RHS)
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
bool isInstantiationDependent() const
Whether this nested name specifier involves a template parameter.
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
bool isUnevaluatedBuiltinCall(const ASTContext &Ctx) const
Returns true if this is a call to a builtin which does not evaluate side-effects within its arguments...
ConditionalOperator - The ?: ternary operator.
llvm::iterator_range< const_child_iterator > const_child_range
CompoundStmt - This represents a group of statements like { stmt stmt }.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
bool EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsLValue - Evaluate an expression to see if we can fold it to an lvalue with link time known ...
Expr * IgnoreParenNoopCasts(ASTContext &Ctx) LLVM_READONLY
IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the value (including ptr->int ...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
CastKind
CastKind - The kind of operation required for a conversion.
SourceLocation getLocEnd() const LLVM_READONLY
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
Specifies that the expression should never be value-dependent.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
InitListExpr * getUpdater() const
void outputString(raw_ostream &OS) const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
ConstStmtIterator const_child_iterator
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Exposes information about the current target.
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
void setString(const ASTContext &C, StringRef Str, StringKind Kind, bool IsPascal)
Sets the string data to the given string data.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
SourceLocation getLocStart() const LLVM_READONLY
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
void setDesignators(const ASTContext &C, const Designator *Desigs, unsigned NumDesigs)
SourceLocation getLocStart() const LLVM_READONLY
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
const FunctionProtoType * T
const T * castAs() const
Member-template castAs<specific type>.
SourceLocation getLocEnd() const LLVM_READONLY
void setTypeDependent(bool TD)
Set whether this expression is type-dependent or not.
Represents a C++ destructor within a class.
bool isFieldDesignator() const
unsigned getNumInits() const
const Expr * getCallee() const
SourceLocation getLocEnd() const LLVM_READONLY
const Expr * skipRValueSubobjectAdjustments() const
field_iterator field_end() const
DeclContext * getDeclContext()
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
Represents the type decltype(expr) (C++11).
ArrayRef< Expr * > inits()
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
Extra data stored in some MemberExpr objects.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
An expression that sends a message to the given Objective-C object or class.
InitListExpr(const ASTContext &C, SourceLocation lbraceloc, ArrayRef< Expr *> initExprs, SourceLocation rbraceloc)
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
unsigned Index
Location of the first index expression within the designated initializer expression's list of subexpr...
Represents a GCC generic vector type.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Allow UB that we can give a value, but not arbitrary unmodeled side effects.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
The result type of a method or function.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.
ImplicitParamDecl * getSelfDecl() const
SourceLocation getLocEnd() const LLVM_READONLY
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
SourceRange getSourceRange() const
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
unsigned getBuiltinCallee() const
getBuiltinCallee - If this is a call to a builtin, return the builtin ID of the callee.
unsigned getWCharWidth() const
getWCharWidth/Align - Return the size of 'wchar_t' for this target, in bits.
RecordDecl * getDecl() const
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Expr * IgnoreCasts() LLVM_READONLY
Ignore casts. Strip off any CastExprs, returning their operand.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
const llvm::fltSemantics & getSemantics() const
Return the APFloat semantics this literal uses.
Expr * IgnoreConversionOperator() LLVM_READONLY
IgnoreConversionOperator - Ignore conversion operator.
AtomicExpr(SourceLocation BLoc, ArrayRef< Expr *> args, QualType t, AtomicOp op, SourceLocation RP)
unsigned DotLoc
The location of the '.' in the designated initializer.
UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, TypeSourceInfo *TInfo, QualType resultType, SourceLocation op, SourceLocation rp)
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
void ExpandDesignator(const ASTContext &C, unsigned Idx, const Designator *First, const Designator *Last)
Replaces the designator at index Idx with the series of designators in [First, Last).
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
QualType getCanonicalType() const
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Encodes a location in the source.
QualType getReturnType() const
SourceLocation getOperatorLoc() const
PseudoObjectExprBitfields PseudoObjectExprBits
LangAS getAddressSpace() const
Return the address space of this type.
Expression is not a Null pointer constant.
Expr * getSubExpr() const
CastKind getCastKind() const
static const FieldDecl * getTargetFieldForToUnionCast(QualType unionType, QualType opType)
ObjCMethodFamily getMethodFamily() const
unsigned getChar16Width() const
getChar16Width/Align - Return the size of 'char16_t' for this target, in bits.
Represents a call to a member function that may be written either with member call syntax (e...
ASTContext & getASTContext() const LLVM_READONLY
static QualType getUnderlyingType(const SubRegion *R)
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr *> exprs, SourceLocation RParenLoc)
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents a static or instance method of a struct/union/class.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
const ParmVarDecl * getParamDecl(unsigned i) const
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
Expr * updateInit(const ASTContext &C, unsigned Init, Expr *expr)
Updates the initializer at index Init with the new expression expr, and returns the old expression at...
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
AccessSpecifier getAccess() const
bool isKnownToHaveBooleanValue() const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
StringLiteral * getFunctionName()
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
Expr ** getInits()
Retrieve the set of initializers.
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
static DesignatedInitExpr * CreateEmpty(const ASTContext &C, unsigned NumIndexExprs)
const CXXRecordDecl * getBestDynamicClassType() const
For an expression of class type or pointer to class type, return the most derived class decl the expr...
Expr * getArrayRangeStart(const Designator &D) const
const ObjCMethodDecl * getMethodDecl() const
bool isVectorType() const
An rvalue ref-qualifier was provided (&&).
SourceLocation getLocStart() const LLVM_READONLY
unsigned LBracketLoc
The location of the '[' starting the array range designator.
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
SourceLocation getLocStart() const LLVM_READONLY
LLVM_READONLY bool isPrintable(unsigned char c)
Return true if this character is an ASCII printable character; that is, a character that should take ...
void sawArrayRangeDesignator(bool ARD=true)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
static MemberExpr * Create(const ASTContext &C, Expr *base, bool isarrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *memberdecl, DeclAccessPair founddecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *targs, QualType ty, ExprValueKind VK, ExprObjectKind OK)
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
A POD class for pairing a NamedDecl* with an access specifier.
void * Allocate(size_t Size, unsigned Align=8) const
Represents a C11 generic selection.
SourceRange getDesignatorsSourceRange() const
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
Dataflow Directional Tag Classes.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isValid() const
Return true if this is a valid SourceLocation object.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
EvalResult is a struct with detailed info about an evaluated expression.
bool hasSideEffects(Expr *E, ASTContext &Ctx)
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Decl * getReferencedDeclOfCallee()
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
A field designator, e.g., ".x".
The same as PrettyFunction, except that the 'virtual' keyword is omitted for virtual member functions...
void setExprs(const ASTContext &C, ArrayRef< Expr *> Exprs)
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
AccessSpecifier getAccess() const
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
StmtClass getStmtClass() const
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isBooleanType() const
SourceLocation getLocStart() const LLVM_READONLY
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
void resize(const ASTContext &C, unsigned N, const T &NV)
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr *> semantic, unsigned resultIndex)
void setInstantiationDependent(bool ID)
Set whether this expression is instantiation-dependent or not.
Expression is a C++11 nullptr.
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
unsigned getNumElements() const
getNumElements - Get the number of components being selected.
semantics_iterator semantics_begin()
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
ExplicitCastExpr - An explicit cast written in the source code.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
Expr * getArrayRangeEnd(const Designator &D) const
llvm::APInt getValue() const
unsigned getNumSubExprs() const
GenericSelectionExpr(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo *> AssocTypes, ArrayRef< Expr *> AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
bool isStringLiteralInit() const
struct ArrayOrRangeDesignator ArrayOrRange
An array or GNU array-range designator, e.g., "[9]" or "[10..15]".
unsigned getIntWidth(QualType T) const
Not an overloaded operator.
bool isIncompleteArrayType() const
bool HasSideEffects
Whether the evaluated expression has side effects.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Location wrapper for a TemplateArgument.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
SourceLocation getLocEnd() const LLVM_READONLY
static StringRef getIdentTypeName(IdentType IT)
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isConstantInitializer(ASTContext &Ctx, bool ForRef, const Expr **Culprit=nullptr) const
isConstantInitializer - Returns true if this expression can be emitted to IR as a constant...
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
bool isFunctionType() const
static ImplicitCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize)
SourceLocation getLocStart() const LLVM_READONLY
Expr * IgnoreParenLValueCasts() LLVM_READONLY
Ignore parentheses and lvalue casts.
Expr * getArg(unsigned Arg)
Return the specified argument.
SourceLocation getLocEnd() const LLVM_READONLY
UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits
Represents a base class of a C++ class.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
A use of a default initializer in a constructor or in aggregate initialization.
A template argument list.
static CStyleCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize)
static const Expr * skipTemporaryBindingsNoOpCastsAndParens(const Expr *E)
Skip over any no-op casts and any temporary-binding expressions.
SourceLocation getLocEnd() const LLVM_READONLY
bool refersToGlobalRegisterVar() const
Returns whether this expression refers to a global register variable.
bool isUnusedResultAWarning(const Expr *&WarnExpr, SourceLocation &Loc, SourceRange &R1, SourceRange &R2, ASTContext &Ctx) const
isUnusedResultAWarning - Return true if this immediate expression should be warned about if the resul...
void reserve(const ASTContext &C, unsigned N)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Expression is a Null pointer constant built from a literal zero.
void Deallocate(void *Ptr) const
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
CallingConv getCallConv() const
Represents a C++ struct/union/class.
bool isSyntacticForm() const
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr *> Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Builtin::Context & BuiltinInfo
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool isImplicitCXXThis() const
Whether this expression is an implicit reference to 'this' in C++.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Designator * getDesignator(unsigned Idx)
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
void reserveInits(const ASTContext &C, unsigned NumInits)
Reserve space for some number of initializers.
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
static Decl::Kind getKind(const Decl *D)
DeclAccessPair FoundDecl
The DeclAccessPair through which the MemberDecl was found due to name qualifiers. ...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isEvaluatable(const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
isEvaluatable - Call EvaluateAsRValue to see if this expression can be constant folded without side-e...
std::reverse_iterator< const_iterator > const_reverse_iterator
A reference to a declared variable, function, enum, etc.
bool isPointerType() const
CallExprBitfields CallExprBits
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
bool isOBJCGCCandidate(ASTContext &Ctx) const
isOBJCGCCandidate - Return true if this expression may be used in a read/ write barrier.
An l-value expression is a reference to an object with independent storage.
unsigned getNumArgs() const
A trivial tuple used to represent a source range.
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
NamedDecl - This represents a decl with a name.
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Represents a C array with a specified size that is not an integer-constant-expression.
static int getAccessorIdx(char c, bool isNumericAccessor)
QualType getValueType() const
double getValueAsApproximateDouble() const
getValueAsApproximateDouble - This returns the value as an inaccurate double.
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
SourceLocation getLocStart() const LLVM_READONLY
const LangOptions & getLangOpts() const
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
IdentifierInfo * getFieldName() const
This class handles loading and caching of source files into memory.
InitListExpr * getSyntacticForm() const
Defines enum values for all the target-independent builtin functions.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
QualType getType() const
Return the type wrapped by this type source info.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation getLocStart() const LLVM_READONLY