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>
202 return static_cast<const E*
>(
expr)->getExprLoc();
212 return static_cast<const E*
>(
expr)->getLocStart();
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,
354 D(D), Loc(NameInfo.getLoc()), DNLoc(NameInfo.
getInfo()) {
355 DeclRefExprBits.HasQualifier = QualifierLoc ? 1 : 0;
357 new (getTrailingObjects<NestedNameSpecifierLoc>())
360 if (NNS->isInstantiationDependent())
361 ExprBits.InstantiationDependent =
true;
362 if (NNS->containsUnexpandedParameterPack())
363 ExprBits.ContainsUnexpandedParameterPack =
true;
365 DeclRefExprBits.HasFoundDecl = FoundD ? 1 : 0;
367 *getTrailingObjects<NamedDecl *>() = FoundD;
368 DeclRefExprBits.HasTemplateKWAndArgsInfo
369 = (TemplateArgs || TemplateKWLoc.
isValid()) ? 1 : 0;
370 DeclRefExprBits.RefersToEnclosingVariableOrCapture =
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(
386 DeclRefExprBits.HadMultipleCandidates = 0;
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,
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,
762 setSemantics(V.getSemantics());
767 FloatingLiteral::FloatingLiteral(
const ASTContext &C, EmptyShell Empty)
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";
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;
1067 std::pair<FileID, unsigned> LocInfo =
1069 bool Invalid =
false;
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 ||
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;
1164 fn->isValueDependent(), fn->isInstantiationDependent(),
1165 fn->containsUnexpandedParameterPack()),
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));
1371 tsi->getType()->isDependentType(),
1372 tsi->getType()->isInstantiationDependentType(),
1373 tsi->getType()->containsUnexpandedParameterPack()),
1374 OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
1375 NumComps(comps.size()), NumExprs(exprs.size())
1377 for (
unsigned i = 0; i != comps.size(); ++i) {
1381 for (
unsigned i = 0; i != exprs.size(); ++i) {
1385 ExprBits.ContainsUnexpandedParameterPack =
true;
1405 E->isTypeDependent(), E->isInstantiationDependent(),
1406 E->containsUnexpandedParameterPack()),
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(
1508 return BaseStartLoc;
1520 bool CastExpr::CastConsistency()
const {
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());
1533 goto CheckNoBasePath;
1535 case CK_BlockPointerToObjCPointerCast:
1536 assert(
getType()->isObjCObjectPointerType());
1538 goto CheckNoBasePath;
1540 case CK_ReinterpretMemberPointer:
1541 assert(
getType()->isMemberPointerType());
1543 goto CheckNoBasePath;
1549 if (!
getType()->isPointerType()) {
1550 assert(
getType()->isObjCObjectPointerType() ==
1552 assert(
getType()->isBlockPointerType() ==
1555 goto CheckNoBasePath;
1557 case CK_AnyPointerToBlockPointerCast:
1558 assert(
getType()->isBlockPointerType());
1561 goto CheckNoBasePath;
1563 case CK_CopyAndAutoreleaseBlockObject:
1564 assert(
getType()->isBlockPointerType());
1566 goto CheckNoBasePath;
1568 case CK_FunctionToPointerDecay:
1569 assert(
getType()->isPointerType());
1571 goto CheckNoBasePath;
1573 case CK_AddressSpaceConversion:
1574 assert(
getType()->isPointerType() ||
getType()->isBlockPointerType());
1577 assert(
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!");
1638 #define CAST_OPERATION(Name) case CK_##Name: return #Name;
1639 #include "clang/AST/OperationKinds.def"
1641 llvm_unreachable(
"Unhandled cast kind!");
1645 Expr *skipImplicitTemporary(
Expr *expr) {
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");
1702 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1703 void *
Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1707 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1713 unsigned PathSize) {
1714 void *
Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1724 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1725 void *
Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1729 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1735 unsigned PathSize) {
1736 void *
Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1744 #define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling;
1745 #include "clang/AST/OperationKinds.def"
1747 llvm_unreachable(
"Invalid OpCode!");
1753 default: llvm_unreachable(
"Not an overloadable binary operator");
1754 case OO_Plus:
return BO_Add;
1755 case OO_Minus:
return BO_Sub;
1756 case OO_Star:
return BO_Mul;
1757 case OO_Slash:
return BO_Div;
1758 case OO_Percent:
return BO_Rem;
1759 case OO_Caret:
return BO_Xor;
1760 case OO_Amp:
return BO_And;
1761 case OO_Pipe:
return BO_Or;
1762 case OO_Equal:
return BO_Assign;
1763 case OO_Less:
return BO_LT;
1764 case OO_Greater:
return BO_GT;
1765 case OO_PlusEqual:
return BO_AddAssign;
1766 case OO_MinusEqual:
return BO_SubAssign;
1767 case OO_StarEqual:
return BO_MulAssign;
1768 case OO_SlashEqual:
return BO_DivAssign;
1769 case OO_PercentEqual:
return BO_RemAssign;
1770 case OO_CaretEqual:
return BO_XorAssign;
1771 case OO_AmpEqual:
return BO_AndAssign;
1772 case OO_PipeEqual:
return BO_OrAssign;
1773 case OO_LessLess:
return BO_Shl;
1774 case OO_GreaterGreater:
return BO_Shr;
1775 case OO_LessLessEqual:
return BO_ShlAssign;
1776 case OO_GreaterGreaterEqual:
return BO_ShrAssign;
1777 case OO_EqualEqual:
return BO_EQ;
1778 case OO_ExclaimEqual:
return BO_NE;
1779 case OO_LessEqual:
return BO_LE;
1780 case OO_GreaterEqual:
return BO_GE;
1781 case OO_AmpAmp:
return BO_LAnd;
1782 case OO_PipePipe:
return BO_LOr;
1783 case OO_Comma:
return BO_Comma;
1784 case OO_ArrowStar:
return BO_PtrMemI;
1791 OO_Star, OO_Slash, OO_Percent,
1793 OO_LessLess, OO_GreaterGreater,
1794 OO_Less, OO_Greater, OO_LessEqual, OO_GreaterEqual,
1795 OO_EqualEqual, OO_ExclaimEqual,
1801 OO_Equal, OO_StarEqual,
1802 OO_SlashEqual, OO_PercentEqual,
1803 OO_PlusEqual, OO_MinusEqual,
1804 OO_LessLessEqual, OO_GreaterGreaterEqual,
1805 OO_AmpEqual, OO_CaretEqual,
1809 return OverOps[Opc];
1816 InitExprs(C, initExprs.size()),
1817 LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(nullptr,
true)
1820 for (
unsigned I = 0;
I != initExprs.size(); ++
I) {
1826 ExprBits.InstantiationDependent =
true;
1828 ExprBits.ContainsUnexpandedParameterPack =
true;
1831 InitExprs.
insert(C, InitExprs.
end(), initExprs.begin(), initExprs.end());
1835 if (NumInits > InitExprs.
size())
1836 InitExprs.
reserve(C, NumInits);
1840 InitExprs.
resize(C, NumInits,
nullptr);
1844 if (Init >= InitExprs.
size()) {
1845 InitExprs.
insert(C, InitExprs.
end(), Init - InitExprs.
size() + 1,
nullptr);
1850 Expr *
Result = cast_or_null<Expr>(InitExprs[Init]);
1857 ArrayFillerOrUnionFieldInit = filler;
1860 for (
unsigned i = 0, e =
getNumInits(); i != e; ++i)
1861 if (inits[i] ==
nullptr)
1876 return isa<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init);
1880 assert(
isSemanticForm() &&
"syntactic form never semantically transparent");
1884 assert(
getNumInits() == 1 &&
"multiple inits in glvalue init list");
1904 return SyntacticForm->getLocStart();
1909 E = InitExprs.
end();
1912 Beg =
S->getLocStart();
1922 return SyntacticForm->getLocEnd();
1927 E = InitExprs.
rend();
1930 End =
S->getLocEnd();
1942 return cast<BlockPointerType>(
getType())
1981 case ParenExprClass:
1982 return cast<ParenExpr>(
this)->getSubExpr()->
1984 case GenericSelectionExprClass:
1985 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
1987 case ChooseExprClass:
1988 return cast<ChooseExpr>(
this)->getChosenSubExpr()->
1990 case UnaryOperatorClass: {
2013 .isVolatileQualified())
2024 case BinaryOperatorClass: {
2036 if (IE->getValue() == 0)
2055 case CompoundAssignOperatorClass:
2056 case VAArgExprClass:
2057 case AtomicExprClass:
2060 case ConditionalOperatorClass: {
2072 case MemberExprClass:
2074 Loc = cast<MemberExpr>(
this)->getMemberLoc();
2076 R2 = cast<MemberExpr>(
this)->getBase()->getSourceRange();
2079 case ArraySubscriptExprClass:
2081 Loc = cast<ArraySubscriptExpr>(
this)->getRBracketLoc();
2082 R1 = cast<ArraySubscriptExpr>(
this)->getLHS()->getSourceRange();
2083 R2 = cast<ArraySubscriptExpr>(
this)->getRHS()->getSourceRange();
2086 case CXXOperatorCallExprClass: {
2098 case OO_ExclaimEqual:
2101 case OO_GreaterEqual:
2116 case CXXMemberCallExprClass:
2117 case UserDefinedLiteralClass: {
2119 const CallExpr *CE = cast<CallExpr>(
this);
2123 : FD->hasAttr<WarnUnusedResultAttr>();
2130 if (HasWarnUnusedResultAttr ||
2131 FD->hasAttr<PureAttr>() || FD->hasAttr<ConstAttr>()) {
2146 case UnresolvedLookupExprClass:
2147 case CXXUnresolvedConstructExprClass:
2150 case CXXTemporaryObjectExprClass:
2151 case CXXConstructExprClass: {
2153 if (Type->hasAttr<WarnUnusedAttr>()) {
2163 case ObjCMessageExprClass: {
2176 if (MD->hasAttr<WarnUnusedResultAttr>()) {
2185 case ObjCPropertyRefExprClass:
2191 case PseudoObjectExprClass: {
2205 case StmtExprClass: {
2211 const CompoundStmt *CS = cast<StmtExpr>(
this)->getSubStmt();
2214 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2216 if (
const Expr *
E = dyn_cast<Expr>(
Label->getSubStmt()))
2217 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2223 Loc = cast<StmtExpr>(
this)->getLParenLoc();
2227 case CXXFunctionalCastExprClass:
2228 case CStyleCastExprClass: {
2231 const CastExpr *CE = cast<CastExpr>(
this);
2237 if (!(DRE && isa<VarDecl>(DRE->
getDecl()) &&
2238 cast<VarDecl>(DRE->
getDecl())->hasLocalStorage())) {
2248 if (CE->
getCastKind() == CK_ConstructorConversion)
2253 dyn_cast<CXXFunctionalCastExpr>(
this)) {
2254 Loc = CXXCE->getLocStart();
2255 R1 = CXXCE->getSubExpr()->getSourceRange();
2263 case ImplicitCastExprClass: {
2264 const CastExpr *ICE = cast<ImplicitCastExpr>(
this);
2273 case CXXDefaultArgExprClass:
2274 return (cast<CXXDefaultArgExpr>(
this)
2276 case CXXDefaultInitExprClass:
2277 return (cast<CXXDefaultInitExpr>(
this)
2280 case CXXNewExprClass:
2283 case CXXDeleteExprClass:
2285 case MaterializeTemporaryExprClass:
2286 return cast<MaterializeTemporaryExpr>(
this)->GetTemporaryExpr()
2287 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2288 case CXXBindTemporaryExprClass:
2289 return cast<CXXBindTemporaryExpr>(
this)->getSubExpr()
2290 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2291 case ExprWithCleanupsClass:
2292 return cast<ExprWithCleanups>(
this)->getSubExpr()
2293 ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2304 case ObjCIvarRefExprClass:
2306 case Expr::UnaryOperatorClass:
2307 return cast<UnaryOperator>(
E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2308 case ImplicitCastExprClass:
2309 return cast<ImplicitCastExpr>(
E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2310 case MaterializeTemporaryExprClass:
2311 return cast<MaterializeTemporaryExpr>(
E)->GetTemporaryExpr()
2312 ->isOBJCGCCandidate(Ctx);
2313 case CStyleCastExprClass:
2314 return cast<CStyleCastExpr>(
E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2315 case DeclRefExprClass: {
2316 const Decl *D = cast<DeclRefExpr>(
E)->getDecl();
2318 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2319 if (VD->hasGlobalStorage())
2329 case MemberExprClass: {
2333 case ArraySubscriptExprClass:
2334 return cast<ArraySubscriptExpr>(
E)->getBase()->isOBJCGCCandidate(Ctx);
2352 if (
const MemberExpr *mem = dyn_cast<MemberExpr>(expr)) {
2353 assert(isa<CXXMethodDecl>(mem->getMemberDecl()));
2354 return mem->getMemberDecl()->getType();
2364 assert(isa<UnresolvedMemberExpr>(expr) || isa<CXXPseudoDestructorExpr>(expr));
2372 E =
P->getSubExpr();
2376 if (
P->getOpcode() == UO_Extension) {
2377 E =
P->getSubExpr();
2382 if (!
P->isResultDependent()) {
2383 E =
P->getResultExpr();
2388 if (!
P->isConditionDependent()) {
2389 E =
P->getChosenSubExpr();
2403 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2404 E =
P->getSubExpr();
2408 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2409 E = Materialize->GetTemporaryExpr();
2413 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2414 E = NTTP->getReplacement();
2424 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2425 E =
P->getSubExpr();
2429 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2430 E = Materialize->GetTemporaryExpr();
2434 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2435 E = NTTP->getReplacement();
2450 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2451 if (
P->getCastKind() == CK_LValueToRValue) {
2452 E =
P->getSubExpr();
2456 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2457 E = Materialize->GetTemporaryExpr();
2460 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2461 E = NTTP->getReplacement();
2473 if (
CastExpr *CE = dyn_cast<CastExpr>(E)) {
2474 if (CE->getCastKind() == CK_DerivedToBase ||
2475 CE->getCastKind() == CK_UncheckedDerivedToBase ||
2476 CE->getCastKind() == CK_NoOp) {
2477 E = CE->getSubExpr();
2491 E =
P->getSubExpr();
2495 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2496 E = Materialize->GetTemporaryExpr();
2500 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2501 E = NTTP->getReplacement();
2510 if (MCE->getMethodDecl() && isa<CXXConversionDecl>(MCE->getMethodDecl()))
2511 return MCE->getImplicitObjectArgument();
2524 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2527 Expr *SE =
P->getSubExpr();
2545 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2546 E = NTTP->getReplacement();
2555 const Expr *
E =
this;
2557 E = M->GetTemporaryExpr();
2560 E = ICE->getSubExprAsWritten();
2562 return isa<CXXDefaultArgExpr>(
E);
2569 E = M->GetTemporaryExpr();
2572 if (ICE->getCastKind() == CK_NoOp)
2573 E = ICE->getSubExpr();
2579 E = BE->getSubExpr();
2582 if (ICE->getCastKind() == CK_NoOp)
2583 E = ICE->getSubExpr();
2602 if (!isa<ObjCPropertyRefExpr>(E))
2610 if (isa<ImplicitCastExpr>(E)) {
2611 switch (cast<ImplicitCastExpr>(E)->getCastKind()) {
2612 case CK_DerivedToBase:
2613 case CK_UncheckedDerivedToBase:
2621 if (isa<MemberExpr>(E))
2625 if (BO->isPtrMemOp())
2629 if (isa<OpaqueValueExpr>(E))
2636 const Expr *
E =
this;
2641 E =
Paren->getSubExpr();
2646 if (ICE->getCastKind() == CK_NoOp ||
2647 ICE->getCastKind() == CK_LValueToRValue ||
2648 ICE->getCastKind() == CK_DerivedToBase ||
2649 ICE->getCastKind() == CK_UncheckedDerivedToBase) {
2650 E = ICE->getSubExpr();
2655 if (
const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) {
2656 if (UnOp->getOpcode() == UO_Extension) {
2657 E = UnOp->getSubExpr();
2663 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2664 E = M->GetTemporaryExpr();
2671 if (
const CXXThisExpr *This = dyn_cast<CXXThisExpr>(E))
2672 return This->isImplicit();
2680 for (
unsigned I = 0;
I < Exprs.size(); ++
I)
2688 const Expr **Culprit)
const {
2709 case StringLiteralClass:
2710 case ObjCEncodeExprClass:
2712 case CXXTemporaryObjectExprClass:
2713 case CXXConstructExprClass: {
2722 assert(CE->
getNumArgs() == 1 &&
"trivial ctor with > 1 argument");
2728 case CompoundLiteralExprClass: {
2732 const Expr *Exp = cast<CompoundLiteralExpr>(
this)->getInitializer();
2735 case DesignatedInitUpdateExprClass: {
2740 case InitListExprClass: {
2744 for (
unsigned i = 0; i < numInits; i++) {
2752 unsigned ElementNo = 0;
2754 for (
const auto *Field : RD->
fields()) {
2760 if (Field->isUnnamedBitfield())
2763 if (ElementNo < ILE->getNumInits()) {
2765 if (Field->isBitField()) {
2767 llvm::APSInt ResultTmp;
2774 bool RefType = Field->getType()->isReferenceType();
2785 case ImplicitValueInitExprClass:
2786 case NoInitExprClass:
2788 case ParenExprClass:
2789 return cast<ParenExpr>(
this)->getSubExpr()
2790 ->isConstantInitializer(Ctx, IsForRef, Culprit);
2791 case GenericSelectionExprClass:
2792 return cast<GenericSelectionExpr>(
this)->getResultExpr()
2793 ->isConstantInitializer(Ctx, IsForRef, Culprit);
2794 case ChooseExprClass:
2795 if (cast<ChooseExpr>(
this)->isConditionDependent()) {
2800 return cast<ChooseExpr>(
this)->getChosenSubExpr()
2802 case UnaryOperatorClass: {
2808 case CXXFunctionalCastExprClass:
2809 case CXXStaticCastExprClass:
2810 case ImplicitCastExprClass:
2811 case CStyleCastExprClass:
2812 case ObjCBridgedCastExprClass:
2813 case CXXDynamicCastExprClass:
2814 case CXXReinterpretCastExprClass:
2815 case CXXConstCastExprClass: {
2816 const CastExpr *CE = cast<CastExpr>(
this);
2830 case MaterializeTemporaryExprClass:
2831 return cast<MaterializeTemporaryExpr>(
this)->GetTemporaryExpr()
2832 ->isConstantInitializer(Ctx,
false, Culprit);
2834 case SubstNonTypeTemplateParmExprClass:
2835 return cast<SubstNonTypeTemplateParmExpr>(
this)->getReplacement()
2836 ->isConstantInitializer(Ctx,
false, Culprit);
2837 case CXXDefaultArgExprClass:
2838 return cast<CXXDefaultArgExpr>(
this)->getExpr()
2839 ->isConstantInitializer(Ctx,
false, Culprit);
2840 case CXXDefaultInitExprClass:
2841 return cast<CXXDefaultInitExpr>(
this)->getExpr()
2842 ->isConstantInitializer(Ctx,
false, Culprit);
2858 const bool IncludePossibleEffects;
2859 bool HasSideEffects;
2863 : Inherited(Context),
2864 IncludePossibleEffects(IncludePossible), HasSideEffects(
false) { }
2868 void VisitExpr(
const Expr *
E) {
2869 if (!HasSideEffects &&
2871 HasSideEffects =
true;
2877 bool IncludePossibleEffects)
const {
2881 if (!IncludePossibleEffects &&
getExprLoc().isMacroID())
2885 return IncludePossibleEffects;
2889 #define ABSTRACT_STMT(Type)
2890 #define STMT(Type, Base) case Type##Class:
2891 #define EXPR(Type, Base)
2892 #include "clang/AST/StmtNodes.inc"
2893 llvm_unreachable(
"unexpected Expr kind");
2895 case DependentScopeDeclRefExprClass:
2896 case CXXUnresolvedConstructExprClass:
2897 case CXXDependentScopeMemberExprClass:
2898 case UnresolvedLookupExprClass:
2899 case UnresolvedMemberExprClass:
2900 case PackExpansionExprClass:
2901 case SubstNonTypeTemplateParmPackExprClass:
2902 case FunctionParmPackExprClass:
2904 case CXXFoldExprClass:
2905 llvm_unreachable(
"shouldn't see dependent / unresolved nodes here");
2907 case DeclRefExprClass:
2908 case ObjCIvarRefExprClass:
2909 case PredefinedExprClass:
2910 case IntegerLiteralClass:
2911 case FloatingLiteralClass:
2912 case ImaginaryLiteralClass:
2913 case StringLiteralClass:
2914 case CharacterLiteralClass:
2915 case OffsetOfExprClass:
2916 case ImplicitValueInitExprClass:
2917 case UnaryExprOrTypeTraitExprClass:
2918 case AddrLabelExprClass:
2919 case GNUNullExprClass:
2920 case ArrayInitIndexExprClass:
2921 case NoInitExprClass:
2922 case CXXBoolLiteralExprClass:
2923 case CXXNullPtrLiteralExprClass:
2924 case CXXThisExprClass:
2925 case CXXScalarValueInitExprClass:
2926 case TypeTraitExprClass:
2927 case ArrayTypeTraitExprClass:
2928 case ExpressionTraitExprClass:
2929 case CXXNoexceptExprClass:
2930 case SizeOfPackExprClass:
2931 case ObjCStringLiteralClass:
2932 case ObjCEncodeExprClass:
2933 case ObjCBoolLiteralExprClass:
2934 case ObjCAvailabilityCheckExprClass:
2935 case CXXUuidofExprClass:
2936 case OpaqueValueExprClass:
2941 case CXXOperatorCallExprClass:
2942 case CXXMemberCallExprClass:
2943 case CUDAKernelCallExprClass:
2944 case UserDefinedLiteralClass: {
2948 const Decl *FD = cast<CallExpr>(
this)->getCalleeDecl();
2949 bool IsPure = FD && (FD->
hasAttr<ConstAttr>() || FD->
hasAttr<PureAttr>());
2950 if (IsPure || !IncludePossibleEffects)
2955 case BlockExprClass:
2956 case CXXBindTemporaryExprClass:
2957 if (!IncludePossibleEffects)
2961 case MSPropertyRefExprClass:
2962 case MSPropertySubscriptExprClass:
2963 case CompoundAssignOperatorClass:
2964 case VAArgExprClass:
2965 case AtomicExprClass:
2966 case CXXThrowExprClass:
2967 case CXXNewExprClass:
2968 case CXXDeleteExprClass:
2969 case CoawaitExprClass:
2970 case DependentCoawaitExprClass:
2971 case CoyieldExprClass:
2975 case StmtExprClass: {
2977 SideEffectFinder
Finder(Ctx, IncludePossibleEffects);
2978 Finder.Visit(cast<StmtExpr>(
this)->getSubStmt());
2979 return Finder.hasSideEffects();
2982 case ExprWithCleanupsClass:
2983 if (IncludePossibleEffects)
2984 if (cast<ExprWithCleanups>(
this)->cleanupsHaveSideEffects())
2988 case ParenExprClass:
2989 case ArraySubscriptExprClass:
2990 case OMPArraySectionExprClass:
2991 case MemberExprClass:
2992 case ConditionalOperatorClass:
2993 case BinaryConditionalOperatorClass:
2994 case CompoundLiteralExprClass:
2995 case ExtVectorElementExprClass:
2996 case DesignatedInitExprClass:
2997 case DesignatedInitUpdateExprClass:
2998 case ArrayInitLoopExprClass:
2999 case ParenListExprClass:
3000 case CXXPseudoDestructorExprClass:
3001 case CXXStdInitializerListExprClass:
3002 case SubstNonTypeTemplateParmExprClass:
3003 case MaterializeTemporaryExprClass:
3004 case ShuffleVectorExprClass:
3005 case ConvertVectorExprClass:
3006 case AsTypeExprClass:
3010 case UnaryOperatorClass:
3011 if (cast<UnaryOperator>(
this)->isIncrementDecrementOp())
3015 case BinaryOperatorClass:
3016 if (cast<BinaryOperator>(
this)->isAssignmentOp())
3020 case InitListExprClass:
3022 if (
const Expr *
E = cast<InitListExpr>(
this)->getArrayFiller())
3023 if (
E->HasSideEffects(Ctx, IncludePossibleEffects))
3027 case GenericSelectionExprClass:
3028 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
3031 case ChooseExprClass:
3032 return cast<ChooseExpr>(
this)->getChosenSubExpr()->HasSideEffects(
3033 Ctx, IncludePossibleEffects);
3035 case CXXDefaultArgExprClass:
3036 return cast<CXXDefaultArgExpr>(
this)->getExpr()->HasSideEffects(
3037 Ctx, IncludePossibleEffects);
3039 case CXXDefaultInitExprClass: {
3040 const FieldDecl *FD = cast<CXXDefaultInitExpr>(
this)->getField();
3042 return E->HasSideEffects(Ctx, IncludePossibleEffects);
3047 case CXXDynamicCastExprClass: {
3054 case ImplicitCastExprClass:
3055 case CStyleCastExprClass:
3056 case CXXStaticCastExprClass:
3057 case CXXReinterpretCastExprClass:
3058 case CXXConstCastExprClass:
3059 case CXXFunctionalCastExprClass: {
3064 if (!IncludePossibleEffects)
3067 const CastExpr *CE = cast<CastExpr>(
this);
3074 case CXXTypeidExprClass:
3077 return cast<CXXTypeidExpr>(
this)->isPotentiallyEvaluated();
3079 case CXXConstructExprClass:
3080 case CXXTemporaryObjectExprClass: {
3089 case CXXInheritedCtorInitExprClass: {
3090 const auto *ICIE = cast<CXXInheritedCtorInitExpr>(
this);
3091 if (!ICIE->getConstructor()->isTrivial() && IncludePossibleEffects)
3096 case LambdaExprClass: {
3097 const LambdaExpr *LE = cast<LambdaExpr>(
this);
3107 case PseudoObjectExprClass: {
3114 const Expr *Subexpr = *
I;
3116 Subexpr = OVE->getSourceExpr();
3123 case ObjCBoxedExprClass:
3124 case ObjCArrayLiteralClass:
3125 case ObjCDictionaryLiteralClass:
3126 case ObjCSelectorExprClass:
3127 case ObjCProtocolExprClass:
3128 case ObjCIsaExprClass:
3129 case ObjCIndirectCopyRestoreExprClass:
3130 case ObjCSubscriptRefExprClass:
3131 case ObjCBridgedCastExprClass:
3132 case ObjCMessageExprClass:
3133 case ObjCPropertyRefExprClass:
3135 if (IncludePossibleEffects)
3143 cast<Expr>(SubStmt)->HasSideEffects(Ctx, IncludePossibleEffects))
3159 : Inherited(Context), NonTrivial(
false) { }
3161 bool hasNonTrivialCall()
const {
return NonTrivial; }
3165 = dyn_cast_or_null<const CXXMethodDecl>(E->
getCalleeDecl())) {
3166 if (Method->isTrivial()) {
3168 Inherited::VisitStmt(E);
3179 Inherited::VisitStmt(E);
3188 Inherited::VisitStmt(E);
3198 NonTrivialCallFinder
Finder(Ctx);
3200 return Finder.hasNonTrivialCall();
3215 llvm_unreachable(
"Unexpected value dependent expression!");
3236 bool IsASValid =
true;
3246 CE->getSubExpr()->getType()->isIntegerType())
3247 return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3250 }
else if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(
this)) {
3252 return ICE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3253 }
else if (
const ParenExpr *PE = dyn_cast<ParenExpr>(
this)) {
3256 return PE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3258 dyn_cast<GenericSelectionExpr>(
this)) {
3259 if (GE->isResultDependent())
3261 return GE->getResultExpr()->isNullPointerConstant(Ctx, NPC);
3262 }
else if (
const ChooseExpr *CE = dyn_cast<ChooseExpr>(
this)) {
3263 if (CE->isConditionDependent())
3265 return CE->getChosenSubExpr()->isNullPointerConstant(Ctx, NPC);
3267 = dyn_cast<CXXDefaultArgExpr>(
this)) {
3269 return DefaultArg->getExpr()->isNullPointerConstant(Ctx, NPC);
3271 = dyn_cast<CXXDefaultInitExpr>(
this)) {
3273 return DefaultInit->getExpr()->isNullPointerConstant(Ctx, NPC);
3274 }
else if (isa<GNUNullExpr>(
this)) {
3278 = dyn_cast<MaterializeTemporaryExpr>(
this)) {
3279 return M->GetTemporaryExpr()->isNullPointerConstant(Ctx, NPC);
3280 }
else if (
const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(
this)) {
3281 if (
const Expr *Source = OVE->getSourceExpr())
3282 return Source->isNullPointerConstant(Ctx, NPC);
3286 if (
getType()->isNullPtrType())
3291 UT && UT->getDecl()->hasAttr<TransparentUnionAttr>())
3293 const Expr *InitExpr = CLE->getInitializer();
3294 if (
const InitListExpr *ILE = dyn_cast<InitListExpr>(InitExpr))
3298 if (!
getType()->isIntegerType() ||
3321 if (isa<IntegerLiteral>(
this))
3329 const Expr *E =
this;
3333 "expression is not a property reference");
3336 if (BO->getOpcode() == BO_Comma) {
3345 return cast<ObjCPropertyRefExpr>(
E);
3370 if (ICE->getCastKind() == CK_LValueToRValue ||
3371 (ICE->getValueKind() !=
VK_RValue && ICE->getCastKind() == CK_NoOp))
3377 if (
MemberExpr *MemRef = dyn_cast<MemberExpr>(E))
3378 if (
FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
3379 if (Field->isBitField())
3383 if (
FieldDecl *Ivar = dyn_cast<FieldDecl>(IvarRef->getDecl()))
3384 if (Ivar->isBitField())
3387 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E)) {
3388 if (
FieldDecl *Field = dyn_cast<FieldDecl>(DeclRef->getDecl()))
3389 if (Field->isBitField())
3392 if (
BindingDecl *BD = dyn_cast<BindingDecl>(DeclRef->getDecl()))
3393 if (
Expr *E = BD->getBinding())
3398 if (BinOp->isAssignmentOp() && BinOp->getLHS())
3399 return BinOp->getLHS()->getSourceBitField();
3401 if (BinOp->getOpcode() == BO_Comma && BinOp->getRHS())
3402 return BinOp->getRHS()->getSourceBitField();
3406 if (UnOp->isPrefix() && UnOp->isIncrementDecrementOp())
3407 return UnOp->getSubExpr()->getSourceBitField();
3418 ICE->getCastKind() == CK_NoOp)
3427 if (isa<ExtVectorElementExpr>(E))
3430 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
3431 if (
auto *BD = dyn_cast<BindingDecl>(DRE->getDecl()))
3432 if (
auto *E = BD->getBinding())
3441 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
3442 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
3444 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
3458 return VT->getNumElements();
3466 StringRef Comp = Accessor->
getName();
3469 if (Comp ==
"hi" || Comp ==
"lo" || Comp ==
"even" || Comp ==
"odd")
3473 if (Comp[0] ==
's' || Comp[0] ==
'S')
3474 Comp = Comp.substr(1);
3476 for (
unsigned i = 0, e = Comp.size(); i != e; ++i)
3477 if (Comp.substr(i + 1).find(Comp[i]) != StringRef::npos)
3486 StringRef Comp = Accessor->
getName();
3487 bool isNumericAccessor =
false;
3488 if (Comp[0] ==
's' || Comp[0] ==
'S') {
3489 Comp = Comp.substr(1);
3490 isNumericAccessor =
true;
3493 bool isHi = Comp ==
"hi";
3494 bool isLo = Comp ==
"lo";
3495 bool isEven = Comp ==
"even";
3496 bool isOdd = Comp ==
"odd";
3512 Elts.push_back(Index);
3520 Type->isDependentType(), Type->isDependentType(),
3521 Type->isInstantiationDependentType(),
3522 Type->containsUnexpandedParameterPack()),
3523 BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size())
3525 SubExprs =
new (C)
Stmt*[args.size()];
3526 for (
unsigned i = 0; i != args.size(); i++) {
3532 ExprBits.InstantiationDependent =
true;
3534 ExprBits.ContainsUnexpandedParameterPack =
true;
3536 SubExprs[i] = args[i];
3543 this->NumExprs = Exprs.size();
3544 SubExprs =
new (C)
Stmt*[NumExprs];
3545 memcpy(SubExprs, Exprs.data(),
sizeof(
Expr *) * Exprs.size());
3554 bool ContainsUnexpandedParameterPack,
3555 unsigned ResultIndex)
3556 :
Expr(GenericSelectionExprClass,
3557 AssocExprs[ResultIndex]->getType(),
3558 AssocExprs[ResultIndex]->getValueKind(),
3559 AssocExprs[ResultIndex]->getObjectKind(),
3560 AssocExprs[ResultIndex]->isTypeDependent(),
3561 AssocExprs[ResultIndex]->isValueDependent(),
3562 AssocExprs[ResultIndex]->isInstantiationDependent(),
3563 ContainsUnexpandedParameterPack),
3565 SubExprs(new (Context)
Stmt*[END_EXPR+AssocExprs.size()]),
3566 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
3567 GenericLoc(GenericLoc), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
3568 SubExprs[CONTROLLING] = ControllingExpr;
3569 assert(AssocTypes.size() == AssocExprs.size());
3570 std::copy(AssocTypes.begin(), AssocTypes.end(), this->AssocTypes);
3571 std::copy(AssocExprs.begin(), AssocExprs.end(), SubExprs+END_EXPR);
3580 bool ContainsUnexpandedParameterPack)
3581 :
Expr(GenericSelectionExprClass,
3582 Context.DependentTy,
3588 ContainsUnexpandedParameterPack),
3590 SubExprs(new (Context)
Stmt*[END_EXPR+AssocExprs.size()]),
3591 NumAssocs(AssocExprs.size()), ResultIndex(-1U), GenericLoc(GenericLoc),
3592 DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
3593 SubExprs[CONTROLLING] = ControllingExpr;
3594 assert(AssocTypes.size() == AssocExprs.size());
3595 std::copy(AssocTypes.begin(), AssocTypes.end(), this->AssocTypes);
3596 std::copy(AssocExprs.begin(), AssocExprs.end(), SubExprs+END_EXPR);
3617 :
Expr(DesignatedInitExprClass, Ty,
3622 EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
3623 NumDesignators(Designators.
size()), NumSubExprs(IndexExprs.
size() + 1) {
3624 this->Designators =
new (C)
Designator[NumDesignators];
3632 unsigned IndexIdx = 0;
3633 for (
unsigned I = 0;
I != NumDesignators; ++
I) {
3634 this->Designators[
I] = Designators[
I];
3638 Expr *Index = IndexExprs[IndexIdx];
3642 ExprBits.InstantiationDependent =
true;
3645 ExprBits.ContainsUnexpandedParameterPack =
true;
3648 *Child++ = IndexExprs[IndexIdx++];
3651 Expr *Start = IndexExprs[IndexIdx];
3652 Expr *
End = IndexExprs[IndexIdx + 1];
3656 ExprBits.InstantiationDependent =
true;
3659 ExprBits.InstantiationDependent =
true;
3665 ExprBits.ContainsUnexpandedParameterPack =
true;
3668 *Child++ = IndexExprs[IndexIdx++];
3669 *Child++ = IndexExprs[IndexIdx++];
3673 assert(IndexIdx == IndexExprs.size() &&
"Wrong number of index expressions");
3681 bool UsesColonSyntax,
Expr *Init) {
3682 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(IndexExprs.size() + 1),
3685 ColonOrEqualLoc, UsesColonSyntax,
3690 unsigned NumIndexExprs) {
3691 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(NumIndexExprs + 1),
3698 unsigned NumDesigs) {
3700 NumDesignators = NumDesigs;
3701 for (
unsigned I = 0;
I != NumDesigs; ++
I)
3702 Designators[
I] = Desigs[
I];
3733 assert(D.Kind == Designator::ArrayDesignator &&
"Requires array designator");
3738 assert(D.Kind == Designator::ArrayRangeDesignator &&
3739 "Requires array range designator");
3744 assert(D.Kind == Designator::ArrayRangeDesignator &&
3745 "Requires array range designator");
3754 unsigned NumNewDesignators = Last - First;
3755 if (NumNewDesignators == 0) {
3756 std::copy_backward(Designators + Idx + 1,
3757 Designators + NumDesignators,
3759 --NumNewDesignators;
3761 }
else if (NumNewDesignators == 1) {
3762 Designators[Idx] = *First;
3767 =
new (C)
Designator[NumDesignators - 1 + NumNewDesignators];
3768 std::copy(Designators, Designators + Idx, NewDesignators);
3769 std::copy(First, Last, NewDesignators + Idx);
3770 std::copy(Designators + Idx + 1, Designators + NumDesignators,
3771 NewDesignators + Idx + NumNewDesignators);
3772 Designators = NewDesignators;
3773 NumDesignators = NumDesignators - 1 + NumNewDesignators;
3780 BaseAndUpdaterExprs[0] = baseExpr;
3784 BaseAndUpdaterExprs[1] = ILE;
3800 NumExprs(exprs.size()), LParenLoc(lparenloc), RParenLoc(rparenloc) {
3801 Exprs =
new (C)
Stmt*[exprs.size()];
3802 for (
unsigned i = 0; i != exprs.size(); ++i) {
3808 ExprBits.InstantiationDependent =
true;
3810 ExprBits.ContainsUnexpandedParameterPack =
true;
3812 Exprs[i] = exprs[i];
3818 e = ewc->getSubExpr();
3820 e = m->GetTemporaryExpr();
3821 e = cast<CXXConstructExpr>(e)->getArg(0);
3823 e = ice->getSubExpr();
3824 return cast<OpaqueValueExpr>(e);
3829 unsigned numSemanticExprs) {
3831 Context.
Allocate(totalSizeToAlloc<Expr *>(1 + numSemanticExprs),
3836 PseudoObjectExpr::PseudoObjectExpr(EmptyShell shell,
unsigned numSemanticExprs)
3837 :
Expr(PseudoObjectExprClass, shell) {
3843 unsigned resultIndex) {
3844 assert(syntax &&
"no syntactic expression!");
3845 assert(semantics.size() &&
"no semantic expressions!");
3853 assert(resultIndex < semantics.size());
3854 type = semantics[resultIndex]->getType();
3855 VK = semantics[resultIndex]->getValueKind();
3859 void *buffer = C.
Allocate(totalSizeToAlloc<Expr *>(semantics.size() + 1),
3867 unsigned resultIndex)
3873 for (
unsigned i = 0, e = semantics.size() + 1; i != e; ++i) {
3874 Expr *E = (i == 0 ? syntax : semantics[i-1]);
3875 getSubExprsBuffer()[i] =
E;
3882 ExprBits.InstantiationDependent =
true;
3884 ExprBits.ContainsUnexpandedParameterPack =
true;
3886 if (isa<OpaqueValueExpr>(E))
3887 assert(cast<OpaqueValueExpr>(E)->getSourceExpr() !=
nullptr &&
3888 "opaque-value semantic expressions for pseudo-object "
3889 "operations must have sources");
3921 NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op)
3923 assert(args.size() ==
getNumSubExprs(op) &&
"wrong number of subexpressions");
3924 for (
unsigned i = 0; i != args.size(); i++) {
3930 ExprBits.InstantiationDependent =
true;
3932 ExprBits.ContainsUnexpandedParameterPack =
true;
3934 SubExprs[i] = args[i];
3940 case AO__c11_atomic_init:
3941 case AO__c11_atomic_load:
3942 case AO__atomic_load_n:
3945 case AO__c11_atomic_store:
3946 case AO__c11_atomic_exchange:
3947 case AO__atomic_load:
3948 case AO__atomic_store:
3949 case AO__atomic_store_n:
3950 case AO__atomic_exchange_n:
3951 case AO__c11_atomic_fetch_add:
3952 case AO__c11_atomic_fetch_sub:
3953 case AO__c11_atomic_fetch_and:
3954 case AO__c11_atomic_fetch_or:
3955 case AO__c11_atomic_fetch_xor:
3956 case AO__atomic_fetch_add:
3957 case AO__atomic_fetch_sub:
3958 case AO__atomic_fetch_and:
3959 case AO__atomic_fetch_or:
3960 case AO__atomic_fetch_xor:
3961 case AO__atomic_fetch_nand:
3962 case AO__atomic_add_fetch:
3963 case AO__atomic_sub_fetch:
3964 case AO__atomic_and_fetch:
3965 case AO__atomic_or_fetch:
3966 case AO__atomic_xor_fetch:
3967 case AO__atomic_nand_fetch:
3970 case AO__atomic_exchange:
3973 case AO__c11_atomic_compare_exchange_strong:
3974 case AO__c11_atomic_compare_exchange_weak:
3977 case AO__atomic_compare_exchange:
3978 case AO__atomic_compare_exchange_n:
3981 llvm_unreachable(
"unknown atomic op");
3985 unsigned ArraySectionCount = 0;
3986 while (
auto *OASE = dyn_cast<OMPArraySectionExpr>(Base->
IgnoreParens())) {
3987 Base = OASE->getBase();
3988 ++ArraySectionCount;
3992 Base = ASE->getBase();
3993 ++ArraySectionCount;
3996 auto OriginalTy = Base->
getType();
3997 if (
auto *DRE = dyn_cast<DeclRefExpr>(Base))
3998 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl()))
3999 OriginalTy = PVD->getOriginalType().getNonReferenceType();
4001 for (
unsigned Cnt = 0; Cnt < ArraySectionCount; ++Cnt) {
4002 if (OriginalTy->isAnyPointerType())
4005 assert (OriginalTy->isArrayType());
child_iterator child_begin()
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
GenericSelectionExpr(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
A call to an overloaded operator written using operator syntax.
unsigned getAddressSpace() const
Return the address space of this type.
Represents a single C99 designator.
void setValueDependent(bool VD)
Set whether this expression is value-dependent or not.
Defines the clang::ASTContext interface.
unsigned getNumInits() const
bool containsDuplicateElements() const
containsDuplicateElements - Return true if any element access is repeated.
StmtClass getStmtClass() const
static std::string ComputeName(IdentType IT, const Decl *CurrentDecl)
CastKind getCastKind() const
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
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...
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
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...
void setArrayFiller(Expr *filler)
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
static StringLiteral * CreateEmpty(const ASTContext &C, unsigned NumStrs)
Construct an empty string literal.
ObjCMethodFamily getMethodFamily() const
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
static Decl * castFromDeclContext(const DeclContext *)
unsigned FieldLoc
The location of the field name in the designated initializer.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
SourceLocation getLocEnd() const LLVM_READONLY
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
Stmt - This represents one statement.
DesignatedInitUpdateExpr(const ASTContext &C, SourceLocation lBraceLoc, Expr *baseExprs, SourceLocation rBraceLoc)
SourceLocation getEndLoc() const
getEndLoc - Retrieve the location of the last token.
FunctionType - C99 6.7.5.3 - Function Declarators.
bool isArgumentType() const
unsigned getChar16Width() const
getChar16Width/Align - Return the size of 'char16_t' for this target, in bits.
Expr * getInit() const
Retrieve the initializer value.
unsigned getIntWidth(QualType T) const
bool isArrow() const
isArrow - Return true if the base expression is a pointer to vector, return false if the base express...
Defines the SourceManager interface.
reverse_iterator rbegin()
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
bool isRecordType() const
void setSemantics(const llvm::fltSemantics &Sem)
Set the APFloat semantics this literal uses.
Decl - This represents one declaration (or definition), e.g.
unsigned size() const
Returns the number of designators in this initializer.
AccessSpecifier getAccess() const
FloatingLiteralBitfields FloatingLiteralBits
Defines the C++ template declaration subclasses.
iterator insert(const ASTContext &C, iterator I, const T &Elt)
bool isEnumeralType() const
bool hasUnusedResultAttr() const
Returns true if this function or its return type has the warn_unused_result attribute.
ParenExpr - This represents a parethesized expression, e.g.
const char * getCastKindName() const
The base class of the type hierarchy.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
std::unique_ptr< llvm::MemoryBuffer > Buffer
InitListExpr * getSyntacticForm() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
void getEncodedElementAccess(SmallVectorImpl< uint32_t > &Elts) const
getEncodedElementAccess - Encode the elements accessed into an llvm aggregate Constant of ConstantInt...
Represents a call to a C++ constructor.
NamedDecl * getParam(unsigned Idx)
bool isBooleanType() const
A container of type source information.
SourceLocation getOperatorLoc() const
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...
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
Describes the capture of a variable or of this, or of a C++1y init-capture.
Represents a C++ constructor within a class.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Expr * getInClassInitializer() const
getInClassInitializer - Get the C++11 in-class initializer for this member, or null if one has not be...
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Expr * ignoreParenBaseCasts() LLVM_READONLY
Ignore parentheses and derived-to-base casts.
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
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)?
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.
unsigned getChar32Width() const
getChar32Width/Align - Return the size of 'char32_t' for this target, in bits.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
CompoundLiteralExpr - [C99 6.5.2.5].
const Expr * getCallee() const
MangleContext * createMangleContext()
AccessSpecifier getAccess() const
CallingConv getCallConv() const
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
void setInit(unsigned Init, Expr *expr)
ObjCMethodDecl - Represents an instance or class method declaration.
PredefinedExpr(SourceLocation L, QualType FNTy, IdentType IT, StringLiteral *SL)
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.
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Describes how types, statements, expressions, and declarations should be printed. ...
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
static bool isAssignmentOp(Opcode Opc)
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Defines the clang::Expr interface and subclasses for C++ expressions.
Expr * getArrayIndex(const Designator &D) const
The collection of all-type qualifiers we support.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
LabelStmt - Represents a label, which has a substatement.
RecordDecl - Represents a struct/union/class.
Represents a C99 designated initializer expression.
bool refersToGlobalRegisterVar() const
Returns whether this expression refers to a global register variable.
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...
Expr * getSubExpr(unsigned Idx) const
StmtIterator cast_away_const(const ConstStmtIterator &RHS)
StringRef getBufferData(FileID FID, bool *Invalid=nullptr) const
Return a StringRef to the source buffer data for the specified FileID.
ShuffleVectorExpr(const ASTContext &C, ArrayRef< Expr * > args, QualType Type, SourceLocation BLoc, SourceLocation RP)
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.
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
bool isReferenceType() const
bool isImplicitCXXThis() const
Whether this expression is an implicit reference to 'this' in C++.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
bool isSemanticForm() const
void setNumArgs(const ASTContext &C, unsigned NumArgs)
setNumArgs - This changes the number of arguments present in this call.
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
bool isUnevaluated(unsigned ID) const
Returns true if this builtin does not perform the side-effects of its arguments.
void Deallocate(void *Ptr) const
const Stmt * getBody() const
unsigned getOffsetOfStringByte(const Token &TheTok, unsigned ByteNo) const
getOffsetOfStringByte - This function returns the offset of the specified byte of the string data rep...
const Expr * skipRValueSubobjectAdjustments() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
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)
Stmt * getBody() const override
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
void setComponent(unsigned Idx, OffsetOfNode ON)
bool isExplicitSpecialization() const
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ObjCPropertyRefExpr * getObjCProperty() const
If this expression is an l-value for an Objective C property, find the underlying property reference ...
SourceLocation getRParenLoc() const
NestedNameSpecifierLoc QualifierLoc
The nested-name-specifier that qualifies the name, including source-location information.
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr * > exprs, SourceLocation RParenLoc)
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
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Describes an C or C++ initializer list.
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
uint32_t getCodeUnit(size_t i) const
void setValue(const ASTContext &C, const llvm::APInt &Val)
const TargetInfo & getTargetInfo() const
An lvalue ref-qualifier was provided (&).
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
const LangOptions & getLangOpts() const
CallExpr(const ASTContext &C, StmtClass SC, Expr *fn, ArrayRef< Expr * > preargs, ArrayRef< Expr * > args, QualType t, ExprValueKind VK, SourceLocation rparenloc)
< Capturing the *this object by copy
unsigned getLength() const
A convenient class for passing around template argument information.
DeclarationNameInfo getNameInfo() const
QualType getReturnType() const
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
field_range fields() const
NullPointerConstantValueDependence
Enumeration used to describe how isNullPointerConstant() should cope with value-dependent expressions...
static bool isRecordType(QualType T)
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
semantics_iterator semantics_end()
A builtin binary operation expression such as "x + y" or "x <= y".
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
RecordDecl * getDecl() const
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
bool isInstantiationDependent() const
Whether this nested name specifier involves a template parameter.
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
static bool isBooleanType(QualType Ty)
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
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...
std::reverse_iterator< const_iterator > const_reverse_iterator
Represents binding an expression to a temporary.
CXXTemporary * getTemporary()
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
unsigned getBuiltinCallee() const
getBuiltinCallee - If this is a call to a builtin, return the builtin ID of the callee.
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'.
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.
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.
detail::InMemoryDirectory::const_iterator I
A binding in a decomposition declaration.
unsigned getWCharWidth() const
getWCharWidth/Align - Return the size of 'wchar_t' for this target, in bits.
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)
uint64_t * pVal
Used to store the >64 bits integer value.
Represents the this expression in C++.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
ConditionalOperator - The ?: ternary operator.
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type...
llvm::APInt getValue() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
Represents a prototype with parameter type info, e.g.
IdentifierInfo * getFieldName() const
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
Expr * IgnoreParenNoopCasts(ASTContext &Ctx) LLVM_READONLY
IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the value (including ptr->int ...
bool isOBJCGCCandidate(ASTContext &Ctx) const
isOBJCGCCandidate - Return true if this expression may be used in a read/ write barrier.
CastKind
CastKind - The kind of operation required for a conversion.
SourceRange getDesignatorsSourceRange() const
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
SourceLocation getLocEnd() const LLVM_READONLY
Specifies that the expression should never be value-dependent.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
NamedDecl * getDecl() const
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
Exposes information about the current target.
InitListExpr(const ASTContext &C, SourceLocation lbraceloc, ArrayRef< Expr * > initExprs, SourceLocation rbraceloc)
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
const ObjCMethodDecl * getMethodDecl() const
bool isObjCSelfExpr() const
Check if this expression is the ObjC 'self' implicit parameter.
void setString(const ASTContext &C, StringRef Str, StringKind Kind, bool IsPascal)
Sets the string data to the given string data.
SourceLocation getLocStart() const LLVM_READONLY
bool isKnownToHaveBooleanValue() const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
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
StringRef getName() const
Return the actual identifier string.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
void outputString(raw_ostream &OS) const
double getValueAsApproximateDouble() const
getValueAsApproximateDouble - This returns the value as an inaccurate double.
ConstStmtIterator const_child_iterator
SourceLocation getLocEnd() const LLVM_READONLY
void setTypeDependent(bool TD)
Set whether this expression is type-dependent or not.
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...
Represents a C++ destructor within a class.
SourceRange getSourceRange() const
SourceLocation getLocEnd() const LLVM_READONLY
const ParmVarDecl * getParamDecl(unsigned i) const
Expr * getArrayRangeStart(const Designator &D) const
DeclContext * getDeclContext()
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
ImplicitParamDecl * getSelfDecl() const
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
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.
SourceLocation getLocEnd() const LLVM_READONLY
unsigned getNumSubExprs() const
Expr * getSubExpr() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
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...
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.
An expression that sends a message to the given Objective-C object or class.
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.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Allow UB that we can give a value, but not arbitrary unmodeled side effects.
The result type of a method or function.
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.
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name, with source-location information.
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...
InitListExpr * getUpdater() const
bool isArrayRangeDesignator() const
SourceLocation getCaretLocation() const
Expr * IgnoreCasts() LLVM_READONLY
Ignore casts. Strip off any CastExprs, returning their operand.
bool isBoundMemberFunction(ASTContext &Ctx) const
Returns true if this expression is a bound member function.
const llvm::fltSemantics & getSemantics() const
Return the APFloat semantics this literal uses.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Expr * IgnoreConversionOperator() LLVM_READONLY
IgnoreConversionOperator - Ignore conversion operator.
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]).
ASTMatchFinder *const Finder
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...
A field in a dependent type, known only by its name.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Expr * getArrayRangeEnd(const Designator &D) const
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Encodes a location in the source.
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
llvm::iterator_range< child_iterator > child_range
PseudoObjectExprBitfields PseudoObjectExprBits
Expression is not a Null pointer constant.
bool isImplicitAccess() const
Determine whether the base of this explicit is implicit.
bool isValid() const
Return true if this is a valid SourceLocation object.
FieldDecl * getField() const
Represents a call to a member function that may be written either with member call syntax (e...
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
ASTContext & getASTContext() const LLVM_READONLY
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.
static QualType getUnderlyingType(const SubRegion *R)
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Represents a static or instance method of a struct/union/class.
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
const CXXRecordDecl * getBestDynamicClassType() const
For an expression of class type or pointer to class type, return the most derived class decl the expr...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
SourceLocation getStrTokenLoc(unsigned TokNum) const
uint64_t VAL
Used to store the <= 64 bits integer value.
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...
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 isUnevaluatedBuiltinCall(const ASTContext &Ctx) const
Returns true if this is a call to a builtin which does not evaluate side-effects within its arguments...
StringLiteral * getFunctionName()
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
ParenListExpr(const ASTContext &C, SourceLocation lparenloc, ArrayRef< Expr * > exprs, SourceLocation rparenloc)
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 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.
const T * castAs() const
Member-template castAs<specific type>.
static DesignatedInitExpr * CreateEmpty(const ASTContext &C, unsigned NumIndexExprs)
static DesignatedInitExpr * Create(const ASTContext &C, llvm::ArrayRef< Designator > Designators, ArrayRef< Expr * > IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
bool isVectorType() const
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
uintptr_t NameOrField
Refers to the field that is being initialized.
An rvalue ref-qualifier was provided (&&).
SourceLocation getLocStart() const LLVM_READONLY
const Expr * getBase() const
unsigned LBracketLoc
The location of the '[' starting the array range designator.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
SourceLocation getLocStart() const LLVM_READONLY
void sawArrayRangeDesignator(bool ARD=true)
bool isCXX98IntegralConstantExpr(const ASTContext &Ctx) const
isCXX98IntegralConstantExpr - Return true if this expression is an integral constant expression in C+...
QualType getType() const
Return the type wrapped by this type source info.
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...
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
A POD class for pairing a NamedDecl* with an access specifier.
Represents a C11 generic selection.
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
SourceLocation getLParenLoc() const
StringRef getOpcodeStr() const
void setExprs(const ASTContext &C, ArrayRef< Expr * > Exprs)
SourceLocation getLocStart() const LLVM_READONLY
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
Enumeration specifying the different kinds of C++ overloaded operators.
Decl * getReferencedDeclOfCallee()
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
static LLVM_READONLY bool isPrintable(unsigned char c)
Return true if this character is an ASCII printable character; that is, a character that should take ...
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
AtomicExpr(SourceLocation BLoc, ArrayRef< Expr * > args, QualType t, AtomicOp op, SourceLocation RP)
unsigned getCharWidth() const
A field designator, e.g., ".x".
NestedNameSpecifierLoc getQualifierLoc() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
The same as PrettyFunction, except that the 'virtual' keyword is omitted for virtual member functions...
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
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)
void setInstantiationDependent(bool ID)
Set whether this expression is instantiation-dependent or not.
StringKind getKind() const
Expression is a C++11 nullptr.
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
semantics_iterator semantics_begin()
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
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...
unsigned getNumArgs() const
unsigned getNumConcatenated() const
getNumConcatenated - Get the number of string literal tokens that were concatenated in translation ph...
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr * > semantic, unsigned resultIndex)
llvm::APFloat getValue() const
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
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...
bool hasQualifier() const
Determine whether this declaration reference was preceded by a C++ nested-name-specifier, e.g., N::foo.
struct ArrayOrRangeDesignator ArrayOrRange
An array or GNU array-range designator, e.g., "[9]" or "[10..15]".
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...
Not an overloaded operator.
bool HasSideEffects
Whether the evaluated expression has side effects.
MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc, ValueDecl *memberdecl, const DeclarationNameInfo &NameInfo, QualType ty, ExprValueKind VK, ExprObjectKind OK)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Location wrapper for a TemplateArgument.
static const TypeInfo & getInfo(unsigned id)
SourceLocation getCaretLocation() const
const T * getAs() const
Member-template getAs<specific type>'.
llvm::iterator_range< const_child_iterator > const_child_range
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
SourceLocation getLocEnd() const LLVM_READONLY
QualType getCanonicalType() const
static StringRef getIdentTypeName(IdentType IT)
void setIndexExpr(unsigned Idx, Expr *E)
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
static ImplicitCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize)
SourceLocation getLocStart() const LLVM_READONLY
bool isFunctionType() const
Expr * IgnoreParenLValueCasts() LLVM_READONLY
Ignore parentheses and lvalue casts.
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
SourceLocation getLocEnd() const LLVM_READONLY
UnaryExprOrTypeTraitExprBitfields UnaryExprOrTypeTraitExprBits
Represents a base class of a C++ class.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
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
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.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
Represents a C++ struct/union/class.
bool hasQualifiers() const
Return true if the set contains any qualifiers.
bool hasNonTrivialCall(const ASTContext &Ctx) const
Determine whether this expression involves a call to any function that is not trivial.
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
void * Allocate(size_t Size, unsigned Align=8) const
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Builtin::Context & BuiltinInfo
FieldDecl * getField() const
For a field offsetof node, returns the field.
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list...
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]).
unsigned GetStringLength() const
Designator * getDesignator(unsigned Idx)
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
const Expr * getBestDynamicClassTypeExpr() const
Get the inner expression that determines the best dynamic class.
void reserveInits(const ASTContext &C, unsigned NumInits)
Reserve space for some number of initializers.
bool isIncompleteArrayType() const
bool isStringLiteralInit() const
DeclAccessPair FoundDecl
The DeclAccessPair through which the MemberDecl was found due to name qualifiers. ...
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
QualType getElementType() const
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
CallExprBitfields CallExprBits
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
const Expr * getInit(unsigned Init) const
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
bool isFieldDesignator() const
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
An l-value expression is a reference to an object with independent storage.
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...
unsigned getNumElements() const
getNumElements - Get the number of components being selected.
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.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
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...
static int getAccessorIdx(char c, bool isNumericAccessor)
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 ...
unsigned getNumPreArgs() const
SourceLocation getLocStart() const LLVM_READONLY
void removeAddressSpace()
bool isExplicitSpecialization() const
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
This class handles loading and caching of source files into memory.
const CXXDestructorDecl * getDestructor() const
bool isArrayDesignator() 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()...
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Kind getKind() const
Determine what kind of offsetof node this is.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isPointerType() const
SourceRange getSourceRange() const LLVM_READONLY
QualType getArgumentType() const
SourceLocation getLocStart() const LLVM_READONLY