33 #include "llvm/Support/ErrorHandling.h"
34 #include "llvm/Support/raw_ostream.h"
37 using namespace clang;
51 return cast<CXXRecordDecl>(D);
61 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
72 if (CE->getCastKind() ==
CK_NoOp) {
76 }
else if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
78 assert(ME->getBase()->getType()->isRecordType());
79 if (
FieldDecl *Field = dyn_cast<FieldDecl>(ME->getMemberDecl())) {
80 if (!Field->isBitField() && !Field->getType()->isReferenceType()) {
87 }
else if (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) {
88 if (BO->isPtrMemOp()) {
89 assert(BO->getRHS()->isRValue());
95 }
else if (BO->getOpcode() ==
BO_Comma) {
96 CommaLHSs.push_back(BO->getLHS());
121 switch (UO->getOpcode()) {
123 return UO->getSubExpr()->isKnownToHaveBooleanValue();
134 return CE->getSubExpr()->isKnownToHaveBooleanValue();
137 switch (BO->getOpcode()) {
138 default:
return false;
153 return BO->getLHS()->isKnownToHaveBooleanValue() &&
154 BO->getRHS()->isKnownToHaveBooleanValue();
158 return BO->getRHS()->isKnownToHaveBooleanValue();
163 return CO->getTrueExpr()->isKnownToHaveBooleanValue() &&
164 CO->getFalseExpr()->isKnownToHaveBooleanValue();
176 template <
class E,
class T>
179 return static_cast<const E*
>(
expr)->getExprLoc();
189 return static_cast<const E*
>(
expr)->getLocStart();
194 switch (getStmtClass()) {
195 case Stmt::NoStmtClass: llvm_unreachable(
"statement without class");
196 #define ABSTRACT_STMT(type)
197 #define STMT(type, base) \
198 case Stmt::type##Class: break;
199 #define EXPR(type, base) \
200 case Stmt::type##Class: return getExprLocImpl<type>(this, &type::getExprLoc);
201 #include "clang/AST/StmtNodes.inc"
203 llvm_unreachable(
"unknown expression kind");
215 bool &ValueDependent,
216 bool &InstantiationDependent) {
217 TypeDependent =
false;
218 ValueDependent =
false;
219 InstantiationDependent =
false;
232 TypeDependent =
true;
233 ValueDependent =
true;
234 InstantiationDependent =
true;
237 InstantiationDependent =
true;
245 TypeDependent =
true;
246 ValueDependent =
true;
247 InstantiationDependent =
true;
252 InstantiationDependent =
true;
256 if (isa<NonTypeTemplateParmDecl>(D)) {
257 ValueDependent =
true;
258 InstantiationDependent =
true;
269 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
271 Var->getType()->isLiteralType(Ctx) :
272 Var->getType()->isIntegralOrEnumerationType()) &&
273 (Var->getType().isConstQualified() ||
274 Var->getType()->isReferenceType())) {
275 if (
const Expr *Init = Var->getAnyInitializer())
276 if (Init->isValueDependent()) {
277 ValueDependent =
true;
278 InstantiationDependent =
true;
285 if (Var->isStaticDataMember() &&
286 Var->getDeclContext()->isDependentContext()) {
287 ValueDependent =
true;
288 InstantiationDependent =
true;
291 TypeDependent =
true;
301 ValueDependent =
true;
302 InstantiationDependent =
true;
306 void DeclRefExpr::computeDependence(
const ASTContext &Ctx) {
307 bool TypeDependent =
false;
308 bool ValueDependent =
false;
309 bool InstantiationDependent =
false;
311 ValueDependent, InstantiationDependent);
313 ExprBits.TypeDependent |= TypeDependent;
314 ExprBits.ValueDependent |= ValueDependent;
315 ExprBits.InstantiationDependent |= InstantiationDependent;
318 if (
getDecl()->isParameterPack())
319 ExprBits.ContainsUnexpandedParameterPack =
true;
322 DeclRefExpr::DeclRefExpr(
const ASTContext &Ctx,
325 ValueDecl *D,
bool RefersToEnclosingVariableOrCapture,
331 D(D), Loc(NameInfo.getLoc()), DNLoc(NameInfo.
getInfo()) {
332 DeclRefExprBits.HasQualifier = QualifierLoc ? 1 : 0;
334 new (getTrailingObjects<NestedNameSpecifierLoc>())
337 if (NNS->isInstantiationDependent())
338 ExprBits.InstantiationDependent =
true;
339 if (NNS->containsUnexpandedParameterPack())
340 ExprBits.ContainsUnexpandedParameterPack =
true;
342 DeclRefExprBits.HasFoundDecl = FoundD ? 1 : 0;
344 *getTrailingObjects<NamedDecl *>() = FoundD;
345 DeclRefExprBits.HasTemplateKWAndArgsInfo
346 = (TemplateArgs || TemplateKWLoc.
isValid()) ? 1 : 0;
347 DeclRefExprBits.RefersToEnclosingVariableOrCapture =
348 RefersToEnclosingVariableOrCapture;
350 bool Dependent =
false;
351 bool InstantiationDependent =
false;
352 bool ContainsUnexpandedParameterPack =
false;
353 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
354 TemplateKWLoc, *TemplateArgs, getTrailingObjects<TemplateArgumentLoc>(),
355 Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
356 assert(!Dependent &&
"built a DeclRefExpr with dependent template args");
357 ExprBits.InstantiationDependent |= InstantiationDependent;
358 ExprBits.ContainsUnexpandedParameterPack |= ContainsUnexpandedParameterPack;
359 }
else if (TemplateKWLoc.
isValid()) {
360 getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
363 DeclRefExprBits.HadMultipleCandidates = 0;
365 computeDependence(Ctx);
372 bool RefersToEnclosingVariableOrCapture,
378 return Create(Context, QualifierLoc, TemplateKWLoc, D,
379 RefersToEnclosingVariableOrCapture,
381 T, VK, FoundD, TemplateArgs);
388 bool RefersToEnclosingVariableOrCapture,
398 bool HasTemplateKWAndArgsInfo = TemplateArgs || TemplateKWLoc.
isValid();
402 QualifierLoc ? 1 : 0, FoundD ? 1 : 0,
403 HasTemplateKWAndArgsInfo ? 1 : 0,
404 TemplateArgs ? TemplateArgs->
size() : 0);
406 void *Mem = Context.
Allocate(Size, llvm::alignOf<DeclRefExpr>());
407 return new (Mem)
DeclRefExpr(Context, QualifierLoc, TemplateKWLoc, D,
408 RefersToEnclosingVariableOrCapture,
409 NameInfo, FoundD, TemplateArgs, T, VK);
415 bool HasTemplateKWAndArgsInfo,
416 unsigned NumTemplateArgs) {
417 assert(NumTemplateArgs == 0 || HasTemplateKWAndArgsInfo);
421 HasQualifier ? 1 : 0, HasFoundDecl ? 1 : 0, HasTemplateKWAndArgsInfo,
423 void *Mem = Context.
Allocate(Size, llvm::alignOf<DeclRefExpr>());
441 FNTy->isDependentType(), FNTy->isDependentType(),
442 FNTy->isInstantiationDependentType(),
444 Loc(L),
Type(IT), FnName(SL) {}
447 return cast_or_null<StringLiteral>(FnName);
455 return "__FUNCTION__";
457 return "__FUNCDNAME__";
459 return "L__FUNCTION__";
461 return "__PRETTY_FUNCTION__";
463 return "__FUNCSIG__";
467 llvm_unreachable(
"Unknown ident type for PredefinedExpr");
476 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(CurrentDecl)) {
477 std::unique_ptr<MangleContext> MC;
480 if (MC->shouldMangleDeclName(ND)) {
482 llvm::raw_svector_ostream Out(Buffer);
488 MC->mangleName(ND, Out);
490 if (!Buffer.empty() && Buffer.front() ==
'\01')
491 return Buffer.substr(1);
494 return ND->getIdentifier()->getName();
498 if (
auto *BD = dyn_cast<BlockDecl>(CurrentDecl)) {
499 std::unique_ptr<MangleContext> MC;
502 llvm::raw_svector_ostream Out(Buffer);
504 if (DC->isFileContext())
505 MC->mangleGlobalBlock(BD,
nullptr, Out);
506 else if (
const auto *CD = dyn_cast<CXXConstructorDecl>(DC))
508 else if (
const auto *DD = dyn_cast<CXXDestructorDecl>(DC))
511 MC->mangleBlock(DC, BD, Out);
514 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(CurrentDecl)) {
516 return FD->getNameAsString();
519 llvm::raw_svector_ostream Out(Name);
530 llvm::raw_string_ostream POut(Proto);
537 if (FD->hasWrittenPrototype())
538 FT = dyn_cast<FunctionProtoType>(AFT);
541 switch (FT->getCallConv()) {
542 case CC_C: POut <<
"__cdecl ";
break;
552 FD->printQualifiedName(POut, Policy);
556 for (
unsigned i = 0, e = Decl->
getNumParams(); i != e; ++i) {
561 if (FT->isVariadic()) {
562 if (FD->getNumParams()) POut <<
", ";
584 while (Ctx && isa<NamedDecl>(Ctx)) {
588 Specs.push_back(Spec);
592 std::string TemplateParams;
593 llvm::raw_string_ostream TOut(TemplateParams);
594 for (SpecsTy::reverse_iterator
I = Specs.rbegin(),
E = Specs.rend();
597 = (*I)->getSpecializedTemplate()->getTemplateParameters();
599 assert(Params->
size() == Args.
size());
600 for (
unsigned i = 0, numParams = Params->
size(); i != numParams; ++i) {
602 if (Param.empty())
continue;
603 TOut << Param <<
" = ";
610 = FD->getTemplateSpecializationInfo();
615 assert(Params->
size() == Args->
size());
616 for (
unsigned i = 0, e = Params->
size(); i != e; ++i) {
618 if (Param.empty())
continue;
619 TOut << Param <<
" = ";
626 if (!TemplateParams.empty()) {
628 TemplateParams.resize(TemplateParams.size() - 2);
629 POut <<
" [" << TemplateParams <<
"]";
638 if (isa<CXXMethodDecl>(FD) &&
639 cast<CXXMethodDecl>(FD)->getParent()->isLambda())
640 Proto =
"auto " + Proto;
641 else if (FT && FT->getReturnType()->getAs<
DecltypeType>())
646 else if (!isa<CXXConstructorDecl>(FD) && !isa<CXXDestructorDecl>(FD))
651 return Name.str().str();
653 if (
const CapturedDecl *CD = dyn_cast<CapturedDecl>(CurrentDecl)) {
657 if (DC->isFunctionOrMethod() && (DC->getDeclKind() != Decl::Captured)) {
661 llvm_unreachable(
"CapturedDecl not inside a function or method");
663 if (
const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(CurrentDecl)) {
665 llvm::raw_svector_ostream Out(Name);
666 Out << (MD->isInstanceMethod() ?
'-' :
'+');
675 dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext()))
676 Out <<
'(' << *CID <<
')';
679 MD->getSelector().print(Out);
682 return Name.str().str();
684 if (isa<TranslationUnitDecl>(CurrentDecl) && IT ==
PrettyFunction) {
692 const llvm::APInt &Val) {
696 BitWidth = Val.getBitWidth();
697 unsigned NumWords = Val.getNumWords();
698 const uint64_t* Words = Val.getRawData();
700 pVal =
new (
C) uint64_t[NumWords];
701 std::copy(Words, Words + NumWords,
pVal);
702 }
else if (NumWords == 1)
708 IntegerLiteral::IntegerLiteral(
const ASTContext &
C,
const llvm::APInt &V,
713 assert(type->
isIntegerType() &&
"Illegal type in IntegerLiteral");
715 "Integer type is not the correct size for constant.");
730 FloatingLiteral::FloatingLiteral(
const ASTContext &
C,
const llvm::APFloat &V,
734 setSemantics(V.getSemantics());
735 FloatingLiteralBits.IsExact = isexact;
739 FloatingLiteral::FloatingLiteral(
const ASTContext &C, EmptyShell Empty)
740 :
Expr(FloatingLiteralClass, Empty) {
741 setRawSemantics(IEEEhalf);
742 FloatingLiteralBits.IsExact =
false;
757 switch(FloatingLiteralBits.Semantics) {
759 return llvm::APFloat::IEEEhalf;
761 return llvm::APFloat::IEEEsingle;
763 return llvm::APFloat::IEEEdouble;
764 case x87DoubleExtended:
765 return llvm::APFloat::x87DoubleExtended;
767 return llvm::APFloat::IEEEquad;
768 case PPCDoubleDouble:
769 return llvm::APFloat::PPCDoubleDouble;
771 llvm_unreachable(
"Unrecognised floating semantics");
775 if (&Sem == &llvm::APFloat::IEEEhalf)
776 FloatingLiteralBits.Semantics = IEEEhalf;
777 else if (&Sem == &llvm::APFloat::IEEEsingle)
778 FloatingLiteralBits.Semantics = IEEEsingle;
779 else if (&Sem == &llvm::APFloat::IEEEdouble)
780 FloatingLiteralBits.Semantics = IEEEdouble;
781 else if (&Sem == &llvm::APFloat::x87DoubleExtended)
782 FloatingLiteralBits.Semantics = x87DoubleExtended;
783 else if (&Sem == &llvm::APFloat::IEEEquad)
784 FloatingLiteralBits.Semantics = IEEEquad;
785 else if (&Sem == &llvm::APFloat::PPCDoubleDouble)
786 FloatingLiteralBits.Semantics = PPCDoubleDouble;
788 llvm_unreachable(
"Unknown floating semantics");
797 V.convert(llvm::APFloat::IEEEdouble, llvm::APFloat::rmNearestTiesToEven,
799 return V.convertToDouble();
802 int StringLiteral::mapCharByteWidth(
TargetInfo const &target,StringKind k) {
803 int CharByteWidth = 0;
819 assert((CharByteWidth & 7) == 0 &&
"Assumes character size is byte multiple");
821 assert((CharByteWidth==1 || CharByteWidth==2 || CharByteWidth==4)
822 &&
"character byte widths supported are 1, 2, and 4 only");
823 return CharByteWidth;
831 "StringLiteral must be of constant array type!");
837 llvm::alignOf<StringLiteral>());
843 SL->TokLocs[0] = Loc[0];
844 SL->NumConcatenated = NumStrs;
847 memcpy(&SL->TokLocs[1], Loc+1,
sizeof(
SourceLocation)*(NumStrs-1));
855 llvm::alignOf<StringLiteral>());
857 SL->CharByteWidth = 0;
859 SL->NumConcatenated = NumStrs;
866 case Wide: OS <<
'L';
break;
867 case UTF8: OS <<
"u8";
break;
868 case UTF16: OS <<
'u';
break;
869 case UTF32: OS <<
'U';
break;
872 static const char Hex[] =
"0123456789ABCDEF";
885 if (Trail >= 0xdc00 && Trail <= 0xdfff) {
886 Char = 0x10000 + ((Char - 0xd800) << 10) + (Trail - 0xdc00);
896 (Char >= 0xd800 && Char <= 0xdfff) || Char >= 0x110000) {
900 while ((Char >> Shift) == 0)
902 for (; Shift >= 0; Shift -= 4)
903 OS << Hex[(Char >> Shift) & 15];
910 << Hex[(Char >> 20) & 15]
911 << Hex[(Char >> 16) & 15];
914 OS << Hex[(Char >> 12) & 15]
915 << Hex[(Char >> 8) & 15]
916 << Hex[(Char >> 4) & 15]
917 << Hex[(Char >> 0) & 15];
923 if (LastSlashX + 1 ==
I) {
925 case '0':
case '1':
case '2':
case '3':
case '4':
926 case '5':
case '6':
case '7':
case '8':
case '9':
927 case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
928 case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
933 assert(Char <= 0xff &&
934 "Characters above 0xff should already have been handled.");
940 << (char)(
'0' + ((Char >> 6) & 7))
941 << (char)(
'0' + ((Char >> 3) & 7))
942 << (char)(
'0' + ((Char >> 0) & 7));
945 case '\\': OS <<
"\\\\";
break;
946 case '"': OS <<
"\\\"";
break;
947 case '\n': OS <<
"\\n";
break;
948 case '\t': OS <<
"\\t";
break;
949 case '\a': OS <<
"\\a";
break;
950 case '\b': OS <<
"\\b";
break;
961 this->IsPascal = IsPascal;
964 assert((Str.size()%CharByteWidth == 0)
965 &&
"size of data must be multiple of CharByteWidth");
966 Length = Str.size()/CharByteWidth;
968 switch(CharByteWidth) {
970 char *AStrData =
new (
C)
char[Length];
971 std::memcpy(AStrData,Str.data(),Length*
sizeof(*AStrData));
972 StrData.asChar = AStrData;
976 uint16_t *AStrData =
new (
C) uint16_t[Length];
977 std::memcpy(AStrData,Str.data(),Length*
sizeof(*AStrData));
978 StrData.asUInt16 = AStrData;
982 uint32_t *AStrData =
new (
C) uint32_t[Length];
983 std::memcpy(AStrData,Str.data(),Length*
sizeof(*AStrData));
984 StrData.asUInt32 = AStrData;
988 assert(
false &&
"unsupported CharByteWidth");
1011 const TargetInfo &Target,
unsigned *StartToken,
1012 unsigned *StartTokenByteOffset)
const {
1014 "Only narrow string literals are currently supported");
1019 unsigned StringOffset = 0;
1021 TokNo = *StartToken;
1022 if (StartTokenByteOffset) {
1023 StringOffset = *StartTokenByteOffset;
1024 ByteNo -= StringOffset;
1036 std::pair<FileID, unsigned> LocInfo =
1038 bool Invalid =
false;
1041 if (StartTokenByteOffset !=
nullptr)
1042 *StartTokenByteOffset = StringOffset;
1043 if (StartToken !=
nullptr)
1044 *StartToken = TokNo;
1045 return StrTokSpellingLoc;
1048 const char *StrData = Buffer.data()+LocInfo.second;
1052 Buffer.begin(), StrData, Buffer.end());
1054 TheLexer.LexFromRawLexer(TheTok);
1061 if (ByteNo < TokNumBytes ||
1067 if (StartTokenByteOffset !=
nullptr)
1068 *StartTokenByteOffset = StringOffset;
1069 if (StartToken !=
nullptr)
1070 *StartToken = TokNo;
1075 StringOffset += TokNumBytes;
1077 ByteNo -= TokNumBytes;
1097 case UO_Real:
return "__real";
1098 case UO_Imag:
return "__imag";
1102 llvm_unreachable(
"Unknown unary operator");
1108 default: llvm_unreachable(
"No unary operator for overloaded function");
1115 case OO_Tilde:
return UO_Not;
1116 case OO_Exclaim:
return UO_LNot;
1129 case UO_Not:
return OO_Tilde;
1130 case UO_LNot:
return OO_Exclaim;
1145 fn->isTypeDependent(),
1146 fn->isValueDependent(),
1147 fn->isInstantiationDependent(),
1148 fn->containsUnexpandedParameterPack()),
1151 SubExprs =
new (
C)
Stmt*[args.size()+PREARGS_START+NumPreArgs];
1153 for (
unsigned i = 0; i != args.size(); ++i) {
1155 ExprBits.TypeDependent =
true;
1157 ExprBits.ValueDependent =
true;
1159 ExprBits.InstantiationDependent =
true;
1161 ExprBits.ContainsUnexpandedParameterPack =
true;
1163 SubExprs[i+PREARGS_START+NumPreArgs] = args[i];
1166 CallExprBits.NumPreArgs = NumPreArgs;
1167 RParenLoc = rparenloc;
1172 :
CallExpr(C, CallExprClass, fn, 0, args, t, VK, rparenloc) {
1180 :
Expr(SC, Empty), SubExprs(nullptr),
NumArgs(0) {
1182 SubExprs =
new (
C)
Stmt*[PREARGS_START+NumPreArgs];
1183 CallExprBits.NumPreArgs = NumPreArgs;
1190 = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE)) {
1196 if (BO->isPtrMemOp())
1198 }
else if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(CEE)) {
1202 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE))
1203 return DRE->getDecl();
1204 if (
MemberExpr *ME = dyn_cast<MemberExpr>(CEE))
1205 return ME->getMemberDecl();
1223 this->NumArgs = NumArgs;
1229 Stmt **NewSubExprs =
new (
C)
Stmt*[NumArgs+PREARGS_START+NumPreArgs];
1231 for (
unsigned i = 0; i !=
getNumArgs()+PREARGS_START+NumPreArgs; ++i)
1232 NewSubExprs[i] = SubExprs[i];
1234 for (
unsigned i =
getNumArgs()+PREARGS_START+NumPreArgs;
1235 i != NumArgs+PREARGS_START+NumPreArgs; ++i)
1236 NewSubExprs[i] =
nullptr;
1239 SubExprs = NewSubExprs;
1240 this->NumArgs = NumArgs;
1281 if (isa<CXXPseudoDestructorExpr>(Callee->
IgnoreParens()))
1293 if (isa<CXXOperatorCallExpr>(
this))
1294 return cast<CXXOperatorCallExpr>(
this)->
getLocStart();
1298 begin =
getArg(0)->getLocStart();
1302 if (isa<CXXOperatorCallExpr>(
this))
1303 return cast<CXXOperatorCallExpr>(
this)->
getLocEnd();
1318 totalSizeToAlloc<OffsetOfNode, Expr *>(comps.size(), exprs.size()));
1320 return new (Mem)
OffsetOfExpr(C, type, OperatorLoc, tsi, comps, exprs,
1325 unsigned numComps,
unsigned numExprs) {
1327 C.
Allocate(totalSizeToAlloc<OffsetOfNode, Expr *>(numComps, numExprs));
1337 tsi->getType()->isDependentType(),
1338 tsi->getType()->isInstantiationDependentType(),
1339 tsi->getType()->containsUnexpandedParameterPack()),
1340 OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
1341 NumComps(comps.size()), NumExprs(exprs.size())
1343 for (
unsigned i = 0; i != comps.size(); ++i) {
1347 for (
unsigned i = 0; i != exprs.size(); ++i) {
1349 ExprBits.ValueDependent =
true;
1351 ExprBits.ContainsUnexpandedParameterPack =
true;
1362 return reinterpret_cast<IdentifierInfo *
> (Data & ~(uintptr_t)Mask);
1371 E->isTypeDependent(), E->isInstantiationDependent(),
1372 E->containsUnexpandedParameterPack()),
1373 OpLoc(op), RParenLoc(rp) {
1374 UnaryExprOrTypeTraitExprBits.Kind = ExprKind;
1375 UnaryExprOrTypeTraitExprBits.IsType =
false;
1385 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
1387 else if (
const auto *ME = dyn_cast<MemberExpr>(E))
1388 D = ME->getMemberDecl();
1392 if (
I->isAlignmentDependent()) {
1410 bool hasQualOrFound = (QualifierLoc ||
1411 founddecl.
getDecl() != memberdecl ||
1414 bool HasTemplateKWAndArgsInfo = targs || TemplateKWLoc.
isValid();
1418 HasTemplateKWAndArgsInfo ? 1 : 0,
1419 targs ? targs->
size() : 0);
1421 void *Mem = C.
Allocate(Size, llvm::alignOf<MemberExpr>());
1423 MemberExpr(base, isarrow, OperatorLoc, memberdecl, nameinfo, ty, vk, ok);
1425 if (hasQualOrFound) {
1432 else if (QualifierLoc &&
1436 E->HasQualifierOrFoundDecl =
true;
1438 MemberExprNameQualifier *NQ =
1439 E->getTrailingObjects<MemberExprNameQualifier>();
1444 E->HasTemplateKWAndArgsInfo = (targs || TemplateKWLoc.
isValid());
1447 bool Dependent =
false;
1448 bool InstantiationDependent =
false;
1449 bool ContainsUnexpandedParameterPack =
false;
1450 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1452 Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
1453 if (InstantiationDependent)
1455 }
else if (TemplateKWLoc.
isValid()) {
1456 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1474 return BaseStartLoc;
1482 EndLoc =
getBase()->getLocEnd();
1486 bool CastExpr::CastConsistency()
const {
1493 assert(!
path_empty() &&
"Cast kind should have a base path!");
1497 assert(
getType()->isObjCObjectPointerType());
1499 goto CheckNoBasePath;
1502 assert(
getType()->isObjCObjectPointerType());
1504 goto CheckNoBasePath;
1507 assert(
getType()->isMemberPointerType());
1509 goto CheckNoBasePath;
1515 if (!
getType()->isPointerType()) {
1516 assert(
getType()->isObjCObjectPointerType() ==
1518 assert(
getType()->isBlockPointerType() ==
1521 goto CheckNoBasePath;
1524 assert(
getType()->isBlockPointerType());
1527 goto CheckNoBasePath;
1530 assert(
getType()->isBlockPointerType());
1532 goto CheckNoBasePath;
1535 assert(
getType()->isPointerType());
1537 goto CheckNoBasePath;
1540 assert(
getType()->isPointerType());
1542 assert(
getType()->getPointeeType().getAddressSpace() !=
1575 goto CheckNoBasePath;
1592 assert(
path_empty() &&
"Cast kind should not have a base path!");
1605 return "LValueBitCast";
1607 return "LValueToRValue";
1611 return "BaseToDerived";
1613 return "DerivedToBase";
1615 return "UncheckedDerivedToBase";
1621 return "ArrayToPointerDecay";
1623 return "FunctionToPointerDecay";
1625 return "NullToMemberPointer";
1627 return "NullToPointer";
1629 return "BaseToDerivedMemberPointer";
1631 return "DerivedToBaseMemberPointer";
1633 return "ReinterpretMemberPointer";
1635 return "UserDefinedConversion";
1637 return "ConstructorConversion";
1639 return "IntegralToPointer";
1641 return "PointerToIntegral";
1643 return "PointerToBoolean";
1647 return "VectorSplat";
1649 return "IntegralCast";
1651 return "BooleanToSignedIntegral";
1653 return "IntegralToBoolean";
1655 return "IntegralToFloating";
1657 return "FloatingToIntegral";
1659 return "FloatingCast";
1661 return "FloatingToBoolean";
1663 return "MemberPointerToBoolean";
1665 return "CPointerToObjCPointerCast";
1667 return "BlockPointerToObjCPointerCast";
1669 return "AnyPointerToBlockPointerCast";
1671 return "ObjCObjectLValueCast";
1673 return "FloatingRealToComplex";
1675 return "FloatingComplexToReal";
1677 return "FloatingComplexToBoolean";
1679 return "FloatingComplexCast";
1681 return "FloatingComplexToIntegralComplex";
1683 return "IntegralRealToComplex";
1685 return "IntegralComplexToReal";
1687 return "IntegralComplexToBoolean";
1689 return "IntegralComplexCast";
1691 return "IntegralComplexToFloatingComplex";
1693 return "ARCConsumeObject";
1695 return "ARCProduceObject";
1697 return "ARCReclaimReturnedObject";
1699 return "ARCExtendBlockObject";
1701 return "AtomicToNonAtomic";
1703 return "NonAtomicToAtomic";
1705 return "CopyAndAutoreleaseBlockObject";
1707 return "BuiltinFnToFnPtr";
1709 return "ZeroToOCLEvent";
1711 return "AddressSpaceConversion";
1714 llvm_unreachable(
"Unhandled cast kind!");
1718 Expr *SubExpr =
nullptr;
1725 = dyn_cast<MaterializeTemporaryExpr>(SubExpr))
1726 SubExpr = Materialize->GetTemporaryExpr();
1730 SubExpr = Binder->getSubExpr();
1735 SubExpr = cast<CXXConstructExpr>(SubExpr)->getArg(0);
1737 SubExpr = cast<CXXMemberCallExpr>(SubExpr)->getImplicitObjectArgument();
1741 }
while ((E = dyn_cast<ImplicitCastExpr>(SubExpr)));
1747 switch (getStmtClass()) {
1748 #define ABSTRACT_STMT(x)
1749 #define CASTEXPR(Type, Base) \
1750 case Stmt::Type##Class: \
1751 return static_cast<Type *>(this)->getTrailingObjects<CXXBaseSpecifier *>();
1752 #define STMT(Type, Base)
1753 #include "clang/AST/StmtNodes.inc"
1755 llvm_unreachable(
"non-cast expressions not possible here");
1763 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1764 void *
Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1768 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1774 unsigned PathSize) {
1775 void *
Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1785 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1786 void *
Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1790 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1796 unsigned PathSize) {
1797 void *
Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1812 case BO_Shl:
return "<<";
1813 case BO_Shr:
return ">>";
1814 case BO_LT:
return "<";
1815 case BO_GT:
return ">";
1816 case BO_LE:
return "<=";
1817 case BO_GE:
return ">=";
1818 case BO_EQ:
return "==";
1819 case BO_NE:
return "!=";
1822 case BO_Or:
return "|";
1824 case BO_LOr:
return "||";
1839 llvm_unreachable(
"Invalid OpCode!");
1845 default: llvm_unreachable(
"Not an overloadable binary operator");
1846 case OO_Plus:
return BO_Add;
1847 case OO_Minus:
return BO_Sub;
1848 case OO_Star:
return BO_Mul;
1849 case OO_Slash:
return BO_Div;
1850 case OO_Percent:
return BO_Rem;
1851 case OO_Caret:
return BO_Xor;
1852 case OO_Amp:
return BO_And;
1853 case OO_Pipe:
return BO_Or;
1855 case OO_Less:
return BO_LT;
1856 case OO_Greater:
return BO_GT;
1865 case OO_LessLess:
return BO_Shl;
1866 case OO_GreaterGreater:
return BO_Shr;
1869 case OO_EqualEqual:
return BO_EQ;
1870 case OO_ExclaimEqual:
return BO_NE;
1871 case OO_LessEqual:
return BO_LE;
1872 case OO_GreaterEqual:
return BO_GE;
1873 case OO_AmpAmp:
return BO_LAnd;
1874 case OO_PipePipe:
return BO_LOr;
1883 OO_Star, OO_Slash, OO_Percent,
1885 OO_LessLess, OO_GreaterGreater,
1886 OO_Less, OO_Greater, OO_LessEqual, OO_GreaterEqual,
1887 OO_EqualEqual, OO_ExclaimEqual,
1893 OO_Equal, OO_StarEqual,
1894 OO_SlashEqual, OO_PercentEqual,
1895 OO_PlusEqual, OO_MinusEqual,
1896 OO_LessLessEqual, OO_GreaterGreaterEqual,
1897 OO_AmpEqual, OO_CaretEqual,
1901 return OverOps[Opc];
1908 InitExprs(C, initExprs.size()),
1909 LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(nullptr,
true)
1912 for (
unsigned I = 0;
I != initExprs.size(); ++
I) {
1914 ExprBits.TypeDependent =
true;
1916 ExprBits.ValueDependent =
true;
1918 ExprBits.InstantiationDependent =
true;
1920 ExprBits.ContainsUnexpandedParameterPack =
true;
1923 InitExprs.
insert(C, InitExprs.
end(), initExprs.begin(), initExprs.end());
1927 if (NumInits > InitExprs.
size())
1928 InitExprs.
reserve(C, NumInits);
1932 InitExprs.
resize(C, NumInits,
nullptr);
1936 if (Init >= InitExprs.
size()) {
1937 InitExprs.
insert(C, InitExprs.
end(), Init - InitExprs.
size() + 1,
nullptr);
1942 Expr *
Result = cast_or_null<Expr>(InitExprs[Init]);
1949 ArrayFillerOrUnionFieldInit = filler;
1952 for (
unsigned i = 0, e =
getNumInits(); i != e; ++i)
1953 if (inits[i] ==
nullptr)
1968 return isa<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init);
1973 return SyntacticForm->getLocStart();
1978 E = InitExprs.
end();
1981 Beg =
S->getLocStart();
1991 return SyntacticForm->getLocEnd();
1996 E = InitExprs.
rend();
1999 End =
S->getLocEnd();
2011 return cast<BlockPointerType>(
getType())
2042 switch (getStmtClass()) {
2048 R1 = getSourceRange();
2050 case ParenExprClass:
2051 return cast<ParenExpr>(
this)->getSubExpr()->
2053 case GenericSelectionExprClass:
2054 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
2056 case ChooseExprClass:
2057 return cast<ChooseExpr>(
this)->getChosenSubExpr()->
2059 case UnaryOperatorClass: {
2082 .isVolatileQualified())
2093 case BinaryOperatorClass: {
2105 if (IE->getValue() == 0)
2120 R1 = BO->
getLHS()->getSourceRange();
2121 R2 = BO->
getRHS()->getSourceRange();
2124 case CompoundAssignOperatorClass:
2125 case VAArgExprClass:
2126 case AtomicExprClass:
2129 case ConditionalOperatorClass: {
2141 case MemberExprClass:
2143 Loc = cast<MemberExpr>(
this)->getMemberLoc();
2145 R2 = cast<MemberExpr>(
this)->getBase()->getSourceRange();
2148 case ArraySubscriptExprClass:
2150 Loc = cast<ArraySubscriptExpr>(
this)->getRBracketLoc();
2151 R1 = cast<ArraySubscriptExpr>(
this)->getLHS()->getSourceRange();
2152 R2 = cast<ArraySubscriptExpr>(
this)->getRHS()->getSourceRange();
2155 case CXXOperatorCallExprClass: {
2167 case OO_ExclaimEqual:
2170 case OO_GreaterEqual:
2184 case CXXMemberCallExprClass:
2185 case UserDefinedLiteralClass: {
2187 const CallExpr *CE = cast<CallExpr>(
this);
2191 : FD->hasAttr<WarnUnusedResultAttr>();
2198 if (HasWarnUnusedResultAttr ||
2199 FD->hasAttr<PureAttr>() || FD->hasAttr<ConstAttr>()) {
2214 case UnresolvedLookupExprClass:
2215 case CXXUnresolvedConstructExprClass:
2218 case CXXTemporaryObjectExprClass:
2219 case CXXConstructExprClass: {
2221 if (Type->hasAttr<WarnUnusedAttr>()) {
2223 Loc = getLocStart();
2224 R1 = getSourceRange();
2231 case ObjCMessageExprClass: {
2239 R1 = ME->getSourceRange();
2244 if (MD->hasAttr<WarnUnusedResultAttr>()) {
2253 case ObjCPropertyRefExprClass:
2256 R1 = getSourceRange();
2259 case PseudoObjectExprClass: {
2269 R1 = getSourceRange();
2273 case StmtExprClass: {
2279 const CompoundStmt *CS = cast<StmtExpr>(
this)->getSubStmt();
2282 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2284 if (
const Expr *
E = dyn_cast<Expr>(Label->getSubStmt()))
2285 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2291 Loc = cast<StmtExpr>(
this)->getLParenLoc();
2292 R1 = getSourceRange();
2295 case CXXFunctionalCastExprClass:
2296 case CStyleCastExprClass: {
2299 const CastExpr *CE = cast<CastExpr>(
this);
2305 if (!(DRE && isa<VarDecl>(DRE->
getDecl()) &&
2306 cast<VarDecl>(DRE->
getDecl())->hasLocalStorage())) {
2321 dyn_cast<CXXFunctionalCastExpr>(
this)) {
2322 Loc = CXXCE->getLocStart();
2323 R1 = CXXCE->getSubExpr()->getSourceRange();
2327 R1 = CStyleCE->
getSubExpr()->getSourceRange();
2331 case ImplicitCastExprClass: {
2332 const CastExpr *ICE = cast<ImplicitCastExpr>(
this);
2341 case CXXDefaultArgExprClass:
2342 return (cast<CXXDefaultArgExpr>(
this)
2344 case CXXDefaultInitExprClass:
2345 return (cast<CXXDefaultInitExpr>(
this)
2348 case CXXNewExprClass:
2351 case CXXDeleteExprClass:
2353 case CXXBindTemporaryExprClass:
2354 return (cast<CXXBindTemporaryExpr>(
this)
2356 case ExprWithCleanupsClass:
2357 return (cast<ExprWithCleanups>(
this)
2366 switch (E->getStmtClass()) {
2369 case ObjCIvarRefExprClass:
2371 case Expr::UnaryOperatorClass:
2372 return cast<UnaryOperator>(
E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2373 case ImplicitCastExprClass:
2374 return cast<ImplicitCastExpr>(
E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2375 case MaterializeTemporaryExprClass:
2376 return cast<MaterializeTemporaryExpr>(
E)->GetTemporaryExpr()
2377 ->isOBJCGCCandidate(Ctx);
2378 case CStyleCastExprClass:
2379 return cast<CStyleCastExpr>(
E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2380 case DeclRefExprClass: {
2381 const Decl *D = cast<DeclRefExpr>(
E)->getDecl();
2383 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2384 if (VD->hasGlobalStorage())
2394 case MemberExprClass: {
2398 case ArraySubscriptExprClass:
2399 return cast<ArraySubscriptExpr>(
E)->getBase()->isOBJCGCCandidate(Ctx);
2417 if (
const MemberExpr *mem = dyn_cast<MemberExpr>(expr)) {
2418 assert(isa<CXXMethodDecl>(mem->getMemberDecl()));
2419 return mem->getMemberDecl()->getType();
2429 assert(isa<UnresolvedMemberExpr>(expr) || isa<CXXPseudoDestructorExpr>(expr));
2437 E =
P->getSubExpr();
2442 E =
P->getSubExpr();
2447 if (!
P->isResultDependent()) {
2448 E =
P->getResultExpr();
2453 if (!
P->isConditionDependent()) {
2454 E =
P->getChosenSubExpr();
2468 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2469 E =
P->getSubExpr();
2473 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2474 E = Materialize->GetTemporaryExpr();
2478 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2479 E = NTTP->getReplacement();
2489 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2490 E =
P->getSubExpr();
2494 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2495 E = Materialize->GetTemporaryExpr();
2499 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2500 E = NTTP->getReplacement();
2515 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2517 E =
P->getSubExpr();
2521 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2522 E = Materialize->GetTemporaryExpr();
2525 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2526 E = NTTP->getReplacement();
2538 if (
CastExpr *CE = dyn_cast<CastExpr>(E)) {
2541 CE->getCastKind() ==
CK_NoOp) {
2542 E = CE->getSubExpr();
2556 E =
P->getSubExpr();
2560 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2561 E = Materialize->GetTemporaryExpr();
2565 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2566 E = NTTP->getReplacement();
2575 if (MCE->getMethodDecl() && isa<CXXConversionDecl>(MCE->getMethodDecl()))
2576 return MCE->getImplicitObjectArgument();
2589 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2592 Expr *SE =
P->getSubExpr();
2610 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2611 E = NTTP->getReplacement();
2620 const Expr *
E =
this;
2622 E = M->GetTemporaryExpr();
2625 E = ICE->getSubExprAsWritten();
2627 return isa<CXXDefaultArgExpr>(
E);
2634 E = M->GetTemporaryExpr();
2637 if (ICE->getCastKind() ==
CK_NoOp)
2638 E = ICE->getSubExpr();
2644 E = BE->getSubExpr();
2647 if (ICE->getCastKind() ==
CK_NoOp)
2648 E = ICE->getSubExpr();
2667 if (!isa<ObjCPropertyRefExpr>(E))
2675 if (isa<ImplicitCastExpr>(E)) {
2676 switch (cast<ImplicitCastExpr>(E)->getCastKind()) {
2686 if (isa<MemberExpr>(E))
2690 if (BO->isPtrMemOp())
2694 if (isa<OpaqueValueExpr>(E))
2701 const Expr *
E =
this;
2706 E =
Paren->getSubExpr();
2711 if (ICE->getCastKind() ==
CK_NoOp ||
2715 E = ICE->getSubExpr();
2720 if (
const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) {
2722 E = UnOp->getSubExpr();
2728 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2729 E = M->GetTemporaryExpr();
2736 if (
const CXXThisExpr *This = dyn_cast<CXXThisExpr>(E))
2737 return This->isImplicit();
2745 for (
unsigned I = 0;
I < Exprs.size(); ++
I)
2753 const Expr **Culprit)
const {
2772 switch (getStmtClass()) {
2774 case StringLiteralClass:
2775 case ObjCEncodeExprClass:
2777 case CXXTemporaryObjectExprClass:
2778 case CXXConstructExprClass: {
2787 assert(CE->
getNumArgs() == 1 &&
"trivial ctor with > 1 argument");
2793 case CompoundLiteralExprClass: {
2797 const Expr *Exp = cast<CompoundLiteralExpr>(
this)->getInitializer();
2800 case DesignatedInitUpdateExprClass: {
2805 case InitListExprClass: {
2809 for (
unsigned i = 0; i < numInits; i++) {
2817 unsigned ElementNo = 0;
2819 for (
const auto *Field : RD->
fields()) {
2825 if (Field->isUnnamedBitfield())
2828 if (ElementNo < ILE->getNumInits()) {
2830 if (Field->isBitField()) {
2832 llvm::APSInt ResultTmp;
2850 case ImplicitValueInitExprClass:
2851 case NoInitExprClass:
2853 case ParenExprClass:
2854 return cast<ParenExpr>(
this)->getSubExpr()
2855 ->isConstantInitializer(Ctx, IsForRef, Culprit);
2856 case GenericSelectionExprClass:
2857 return cast<GenericSelectionExpr>(
this)->getResultExpr()
2858 ->isConstantInitializer(Ctx, IsForRef, Culprit);
2859 case ChooseExprClass:
2860 if (cast<ChooseExpr>(
this)->isConditionDependent()) {
2865 return cast<ChooseExpr>(
this)->getChosenSubExpr()
2867 case UnaryOperatorClass: {
2873 case CXXFunctionalCastExprClass:
2874 case CXXStaticCastExprClass:
2875 case ImplicitCastExprClass:
2876 case CStyleCastExprClass:
2877 case ObjCBridgedCastExprClass:
2878 case CXXDynamicCastExprClass:
2879 case CXXReinterpretCastExprClass:
2880 case CXXConstCastExprClass: {
2881 const CastExpr *CE = cast<CastExpr>(
this);
2894 case MaterializeTemporaryExprClass:
2895 return cast<MaterializeTemporaryExpr>(
this)->GetTemporaryExpr()
2896 ->isConstantInitializer(Ctx,
false, Culprit);
2898 case SubstNonTypeTemplateParmExprClass:
2899 return cast<SubstNonTypeTemplateParmExpr>(
this)->getReplacement()
2900 ->isConstantInitializer(Ctx,
false, Culprit);
2901 case CXXDefaultArgExprClass:
2902 return cast<CXXDefaultArgExpr>(
this)->getExpr()
2903 ->isConstantInitializer(Ctx,
false, Culprit);
2904 case CXXDefaultInitExprClass:
2905 return cast<CXXDefaultInitExpr>(
this)->getExpr()
2906 ->isConstantInitializer(Ctx,
false, Culprit);
2922 const bool IncludePossibleEffects;
2923 bool HasSideEffects;
2927 : Inherited(Context),
2928 IncludePossibleEffects(IncludePossible), HasSideEffects(
false) { }
2932 void VisitExpr(
const Expr *
E) {
2933 if (!HasSideEffects &&
2935 HasSideEffects =
true;
2941 bool IncludePossibleEffects)
const {
2945 if (!IncludePossibleEffects &&
getExprLoc().isMacroID())
2949 return IncludePossibleEffects;
2951 switch (getStmtClass()) {
2953 #define ABSTRACT_STMT(Type)
2954 #define STMT(Type, Base) case Type##Class:
2955 #define EXPR(Type, Base)
2956 #include "clang/AST/StmtNodes.inc"
2957 llvm_unreachable(
"unexpected Expr kind");
2959 case DependentScopeDeclRefExprClass:
2960 case CXXUnresolvedConstructExprClass:
2961 case CXXDependentScopeMemberExprClass:
2962 case UnresolvedLookupExprClass:
2963 case UnresolvedMemberExprClass:
2964 case PackExpansionExprClass:
2965 case SubstNonTypeTemplateParmPackExprClass:
2966 case FunctionParmPackExprClass:
2968 case CXXFoldExprClass:
2969 llvm_unreachable(
"shouldn't see dependent / unresolved nodes here");
2971 case DeclRefExprClass:
2972 case ObjCIvarRefExprClass:
2973 case PredefinedExprClass:
2974 case IntegerLiteralClass:
2975 case FloatingLiteralClass:
2976 case ImaginaryLiteralClass:
2977 case StringLiteralClass:
2978 case CharacterLiteralClass:
2979 case OffsetOfExprClass:
2980 case ImplicitValueInitExprClass:
2981 case UnaryExprOrTypeTraitExprClass:
2982 case AddrLabelExprClass:
2983 case GNUNullExprClass:
2984 case NoInitExprClass:
2985 case CXXBoolLiteralExprClass:
2986 case CXXNullPtrLiteralExprClass:
2987 case CXXThisExprClass:
2988 case CXXScalarValueInitExprClass:
2989 case TypeTraitExprClass:
2990 case ArrayTypeTraitExprClass:
2991 case ExpressionTraitExprClass:
2992 case CXXNoexceptExprClass:
2993 case SizeOfPackExprClass:
2994 case ObjCStringLiteralClass:
2995 case ObjCEncodeExprClass:
2996 case ObjCBoolLiteralExprClass:
2997 case CXXUuidofExprClass:
2998 case OpaqueValueExprClass:
3003 case CXXOperatorCallExprClass:
3004 case CXXMemberCallExprClass:
3005 case CUDAKernelCallExprClass:
3006 case UserDefinedLiteralClass: {
3010 const Decl *FD = cast<CallExpr>(
this)->getCalleeDecl();
3011 bool IsPure = FD && (FD->
hasAttr<ConstAttr>() || FD->
hasAttr<PureAttr>());
3012 if (IsPure || !IncludePossibleEffects)
3017 case BlockExprClass:
3018 case CXXBindTemporaryExprClass:
3019 if (!IncludePossibleEffects)
3023 case MSPropertyRefExprClass:
3024 case MSPropertySubscriptExprClass:
3025 case CompoundAssignOperatorClass:
3026 case VAArgExprClass:
3027 case AtomicExprClass:
3028 case CXXThrowExprClass:
3029 case CXXNewExprClass:
3030 case CXXDeleteExprClass:
3031 case ExprWithCleanupsClass:
3032 case CoawaitExprClass:
3033 case CoyieldExprClass:
3037 case StmtExprClass: {
3039 SideEffectFinder
Finder(Ctx, IncludePossibleEffects);
3040 Finder.Visit(cast<StmtExpr>(
this)->getSubStmt());
3041 return Finder.hasSideEffects();
3044 case ParenExprClass:
3045 case ArraySubscriptExprClass:
3046 case OMPArraySectionExprClass:
3047 case MemberExprClass:
3048 case ConditionalOperatorClass:
3049 case BinaryConditionalOperatorClass:
3050 case CompoundLiteralExprClass:
3051 case ExtVectorElementExprClass:
3052 case DesignatedInitExprClass:
3053 case DesignatedInitUpdateExprClass:
3054 case ParenListExprClass:
3055 case CXXPseudoDestructorExprClass:
3056 case CXXStdInitializerListExprClass:
3057 case SubstNonTypeTemplateParmExprClass:
3058 case MaterializeTemporaryExprClass:
3059 case ShuffleVectorExprClass:
3060 case ConvertVectorExprClass:
3061 case AsTypeExprClass:
3065 case UnaryOperatorClass:
3066 if (cast<UnaryOperator>(
this)->isIncrementDecrementOp())
3070 case BinaryOperatorClass:
3071 if (cast<BinaryOperator>(
this)->isAssignmentOp())
3075 case InitListExprClass:
3077 if (
const Expr *
E = cast<InitListExpr>(
this)->getArrayFiller())
3078 if (
E->HasSideEffects(Ctx, IncludePossibleEffects))
3082 case GenericSelectionExprClass:
3083 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
3086 case ChooseExprClass:
3087 return cast<ChooseExpr>(
this)->getChosenSubExpr()->HasSideEffects(
3088 Ctx, IncludePossibleEffects);
3090 case CXXDefaultArgExprClass:
3091 return cast<CXXDefaultArgExpr>(
this)->getExpr()->HasSideEffects(
3092 Ctx, IncludePossibleEffects);
3094 case CXXDefaultInitExprClass: {
3095 const FieldDecl *FD = cast<CXXDefaultInitExpr>(
this)->getField();
3097 return E->HasSideEffects(Ctx, IncludePossibleEffects);
3102 case CXXDynamicCastExprClass: {
3109 case ImplicitCastExprClass:
3110 case CStyleCastExprClass:
3111 case CXXStaticCastExprClass:
3112 case CXXReinterpretCastExprClass:
3113 case CXXConstCastExprClass:
3114 case CXXFunctionalCastExprClass: {
3119 if (!IncludePossibleEffects)
3122 const CastExpr *CE = cast<CastExpr>(
this);
3129 case CXXTypeidExprClass:
3132 return cast<CXXTypeidExpr>(
this)->isPotentiallyEvaluated();
3134 case CXXConstructExprClass:
3135 case CXXTemporaryObjectExprClass: {
3144 case LambdaExprClass: {
3145 const LambdaExpr *LE = cast<LambdaExpr>(
this);
3155 case PseudoObjectExprClass: {
3162 const Expr *Subexpr = *
I;
3164 Subexpr = OVE->getSourceExpr();
3171 case ObjCBoxedExprClass:
3172 case ObjCArrayLiteralClass:
3173 case ObjCDictionaryLiteralClass:
3174 case ObjCSelectorExprClass:
3175 case ObjCProtocolExprClass:
3176 case ObjCIsaExprClass:
3177 case ObjCIndirectCopyRestoreExprClass:
3178 case ObjCSubscriptRefExprClass:
3179 case ObjCBridgedCastExprClass:
3180 case ObjCMessageExprClass:
3181 case ObjCPropertyRefExprClass:
3183 if (IncludePossibleEffects)
3191 cast<Expr>(SubStmt)->HasSideEffects(Ctx, IncludePossibleEffects))
3207 : Inherited(Context), NonTrivial(
false) { }
3209 bool hasNonTrivialCall()
const {
return NonTrivial; }
3213 = dyn_cast_or_null<const CXXMethodDecl>(E->
getCalleeDecl())) {
3214 if (Method->isTrivial()) {
3216 Inherited::VisitStmt(E);
3227 Inherited::VisitStmt(E);
3236 Inherited::VisitStmt(E);
3246 NonTrivialCallFinder
Finder(Ctx);
3248 return Finder.hasNonTrivialCall();
3263 llvm_unreachable(
"Unexpected value dependent expression!");
3284 bool IsASValid =
true;
3294 CE->getSubExpr()->getType()->isIntegerType())
3295 return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3298 }
else if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(
this)) {
3300 return ICE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3301 }
else if (
const ParenExpr *PE = dyn_cast<ParenExpr>(
this)) {
3304 return PE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3306 dyn_cast<GenericSelectionExpr>(
this)) {
3307 if (GE->isResultDependent())
3309 return GE->getResultExpr()->isNullPointerConstant(Ctx, NPC);
3310 }
else if (
const ChooseExpr *CE = dyn_cast<ChooseExpr>(
this)) {
3311 if (CE->isConditionDependent())
3313 return CE->getChosenSubExpr()->isNullPointerConstant(Ctx, NPC);
3315 = dyn_cast<CXXDefaultArgExpr>(
this)) {
3317 return DefaultArg->getExpr()->isNullPointerConstant(Ctx, NPC);
3319 = dyn_cast<CXXDefaultInitExpr>(
this)) {
3321 return DefaultInit->getExpr()->isNullPointerConstant(Ctx, NPC);
3322 }
else if (isa<GNUNullExpr>(
this)) {
3326 = dyn_cast<MaterializeTemporaryExpr>(
this)) {
3327 return M->GetTemporaryExpr()->isNullPointerConstant(Ctx, NPC);
3328 }
else if (
const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(
this)) {
3329 if (
const Expr *Source = OVE->getSourceExpr())
3330 return Source->isNullPointerConstant(Ctx, NPC);
3334 if (
getType()->isNullPtrType())
3339 UT && UT->getDecl()->hasAttr<TransparentUnionAttr>())
3341 const Expr *InitExpr = CLE->getInitializer();
3342 if (
const InitListExpr *ILE = dyn_cast<InitListExpr>(InitExpr))
3346 if (!
getType()->isIntegerType() ||
3369 if (isa<IntegerLiteral>(
this))
3377 const Expr *E =
this;
3381 "expression is not a property reference");
3393 return cast<ObjCPropertyRefExpr>(
E);
3425 if (
MemberExpr *MemRef = dyn_cast<MemberExpr>(E))
3426 if (
FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
3427 if (Field->isBitField())
3431 if (
FieldDecl *Ivar = dyn_cast<FieldDecl>(IvarRef->getDecl()))
3432 if (Ivar->isBitField())
3435 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E))
3436 if (
FieldDecl *Field = dyn_cast<FieldDecl>(DeclRef->getDecl()))
3437 if (Field->isBitField())
3441 if (BinOp->isAssignmentOp() && BinOp->getLHS())
3444 if (BinOp->getOpcode() ==
BO_Comma && BinOp->getRHS())
3445 return BinOp->getRHS()->getSourceBitField();
3449 if (UnOp->isPrefix() && UnOp->isIncrementDecrementOp())
3450 return UnOp->getSubExpr()->getSourceBitField();
3460 ICE->getCastKind() ==
CK_NoOp)
3469 if (isa<ExtVectorElementExpr>(E))
3478 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
3479 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
3481 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
3495 return VT->getNumElements();
3503 StringRef Comp = Accessor->
getName();
3506 if (Comp ==
"hi" || Comp ==
"lo" || Comp ==
"even" || Comp ==
"odd")
3510 if (Comp[0] ==
's' || Comp[0] ==
'S')
3511 Comp = Comp.substr(1);
3513 for (
unsigned i = 0, e = Comp.size(); i != e; ++i)
3514 if (Comp.substr(i + 1).find(Comp[i]) != StringRef::npos)
3523 StringRef Comp = Accessor->
getName();
3524 if (Comp[0] ==
's' || Comp[0] ==
'S')
3525 Comp = Comp.substr(1);
3527 bool isHi = Comp ==
"hi";
3528 bool isLo = Comp ==
"lo";
3529 bool isEven = Comp ==
"even";
3530 bool isOdd = Comp ==
"odd";
3546 Elts.push_back(Index);
3554 Type->isDependentType(), Type->isDependentType(),
3555 Type->isInstantiationDependentType(),
3556 Type->containsUnexpandedParameterPack()),
3557 BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size())
3559 SubExprs =
new (
C)
Stmt*[args.size()];
3560 for (
unsigned i = 0; i != args.size(); i++) {
3562 ExprBits.TypeDependent =
true;
3564 ExprBits.ValueDependent =
true;
3566 ExprBits.InstantiationDependent =
true;
3568 ExprBits.ContainsUnexpandedParameterPack =
true;
3570 SubExprs[i] = args[i];
3577 this->NumExprs = Exprs.size();
3578 SubExprs =
new (
C)
Stmt*[NumExprs];
3579 memcpy(SubExprs, Exprs.data(),
sizeof(
Expr *) * Exprs.size());
3588 bool ContainsUnexpandedParameterPack,
3589 unsigned ResultIndex)
3590 :
Expr(GenericSelectionExprClass,
3591 AssocExprs[ResultIndex]->getType(),
3592 AssocExprs[ResultIndex]->getValueKind(),
3593 AssocExprs[ResultIndex]->getObjectKind(),
3594 AssocExprs[ResultIndex]->isTypeDependent(),
3595 AssocExprs[ResultIndex]->isValueDependent(),
3596 AssocExprs[ResultIndex]->isInstantiationDependent(),
3597 ContainsUnexpandedParameterPack),
3599 SubExprs(new (Context)
Stmt*[END_EXPR+AssocExprs.size()]),
3600 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
3601 GenericLoc(GenericLoc), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
3602 SubExprs[CONTROLLING] = ControllingExpr;
3603 assert(AssocTypes.size() == AssocExprs.size());
3604 std::copy(AssocTypes.begin(), AssocTypes.end(), this->AssocTypes);
3605 std::copy(AssocExprs.begin(), AssocExprs.end(), SubExprs+END_EXPR);
3614 bool ContainsUnexpandedParameterPack)
3615 :
Expr(GenericSelectionExprClass,
3616 Context.DependentTy,
3622 ContainsUnexpandedParameterPack),
3624 SubExprs(new (Context)
Stmt*[END_EXPR+AssocExprs.size()]),
3625 NumAssocs(AssocExprs.size()), ResultIndex(-1U), GenericLoc(GenericLoc),
3626 DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
3627 SubExprs[CONTROLLING] = ControllingExpr;
3628 assert(AssocTypes.size() == AssocExprs.size());
3629 std::copy(AssocTypes.begin(), AssocTypes.end(), this->AssocTypes);
3630 std::copy(AssocExprs.begin(), AssocExprs.end(), SubExprs+END_EXPR);
3646 unsigned NumDesignators,
3652 :
Expr(DesignatedInitExprClass, Ty,
3657 EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
3658 NumDesignators(NumDesignators), NumSubExprs(IndexExprs.
size() + 1) {
3659 this->Designators =
new (
C)
Designator[NumDesignators];
3662 child_iterator Child = child_begin();
3667 unsigned IndexIdx = 0;
3668 for (
unsigned I = 0;
I != NumDesignators; ++
I) {
3669 this->Designators[
I] = Designators[
I];
3673 Expr *Index = IndexExprs[IndexIdx];
3675 ExprBits.TypeDependent = ExprBits.ValueDependent =
true;
3677 ExprBits.InstantiationDependent =
true;
3680 ExprBits.ContainsUnexpandedParameterPack =
true;
3683 *Child++ = IndexExprs[IndexIdx++];
3686 Expr *Start = IndexExprs[IndexIdx];
3687 Expr *
End = IndexExprs[IndexIdx + 1];
3690 ExprBits.TypeDependent = ExprBits.ValueDependent =
true;
3691 ExprBits.InstantiationDependent =
true;
3694 ExprBits.InstantiationDependent =
true;
3700 ExprBits.ContainsUnexpandedParameterPack =
true;
3703 *Child++ = IndexExprs[IndexIdx++];
3704 *Child++ = IndexExprs[IndexIdx++];
3708 assert(IndexIdx == IndexExprs.size() &&
"Wrong number of index expressions");
3713 unsigned NumDesignators,
3716 bool UsesColonSyntax,
Expr *Init) {
3717 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(IndexExprs.size() + 1),
3718 llvm::alignOf<DesignatedInitExpr>());
3720 ColonOrEqualLoc, UsesColonSyntax,
3725 unsigned NumIndexExprs) {
3726 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(NumIndexExprs + 1),
3727 llvm::alignOf<DesignatedInitExpr>());
3733 unsigned NumDesigs) {
3735 NumDesignators = NumDesigs;
3736 for (
unsigned I = 0;
I != NumDesigs; ++
I)
3737 Designators[
I] = Desigs[
I];
3764 return getInit()->getLocEnd();
3768 assert(D.Kind == Designator::ArrayDesignator &&
"Requires array designator");
3773 assert(D.Kind == Designator::ArrayRangeDesignator &&
3774 "Requires array range designator");
3779 assert(D.Kind == Designator::ArrayRangeDesignator &&
3780 "Requires array range designator");
3789 unsigned NumNewDesignators = Last - First;
3790 if (NumNewDesignators == 0) {
3791 std::copy_backward(Designators + Idx + 1,
3792 Designators + NumDesignators,
3794 --NumNewDesignators;
3796 }
else if (NumNewDesignators == 1) {
3797 Designators[Idx] = *First;
3802 =
new (
C)
Designator[NumDesignators - 1 + NumNewDesignators];
3803 std::copy(Designators, Designators + Idx, NewDesignators);
3804 std::copy(First, Last, NewDesignators + Idx);
3805 std::copy(Designators + Idx + 1, Designators + NumDesignators,
3806 NewDesignators + Idx + NumNewDesignators);
3807 Designators = NewDesignators;
3808 NumDesignators = NumDesignators - 1 + NumNewDesignators;
3815 BaseAndUpdaterExprs[0] = baseExpr;
3819 BaseAndUpdaterExprs[1] = ILE;
3823 return getBase()->getLocStart();
3827 return getBase()->getLocEnd();
3835 NumExprs(exprs.size()), LParenLoc(lparenloc), RParenLoc(rparenloc) {
3836 Exprs =
new (
C)
Stmt*[exprs.size()];
3837 for (
unsigned i = 0; i != exprs.size(); ++i) {
3839 ExprBits.TypeDependent =
true;
3841 ExprBits.ValueDependent =
true;
3843 ExprBits.InstantiationDependent =
true;
3845 ExprBits.ContainsUnexpandedParameterPack =
true;
3847 Exprs[i] = exprs[i];
3853 e = ewc->getSubExpr();
3855 e = m->GetTemporaryExpr();
3856 e = cast<CXXConstructExpr>(e)->
getArg(0);
3858 e = ice->getSubExpr();
3859 return cast<OpaqueValueExpr>(e);
3864 unsigned numSemanticExprs) {
3866 Context.
Allocate(totalSizeToAlloc<Expr *>(1 + numSemanticExprs),
3867 llvm::alignOf<PseudoObjectExpr>());
3871 PseudoObjectExpr::PseudoObjectExpr(EmptyShell shell,
unsigned numSemanticExprs)
3872 :
Expr(PseudoObjectExprClass, shell) {
3873 PseudoObjectExprBits.NumSubExprs = numSemanticExprs + 1;
3878 unsigned resultIndex) {
3879 assert(syntax &&
"no syntactic expression!");
3880 assert(semantics.size() &&
"no semantic expressions!");
3888 assert(resultIndex < semantics.size());
3889 type = semantics[resultIndex]->getType();
3890 VK = semantics[resultIndex]->getValueKind();
3894 void *buffer = C.
Allocate(totalSizeToAlloc<Expr *>(semantics.size() + 1),
3895 llvm::alignOf<PseudoObjectExpr>());
3902 unsigned resultIndex)
3905 PseudoObjectExprBits.NumSubExprs = semantics.size() + 1;
3906 PseudoObjectExprBits.ResultIndex = resultIndex + 1;
3908 for (
unsigned i = 0, e = semantics.size() + 1; i != e; ++i) {
3909 Expr *E = (i == 0 ? syntax : semantics[i-1]);
3910 getSubExprsBuffer()[i] =
E;
3913 ExprBits.TypeDependent =
true;
3915 ExprBits.ValueDependent =
true;
3917 ExprBits.InstantiationDependent =
true;
3919 ExprBits.ContainsUnexpandedParameterPack =
true;
3921 if (isa<OpaqueValueExpr>(E))
3922 assert(cast<OpaqueValueExpr>(E)->getSourceExpr() !=
nullptr &&
3923 "opaque-value semantic expressions for pseudo-object "
3924 "operations must have sources");
3940 return child_range(child_iterator(T), child_iterator());
3941 return child_range(child_iterator(), child_iterator());
3943 return child_range(&Argument.Ex, &Argument.Ex + 1);
3950 NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op)
3952 assert(args.size() ==
getNumSubExprs(op) &&
"wrong number of subexpressions");
3953 for (
unsigned i = 0; i != args.size(); i++) {
3955 ExprBits.TypeDependent =
true;
3957 ExprBits.ValueDependent =
true;
3959 ExprBits.InstantiationDependent =
true;
3961 ExprBits.ContainsUnexpandedParameterPack =
true;
3963 SubExprs[i] = args[i];
3969 case AO__c11_atomic_init:
3970 case AO__c11_atomic_load:
3971 case AO__atomic_load_n:
3974 case AO__c11_atomic_store:
3975 case AO__c11_atomic_exchange:
3976 case AO__atomic_load:
3977 case AO__atomic_store:
3978 case AO__atomic_store_n:
3979 case AO__atomic_exchange_n:
3980 case AO__c11_atomic_fetch_add:
3981 case AO__c11_atomic_fetch_sub:
3982 case AO__c11_atomic_fetch_and:
3983 case AO__c11_atomic_fetch_or:
3984 case AO__c11_atomic_fetch_xor:
3985 case AO__atomic_fetch_add:
3986 case AO__atomic_fetch_sub:
3987 case AO__atomic_fetch_and:
3988 case AO__atomic_fetch_or:
3989 case AO__atomic_fetch_xor:
3990 case AO__atomic_fetch_nand:
3991 case AO__atomic_add_fetch:
3992 case AO__atomic_sub_fetch:
3993 case AO__atomic_and_fetch:
3994 case AO__atomic_or_fetch:
3995 case AO__atomic_xor_fetch:
3996 case AO__atomic_nand_fetch:
3999 case AO__atomic_exchange:
4002 case AO__c11_atomic_compare_exchange_strong:
4003 case AO__c11_atomic_compare_exchange_weak:
4006 case AO__atomic_compare_exchange:
4007 case AO__atomic_compare_exchange_n:
4010 llvm_unreachable(
"unknown atomic op");
4014 unsigned ArraySectionCount = 0;
4015 while (
auto *OASE = dyn_cast<OMPArraySectionExpr>(Base->
IgnoreParens())) {
4016 Base = OASE->getBase();
4017 ++ArraySectionCount;
4019 while (
auto *ASE = dyn_cast<ArraySubscriptExpr>(Base->
IgnoreParens())) {
4020 Base = ASE->getBase();
4021 ++ArraySectionCount;
4023 auto OriginalTy = Base->
getType();
4024 if (
auto *DRE = dyn_cast<DeclRefExpr>(Base))
4025 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl()))
4026 OriginalTy = PVD->getOriginalType().getNonReferenceType();
4028 for (
unsigned Cnt = 0; Cnt < ArraySectionCount; ++Cnt) {
4029 if (OriginalTy->isAnyPointerType())
4032 assert (OriginalTy->isArrayType());
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.
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...
CK_LValueToRValue - A conversion which causes the extraction of an r-value from the operand gl-value...
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)
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.
bool hasUnusedResultAttr() const
Returns true if this function or its return type has the warn_unused_result attribute.
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. ...
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.
CK_ToUnion - The GCC cast-to-union extension.
Decl - This represents one declaration (or definition), e.g.
unsigned size() const
Returns the number of designators in this initializer.
AccessSpecifier getAccess() const
Defines the C++ template declaration subclasses.
iterator insert(const ASTContext &C, iterator I, const T &Elt)
bool isEnumeralType() const
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.
CK_BaseToDerivedMemberPointer - Member pointer in base class to member pointer in derived class...
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.
CK_FloatingToIntegral - Floating point to integral.
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...
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
[ARC] Consumes a retainable object pointer that has just been produced, e.g.
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.
CK_IntegralToFloating - Integral to floating point.
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...
CK_IntegralCast - A cast between integral types (other than to boolean).
CompoundLiteralExpr - [C99 6.5.2.5].
const Expr * getCallee() const
MangleContext * createMangleContext()
AccessSpecifier getAccess() 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)
CK_Dynamic - A C++ dynamic_cast.
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.
CK_Dependent - A conversion which cannot yet be analyzed because either the expression or target type...
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Describes how types, statements, expressions, and declarations should be printed. ...
static DesignatedInitExpr * Create(const ASTContext &C, Designator *Designators, unsigned NumDesignators, ArrayRef< Expr * > IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
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.
static int getAccessorIdx(char c)
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
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
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.
Converts between different integral complex types.
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...
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
Converting between two Objective-C object types, which can occur when performing reference binding to...
unsigned getOffsetOfStringByte(const Token &TheTok, unsigned ByteNo) const
getOffsetOfStringByte - This function returns the offset of the specified byte of the string data rep...
unsigned size() const
Retrieve the number of template arguments in this template argument list.
CK_FloatingCast - Casting between floating types of different size.
[ARC] Causes a value of block type to be copied to the heap, if it is not already there...
Token - This structure provides full information about a lexed token.
CK_VectorSplat - A conversion from an arithmetic type to a vector of that element type...
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)
CallExpr(const ASTContext &C, StmtClass SC, Expr *fn, unsigned NumPreArgs, ArrayRef< Expr * > args, QualType t, ExprValueKind VK, SourceLocation rparenloc)
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
CK_NullToPointer - Null pointer constant to pointer, ObjC pointer, or block pointer.
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.
CK_PointerToIntegral - Pointer to integral.
CK_IntegralToPointer - Integral to pointer.
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 ...
Converts a floating point complex to bool by comparing against 0+0i.
Describes an C or C++ initializer list.
CK_IntegralToBoolean - Integral to boolean.
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
Capturing by copy (a.k.a., by value)
unsigned getLength() const
A convenient class for passing around template argument information.
DeclarationNameInfo getNameInfo() const
QualType getReturnType() const
const TemplateArgument & getArg(unsigned Idx) const
Retrieve a specific template argument as a type.
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...
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".
const Expr * skipRValueSubobjectAdjustments(SmallVectorImpl< const Expr * > &CommaLHS, SmallVectorImpl< SubobjectAdjustment > &Adjustments) const
Walk outwards from an expression we want to bind a reference to and find the expression whose lifetim...
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...
static QualType getBaseOriginalType(Expr *Base)
Return original type of the base expression for array section.
Expression is a GNU-style __null constant.
detail::InMemoryDirectory::const_iterator I
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++.
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
CK_AnyPointerToBlockPointerCast - Casting any non-block pointer to a block pointer.
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 ...
Causes a block literal to by copied to the heap and then autoreleased.
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)
Specifies that the expression should never be value-dependent.
NamedDecl * getDecl() const
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
ID
Defines the set of possible language-specific address spaces.
CK_FunctionToPointerDecay - Function to pointer decay.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Converts between different floating point complex types.
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
designators_iterator designators_begin()
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.
CK_PointerToBoolean - Pointer to boolean conversion.
Converts an integral complex to an integral real of the source's element type by discarding the imagi...
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
void outputString(raw_ostream &OS) const
CK_BitCast - A conversion which causes a bit pattern of one type to be reinterpreted as a bit pattern...
double getValueAsApproximateDouble() const
getValueAsApproximateDouble - This returns the value as an inaccurate double.
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
Expr * getSubExpr() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
CK_ConstructorConversion - Conversion by constructor.
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.
Converts from an integral complex to a floating complex.
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
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)
Creates clause with a list of variables VL and a linear step Step.
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.
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
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
CK_ArrayToPointerDecay - Array to pointer decay.
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.
CK_CPointerToObjCPointerCast - Casting a C pointer kind to an Objective-C pointer.
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.
CK_UserDefinedConversion - Conversion using a user defined type conversion function.
Encodes a location in the source.
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
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
CK_NullToMemberPointer - Null pointer constant to member pointer.
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...
CK_ReinterpretMemberPointer - Reinterpret a member pointer as a different kind of member pointer...
CK_DerivedToBase - A conversion from a C++ class pointer to a base class pointer. ...
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.
Converts from an integral real to an integral complex whose element type matches the source...
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)
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)
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()))
Converts a floating point complex to floating point real of the source's element type.
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.
Converts an integral complex to bool by comparing against 0+0i.
bool hasSideEffects(Expr *E, ASTContext &Ctx)
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
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...
CK_BaseToDerived - A conversion from a C++ class pointer/reference to a derived class pointer/referen...
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.
CK_BlockPointerToObjCPointerCast - Casting a block pointer to an ObjC pointer.
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.
A conversion of a floating point real to a floating point complex of the original type...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
CK_MemberPointerToBoolean - Member pointer to boolean.
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
[ARC] Reclaim a retainable object pointer object that may have been produced and autoreleased as part...
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>'.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
SourceLocation getLocEnd() const LLVM_READONLY
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)
[ARC] Produces a retainable object pointer so that it may be consumed, e.g.
static ImplicitCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize)
SourceLocation getLocStart() const LLVM_READONLY
bool isFunctionType() const
CK_LValueBitCast - A conversion which reinterprets the address of an l-value as an l-value of a diffe...
Expr * IgnoreParenLValueCasts() LLVM_READONLY
Ignore parentheses and lvalue casts.
Converts from T to _Atomic(T).
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
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.
Converts from a floating complex to an integral complex.
SourceLocation getLocEnd() const LLVM_READONLY
Represents a base class of a C++ class.
CK_UncheckedDerivedToBase - A conversion from a C++ class pointer/reference to a base class that can ...
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.
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.
unsigned getNumSubExprs()
Converts from _Atomic(T) to T.
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.
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. ...
CK_NoOp - A conversion which does not affect the type other than (possibly) adding qualifiers...
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
CK_DerivedToBaseMemberPointer - Member pointer in derived class to member pointer in base class...
QualType getElementType() const
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
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...
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 ...
CK_ToVoid - Cast to void, discarding the computed value.
unsigned getNumPreArgs() const
void removeAddressSpace()
bool isExplicitSpecialization() const
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
bool isIntegralType(ASTContext &Ctx) const
Determine whether this type is an integral type.
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.
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine()) const
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isPointerType() const
SourceRange getSourceRange() const LLVM_READONLY
QualType getArgumentType() const
CK_FloatingToBoolean - Floating point to boolean.
SourceLocation getLocStart() const LLVM_READONLY