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)) {
62 if ((CE->getCastKind() == CK_DerivedToBase ||
63 CE->getCastKind() == CK_UncheckedDerivedToBase) &&
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;
300 if (isa<CXXMethodDecl>(D) && D->getDeclContext()->isDependentContext()) {
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);
503 auto DC = CurrentDecl->getDeclContext();
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)) {
658 const Decl *D = Decl::castFromDeclContext(DC);
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 llvm_unreachable(
"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;
1087 #define UNARY_OPERATION(Name, Spelling) case UO_##Name: return Spelling;
1088 #include "clang/AST/OperationKinds.def"
1090 llvm_unreachable(
"Unknown unary operator");
1096 default: llvm_unreachable(
"No unary operator for overloaded function");
1097 case OO_PlusPlus:
return Postfix ? UO_PostInc : UO_PreInc;
1098 case OO_MinusMinus:
return Postfix ? UO_PostDec : UO_PreDec;
1099 case OO_Amp:
return UO_AddrOf;
1100 case OO_Star:
return UO_Deref;
1101 case OO_Plus:
return UO_Plus;
1102 case OO_Minus:
return UO_Minus;
1103 case OO_Tilde:
return UO_Not;
1104 case OO_Exclaim:
return UO_LNot;
1105 case OO_Coawait:
return UO_Coawait;
1111 case UO_PostInc:
case UO_PreInc:
return OO_PlusPlus;
1112 case UO_PostDec:
case UO_PreDec:
return OO_MinusMinus;
1113 case UO_AddrOf:
return OO_Amp;
1114 case UO_Deref:
return OO_Star;
1115 case UO_Plus:
return OO_Plus;
1116 case UO_Minus:
return OO_Minus;
1117 case UO_Not:
return OO_Tilde;
1118 case UO_LNot:
return OO_Exclaim;
1119 case UO_Coawait:
return OO_Coawait;
1133 fn->isValueDependent(), fn->isInstantiationDependent(),
1134 fn->containsUnexpandedParameterPack()),
1137 unsigned NumPreArgs = preargs.size();
1138 SubExprs =
new (C)
Stmt *[args.size()+PREARGS_START+NumPreArgs];
1140 for (
unsigned i = 0; i != NumPreArgs; ++i) {
1141 updateDependenciesFromArg(preargs[i]);
1142 SubExprs[i+PREARGS_START] = preargs[i];
1144 for (
unsigned i = 0; i != args.size(); ++i) {
1145 updateDependenciesFromArg(args[i]);
1146 SubExprs[i+PREARGS_START+NumPreArgs] = args[i];
1149 CallExprBits.NumPreArgs = NumPreArgs;
1150 RParenLoc = rparenloc;
1168 :
Expr(SC, Empty), SubExprs(nullptr),
NumArgs(0) {
1170 SubExprs =
new (C)
Stmt*[PREARGS_START+NumPreArgs]();
1171 CallExprBits.NumPreArgs = NumPreArgs;
1174 void CallExpr::updateDependenciesFromArg(
Expr *Arg) {
1176 ExprBits.TypeDependent =
true;
1178 ExprBits.ValueDependent =
true;
1180 ExprBits.InstantiationDependent =
true;
1182 ExprBits.ContainsUnexpandedParameterPack =
true;
1189 = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE)) {
1195 if (BO->isPtrMemOp())
1197 }
else if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(CEE)) {
1198 if (UO->getOpcode() == UO_Deref)
1201 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE))
1202 return DRE->getDecl();
1203 if (
MemberExpr *ME = dyn_cast<MemberExpr>(CEE))
1204 return ME->getMemberDecl();
1222 this->NumArgs = NumArgs;
1228 Stmt **NewSubExprs =
new (C)
Stmt*[NumArgs+PREARGS_START+NumPreArgs];
1230 for (
unsigned i = 0; i !=
getNumArgs()+PREARGS_START+NumPreArgs; ++i)
1231 NewSubExprs[i] = SubExprs[i];
1233 for (
unsigned i =
getNumArgs()+PREARGS_START+NumPreArgs;
1234 i != NumArgs+PREARGS_START+NumPreArgs; ++i)
1235 NewSubExprs[i] =
nullptr;
1238 SubExprs = NewSubExprs;
1239 this->NumArgs = NumArgs;
1280 if (isa<CXXPseudoDestructorExpr>(Callee->
IgnoreParens()))
1292 if (isa<CXXOperatorCallExpr>(
this))
1293 return cast<CXXOperatorCallExpr>(
this)->
getLocStart();
1297 begin =
getArg(0)->getLocStart();
1301 if (isa<CXXOperatorCallExpr>(
this))
1302 return cast<CXXOperatorCallExpr>(
this)->
getLocEnd();
1317 totalSizeToAlloc<OffsetOfNode, Expr *>(comps.size(), exprs.size()));
1319 return new (Mem)
OffsetOfExpr(C, type, OperatorLoc, tsi, comps, exprs,
1324 unsigned numComps,
unsigned numExprs) {
1326 C.
Allocate(totalSizeToAlloc<OffsetOfNode, Expr *>(numComps, numExprs));
1336 tsi->getType()->isDependentType(),
1337 tsi->getType()->isInstantiationDependentType(),
1338 tsi->getType()->containsUnexpandedParameterPack()),
1339 OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi),
1340 NumComps(comps.size()), NumExprs(exprs.size())
1342 for (
unsigned i = 0; i != comps.size(); ++i) {
1346 for (
unsigned i = 0; i != exprs.size(); ++i) {
1348 ExprBits.ValueDependent =
true;
1350 ExprBits.ContainsUnexpandedParameterPack =
true;
1370 E->isTypeDependent(), E->isInstantiationDependent(),
1371 E->containsUnexpandedParameterPack()),
1372 OpLoc(op), RParenLoc(rp) {
1373 UnaryExprOrTypeTraitExprBits.Kind = ExprKind;
1374 UnaryExprOrTypeTraitExprBits.IsType =
false;
1384 if (
const auto *DRE = dyn_cast<DeclRefExpr>(E))
1386 else if (
const auto *ME = dyn_cast<MemberExpr>(E))
1387 D = ME->getMemberDecl();
1390 for (
const auto *
I : D->specific_attrs<AlignedAttr>()) {
1391 if (
I->isAlignmentDependent()) {
1409 bool hasQualOrFound = (QualifierLoc ||
1410 founddecl.
getDecl() != memberdecl ||
1411 founddecl.
getAccess() != memberdecl->getAccess());
1413 bool HasTemplateKWAndArgsInfo = targs || TemplateKWLoc.
isValid();
1417 HasTemplateKWAndArgsInfo ? 1 : 0,
1418 targs ? targs->
size() : 0);
1420 void *Mem = C.
Allocate(Size, llvm::alignOf<MemberExpr>());
1422 MemberExpr(base, isarrow, OperatorLoc, memberdecl, nameinfo, ty, vk, ok);
1424 if (hasQualOrFound) {
1431 else if (QualifierLoc &&
1435 E->HasQualifierOrFoundDecl =
true;
1437 MemberExprNameQualifier *NQ =
1438 E->getTrailingObjects<MemberExprNameQualifier>();
1443 E->HasTemplateKWAndArgsInfo = (targs || TemplateKWLoc.
isValid());
1446 bool Dependent =
false;
1447 bool InstantiationDependent =
false;
1448 bool ContainsUnexpandedParameterPack =
false;
1449 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1451 Dependent, InstantiationDependent, ContainsUnexpandedParameterPack);
1452 if (InstantiationDependent)
1454 }
else if (TemplateKWLoc.
isValid()) {
1455 E->getTrailingObjects<ASTTemplateKWAndArgsInfo>()->initializeFrom(
1473 return BaseStartLoc;
1481 EndLoc =
getBase()->getLocEnd();
1485 bool CastExpr::CastConsistency()
const {
1487 case CK_DerivedToBase:
1488 case CK_UncheckedDerivedToBase:
1489 case CK_DerivedToBaseMemberPointer:
1490 case CK_BaseToDerived:
1491 case CK_BaseToDerivedMemberPointer:
1492 assert(!
path_empty() &&
"Cast kind should have a base path!");
1495 case CK_CPointerToObjCPointerCast:
1496 assert(
getType()->isObjCObjectPointerType());
1498 goto CheckNoBasePath;
1500 case CK_BlockPointerToObjCPointerCast:
1501 assert(
getType()->isObjCObjectPointerType());
1503 goto CheckNoBasePath;
1505 case CK_ReinterpretMemberPointer:
1506 assert(
getType()->isMemberPointerType());
1508 goto CheckNoBasePath;
1514 if (!
getType()->isPointerType()) {
1515 assert(
getType()->isObjCObjectPointerType() ==
1517 assert(
getType()->isBlockPointerType() ==
1520 goto CheckNoBasePath;
1522 case CK_AnyPointerToBlockPointerCast:
1523 assert(
getType()->isBlockPointerType());
1526 goto CheckNoBasePath;
1528 case CK_CopyAndAutoreleaseBlockObject:
1529 assert(
getType()->isBlockPointerType());
1531 goto CheckNoBasePath;
1533 case CK_FunctionToPointerDecay:
1534 assert(
getType()->isPointerType());
1536 goto CheckNoBasePath;
1538 case CK_AddressSpaceConversion:
1539 assert(
getType()->isPointerType());
1541 assert(
getType()->getPointeeType().getAddressSpace() !=
1546 case CK_ArrayToPointerDecay:
1547 case CK_NullToMemberPointer:
1548 case CK_NullToPointer:
1549 case CK_ConstructorConversion:
1550 case CK_IntegralToPointer:
1551 case CK_PointerToIntegral:
1553 case CK_VectorSplat:
1554 case CK_IntegralCast:
1555 case CK_BooleanToSignedIntegral:
1556 case CK_IntegralToFloating:
1557 case CK_FloatingToIntegral:
1558 case CK_FloatingCast:
1559 case CK_ObjCObjectLValueCast:
1560 case CK_FloatingRealToComplex:
1561 case CK_FloatingComplexToReal:
1562 case CK_FloatingComplexCast:
1563 case CK_FloatingComplexToIntegralComplex:
1564 case CK_IntegralRealToComplex:
1565 case CK_IntegralComplexToReal:
1566 case CK_IntegralComplexCast:
1567 case CK_IntegralComplexToFloatingComplex:
1568 case CK_ARCProduceObject:
1569 case CK_ARCConsumeObject:
1570 case CK_ARCReclaimReturnedObject:
1571 case CK_ARCExtendBlockObject:
1572 case CK_ZeroToOCLEvent:
1574 goto CheckNoBasePath;
1577 case CK_LValueToRValue:
1579 case CK_AtomicToNonAtomic:
1580 case CK_NonAtomicToAtomic:
1581 case CK_PointerToBoolean:
1582 case CK_IntegralToBoolean:
1583 case CK_FloatingToBoolean:
1584 case CK_MemberPointerToBoolean:
1585 case CK_FloatingComplexToBoolean:
1586 case CK_IntegralComplexToBoolean:
1587 case CK_LValueBitCast:
1588 case CK_UserDefinedConversion:
1589 case CK_BuiltinFnToFnPtr:
1591 assert(
path_empty() &&
"Cast kind should not have a base path!");
1599 #define CAST_OPERATION(Name) case CK_##Name: return #Name;
1600 #include "clang/AST/OperationKinds.def"
1602 llvm_unreachable(
"Unhandled cast kind!");
1606 Expr *SubExpr =
nullptr;
1613 = dyn_cast<MaterializeTemporaryExpr>(SubExpr))
1614 SubExpr = Materialize->GetTemporaryExpr();
1618 SubExpr = Binder->getSubExpr();
1623 SubExpr = cast<CXXConstructExpr>(SubExpr)->getArg(0);
1624 else if (E->
getCastKind() == CK_UserDefinedConversion) {
1625 assert((isa<CXXMemberCallExpr>(SubExpr) ||
1626 isa<BlockExpr>(SubExpr)) &&
1627 "Unexpected SubExpr for CK_UserDefinedConversion.");
1628 if (isa<CXXMemberCallExpr>(SubExpr))
1629 SubExpr = cast<CXXMemberCallExpr>(SubExpr)->getImplicitObjectArgument();
1634 }
while ((E = dyn_cast<ImplicitCastExpr>(SubExpr)));
1640 switch (getStmtClass()) {
1641 #define ABSTRACT_STMT(x)
1642 #define CASTEXPR(Type, Base) \
1643 case Stmt::Type##Class: \
1644 return static_cast<Type *>(this)->getTrailingObjects<CXXBaseSpecifier *>();
1645 #define STMT(Type, Base)
1646 #include "clang/AST/StmtNodes.inc"
1648 llvm_unreachable(
"non-cast expressions not possible here");
1656 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1657 void *
Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1661 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1667 unsigned PathSize) {
1668 void *
Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1678 unsigned PathSize = (BasePath ? BasePath->size() : 0);
1679 void *
Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1683 std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
1689 unsigned PathSize) {
1690 void *
Buffer = C.
Allocate(totalSizeToAlloc<CXXBaseSpecifier *>(PathSize));
1698 #define BINARY_OPERATION(Name, Spelling) case BO_##Name: return Spelling;
1699 #include "clang/AST/OperationKinds.def"
1701 llvm_unreachable(
"Invalid OpCode!");
1707 default: llvm_unreachable(
"Not an overloadable binary operator");
1708 case OO_Plus:
return BO_Add;
1709 case OO_Minus:
return BO_Sub;
1710 case OO_Star:
return BO_Mul;
1711 case OO_Slash:
return BO_Div;
1712 case OO_Percent:
return BO_Rem;
1713 case OO_Caret:
return BO_Xor;
1714 case OO_Amp:
return BO_And;
1715 case OO_Pipe:
return BO_Or;
1716 case OO_Equal:
return BO_Assign;
1717 case OO_Less:
return BO_LT;
1718 case OO_Greater:
return BO_GT;
1719 case OO_PlusEqual:
return BO_AddAssign;
1720 case OO_MinusEqual:
return BO_SubAssign;
1721 case OO_StarEqual:
return BO_MulAssign;
1722 case OO_SlashEqual:
return BO_DivAssign;
1723 case OO_PercentEqual:
return BO_RemAssign;
1724 case OO_CaretEqual:
return BO_XorAssign;
1725 case OO_AmpEqual:
return BO_AndAssign;
1726 case OO_PipeEqual:
return BO_OrAssign;
1727 case OO_LessLess:
return BO_Shl;
1728 case OO_GreaterGreater:
return BO_Shr;
1729 case OO_LessLessEqual:
return BO_ShlAssign;
1730 case OO_GreaterGreaterEqual:
return BO_ShrAssign;
1731 case OO_EqualEqual:
return BO_EQ;
1732 case OO_ExclaimEqual:
return BO_NE;
1733 case OO_LessEqual:
return BO_LE;
1734 case OO_GreaterEqual:
return BO_GE;
1735 case OO_AmpAmp:
return BO_LAnd;
1736 case OO_PipePipe:
return BO_LOr;
1737 case OO_Comma:
return BO_Comma;
1738 case OO_ArrowStar:
return BO_PtrMemI;
1745 OO_Star, OO_Slash, OO_Percent,
1747 OO_LessLess, OO_GreaterGreater,
1748 OO_Less, OO_Greater, OO_LessEqual, OO_GreaterEqual,
1749 OO_EqualEqual, OO_ExclaimEqual,
1755 OO_Equal, OO_StarEqual,
1756 OO_SlashEqual, OO_PercentEqual,
1757 OO_PlusEqual, OO_MinusEqual,
1758 OO_LessLessEqual, OO_GreaterGreaterEqual,
1759 OO_AmpEqual, OO_CaretEqual,
1763 return OverOps[Opc];
1770 InitExprs(C, initExprs.size()),
1771 LBraceLoc(lbraceloc), RBraceLoc(rbraceloc), AltForm(nullptr,
true)
1774 for (
unsigned I = 0;
I != initExprs.size(); ++
I) {
1776 ExprBits.TypeDependent =
true;
1778 ExprBits.ValueDependent =
true;
1780 ExprBits.InstantiationDependent =
true;
1782 ExprBits.ContainsUnexpandedParameterPack =
true;
1785 InitExprs.
insert(C, InitExprs.
end(), initExprs.begin(), initExprs.end());
1789 if (NumInits > InitExprs.
size())
1790 InitExprs.
reserve(C, NumInits);
1794 InitExprs.
resize(C, NumInits,
nullptr);
1798 if (Init >= InitExprs.
size()) {
1799 InitExprs.
insert(C, InitExprs.
end(), Init - InitExprs.
size() + 1,
nullptr);
1804 Expr *
Result = cast_or_null<Expr>(InitExprs[Init]);
1811 ArrayFillerOrUnionFieldInit = filler;
1814 for (
unsigned i = 0, e =
getNumInits(); i != e; ++i)
1815 if (inits[i] ==
nullptr)
1830 return isa<StringLiteral>(Init) || isa<ObjCEncodeExpr>(Init);
1835 return SyntacticForm->getLocStart();
1840 E = InitExprs.
end();
1843 Beg =
S->getLocStart();
1853 return SyntacticForm->getLocEnd();
1858 E = InitExprs.
rend();
1861 End =
S->getLocEnd();
1873 return cast<BlockPointerType>(
getType())
1904 switch (getStmtClass()) {
1912 case ParenExprClass:
1913 return cast<ParenExpr>(
this)->getSubExpr()->
1915 case GenericSelectionExprClass:
1916 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
1918 case ChooseExprClass:
1919 return cast<ChooseExpr>(
this)->getChosenSubExpr()->
1921 case UnaryOperatorClass: {
1944 .isVolatileQualified())
1955 case BinaryOperatorClass: {
1967 if (IE->getValue() == 0)
1982 R1 = BO->
getLHS()->getSourceRange();
1983 R2 = BO->
getRHS()->getSourceRange();
1986 case CompoundAssignOperatorClass:
1987 case VAArgExprClass:
1988 case AtomicExprClass:
1991 case ConditionalOperatorClass: {
2003 case MemberExprClass:
2005 Loc = cast<MemberExpr>(
this)->getMemberLoc();
2007 R2 = cast<MemberExpr>(
this)->getBase()->getSourceRange();
2010 case ArraySubscriptExprClass:
2012 Loc = cast<ArraySubscriptExpr>(
this)->getRBracketLoc();
2013 R1 = cast<ArraySubscriptExpr>(
this)->getLHS()->getSourceRange();
2014 R2 = cast<ArraySubscriptExpr>(
this)->getRHS()->getSourceRange();
2017 case CXXOperatorCallExprClass: {
2029 case OO_ExclaimEqual:
2032 case OO_GreaterEqual:
2046 case CXXMemberCallExprClass:
2047 case UserDefinedLiteralClass: {
2049 const CallExpr *CE = cast<CallExpr>(
this);
2053 : FD->hasAttr<WarnUnusedResultAttr>();
2060 if (HasWarnUnusedResultAttr ||
2061 FD->hasAttr<PureAttr>() || FD->hasAttr<ConstAttr>()) {
2076 case UnresolvedLookupExprClass:
2077 case CXXUnresolvedConstructExprClass:
2080 case CXXTemporaryObjectExprClass:
2081 case CXXConstructExprClass: {
2083 if (Type->hasAttr<WarnUnusedAttr>()) {
2085 Loc = getLocStart();
2093 case ObjCMessageExprClass: {
2101 R1 = ME->getSourceRange();
2106 if (MD->hasAttr<WarnUnusedResultAttr>()) {
2115 case ObjCPropertyRefExprClass:
2121 case PseudoObjectExprClass: {
2135 case StmtExprClass: {
2141 const CompoundStmt *CS = cast<StmtExpr>(
this)->getSubStmt();
2144 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2146 if (
const Expr *
E = dyn_cast<Expr>(Label->getSubStmt()))
2147 return E->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
2153 Loc = cast<StmtExpr>(
this)->getLParenLoc();
2157 case CXXFunctionalCastExprClass:
2158 case CStyleCastExprClass: {
2161 const CastExpr *CE = cast<CastExpr>(
this);
2167 if (!(DRE && isa<VarDecl>(DRE->
getDecl()) &&
2168 cast<VarDecl>(DRE->
getDecl())->hasLocalStorage())) {
2178 if (CE->
getCastKind() == CK_ConstructorConversion)
2183 dyn_cast<CXXFunctionalCastExpr>(
this)) {
2184 Loc = CXXCE->getLocStart();
2185 R1 = CXXCE->getSubExpr()->getSourceRange();
2189 R1 = CStyleCE->
getSubExpr()->getSourceRange();
2193 case ImplicitCastExprClass: {
2194 const CastExpr *ICE = cast<ImplicitCastExpr>(
this);
2203 case CXXDefaultArgExprClass:
2204 return (cast<CXXDefaultArgExpr>(
this)
2206 case CXXDefaultInitExprClass:
2207 return (cast<CXXDefaultInitExpr>(
this)
2210 case CXXNewExprClass:
2213 case CXXDeleteExprClass:
2215 case CXXBindTemporaryExprClass:
2216 return (cast<CXXBindTemporaryExpr>(
this)
2218 case ExprWithCleanupsClass:
2219 return (cast<ExprWithCleanups>(
this)
2228 switch (E->getStmtClass()) {
2231 case ObjCIvarRefExprClass:
2233 case Expr::UnaryOperatorClass:
2234 return cast<UnaryOperator>(
E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2235 case ImplicitCastExprClass:
2236 return cast<ImplicitCastExpr>(
E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2237 case MaterializeTemporaryExprClass:
2238 return cast<MaterializeTemporaryExpr>(
E)->GetTemporaryExpr()
2239 ->isOBJCGCCandidate(Ctx);
2240 case CStyleCastExprClass:
2241 return cast<CStyleCastExpr>(
E)->getSubExpr()->isOBJCGCCandidate(Ctx);
2242 case DeclRefExprClass: {
2243 const Decl *D = cast<DeclRefExpr>(
E)->getDecl();
2245 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2246 if (VD->hasGlobalStorage())
2256 case MemberExprClass: {
2260 case ArraySubscriptExprClass:
2261 return cast<ArraySubscriptExpr>(
E)->getBase()->isOBJCGCCandidate(Ctx);
2279 if (
const MemberExpr *mem = dyn_cast<MemberExpr>(expr)) {
2280 assert(isa<CXXMethodDecl>(mem->getMemberDecl()));
2281 return mem->getMemberDecl()->getType();
2291 assert(isa<UnresolvedMemberExpr>(expr) || isa<CXXPseudoDestructorExpr>(expr));
2299 E =
P->getSubExpr();
2303 if (
P->getOpcode() == UO_Extension) {
2304 E =
P->getSubExpr();
2309 if (!
P->isResultDependent()) {
2310 E =
P->getResultExpr();
2315 if (!
P->isConditionDependent()) {
2316 E =
P->getChosenSubExpr();
2330 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2331 E =
P->getSubExpr();
2335 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2336 E = Materialize->GetTemporaryExpr();
2340 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2341 E = NTTP->getReplacement();
2351 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2352 E =
P->getSubExpr();
2356 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2357 E = Materialize->GetTemporaryExpr();
2361 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2362 E = NTTP->getReplacement();
2377 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2378 if (
P->getCastKind() == CK_LValueToRValue) {
2379 E =
P->getSubExpr();
2383 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2384 E = Materialize->GetTemporaryExpr();
2387 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2388 E = NTTP->getReplacement();
2400 if (
CastExpr *CE = dyn_cast<CastExpr>(E)) {
2401 if (CE->getCastKind() == CK_DerivedToBase ||
2402 CE->getCastKind() == CK_UncheckedDerivedToBase ||
2403 CE->getCastKind() == CK_NoOp) {
2404 E = CE->getSubExpr();
2418 E =
P->getSubExpr();
2422 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2423 E = Materialize->GetTemporaryExpr();
2427 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2428 E = NTTP->getReplacement();
2437 if (MCE->getMethodDecl() && isa<CXXConversionDecl>(MCE->getMethodDecl()))
2438 return MCE->getImplicitObjectArgument();
2451 if (
CastExpr *
P = dyn_cast<CastExpr>(E)) {
2454 Expr *SE =
P->getSubExpr();
2472 = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) {
2473 E = NTTP->getReplacement();
2482 const Expr *
E =
this;
2484 E = M->GetTemporaryExpr();
2487 E = ICE->getSubExprAsWritten();
2489 return isa<CXXDefaultArgExpr>(
E);
2496 E = M->GetTemporaryExpr();
2499 if (ICE->getCastKind() == CK_NoOp)
2500 E = ICE->getSubExpr();
2506 E = BE->getSubExpr();
2509 if (ICE->getCastKind() == CK_NoOp)
2510 E = ICE->getSubExpr();
2529 if (!isa<ObjCPropertyRefExpr>(E))
2537 if (isa<ImplicitCastExpr>(E)) {
2538 switch (cast<ImplicitCastExpr>(E)->getCastKind()) {
2539 case CK_DerivedToBase:
2540 case CK_UncheckedDerivedToBase:
2548 if (isa<MemberExpr>(E))
2552 if (BO->isPtrMemOp())
2556 if (isa<OpaqueValueExpr>(E))
2563 const Expr *
E =
this;
2568 E =
Paren->getSubExpr();
2573 if (ICE->getCastKind() == CK_NoOp ||
2574 ICE->getCastKind() == CK_LValueToRValue ||
2575 ICE->getCastKind() == CK_DerivedToBase ||
2576 ICE->getCastKind() == CK_UncheckedDerivedToBase) {
2577 E = ICE->getSubExpr();
2582 if (
const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) {
2583 if (UnOp->getOpcode() == UO_Extension) {
2584 E = UnOp->getSubExpr();
2590 = dyn_cast<MaterializeTemporaryExpr>(E)) {
2591 E = M->GetTemporaryExpr();
2598 if (
const CXXThisExpr *This = dyn_cast<CXXThisExpr>(E))
2599 return This->isImplicit();
2607 for (
unsigned I = 0;
I < Exprs.size(); ++
I)
2615 const Expr **Culprit)
const {
2634 switch (getStmtClass()) {
2636 case StringLiteralClass:
2637 case ObjCEncodeExprClass:
2639 case CXXTemporaryObjectExprClass:
2640 case CXXConstructExprClass: {
2649 assert(CE->
getNumArgs() == 1 &&
"trivial ctor with > 1 argument");
2655 case CompoundLiteralExprClass: {
2659 const Expr *Exp = cast<CompoundLiteralExpr>(
this)->getInitializer();
2662 case DesignatedInitUpdateExprClass: {
2667 case InitListExprClass: {
2671 for (
unsigned i = 0; i < numInits; i++) {
2679 unsigned ElementNo = 0;
2681 for (
const auto *Field : RD->
fields()) {
2687 if (Field->isUnnamedBitfield())
2690 if (ElementNo < ILE->getNumInits()) {
2692 if (Field->isBitField()) {
2694 llvm::APSInt ResultTmp;
2701 bool RefType = Field->getType()->isReferenceType();
2712 case ImplicitValueInitExprClass:
2713 case NoInitExprClass:
2715 case ParenExprClass:
2716 return cast<ParenExpr>(
this)->getSubExpr()
2717 ->isConstantInitializer(Ctx, IsForRef, Culprit);
2718 case GenericSelectionExprClass:
2719 return cast<GenericSelectionExpr>(
this)->getResultExpr()
2720 ->isConstantInitializer(Ctx, IsForRef, Culprit);
2721 case ChooseExprClass:
2722 if (cast<ChooseExpr>(
this)->isConditionDependent()) {
2727 return cast<ChooseExpr>(
this)->getChosenSubExpr()
2729 case UnaryOperatorClass: {
2735 case CXXFunctionalCastExprClass:
2736 case CXXStaticCastExprClass:
2737 case ImplicitCastExprClass:
2738 case CStyleCastExprClass:
2739 case ObjCBridgedCastExprClass:
2740 case CXXDynamicCastExprClass:
2741 case CXXReinterpretCastExprClass:
2742 case CXXConstCastExprClass: {
2743 const CastExpr *CE = cast<CastExpr>(
this);
2756 case MaterializeTemporaryExprClass:
2757 return cast<MaterializeTemporaryExpr>(
this)->GetTemporaryExpr()
2758 ->isConstantInitializer(Ctx,
false, Culprit);
2760 case SubstNonTypeTemplateParmExprClass:
2761 return cast<SubstNonTypeTemplateParmExpr>(
this)->getReplacement()
2762 ->isConstantInitializer(Ctx,
false, Culprit);
2763 case CXXDefaultArgExprClass:
2764 return cast<CXXDefaultArgExpr>(
this)->getExpr()
2765 ->isConstantInitializer(Ctx,
false, Culprit);
2766 case CXXDefaultInitExprClass:
2767 return cast<CXXDefaultInitExpr>(
this)->getExpr()
2768 ->isConstantInitializer(Ctx,
false, Culprit);
2784 const bool IncludePossibleEffects;
2785 bool HasSideEffects;
2789 : Inherited(Context),
2790 IncludePossibleEffects(IncludePossible), HasSideEffects(
false) { }
2794 void VisitExpr(
const Expr *
E) {
2795 if (!HasSideEffects &&
2797 HasSideEffects =
true;
2803 bool IncludePossibleEffects)
const {
2807 if (!IncludePossibleEffects &&
getExprLoc().isMacroID())
2811 return IncludePossibleEffects;
2813 switch (getStmtClass()) {
2815 #define ABSTRACT_STMT(Type)
2816 #define STMT(Type, Base) case Type##Class:
2817 #define EXPR(Type, Base)
2818 #include "clang/AST/StmtNodes.inc"
2819 llvm_unreachable(
"unexpected Expr kind");
2821 case DependentScopeDeclRefExprClass:
2822 case CXXUnresolvedConstructExprClass:
2823 case CXXDependentScopeMemberExprClass:
2824 case UnresolvedLookupExprClass:
2825 case UnresolvedMemberExprClass:
2826 case PackExpansionExprClass:
2827 case SubstNonTypeTemplateParmPackExprClass:
2828 case FunctionParmPackExprClass:
2830 case CXXFoldExprClass:
2831 llvm_unreachable(
"shouldn't see dependent / unresolved nodes here");
2833 case DeclRefExprClass:
2834 case ObjCIvarRefExprClass:
2835 case PredefinedExprClass:
2836 case IntegerLiteralClass:
2837 case FloatingLiteralClass:
2838 case ImaginaryLiteralClass:
2839 case StringLiteralClass:
2840 case CharacterLiteralClass:
2841 case OffsetOfExprClass:
2842 case ImplicitValueInitExprClass:
2843 case UnaryExprOrTypeTraitExprClass:
2844 case AddrLabelExprClass:
2845 case GNUNullExprClass:
2846 case NoInitExprClass:
2847 case CXXBoolLiteralExprClass:
2848 case CXXNullPtrLiteralExprClass:
2849 case CXXThisExprClass:
2850 case CXXScalarValueInitExprClass:
2851 case TypeTraitExprClass:
2852 case ArrayTypeTraitExprClass:
2853 case ExpressionTraitExprClass:
2854 case CXXNoexceptExprClass:
2855 case SizeOfPackExprClass:
2856 case ObjCStringLiteralClass:
2857 case ObjCEncodeExprClass:
2858 case ObjCBoolLiteralExprClass:
2859 case ObjCAvailabilityCheckExprClass:
2860 case CXXUuidofExprClass:
2861 case OpaqueValueExprClass:
2866 case CXXOperatorCallExprClass:
2867 case CXXMemberCallExprClass:
2868 case CUDAKernelCallExprClass:
2869 case UserDefinedLiteralClass: {
2873 const Decl *FD = cast<CallExpr>(
this)->getCalleeDecl();
2874 bool IsPure = FD && (FD->hasAttr<ConstAttr>() || FD->hasAttr<PureAttr>());
2875 if (IsPure || !IncludePossibleEffects)
2880 case BlockExprClass:
2881 case CXXBindTemporaryExprClass:
2882 if (!IncludePossibleEffects)
2886 case MSPropertyRefExprClass:
2887 case MSPropertySubscriptExprClass:
2888 case CompoundAssignOperatorClass:
2889 case VAArgExprClass:
2890 case AtomicExprClass:
2891 case CXXThrowExprClass:
2892 case CXXNewExprClass:
2893 case CXXDeleteExprClass:
2894 case CoawaitExprClass:
2895 case CoyieldExprClass:
2899 case StmtExprClass: {
2901 SideEffectFinder
Finder(Ctx, IncludePossibleEffects);
2902 Finder.Visit(cast<StmtExpr>(
this)->getSubStmt());
2903 return Finder.hasSideEffects();
2906 case ExprWithCleanupsClass:
2907 if (IncludePossibleEffects)
2908 if (cast<ExprWithCleanups>(
this)->cleanupsHaveSideEffects())
2912 case ParenExprClass:
2913 case ArraySubscriptExprClass:
2914 case OMPArraySectionExprClass:
2915 case MemberExprClass:
2916 case ConditionalOperatorClass:
2917 case BinaryConditionalOperatorClass:
2918 case CompoundLiteralExprClass:
2919 case ExtVectorElementExprClass:
2920 case DesignatedInitExprClass:
2921 case DesignatedInitUpdateExprClass:
2922 case ParenListExprClass:
2923 case CXXPseudoDestructorExprClass:
2924 case CXXStdInitializerListExprClass:
2925 case SubstNonTypeTemplateParmExprClass:
2926 case MaterializeTemporaryExprClass:
2927 case ShuffleVectorExprClass:
2928 case ConvertVectorExprClass:
2929 case AsTypeExprClass:
2933 case UnaryOperatorClass:
2934 if (cast<UnaryOperator>(
this)->isIncrementDecrementOp())
2938 case BinaryOperatorClass:
2939 if (cast<BinaryOperator>(
this)->isAssignmentOp())
2943 case InitListExprClass:
2945 if (
const Expr *
E = cast<InitListExpr>(
this)->getArrayFiller())
2946 if (
E->HasSideEffects(Ctx, IncludePossibleEffects))
2950 case GenericSelectionExprClass:
2951 return cast<GenericSelectionExpr>(
this)->getResultExpr()->
2954 case ChooseExprClass:
2955 return cast<ChooseExpr>(
this)->getChosenSubExpr()->HasSideEffects(
2956 Ctx, IncludePossibleEffects);
2958 case CXXDefaultArgExprClass:
2959 return cast<CXXDefaultArgExpr>(
this)->getExpr()->HasSideEffects(
2960 Ctx, IncludePossibleEffects);
2962 case CXXDefaultInitExprClass: {
2963 const FieldDecl *FD = cast<CXXDefaultInitExpr>(
this)->getField();
2965 return E->HasSideEffects(Ctx, IncludePossibleEffects);
2970 case CXXDynamicCastExprClass: {
2977 case ImplicitCastExprClass:
2978 case CStyleCastExprClass:
2979 case CXXStaticCastExprClass:
2980 case CXXReinterpretCastExprClass:
2981 case CXXConstCastExprClass:
2982 case CXXFunctionalCastExprClass: {
2987 if (!IncludePossibleEffects)
2990 const CastExpr *CE = cast<CastExpr>(
this);
2997 case CXXTypeidExprClass:
3000 return cast<CXXTypeidExpr>(
this)->isPotentiallyEvaluated();
3002 case CXXConstructExprClass:
3003 case CXXTemporaryObjectExprClass: {
3012 case CXXInheritedCtorInitExprClass: {
3013 const auto *ICIE = cast<CXXInheritedCtorInitExpr>(
this);
3014 if (!ICIE->getConstructor()->isTrivial() && IncludePossibleEffects)
3019 case LambdaExprClass: {
3020 const LambdaExpr *LE = cast<LambdaExpr>(
this);
3030 case PseudoObjectExprClass: {
3037 const Expr *Subexpr = *
I;
3039 Subexpr = OVE->getSourceExpr();
3046 case ObjCBoxedExprClass:
3047 case ObjCArrayLiteralClass:
3048 case ObjCDictionaryLiteralClass:
3049 case ObjCSelectorExprClass:
3050 case ObjCProtocolExprClass:
3051 case ObjCIsaExprClass:
3052 case ObjCIndirectCopyRestoreExprClass:
3053 case ObjCSubscriptRefExprClass:
3054 case ObjCBridgedCastExprClass:
3055 case ObjCMessageExprClass:
3056 case ObjCPropertyRefExprClass:
3058 if (IncludePossibleEffects)
3066 cast<Expr>(SubStmt)->HasSideEffects(Ctx, IncludePossibleEffects))
3082 : Inherited(Context), NonTrivial(
false) { }
3084 bool hasNonTrivialCall()
const {
return NonTrivial; }
3088 = dyn_cast_or_null<const CXXMethodDecl>(E->
getCalleeDecl())) {
3089 if (Method->isTrivial()) {
3091 Inherited::VisitStmt(E);
3102 Inherited::VisitStmt(E);
3111 Inherited::VisitStmt(E);
3121 NonTrivialCallFinder
Finder(Ctx);
3123 return Finder.hasNonTrivialCall();
3138 llvm_unreachable(
"Unexpected value dependent expression!");
3159 bool IsASValid =
true;
3169 CE->getSubExpr()->getType()->isIntegerType())
3170 return CE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3173 }
else if (
const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(
this)) {
3175 return ICE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3176 }
else if (
const ParenExpr *PE = dyn_cast<ParenExpr>(
this)) {
3179 return PE->getSubExpr()->isNullPointerConstant(Ctx, NPC);
3181 dyn_cast<GenericSelectionExpr>(
this)) {
3182 if (GE->isResultDependent())
3184 return GE->getResultExpr()->isNullPointerConstant(Ctx, NPC);
3185 }
else if (
const ChooseExpr *CE = dyn_cast<ChooseExpr>(
this)) {
3186 if (CE->isConditionDependent())
3188 return CE->getChosenSubExpr()->isNullPointerConstant(Ctx, NPC);
3190 = dyn_cast<CXXDefaultArgExpr>(
this)) {
3192 return DefaultArg->getExpr()->isNullPointerConstant(Ctx, NPC);
3194 = dyn_cast<CXXDefaultInitExpr>(
this)) {
3196 return DefaultInit->getExpr()->isNullPointerConstant(Ctx, NPC);
3197 }
else if (isa<GNUNullExpr>(
this)) {
3201 = dyn_cast<MaterializeTemporaryExpr>(
this)) {
3202 return M->GetTemporaryExpr()->isNullPointerConstant(Ctx, NPC);
3203 }
else if (
const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(
this)) {
3204 if (
const Expr *Source = OVE->getSourceExpr())
3205 return Source->isNullPointerConstant(Ctx, NPC);
3209 if (
getType()->isNullPtrType())
3214 UT && UT->getDecl()->hasAttr<TransparentUnionAttr>())
3216 const Expr *InitExpr = CLE->getInitializer();
3217 if (
const InitListExpr *ILE = dyn_cast<InitListExpr>(InitExpr))
3221 if (!
getType()->isIntegerType() ||
3244 if (isa<IntegerLiteral>(
this))
3252 const Expr *E =
this;
3256 "expression is not a property reference");
3259 if (BO->getOpcode() == BO_Comma) {
3268 return cast<ObjCPropertyRefExpr>(
E);
3293 if (ICE->getCastKind() == CK_LValueToRValue ||
3294 (ICE->getValueKind() !=
VK_RValue && ICE->getCastKind() == CK_NoOp))
3300 if (
MemberExpr *MemRef = dyn_cast<MemberExpr>(E))
3301 if (
FieldDecl *Field = dyn_cast<FieldDecl>(MemRef->getMemberDecl()))
3302 if (Field->isBitField())
3306 if (
FieldDecl *Ivar = dyn_cast<FieldDecl>(IvarRef->getDecl()))
3307 if (Ivar->isBitField())
3310 if (
DeclRefExpr *DeclRef = dyn_cast<DeclRefExpr>(E))
3311 if (
FieldDecl *Field = dyn_cast<FieldDecl>(DeclRef->getDecl()))
3312 if (Field->isBitField())
3316 if (BinOp->isAssignmentOp() && BinOp->getLHS())
3317 return BinOp->getLHS()->getSourceBitField();
3319 if (BinOp->getOpcode() == BO_Comma && BinOp->getRHS())
3320 return BinOp->getRHS()->getSourceBitField();
3324 if (UnOp->isPrefix() && UnOp->isIncrementDecrementOp())
3325 return UnOp->getSubExpr()->getSourceBitField();
3335 ICE->getCastKind() == CK_NoOp)
3344 if (isa<ExtVectorElementExpr>(E))
3353 if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E))
3354 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()))
3356 VD->hasAttr<AsmLabelAttr>() && !VD->isLocalVarDecl())
3370 return VT->getNumElements();
3378 StringRef Comp = Accessor->
getName();
3381 if (Comp ==
"hi" || Comp ==
"lo" || Comp ==
"even" || Comp ==
"odd")
3385 if (Comp[0] ==
's' || Comp[0] ==
'S')
3386 Comp = Comp.substr(1);
3388 for (
unsigned i = 0, e = Comp.size(); i != e; ++i)
3389 if (Comp.substr(i + 1).find(Comp[i]) != StringRef::npos)
3398 StringRef Comp = Accessor->
getName();
3399 if (Comp[0] ==
's' || Comp[0] ==
'S')
3400 Comp = Comp.substr(1);
3402 bool isHi = Comp ==
"hi";
3403 bool isLo = Comp ==
"lo";
3404 bool isEven = Comp ==
"even";
3405 bool isOdd = Comp ==
"odd";
3421 Elts.push_back(Index);
3429 Type->isDependentType(), Type->isDependentType(),
3430 Type->isInstantiationDependentType(),
3431 Type->containsUnexpandedParameterPack()),
3432 BuiltinLoc(BLoc), RParenLoc(RP), NumExprs(args.size())
3434 SubExprs =
new (C)
Stmt*[args.size()];
3435 for (
unsigned i = 0; i != args.size(); i++) {
3437 ExprBits.TypeDependent =
true;
3439 ExprBits.ValueDependent =
true;
3441 ExprBits.InstantiationDependent =
true;
3443 ExprBits.ContainsUnexpandedParameterPack =
true;
3445 SubExprs[i] = args[i];
3452 this->NumExprs = Exprs.size();
3453 SubExprs =
new (C)
Stmt*[NumExprs];
3454 memcpy(SubExprs, Exprs.data(),
sizeof(
Expr *) * Exprs.size());
3463 bool ContainsUnexpandedParameterPack,
3464 unsigned ResultIndex)
3465 :
Expr(GenericSelectionExprClass,
3466 AssocExprs[ResultIndex]->getType(),
3467 AssocExprs[ResultIndex]->getValueKind(),
3468 AssocExprs[ResultIndex]->getObjectKind(),
3469 AssocExprs[ResultIndex]->isTypeDependent(),
3470 AssocExprs[ResultIndex]->isValueDependent(),
3471 AssocExprs[ResultIndex]->isInstantiationDependent(),
3472 ContainsUnexpandedParameterPack),
3474 SubExprs(new (Context)
Stmt*[END_EXPR+AssocExprs.size()]),
3475 NumAssocs(AssocExprs.size()), ResultIndex(ResultIndex),
3476 GenericLoc(GenericLoc), DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
3477 SubExprs[CONTROLLING] = ControllingExpr;
3478 assert(AssocTypes.size() == AssocExprs.size());
3479 std::copy(AssocTypes.begin(), AssocTypes.end(), this->AssocTypes);
3480 std::copy(AssocExprs.begin(), AssocExprs.end(), SubExprs+END_EXPR);
3489 bool ContainsUnexpandedParameterPack)
3490 :
Expr(GenericSelectionExprClass,
3491 Context.DependentTy,
3497 ContainsUnexpandedParameterPack),
3499 SubExprs(new (Context)
Stmt*[END_EXPR+AssocExprs.size()]),
3500 NumAssocs(AssocExprs.size()), ResultIndex(-1U), GenericLoc(GenericLoc),
3501 DefaultLoc(DefaultLoc), RParenLoc(RParenLoc) {
3502 SubExprs[CONTROLLING] = ControllingExpr;
3503 assert(AssocTypes.size() == AssocExprs.size());
3504 std::copy(AssocTypes.begin(), AssocTypes.end(), this->AssocTypes);
3505 std::copy(AssocExprs.begin(), AssocExprs.end(), SubExprs+END_EXPR);
3526 :
Expr(DesignatedInitExprClass, Ty,
3531 EqualOrColonLoc(EqualOrColonLoc), GNUSyntax(GNUSyntax),
3532 NumDesignators(Designators.
size()), NumSubExprs(IndexExprs.
size() + 1) {
3533 this->Designators =
new (C)
Designator[NumDesignators];
3536 child_iterator Child = child_begin();
3541 unsigned IndexIdx = 0;
3542 for (
unsigned I = 0;
I != NumDesignators; ++
I) {
3543 this->Designators[
I] = Designators[
I];
3547 Expr *Index = IndexExprs[IndexIdx];
3549 ExprBits.TypeDependent = ExprBits.ValueDependent =
true;
3551 ExprBits.InstantiationDependent =
true;
3554 ExprBits.ContainsUnexpandedParameterPack =
true;
3557 *Child++ = IndexExprs[IndexIdx++];
3560 Expr *Start = IndexExprs[IndexIdx];
3561 Expr *
End = IndexExprs[IndexIdx + 1];
3564 ExprBits.TypeDependent = ExprBits.ValueDependent =
true;
3565 ExprBits.InstantiationDependent =
true;
3568 ExprBits.InstantiationDependent =
true;
3574 ExprBits.ContainsUnexpandedParameterPack =
true;
3577 *Child++ = IndexExprs[IndexIdx++];
3578 *Child++ = IndexExprs[IndexIdx++];
3582 assert(IndexIdx == IndexExprs.size() &&
"Wrong number of index expressions");
3590 bool UsesColonSyntax,
Expr *Init) {
3591 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(IndexExprs.size() + 1),
3592 llvm::alignOf<DesignatedInitExpr>());
3594 ColonOrEqualLoc, UsesColonSyntax,
3599 unsigned NumIndexExprs) {
3600 void *Mem = C.
Allocate(totalSizeToAlloc<Stmt *>(NumIndexExprs + 1),
3601 llvm::alignOf<DesignatedInitExpr>());
3607 unsigned NumDesigs) {
3609 NumDesignators = NumDesigs;
3610 for (
unsigned I = 0;
I != NumDesigs; ++
I)
3611 Designators[
I] = Desigs[
I];
3638 return getInit()->getLocEnd();
3642 assert(D.Kind == Designator::ArrayDesignator &&
"Requires array designator");
3647 assert(D.Kind == Designator::ArrayRangeDesignator &&
3648 "Requires array range designator");
3653 assert(D.Kind == Designator::ArrayRangeDesignator &&
3654 "Requires array range designator");
3663 unsigned NumNewDesignators = Last - First;
3664 if (NumNewDesignators == 0) {
3665 std::copy_backward(Designators + Idx + 1,
3666 Designators + NumDesignators,
3668 --NumNewDesignators;
3670 }
else if (NumNewDesignators == 1) {
3671 Designators[Idx] = *First;
3676 =
new (C)
Designator[NumDesignators - 1 + NumNewDesignators];
3677 std::copy(Designators, Designators + Idx, NewDesignators);
3678 std::copy(First, Last, NewDesignators + Idx);
3679 std::copy(Designators + Idx + 1, Designators + NumDesignators,
3680 NewDesignators + Idx + NumNewDesignators);
3681 Designators = NewDesignators;
3682 NumDesignators = NumDesignators - 1 + NumNewDesignators;
3689 BaseAndUpdaterExprs[0] = baseExpr;
3693 BaseAndUpdaterExprs[1] = ILE;
3697 return getBase()->getLocStart();
3701 return getBase()->getLocEnd();
3709 NumExprs(exprs.size()), LParenLoc(lparenloc), RParenLoc(rparenloc) {
3710 Exprs =
new (C)
Stmt*[exprs.size()];
3711 for (
unsigned i = 0; i != exprs.size(); ++i) {
3713 ExprBits.TypeDependent =
true;
3715 ExprBits.ValueDependent =
true;
3717 ExprBits.InstantiationDependent =
true;
3719 ExprBits.ContainsUnexpandedParameterPack =
true;
3721 Exprs[i] = exprs[i];
3727 e = ewc->getSubExpr();
3729 e = m->GetTemporaryExpr();
3730 e = cast<CXXConstructExpr>(e)->
getArg(0);
3732 e = ice->getSubExpr();
3733 return cast<OpaqueValueExpr>(e);
3738 unsigned numSemanticExprs) {
3740 Context.
Allocate(totalSizeToAlloc<Expr *>(1 + numSemanticExprs),
3741 llvm::alignOf<PseudoObjectExpr>());
3745 PseudoObjectExpr::PseudoObjectExpr(EmptyShell shell,
unsigned numSemanticExprs)
3746 :
Expr(PseudoObjectExprClass, shell) {
3747 PseudoObjectExprBits.NumSubExprs = numSemanticExprs + 1;
3752 unsigned resultIndex) {
3753 assert(syntax &&
"no syntactic expression!");
3754 assert(semantics.size() &&
"no semantic expressions!");
3762 assert(resultIndex < semantics.size());
3763 type = semantics[resultIndex]->getType();
3764 VK = semantics[resultIndex]->getValueKind();
3768 void *buffer = C.
Allocate(totalSizeToAlloc<Expr *>(semantics.size() + 1),
3769 llvm::alignOf<PseudoObjectExpr>());
3776 unsigned resultIndex)
3779 PseudoObjectExprBits.NumSubExprs = semantics.size() + 1;
3780 PseudoObjectExprBits.ResultIndex = resultIndex + 1;
3782 for (
unsigned i = 0, e = semantics.size() + 1; i != e; ++i) {
3783 Expr *E = (i == 0 ? syntax : semantics[i-1]);
3784 getSubExprsBuffer()[i] =
E;
3787 ExprBits.TypeDependent =
true;
3789 ExprBits.ValueDependent =
true;
3791 ExprBits.InstantiationDependent =
true;
3793 ExprBits.ContainsUnexpandedParameterPack =
true;
3795 if (isa<OpaqueValueExpr>(E))
3796 assert(cast<OpaqueValueExpr>(E)->getSourceExpr() !=
nullptr &&
3797 "opaque-value semantic expressions for pseudo-object "
3798 "operations must have sources");
3814 return child_range(child_iterator(T), child_iterator());
3815 return child_range(child_iterator(), child_iterator());
3817 return child_range(&Argument.Ex, &Argument.Ex + 1);
3824 NumSubExprs(args.size()), BuiltinLoc(BLoc), RParenLoc(RP), Op(op)
3826 assert(args.size() ==
getNumSubExprs(op) &&
"wrong number of subexpressions");
3827 for (
unsigned i = 0; i != args.size(); i++) {
3829 ExprBits.TypeDependent =
true;
3831 ExprBits.ValueDependent =
true;
3833 ExprBits.InstantiationDependent =
true;
3835 ExprBits.ContainsUnexpandedParameterPack =
true;
3837 SubExprs[i] = args[i];
3843 case AO__c11_atomic_init:
3844 case AO__c11_atomic_load:
3845 case AO__atomic_load_n:
3848 case AO__c11_atomic_store:
3849 case AO__c11_atomic_exchange:
3850 case AO__atomic_load:
3851 case AO__atomic_store:
3852 case AO__atomic_store_n:
3853 case AO__atomic_exchange_n:
3854 case AO__c11_atomic_fetch_add:
3855 case AO__c11_atomic_fetch_sub:
3856 case AO__c11_atomic_fetch_and:
3857 case AO__c11_atomic_fetch_or:
3858 case AO__c11_atomic_fetch_xor:
3859 case AO__atomic_fetch_add:
3860 case AO__atomic_fetch_sub:
3861 case AO__atomic_fetch_and:
3862 case AO__atomic_fetch_or:
3863 case AO__atomic_fetch_xor:
3864 case AO__atomic_fetch_nand:
3865 case AO__atomic_add_fetch:
3866 case AO__atomic_sub_fetch:
3867 case AO__atomic_and_fetch:
3868 case AO__atomic_or_fetch:
3869 case AO__atomic_xor_fetch:
3870 case AO__atomic_nand_fetch:
3873 case AO__atomic_exchange:
3876 case AO__c11_atomic_compare_exchange_strong:
3877 case AO__c11_atomic_compare_exchange_weak:
3880 case AO__atomic_compare_exchange:
3881 case AO__atomic_compare_exchange_n:
3884 llvm_unreachable(
"unknown atomic op");
3888 unsigned ArraySectionCount = 0;
3889 while (
auto *OASE = dyn_cast<OMPArraySectionExpr>(Base->
IgnoreParens())) {
3890 Base = OASE->getBase();
3891 ++ArraySectionCount;
3895 Base = ASE->getBase();
3896 ++ArraySectionCount;
3899 auto OriginalTy = Base->
getType();
3900 if (
auto *DRE = dyn_cast<DeclRefExpr>(Base))
3901 if (
auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl()))
3902 OriginalTy = PVD->getOriginalType().getNonReferenceType();
3904 for (
unsigned Cnt = 0; Cnt < ArraySectionCount; ++Cnt) {
3905 if (OriginalTy->isAnyPointerType())
3908 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...
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D, QualType T, bool &TypeDependent, bool &ValueDependent, bool &InstantiationDependent)
Compute the type-, value-, and instantiation-dependence of a declaration reference based on the decla...
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens...
void setArrayFiller(Expr *filler)
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
static StringLiteral * CreateEmpty(const ASTContext &C, unsigned NumStrs)
Construct an empty string literal.
ObjCMethodFamily getMethodFamily() const
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
unsigned FieldLoc
The location of the field name in the designated initializer.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
SourceLocation getLocEnd() const LLVM_READONLY
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
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.
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
bool hasUnusedResultAttr() const
Returns true if this function or its return type has the warn_unused_result attribute.
ParenExpr - This represents a parethesized expression, e.g.
const char * getCastKindName() const
The base class of the type hierarchy.
std::unique_ptr< llvm::MemoryBuffer > Buffer
InitListExpr * getSyntacticForm() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
void getEncodedElementAccess(SmallVectorImpl< uint32_t > &Elts) const
getEncodedElementAccess - Encode the elements accessed into an llvm aggregate Constant of ConstantInt...
Represents a call to a C++ constructor.
NamedDecl * getParam(unsigned Idx)
bool isBooleanType() const
A container of type source information.
SourceLocation getOperatorLoc() const
static StringLiteral * Create(const ASTContext &C, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumStrs)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
StreamedQualTypeHelper stream(const PrintingPolicy &Policy, const Twine &PlaceHolder=Twine(), unsigned Indentation=0) const
const TemplateArgument & get(unsigned Idx) const
Retrieve the template argument at a given index.
Describes the capture of a variable or of this, or of a C++1y init-capture.
Represents a C++ constructor within a class.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Expr * getInClassInitializer() const
getInClassInitializer - Get the C++11 in-class initializer for this member, or null if one has not be...
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Expr * ignoreParenBaseCasts() LLVM_READONLY
Ignore parentheses and derived-to-base casts.
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
static OffsetOfExpr * CreateEmpty(const ASTContext &C, unsigned NumComps, unsigned NumExprs)
static const OpaqueValueExpr * findInCopyConstruct(const Expr *expr)
Given an expression which invokes a copy constructor — i.e.
unsigned getChar32Width() const
getChar32Width/Align - Return the size of 'char32_t' for this target, in bits.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
CompoundLiteralExpr - [C99 6.5.2.5].
const Expr * getCallee() const
MangleContext * createMangleContext()
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
void resizeInits(const ASTContext &Context, unsigned NumInits)
Specify the number of initializers.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
void setInit(unsigned Init, Expr *expr)
ObjCMethodDecl - Represents an instance or class method declaration.
PredefinedExpr(SourceLocation L, QualType FNTy, IdentType IT, StringLiteral *SL)
Stores a list of template parameters for a TemplateDecl and its derived classes.
static DeclRefExpr * CreateEmpty(const ASTContext &Context, bool HasQualifier, bool HasFoundDecl, bool HasTemplateKWAndArgsInfo, unsigned NumTemplateArgs)
Construct an empty declaration reference expression.
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Describes how types, statements, expressions, and declarations should be printed. ...
void getAsStringInternal(std::string &Str, const PrintingPolicy &Policy) const
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
static bool isAssignmentOp(Opcode Opc)
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
Defines the clang::Expr interface and subclasses for C++ expressions.
Expr * getArrayIndex(const Designator &D) const
The collection of all-type qualifiers we support.
FieldDecl * getSourceBitField()
If this expression refers to a bit-field, retrieve the declaration of that bit-field.
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.
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
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.
Token - This structure provides full information about a lexed token.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
Stmt * getBody() const override
bool refersToVectorElement() const
Returns whether this expression refers to a vector element.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
void setComponent(unsigned Idx, OffsetOfNode ON)
bool isExplicitSpecialization() const
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ObjCPropertyRefExpr * getObjCProperty() const
If this expression is an l-value for an Objective C property, find the underlying property reference ...
SourceLocation getRParenLoc() const
NestedNameSpecifierLoc QualifierLoc
The nested-name-specifier that qualifies the name, including source-location information.
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr * > exprs, SourceLocation RParenLoc)
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
struct FieldDesignator Field
A field designator, e.g., ".x".
const Expr *const * const_semantics_iterator
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Describes an C or C++ initializer list.
const TemplateArgumentList * TemplateArguments
The template arguments used to produce the function template specialization from the function templat...
uint32_t getCodeUnit(size_t i) const
void setValue(const ASTContext &C, const llvm::APInt &Val)
const TargetInfo & getTargetInfo() const
An lvalue ref-qualifier was provided (&).
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
const LangOptions & getLangOpts() const
CallExpr(const ASTContext &C, StmtClass SC, Expr *fn, ArrayRef< Expr * > preargs, ArrayRef< Expr * > args, QualType t, ExprValueKind VK, SourceLocation rparenloc)
< Capturing the *this object by copy
unsigned getLength() const
A convenient class for passing around template argument information.
DeclarationNameInfo getNameInfo() const
QualType getReturnType() const
const 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...
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...
ConditionalOperator - The ?: ternary operator.
const ArrayType * castAsArrayTypeUnsafe() const
A variant of castAs<> for array type which silently discards qualifiers from the outermost type...
llvm::APInt getValue() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
Represents a prototype with parameter type info, e.g.
IdentifierInfo * getFieldName() const
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
bool isInstanceMessage() const
Determine whether this is an instance message to either a computed object or to super.
Expr * IgnoreParenNoopCasts(ASTContext &Ctx) LLVM_READONLY
IgnoreParenNoopCasts - Ignore parentheses and casts that do not change the value (including ptr->int ...
bool isOBJCGCCandidate(ASTContext &Ctx) const
isOBJCGCCandidate - Return true if this expression may be used in a read/ write barrier.
CastKind
CastKind - The kind of operation required for a conversion.
SourceRange getDesignatorsSourceRange() const
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
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...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
Exposes information about the current target.
InitListExpr(const ASTContext &C, SourceLocation lbraceloc, ArrayRef< Expr * > initExprs, SourceLocation rbraceloc)
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
const ObjCMethodDecl * getMethodDecl() const
bool isObjCSelfExpr() const
Check if this expression is the ObjC 'self' implicit parameter.
void setString(const ASTContext &C, StringRef Str, StringKind Kind, bool IsPascal)
Sets the string data to the given string data.
SourceLocation getLocStart() const LLVM_READONLY
bool isKnownToHaveBooleanValue() const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
void setDesignators(const ASTContext &C, const Designator *Desigs, unsigned NumDesigs)
SourceLocation getLocStart() const LLVM_READONLY
StringRef getName() const
Return the actual identifier string.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
void outputString(raw_ostream &OS) const
double getValueAsApproximateDouble() const
getValueAsApproximateDouble - This returns the value as an inaccurate double.
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
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
ImplicitParamDecl * getSelfDecl() const
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
Represents the type decltype(expr) (C++11).
ArrayRef< Expr * > inits()
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
Extra data stored in some MemberExpr objects.
SourceLocation getLocEnd() const LLVM_READONLY
unsigned getNumSubExprs() const
Expr * getSubExpr() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
An expression that sends a message to the given Objective-C object or class.
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
unsigned Index
Location of the first index expression within the designated initializer expression's list of subexpr...
Represents a GCC generic vector type.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Allow UB that we can give a value, but not arbitrary unmodeled side effects.
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
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
InitListExpr * getUpdater() const
bool isArrayRangeDesignator() const
SourceLocation getCaretLocation() const
Expr * IgnoreCasts() LLVM_READONLY
Ignore casts. Strip off any CastExprs, returning their operand.
bool isBoundMemberFunction(ASTContext &Ctx) const
Returns true if this expression is a bound member function.
const llvm::fltSemantics & getSemantics() const
Return the APFloat semantics this literal uses.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Expr * IgnoreConversionOperator() LLVM_READONLY
IgnoreConversionOperator - Ignore conversion operator.
unsigned DotLoc
The location of the '.' in the designated initializer.
UnaryExprOrTypeTraitExpr(UnaryExprOrTypeTrait ExprKind, TypeSourceInfo *TInfo, QualType resultType, SourceLocation op, SourceLocation rp)
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
ASTMatchFinder *const Finder
void ExpandDesignator(const ASTContext &C, unsigned Idx, const Designator *First, const Designator *Last)
Replaces the designator at index Idx with the series of designators in [First, Last).
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
A field in a dependent type, known only by its name.
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
Expr * getArrayRangeEnd(const Designator &D) const
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Encodes a location in the source.
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
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.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
static QualType getUnderlyingType(const SubRegion *R)
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Represents a static or instance method of a struct/union/class.
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
const CXXRecordDecl * getBestDynamicClassType() const
For an expression of class type or pointer to class type, return the most derived class decl the expr...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
SourceLocation getStrTokenLoc(unsigned TokNum) const
uint64_t VAL
Used to store the <= 64 bits integer value.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
Expr * updateInit(const ASTContext &C, unsigned Init, Expr *expr)
Updates the initializer at index Init with the new expression expr, and returns the old expression at...
bool isUnevaluatedBuiltinCall(const ASTContext &Ctx) const
Returns true if this is a call to a builtin which does not evaluate side-effects within its arguments...
StringLiteral * getFunctionName()
RefQualifierKind
The kind of C++11 ref-qualifier associated with a function type.
ParenListExpr(const ASTContext &C, SourceLocation lparenloc, ArrayRef< Expr * > exprs, SourceLocation rparenloc)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
Expr ** getInits()
Retrieve the set of initializers.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const T * castAs() const
Member-template castAs<specific type>.
static DesignatedInitExpr * CreateEmpty(const ASTContext &C, unsigned NumIndexExprs)
static DesignatedInitExpr * Create(const ASTContext &C, llvm::ArrayRef< Designator > Designators, ArrayRef< Expr * > IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
bool isVectorType() const
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
uintptr_t NameOrField
Refers to the field that is being initialized.
An rvalue ref-qualifier was provided (&&).
SourceLocation getLocStart() const LLVM_READONLY
const Expr * getBase() const
unsigned LBracketLoc
The location of the '[' starting the array range designator.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
SourceLocation getLocStart() const LLVM_READONLY
void sawArrayRangeDesignator(bool ARD=true)
bool isCXX98IntegralConstantExpr(const ASTContext &Ctx) const
isCXX98IntegralConstantExpr - Return true if this expression is an integral constant expression in C+...
QualType getType() const
Return the type wrapped by this type source info.
static MemberExpr * Create(const ASTContext &C, Expr *base, bool isarrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *memberdecl, DeclAccessPair founddecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *targs, QualType ty, ExprValueKind VK, ExprObjectKind OK)
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
A POD class for pairing a NamedDecl* with an access specifier.
Represents a C11 generic selection.
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
SourceLocation getLParenLoc() const
StringRef getOpcodeStr() const
void setExprs(const ASTContext &C, ArrayRef< Expr * > Exprs)
SourceLocation getLocStart() const LLVM_READONLY
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
EvalResult is a struct with detailed info about an evaluated expression.
bool hasSideEffects(Expr *E, ASTContext &Ctx)
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
static LLVM_READONLY bool isPrintable(unsigned char c)
Return true if this character is an ASCII printable character; that is, a character that should take ...
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type...
AtomicExpr(SourceLocation BLoc, ArrayRef< Expr * > args, QualType t, AtomicOp op, SourceLocation RP)
unsigned getCharWidth() const
A field designator, e.g., ".x".
NestedNameSpecifierLoc getQualifierLoc() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
The same as PrettyFunction, except that the 'virtual' keyword is omitted for virtual member functions...
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
SourceLocation getLocStart() const LLVM_READONLY
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
void resize(const ASTContext &C, unsigned N, const T &NV)
void setInstantiationDependent(bool ID)
Set whether this expression is instantiation-dependent or not.
StringKind getKind() const
Expression is a C++11 nullptr.
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
semantics_iterator semantics_begin()
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
ExplicitCastExpr - An explicit cast written in the source code.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
unsigned getNumArgs() const
unsigned getNumConcatenated() const
getNumConcatenated - Get the number of string literal tokens that were concatenated in translation ph...
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr * > semantic, unsigned resultIndex)
llvm::APFloat getValue() const
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
bool isConstantInitializer(ASTContext &Ctx, bool ForRef, const Expr **Culprit=nullptr) const
isConstantInitializer - Returns true if this expression can be emitted to IR as a constant...
bool hasQualifier() const
Determine whether this declaration reference was preceded by a C++ nested-name-specifier, e.g., N::foo.
struct ArrayOrRangeDesignator ArrayOrRange
An array or GNU array-range designator, e.g., "[9]" or "[10..15]".
bool isEvaluatable(const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
isEvaluatable - Call EvaluateAsRValue to see if this expression can be constant folded without side-e...
Not an overloaded operator.
bool HasSideEffects
Whether the evaluated expression has side effects.
MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc, ValueDecl *memberdecl, const DeclarationNameInfo &NameInfo, QualType ty, ExprValueKind VK, ExprObjectKind OK)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Location wrapper for a TemplateArgument.
static const TypeInfo & getInfo(unsigned id)
SourceLocation getCaretLocation() const
const T * getAs() const
Member-template getAs<specific type>'.
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)
static ImplicitCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize)
SourceLocation getLocStart() const LLVM_READONLY
bool isFunctionType() const
Expr * IgnoreParenLValueCasts() LLVM_READONLY
Ignore parentheses and lvalue casts.
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
SourceLocation getLocEnd() const LLVM_READONLY
Represents a base class of a C++ class.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
A use of a default initializer in a constructor or in aggregate initialization.
A template argument list.
static CStyleCastExpr * CreateEmpty(const ASTContext &Context, unsigned PathSize)
static const Expr * skipTemporaryBindingsNoOpCastsAndParens(const Expr *E)
Skip over any no-op casts and any temporary-binding expressions.
SourceLocation getLocEnd() const LLVM_READONLY
void reserve(const ASTContext &C, unsigned N)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Expression is a Null pointer constant built from a literal zero.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
Represents a C++ struct/union/class.
bool hasQualifiers() const
Return true if the set contains any qualifiers.
bool hasNonTrivialCall(const ASTContext &Ctx) const
Determine whether this expression involves a call to any function that is not trivial.
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
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.
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. ...
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
QualType getElementType() const
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
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 ...
unsigned getNumPreArgs() const
void removeAddressSpace()
bool isExplicitSpecialization() const
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
This class handles loading and caching of source files into memory.
const CXXDestructorDecl * getDestructor() const
bool isArrayDesignator() const
Defines enum values for all the target-independent builtin functions.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
Kind getKind() const
Determine what kind of offsetof node this is.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isPointerType() const
SourceRange getSourceRange() const LLVM_READONLY
QualType getArgumentType() const
SourceLocation getLocStart() const LLVM_READONLY