57#include "llvm/ADT/ArrayRef.h"
58#include "llvm/ADT/DenseMap.h"
59#include "llvm/ADT/STLExtras.h"
60#include "llvm/ADT/ScopeExit.h"
61#include "llvm/ADT/SmallVector.h"
62#include "llvm/Support/ErrorHandling.h"
63#include "llvm/Support/MemoryBuffer.h"
74 using llvm::make_error;
89 return "NameConflict";
91 return "UnsupportedConstruct";
93 return "Unknown error";
95 llvm_unreachable(
"Invalid error code.");
96 return "Invalid error code.";
102 llvm_unreachable(
"Function not implemented.");
113 Redecls.push_back(R);
116 std::reverse(Redecls.begin(), Redecls.end());
121 if (
auto *FD = dyn_cast<FunctionDecl>(D))
123 if (
auto *VD = dyn_cast<VarDecl>(D))
125 if (
auto *TD = dyn_cast<TagDecl>(D))
127 llvm_unreachable(
"Bad declaration kind");
148 bool const IgnoreChildErrors;
152 : FromDC(FromDC), IgnoreChildErrors(!
isa<
TagDecl>(FromDC)) {}
162 if (ChildErr && !IgnoreChildErrors)
163 ResultErr = joinErrors(std::move(ResultErr), std::move(ChildErr));
165 consumeError(std::move(ChildErr));
171 if (!IgnoreChildErrors || !FromDC)
173 return FromDC->containsDecl(FromChildD);
179 public StmtVisitor<ASTNodeImporter, ExpectedStmt> {
183 template <
typename ImportT>
184 [[nodiscard]]
Error importInto(ImportT &To,
const ImportT &From) {
185 return Importer.importInto(To, From);
189 template <
typename ImportT>
190 [[nodiscard]]
Error importInto(ImportT *&To, ImportT *From) {
191 auto ToOrErr = Importer.Import(From);
193 To = cast_or_null<ImportT>(*ToOrErr);
194 return ToOrErr.takeError();
199 template <
typename T>
203 auto ToOrErr = Importer.Import(From);
205 return ToOrErr.takeError();
206 return cast_or_null<T>(*ToOrErr);
209 template <
typename T>
210 auto import(
const T *From) {
211 return import(
const_cast<T *
>(From));
215 template <
typename T>
217 return Importer.Import(From);
221 template <
typename T>
225 return import(*From);
232 template <
typename ToDeclT>
struct CallOverloadedCreateFun {
233 template <
typename... Args>
decltype(
auto)
operator()(Args &&... args) {
234 return ToDeclT::Create(std::forward<Args>(args)...);
244 template <
typename ToDeclT,
typename FromDeclT,
typename... Args>
245 [[nodiscard]]
bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
250 CallOverloadedCreateFun<ToDeclT> OC;
251 return GetImportedOrCreateSpecialDecl(ToD, OC, FromD,
252 std::forward<Args>(args)...);
259 template <
typename NewDeclT,
typename ToDeclT,
typename FromDeclT,
261 [[nodiscard]]
bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
263 CallOverloadedCreateFun<NewDeclT> OC;
264 return GetImportedOrCreateSpecialDecl(ToD, OC, FromD,
265 std::forward<Args>(args)...);
269 template <
typename ToDeclT,
typename CreateFunT,
typename FromDeclT,
272 GetImportedOrCreateSpecialDecl(ToDeclT *&ToD, CreateFunT CreateFun,
273 FromDeclT *FromD, Args &&...args) {
274 if (Importer.getImportDeclErrorIfAny(FromD)) {
278 ToD = cast_or_null<ToDeclT>(Importer.GetAlreadyImportedOrNull(FromD));
281 ToD = CreateFun(std::forward<Args>(args)...);
283 Importer.RegisterImportedDecl(FromD, ToD);
284 Importer.SharedState->markAsNewDecl(ToD);
285 InitializeImportedDecl(FromD, ToD);
289 void InitializeImportedDecl(
Decl *FromD,
Decl *ToD) {
293 if (FromD->isImplicit())
307 void addDeclToContexts(
Decl *FromD,
Decl *ToD) {
308 if (Importer.isMinimalImport()) {
312 if (!FromD->getDescribedTemplate() &&
319 DeclContext *FromLexicalDC = FromD->getLexicalDeclContext();
323 bool Visible =
false;
336 if (
auto *FromNamed = dyn_cast<NamedDecl>(FromD)) {
339 FromDC->
lookup(FromNamed->getDeclName());
340 if (llvm::is_contained(FromLookup, FromNamed))
353 LT->update(TP, OldDC);
357 updateLookupTableForTemplateParameters(
358 Params, Importer.getToContext().getTranslationUnitDecl());
361 template <
typename TemplateParmDeclT>
362 Error importTemplateParameterDefaultArgument(
const TemplateParmDeclT *D,
363 TemplateParmDeclT *ToD) {
364 if (D->hasDefaultArgument()) {
365 if (D->defaultArgumentWasInherited()) {
367 import(D->getDefaultArgStorage().getInheritedFrom());
368 if (!ToInheritedFromOrErr)
369 return ToInheritedFromOrErr.takeError();
370 TemplateParmDeclT *ToInheritedFrom = *ToInheritedFromOrErr;
371 if (!ToInheritedFrom->hasDefaultArgument()) {
375 import(D->getDefaultArgStorage()
377 ->getDefaultArgument());
378 if (!ToInheritedDefaultArgOrErr)
379 return ToInheritedDefaultArgOrErr.takeError();
380 ToInheritedFrom->setDefaultArgument(Importer.getToContext(),
381 *ToInheritedDefaultArgOrErr);
383 ToD->setInheritedDefaultArgument(ToD->getASTContext(),
387 import(D->getDefaultArgument());
388 if (!ToDefaultArgOrErr)
389 return ToDefaultArgOrErr.takeError();
392 if (!ToD->hasDefaultArgument())
393 ToD->setDefaultArgument(Importer.getToContext(),
397 return Error::success();
409#define TYPE(Class, Base) \
410 ExpectedType Visit##Class##Type(const Class##Type *T);
411#include "clang/AST/TypeNodes.inc"
448 (IDK ==
IDK_Default && !Importer.isMinimalImport());
469 template <
typename InContainerTy>
473 template<
typename InContainerTy>
480 std::tuple<FunctionTemplateDecl *, TemplateArgsTy>;
485 template <
typename DeclTy>
509 template <
typename T>
513 bool IgnoreTemplateParmDepth =
false);
714 Err = MaybeVal.takeError();
720 template<
typename IIter,
typename OIter>
722 using ItemT = std::remove_reference_t<
decltype(*Obegin)>;
723 for (; Ibegin != Iend; ++Ibegin, ++Obegin) {
726 return ToOrErr.takeError();
729 return Error::success();
736 template<
typename InContainerTy,
typename OutContainerTy>
738 const InContainerTy &InContainer, OutContainerTy &OutContainer) {
740 InContainer.begin(), InContainer.end(), OutContainer.begin());
743 template<
typename InContainerTy,
typename OIter>
760template <
typename InContainerTy>
764 auto ToLAngleLocOrErr =
import(FromLAngleLoc);
765 if (!ToLAngleLocOrErr)
766 return ToLAngleLocOrErr.takeError();
767 auto ToRAngleLocOrErr =
import(FromRAngleLoc);
768 if (!ToRAngleLocOrErr)
769 return ToRAngleLocOrErr.takeError();
774 Result = std::move(ToTAInfo);
775 return Error::success();
791 From.LAngleLoc, From.RAngleLoc, From.arguments(),
Result);
803 if (
Error Err = importInto(std::get<0>(
Result), FTSInfo->getTemplate()))
804 return std::move(Err);
809 return std::move(Err);
819 return std::move(Err);
822 if (!ToRequiresClause)
823 return ToRequiresClause.takeError();
826 if (!ToTemplateLocOrErr)
827 return ToTemplateLocOrErr.takeError();
829 if (!ToLAngleLocOrErr)
830 return ToLAngleLocOrErr.takeError();
832 if (!ToRAngleLocOrErr)
833 return ToRAngleLocOrErr.takeError();
836 Importer.getToContext(),
854 return ToTypeOrErr.takeError();
862 return ToTypeOrErr.takeError();
869 return ToOrErr.takeError();
872 return ToTypeOrErr.takeError();
873 return TemplateArgument(dyn_cast<ValueDecl>((*ToOrErr)->getCanonicalDecl()),
880 return ToTypeOrErr.takeError();
888 return ToTypeOrErr.takeError();
891 return ToValueOrErr.takeError();
898 if (!ToTemplateOrErr)
899 return ToTemplateOrErr.takeError();
907 if (!ToTemplateOrErr)
908 return ToTemplateOrErr.takeError();
919 return ToExpr.takeError();
925 return std::move(Err);
931 llvm_unreachable(
"Invalid template argument kind");
939 return ArgOrErr.takeError();
948 return E.takeError();
954 return TSIOrErr.takeError();
957 if (!ToTemplateKWLocOrErr)
958 return ToTemplateKWLocOrErr.takeError();
960 if (!ToTemplateQualifierLocOrErr)
961 return ToTemplateQualifierLocOrErr.takeError();
963 if (!ToTemplateNameLocOrErr)
964 return ToTemplateNameLocOrErr.takeError();
965 auto ToTemplateEllipsisLocOrErr =
967 if (!ToTemplateEllipsisLocOrErr)
968 return ToTemplateEllipsisLocOrErr.takeError();
970 Importer.getToContext(), *ToTemplateKWLocOrErr,
971 *ToTemplateQualifierLocOrErr, *ToTemplateNameLocOrErr,
972 *ToTemplateEllipsisLocOrErr);
982 size_t NumDecls = DG.
end() - DG.
begin();
984 ToDecls.reserve(NumDecls);
985 for (
Decl *FromD : DG) {
986 if (
auto ToDOrErr =
import(FromD))
987 ToDecls.push_back(*ToDOrErr);
989 return ToDOrErr.takeError();
1004 return ToDotLocOrErr.takeError();
1007 if (!ToFieldLocOrErr)
1008 return ToFieldLocOrErr.takeError();
1011 ToFieldName, *ToDotLocOrErr, *ToFieldLocOrErr);
1015 if (!ToLBracketLocOrErr)
1016 return ToLBracketLocOrErr.takeError();
1019 if (!ToRBracketLocOrErr)
1020 return ToRBracketLocOrErr.takeError();
1024 *ToLBracketLocOrErr,
1025 *ToRBracketLocOrErr);
1028 if (!ToEllipsisLocOrErr)
1029 return ToEllipsisLocOrErr.takeError();
1033 D.
getArrayIndex(), *ToLBracketLocOrErr, *ToEllipsisLocOrErr,
1034 *ToRBracketLocOrErr);
1039 Error Err = Error::success();
1042 auto ToConceptNameLoc =
1048 return std::move(Err);
1051 if (ASTTemplateArgs)
1053 return std::move(Err);
1055 Importer.getToContext(), ToNNS, ToTemplateKWLoc,
1059 Importer.getToContext(), ToTAInfo)
1065 char *ToStore =
new (Importer.getToContext())
char[FromStr.size()];
1066 std::copy(FromStr.begin(), FromStr.end(), ToStore);
1067 return StringRef(ToStore, FromStr.size());
1079 return ToSecondExpr.takeError();
1080 ToSat.
Details.emplace_back(ToSecondExpr.get());
1087 return ToPairFirst.takeError();
1089 ToSat.
Details.emplace_back(
new (Importer.getToContext())
1091 ToPairFirst.get(), ToPairSecond});
1095 return Error::success();
1100ASTNodeImporter::import(
1105 return ToLoc.takeError();
1107 return new (Importer.getToContext())
1119 return DiagOrErr.takeError();
1120 return new (Importer.getToContext()) TypeRequirement(*DiagOrErr);
1124 return ToType.takeError();
1125 return new (Importer.getToContext()) TypeRequirement(*ToType);
1133 bool IsRKSimple = From->
getKind() == Requirement::RK_Simple;
1136 std::optional<ExprRequirement::ReturnTypeRequirement> Req;
1142 const ExprRequirement::ReturnTypeRequirement &FromTypeRequirement =
1145 if (FromTypeRequirement.isTypeConstraint()) {
1146 const bool IsDependent = FromTypeRequirement.isDependent();
1148 import(FromTypeRequirement.getTypeConstraintTemplateParameterList());
1150 return ParamsOrErr.takeError();
1151 if (Status >= ExprRequirement::SS_ConstraintsNotSatisfied) {
1152 auto SubstConstraintExprOrErr =
1154 if (!SubstConstraintExprOrErr)
1155 return SubstConstraintExprOrErr.takeError();
1156 SubstitutedConstraintExpr = SubstConstraintExprOrErr.get();
1158 Req.emplace(ParamsOrErr.get(), IsDependent);
1159 }
else if (FromTypeRequirement.isSubstitutionFailure()) {
1160 auto DiagOrErr =
import(FromTypeRequirement.getSubstitutionDiagnostic());
1162 return DiagOrErr.takeError();
1163 Req.emplace(DiagOrErr.get());
1170 if (!NoexceptLocOrErr)
1171 return NoexceptLocOrErr.takeError();
1173 if (Status == ExprRequirement::SS_ExprSubstitutionFailure) {
1176 return DiagOrErr.takeError();
1177 return new (Importer.getToContext()) ExprRequirement(
1178 *DiagOrErr, IsRKSimple, *NoexceptLocOrErr, std::move(*Req));
1182 return ExprOrErr.takeError();
1184 *ExprOrErr, IsRKSimple, *NoexceptLocOrErr, std::move(*Req), Status,
1185 SubstitutedConstraintExpr);
1200 return new (Importer.getToContext())
1201 NestedRequirement(ToEntity, ToSatisfaction);
1205 return ToExpr.takeError();
1206 if (ToExpr.get()->isInstantiationDependent()) {
1207 return new (Importer.getToContext()) NestedRequirement(ToExpr.get());
1212 return std::move(Err);
1213 return new (Importer.getToContext()) NestedRequirement(
1214 Importer.getToContext(), ToExpr.get(), Satisfaction);
1222 switch (FromRequire->
getKind()) {
1232 llvm_unreachable(
"Unhandled requirement kind");
1242 return VarOrErr.takeError();
1247 return LocationOrErr.takeError();
1252 return std::move(Err);
1259template <
typename T>
1261 if (
Found->getLinkageInternal() != From->getLinkageInternal())
1264 if (From->hasExternalFormalLinkage())
1265 return Found->hasExternalFormalLinkage();
1266 if (Importer.GetFromTU(
Found) != From->getTranslationUnitDecl())
1268 if (From->isInAnonymousNamespace())
1269 return Found->isInAnonymousNamespace();
1271 return !
Found->isInAnonymousNamespace() &&
1272 !
Found->hasExternalFormalLinkage();
1292using namespace clang;
1298 FunctionDeclsWithImportInProgress.insert(D);
1301 return llvm::scope_exit([
this, LambdaD]() {
1303 FunctionDeclsWithImportInProgress.erase(LambdaD);
1310 return FunctionDeclsWithImportInProgress.find(D) !=
1311 FunctionDeclsWithImportInProgress.end();
1315 Importer.FromDiag(
SourceLocation(), diag::err_unsupported_ast_node)
1316 << T->getTypeClassName();
1321 ExpectedType UnderlyingTypeOrErr =
import(T->getValueType());
1322 if (!UnderlyingTypeOrErr)
1323 return UnderlyingTypeOrErr.takeError();
1325 return Importer.getToContext().getAtomicType(*UnderlyingTypeOrErr);
1329 switch (T->getKind()) {
1330#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1331 case BuiltinType::Id: \
1332 return Importer.getToContext().SingletonId;
1333#include "clang/Basic/OpenCLImageTypes.def"
1334#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1335 case BuiltinType::Id: \
1336 return Importer.getToContext().Id##Ty;
1337#include "clang/Basic/OpenCLExtensionTypes.def"
1338#define SVE_TYPE(Name, Id, SingletonId) \
1339 case BuiltinType::Id: \
1340 return Importer.getToContext().SingletonId;
1341#include "clang/Basic/AArch64ACLETypes.def"
1342#define PPC_VECTOR_TYPE(Name, Id, Size) \
1343 case BuiltinType::Id: \
1344 return Importer.getToContext().Id##Ty;
1345#include "clang/Basic/PPCTypes.def"
1346#define RVV_TYPE(Name, Id, SingletonId) \
1347 case BuiltinType::Id: \
1348 return Importer.getToContext().SingletonId;
1349#include "clang/Basic/RISCVVTypes.def"
1350#define WASM_TYPE(Name, Id, SingletonId) \
1351 case BuiltinType::Id: \
1352 return Importer.getToContext().SingletonId;
1353#include "clang/Basic/WebAssemblyReferenceTypes.def"
1354#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1355 case BuiltinType::Id: \
1356 return Importer.getToContext().SingletonId;
1357#include "clang/Basic/AMDGPUTypes.def"
1358#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1359 case BuiltinType::Id: \
1360 return Importer.getToContext().SingletonId;
1361#include "clang/Basic/HLSLIntangibleTypes.def"
1362#define SHARED_SINGLETON_TYPE(Expansion)
1363#define BUILTIN_TYPE(Id, SingletonId) \
1364 case BuiltinType::Id: return Importer.getToContext().SingletonId;
1365#include "clang/AST/BuiltinTypes.def"
1373 case BuiltinType::Char_U:
1377 if (Importer.getToContext().getLangOpts().CharIsSigned)
1378 return Importer.getToContext().UnsignedCharTy;
1380 return Importer.getToContext().CharTy;
1382 case BuiltinType::Char_S:
1386 if (!Importer.getToContext().getLangOpts().CharIsSigned)
1387 return Importer.getToContext().SignedCharTy;
1389 return Importer.getToContext().CharTy;
1391 case BuiltinType::WChar_S:
1392 case BuiltinType::WChar_U:
1395 return Importer.getToContext().WCharTy;
1398 llvm_unreachable(
"Invalid BuiltinType Kind!");
1401ExpectedType ASTNodeImporter::VisitDecayedType(
const DecayedType *T) {
1403 if (!ToOriginalTypeOrErr)
1404 return ToOriginalTypeOrErr.takeError();
1406 return Importer.getToContext().getDecayedType(*ToOriginalTypeOrErr);
1409ExpectedType ASTNodeImporter::VisitComplexType(
const ComplexType *T) {
1411 if (!ToElementTypeOrErr)
1412 return ToElementTypeOrErr.takeError();
1414 return Importer.getToContext().getComplexType(*ToElementTypeOrErr);
1417ExpectedType ASTNodeImporter::VisitPointerType(
const PointerType *T) {
1419 if (!ToPointeeTypeOrErr)
1420 return ToPointeeTypeOrErr.takeError();
1422 return Importer.getToContext().getPointerType(*ToPointeeTypeOrErr);
1425ExpectedType ASTNodeImporter::VisitBlockPointerType(
const BlockPointerType *T) {
1428 if (!ToPointeeTypeOrErr)
1429 return ToPointeeTypeOrErr.takeError();
1431 return Importer.getToContext().getBlockPointerType(*ToPointeeTypeOrErr);
1435ASTNodeImporter::VisitLValueReferenceType(
const LValueReferenceType *T) {
1438 if (!ToPointeeTypeOrErr)
1439 return ToPointeeTypeOrErr.takeError();
1441 return Importer.getToContext().getLValueReferenceType(*ToPointeeTypeOrErr);
1445ASTNodeImporter::VisitRValueReferenceType(
const RValueReferenceType *T) {
1448 if (!ToPointeeTypeOrErr)
1449 return ToPointeeTypeOrErr.takeError();
1451 return Importer.getToContext().getRValueReferenceType(*ToPointeeTypeOrErr);
1455ASTNodeImporter::VisitMemberPointerType(
const MemberPointerType *T) {
1458 if (!ToPointeeTypeOrErr)
1459 return ToPointeeTypeOrErr.takeError();
1462 if (!QualifierOrErr)
1463 return QualifierOrErr.takeError();
1467 return ClsOrErr.takeError();
1469 return Importer.getToContext().getMemberPointerType(
1470 *ToPointeeTypeOrErr, *QualifierOrErr, *ClsOrErr);
1474ASTNodeImporter::VisitConstantArrayType(
const ConstantArrayType *T) {
1475 Error Err = Error::success();
1477 auto ToSizeExpr = importChecked(Err, T->
getSizeExpr());
1479 return std::move(Err);
1481 return Importer.getToContext().getConstantArrayType(
1487ASTNodeImporter::VisitArrayParameterType(
const ArrayParameterType *T) {
1488 ExpectedType ToArrayTypeOrErr = VisitConstantArrayType(T);
1489 if (!ToArrayTypeOrErr)
1490 return ToArrayTypeOrErr.takeError();
1492 return Importer.getToContext().getArrayParameterType(*ToArrayTypeOrErr);
1496ASTNodeImporter::VisitIncompleteArrayType(
const IncompleteArrayType *T) {
1498 if (!ToElementTypeOrErr)
1499 return ToElementTypeOrErr.takeError();
1501 return Importer.getToContext().getIncompleteArrayType(*ToElementTypeOrErr,
1507ASTNodeImporter::VisitVariableArrayType(
const VariableArrayType *T) {
1508 Error Err = Error::success();
1509 QualType ToElementType = importChecked(Err, T->
getElementType());
1510 Expr *ToSizeExpr = importChecked(Err, T->
getSizeExpr());
1512 return std::move(Err);
1513 return Importer.getToContext().getVariableArrayType(
1518ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(
1519 const DependentSizedArrayType *T) {
1520 Error Err = Error::success();
1521 QualType ToElementType = importChecked(Err, T->
getElementType());
1522 Expr *ToSizeExpr = importChecked(Err, T->
getSizeExpr());
1524 return std::move(Err);
1528 return Importer.getToContext().getDependentSizedArrayType(
1533ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType(
1534 const DependentSizedExtVectorType *T) {
1535 Error Err = Error::success();
1536 QualType ToElementType = importChecked(Err, T->
getElementType());
1537 Expr *ToSizeExpr = importChecked(Err, T->
getSizeExpr());
1540 return std::move(Err);
1541 return Importer.getToContext().getDependentSizedExtVectorType(
1542 ToElementType, ToSizeExpr, ToAttrLoc);
1545ExpectedType ASTNodeImporter::VisitVectorType(
const VectorType *T) {
1547 if (!ToElementTypeOrErr)
1548 return ToElementTypeOrErr.takeError();
1550 return Importer.getToContext().getVectorType(*ToElementTypeOrErr,
1555ExpectedType ASTNodeImporter::VisitExtVectorType(
const ExtVectorType *T) {
1557 if (!ToElementTypeOrErr)
1558 return ToElementTypeOrErr.takeError();
1560 return Importer.getToContext().getExtVectorType(*ToElementTypeOrErr,
1565ASTNodeImporter::VisitFunctionNoProtoType(
const FunctionNoProtoType *T) {
1569 if (!ToReturnTypeOrErr)
1570 return ToReturnTypeOrErr.takeError();
1572 return Importer.getToContext().getFunctionNoProtoType(*ToReturnTypeOrErr,
1577ASTNodeImporter::VisitFunctionProtoType(
const FunctionProtoType *T) {
1579 if (!ToReturnTypeOrErr)
1580 return ToReturnTypeOrErr.takeError();
1583 SmallVector<QualType, 4> ArgTypes;
1587 return TyOrErr.takeError();
1588 ArgTypes.push_back(*TyOrErr);
1592 SmallVector<QualType, 4> ExceptionTypes;
1596 return TyOrErr.takeError();
1597 ExceptionTypes.push_back(*TyOrErr);
1601 Error Err = Error::success();
1602 FunctionProtoType::ExtProtoInfo ToEPI;
1618 return std::move(Err);
1620 return Importer.getToContext().getFunctionType(
1621 *ToReturnTypeOrErr, ArgTypes, ToEPI);
1625 const UnresolvedUsingType *T) {
1626 Error Err = Error::success();
1627 auto ToQualifier = importChecked(Err, T->
getQualifier());
1628 auto *ToD = importChecked(Err, T->
getDecl());
1630 return std::move(Err);
1633 return Importer.getToContext().getCanonicalUnresolvedUsingType(ToD);
1634 return Importer.getToContext().getUnresolvedUsingType(T->
getKeyword(),
1638ExpectedType ASTNodeImporter::VisitParenType(
const ParenType *T) {
1640 if (!ToInnerTypeOrErr)
1641 return ToInnerTypeOrErr.takeError();
1643 return Importer.getToContext().getParenType(*ToInnerTypeOrErr);
1647ASTNodeImporter::VisitPackIndexingType(clang::PackIndexingType
const *T) {
1651 return Pattern.takeError();
1654 return Index.takeError();
1655 return Importer.getToContext().getPackIndexingType(*Pattern, *Index);
1658ExpectedType ASTNodeImporter::VisitTypedefType(
const TypedefType *T) {
1659 Expected<TypedefNameDecl *> ToDeclOrErr =
import(T->
getDecl());
1661 return ToDeclOrErr.takeError();
1664 if (!ToQualifierOrErr)
1665 return ToQualifierOrErr.takeError();
1669 if (!ToUnderlyingTypeOrErr)
1670 return ToUnderlyingTypeOrErr.takeError();
1672 return Importer.getToContext().getTypedefType(
1673 T->
getKeyword(), *ToQualifierOrErr, *ToDeclOrErr, *ToUnderlyingTypeOrErr);
1676ExpectedType ASTNodeImporter::VisitTypeOfExprType(
const TypeOfExprType *T) {
1679 return ToExprOrErr.takeError();
1680 return Importer.getToContext().getTypeOfExprType(*ToExprOrErr, T->
getKind());
1683ExpectedType ASTNodeImporter::VisitTypeOfType(
const TypeOfType *T) {
1684 ExpectedType ToUnderlyingTypeOrErr =
import(T->getUnmodifiedType());
1685 if (!ToUnderlyingTypeOrErr)
1686 return ToUnderlyingTypeOrErr.takeError();
1687 return Importer.getToContext().getTypeOfType(*ToUnderlyingTypeOrErr,
1691ExpectedType ASTNodeImporter::VisitUsingType(
const UsingType *T) {
1692 Error Err = Error::success();
1693 auto ToQualifier = importChecked(Err, T->
getQualifier());
1694 auto *ToD = importChecked(Err, T->
getDecl());
1695 QualType ToT = importChecked(Err, T->
desugar());
1697 return std::move(Err);
1698 return Importer.getToContext().getUsingType(T->
getKeyword(), ToQualifier, ToD,
1702ExpectedType ASTNodeImporter::VisitDecltypeType(
const DecltypeType *T) {
1704 ExpectedExpr ToExprOrErr =
import(T->getUnderlyingExpr());
1706 return ToExprOrErr.takeError();
1708 ExpectedType ToUnderlyingTypeOrErr =
import(T->getUnderlyingType());
1709 if (!ToUnderlyingTypeOrErr)
1710 return ToUnderlyingTypeOrErr.takeError();
1712 return Importer.getToContext().getDecltypeType(
1713 *ToExprOrErr, *ToUnderlyingTypeOrErr);
1717ASTNodeImporter::VisitUnaryTransformType(
const UnaryTransformType *T) {
1718 ExpectedType ToBaseTypeOrErr =
import(T->getBaseType());
1719 if (!ToBaseTypeOrErr)
1720 return ToBaseTypeOrErr.takeError();
1722 ExpectedType ToUnderlyingTypeOrErr =
import(T->getUnderlyingType());
1723 if (!ToUnderlyingTypeOrErr)
1724 return ToUnderlyingTypeOrErr.takeError();
1726 return Importer.getToContext().getUnaryTransformType(
1727 *ToBaseTypeOrErr, *ToUnderlyingTypeOrErr, T->getUTTKind());
1730ExpectedType ASTNodeImporter::VisitAutoType(
const AutoType *T) {
1732 ExpectedType ToDeducedTypeOrErr =
import(T->getDeducedType());
1733 if (!ToDeducedTypeOrErr)
1734 return ToDeducedTypeOrErr.takeError();
1736 ExpectedDecl ToTypeConstraintConcept =
import(T->getTypeConstraintConcept());
1737 if (!ToTypeConstraintConcept)
1738 return ToTypeConstraintConcept.takeError();
1740 SmallVector<TemplateArgument, 2> ToTemplateArgs;
1743 return std::move(Err);
1745 return Importer.getToContext().getAutoType(
1746 *ToDeducedTypeOrErr, T->getKeyword(),
false,
1747 false, cast_or_null<ConceptDecl>(*ToTypeConstraintConcept),
1751ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
1752 const DeducedTemplateSpecializationType *T) {
1754 Expected<TemplateName> ToTemplateNameOrErr =
import(T->getTemplateName());
1755 if (!ToTemplateNameOrErr)
1756 return ToTemplateNameOrErr.takeError();
1757 ExpectedType ToDeducedTypeOrErr =
import(T->getDeducedType());
1758 if (!ToDeducedTypeOrErr)
1759 return ToDeducedTypeOrErr.takeError();
1761 return Importer.getToContext().getDeducedTemplateSpecializationType(
1762 T->getKeyword(), *ToTemplateNameOrErr, *ToDeducedTypeOrErr,
1763 T->isDependentType());
1766ExpectedType ASTNodeImporter::VisitTagType(
const TagType *T) {
1767 TagDecl *DeclForType = T->getDecl();
1768 Expected<TagDecl *> ToDeclOrErr =
import(DeclForType);
1770 return ToDeclOrErr.takeError();
1776 Expected<TagDecl *> ToDefDeclOrErr =
import(DeclForType->
getDefinition());
1777 if (!ToDefDeclOrErr)
1778 return ToDefDeclOrErr.takeError();
1780 if (T->isCanonicalUnqualified())
1781 return Importer.getToContext().getCanonicalTagType(*ToDeclOrErr);
1783 auto ToQualifierOrErr =
import(T->getQualifier());
1784 if (!ToQualifierOrErr)
1785 return ToQualifierOrErr.takeError();
1787 return Importer.getToContext().getTagType(T->getKeyword(), *ToQualifierOrErr,
1788 *ToDeclOrErr, T->isTagOwned());
1791ExpectedType ASTNodeImporter::VisitEnumType(
const EnumType *T) {
1792 return VisitTagType(T);
1795ExpectedType ASTNodeImporter::VisitRecordType(
const RecordType *T) {
1796 return VisitTagType(T);
1800ASTNodeImporter::VisitInjectedClassNameType(
const InjectedClassNameType *T) {
1801 return VisitTagType(T);
1804ExpectedType ASTNodeImporter::VisitAttributedType(
const AttributedType *T) {
1805 ExpectedType ToModifiedTypeOrErr =
import(T->getModifiedType());
1806 if (!ToModifiedTypeOrErr)
1807 return ToModifiedTypeOrErr.takeError();
1808 ExpectedType ToEquivalentTypeOrErr =
import(T->getEquivalentType());
1809 if (!ToEquivalentTypeOrErr)
1810 return ToEquivalentTypeOrErr.takeError();
1812 return Importer.getToContext().getAttributedType(
1813 T->getAttrKind(), *ToModifiedTypeOrErr, *ToEquivalentTypeOrErr,
1818ASTNodeImporter::VisitCountAttributedType(
const CountAttributedType *T) {
1820 if (!ToWrappedTypeOrErr)
1821 return ToWrappedTypeOrErr.takeError();
1823 Error Err = Error::success();
1824 Expr *CountExpr = importChecked(Err, T->
getCountExpr());
1826 SmallVector<TypeCoupledDeclRefInfo, 1> CoupledDecls;
1828 Expected<ValueDecl *> ToDeclOrErr =
import(TI.getDecl());
1830 return ToDeclOrErr.takeError();
1831 CoupledDecls.emplace_back(*ToDeclOrErr, TI.isDeref());
1834 return Importer.getToContext().getCountAttributedType(
1836 ArrayRef(CoupledDecls));
1839ExpectedType ASTNodeImporter::VisitTemplateTypeParmType(
1840 const TemplateTypeParmType *T) {
1841 Expected<TemplateTypeParmDecl *> ToDeclOrErr =
import(T->getDecl());
1843 return ToDeclOrErr.takeError();
1845 return Importer.getToContext().getTemplateTypeParmType(
1846 T->getDepth(), T->getIndex(), T->isParameterPack(), *ToDeclOrErr);
1849ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmType(
1850 const SubstTemplateTypeParmType *T) {
1851 Expected<Decl *> ReplacedOrErr =
import(T->getAssociatedDecl());
1853 return ReplacedOrErr.takeError();
1855 ExpectedType ToReplacementTypeOrErr =
import(T->getReplacementType());
1856 if (!ToReplacementTypeOrErr)
1857 return ToReplacementTypeOrErr.takeError();
1859 return Importer.getToContext().getSubstTemplateTypeParmType(
1860 *ToReplacementTypeOrErr, *ReplacedOrErr, T->getIndex(), T->getPackIndex(),
1864ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmPackType(
1865 const SubstTemplateTypeParmPackType *T) {
1866 Expected<Decl *> ReplacedOrErr =
import(T->getAssociatedDecl());
1868 return ReplacedOrErr.takeError();
1870 Expected<TemplateArgument> ToArgumentPack =
import(T->getArgumentPack());
1871 if (!ToArgumentPack)
1872 return ToArgumentPack.takeError();
1874 return Importer.getToContext().getSubstTemplateTypeParmPackType(
1875 *ReplacedOrErr, T->getIndex(), T->getFinal(), *ToArgumentPack);
1878ExpectedType ASTNodeImporter::VisitSubstBuiltinTemplatePackType(
1879 const SubstBuiltinTemplatePackType *T) {
1880 Expected<TemplateArgument> ToArgumentPack =
import(T->getArgumentPack());
1881 if (!ToArgumentPack)
1882 return ToArgumentPack.takeError();
1883 return Importer.getToContext().getSubstBuiltinTemplatePack(*ToArgumentPack);
1886ExpectedType ASTNodeImporter::VisitTemplateSpecializationType(
1887 const TemplateSpecializationType *T) {
1888 auto ToTemplateOrErr =
import(T->getTemplateName());
1889 if (!ToTemplateOrErr)
1890 return ToTemplateOrErr.takeError();
1892 SmallVector<TemplateArgument, 2> ToTemplateArgs;
1895 return std::move(Err);
1898 T->isCanonicalUnqualified() ? QualType() : import(T->desugar());
1899 if (!ToUnderlyingOrErr)
1900 return ToUnderlyingOrErr.takeError();
1901 return Importer.getToContext().getTemplateSpecializationType(
1902 T->getKeyword(), *ToTemplateOrErr, ToTemplateArgs, {},
1903 *ToUnderlyingOrErr);
1907ASTNodeImporter::VisitPackExpansionType(
const PackExpansionType *T) {
1909 if (!ToPatternOrErr)
1910 return ToPatternOrErr.takeError();
1912 return Importer.getToContext().getPackExpansionType(*ToPatternOrErr,
1913 T->getNumExpansions(),
1918ASTNodeImporter::VisitDependentNameType(
const DependentNameType *T) {
1919 auto ToQualifierOrErr =
import(T->getQualifier());
1920 if (!ToQualifierOrErr)
1921 return ToQualifierOrErr.takeError();
1923 IdentifierInfo *Name = Importer.Import(T->getIdentifier());
1924 return Importer.getToContext().getDependentNameType(T->getKeyword(),
1925 *ToQualifierOrErr, Name);
1929ASTNodeImporter::VisitObjCInterfaceType(
const ObjCInterfaceType *T) {
1930 Expected<ObjCInterfaceDecl *> ToDeclOrErr =
import(T->
getDecl());
1932 return ToDeclOrErr.takeError();
1934 return Importer.getToContext().getObjCInterfaceType(*ToDeclOrErr);
1937ExpectedType ASTNodeImporter::VisitObjCObjectType(
const ObjCObjectType *T) {
1938 ExpectedType ToBaseTypeOrErr =
import(T->getBaseType());
1939 if (!ToBaseTypeOrErr)
1940 return ToBaseTypeOrErr.takeError();
1942 SmallVector<QualType, 4> TypeArgs;
1943 for (
auto TypeArg : T->getTypeArgsAsWritten()) {
1945 TypeArgs.push_back(*TyOrErr);
1947 return TyOrErr.takeError();
1950 SmallVector<ObjCProtocolDecl *, 4> Protocols;
1951 for (
auto *P : T->quals()) {
1952 if (Expected<ObjCProtocolDecl *> ProtocolOrErr =
import(P))
1953 Protocols.push_back(*ProtocolOrErr);
1955 return ProtocolOrErr.takeError();
1959 return Importer.getToContext().getObjCObjectType(*ToBaseTypeOrErr, TypeArgs,
1961 T->isKindOfTypeAsWritten());
1965ASTNodeImporter::VisitObjCObjectPointerType(
const ObjCObjectPointerType *T) {
1967 if (!ToPointeeTypeOrErr)
1968 return ToPointeeTypeOrErr.takeError();
1970 return Importer.getToContext().getObjCObjectPointerType(*ToPointeeTypeOrErr);
1974ASTNodeImporter::VisitMacroQualifiedType(
const MacroQualifiedType *T) {
1976 if (!ToUnderlyingTypeOrErr)
1977 return ToUnderlyingTypeOrErr.takeError();
1980 return Importer.getToContext().getMacroQualifiedType(*ToUnderlyingTypeOrErr,
1984ExpectedType clang::ASTNodeImporter::VisitAdjustedType(
const AdjustedType *T) {
1985 Error Err = Error::success();
1989 return std::move(Err);
1991 return Importer.getToContext().getAdjustedType(ToOriginalType,
1995ExpectedType clang::ASTNodeImporter::VisitBitIntType(
const BitIntType *T) {
1996 return Importer.getToContext().getBitIntType(T->
isUnsigned(),
2000ExpectedType clang::ASTNodeImporter::VisitBTFTagAttributedType(
2001 const clang::BTFTagAttributedType *T) {
2002 Error Err = Error::success();
2003 const BTFTypeTagAttr *ToBTFAttr = importChecked(Err, T->getAttr());
2004 QualType ToWrappedType = importChecked(Err, T->getWrappedType());
2006 return std::move(Err);
2008 return Importer.getToContext().getBTFTagAttributedType(ToBTFAttr,
2012ExpectedType clang::ASTNodeImporter::VisitOverflowBehaviorType(
2013 const clang::OverflowBehaviorType *T) {
2014 Error Err = Error::success();
2015 OverflowBehaviorType::OverflowBehaviorKind ToKind = T->getBehaviorKind();
2018 return std::move(Err);
2020 return Importer.getToContext().getOverflowBehaviorType(ToKind,
2024ExpectedType clang::ASTNodeImporter::VisitHLSLAttributedResourceType(
2025 const clang::HLSLAttributedResourceType *T) {
2026 Error Err = Error::success();
2027 const HLSLAttributedResourceType::Attributes &ToAttrs = T->getAttrs();
2028 QualType ToWrappedType = importChecked(Err, T->getWrappedType());
2029 QualType ToContainedType = importChecked(Err, T->getContainedType());
2031 return std::move(Err);
2033 return Importer.getToContext().getHLSLAttributedResourceType(
2034 ToWrappedType, ToContainedType, ToAttrs);
2037ExpectedType clang::ASTNodeImporter::VisitHLSLInlineSpirvType(
2038 const clang::HLSLInlineSpirvType *T) {
2039 Error Err = Error::success();
2041 uint32_t ToOpcode = T->getOpcode();
2043 uint32_t ToAlignment = T->getAlignment();
2045 llvm::SmallVector<SpirvOperand> ToOperands;
2047 for (
auto &Operand : T->getOperands()) {
2048 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
2051 case SpirvOperandKind::ConstantId:
2052 ToOperands.push_back(SpirvOperand::createConstant(
2053 importChecked(Err,
Operand.getResultType()),
Operand.getValue()));
2055 case SpirvOperandKind::Literal:
2056 ToOperands.push_back(SpirvOperand::createLiteral(
Operand.getValue()));
2058 case SpirvOperandKind::TypeId:
2059 ToOperands.push_back(SpirvOperand::createType(
2060 importChecked(Err,
Operand.getResultType())));
2063 llvm_unreachable(
"Invalid SpirvOperand kind");
2067 return std::move(Err);
2070 return Importer.getToContext().getHLSLInlineSpirvType(
2071 ToOpcode, ToSize, ToAlignment, ToOperands);
2074ExpectedType clang::ASTNodeImporter::VisitConstantMatrixType(
2075 const clang::ConstantMatrixType *T) {
2077 if (!ToElementTypeOrErr)
2078 return ToElementTypeOrErr.takeError();
2080 return Importer.getToContext().getConstantMatrixType(
2084ExpectedType clang::ASTNodeImporter::VisitDependentAddressSpaceType(
2085 const clang::DependentAddressSpaceType *T) {
2086 Error Err = Error::success();
2087 QualType ToPointeeType = importChecked(Err, T->
getPointeeType());
2091 return std::move(Err);
2093 return Importer.getToContext().getDependentAddressSpaceType(
2094 ToPointeeType, ToAddrSpaceExpr, ToAttrLoc);
2097ExpectedType clang::ASTNodeImporter::VisitDependentBitIntType(
2098 const clang::DependentBitIntType *T) {
2100 if (!ToNumBitsExprOrErr)
2101 return ToNumBitsExprOrErr.takeError();
2102 return Importer.getToContext().getDependentBitIntType(T->
isUnsigned(),
2103 *ToNumBitsExprOrErr);
2106ExpectedType clang::ASTNodeImporter::VisitPredefinedSugarType(
2107 const clang::PredefinedSugarType *T) {
2108 return Importer.getToContext().getPredefinedSugarType(T->
getKind());
2111ExpectedType clang::ASTNodeImporter::VisitDependentSizedMatrixType(
2112 const clang::DependentSizedMatrixType *T) {
2113 Error Err = Error::success();
2114 QualType ToElementType = importChecked(Err, T->
getElementType());
2115 Expr *ToRowExpr = importChecked(Err, T->
getRowExpr());
2116 Expr *ToColumnExpr = importChecked(Err, T->
getColumnExpr());
2119 return std::move(Err);
2121 return Importer.getToContext().getDependentSizedMatrixType(
2122 ToElementType, ToRowExpr, ToColumnExpr, ToAttrLoc);
2125ExpectedType clang::ASTNodeImporter::VisitDependentVectorType(
2126 const clang::DependentVectorType *T) {
2127 Error Err = Error::success();
2128 QualType ToElementType = importChecked(Err, T->
getElementType());
2129 Expr *ToSizeExpr = importChecked(Err, T->
getSizeExpr());
2132 return std::move(Err);
2134 return Importer.getToContext().getDependentVectorType(
2138ExpectedType clang::ASTNodeImporter::VisitObjCTypeParamType(
2139 const clang::ObjCTypeParamType *T) {
2140 Expected<ObjCTypeParamDecl *> ToDeclOrErr =
import(T->getDecl());
2142 return ToDeclOrErr.takeError();
2144 SmallVector<ObjCProtocolDecl *, 4> ToProtocols;
2145 for (ObjCProtocolDecl *FromProtocol : T->getProtocols()) {
2146 Expected<ObjCProtocolDecl *> ToProtocolOrErr =
import(FromProtocol);
2147 if (!ToProtocolOrErr)
2148 return ToProtocolOrErr.takeError();
2149 ToProtocols.push_back(*ToProtocolOrErr);
2152 return Importer.getToContext().getObjCTypeParamType(*ToDeclOrErr,
2156ExpectedType clang::ASTNodeImporter::VisitPipeType(
const clang::PipeType *T) {
2158 if (!ToElementTypeOrErr)
2159 return ToElementTypeOrErr.takeError();
2161 ASTContext &ToCtx = Importer.getToContext();
2182 if (
isa<RecordDecl>(D) && (FunDecl = dyn_cast<FunctionDecl>(OrigDC)) &&
2184 auto getLeafPointeeType = [](
const Type *T) {
2185 while (T->isPointerType() || T->isArrayType()) {
2186 T = T->getPointeeOrArrayElementType();
2192 getLeafPointeeType(
P->getType().getCanonicalType().getTypePtr());
2193 auto *RT = dyn_cast<RecordType>(LeafT);
2194 if (RT && RT->getDecl() == D) {
2195 Importer.FromDiag(D->
getLocation(), diag::err_unsupported_ast_node)
2214 ToD = cast_or_null<NamedDecl>(Importer.GetAlreadyImportedOrNull(D));
2219 return Error::success();
2233 ToD = cast_or_null<NamedDecl>(Importer.GetAlreadyImportedOrNull(D));
2238 return Error::success();
2243 return Error::success();
2249 if (
RecordDecl *FromRecord = dyn_cast<RecordDecl>(FromD)) {
2251 if (FromRecord->getDefinition() && FromRecord->isCompleteDefinition() &&
2252 !ToRecord->getDefinition()) {
2257 return Error::success();
2260 if (
EnumDecl *FromEnum = dyn_cast<EnumDecl>(FromD)) {
2262 if (FromEnum->getDefinition() && !ToEnum->getDefinition()) {
2267 return Error::success();
2270 return Error::success();
2285 return Error::success();
2291 return ToRangeOrErr.takeError();
2292 return Error::success();
2298 return LocOrErr.takeError();
2299 return Error::success();
2307 return ToTInfoOrErr.takeError();
2308 return Error::success();
2311 llvm_unreachable(
"Unknown name kind.");
2316 if (Importer.isMinimalImport() && !ForceImport) {
2317 auto ToDCOrErr = Importer.ImportContext(FromDC);
2318 return ToDCOrErr.takeError();
2332 auto MightNeedReordering = [](
const Decl *D) {
2337 Error ChildErrors = Error::success();
2338 for (
auto *From : FromDC->
decls()) {
2339 if (!MightNeedReordering(From))
2348 if (!ImportedOrErr) {
2350 ImportedOrErr.takeError());
2353 FieldDecl *FieldFrom = dyn_cast_or_null<FieldDecl>(From);
2354 Decl *ImportedDecl = *ImportedOrErr;
2355 FieldDecl *FieldTo = dyn_cast_or_null<FieldDecl>(ImportedDecl);
2356 if (FieldFrom && FieldTo) {
2386 auto ToDCOrErr = Importer.ImportContext(FromDC);
2388 consumeError(std::move(ChildErrors));
2389 return ToDCOrErr.takeError();
2392 if (
const auto *FromRD = dyn_cast<RecordDecl>(FromDC)) {
2396 for (
auto *D : FromRD->decls()) {
2397 if (!MightNeedReordering(D))
2400 assert(D &&
"DC contains a null decl");
2401 if (
Decl *ToD = Importer.GetAlreadyImportedOrNull(D)) {
2403 assert(ToDC == ToD->getLexicalDeclContext() && ToDC->
containsDecl(ToD));
2415 for (
auto *From : FromDC->
decls()) {
2416 if (MightNeedReordering(From))
2422 ImportedOrErr.takeError());
2442 if (!FromRecordDecl || !ToRecordDecl) {
2443 const RecordType *RecordFrom = FromType->
getAs<RecordType>();
2444 const RecordType *RecordTo = ToType->
getAs<RecordType>();
2446 if (RecordFrom && RecordTo) {
2447 FromRecordDecl = RecordFrom->getDecl();
2448 ToRecordDecl = RecordTo->getDecl();
2452 if (FromRecordDecl && ToRecordDecl) {
2458 return Error::success();
2463 auto ToDCOrErr = Importer.ImportContext(FromD->
getDeclContext());
2465 return ToDCOrErr.takeError();
2469 auto ToLexicalDCOrErr = Importer.ImportContext(
2471 if (!ToLexicalDCOrErr)
2472 return ToLexicalDCOrErr.takeError();
2473 ToLexicalDC = *ToLexicalDCOrErr;
2477 return Error::success();
2483 "Import implicit methods to or from non-definition");
2486 if (FromM->isImplicit()) {
2489 return ToMOrErr.takeError();
2492 return Error::success();
2501 return ToTypedefOrErr.takeError();
2503 return Error::success();
2508 auto DefinitionCompleter = [To]() {
2529 ToCaptures.reserve(FromCXXRD->capture_size());
2530 for (
const auto &FromCapture : FromCXXRD->captures()) {
2531 if (
auto ToCaptureOrErr =
import(FromCapture))
2532 ToCaptures.push_back(*ToCaptureOrErr);
2534 return ToCaptureOrErr.takeError();
2543 DefinitionCompleter();
2547 return Error::success();
2557 if (!Importer.isMinimalImport())
2562 llvm::scope_exit DefinitionCompleterScopeExit(DefinitionCompleter);
2568 auto *ToCXX = dyn_cast<CXXRecordDecl>(To);
2569 auto *FromCXX = dyn_cast<CXXRecordDecl>(From);
2570 if (ToCXX && FromCXX && ToCXX->dataPtr() && FromCXX->dataPtr()) {
2572 struct CXXRecordDecl::DefinitionData &ToData = ToCXX->data();
2573 struct CXXRecordDecl::DefinitionData &FromData = FromCXX->data();
2575 #define FIELD(Name, Width, Merge) \
2576 ToData.Name = FromData.Name;
2577 #include "clang/AST/CXXRecordDeclDefinitionBits.def"
2580 ToCXX->setArgPassingRestrictions(FromCXX->getArgPassingRestrictions());
2583 for (
const auto &Base1 : FromCXX->bases()) {
2586 return TyOrErr.takeError();
2589 if (Base1.isPackExpansion()) {
2590 if (
ExpectedSLoc LocOrErr =
import(Base1.getEllipsisLoc()))
2591 EllipsisLoc = *LocOrErr;
2593 return LocOrErr.takeError();
2601 auto RangeOrErr =
import(Base1.getSourceRange());
2603 return RangeOrErr.takeError();
2605 auto TSIOrErr =
import(Base1.getTypeSourceInfo());
2607 return TSIOrErr.takeError();
2613 Base1.isBaseOfClass(),
2614 Base1.getAccessSpecifierAsWritten(),
2619 ToCXX->setBases(Bases.data(), Bases.size());
2627 return Error::success();
2632 return Error::success();
2636 return Error::success();
2640 return ToInitOrErr.takeError();
2651 return Error::success();
2659 return Error::success();
2668 import(
QualType(Importer.getFromContext().getCanonicalTagType(From)));
2670 return ToTypeOrErr.takeError();
2673 if (!ToPromotionTypeOrErr)
2674 return ToPromotionTypeOrErr.takeError();
2685 return Error::success();
2691 for (
const auto &Arg : FromArgs) {
2692 if (
auto ToOrErr =
import(Arg))
2693 ToArgs.push_back(*ToOrErr);
2695 return ToOrErr.takeError();
2698 return Error::success();
2704 return import(From);
2707template <
typename InContainerTy>
2710 for (
const auto &FromLoc : Container) {
2711 if (
auto ToLocOrErr =
import(FromLoc))
2714 return ToLocOrErr.takeError();
2716 return Error::success();
2726 bool IgnoreTemplateParmDepth) {
2729 Decl *ToOrigin = Importer.GetOriginalDecl(To);
2735 Importer.getToContext().getLangOpts(), Importer.getFromContext(),
2736 Importer.getToContext(), Importer.getNonEquivalentDecls(),
2738 false, Complain,
false,
2739 IgnoreTemplateParmDepth);
2744 Importer.FromDiag(D->
getLocation(), diag::err_unsupported_ast_node)
2750 Importer.FromDiag(D->
getLocation(), diag::err_unsupported_ast_node)
2759 return std::move(Err);
2764 return LocOrErr.takeError();
2767 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, *LocOrErr))
2779 Importer.MapImported(D, ToD);
2790 return std::move(Err);
2795 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, Loc,
2799 Error Err = Error::success();
2804 return std::move(Err);
2808 addDeclToContexts(D, ToD);
2816 return LocOrErr.takeError();
2819 return ColonLocOrErr.takeError();
2824 return DCOrErr.takeError();
2828 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), D->
getAccess(),
2829 DC, *LocOrErr, *ColonLocOrErr))
2843 return DCOrErr.takeError();
2847 Error Err = Error::success();
2853 return std::move(Err);
2856 if (GetImportedOrCreateDecl(
2857 ToD, D, Importer.getToContext(), DC, ToLocation, ToAssertExpr, ToMessage,
2873 return std::move(Err);
2882 if (
auto *TU = dyn_cast<TranslationUnitDecl>(EnclosingDC))
2885 MergeWithNamespace =
2889 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2890 for (
auto *FoundDecl : FoundDecls) {
2894 if (
auto *FoundNS = dyn_cast<NamespaceDecl>(FoundDecl)) {
2895 MergeWithNamespace = FoundNS;
2896 ConflictingDecls.clear();
2900 ConflictingDecls.push_back(FoundDecl);
2903 if (!ConflictingDecls.empty()) {
2906 ConflictingDecls.size());
2908 Name = NameOrErr.get();
2910 return NameOrErr.takeError();
2916 return BeginLocOrErr.takeError();
2918 if (!RBraceLocOrErr)
2919 return RBraceLocOrErr.takeError();
2924 if (GetImportedOrCreateDecl(ToNamespace, D, Importer.getToContext(), DC,
2925 D->
isInline(), *BeginLocOrErr, Loc,
2936 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2937 TU->setAnonymousNamespace(ToNamespace);
2942 Importer.MapImported(D, ToNamespace);
2945 return std::move(Err);
2957 return std::move(Err);
2963 Error Err = Error::success();
2970 return std::move(Err);
2975 if (GetImportedOrCreateDecl(
2976 ToD, D, Importer.getToContext(), DC, ToNamespaceLoc, ToAliasLoc,
2977 ToIdentifier, ToQualifierLoc, ToTargetNameLoc, ToNamespace))
2995 return std::move(Err);
3002 cast_or_null<DeclContext>(Importer.GetAlreadyImportedOrNull(
3014 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3015 for (
auto *FoundDecl : FoundDecls) {
3016 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3018 if (
auto *FoundTypedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
3023 QualType FoundUT = FoundTypedef->getUnderlyingType();
3024 if (Importer.IsStructurallyEquivalent(FromUT, FoundUT)) {
3037 if (FromR && FoundR &&
3044 return Importer.MapImported(D, FoundTypedef);
3048 ConflictingDecls.push_back(FoundDecl);
3053 if (!ConflictingDecls.empty()) {
3055 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3057 Name = NameOrErr.get();
3059 return NameOrErr.takeError();
3063 Error Err = Error::success();
3068 return std::move(Err);
3075 if (GetImportedOrCreateDecl<TypeAliasDecl>(
3076 ToTypedef, D, Importer.getToContext(), DC, ToBeginLoc, Loc,
3079 }
else if (GetImportedOrCreateDecl<TypedefDecl>(
3080 ToTypedef, D, Importer.getToContext(), DC, ToBeginLoc, Loc,
3086 return std::move(Err);
3090 Importer.AddToLookupTable(ToTypedef);
3118 return std::move(Err);
3128 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3129 for (
auto *FoundDecl : FoundDecls) {
3130 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3132 if (
auto *FoundAlias = dyn_cast<TypeAliasTemplateDecl>(FoundDecl)) {
3134 return Importer.MapImported(D, FoundAlias);
3135 ConflictingDecls.push_back(FoundDecl);
3139 if (!ConflictingDecls.empty()) {
3141 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3143 Name = NameOrErr.get();
3145 return NameOrErr.takeError();
3149 Error Err = Error::success();
3153 return std::move(Err);
3156 if (GetImportedOrCreateDecl(ToAlias, D, Importer.getToContext(), DC, Loc,
3157 Name, ToTemplateParameters, ToTemplatedDecl))
3160 ToTemplatedDecl->setDescribedAliasTemplate(ToAlias);
3165 if (DC != Importer.getToContext().getTranslationUnitDecl())
3166 updateLookupTableForTemplateParameters(*ToTemplateParameters);
3177 return std::move(Err);
3187 return BeginLocOrErr.takeError();
3188 if (GetImportedOrCreateDecl(ToLabel, D, Importer.getToContext(), DC, Loc,
3193 if (GetImportedOrCreateDecl(ToLabel, D, Importer.getToContext(), DC, Loc,
3201 return ToStmtOrErr.takeError();
3203 ToLabel->
setStmt(*ToStmtOrErr);
3216 return std::move(Err);
3226 return std::move(Err);
3228 }
else if (Importer.getToContext().getLangOpts().CPlusPlus)
3236 Importer.findDeclsInToCtx(DC, SearchName);
3237 for (
auto *FoundDecl : FoundDecls) {
3238 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3241 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
3242 if (
const auto *Tag =
Typedef->getUnderlyingType()->getAs<TagType>())
3243 FoundDecl = Tag->getDecl();
3246 if (
auto *FoundEnum = dyn_cast<EnumDecl>(FoundDecl)) {
3252 return Importer.MapImported(D, FoundDef);
3256 ConflictingDecls.push_back(FoundDecl);
3265 if (SearchName && !ConflictingDecls.empty()) {
3267 SearchName, DC, IDNS, ConflictingDecls.data(),
3268 ConflictingDecls.size());
3270 Name = NameOrErr.get();
3272 return NameOrErr.takeError();
3276 Error Err = Error::success();
3282 return std::move(Err);
3286 if (GetImportedOrCreateDecl(
3287 D2, D, Importer.getToContext(), DC, ToBeginLoc,
3297 addDeclToContexts(D, D2);
3303 D2->setInstantiationOfMemberEnum(*ToInstOrErr, SK);
3305 return ToInstOrErr.takeError();
3306 if (
ExpectedSLoc POIOrErr =
import(MemberInfo->getPointOfInstantiation()))
3309 return POIOrErr.takeError();
3315 return std::move(Err);
3321 bool IsFriendTemplate =
false;
3322 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3324 DCXX->getDescribedClassTemplate() &&
3325 DCXX->getDescribedClassTemplate()->getFriendObjectKind() !=
3335 return std::move(Err);
3345 return std::move(Err);
3347 }
else if (Importer.getToContext().getLangOpts().CPlusPlus)
3352 bool DependentFriend = IsFriendTemplate && IsDependentContext;
3359 Importer.findDeclsInToCtx(DC, SearchName);
3360 if (!FoundDecls.empty()) {
3367 for (
auto *FoundDecl : FoundDecls) {
3368 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3372 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Found)) {
3373 if (
const auto *Tag =
Typedef->getUnderlyingType()->getAs<TagType>())
3374 Found = Tag->getDecl();
3377 if (
auto *FoundRecord = dyn_cast<RecordDecl>(
Found)) {
3399 Importer.MapImported(D, FoundDef);
3400 if (
const auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3401 auto *FoundCXX = dyn_cast<CXXRecordDecl>(FoundDef);
3402 assert(FoundCXX &&
"Record type mismatch");
3404 if (!Importer.isMinimalImport())
3408 return std::move(Err);
3415 ConflictingDecls.push_back(FoundDecl);
3419 if (!ConflictingDecls.empty() && SearchName) {
3421 SearchName, DC, IDNS, ConflictingDecls.data(),
3422 ConflictingDecls.size());
3424 Name = NameOrErr.get();
3426 return NameOrErr.takeError();
3432 return BeginLocOrErr.takeError();
3437 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3438 if (DCXX->isLambda()) {
3439 auto TInfoOrErr =
import(DCXX->getLambdaTypeInfo());
3441 return TInfoOrErr.takeError();
3442 if (GetImportedOrCreateSpecialDecl(
3444 DC, *TInfoOrErr, Loc, DCXX->getLambdaDependencyKind(),
3445 DCXX->isGenericLambda(), DCXX->getLambdaCaptureDefault()))
3447 Decl *ContextDecl = DCXX->getLambdaContextDecl();
3450 return CDeclOrErr.takeError();
3451 if (ContextDecl !=
nullptr) {
3456 if (GetImportedOrCreateDecl(D2CXX, D, Importer.getToContext(),
3459 cast_or_null<CXXRecordDecl>(PrevDecl)))
3466 addDeclToContexts(D, D2);
3469 DCXX->getDescribedClassTemplate()) {
3472 return std::move(Err);
3475 DCXX->getMemberSpecializationInfo()) {
3477 MemberInfo->getTemplateSpecializationKind();
3483 return ToInstOrErr.takeError();
3486 import(MemberInfo->getPointOfInstantiation()))
3490 return POIOrErr.takeError();
3494 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(),
3499 addDeclToContexts(D, D2);
3505 return BraceRangeOrErr.takeError();
3509 return QualifierLocOrErr.takeError();
3516 return std::move(Err);
3528 return std::move(Err);
3537 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3538 for (
auto *FoundDecl : FoundDecls) {
3539 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3542 if (
auto *FoundEnumConstant = dyn_cast<EnumConstantDecl>(FoundDecl)) {
3544 return Importer.MapImported(D, FoundEnumConstant);
3545 ConflictingDecls.push_back(FoundDecl);
3549 if (!ConflictingDecls.empty()) {
3551 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3553 Name = NameOrErr.get();
3555 return NameOrErr.takeError();
3561 return TypeOrErr.takeError();
3565 return InitOrErr.takeError();
3568 if (GetImportedOrCreateDecl(
3569 ToEnumerator, D, Importer.getToContext(),
cast<EnumDecl>(DC), Loc,
3571 return ToEnumerator;
3576 return ToEnumerator;
3579template <
typename DeclTy>
3582 unsigned int Num = FromD->getNumTemplateParameterLists();
3584 return Error::success();
3586 for (
unsigned int I = 0; I <
Num; ++I)
3588 import(FromD->getTemplateParameterList(I)))
3589 ToTPLists[I] = *ToTPListOrErr;
3591 return ToTPListOrErr.takeError();
3592 ToD->setTemplateParameterListsInfo(Importer.ToContext, ToTPLists);
3593 return Error::success();
3601 return Error::success();
3607 return Error::success();
3613 ToFD->setInstantiationOfMemberFunction(*InstFDOrErr, TSK);
3615 return InstFDOrErr.takeError();
3621 return POIOrErr.takeError();
3623 return Error::success();
3627 auto FunctionAndArgsOrErr =
3629 if (!FunctionAndArgsOrErr)
3630 return FunctionAndArgsOrErr.takeError();
3633 Importer.getToContext(), std::get<1>(*FunctionAndArgsOrErr));
3637 const auto *FromTAArgsAsWritten = FTSInfo->TemplateArgumentsAsWritten;
3638 if (FromTAArgsAsWritten)
3640 *FromTAArgsAsWritten, ToTAInfo))
3643 ExpectedSLoc POIOrErr =
import(FTSInfo->getPointOfInstantiation());
3645 return POIOrErr.takeError();
3651 ToFD->setFunctionTemplateSpecialization(
3652 std::get<0>(*FunctionAndArgsOrErr), ToTAList,
nullptr,
3653 TSK, FromTAArgsAsWritten ? &ToTAInfo :
nullptr, *POIOrErr);
3654 return Error::success();
3662 Candidates.
addDecl(*ToFTDOrErr);
3664 return ToFTDOrErr.takeError();
3669 const auto *FromTAArgsAsWritten = FromInfo->TemplateArgumentsAsWritten;
3670 if (FromTAArgsAsWritten)
3676 Importer.getToContext(), Candidates,
3677 FromTAArgsAsWritten ? &ToTAInfo :
nullptr);
3678 return Error::success();
3681 llvm_unreachable(
"All cases should be covered!");
3686 auto FunctionAndArgsOrErr =
3688 if (!FunctionAndArgsOrErr)
3689 return FunctionAndArgsOrErr.takeError();
3693 std::tie(
Template, ToTemplArgs) = *FunctionAndArgsOrErr;
3694 void *InsertPos =
nullptr;
3695 auto *FoundSpec =
Template->findSpecialization(ToTemplArgs, InsertPos);
3705 return ToBodyOrErr.takeError();
3707 return Error::success();
3713 const DeclContext *DCi = dyn_cast<DeclContext>(D);
3716 assert(DCi &&
"Declaration should have a context");
3730 ToProcess.push_back(S);
3731 while (!ToProcess.empty()) {
3732 const Stmt *CurrentS = ToProcess.pop_back_val();
3734 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(CurrentS)) {
3735 if (
const Decl *D = DeclRef->getDecl())
3738 }
else if (
const auto *E =
3739 dyn_cast_or_null<SubstNonTypeTemplateParmExpr>(CurrentS)) {
3740 if (
const Decl *D = E->getAssociatedDecl())
3773class IsTypeDeclaredInsideVisitor
3774 :
public TypeVisitor<IsTypeDeclaredInsideVisitor, std::optional<bool>> {
3776 IsTypeDeclaredInsideVisitor(
const FunctionDecl *ParentDC)
3777 : ParentDC(ParentDC) {}
3779 bool CheckType(QualType T) {
3783 if (std::optional<bool> Res = Visit(T.
getTypePtr()))
3788 if (std::optional<bool> Res = Visit(DsT.
getTypePtr()))
3796 std::optional<bool> VisitTagType(
const TagType *T) {
3797 if (
auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(T->getDecl()))
3798 for (
const auto &Arg : Spec->getTemplateArgs().asArray())
3799 if (checkTemplateArgument(Arg))
3804 std::optional<bool> VisitPointerType(
const PointerType *T) {
3808 std::optional<bool> VisitReferenceType(
const ReferenceType *T) {
3812 std::optional<bool> VisitTypedefType(
const TypedefType *T) {
3816 std::optional<bool> VisitUsingType(
const UsingType *T) {
3821 VisitTemplateSpecializationType(
const TemplateSpecializationType *T) {
3822 for (
const auto &Arg : T->template_arguments())
3823 if (checkTemplateArgument(Arg))
3829 std::optional<bool> VisitUnaryTransformType(
const UnaryTransformType *T) {
3830 return CheckType(T->getBaseType());
3834 VisitSubstTemplateTypeParmType(
const SubstTemplateTypeParmType *T) {
3841 std::optional<bool> VisitConstantArrayType(
const ConstantArrayType *T) {
3848 std::optional<bool> VisitVariableArrayType(
const VariableArrayType *T) {
3850 "Variable array should not occur in deduced return type of a function");
3853 std::optional<bool> VisitIncompleteArrayType(
const IncompleteArrayType *T) {
3854 llvm_unreachable(
"Incomplete array should not occur in deduced return type "
3858 std::optional<bool> VisitDependentArrayType(
const IncompleteArrayType *T) {
3859 llvm_unreachable(
"Dependent array should not occur in deduced return type "
3864 const DeclContext *
const ParentDC;
3866 bool checkTemplateArgument(
const TemplateArgument &Arg) {
3886 if (checkTemplateArgument(PackArg))
3898 llvm_unreachable(
"Unknown TemplateArgument::ArgKind enum");
3908 assert(FromFPT &&
"Must be called on FunctionProtoType");
3910 auto IsCXX11Lambda = [&]() {
3911 if (Importer.FromContext.getLangOpts().CPlusPlus14)
3917 QualType RetT = FromFPT->getReturnType();
3920 IsTypeDeclaredInsideVisitor Visitor(Def ? Def : D);
3921 return Visitor.CheckType(RetT);
3931 ExplicitExpr = importChecked(Err, ESpec.
getExpr());
3938 auto RedeclIt = Redecls.begin();
3941 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
3944 return ToRedeclOrErr.takeError();
3946 assert(*RedeclIt == D);
3954 return std::move(Err);
3969 if (!FoundFunctionOrErr)
3970 return FoundFunctionOrErr.takeError();
3971 if (
FunctionDecl *FoundFunction = *FoundFunctionOrErr) {
3972 if (
Decl *Def = FindAndMapDefinition(D, FoundFunction))
3974 FoundByLookup = FoundFunction;
3982 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3983 for (
auto *FoundDecl : FoundDecls) {
3984 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3987 if (
auto *FoundFunction = dyn_cast<FunctionDecl>(FoundDecl)) {
3992 if (
Decl *Def = FindAndMapDefinition(D, FoundFunction))
3994 FoundByLookup = FoundFunction;
4001 if (Importer.getToContext().getLangOpts().CPlusPlus)
4005 Importer.ToDiag(Loc, diag::warn_odr_function_type_inconsistent)
4006 << Name << D->
getType() << FoundFunction->getType();
4007 Importer.ToDiag(FoundFunction->getLocation(), diag::note_odr_value_here)
4008 << FoundFunction->getType();
4009 ConflictingDecls.push_back(FoundDecl);
4013 if (!ConflictingDecls.empty()) {
4015 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
4017 Name = NameOrErr.get();
4019 return NameOrErr.takeError();
4029 if (FoundByLookup) {
4039 "Templated function mapped to non-templated?");
4040 Importer.MapImported(DescribedD,
4043 return Importer.MapImported(D, FoundByLookup);
4055 return std::move(Err);
4066 bool UsedDifferentProtoType =
false;
4068 QualType FromReturnTy = FromFPT->getReturnType();
4077 Importer.FindFunctionDeclImportCycle.isCycle(D)) {
4078 FromReturnTy = Importer.getFromContext().VoidTy;
4079 UsedDifferentProtoType =
true;
4090 FromEPI = DefaultEPI;
4091 UsedDifferentProtoType =
true;
4093 FromTy = Importer.getFromContext().getFunctionType(
4094 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
4095 FromTSI = Importer.getFromContext().getTrivialTypeSourceInfo(
4099 Error Err = Error::success();
4100 auto ScopedReturnTypeDeclCycleDetector =
4101 Importer.FindFunctionDeclImportCycle.makeScopedCycleDetection(D);
4112 return std::move(Err);
4118 Parameters.push_back(*ToPOrErr);
4120 return ToPOrErr.takeError();
4125 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
4127 importExplicitSpecifier(Err, FromConstructor->getExplicitSpecifier());
4129 return std::move(Err);
4131 if (FromConstructor->isInheritingConstructor()) {
4133 import(FromConstructor->getInheritedConstructor());
4134 if (!ImportedInheritedCtor)
4135 return ImportedInheritedCtor.takeError();
4136 ToInheritedConstructor = *ImportedInheritedCtor;
4138 if (GetImportedOrCreateDecl<CXXConstructorDecl>(
4140 ToInnerLocStart, NameInfo, T, TInfo, ESpec, D->
UsesFPIntrin(),
4142 ToInheritedConstructor, TrailingRequiresClause))
4146 Error Err = Error::success();
4148 Err,
const_cast<FunctionDecl *
>(FromDtor->getOperatorDelete()));
4149 auto ToThisArg =
importChecked(Err, FromDtor->getOperatorDeleteThisArg());
4151 return std::move(Err);
4153 if (GetImportedOrCreateDecl<CXXDestructorDecl>(
4155 ToInnerLocStart, NameInfo, T, TInfo, D->
UsesFPIntrin(),
4157 TrailingRequiresClause))
4164 dyn_cast<CXXConversionDecl>(D)) {
4166 importExplicitSpecifier(Err, FromConversion->getExplicitSpecifier());
4168 return std::move(Err);
4169 if (GetImportedOrCreateDecl<CXXConversionDecl>(
4171 ToInnerLocStart, NameInfo, T, TInfo, D->
UsesFPIntrin(),
4175 }
else if (
auto *
Method = dyn_cast<CXXMethodDecl>(D)) {
4176 if (GetImportedOrCreateDecl<CXXMethodDecl>(
4178 ToInnerLocStart, NameInfo, T, TInfo,
Method->getStorageClass(),
4182 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(D)) {
4184 importExplicitSpecifier(Err, Guide->getExplicitSpecifier());
4190 return std::move(Err);
4191 if (GetImportedOrCreateDecl<CXXDeductionGuideDecl>(
4192 ToFunction, D, Importer.getToContext(), DC, ToInnerLocStart, ESpec,
4193 NameInfo, T, TInfo, ToEndLoc, Ctor,
4194 Guide->getDeductionCandidateKind(), TrailingRequiresClause,
4198 if (GetImportedOrCreateDecl(
4199 ToFunction, D, Importer.getToContext(), DC, ToInnerLocStart,
4207 if (FoundByLookup) {
4246 Importer.getToContext(), {}, Msg));
4249 for (
auto *Param : Parameters) {
4250 Param->setOwningFunction(ToFunction);
4253 LT->update(Param, Importer.getToContext().getTranslationUnitDecl());
4255 ToFunction->setParams(Parameters);
4262 for (
unsigned I = 0, N = Parameters.size(); I != N; ++I)
4263 ProtoLoc.setParam(I, Parameters[I]);
4269 auto ToFTOrErr =
import(FromFT);
4271 return ToFTOrErr.takeError();
4275 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
4276 if (
unsigned NumInitializers = FromConstructor->getNumCtorInitializers()) {
4280 FromConstructor->inits(), CtorInitializers))
4281 return std::move(Err);
4284 llvm::copy(CtorInitializers, Memory);
4286 ToCtor->setCtorInitializers(Memory);
4287 ToCtor->setNumCtorInitializers(NumInitializers);
4293 return std::move(Err);
4295 if (
auto *FromCXXMethod = dyn_cast<CXXMethodDecl>(D))
4298 return std::move(Err);
4304 return std::move(Err);
4308 if (UsedDifferentProtoType) {
4310 ToFunction->
setType(*TyOrErr);
4312 return TyOrErr.takeError();
4316 return TSIOrErr.takeError();
4321 addDeclToContexts(D, ToFunction);
4324 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4327 return ToRedeclOrErr.takeError();
4361 return std::move(Err);
4366 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4367 for (
auto *FoundDecl : FoundDecls) {
4368 if (
FieldDecl *FoundField = dyn_cast<FieldDecl>(FoundDecl)) {
4375 if (Importer.IsStructurallyEquivalent(D->
getType(),
4376 FoundField->getType())) {
4377 Importer.MapImported(D, FoundField);
4385 if (
ExpectedExpr ToInitializerOrErr =
import(FromInitializer)) {
4388 assert(FoundField->hasInClassInitializer() &&
4389 "Field should have an in-class initializer if it has an "
4390 "expression for it.");
4391 if (!FoundField->getInClassInitializer())
4392 FoundField->setInClassInitializer(*ToInitializerOrErr);
4394 return ToInitializerOrErr.takeError();
4401 Importer.ToDiag(Loc, diag::warn_odr_field_type_inconsistent)
4402 << Name << D->
getType() << FoundField->getType();
4403 Importer.ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4404 << FoundField->getType();
4410 Error Err = Error::success();
4416 return std::move(Err);
4417 const Type *ToCapturedVLAType =
nullptr;
4418 if (
Error Err = Importer.importInto(
4420 return std::move(Err);
4423 if (GetImportedOrCreateDecl(ToField, D, Importer.getToContext(), DC,
4425 ToType, ToTInfo, ToBitWidth, D->
isMutable(),
4432 if (ToCapturedVLAType)
4439 return std::move(Err);
4440 if (ToInitializer) {
4442 if (AlreadyImported)
4443 assert(ToInitializer == AlreadyImported &&
4444 "Duplicate import of in-class initializer.");
4459 return std::move(Err);
4464 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4465 for (
unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
4466 if (
auto *FoundField = dyn_cast<IndirectFieldDecl>(FoundDecls[I])) {
4473 if (Importer.IsStructurallyEquivalent(D->
getType(),
4474 FoundField->getType(),
4476 Importer.MapImported(D, FoundField);
4481 if (!Name && I < N-1)
4485 Importer.ToDiag(Loc, diag::warn_odr_field_type_inconsistent)
4486 << Name << D->
getType() << FoundField->getType();
4487 Importer.ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4488 << FoundField->getType();
4495 auto TypeOrErr =
import(D->
getType());
4497 return TypeOrErr.takeError();
4503 for (
auto *PI : D->
chain())
4505 NamedChain[i++] = *ToD;
4507 return ToD.takeError();
4511 if (GetImportedOrCreateDecl(ToIndirectField, D, Importer.getToContext(), DC,
4514 return ToIndirectField;
4519 return ToIndirectField;
4550 unsigned int FriendCount = 0;
4554 for (
FriendDecl *FoundFriend : RD->friends()) {
4555 if (FoundFriend == FD) {
4556 FriendPosition = FriendCount;
4563 assert(FriendPosition &&
"Friend decl not found in own parent.");
4565 return {FriendCount, *FriendPosition};
4572 return std::move(Err);
4579 for (
FriendDecl *ImportedFriend : RD->friends())
4581 ImportedEquivalentFriends.push_back(ImportedFriend);
4586 assert(ImportedEquivalentFriends.size() <= CountAndPosition.
TotalCount &&
4587 "Class with non-matching friends is imported, ODR check wrong?");
4588 if (ImportedEquivalentFriends.size() == CountAndPosition.
TotalCount)
4589 return Importer.MapImported(
4590 D, ImportedEquivalentFriends[CountAndPosition.
IndexOfDecl]);
4598 return std::move(Err);
4609 return TSIOrErr.takeError();
4613 auto **FromTPLists = D->getTrailingObjects();
4614 for (
unsigned I = 0; I < D->NumTPLists; I++) {
4615 if (
auto ListOrErr =
import(FromTPLists[I]))
4616 ToTPLists[I] = *ListOrErr;
4618 return ListOrErr.takeError();
4623 return LocationOrErr.takeError();
4625 if (!FriendLocOrErr)
4626 return FriendLocOrErr.takeError();
4628 if (!EllipsisLocOrErr)
4629 return EllipsisLocOrErr.takeError();
4632 if (GetImportedOrCreateDecl(FrD, D, Importer.getToContext(), DC,
4633 *LocationOrErr, ToFU, *FriendLocOrErr,
4634 *EllipsisLocOrErr, ToTPLists))
4650 return std::move(Err);
4655 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4656 for (
auto *FoundDecl : FoundDecls) {
4657 if (
ObjCIvarDecl *FoundIvar = dyn_cast<ObjCIvarDecl>(FoundDecl)) {
4658 if (Importer.IsStructurallyEquivalent(D->
getType(),
4659 FoundIvar->getType())) {
4660 Importer.MapImported(D, FoundIvar);
4664 Importer.ToDiag(Loc, diag::warn_odr_ivar_type_inconsistent)
4665 << Name << D->
getType() << FoundIvar->getType();
4666 Importer.ToDiag(FoundIvar->getLocation(), diag::note_odr_value_here)
4667 << FoundIvar->getType();
4673 Error Err = Error::success();
4679 return std::move(Err);
4682 if (GetImportedOrCreateDecl(
4685 ToType, ToTypeSourceInfo,
4697 auto RedeclIt = Redecls.begin();
4700 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
4703 return RedeclOrErr.takeError();
4705 assert(*RedeclIt == D);
4713 return std::move(Err);
4719 VarDecl *FoundByLookup =
nullptr;
4723 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4724 for (
auto *FoundDecl : FoundDecls) {
4725 if (!FoundDecl->isInIdentifierNamespace(IDNS))
4728 if (
auto *FoundVar = dyn_cast<VarDecl>(FoundDecl)) {
4731 if (Importer.IsStructurallyEquivalent(D->
getType(),
4732 FoundVar->getType())) {
4740 return Importer.MapImported(D, FoundDef);
4744 const VarDecl *FoundDInit =
nullptr;
4745 if (D->
getInit() && FoundVar->getAnyInitializer(FoundDInit))
4747 return Importer.MapImported(D,
const_cast<VarDecl*
>(FoundDInit));
4749 FoundByLookup = FoundVar;
4754 = Importer.getToContext().getAsArrayType(FoundVar->getType());
4756 = Importer.getToContext().getAsArrayType(D->
getType());
4757 if (FoundArray && TArray) {
4761 if (
auto TyOrErr =
import(D->
getType()))
4762 FoundVar->setType(*TyOrErr);
4764 return TyOrErr.takeError();
4766 FoundByLookup = FoundVar;
4770 FoundByLookup = FoundVar;
4775 Importer.ToDiag(Loc, diag::warn_odr_variable_type_inconsistent)
4776 << Name << D->
getType() << FoundVar->getType();
4777 Importer.ToDiag(FoundVar->getLocation(), diag::note_odr_value_here)
4778 << FoundVar->getType();
4779 ConflictingDecls.push_back(FoundDecl);
4783 if (!ConflictingDecls.empty()) {
4785 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
4787 Name = NameOrErr.get();
4789 return NameOrErr.takeError();
4793 Error Err = Error::success();
4799 return std::move(Err);
4802 if (
auto *FromDecomp = dyn_cast<DecompositionDecl>(D)) {
4806 return std::move(Err);
4808 if (GetImportedOrCreateDecl(
4809 ToDecomp, FromDecomp, Importer.getToContext(), DC, ToInnerLocStart,
4815 if (GetImportedOrCreateDecl(ToVar, D, Importer.getToContext(), DC,
4816 ToInnerLocStart, Loc,
4831 if (FoundByLookup) {
4840 return ToVTOrErr.takeError();
4847 return ToInstOrErr.takeError();
4848 if (
ExpectedSLoc POIOrErr =
import(MSI->getPointOfInstantiation()))
4851 return POIOrErr.takeError();
4855 return std::move(Err);
4860 addDeclToContexts(D, ToVar);
4863 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4866 return RedeclOrErr.takeError();
4875 DeclContext *DC = Importer.getToContext().getTranslationUnitDecl();
4877 Error Err = Error::success();
4882 return std::move(Err);
4886 if (GetImportedOrCreateDecl(ToParm, D, Importer.getToContext(), DC,
4887 ToLocation, ToDeclName.getAsIdentifierInfo(),
4899 return LocOrErr.takeError();
4908 return ToDefArgOrErr.takeError();
4912 if (
auto ToDefArgOrErr =
import(FromParam->
getDefaultArg()))
4915 return ToDefArgOrErr.takeError();
4918 return Error::success();
4923 Error Err = Error::success();
4928 return std::move(Err);
4935 DeclContext *DC = Importer.getToContext().getTranslationUnitDecl();
4937 Error Err = Error::success();
4944 return std::move(Err);
4947 if (GetImportedOrCreateDecl(ToParm, D, Importer.getToContext(), DC,
4948 ToInnerLocStart, ToLocation,
4949 ToDeclName.getAsIdentifierInfo(), ToType,
4958 return std::move(Err);
4978 return std::move(Err);
4982 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4983 for (
auto *FoundDecl : FoundDecls) {
4984 if (
auto *FoundMethod = dyn_cast<ObjCMethodDecl>(FoundDecl)) {
4990 FoundMethod->getReturnType())) {
4991 Importer.ToDiag(Loc, diag::warn_odr_objc_method_result_type_inconsistent)
4993 << FoundMethod->getReturnType();
4994 Importer.ToDiag(FoundMethod->getLocation(),
4995 diag::note_odr_objc_method_here)
5002 if (D->
param_size() != FoundMethod->param_size()) {
5003 Importer.ToDiag(Loc, diag::warn_odr_objc_method_num_params_inconsistent)
5005 << D->
param_size() << FoundMethod->param_size();
5006 Importer.ToDiag(FoundMethod->getLocation(),
5007 diag::note_odr_objc_method_here)
5015 PEnd = D->
param_end(), FoundP = FoundMethod->param_begin();
5016 P != PEnd; ++
P, ++FoundP) {
5017 if (!Importer.IsStructurallyEquivalent((*P)->getType(),
5018 (*FoundP)->getType())) {
5019 Importer.FromDiag((*P)->getLocation(),
5020 diag::warn_odr_objc_method_param_type_inconsistent)
5022 << (*P)->getType() << (*FoundP)->getType();
5023 Importer.ToDiag((*FoundP)->getLocation(), diag::note_odr_value_here)
5024 << (*FoundP)->getType();
5032 if (D->
isVariadic() != FoundMethod->isVariadic()) {
5033 Importer.ToDiag(Loc, diag::warn_odr_objc_method_variadic_inconsistent)
5035 Importer.ToDiag(FoundMethod->getLocation(),
5036 diag::note_odr_objc_method_here)
5043 return Importer.MapImported(D, FoundMethod);
5047 Error Err = Error::success();
5050 auto ToReturnTypeSourceInfo =
5053 return std::move(Err);
5056 if (GetImportedOrCreateDecl(
5057 ToMethod, D, Importer.getToContext(), Loc, ToEndLoc,
5071 ToParams.push_back(*ToPOrErr);
5073 return ToPOrErr.takeError();
5077 for (
auto *ToParam : ToParams) {
5078 ToParam->setOwningFunction(ToMethod);
5086 return std::move(Err);
5088 ToMethod->
setMethodParams(Importer.getToContext(), ToParams, ToSelLocs);
5110 return std::move(Err);
5114 Error Err = Error::success();
5120 return std::move(Err);
5123 if (GetImportedOrCreateDecl(
5127 ToColonLoc, ToTypeSourceInfo))
5133 return std::move(Err);
5134 Result->setTypeForDecl(ToTypeForDecl);
5135 Result->setLexicalDeclContext(LexicalDC);
5146 return std::move(Err);
5152 return std::move(Err);
5160 Error Err = Error::success();
5166 return std::move(Err);
5168 if (GetImportedOrCreateDecl(ToCategory, D, Importer.getToContext(), DC,
5184 return PListOrErr.takeError();
5193 FromProto != FromProtoEnd;
5194 ++FromProto, ++FromProtoLoc) {
5196 Protocols.push_back(*ToProtoOrErr);
5198 return ToProtoOrErr.takeError();
5200 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5201 ProtocolLocs.push_back(*ToProtoLocOrErr);
5203 return ToProtoLocOrErr.takeError();
5208 ProtocolLocs.data(), Importer.getToContext());
5211 Importer.MapImported(D, ToCategory);
5216 return std::move(Err);
5224 return ToImplOrErr.takeError();
5236 return Error::success();
5249 FromProto != FromProtoEnd;
5250 ++FromProto, ++FromProtoLoc) {
5252 Protocols.push_back(*ToProtoOrErr);
5254 return ToProtoOrErr.takeError();
5256 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5257 ProtocolLocs.push_back(*ToProtoLocOrErr);
5259 return ToProtoLocOrErr.takeError();
5265 ProtocolLocs.data(), Importer.getToContext());
5272 return Error::success();
5282 return Importer.MapImported(D, *ImportedDefOrErr);
5284 return ImportedDefOrErr.takeError();
5293 return std::move(Err);
5298 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5299 for (
auto *FoundDecl : FoundDecls) {
5303 if ((MergeWithProtocol = dyn_cast<ObjCProtocolDecl>(FoundDecl)))
5310 if (!ToAtBeginLocOrErr)
5311 return ToAtBeginLocOrErr.takeError();
5313 if (GetImportedOrCreateDecl(ToProto, D, Importer.getToContext(), DC,
5322 Importer.MapImported(D, ToProto);
5326 return std::move(Err);
5334 return std::move(Err);
5337 if (!ExternLocOrErr)
5338 return ExternLocOrErr.takeError();
5342 return LangLocOrErr.takeError();
5347 if (GetImportedOrCreateDecl(ToLinkageSpec, D, Importer.getToContext(), DC,
5348 *ExternLocOrErr, *LangLocOrErr,
5350 return ToLinkageSpec;
5354 if (!RBraceLocOrErr)
5355 return RBraceLocOrErr.takeError();
5362 return ToLinkageSpec;
5373 return ToShadowOrErr.takeError();
5384 return std::move(Err);
5388 Error Err = Error::success();
5393 return std::move(Err);
5397 return std::move(Err);
5400 if (GetImportedOrCreateDecl(ToUsing, D, Importer.getToContext(), DC,
5401 ToUsingLoc, ToQualifierLoc, NameInfo,
5409 Importer.getFromContext().getInstantiatedFromUsingDecl(D)) {
5411 Importer.getToContext().setInstantiatedFromUsingDecl(
5412 ToUsing, *ToPatternOrErr);
5414 return ToPatternOrErr.takeError();
5426 return std::move(Err);
5430 Error Err = Error::success();
5436 return std::move(Err);
5439 if (GetImportedOrCreateDecl(ToUsingEnum, D, Importer.getToContext(), DC,
5440 ToUsingLoc, ToEnumLoc, ToNameLoc, ToEnumType))
5447 Importer.getFromContext().getInstantiatedFromUsingEnumDecl(D)) {
5449 Importer.getToContext().setInstantiatedFromUsingEnumDecl(ToUsingEnum,
5452 return ToPatternOrErr.takeError();
5464 return std::move(Err);
5469 if (!ToIntroducerOrErr)
5470 return ToIntroducerOrErr.takeError();
5474 return ToTargetOrErr.takeError();
5477 if (
auto *FromConstructorUsingShadow =
5478 dyn_cast<ConstructorUsingShadowDecl>(D)) {
5479 Error Err = Error::success();
5481 Err, FromConstructorUsingShadow->getNominatedBaseClassShadowDecl());
5483 return std::move(Err);
5489 if (GetImportedOrCreateDecl<ConstructorUsingShadowDecl>(
5490 ToShadow, D, Importer.getToContext(), DC, Loc,
5492 Nominated ? Nominated : *ToTargetOrErr,
5493 FromConstructorUsingShadow->constructsVirtualBase()))
5496 if (GetImportedOrCreateDecl(ToShadow, D, Importer.getToContext(), DC, Loc,
5497 Name, *ToIntroducerOrErr, *ToTargetOrErr))
5505 Importer.getFromContext().getInstantiatedFromUsingShadowDecl(D)) {
5507 Importer.getToContext().setInstantiatedFromUsingShadowDecl(
5508 ToShadow, *ToPatternOrErr);
5512 return ToPatternOrErr.takeError();
5526 return std::move(Err);
5531 if (!ToComAncestorOrErr)
5532 return ToComAncestorOrErr.takeError();
5534 Error Err = Error::success();
5537 auto ToNamespaceKeyLocation =
5542 return std::move(Err);
5545 if (GetImportedOrCreateDecl(ToUsingDir, D, Importer.getToContext(), DC,
5547 ToNamespaceKeyLocation,
5550 ToNominatedNamespace, *ToComAncestorOrErr))
5565 return std::move(Err);
5569 auto ToInstantiatedFromUsingOrErr =
5571 if (!ToInstantiatedFromUsingOrErr)
5572 return ToInstantiatedFromUsingOrErr.takeError();
5575 return std::move(Err);
5578 if (GetImportedOrCreateDecl(ToUsingPack, D, Importer.getToContext(), DC,
5583 addDeclToContexts(D, ToUsingPack);
5595 return std::move(Err);
5599 Error Err = Error::success();
5605 return std::move(Err);
5609 return std::move(Err);
5612 if (GetImportedOrCreateDecl(ToUsingValue, D, Importer.getToContext(), DC,
5613 ToUsingLoc, ToQualifierLoc, NameInfo,
5615 return ToUsingValue;
5621 return ToUsingValue;
5631 return std::move(Err);
5635 Error Err = Error::success();
5641 return std::move(Err);
5644 if (GetImportedOrCreateDecl(ToUsing, D, Importer.getToContext(), DC,
5645 ToUsingLoc, ToTypenameLoc,
5646 ToQualifierLoc, Loc, Name, ToEllipsisLoc))
5657 Decl* ToD =
nullptr;
5659#define BuiltinTemplate(BTName) \
5660 case BuiltinTemplateKind::BTK##BTName: \
5661 ToD = Importer.getToContext().get##BTName##Decl(); \
5663#include "clang/Basic/BuiltinTemplates.inc"
5665 assert(ToD &&
"BuiltinTemplateDecl of unsupported kind!");
5666 Importer.MapImported(D, ToD);
5676 if (
auto FromSuperOrErr =
import(FromSuper))
5677 FromSuper = *FromSuperOrErr;
5679 return FromSuperOrErr.takeError();
5683 if ((
bool)FromSuper != (
bool)ToSuper ||
5686 diag::warn_odr_objc_superclass_inconsistent)
5693 diag::note_odr_objc_missing_superclass);
5696 diag::note_odr_objc_superclass)
5700 diag::note_odr_objc_missing_superclass);
5706 return Error::success();
5717 return SuperTInfoOrErr.takeError();
5728 FromProto != FromProtoEnd;
5729 ++FromProto, ++FromProtoLoc) {
5731 Protocols.push_back(*ToProtoOrErr);
5733 return ToProtoOrErr.takeError();
5735 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5736 ProtocolLocs.push_back(*ToProtoLocOrErr);
5738 return ToProtoLocOrErr.takeError();
5744 ProtocolLocs.data(), Importer.getToContext());
5749 auto ToCatOrErr =
import(Cat);
5751 return ToCatOrErr.takeError();
5760 return ToImplOrErr.takeError();
5767 return Error::success();
5776 for (
auto *fromTypeParam : *list) {
5777 if (
auto toTypeParamOrErr =
import(fromTypeParam))
5778 toTypeParams.push_back(*toTypeParamOrErr);
5780 return toTypeParamOrErr.takeError();
5784 if (!LAngleLocOrErr)
5785 return LAngleLocOrErr.takeError();
5788 if (!RAngleLocOrErr)
5789 return RAngleLocOrErr.takeError();
5804 return Importer.MapImported(D, *ImportedDefOrErr);
5806 return ImportedDefOrErr.takeError();
5815 return std::move(Err);
5821 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5822 for (
auto *FoundDecl : FoundDecls) {
5826 if ((MergeWithIface = dyn_cast<ObjCInterfaceDecl>(FoundDecl)))
5834 if (!AtBeginLocOrErr)
5835 return AtBeginLocOrErr.takeError();
5837 if (GetImportedOrCreateDecl(
5838 ToIface, D, Importer.getToContext(), DC,
5846 Importer.MapImported(D, ToIface);
5849 if (
auto ToPListOrErr =
5853 return ToPListOrErr.takeError();
5857 return std::move(Err);
5866 return std::move(Err);
5872 return std::move(Err);
5874 Error Err = Error::success();
5879 return std::move(Err);
5881 if (GetImportedOrCreateDecl(
5882 ToImpl, D, Importer.getToContext(), DC,
5883 Importer.Import(D->
getIdentifier()), Category->getClassInterface(),
5884 ToLocation, ToAtStartLoc, ToCategoryNameLoc))
5889 Category->setImplementation(ToImpl);
5892 Importer.MapImported(D, ToImpl);
5894 return std::move(Err);
5904 return std::move(Err);
5909 return std::move(Err);
5917 return std::move(Err);
5919 Error Err = Error::success();
5926 return std::move(Err);
5928 if (GetImportedOrCreateDecl(Impl, D, Importer.getToContext(),
5937 Impl->setLexicalDeclContext(LexicalDC);
5951 Importer.ToDiag(Impl->getLocation(),
5952 diag::warn_odr_objc_superclass_inconsistent)
5956 if (Impl->getSuperClass())
5957 Importer.ToDiag(Impl->getLocation(),
5958 diag::note_odr_objc_superclass)
5959 << Impl->getSuperClass()->getDeclName();
5961 Importer.ToDiag(Impl->getLocation(),
5962 diag::note_odr_objc_missing_superclass);
5965 diag::note_odr_objc_superclass)
5969 diag::note_odr_objc_missing_superclass);
5977 return std::move(Err);
5989 return std::move(Err);
5994 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5995 for (
auto *FoundDecl : FoundDecls) {
5996 if (
auto *FoundProp = dyn_cast<ObjCPropertyDecl>(FoundDecl)) {
6003 if (!Importer.IsStructurallyEquivalent(D->
getType(),
6004 FoundProp->getType())) {
6005 Importer.ToDiag(Loc, diag::warn_odr_objc_property_type_inconsistent)
6006 << Name << D->
getType() << FoundProp->getType();
6007 Importer.ToDiag(FoundProp->getLocation(), diag::note_odr_value_here)
6008 << FoundProp->getType();
6016 Importer.MapImported(D, FoundProp);
6021 Error Err = Error::success();
6027 return std::move(Err);
6031 if (GetImportedOrCreateDecl(
6032 ToProperty, D, Importer.getToContext(), DC, Loc,
6034 ToLParenLoc, ToType,
6046 return std::move(Err);
6066 return std::move(Err);
6070 return std::move(Err);
6077 return std::move(Err);
6080 = InImpl->FindPropertyImplDecl(
Property->getIdentifier(),
6084 Error Err = Error::success();
6087 auto ToPropertyIvarDeclLoc =
6090 return std::move(Err);
6092 if (GetImportedOrCreateDecl(ToImpl, D, Importer.getToContext(), DC,
6096 ToPropertyIvarDeclLoc))
6106 diag::warn_odr_objc_property_impl_kind_inconsistent)
6111 diag::note_odr_objc_property_impl_kind)
6122 diag::warn_odr_objc_synthesize_ivar_inconsistent)
6127 diag::note_odr_objc_synthesize_ivar_here)
6134 Importer.MapImported(D, ToImpl);
6148 return BeginLocOrErr.takeError();
6152 return LocationOrErr.takeError();
6155 if (GetImportedOrCreateDecl(
6156 ToD, D, Importer.getToContext(),
6158 *BeginLocOrErr, *LocationOrErr,
6167 Error Err = Error::success();
6168 auto ToConceptRef =
importChecked(Err, TC->getConceptReference());
6169 auto ToIDC =
importChecked(Err, TC->getImmediatelyDeclaredConstraint());
6171 return std::move(Err);
6176 if (
Error Err = importTemplateParameterDefaultArgument(D, ToD))
6185 Error Err = Error::success();
6192 return std::move(Err);
6195 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(),
6197 ToInnerLocStart, ToLocation, D->
getDepth(),
6199 ToDeclName.getAsIdentifierInfo(), ToType,
6203 Err = importTemplateParameterDefaultArgument(D, ToD);
6212 bool IsCanonical =
false;
6213 if (
auto *CanonD = Importer.getFromContext()
6214 .findCanonicalTemplateTemplateParmDeclInternal(D);
6221 return NameOrErr.takeError();
6226 return LocationOrErr.takeError();
6230 if (!TemplateParamsOrErr)
6231 return TemplateParamsOrErr.takeError();
6234 if (GetImportedOrCreateDecl(
6235 ToD, D, Importer.getToContext(),
6242 if (
Error Err = importTemplateParameterDefaultArgument(D, ToD))
6246 return Importer.getToContext()
6247 .insertCanonicalTemplateTemplateParmDeclInternal(ToD);
6255 assert(D->getTemplatedDecl() &&
"Should be called on templates only");
6256 auto *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();
6257 if (!ToTemplatedDef)
6259 auto *TemplateWithDef = ToTemplatedDef->getDescribedTemplate();
6260 return cast_or_null<T>(TemplateWithDef);
6271 return std::move(Err);
6283 TD->getLexicalDeclContext()->isDependentContext();
6285 bool DependentFriend = IsDependentFriend(D);
6292 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6293 for (
auto *FoundDecl : FoundDecls) {
6298 auto *FoundTemplate = dyn_cast<ClassTemplateDecl>(FoundDecl);
6299 if (FoundTemplate) {
6304 bool IgnoreTemplateParmDepth =
6308 IgnoreTemplateParmDepth)) {
6309 if (DependentFriend || IsDependentFriend(FoundTemplate))
6315 return Importer.MapImported(D, TemplateWithDef);
6317 FoundByLookup = FoundTemplate;
6335 ConflictingDecls.push_back(FoundDecl);
6339 if (!ConflictingDecls.empty()) {
6342 ConflictingDecls.size());
6344 Name = NameOrErr.get();
6346 return NameOrErr.takeError();
6353 if (!TemplateParamsOrErr)
6354 return TemplateParamsOrErr.takeError();
6359 return std::move(Err);
6363 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), DC, Loc, Name,
6364 *TemplateParamsOrErr, ToTemplated))
6372 addDeclToContexts(D, D2);
6373 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6375 if (FoundByLookup) {
6389 "Found decl must have its templated decl set");
6392 if (ToTemplated != PrevTemplated)
6406 return std::move(Err);
6411 return std::move(Err);
6417 return std::move(Err);
6420 void *InsertPos =
nullptr;
6423 dyn_cast<ClassTemplatePartialSpecializationDecl>(D);
6431 return ToTPListOrErr.takeError();
6432 ToTPList = *ToTPListOrErr;
6443 Importer.MapImported(D, PrevDefinition);
6446 for (
auto *FromField : D->
fields()) {
6447 auto ToOrErr =
import(FromField);
6449 return ToOrErr.takeError();
6455 auto ToOrErr =
import(FromM);
6457 return ToOrErr.takeError();
6465 return PrevDefinition;
6476 return BeginLocOrErr.takeError();
6479 return IdLocOrErr.takeError();
6485 return std::move(Err);
6491 if (GetImportedOrCreateDecl<ClassTemplatePartialSpecializationDecl>(
6492 D2, D, Importer.getToContext(), D->
getTagKind(), DC, *BeginLocOrErr,
6493 *IdLocOrErr, ToTPList, ClassTemplate,
ArrayRef(TemplateArgs),
6495 cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl)))
6507 PartSpec2->setInstantiatedFromMember(*ToInstOrErr);
6509 return ToInstOrErr.takeError();
6511 updateLookupTableForTemplateParameters(*ToTPList);
6513 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), D->
getTagKind(),
6514 DC, *BeginLocOrErr, *IdLocOrErr, ClassTemplate,
6539 return BraceRangeOrErr.takeError();
6542 return std::move(Err);
6548 return LocOrErr.takeError();
6556 return LocOrErr.takeError();
6561 return LocOrErr.takeError();
6567 return POIOrErr.takeError();
6573 if (
auto *CTD = dyn_cast<ClassTemplateDecl *>(
P)) {
6574 if (
auto CTDorErr =
import(CTD))
6578 auto CTPSDOrErr =
import(CTPSD);
6580 return CTPSDOrErr.takeError();
6583 for (
unsigned I = 0; I < DArgs.
size(); ++I) {
6585 if (
auto ArgOrErr =
import(DArg))
6586 D2ArgsVec[I] = *ArgOrErr;
6588 return ArgOrErr.takeError();
6598 return std::move(Err);
6610 return std::move(Err);
6616 "Variable templates cannot be declared at function scope");
6619 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6621 for (
auto *FoundDecl : FoundDecls) {
6625 if (
VarTemplateDecl *FoundTemplate = dyn_cast<VarTemplateDecl>(FoundDecl)) {
6635 assert(FoundTemplate->getDeclContext()->isRecord() &&
6636 "Member variable template imported as non-member, "
6637 "inconsistent imported AST?");
6639 return Importer.MapImported(D, FoundDef);
6641 return Importer.MapImported(D, FoundTemplate);
6644 return Importer.MapImported(D, FoundDef);
6646 FoundByLookup = FoundTemplate;
6649 ConflictingDecls.push_back(FoundDecl);
6653 if (!ConflictingDecls.empty()) {
6656 ConflictingDecls.size());
6658 Name = NameOrErr.get();
6660 return NameOrErr.takeError();
6669 return TypeOrErr.takeError();
6674 return std::move(Err);
6678 if (!TemplateParamsOrErr)
6679 return TemplateParamsOrErr.takeError();
6682 if (GetImportedOrCreateDecl(ToVarTD, D, Importer.getToContext(), DC, Loc,
6683 Name, *TemplateParamsOrErr, ToTemplated))
6691 if (DC != Importer.getToContext().getTranslationUnitDecl())
6692 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6694 if (FoundByLookup) {
6698 auto *PrevTemplated =
6700 if (ToTemplated != PrevTemplated)
6715 auto RedeclIt = Redecls.begin();
6718 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
6721 return RedeclOrErr.takeError();
6723 assert(*RedeclIt == D);
6727 return std::move(Err);
6732 return std::move(Err);
6737 return BeginLocOrErr.takeError();
6741 return IdLocOrErr.takeError();
6747 return std::move(Err);
6750 void *InsertPos =
nullptr;
6752 VarTemplate->findSpecialization(TemplateArgs, InsertPos);
6753 if (FoundSpecialization) {
6761 "Member variable template specialization imported as non-member, "
6762 "inconsistent imported AST?");
6764 return Importer.MapImported(D, FoundDef);
6766 return Importer.MapImported(D, FoundSpecialization);
6771 return Importer.MapImported(D, FoundDef);
6783 return std::move(Err);
6788 if (
auto *FromPartial = dyn_cast<PartVarSpecDecl>(D)) {
6789 auto ToTPListOrErr =
import(FromPartial->getTemplateParameters());
6791 return ToTPListOrErr.takeError();
6793 PartVarSpecDecl *ToPartial;
6794 if (GetImportedOrCreateDecl(ToPartial, D, Importer.getToContext(), DC,
6795 *BeginLocOrErr, *IdLocOrErr, *ToTPListOrErr,
6801 import(FromPartial->getInstantiatedFromMember()))
6802 ToPartial->setInstantiatedFromMember(*ToInstOrErr);
6804 return ToInstOrErr.takeError();
6806 if (FromPartial->isMemberSpecialization())
6807 ToPartial->setMemberSpecialization();
6815 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), DC,
6824 if (!
VarTemplate->findSpecialization(TemplateArgs, InsertPos))
6829 return std::move(Err);
6834 return TInfoOrErr.takeError();
6841 return POIOrErr.takeError();
6852 return LocOrErr.takeError();
6860 return std::move(Err);
6862 if (FoundSpecialization)
6865 addDeclToContexts(D, D2);
6868 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
6871 return RedeclOrErr.takeError();
6885 return std::move(Err);
6897 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6898 for (
auto *FoundDecl : FoundDecls) {
6899 if (!FoundDecl->isInIdentifierNamespace(IDNS))
6902 if (
auto *FoundTemplate = dyn_cast<FunctionTemplateDecl>(FoundDecl)) {
6909 return Importer.MapImported(D, TemplateWithDef);
6911 FoundByLookup = FoundTemplate;
6921 return ParamsOrErr.takeError();
6926 return std::move(Err);
6943 OldParamDC.reserve(Params->
size());
6944 llvm::transform(*Params, std::back_inserter(OldParamDC),
6948 if (GetImportedOrCreateDecl(ToFunc, D, Importer.getToContext(), DC, Loc, Name,
6949 Params, TemplatedFD))
6963 ToFunc->setLexicalDeclContext(LexicalDC);
6964 addDeclToContexts(D, ToFunc);
6967 if (LT && !OldParamDC.empty()) {
6968 for (
unsigned int I = 0; I < OldParamDC.size(); ++I)
6969 LT->updateForced(Params->
getParam(I), OldParamDC[I]);
6972 if (FoundByLookup) {
6977 "Found decl must have its templated decl set");
6978 auto *PrevTemplated =
6980 if (TemplatedFD != PrevTemplated)
6997 return std::move(Err);
7000 if (GetImportedOrCreateDecl(To, D, Importer.getToContext(), DC, LocationOrErr,
7001 NameDeclOrErr, ToTemplateParameters,
7015 return std::move(Err);
7018 if (GetImportedOrCreateDecl(To, D, Importer.getToContext(), DC, RequiresLoc))
7031 return std::move(Err);
7035 return std::move(Err);
7038 if (GetImportedOrCreateDecl(To, D, Importer.getToContext(), DC, ToSL, ToArgs))
7050 Importer.FromDiag(S->
getBeginLoc(), diag::err_unsupported_ast_node)
7057 if (Importer.returnWithErrorInTest())
7064 Names.push_back(ToII);
7067 for (
unsigned I = 0, E = S->
getNumInputs(); I != E; I++) {
7071 Names.push_back(ToII);
7077 Clobbers.push_back(*ClobberOrErr);
7079 return ClobberOrErr.takeError();
7086 Constraints.push_back(*OutputOrErr);
7088 return OutputOrErr.takeError();
7091 for (
unsigned I = 0, E = S->
getNumInputs(); I != E; I++) {
7093 Constraints.push_back(*InputOrErr);
7095 return InputOrErr.takeError();
7101 return std::move(Err);
7105 return std::move(Err);
7109 return std::move(Err);
7113 return AsmLocOrErr.takeError();
7116 return AsmStrOrErr.takeError();
7118 if (!RParenLocOrErr)
7119 return RParenLocOrErr.takeError();
7121 return new (Importer.getToContext())
GCCAsmStmt(
7122 Importer.getToContext(),
7140 Error Err = Error::success();
7145 return std::move(Err);
7146 return new (Importer.getToContext())
DeclStmt(ToDG, ToBeginLoc, ToEndLoc);
7151 if (!ToSemiLocOrErr)
7152 return ToSemiLocOrErr.takeError();
7153 return new (Importer.getToContext())
NullStmt(
7161 return std::move(Err);
7164 if (!ToLBracLocOrErr)
7165 return ToLBracLocOrErr.takeError();
7168 if (!ToRBracLocOrErr)
7169 return ToRBracLocOrErr.takeError();
7174 *ToLBracLocOrErr, *ToRBracLocOrErr);
7179 Error Err = Error::success();
7187 return std::move(Err);
7190 ToCaseLoc, ToEllipsisLoc, ToColonLoc);
7191 ToStmt->setSubStmt(ToSubStmt);
7198 Error Err = Error::success();
7203 return std::move(Err);
7206 ToDefaultLoc, ToColonLoc, ToSubStmt);
7211 Error Err = Error::success();
7216 return std::move(Err);
7218 return new (Importer.getToContext())
LabelStmt(
7219 ToIdentLoc, ToLabelDecl, ToSubStmt);
7224 if (!ToAttrLocOrErr)
7225 return ToAttrLocOrErr.takeError();
7229 return std::move(Err);
7231 if (!ToSubStmtOrErr)
7232 return ToSubStmtOrErr.takeError();
7235 Importer.getToContext(), *ToAttrLocOrErr, ToAttrs, *ToSubStmtOrErr);
7240 Error Err = Error::success();
7251 return std::move(Err);
7254 ToInit, ToConditionVariable, ToCond, ToLParenLoc,
7255 ToRParenLoc, ToThen, ToElseLoc, ToElse);
7260 Error Err = Error::success();
7269 return std::move(Err);
7273 ToCond, ToLParenLoc, ToRParenLoc);
7274 ToStmt->setBody(ToBody);
7275 ToStmt->setSwitchLoc(ToSwitchLoc);
7283 return ToSCOrErr.takeError();
7284 if (LastChainedSwitchCase)
7287 ToStmt->setSwitchCaseList(*ToSCOrErr);
7288 LastChainedSwitchCase = *ToSCOrErr;
7296 Error Err = Error::success();
7304 return std::move(Err);
7307 ToBody, ToWhileLoc, ToLParenLoc, ToRParenLoc);
7312 Error Err = Error::success();
7319 return std::move(Err);
7321 return new (Importer.getToContext())
DoStmt(
7322 ToBody, ToCond, ToDoLoc, ToWhileLoc, ToRParenLoc);
7327 Error Err = Error::success();
7337 return std::move(Err);
7339 return new (Importer.getToContext())
ForStmt(
7340 Importer.getToContext(),
7341 ToInit, ToCond, ToConditionVariable, ToInc, ToBody, ToForLoc, ToLParenLoc,
7347 Error Err = Error::success();
7352 return std::move(Err);
7354 return new (Importer.getToContext())
GotoStmt(
7355 ToLabel, ToGotoLoc, ToLabelLoc);
7360 Error Err = Error::success();
7365 return std::move(Err);
7368 ToGotoLoc, ToStarLoc, ToTarget);
7371template <
typename StmtClass>
7374 Error Err = Error::success();
7375 auto ToLoc = NodeImporter.
importChecked(Err, S->getKwLoc());
7376 auto ToLabelLoc = S->hasLabelTarget()
7379 auto ToDecl = S->hasLabelTarget()
7383 return std::move(Err);
7384 return new (Importer.
getToContext()) StmtClass(ToLoc, ToLabelLoc, ToDecl);
7397 Error Err = Error::success();
7402 return std::move(Err);
7410 Error Err = Error::success();
7415 return std::move(Err);
7418 ToCatchLoc, ToExceptionDecl, ToHandlerBlock);
7424 return ToTryLocOrErr.takeError();
7427 if (!ToTryBlockOrErr)
7428 return ToTryBlockOrErr.takeError();
7431 for (
unsigned HI = 0, HE = S->
getNumHandlers(); HI != HE; ++HI) {
7433 if (
auto ToHandlerOrErr =
import(FromHandler))
7434 ToHandlers[HI] = *ToHandlerOrErr;
7436 return ToHandlerOrErr.takeError();
7445 Error Err = Error::success();
7459 return std::move(Err);
7462 ToInit, ToRangeStmt, ToBeginStmt, ToEndStmt, ToCond, ToInc, ToLoopVarStmt,
7463 ToBody, ToForLoc, ToCoawaitLoc, ToColonLoc, ToRParenLoc);
7468 Error Err = Error::success();
7475 return std::move(Err);
7486 Error Err = Error::success();
7492 return std::move(Err);
7495 ToAtCatchLoc, ToRParenLoc, ToCatchParamDecl, ToCatchBody);
7500 if (!ToAtFinallyLocOrErr)
7501 return ToAtFinallyLocOrErr.takeError();
7503 if (!ToAtFinallyStmtOrErr)
7504 return ToAtFinallyStmtOrErr.takeError();
7506 *ToAtFinallyStmtOrErr);
7511 Error Err = Error::success();
7516 return std::move(Err);
7521 if (
ExpectedStmt ToCatchStmtOrErr =
import(FromCatchStmt))
7522 ToCatchStmts[CI] = *ToCatchStmtOrErr;
7524 return ToCatchStmtOrErr.takeError();
7528 ToAtTryLoc, ToTryBody,
7529 ToCatchStmts.begin(), ToCatchStmts.size(),
7536 Error Err = Error::success();
7541 return std::move(Err);
7544 ToAtSynchronizedLoc, ToSynchExpr, ToSynchBody);
7549 if (!ToThrowLocOrErr)
7550 return ToThrowLocOrErr.takeError();
7552 if (!ToThrowExprOrErr)
7553 return ToThrowExprOrErr.takeError();
7555 *ToThrowLocOrErr, *ToThrowExprOrErr);
7562 return ToAtLocOrErr.takeError();
7564 if (!ToSubStmtOrErr)
7565 return ToSubStmtOrErr.takeError();
7574 Importer.FromDiag(E->
getBeginLoc(), diag::err_unsupported_ast_node)
7580 Error Err = Error::success();
7585 return std::move(Err);
7587 if (!ParentContextOrErr)
7588 return ParentContextOrErr.takeError();
7590 return new (Importer.getToContext())
7592 RParenLoc, *ParentContextOrErr);
7597 Error Err = Error::success();
7604 return std::move(Err);
7606 return new (Importer.getToContext())
VAArgExpr(
7607 ToBuiltinLoc, ToSubExpr, ToWrittenTypeInfo, ToRParenLoc, ToType,
7613 Error Err = Error::success();
7621 return std::move(Err);
7630 return new (Importer.getToContext())
7631 ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType,
VK, OK,
7632 ToRParenLoc, CondIsTrue);
7636 Error Err = Error::success();
7643 return std::move(Err);
7646 Importer.getToContext(), ToSrcExpr, ToTSI, ToType, E->
getValueKind(),
7652 Error Err = Error::success();
7660 ToSubExprs.resize(NumSubExprs);
7663 return std::move(Err);
7666 Importer.getToContext(), ToSubExprs, ToType, ToBeginLoc, ToRParenLoc);
7672 return TypeOrErr.takeError();
7676 return BeginLocOrErr.takeError();
7678 return new (Importer.getToContext())
GNUNullExpr(*TypeOrErr, *BeginLocOrErr);
7683 Error Err = Error::success();
7685 Expr *ToControllingExpr =
nullptr;
7691 assert((ToControllingExpr || ToControllingType) &&
7692 "Either the controlling expr or type must be nonnull");
7696 return std::move(Err);
7701 return std::move(Err);
7706 return std::move(Err);
7708 const ASTContext &ToCtx = Importer.getToContext();
7710 if (ToControllingExpr) {
7712 ToCtx, ToGenericLoc, ToControllingExpr,
ArrayRef(ToAssocTypes),
7713 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7717 ToCtx, ToGenericLoc, ToControllingType,
ArrayRef(ToAssocTypes),
7718 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7722 if (ToControllingExpr) {
7724 ToCtx, ToGenericLoc, ToControllingExpr,
ArrayRef(ToAssocTypes),
7725 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7729 ToCtx, ToGenericLoc, ToControllingType,
ArrayRef(ToAssocTypes),
7730 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7736 Error Err = Error::success();
7741 return std::move(Err);
7750 Error Err = Error::success();
7757 return std::move(Err);
7763 return FoundDOrErr.takeError();
7764 ToFoundD = *FoundDOrErr;
7773 return std::move(Err);
7774 ToResInfo = &ToTAInfo;
7778 Importer.getToContext(), ToQualifierLoc, ToTemplateKeywordLoc, ToDecl,
7782 ToE->setHadMultipleCandidates(
true);
7790 return TypeOrErr.takeError();
7798 return ToInitOrErr.takeError();
7801 if (!ToEqualOrColonLocOrErr)
7802 return ToEqualOrColonLocOrErr.takeError();
7808 ToIndexExprs[I - 1] = *ToArgOrErr;
7810 return ToArgOrErr.takeError();
7815 return std::move(Err);
7818 Importer.getToContext(), ToDesignators,
7819 ToIndexExprs, *ToEqualOrColonLocOrErr,
7827 return ToTypeOrErr.takeError();
7830 if (!ToLocationOrErr)
7831 return ToLocationOrErr.takeError();
7834 *ToTypeOrErr, *ToLocationOrErr);
7840 return ToTypeOrErr.takeError();
7843 if (!ToLocationOrErr)
7844 return ToLocationOrErr.takeError();
7847 Importer.getToContext(), E->
getValue(), *ToTypeOrErr, *ToLocationOrErr);
7854 return ToTypeOrErr.takeError();
7857 if (!ToLocationOrErr)
7858 return ToLocationOrErr.takeError();
7862 *ToTypeOrErr, *ToLocationOrErr);
7866 auto ToTypeOrErr =
import(E->
getType());
7868 return ToTypeOrErr.takeError();
7871 if (!ToSubExprOrErr)
7872 return ToSubExprOrErr.takeError();
7875 *ToSubExprOrErr, *ToTypeOrErr);
7879 auto ToTypeOrErr =
import(E->
getType());
7881 return ToTypeOrErr.takeError();
7884 if (!ToLocationOrErr)
7885 return ToLocationOrErr.takeError();
7888 Importer.getToContext(), E->
getValue(), *ToTypeOrErr, *ToLocationOrErr,
7889 Importer.getToContext().getFixedPointScale(*ToTypeOrErr));
7895 return ToTypeOrErr.takeError();
7898 if (!ToLocationOrErr)
7899 return ToLocationOrErr.takeError();
7908 return ToTypeOrErr.takeError();
7913 return std::move(Err);
7922 Error Err = Error::success();
7928 return std::move(Err);
7931 ToLParenLoc, ToTypeSourceInfo, ToType, E->
getValueKind(),
7937 Error Err = Error::success();
7942 return std::move(Err);
7948 return std::move(Err);
7950 return new (Importer.getToContext())
AtomicExpr(
7952 ToBuiltinLoc, ToExprs, ToType, E->
getOp(), ToRParenLoc);
7956 Error Err = Error::success();
7962 return std::move(Err);
7965 ToAmpAmpLoc, ToLabelLoc, ToLabel, ToType);
7968 Error Err = Error::success();
7972 return std::move(Err);
7977 Error Err = Error::success();
7982 return std::move(Err);
7984 return new (Importer.getToContext())
7985 ParenExpr(ToLParen, ToRParen, ToSubExpr);
7991 return std::move(Err);
7994 if (!ToLParenLocOrErr)
7995 return ToLParenLocOrErr.takeError();
7998 if (!ToRParenLocOrErr)
7999 return ToRParenLocOrErr.takeError();
8002 ToExprs, *ToRParenLocOrErr);
8006 Error Err = Error::success();
8012 return std::move(Err);
8014 return new (Importer.getToContext())
8015 StmtExpr(ToSubStmt, ToType, ToLParenLoc, ToRParenLoc,
8020 Error Err = Error::success();
8025 return std::move(Err);
8029 UO->setType(ToType);
8030 UO->setSubExpr(ToSubExpr);
8032 UO->setOperatorLoc(ToOperatorLoc);
8043 Error Err = Error::success();
8048 return std::move(Err);
8053 if (!ToArgumentTypeInfoOrErr)
8054 return ToArgumentTypeInfoOrErr.takeError();
8057 E->
getKind(), *ToArgumentTypeInfoOrErr, ToType, ToOperatorLoc,
8062 if (!ToArgumentExprOrErr)
8063 return ToArgumentExprOrErr.takeError();
8066 E->
getKind(), *ToArgumentExprOrErr, ToType, ToOperatorLoc, ToRParenLoc);
8070 Error Err = Error::success();
8076 return std::move(Err);
8079 Importer.getToContext(), ToLHS, ToRHS, E->
getOpcode(), ToType,
8085 Error Err = Error::success();
8093 return std::move(Err);
8096 ToCond, ToQuestionLoc, ToLHS, ToColonLoc, ToRHS, ToType,
8102 Error Err = Error::success();
8112 return std::move(Err);
8115 ToCommon, ToOpaqueValue, ToCond, ToTrueExpr, ToFalseExpr,
8122 Error Err = Error::success();
8125 return std::move(Err);
8127 return new (Importer.getToContext())
8132 Error Err = Error::success();
8134 auto ToQueriedTypeSourceInfo =
8140 return std::move(Err);
8144 ToDimensionExpression, ToEndLoc, ToType);
8148 Error Err = Error::success();
8154 return std::move(Err);
8162 Error Err = Error::success();
8167 return std::move(Err);
8174 Error Err = Error::success();
8180 return std::move(Err);
8189 Error Err = Error::success();
8194 auto ToComputationResultType =
8198 return std::move(Err);
8201 Importer.getToContext(), ToLHS, ToRHS, E->
getOpcode(), ToType,
8204 ToComputationLHSType, ToComputationResultType);
8211 if (
auto SpecOrErr =
import(*I))
8212 Path.push_back(*SpecOrErr);
8214 return SpecOrErr.takeError();
8222 return ToTypeOrErr.takeError();
8225 if (!ToSubExprOrErr)
8226 return ToSubExprOrErr.takeError();
8229 if (!ToBasePathOrErr)
8230 return ToBasePathOrErr.takeError();
8233 Importer.getToContext(), *ToTypeOrErr, E->
getCastKind(), *ToSubExprOrErr,
8238 Error Err = Error::success();
8243 return std::move(Err);
8246 if (!ToBasePathOrErr)
8247 return ToBasePathOrErr.takeError();
8251 case Stmt::CStyleCastExprClass: {
8253 ExpectedSLoc ToLParenLocOrErr =
import(CCE->getLParenLoc());
8254 if (!ToLParenLocOrErr)
8255 return ToLParenLocOrErr.takeError();
8256 ExpectedSLoc ToRParenLocOrErr =
import(CCE->getRParenLoc());
8257 if (!ToRParenLocOrErr)
8258 return ToRParenLocOrErr.takeError();
8261 ToSubExpr, ToBasePath, CCE->getFPFeatures(), ToTypeInfoAsWritten,
8262 *ToLParenLocOrErr, *ToRParenLocOrErr);
8265 case Stmt::CXXFunctionalCastExprClass: {
8267 ExpectedSLoc ToLParenLocOrErr =
import(FCE->getLParenLoc());
8268 if (!ToLParenLocOrErr)
8269 return ToLParenLocOrErr.takeError();
8270 ExpectedSLoc ToRParenLocOrErr =
import(FCE->getRParenLoc());
8271 if (!ToRParenLocOrErr)
8272 return ToRParenLocOrErr.takeError();
8274 Importer.getToContext(), ToType, E->
getValueKind(), ToTypeInfoAsWritten,
8275 E->
getCastKind(), ToSubExpr, ToBasePath, FCE->getFPFeatures(),
8276 *ToLParenLocOrErr, *ToRParenLocOrErr);
8279 case Stmt::ObjCBridgedCastExprClass: {
8281 ExpectedSLoc ToLParenLocOrErr =
import(OCE->getLParenLoc());
8282 if (!ToLParenLocOrErr)
8283 return ToLParenLocOrErr.takeError();
8284 ExpectedSLoc ToBridgeKeywordLocOrErr =
import(OCE->getBridgeKeywordLoc());
8285 if (!ToBridgeKeywordLocOrErr)
8286 return ToBridgeKeywordLocOrErr.takeError();
8288 *ToLParenLocOrErr, OCE->getBridgeKind(), E->
getCastKind(),
8289 *ToBridgeKeywordLocOrErr, ToTypeInfoAsWritten, ToSubExpr);
8291 case Stmt::BuiltinBitCastExprClass: {
8293 ExpectedSLoc ToKWLocOrErr =
import(BBC->getBeginLoc());
8295 return ToKWLocOrErr.takeError();
8296 ExpectedSLoc ToRParenLocOrErr =
import(BBC->getEndLoc());
8297 if (!ToRParenLocOrErr)
8298 return ToRParenLocOrErr.takeError();
8301 ToTypeInfoAsWritten, *ToKWLocOrErr, *ToRParenLocOrErr);
8304 llvm_unreachable(
"Cast expression of unsupported type!");
8317 Error Err = Error::success();
8321 return std::move(Err);
8330 auto ToBSOrErr =
import(FromNode.
getBase());
8332 return ToBSOrErr.takeError();
8337 auto ToFieldOrErr =
import(FromNode.
getField());
8339 return ToFieldOrErr.takeError();
8340 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, *ToFieldOrErr, ToEndLoc));
8345 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, ToII, ToEndLoc));
8354 if (!ToIndexExprOrErr)
8355 return ToIndexExprOrErr.takeError();
8356 ToExprs[I] = *ToIndexExprOrErr;
8359 Error Err = Error::success();
8365 return std::move(Err);
8368 Importer.getToContext(), ToType, ToOperatorLoc, ToTypeSourceInfo, ToNodes,
8369 ToExprs, ToRParenLoc);
8373 Error Err = Error::success();
8379 return std::move(Err);
8388 ToType, ToOperand, ToCanThrow, ToBeginLoc, ToEndLoc);
8392 Error Err = Error::success();
8397 return std::move(Err);
8405 if (!ToUsedLocOrErr)
8406 return ToUsedLocOrErr.takeError();
8408 auto ToParamOrErr =
import(E->
getParam());
8410 return ToParamOrErr.takeError();
8412 auto UsedContextOrErr = Importer.ImportContext(E->
getUsedContext());
8413 if (!UsedContextOrErr)
8414 return UsedContextOrErr.takeError();
8424 std::optional<ParmVarDecl *> FromParam =
8425 Importer.getImportedFromDecl(ToParam);
8426 assert(FromParam &&
"ParmVarDecl was not imported?");
8429 return std::move(Err);
8431 Expr *RewrittenInit =
nullptr;
8435 return ExprOrErr.takeError();
8436 RewrittenInit = ExprOrErr.get();
8439 *ToParamOrErr, RewrittenInit,
8445 Error Err = Error::success();
8450 return std::move(Err);
8453 ToType, ToTypeSourceInfo, ToRParenLoc);
8459 if (!ToSubExprOrErr)
8460 return ToSubExprOrErr.takeError();
8462 auto ToDtorOrErr =
import(E->
getTemporary()->getDestructor());
8464 return ToDtorOrErr.takeError();
8474 Error Err = Error::success();
8480 return std::move(Err);
8484 return std::move(Err);
8487 Importer.getToContext(), ToConstructor, ToType, ToTypeSourceInfo, ToArgs,
8497 return std::move(Err);
8499 Error Err = Error::success();
8503 return std::move(Err);
8507 if (GetImportedOrCreateDecl(To, D, Temporary, ExtendingDecl,
8518 Error Err = Error::success();
8522 auto ToMaterializedDecl =
8525 return std::move(Err);
8527 if (!ToTemporaryExpr)
8528 ToTemporaryExpr =
cast<Expr>(ToMaterializedDecl->getTemporaryExpr());
8532 ToMaterializedDecl);
8538 Error Err = Error::success();
8542 return std::move(Err);
8544 return new (Importer.getToContext())
8549 Error Err = Error::success();
8555 return std::move(Err);
8564 ToPartialArguments))
8565 return std::move(Err);
8569 Importer.getToContext(), ToOperatorLoc, ToPack, ToPackLoc, ToRParenLoc,
8570 Length, ToPartialArguments);
8575 Error Err = Error::success();
8582 auto ToAllocatedTypeSourceInfo =
8587 return std::move(Err);
8592 return std::move(Err);
8595 Importer.getToContext(), E->
isGlobalNew(), ToOperatorNew,
8599 ToAllocatedTypeSourceInfo, ToSourceRange, ToDirectInitRange);
8603 Error Err = Error::success();
8609 return std::move(Err);
8618 Error Err = Error::success();
8624 return std::move(Err);
8628 return std::move(Err);
8631 Importer.getToContext(), ToType, ToLocation, ToConstructor,
8635 ToParenOrBraceRange);
8642 if (!ToSubExprOrErr)
8643 return ToSubExprOrErr.takeError();
8647 return std::move(Err);
8655 Error Err = Error::success();
8660 return std::move(Err);
8664 return std::move(Err);
8674 return ToTypeOrErr.takeError();
8677 if (!ToLocationOrErr)
8678 return ToLocationOrErr.takeError();
8687 return ToTypeOrErr.takeError();
8690 if (!ToLocationOrErr)
8691 return ToLocationOrErr.takeError();
8694 *ToTypeOrErr, *ToLocationOrErr);
8698 Error Err = Error::success();
8709 return std::move(Err);
8721 return std::move(Err);
8722 ResInfo = &ToTAInfo;
8726 ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8727 ToMemberDecl, ToFoundDecl, ToMemberNameInfo,
8734 Error Err = Error::success();
8742 return std::move(Err);
8748 if (!ToDestroyedTypeLocOrErr)
8749 return ToDestroyedTypeLocOrErr.takeError();
8755 return ToTIOrErr.takeError();
8759 Importer.getToContext(), ToBase, E->
isArrow(), ToOperatorLoc,
8760 ToQualifierLoc, ToScopeTypeInfo, ToColonColonLoc, ToTildeLoc, Storage);
8765 Error Err = Error::success();
8770 auto ToFirstQualifierFoundInScope =
8773 return std::move(Err);
8775 Expr *ToBase =
nullptr;
8778 ToBase = *ToBaseOrErr;
8780 return ToBaseOrErr.takeError();
8789 return std::move(Err);
8790 ResInfo = &ToTAInfo;
8795 return std::move(Err);
8801 return std::move(Err);
8804 Importer.getToContext(), ToBase, ToType, E->
isArrow(), ToOperatorLoc,
8805 ToQualifierLoc, ToTemplateKeywordLoc, ToFirstQualifierFoundInScope,
8806 ToMemberNameInfo, ResInfo);
8811 Error Err = Error::success();
8819 return std::move(Err);
8823 return std::move(Err);
8830 return std::move(Err);
8831 ResInfo = &ToTAInfo;
8835 Importer.getToContext(), ToQualifierLoc, ToTemplateKeywordLoc,
8836 ToNameInfo, ResInfo);
8841 Error Err = Error::success();
8847 return std::move(Err);
8852 return std::move(Err);
8855 Importer.getToContext(), ToType, ToTypeSourceInfo, ToLParenLoc,
8862 if (!ToNamingClassOrErr)
8863 return ToNamingClassOrErr.takeError();
8866 if (!ToQualifierLocOrErr)
8867 return ToQualifierLocOrErr.takeError();
8869 Error Err = Error::success();
8873 return std::move(Err);
8878 return std::move(Err);
8881 for (
auto *D : E->
decls())
8882 if (
auto ToDOrErr =
import(D))
8885 return ToDOrErr.takeError();
8892 return std::move(Err);
8895 if (!ToTemplateKeywordLocOrErr)
8896 return ToTemplateKeywordLocOrErr.takeError();
8898 const bool KnownDependent =
8900 ExprDependence::TypeValue;
8902 Importer.getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8903 *ToTemplateKeywordLocOrErr, ToNameInfo, E->
requiresADL(), &ToTAInfo,
8904 ToDecls.
begin(), ToDecls.
end(), KnownDependent,
8909 Importer.getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8917 Error Err = Error::success();
8925 return std::move(Err);
8930 return std::move(Err);
8934 if (
auto ToDOrErr =
import(D))
8937 return ToDOrErr.takeError();
8945 return std::move(Err);
8946 ResInfo = &ToTAInfo;
8949 Expr *ToBase =
nullptr;
8952 ToBase = *ToBaseOrErr;
8954 return ToBaseOrErr.takeError();
8959 E->
isArrow(), ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8960 ToNameInfo, ResInfo, ToDecls.
begin(), ToDecls.
end());
8964 Error Err = Error::success();
8969 return std::move(Err);
8974 return std::move(Err);
8976 if (
const auto *OCE = dyn_cast<CXXOperatorCallExpr>(E)) {
8978 Importer.getToContext(), OCE->getOperator(), ToCallee, ToArgs, ToType,
8979 OCE->getValueKind(), ToRParenLoc, OCE->getFPFeatures(),
8980 OCE->getADLCallKind());
8990 auto ToClassOrErr =
import(FromClass);
8992 return ToClassOrErr.takeError();
8997 return ToCallOpOrErr.takeError();
9001 return std::move(Err);
9003 Error Err = Error::success();
9008 return std::move(Err);
9019 Error Err = Error::success();
9024 return std::move(Err);
9028 return std::move(Err);
9032 ToCtx, ToLBraceLoc, ToExprs, ToRBraceLoc);
9039 return ToFillerOrErr.takeError();
9043 if (
auto ToFDOrErr =
import(FromFD))
9046 return ToFDOrErr.takeError();
9050 if (
auto ToSyntFormOrErr =
import(SyntForm))
9053 return ToSyntFormOrErr.takeError();
9067 return ToTypeOrErr.takeError();
9070 if (!ToSubExprOrErr)
9071 return ToSubExprOrErr.takeError();
9074 *ToTypeOrErr, *ToSubExprOrErr);
9079 Error Err = Error::success();
9084 return std::move(Err);
9092 Error Err = Error::success();
9097 return std::move(Err);
9100 ToType, ToCommonExpr, ToSubExpr);
9106 return ToTypeOrErr.takeError();
9112 if (!ToBeginLocOrErr)
9113 return ToBeginLocOrErr.takeError();
9115 auto ToFieldOrErr =
import(E->
getField());
9117 return ToFieldOrErr.takeError();
9119 auto UsedContextOrErr = Importer.ImportContext(E->
getUsedContext());
9120 if (!UsedContextOrErr)
9121 return UsedContextOrErr.takeError();
9125 "Field should have in-class initializer if there is a default init "
9126 "expression that uses it.");
9131 auto ToInClassInitializerOrErr =
9132 import(E->
getField()->getInClassInitializer());
9133 if (!ToInClassInitializerOrErr)
9134 return ToInClassInitializerOrErr.takeError();
9138 Expr *RewrittenInit =
nullptr;
9142 return ExprOrErr.takeError();
9143 RewrittenInit = ExprOrErr.get();
9147 ToField, *UsedContextOrErr, RewrittenInit);
9151 Error Err = Error::success();
9159 return std::move(Err);
9164 if (!ToBasePathOrErr)
9165 return ToBasePathOrErr.takeError();
9167 if (
auto CCE = dyn_cast<CXXStaticCastExpr>(E)) {
9169 Importer.getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9170 ToTypeInfoAsWritten, CCE->getFPFeatures(), ToOperatorLoc, ToRParenLoc,
9174 Importer.getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9175 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9178 Importer.getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9179 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9182 Importer.getToContext(), ToType,
VK, ToSubExpr, ToTypeInfoAsWritten,
9183 ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9185 llvm_unreachable(
"Unknown cast type");
9186 return make_error<ASTImportError>();
9192 Error Err = Error::success();
9198 return std::move(Err);
9201 ToType, E->
getValueKind(), ToNameLoc, ToReplacement, ToAssociatedDecl,
9207 Error Err = Error::success();
9212 return std::move(Err);
9216 return std::move(Err);
9223 E->
getTrait(), ToArgs, ToEndLoc, ToValue);
9233 return ToTypeOrErr.takeError();
9236 if (!ToSourceRangeOrErr)
9237 return ToSourceRangeOrErr.takeError();
9242 *ToTypeOrErr, *ToTSIOrErr, *ToSourceRangeOrErr);
9244 return ToTSIOrErr.takeError();
9248 if (!ToExprOperandOrErr)
9249 return ToExprOperandOrErr.takeError();
9252 *ToTypeOrErr, *ToExprOperandOrErr, *ToSourceRangeOrErr);
9256 Error Err = Error::success();
9267 return std::move(Err);
9269 return new (Importer.getToContext())
9275 Error Err = Error::success();
9283 return std::move(Err);
9287 return std::move(Err);
9292 return std::move(Err);
9294 LParenLoc, LocalParameters, RParenLoc,
9295 Requirements, RBraceLoc);
9300 Error Err = Error::success();
9304 return std::move(Err);
9307 Importer.getToContext(),
CL,
9312 return std::move(Err);
9314 Importer.getToContext(),
CL,
9320 Error Err = Error::success();
9326 return std::move(Err);
9329 ToType, E->
getValueKind(), ToPackLoc, ToArgPack, ToAssociatedDecl,
9336 return std::move(Err);
9339 return ToSyntOrErr.takeError();
9346 Error Err = Error::success();
9352 return std::move(Err);
9356 return std::move(Err);
9359 ToInitLoc, ToBeginLoc, ToEndLoc);
9364 Error ImportErrors = Error::success();
9366 if (
auto ImportedOrErr =
import(FromOverriddenMethod))
9368 (*ImportedOrErr)->getCanonicalDecl()));
9371 joinErrors(std::move(ImportErrors), ImportedOrErr.takeError());
9373 return ImportErrors;
9379 std::shared_ptr<ASTImporterSharedState> SharedState)
9380 : SharedState(SharedState), ToContext(ToContext), FromContext(FromContext),
9381 ToFileManager(ToFileManager), FromFileManager(FromFileManager),
9386 this->SharedState = std::make_shared<ASTImporterSharedState>();
9389 ImportedDecls[FromContext.getTranslationUnitDecl()] =
9390 ToContext.getTranslationUnitDecl();
9397 "Try to get field index for non-field.");
9401 return std::nullopt;
9404 for (
const auto *D : Owner->decls()) {
9412 llvm_unreachable(
"Field was not found in its parent context.");
9414 return std::nullopt;
9417ASTImporter::FoundDeclsTy
9427 if (SharedState->getLookupTable()) {
9435 dyn_cast<NamespaceDecl>(ReDC));
9436 for (
auto *D : NSChain) {
9438 SharedState->getLookupTable()->lookup(dyn_cast<NamespaceDecl>(D),
9445 SharedState->getLookupTable()->lookup(ReDC, Name);
9446 return FoundDeclsTy(LookupResult.begin(), LookupResult.end());
9450 FoundDeclsTy
Result(NoloadLookupResult.
begin(), NoloadLookupResult.
end());
9467void ASTImporter::AddToLookupTable(
Decl *ToD) {
9468 SharedState->addDeclToLookup(ToD);
9474 return Importer.
Visit(FromD);
9498 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
9499 ImportedTypes.find(FromT);
9500 if (Pos != ImportedTypes.end())
9507 return ToTOrErr.takeError();
9510 ImportedTypes[FromT] = ToTOrErr->getTypePtr();
9512 return ToTOrErr->getTypePtr();
9521 return ToTyOrErr.takeError();
9534 return TOrErr.takeError();
9537 return BeginLocOrErr.takeError();
9539 return ToContext.getTrivialTypeSourceInfo(*TOrErr, *BeginLocOrErr);
9546template <
typename T>
struct AttrArgImporter {
9547 AttrArgImporter(
const AttrArgImporter<T> &) =
delete;
9548 AttrArgImporter(AttrArgImporter<T> &&) =
default;
9549 AttrArgImporter<T> &operator=(
const AttrArgImporter<T> &) =
delete;
9550 AttrArgImporter<T> &operator=(AttrArgImporter<T> &&) =
default;
9553 : To(I.importChecked(Err, From)) {}
9555 const T &value() {
return To; }
9566template <
typename T>
struct AttrArgArrayImporter {
9567 AttrArgArrayImporter(
const AttrArgArrayImporter<T> &) =
delete;
9568 AttrArgArrayImporter(AttrArgArrayImporter<T> &&) =
default;
9569 AttrArgArrayImporter<T> &operator=(
const AttrArgArrayImporter<T> &) =
delete;
9570 AttrArgArrayImporter<T> &operator=(AttrArgArrayImporter<T> &&) =
default;
9572 AttrArgArrayImporter(ASTNodeImporter &I,
Error &Err,
9573 const llvm::iterator_range<T *> &From,
9574 unsigned ArraySize) {
9577 To.reserve(ArraySize);
9581 T *value() {
return To.data(); }
9584 llvm::SmallVector<T, 2> To;
9588 Error Err{Error::success()};
9589 Attr *ToAttr =
nullptr;
9590 ASTImporter &Importer;
9591 ASTNodeImporter NImporter;
9594 AttrImporter(ASTImporter &I) : Importer(I), NImporter(I) {}
9597 template <
typename T> T *castAttrAs() {
return cast<T>(ToAttr); }
9598 template <
typename T>
const T *castAttrAs()
const {
return cast<T>(ToAttr); }
9603 template <
class T> AttrArgImporter<T> importArg(
const T &From) {
9604 return AttrArgImporter<T>(NImporter, Err, From);
9610 template <
typename T>
9611 AttrArgArrayImporter<T> importArrayArg(
const llvm::iterator_range<T *> &From,
9612 unsigned ArraySize) {
9613 return AttrArgArrayImporter<T>(NImporter, Err, From, ArraySize);
9624 template <
typename T,
typename... Arg>
9625 void importAttr(
const T *FromAttr, Arg &&...ImportedArg) {
9626 static_assert(std::is_base_of<Attr, T>::value,
9627 "T should be subclass of Attr.");
9628 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9630 const IdentifierInfo *ToAttrName = Importer.
Import(FromAttr->getAttrName());
9631 const IdentifierInfo *ToScopeName =
9632 Importer.
Import(FromAttr->getScopeName());
9633 SourceRange ToAttrRange =
9635 SourceLocation ToScopeLoc =
9641 AttributeCommonInfo ToI(
9642 ToAttrName, AttributeScopeInfo(ToScopeName, ToScopeLoc), ToAttrRange,
9643 FromAttr->getParsedKind(), FromAttr->getForm());
9647 std::forward<Arg>(ImportedArg)..., ToI);
9651 if (
auto *ToInheritableAttr = dyn_cast<InheritableAttr>(ToAttr))
9652 ToInheritableAttr->setInherited(FromAttr->isInherited());
9658 void cloneAttr(
const Attr *FromAttr) {
9659 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9671 llvm::Expected<Attr *> getResult() && {
9673 return std::move(Err);
9674 assert(ToAttr &&
"Attribute should be created.");
9681 AttrImporter AI(*
this);
9684 switch (FromAttr->
getKind()) {
9685 case attr::Aligned: {
9687 if (From->isAlignmentExpr())
9688 AI.importAttr(From,
true, AI.importArg(From->getAlignmentExpr()).value());
9690 AI.importAttr(From,
false,
9691 AI.importArg(From->getAlignmentType()).value());
9695 case attr::AlignValue: {
9697 AI.importAttr(From, AI.importArg(From->getAlignment()).value());
9701 case attr::Format: {
9703 AI.importAttr(From,
Import(From->getType()), From->getFormatIdx(),
9704 From->getFirstArg());
9708 case attr::EnableIf: {
9710 AI.importAttr(From, AI.importArg(From->getCond()).value(),
9711 From->getMessage());
9715 case attr::AssertCapability: {
9718 AI.importArrayArg(From->args(), From->args_size()).value(),
9722 case attr::AcquireCapability: {
9725 AI.importArrayArg(From->args(), From->args_size()).value(),
9729 case attr::TryAcquireCapability: {
9731 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9732 AI.importArrayArg(From->args(), From->args_size()).value(),
9736 case attr::ReleaseCapability: {
9739 AI.importArrayArg(From->args(), From->args_size()).value(),
9743 case attr::RequiresCapability: {
9746 AI.importArrayArg(From->args(), From->args_size()).value(),
9750 case attr::GuardedBy: {
9752 AI.importAttr(From, AI.importArg(From->getArg()).value());
9755 case attr::PtGuardedBy: {
9757 AI.importAttr(From, AI.importArg(From->getArg()).value());
9760 case attr::AcquiredAfter: {
9763 AI.importArrayArg(From->args(), From->args_size()).value(),
9767 case attr::AcquiredBefore: {
9770 AI.importArrayArg(From->args(), From->args_size()).value(),
9774 case attr::LockReturned: {
9776 AI.importAttr(From, AI.importArg(From->getArg()).value());
9779 case attr::LocksExcluded: {
9782 AI.importArrayArg(From->args(), From->args_size()).value(),
9790 AI.cloneAttr(FromAttr);
9795 return std::move(AI).getResult();
9799 return ImportedDecls.lookup(FromD);
9803 auto FromDPos = ImportedFromDecls.find(ToD);
9804 if (FromDPos == ImportedFromDecls.end())
9814 ImportPath.push(FromD);
9815 llvm::scope_exit ImportPathBuilder([
this]() { ImportPath.pop(); });
9820 return make_error<ASTImportError>(*
Error);
9826 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9828 return make_error<ASTImportError>(*
Error);
9835 if (ImportPath.hasCycleAtBack())
9836 SavedImportPaths[FromD].push_back(ImportPath.copyCycleAtBack());
9845 auto Pos = ImportedDecls.find(FromD);
9846 if (Pos != ImportedDecls.end()) {
9849 auto *ToD = Pos->second;
9850 ImportedDecls.erase(Pos);
9862 auto PosF = ImportedFromDecls.find(ToD);
9863 if (PosF != ImportedFromDecls.end()) {
9868 SharedState->removeDeclFromLookup(ToD);
9869 ImportedFromDecls.erase(PosF);
9881 handleAllErrors(ToDOrErr.takeError(),
9885 if (Pos != ImportedDecls.end())
9886 SharedState->setImportDeclError(Pos->second, ErrOut);
9890 for (
const auto &Path : SavedImportPaths[FromD]) {
9893 Decl *PrevFromDi = FromD;
9894 for (
Decl *FromDi : Path) {
9896 if (FromDi == FromD)
9903 PrevFromDi = FromDi;
9907 auto Ii = ImportedDecls.find(FromDi);
9908 if (Ii != ImportedDecls.end())
9909 SharedState->setImportDeclError(Ii->second, ErrOut);
9914 SavedImportPaths.erase(FromD);
9917 return make_error<ASTImportError>(ErrOut);
9929 return make_error<ASTImportError>(*Err);
9935 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9937 return make_error<ASTImportError>(*
Error);
9940 assert(ImportedDecls.count(FromD) != 0 &&
"Missing call to MapImported?");
9944 auto ToAttrOrErr =
Import(FromAttr);
9948 return ToAttrOrErr.takeError();
9955 SavedImportPaths.erase(FromD);
9970 return ToDCOrErr.takeError();
9975 if (
auto *ToRecord = dyn_cast<RecordDecl>(ToDC)) {
9977 if (ToRecord->isCompleteDefinition())
9985 if (FromRecord->getASTContext().getExternalSource() &&
9986 !FromRecord->isCompleteDefinition())
9987 FromRecord->getASTContext().getExternalSource()->CompleteType(FromRecord);
9989 if (FromRecord->isCompleteDefinition())
9992 return std::move(Err);
9993 }
else if (
auto *ToEnum = dyn_cast<EnumDecl>(ToDC)) {
9995 if (ToEnum->isCompleteDefinition()) {
9997 }
else if (FromEnum->isCompleteDefinition()) {
10000 return std::move(Err);
10004 }
else if (
auto *ToClass = dyn_cast<ObjCInterfaceDecl>(ToDC)) {
10006 if (ToClass->getDefinition()) {
10011 return std::move(Err);
10015 }
else if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(ToDC)) {
10017 if (ToProto->getDefinition()) {
10022 return std::move(Err);
10033 return cast_or_null<Expr>(*ToSOrErr);
10035 return ToSOrErr.takeError();
10043 llvm::DenseMap<Stmt *, Stmt *>::iterator Pos = ImportedStmts.find(FromS);
10044 if (Pos != ImportedStmts.end())
10045 return Pos->second;
10053 if (
auto *ToE = dyn_cast<Expr>(*ToSOrErr)) {
10057 ToE->setValueKind(FromE->getValueKind());
10058 ToE->setObjectKind(FromE->getObjectKind());
10059 ToE->setDependence(FromE->getDependence());
10063 ImportedStmts[FromS] = *ToSOrErr;
10074 auto NSOrErr =
Import(Namespace);
10076 return NSOrErr.takeError();
10077 auto PrefixOrErr =
Import(Prefix);
10079 return PrefixOrErr.takeError();
10087 return RDOrErr.takeError();
10092 return TyOrErr.takeError();
10095 llvm_unreachable(
"Invalid nested name specifier kind");
10107 NestedNames.push_back(NNS);
10113 while (!NestedNames.empty()) {
10114 NNS = NestedNames.pop_back_val();
10117 return std::move(Err);
10124 return std::move(Err);
10128 return std::move(Err);
10134 ToLocalBeginLoc, ToLocalEndLoc);
10140 return std::move(Err);
10153 if (!ToSourceRangeOrErr)
10154 return ToSourceRangeOrErr.takeError();
10157 ToSourceRangeOrErr->getBegin(),
10158 ToSourceRangeOrErr->getEnd());
10162 llvm_unreachable(
"unexpected null nested name specifier");
10175 return ToTemplateOrErr.takeError();
10180 for (
auto *I : *FromStorage) {
10181 if (
auto ToOrErr =
Import(I))
10184 return ToOrErr.takeError();
10186 return ToContext.getOverloadedTemplateName(ToTemplates.
begin(),
10187 ToTemplates.
end());
10193 if (!DeclNameOrErr)
10194 return DeclNameOrErr.takeError();
10195 return ToContext.getAssumedTemplateName(*DeclNameOrErr);
10201 if (!QualifierOrErr)
10202 return QualifierOrErr.takeError();
10205 return TNOrErr.takeError();
10206 return ToContext.getQualifiedTemplateName(
10213 if (!QualifierOrErr)
10214 return QualifierOrErr.takeError();
10215 return ToContext.getDependentTemplateName(
10223 if (!ReplacementOrErr)
10224 return ReplacementOrErr.takeError();
10227 if (!AssociatedDeclOrErr)
10228 return AssociatedDeclOrErr.takeError();
10230 return ToContext.getSubstTemplateTemplateParm(
10231 *ReplacementOrErr, *AssociatedDeclOrErr, Subst->
getIndex(),
10239 auto ArgPackOrErr =
10242 return ArgPackOrErr.takeError();
10245 if (!AssociatedDeclOrErr)
10246 return AssociatedDeclOrErr.takeError();
10248 return ToContext.getSubstTemplateTemplateParmPack(
10249 *ArgPackOrErr, *AssociatedDeclOrErr, SubstPack->
getIndex(),
10255 return UsingOrError.takeError();
10259 llvm_unreachable(
"Unexpected DeducedTemplate");
10262 llvm_unreachable(
"Invalid template name kind");
10274 if (!ToFileIDOrErr)
10275 return ToFileIDOrErr.takeError();
10283 return std::move(Err);
10285 return std::move(Err);
10291 llvm::DenseMap<FileID, FileID>::iterator Pos = ImportedFileIDs.find(FromID);
10292 if (Pos != ImportedFileIDs.end())
10293 return Pos->second;
10305 return ToSpLoc.takeError();
10308 return ToExLocS.takeError();
10318 return ToExLocE.takeError();
10324 if (!IsBuiltin && !
Cache->BufferOverridden) {
10328 return ToIncludeLoc.takeError();
10339 if (
Cache->OrigEntry &&
Cache->OrigEntry->getDir()) {
10345 ToFileManager.getOptionalFileRef(
Cache->OrigEntry->getName());
10350 ToID = ToSM.
createFileID(*Entry, ToIncludeLocOrFakeLoc,
10357 std::optional<llvm::MemoryBufferRef> FromBuf =
10358 Cache->getBufferOrNone(FromContext.getDiagnostics(),
10363 std::unique_ptr<llvm::MemoryBuffer> ToBuf =
10364 llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(),
10365 FromBuf->getBufferIdentifier());
10371 assert(ToID.
isValid() &&
"Unexpected invalid fileID was created.");
10373 ImportedFileIDs[FromID] = ToID;
10380 return ToExprOrErr.takeError();
10383 if (!LParenLocOrErr)
10384 return LParenLocOrErr.takeError();
10387 if (!RParenLocOrErr)
10388 return RParenLocOrErr.takeError();
10393 return ToTInfoOrErr.takeError();
10398 return std::move(Err);
10401 ToContext, *ToTInfoOrErr, From->
isBaseVirtual(), *LParenLocOrErr,
10402 *ToExprOrErr, *RParenLocOrErr, EllipsisLoc);
10406 return ToFieldOrErr.takeError();
10409 if (!MemberLocOrErr)
10410 return MemberLocOrErr.takeError();
10413 ToContext, cast_or_null<FieldDecl>(*ToFieldOrErr), *MemberLocOrErr,
10414 *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10417 if (!ToIFieldOrErr)
10418 return ToIFieldOrErr.takeError();
10421 if (!MemberLocOrErr)
10422 return MemberLocOrErr.takeError();
10425 ToContext, cast_or_null<IndirectFieldDecl>(*ToIFieldOrErr),
10426 *MemberLocOrErr, *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10430 return ToTInfoOrErr.takeError();
10432 return new (ToContext)
10434 *ToExprOrErr, *RParenLocOrErr);
10437 return make_error<ASTImportError>();
10443 auto Pos = ImportedCXXBaseSpecifiers.find(BaseSpec);
10444 if (Pos != ImportedCXXBaseSpecifiers.end())
10445 return Pos->second;
10448 if (!ToSourceRange)
10449 return ToSourceRange.takeError();
10452 return ToTSI.takeError();
10454 if (!ToEllipsisLoc)
10455 return ToEllipsisLoc.takeError();
10459 ImportedCXXBaseSpecifiers[BaseSpec] =
Imported;
10471 return ToOrErr.takeError();
10472 Decl *To = *ToOrErr;
10477 if (
auto *ToRecord = dyn_cast<RecordDecl>(To)) {
10478 if (!ToRecord->getDefinition()) {
10485 if (
auto *ToEnum = dyn_cast<EnumDecl>(To)) {
10486 if (!ToEnum->getDefinition()) {
10492 if (
auto *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
10493 if (!ToIFace->getDefinition()) {
10500 if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
10501 if (!ToProto->getDefinition()) {
10525 return ToSelOrErr.takeError();
10529 return ToContext.DeclarationNames.getCXXConstructorName(
10530 ToContext.getCanonicalType(*ToTyOrErr));
10532 return ToTyOrErr.takeError();
10537 return ToContext.DeclarationNames.getCXXDestructorName(
10538 ToContext.getCanonicalType(*ToTyOrErr));
10540 return ToTyOrErr.takeError();
10545 return ToContext.DeclarationNames.getCXXDeductionGuideName(
10548 return ToTemplateOrErr.takeError();
10553 return ToContext.DeclarationNames.getCXXConversionFunctionName(
10554 ToContext.getCanonicalType(*ToTyOrErr));
10556 return ToTyOrErr.takeError();
10560 return ToContext.DeclarationNames.getCXXOperatorName(
10564 return ToContext.DeclarationNames.getCXXLiteralOperatorName(
10572 llvm_unreachable(
"Invalid DeclarationName Kind!");
10600 for (
unsigned I = 1, N = FromSel.
getNumArgs(); I < N; ++I)
10602 return ToContext.Selectors.getSelector(FromSel.
getNumArgs(), Idents.data());
10608 llvm::Error Err = llvm::Error::success();
10609 auto ImportLoop = [&](
const APValue *From,
APValue *To,
unsigned Size) {
10610 for (
unsigned Idx = 0; Idx < Size; Idx++) {
10615 switch (FromValue.
getKind()) {
10629 ImportLoop(((
const APValue::Vec *)(
const char *)&FromValue.Data)->Elts,
10635 llvm_unreachable(
"Matrix APValue import not yet supported");
10639 ImportLoop(((
const APValue::Arr *)(
const char *)&FromValue.Data)->Elts,
10640 ((
const APValue::Arr *)(
const char *)&
Result.Data)->Elts,
10647 ((
const APValue::StructData *)(
const char *)&FromValue.Data)->Elts,
10648 ((
const APValue::StructData *)(
const char *)&
Result.Data)->Elts,
10656 return std::move(Err);
10661 Result.MakeAddrLabelDiff();
10665 return std::move(Err);
10671 const Decl *ImpMemPtrDecl =
10674 return std::move(Err);
10676 Result.setMemberPointerUninit(
10685 return std::move(Err);
10695 "in C++20 dynamic allocation are transient so they shouldn't "
10696 "appear in the AST");
10698 if (
const auto *E =
10700 FromElemTy = E->getType();
10703 return std::move(Err);
10713 return std::move(Err);
10725 return std::move(Err);
10738 for (
unsigned LoopIdx = 0; LoopIdx < PathLength; LoopIdx++) {
10740 const Decl *FromDecl =
10741 FromPath[LoopIdx].getAsBaseOrMember().getPointer();
10744 return std::move(Err);
10745 if (
auto *RD = dyn_cast<CXXRecordDecl>(FromDecl))
10746 FromElemTy = Importer.FromContext.getCanonicalTagType(RD);
10750 ImpDecl, FromPath[LoopIdx].getAsBaseOrMember().getInt()));
10753 Importer.FromContext.getAsArrayType(FromElemTy)->getElementType();
10755 FromPath[LoopIdx].getAsArrayIndex());
10763 return std::move(Err);
10771 unsigned NumDecls) {
10781 if (LastDiagFromFrom)
10782 ToContext.getDiagnostics().notePriorDiagnosticFrom(
10783 FromContext.getDiagnostics());
10784 LastDiagFromFrom =
false;
10785 return ToContext.getDiagnostics().Report(Loc, DiagID);
10789 if (!LastDiagFromFrom)
10790 FromContext.getDiagnostics().notePriorDiagnosticFrom(
10791 ToContext.getDiagnostics());
10792 LastDiagFromFrom =
true;
10793 return FromContext.getDiagnostics().Report(Loc, DiagID);
10797 if (
auto *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
10798 if (!ID->getDefinition())
10799 ID->startDefinition();
10801 else if (
auto *PD = dyn_cast<ObjCProtocolDecl>(D)) {
10802 if (!PD->getDefinition())
10803 PD->startDefinition();
10805 else if (
auto *TD = dyn_cast<TagDecl>(D)) {
10806 if (!TD->getDefinition() && !TD->isBeingDefined()) {
10807 TD->startDefinition();
10808 TD->setCompleteDefinition(
true);
10812 assert(0 &&
"CompleteDecl called on a Decl that can't be completed");
10817 auto [Pos, Inserted] = ImportedDecls.try_emplace(From, To);
10818 assert((Inserted || Pos->second == To) &&
10819 "Try to import an already imported Decl");
10821 return Pos->second;
10824 ImportedFromDecls[To] = From;
10829 AddToLookupTable(To);
10833std::optional<ASTImportError>
10835 auto Pos = ImportDeclErrors.find(FromD);
10836 if (Pos != ImportDeclErrors.end())
10837 return Pos->second;
10839 return std::nullopt;
10843 auto InsertRes = ImportDeclErrors.insert({From,
Error});
10847 assert(InsertRes.second || InsertRes.first->second.Error ==
Error.Error);
10852 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
10854 if (Pos != ImportedTypes.end()) {
10856 if (ToContext.hasSameType(*ToFromOrErr, To))
10859 llvm::consumeError(ToFromOrErr.takeError());
10864 getToContext().getLangOpts(), FromContext, ToContext, NonEquivalentDecls,
Defines the clang::ASTContext interface.
static FriendCountAndPosition getFriendCountAndPosition(ASTImporter &Importer, FriendDecl *FD)
static bool IsEquivalentFriend(ASTImporter &Importer, FriendDecl *FD1, FriendDecl *FD2)
static ExpectedStmt ImportLoopControlStmt(ASTNodeImporter &NodeImporter, ASTImporter &Importer, StmtClass *S)
static auto getTemplateDefinition(T *D) -> T *
static bool isAncestorDeclContextOf(const DeclContext *DC, const Decl *D)
static Error setTypedefNameForAnonDecl(TagDecl *From, TagDecl *To, ASTImporter &Importer)
static StructuralEquivalenceKind getStructuralEquivalenceKind(const ASTImporter &Importer)
This file provides some common utility functions for processing Lambda related AST Constructs.
Defines enum values for all the target-independent builtin functions.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::FileManager interface and associated types.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the LambdaCapture class.
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
Defines the Objective-C statement AST node classes.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
llvm::APInt getValue() const
unsigned getVersion() const
QualType getTypeInfoType() const
static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo)
unsigned getCallIndex() const
A non-discriminated union of a base, field, or array index.
static LValuePathEntry ArrayIndex(uint64_t Index)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
const LValueBase getLValueBase() const
ArrayRef< LValuePathEntry > getLValuePath() const
const FieldDecl * getUnionField() const
unsigned getStructNumFields() const
llvm::PointerIntPair< const Decl *, 1, bool > BaseOrMemberType
A FieldDecl or CXXRecordDecl, along with a flag indicating whether we mean a virtual or non-virtual b...
ValueKind getKind() const
bool isLValueOnePastTheEnd() const
bool isMemberPointerToDerivedMember() const
unsigned getArrayInitializedElts() const
unsigned getStructNumBases() const
bool hasLValuePath() const
const ValueDecl * getMemberPointerDecl() const
APValue & getUnionValue()
const AddrLabelExpr * getAddrLabelDiffRHS() const
CharUnits & getLValueOffset()
unsigned getVectorLength() const
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
unsigned getArraySize() const
@ Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
@ None
There is no such object (it's outside its lifetime).
bool isNullPointer() const
const AddrLabelExpr * getAddrLabelDiffLHS() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
const LangOptions & getLangOpts() const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
std::error_code convertToErrorCode() const override
void log(llvm::raw_ostream &OS) const override
std::string toString() const
@ Unknown
Not supported node or case.
@ UnsupportedConstruct
Naming ambiguity (likely ODR violation).
auto makeScopedCycleDetection(const FunctionDecl *D)
bool isCycle(const FunctionDecl *D) const
Imports selected nodes from one AST context into another context, merging AST nodes where appropriate...
ASTContext & getToContext() const
Retrieve the context that AST nodes are being imported into.
DiagnosticBuilder ToDiag(SourceLocation Loc, unsigned DiagID)
Report a diagnostic in the "to" context.
Decl * MapImported(Decl *From, Decl *To)
Store and assign the imported declaration to its counterpart.
static UnsignedOrNone getFieldIndex(Decl *F)
Determine the index of a field in its parent record.
TranslationUnitDecl * GetFromTU(Decl *ToD)
Return the translation unit from where the declaration was imported.
llvm::Expected< DeclContext * > ImportContext(DeclContext *FromDC)
Import the given declaration context from the "from" AST context into the "to" AST context.
llvm::Error ImportDefinition(Decl *From)
Import the definition of the given declaration, including all of the declarations it contains.
virtual Expected< DeclarationName > HandleNameConflict(DeclarationName Name, DeclContext *DC, unsigned IDNS, NamedDecl **Decls, unsigned NumDecls)
Cope with a name conflict when importing a declaration into the given context.
void RegisterImportedDecl(Decl *FromD, Decl *ToD)
std::optional< ASTImportError > getImportDeclErrorIfAny(Decl *FromD) const
Return if import of the given declaration has failed and if yes the kind of the problem.
friend class ASTNodeImporter
llvm::Error ImportTemplateArguments(ArrayRef< TemplateArgument > FromArgs, SmallVectorImpl< TemplateArgument > &ToArgs)
llvm::Error importInto(ImportT &To, const ImportT &From)
Import the given object, returns the result.
virtual void Imported(Decl *From, Decl *To)
Subclasses can override this function to observe all of the From -> To declaration mappings as they a...
DiagnosticBuilder FromDiag(SourceLocation Loc, unsigned DiagID)
Report a diagnostic in the "from" context.
llvm::DenseSet< std::tuple< Decl *, Decl *, int > > NonEquivalentDeclSet
bool IsStructurallyEquivalent(QualType From, QualType To, bool Complain=true)
Determine whether the given types are structurally equivalent.
virtual Expected< Decl * > ImportImpl(Decl *From)
Can be overwritten by subclasses to implement their own import logic.
bool isMinimalImport() const
Whether the importer will perform a minimal import, creating to-be-completed forward declarations whe...
ASTImporter(ASTContext &ToContext, FileManager &ToFileManager, ASTContext &FromContext, FileManager &FromFileManager, bool MinimalImport, std::shared_ptr< ASTImporterSharedState > SharedState=nullptr)
llvm::Expected< ExprWithCleanups::CleanupObject > Import(ExprWithCleanups::CleanupObject From)
Import cleanup objects owned by ExprWithCleanup.
virtual void CompleteDecl(Decl *D)
Called for ObjCInterfaceDecl, ObjCProtocolDecl, and TagDecl.
Decl * GetAlreadyImportedOrNull(const Decl *FromD) const
Return the copy of the given declaration in the "to" context if it has already been imported from the...
void setImportDeclError(Decl *From, ASTImportError Error)
Mark (newly) imported declaration with error.
ExpectedDecl VisitObjCImplementationDecl(ObjCImplementationDecl *D)
ExpectedStmt VisitGenericSelectionExpr(GenericSelectionExpr *E)
ExpectedStmt VisitTypeTraitExpr(TypeTraitExpr *E)
ExpectedDecl VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
ExpectedDecl VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
ExpectedStmt VisitDeclRefExpr(DeclRefExpr *E)
ExpectedDecl VisitAccessSpecDecl(AccessSpecDecl *D)
ExpectedDecl VisitFunctionDecl(FunctionDecl *D)
ExpectedDecl VisitParmVarDecl(ParmVarDecl *D)
ExpectedStmt VisitImplicitValueInitExpr(ImplicitValueInitExpr *E)
ExpectedStmt VisitImplicitCastExpr(ImplicitCastExpr *E)
ExpectedDecl VisitCXXMethodDecl(CXXMethodDecl *D)
ExpectedDecl VisitUsingDecl(UsingDecl *D)
ExpectedDecl VisitObjCProtocolDecl(ObjCProtocolDecl *D)
ExpectedStmt VisitStmt(Stmt *S)
ExpectedDecl VisitTranslationUnitDecl(TranslationUnitDecl *D)
ExpectedDecl VisitFieldDecl(FieldDecl *D)
Error ImportFieldDeclDefinition(const FieldDecl *From, const FieldDecl *To)
Error ImportDefinitionIfNeeded(Decl *FromD, Decl *ToD=nullptr)
ExpectedStmt VisitCharacterLiteral(CharacterLiteral *E)
ExpectedStmt VisitCXXConstructExpr(CXXConstructExpr *E)
ExpectedStmt VisitObjCAtThrowStmt(ObjCAtThrowStmt *S)
ExpectedDecl VisitStaticAssertDecl(StaticAssertDecl *D)
ExpectedStmt VisitShuffleVectorExpr(ShuffleVectorExpr *E)
ExpectedDecl VisitObjCPropertyDecl(ObjCPropertyDecl *D)
ExpectedDecl VisitRecordDecl(RecordDecl *D)
ExpectedStmt VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E)
ExpectedDecl VisitUsingShadowDecl(UsingShadowDecl *D)
Error ImportArrayChecked(const InContainerTy &InContainer, OIter Obegin)
ExpectedStmt VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S)
StringRef ImportASTStringRef(StringRef FromStr)
T importChecked(Error &Err, const T &From)
ExpectedStmt VisitVAArgExpr(VAArgExpr *E)
ExpectedStmt VisitDefaultStmt(DefaultStmt *S)
ExpectedDecl VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
ExpectedStmt VisitCXXThrowExpr(CXXThrowExpr *E)
ExpectedDecl VisitLabelDecl(LabelDecl *D)
ExpectedStmt VisitSizeOfPackExpr(SizeOfPackExpr *E)
ExpectedDecl VisitRequiresExprBodyDecl(RequiresExprBodyDecl *E)
ExpectedStmt VisitObjCAtTryStmt(ObjCAtTryStmt *S)
ExpectedStmt VisitUnaryOperator(UnaryOperator *E)
Error ImportTemplateParameterLists(const DeclTy *FromD, DeclTy *ToD)
Error ImportDeclContext(DeclContext *FromDC, bool ForceImport=false)
ExpectedStmt VisitRequiresExpr(RequiresExpr *E)
ExpectedDecl VisitImplicitConceptSpecializationDecl(ImplicitConceptSpecializationDecl *D)
ExpectedStmt VisitContinueStmt(ContinueStmt *S)
ExpectedStmt VisitCXXMemberCallExpr(CXXMemberCallExpr *E)
ExpectedDecl VisitVarDecl(VarDecl *D)
ExpectedStmt VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E)
ExpectedDecl VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D)
Error ImportImplicitMethods(const CXXRecordDecl *From, CXXRecordDecl *To)
ExpectedStmt VisitPseudoObjectExpr(PseudoObjectExpr *E)
ExpectedStmt VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E)
ExpectedStmt VisitImaginaryLiteral(ImaginaryLiteral *E)
ExpectedDecl VisitConceptDecl(ConceptDecl *D)
ExpectedDecl VisitLinkageSpecDecl(LinkageSpecDecl *D)
ExpectedDecl VisitCXXDestructorDecl(CXXDestructorDecl *D)
ExpectedStmt VisitCXXNamedCastExpr(CXXNamedCastExpr *E)
ExpectedStmt VisitOffsetOfExpr(OffsetOfExpr *OE)
ExpectedStmt VisitExprWithCleanups(ExprWithCleanups *E)
ExpectedDecl VisitIndirectFieldDecl(IndirectFieldDecl *D)
ExpectedStmt VisitCXXFoldExpr(CXXFoldExpr *E)
ExpectedDecl VisitTypeAliasDecl(TypeAliasDecl *D)
Expected< InheritedConstructor > ImportInheritedConstructor(const InheritedConstructor &From)
ExpectedStmt VisitCXXNewExpr(CXXNewExpr *E)
Error ImportDeclParts(NamedDecl *D, DeclarationName &Name, NamedDecl *&ToD, SourceLocation &Loc)
Error ImportDefinition(RecordDecl *From, RecordDecl *To, ImportDefinitionKind Kind=IDK_Default)
ExpectedStmt VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S)
ExpectedStmt VisitConstantExpr(ConstantExpr *E)
ExpectedStmt VisitCompoundLiteralExpr(CompoundLiteralExpr *E)
ExpectedStmt VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E)
ExpectedDecl VisitDecl(Decl *D)
bool hasSameVisibilityContextAndLinkage(T *Found, T *From)
ExpectedStmt VisitParenExpr(ParenExpr *E)
ExpectedStmt VisitObjCForCollectionStmt(ObjCForCollectionStmt *S)
ExpectedStmt VisitSourceLocExpr(SourceLocExpr *E)
ExpectedStmt VisitInitListExpr(InitListExpr *E)
Expected< FunctionTemplateAndArgsTy > ImportFunctionTemplateWithTemplateArgsFromSpecialization(FunctionDecl *FromFD)
ExpectedStmt VisitReturnStmt(ReturnStmt *S)
SmallVector< TemplateArgument, 8 > TemplateArgsTy
ExpectedStmt VisitAtomicExpr(AtomicExpr *E)
ExpectedStmt VisitConditionalOperator(ConditionalOperator *E)
ExpectedStmt VisitChooseExpr(ChooseExpr *E)
ExpectedStmt VisitCompoundStmt(CompoundStmt *S)
Expected< TemplateArgument > ImportTemplateArgument(const TemplateArgument &From)
ExpectedStmt VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E)
ExpectedStmt VisitCaseStmt(CaseStmt *S)
ExpectedStmt VisitCXXRewrittenBinaryOperator(CXXRewrittenBinaryOperator *E)
ExpectedStmt VisitDesignatedInitExpr(DesignatedInitExpr *E)
ExpectedStmt VisitSubstNonTypeTemplateParmPackExpr(SubstNonTypeTemplateParmPackExpr *E)
ExpectedDecl VisitObjCTypeParamDecl(ObjCTypeParamDecl *D)
ExpectedStmt VisitCompoundAssignOperator(CompoundAssignOperator *E)
ExpectedStmt VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E)
ExpectedStmt VisitLambdaExpr(LambdaExpr *LE)
ExpectedStmt VisitBinaryOperator(BinaryOperator *E)
ExpectedStmt VisitCallExpr(CallExpr *E)
ExpectedStmt VisitDeclStmt(DeclStmt *S)
ExpectedStmt VisitCXXDeleteExpr(CXXDeleteExpr *E)
ExpectedStmt VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E)
Error ImportArrayChecked(IIter Ibegin, IIter Iend, OIter Obegin)
ExpectedDecl VisitClassTemplateDecl(ClassTemplateDecl *D)
ExpectedDecl VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D)
Expected< CXXCastPath > ImportCastPath(CastExpr *E)
Expected< APValue > ImportAPValue(const APValue &FromValue)
ExpectedDecl VisitFunctionTemplateDecl(FunctionTemplateDecl *D)
ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E)
ExpectedDecl VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
ExpectedStmt VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E)
ExpectedDecl VisitLifetimeExtendedTemporaryDecl(LifetimeExtendedTemporaryDecl *D)
Expected< concepts::Requirement * > ImportNestedRequirement(concepts::NestedRequirement *From)
ExpectedDecl VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias)
ExpectedDecl VisitCXXConstructorDecl(CXXConstructorDecl *D)
ExpectedDecl VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D)
ExpectedDecl VisitObjCIvarDecl(ObjCIvarDecl *D)
Expected< ObjCTypeParamList * > ImportObjCTypeParamList(ObjCTypeParamList *list)
ExpectedDecl VisitUsingPackDecl(UsingPackDecl *D)
ExpectedStmt VisitWhileStmt(WhileStmt *S)
ExpectedDecl VisitEnumConstantDecl(EnumConstantDecl *D)
ExpectedStmt VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E)
ExpectedStmt VisitCXXForRangeStmt(CXXForRangeStmt *S)
ExpectedDecl VisitFriendDecl(FriendDecl *D)
Error ImportContainerChecked(const InContainerTy &InContainer, OutContainerTy &OutContainer)
ExpectedStmt VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E)
ExpectedStmt VisitExpressionTraitExpr(ExpressionTraitExpr *E)
bool IsStructuralMatch(Decl *From, Decl *To, bool Complain=true, bool IgnoreTemplateParmDepth=false)
ExpectedStmt VisitFixedPointLiteral(FixedPointLiteral *E)
ExpectedStmt VisitForStmt(ForStmt *S)
ExpectedStmt VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E)
ExpectedDecl VisitEnumDecl(EnumDecl *D)
ExpectedStmt VisitCXXParenListInitExpr(CXXParenListInitExpr *E)
ExpectedDecl VisitObjCCategoryDecl(ObjCCategoryDecl *D)
ExpectedStmt VisitAddrLabelExpr(AddrLabelExpr *E)
ExpectedStmt VisitBinaryConditionalOperator(BinaryConditionalOperator *E)
ExpectedStmt VisitSwitchStmt(SwitchStmt *S)
ExpectedType VisitType(const Type *T)
ExpectedDecl VisitVarTemplateDecl(VarTemplateDecl *D)
ExpectedDecl ImportUsingShadowDecls(BaseUsingDecl *D, BaseUsingDecl *ToSI)
ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E)
ExpectedStmt VisitOpaqueValueExpr(OpaqueValueExpr *E)
ExpectedDecl VisitNamespaceAliasDecl(NamespaceAliasDecl *D)
ExpectedStmt VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E)
ExpectedDecl VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
ExpectedStmt VisitPackExpansionExpr(PackExpansionExpr *E)
ExpectedStmt VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E)
ExpectedDecl VisitObjCMethodDecl(ObjCMethodDecl *D)
Error ImportTemplateArguments(ArrayRef< TemplateArgument > FromArgs, SmallVectorImpl< TemplateArgument > &ToArgs)
ExpectedDecl VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D)
ExpectedStmt VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E)
ExpectedDecl VisitImplicitParamDecl(ImplicitParamDecl *D)
ExpectedDecl VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D)
ExpectedStmt VisitExplicitCastExpr(ExplicitCastExpr *E)
ExpectedStmt VisitArrayInitIndexExpr(ArrayInitIndexExpr *E)
Error ImportTemplateArgumentListInfo(const InContainerTy &Container, TemplateArgumentListInfo &ToTAInfo)
ExpectedStmt VisitDoStmt(DoStmt *S)
ExpectedStmt VisitNullStmt(NullStmt *S)
ExpectedStmt VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E)
ExpectedDecl VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D)
Error ImportOverriddenMethods(CXXMethodDecl *ToMethod, CXXMethodDecl *FromMethod)
ExpectedStmt VisitStringLiteral(StringLiteral *E)
Error ImportDeclarationNameLoc(const DeclarationNameInfo &From, DeclarationNameInfo &To)
ExpectedStmt VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E)
bool hasReturnTypeDeclaredInside(FunctionDecl *D)
This function checks if the given function has a return type that contains a reference (in any way) t...
ASTNodeImporter(ASTImporter &Importer)
ExpectedDecl VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D)
ExpectedStmt VisitMemberExpr(MemberExpr *E)
ExpectedStmt VisitConceptSpecializationExpr(ConceptSpecializationExpr *E)
ExpectedStmt VisitCXXThisExpr(CXXThisExpr *E)
Error ImportInitializer(VarDecl *From, VarDecl *To)
ImportDefinitionKind
What we should import from the definition.
@ IDK_Everything
Import everything.
@ IDK_Default
Import the default subset of the definition, which might be nothing (if minimal import is set) or mig...
@ IDK_Basic
Import only the bare bones needed to establish a valid DeclContext.
ExpectedDecl VisitTypedefDecl(TypedefDecl *D)
ExpectedDecl VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
ExpectedStmt VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E)
ExpectedDecl VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D)
Expected< concepts::Requirement * > ImportExprRequirement(concepts::ExprRequirement *From)
ExpectedStmt VisitFloatingLiteral(FloatingLiteral *E)
ExpectedStmt VisitIfStmt(IfStmt *S)
ExpectedStmt VisitLabelStmt(LabelStmt *S)
ExpectedStmt VisitCXXTypeidExpr(CXXTypeidExpr *E)
ExpectedStmt VisitConvertVectorExpr(ConvertVectorExpr *E)
ExpectedDecl VisitUsingEnumDecl(UsingEnumDecl *D)
ExpectedStmt VisitGotoStmt(GotoStmt *S)
ExpectedStmt VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *E)
ExpectedStmt VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S)
ExpectedStmt VisitGCCAsmStmt(GCCAsmStmt *S)
ExpectedDecl VisitNamespaceDecl(NamespaceDecl *D)
ExpectedStmt VisitCXXTryStmt(CXXTryStmt *S)
Error ImportConstraintSatisfaction(const ASTConstraintSatisfaction &FromSat, ConstraintSatisfaction &ToSat)
ExpectedDecl VisitImportDecl(ImportDecl *D)
Error ImportFunctionDeclBody(FunctionDecl *FromFD, FunctionDecl *ToFD)
ExpectedStmt VisitArraySubscriptExpr(ArraySubscriptExpr *E)
Expected< concepts::Requirement * > ImportTypeRequirement(concepts::TypeRequirement *From)
ExpectedStmt VisitIntegerLiteral(IntegerLiteral *E)
ExpectedDecl VisitEmptyDecl(EmptyDecl *D)
ExpectedStmt VisitCXXNoexceptExpr(CXXNoexceptExpr *E)
ExpectedStmt VisitExpr(Expr *E)
Error ImportDefaultArgOfParmVarDecl(const ParmVarDecl *FromParam, ParmVarDecl *ToParam)
ExpectedStmt VisitArrayInitLoopExpr(ArrayInitLoopExpr *E)
ExpectedStmt VisitCXXCatchStmt(CXXCatchStmt *S)
ExpectedStmt VisitAttributedStmt(AttributedStmt *S)
ExpectedStmt VisitIndirectGotoStmt(IndirectGotoStmt *S)
ExpectedStmt VisitParenListExpr(ParenListExpr *E)
Expected< FunctionDecl * > FindFunctionTemplateSpecialization(FunctionDecl *FromFD)
ExpectedDecl VisitCXXConversionDecl(CXXConversionDecl *D)
ExpectedStmt VisitObjCAtCatchStmt(ObjCAtCatchStmt *S)
Error ImportTemplateInformation(FunctionDecl *FromFD, FunctionDecl *ToFD)
ExpectedStmt VisitStmtExpr(StmtExpr *E)
ExpectedStmt VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E)
bool shouldForceImportDeclContext(ImportDefinitionKind IDK)
ExpectedDecl VisitBindingDecl(BindingDecl *D)
std::tuple< FunctionTemplateDecl *, TemplateArgsTy > FunctionTemplateAndArgsTy
ExpectedStmt VisitBreakStmt(BreakStmt *S)
DesignatedInitExpr::Designator Designator
SourceLocation getColonLoc() const
SourceLocation getQuestionLoc() const
Represents an access specifier followed by colon ':'.
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
AddrLabelExpr - The GNU address of label extension, representing &&label.
SourceLocation getAmpAmpLoc() const
SourceLocation getLabelLoc() const
LabelDecl * getLabel() const
QualType getAdjustedType() const
QualType getOriginalType() const
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Represents a loop initializing the elements of an array.
OpaqueValueExpr * getCommonExpr() const
Get the common subexpression shared by all initializations (the source array).
Expr * getSubExpr() const
Get the initializer to use for each array element.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
SourceLocation getRBracketLoc() const
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
uint64_t getValue() const
SourceLocation getEndLoc() const LLVM_READONLY
ArrayTypeTrait getTrait() const
Expr * getDimensionExpression() const
TypeSourceInfo * getQueriedTypeSourceInfo() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
QualType getElementType() const
unsigned getIndexTypeCVRQualifiers() const
SourceLocation getAsmLoc() const
unsigned getNumClobbers() const
unsigned getNumOutputs() const
unsigned getNumInputs() const
A structure for storing the information associated with a name that has been assumed to be a template...
DeclarationName getDeclName() const
Get the name of the template.
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
SourceLocation getRParenLoc() const
static unsigned getNumSubExprs(AtomicOp Op)
Determine the number of arguments the specified atomic builtin should have.
SourceLocation getBuiltinLoc() const
Attr - This represents one attribute.
attr::Kind getKind() const
void setPackExpansion(bool PE)
Attr * clone(ASTContext &C) const
SourceRange getRange() const
void setRange(SourceRange R)
void setAttrName(const IdentifierInfo *AttrNameII)
const IdentifierInfo * getAttrName() const
Represents an attribute applied to a statement.
SourceLocation getAttrLoc() const
ArrayRef< const Attr * > getAttrs() const
static AttributedStmt * Create(const ASTContext &C, SourceLocation Loc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Represents a C++ declaration that introduces decls from somewhere else.
void addShadowDecl(UsingShadowDecl *S)
shadow_range shadows() const
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condition evaluates to false; ...
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value.
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression which will be evaluated if the condition evaluates to true; th...
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
A builtin binary operation expression such as "x + y" or "x <= y".
SourceLocation getOperatorLoc() const
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
FPOptionsOverride getFPFeatures() const
A binding in a decomposition declaration.
ValueDecl * getDecomposedDecl() const
Get the decomposition declaration that this binding represents a decomposition of.
Expr * getBinding() const
Get the expression to which this declaration is bound.
void setBinding(QualType DeclaredType, Expr *Binding)
Set the binding for this BindingDecl, along with its declared type (which should be a possibly-cv-qua...
void setDecomposedDecl(ValueDecl *Decomposed)
Set the decomposed variable for this BindingDecl.
unsigned getNumBits() const
QualType getPointeeType() const
decl_range dependent_decls() const
BreakStmt - This represents a break.
Represents a C++2a __builtin_bit_cast(T, v) expression.
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
BuiltinTemplateKind getBuiltinTemplateKind() const
This class is used for builtin types like 'int'.
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
Represents a base class of a C++ class.
AccessSpecifier getAccessSpecifierAsWritten() const
Retrieves the access specifier as written in the source code (which may mean that no access specifier...
SourceLocation getEllipsisLoc() const
For a pack expansion, determine the location of the ellipsis.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
TypeSourceInfo * getTypeSourceInfo() const
Retrieves the type and source location of the base class.
bool isBaseOfClass() const
Determine whether this base class is a base of a class declared with the 'class' keyword (vs.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
Represents binding an expression to a temporary.
CXXTemporary * getTemporary()
static CXXBindTemporaryExpr * Create(const ASTContext &C, CXXTemporary *Temp, Expr *SubExpr)
const Expr * getSubExpr() const
A boolean literal, per ([C++ lex.bool] Boolean literals).
static CXXBoolLiteralExpr * Create(const ASTContext &C, bool Val, QualType Ty, SourceLocation Loc)
SourceLocation getLocation() const
CXXCatchStmt - This represents a C++ catch block.
SourceLocation getCatchLoc() const
Stmt * getHandlerBlock() const
VarDecl * getExceptionDecl() const
static CXXConstCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Represents a call to a C++ constructor.
SourceRange getParenOrBraceRange() const
void setIsImmediateEscalating(bool Set)
bool isElidable() const
Whether this construction is elidable.
bool hadMultipleCandidates() const
Whether the referred constructor was resolved from an overloaded set having size greater than 1.
static CXXConstructExpr * Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr * > Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, CXXConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Create a C++ construction expression.
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
bool isImmediateEscalating() const
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called.
SourceLocation getLocation() const
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
CXXConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Represents a C++ constructor within a class.
Represents a C++ conversion function within a class.
Represents a C++ base or member initializer.
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
Expr * getInit() const
Get the initializer.
SourceLocation getRParenLoc() const
SourceLocation getEllipsisLoc() const
SourceLocation getLParenLoc() const
bool isPackExpansion() const
Determine whether this initializer is a pack expansion.
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
bool isMemberInitializer() const
Determine whether this initializer is initializing a non-static data member.
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
bool isIndirectMemberInitializer() const
SourceLocation getMemberLocation() const
IndirectFieldDecl * getIndirectMember() const
bool isBaseVirtual() const
Returns whether the base is virtual or not.
Represents a C++ deduction guide declaration.
SourceDeductionGuideKind getSourceDeductionGuideKind() const
A default argument (C++ [dcl.fct.default]).
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
const ParmVarDecl * getParam() const
Expr * getRewrittenExpr()
const DeclContext * getUsedContext() const
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
bool hasRewrittenInit() const
A use of a default initializer in a constructor or in aggregate initialization.
static CXXDefaultInitExpr * Create(const ASTContext &Ctx, SourceLocation Loc, FieldDecl *Field, DeclContext *UsedContext, Expr *RewrittenInitExpr)
Field is the non-static data member whose default initializer is used by this expression.
const DeclContext * getUsedContext() const
const Expr * getRewrittenExpr() const
Retrieve the initializing expression with evaluated immediate calls, if any.
bool hasRewrittenInit() const
FieldDecl * getField()
Get the field whose initializer will be used.
SourceLocation getBeginLoc() const
Represents a delete expression for memory deallocation and destructor calls, e.g.
FunctionDecl * getOperatorDelete() const
SourceLocation getBeginLoc() const
bool isGlobalDelete() const
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
bool isArrayFormAsWritten() const
Represents a C++ member access expression where the actual member referenced could not be resolved be...
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
SourceLocation getOperatorLoc() const
Retrieve the location of the '->' or '.' operator.
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
SourceLocation getMemberLoc() const
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the member name, with source location information.
bool isImplicitAccess() const
True if this is an implicit access, i.e.
ArrayRef< TemplateArgumentLoc > template_arguments() const
Represents a C++ destructor within a class.
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg)
static CXXDynamicCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Represents a folding of a pack over an operator.
UnresolvedLookupExpr * getCallee() const
SourceLocation getLParenLoc() const
SourceLocation getEllipsisLoc() const
UnsignedOrNone getNumExpansions() const
SourceLocation getRParenLoc() const
BinaryOperatorKind getOperator() const
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
DeclStmt * getBeginStmt()
DeclStmt * getLoopVarStmt()
SourceLocation getForLoc() const
DeclStmt * getRangeStmt()
SourceLocation getRParenLoc() const
SourceLocation getColonLoc() const
SourceLocation getCoawaitLoc() const
static CXXFunctionalCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, TypeSourceInfo *Written, CastKind Kind, Expr *Op, const CXXCastPath *Path, FPOptionsOverride FPO, SourceLocation LPLoc, SourceLocation RPLoc)
Represents a call to an inherited base class constructor from an inheriting constructor.
bool constructsVBase() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will call.
SourceLocation getLocation() const LLVM_READONLY
bool inheritedFromVBase() const
Determine whether the inherited constructor is inherited from a virtual base of the object we constru...
Represents a call to a member function that may be written either with member call syntax (e....
static CXXMemberCallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RP, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0)
Represents a static or instance method of a struct/union/class.
void addOverriddenMethod(const CXXMethodDecl *MD)
overridden_method_range overridden_methods() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Abstract class common to all of the C++ "named"/"keyword" casts.
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
SourceRange getAngleBrackets() const LLVM_READONLY
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
static CXXNewExpr * Create(const ASTContext &Ctx, bool IsGlobalNew, FunctionDecl *OperatorNew, FunctionDecl *OperatorDelete, const ImplicitAllocationParameters &IAP, bool UsualArrayDeleteWantsSize, ArrayRef< Expr * > PlacementArgs, SourceRange TypeIdParens, std::optional< Expr * > ArraySize, CXXNewInitializationStyle InitializationStyle, Expr *Initializer, QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range, SourceRange DirectInitRange)
Create a c++ new expression.
SourceRange getDirectInitRange() const
llvm::iterator_range< arg_iterator > placement_arguments()
std::optional< Expr * > getArraySize()
This might return std::nullopt even if isArray() returns true, since there might not be an array size...
CXXNewInitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
ImplicitAllocationParameters implicitAllocationParameters() const
Provides the full set of information about expected implicit parameters in this call.
FunctionDecl * getOperatorDelete() const
unsigned getNumPlacementArgs() const
TypeSourceInfo * getAllocatedTypeSourceInfo() const
SourceRange getSourceRange() const
SourceRange getTypeIdParens() const
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
FunctionDecl * getOperatorNew() const
Expr * getInitializer()
The initializer of this new-expression.
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
SourceLocation getEndLoc() const
Expr * getOperand() const
SourceLocation getBeginLoc() const
The null pointer literal (C++11 [lex.nullptr])
SourceLocation getLocation() const
static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptionsOverride FPFeatures, ADLCallKind UsesADL=NotADL)
Represents a list-initialization with parenthesis.
static CXXParenListInitExpr * Create(ASTContext &C, ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getInitLoc() const LLVM_READONLY
MutableArrayRef< Expr * > getInitExprs()
ArrayRef< Expr * > getUserSpecifiedInitExprs()
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
TypeSourceInfo * getDestroyedTypeInfo() const
Retrieve the source location information for the type being destroyed.
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise,...
TypeSourceInfo * getScopeTypeInfo() const
Retrieve the scope type in a qualified pseudo-destructor expression.
SourceLocation getTildeLoc() const
Retrieve the location of the '~'.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieves the nested-name-specifier that qualifies the type name, with source-location information.
SourceLocation getDestroyedTypeLoc() const
Retrieve the starting location of the type being destroyed.
SourceLocation getColonColonLoc() const
Retrieve the location of the '::' in a qualified pseudo-destructor expression.
SourceLocation getOperatorLoc() const
Retrieve the location of the '.' or '->' operator.
const IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
Represents a C++ struct/union/class.
CXXRecordDecl * getMostRecentDecl()
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
method_range methods() const
CXXRecordDecl * getDefinition() const
static CXXRecordDecl * CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, unsigned DependencyKind, bool IsGeneric, LambdaCaptureDefault CaptureDefault)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
void setLambdaContextDecl(Decl *ContextDecl)
Set the context declaration for a lambda class.
void setDescribedClassTemplate(ClassTemplateDecl *Template)
void setLambdaNumbering(LambdaNumbering Numbering)
Set the mangling numbers for a lambda class.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
CXXRecordDecl * getPreviousDecl()
static CXXReinterpretCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
A rewritten comparison expression that was originally written using operator syntax.
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
bool isReversed() const
Determine whether this expression was rewritten in reverse form.
An expression "T()" which creates an rvalue of a non-class type T.
TypeSourceInfo * getTypeSourceInfo() const
SourceLocation getRParenLoc() const
static CXXStaticCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, FPOptionsOverride FPO, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Represents a C++ functional cast expression that builds a temporary object.
static CXXTemporaryObjectExpr * Create(const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty, TypeSourceInfo *TSI, ArrayRef< Expr * > Args, SourceRange ParenOrBraceRange, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization)
TypeSourceInfo * getTypeSourceInfo() const
Represents a C++ temporary.
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
Represents the this expression in C++.
static CXXThisExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType Ty, bool IsImplicit)
SourceLocation getLocation() const
A C++ throw-expression (C++ [except.throw]).
const Expr * getSubExpr() const
SourceLocation getThrowLoc() const
bool isThrownVariableInScope() const
Determines whether the variable thrown by this expression (if any!) is within the innermost try block...
CXXTryStmt - A C++ try block, including all handlers.
SourceLocation getTryLoc() const
CXXCatchStmt * getHandler(unsigned i)
unsigned getNumHandlers() const
static CXXTryStmt * Create(const ASTContext &C, SourceLocation tryLoc, CompoundStmt *tryBlock, ArrayRef< Stmt * > handlers)
CompoundStmt * getTryBlock()
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
bool isTypeOperand() const
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Expr * getExprOperand() const
SourceRange getSourceRange() const LLVM_READONLY
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
bool isListInitialization() const
Determine whether this expression models list-initialization.
static CXXUnresolvedConstructExpr * Create(const ASTContext &Context, QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool IsListInit)
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
unsigned getNumArgs() const
Retrieve the number of arguments.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
ADLCallKind getADLCallKind() const
FPOptionsOverride getFPFeatures() const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
SourceLocation getRParenLoc() const
CaseStmt - Represent a case statement.
SourceLocation getEllipsisLoc() const
Get the location of the ... in a case statement of the form LHS ... RHS.
static CaseStmt * Create(const ASTContext &Ctx, Expr *lhs, Expr *rhs, SourceLocation caseLoc, SourceLocation ellipsisLoc, SourceLocation colonLoc)
Build a case statement.
SourceLocation getCaseLoc() const
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
path_iterator path_begin()
CastKind getCastKind() const
FPOptionsOverride getFPFeatures() const
CharUnits - This is an opaque type for sizes expressed in character units.
SourceLocation getLocation() const
unsigned getValue() const
CharacterLiteralKind getKind() const
How to handle import errors that occur when import of a child declaration of a DeclContext fails.
bool ignoreChildErrorOnParent(Decl *FromChildD) const
Determine if import failure of a child does not cause import failure of its parent.
ChildErrorHandlingStrategy(const Decl *FromD)
void handleChildImportResult(Error &ResultErr, Error &&ChildErr)
Process the import result of a child (of the current declaration).
ChildErrorHandlingStrategy(const DeclContext *FromDC)
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
SourceLocation getBuiltinLoc() const
bool isConditionDependent() const
bool isConditionTrue() const
isConditionTrue - Return whether the condition is true (i.e.
SourceLocation getRParenLoc() const
Declaration of a class template.
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
ClassTemplateDecl * getMostRecentDecl()
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary class pattern.
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a class template specialization, which refers to a class template with a given set of temp...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void setPointOfInstantiation(SourceLocation Loc)
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setExternKeywordLoc(SourceLocation Loc)
Sets the location of the extern keyword.
void setSpecializationKind(TemplateSpecializationKind TSK)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
SourceLocation getExternKeywordLoc() const
Gets the location of the extern keyword, if present.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this class template specialization is an instantiation of a template (rather than an explicit spec...
bool hasStrictPackMatch() const
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this class template specialization is actually an instantiation of the given class template...
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
QualType getElementType() const
CompoundAssignOperator - For compound assignments (e.g.
QualType getComputationLHSType() const
static CompoundAssignOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures, QualType CompLHSType=QualType(), QualType CompResultType=QualType())
QualType getComputationResultType() const
CompoundLiteralExpr - [C99 6.5.2.5].
SourceLocation getLParenLoc() const
const Expr * getInitializer() const
TypeSourceInfo * getTypeSourceInfo() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
SourceLocation getLBracLoc() const
bool hasStoredFPFeatures() const
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)
SourceLocation getRBracLoc() const
Declaration of a C++20 concept.
Expr * getConstraintExpr() const
A reference to a concept and its template args, as it appears in the code.
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
NamedDecl * getFoundDecl() const
const DeclarationNameInfo & getConceptNameInfo() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
TemplateDecl * getNamedConcept() const
SourceLocation getTemplateKWLoc() const
Represents the specialization of a concept - evaluates to a prvalue of type bool.
static ConceptSpecializationExpr * Create(const ASTContext &C, ConceptReference *ConceptRef, ImplicitConceptSpecializationDecl *SpecDecl, const ConstraintSatisfaction *Satisfaction)
ConceptReference * getConceptReference() const
const ImplicitConceptSpecializationDecl * getSpecializationDecl() const
const ASTConstraintSatisfaction & getSatisfaction() const
Get elaborated satisfaction info about the template arguments' satisfaction of the named concept.
ConditionalOperator - The ?
Expr * getCond() const
getCond - Return the expression representing the condition for the ?
const Expr * getSizeExpr() const
Return a pointer to the size expression.
llvm::APInt getSize() const
Return the constant array size as an APInt.
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
APValue getAPValueResult() const
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
llvm::SmallVector< UnsatisfiedConstraintRecord, 4 > Details
The substituted constraint expr, if the template arguments could be substituted into them,...
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
ContinueStmt - This represents a continue.
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
FPOptionsOverride getStoredFPFeaturesOrDefault() const
Get the store FPOptionsOverride or default if not stored.
SourceLocation getRParenLoc() const
getRParenLoc - Return the location of final right parenthesis.
static ConvertVectorExpr * Create(const ASTContext &C, Expr *SrcExpr, TypeSourceInfo *TI, QualType DstType, ExprValueKind VK, ExprObjectKind OK, SourceLocation BuiltinLoc, SourceLocation RParenLoc, FPOptionsOverride FPFeatures)
SourceLocation getBuiltinLoc() const
getBuiltinLoc - Return the location of the __builtin_convertvector token.
TypeSourceInfo * getTypeSourceInfo() const
getTypeSourceInfo - Return the destination type.
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
bool isCountInBytes() const
Expr * getCountExpr() const
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
AccessSpecifier getAccess() const
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
DeclContextLookupResult lookup_result
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDeclInternal(Decl *D)
Add the declaration D into this context, but suppress searches for external declarations with the sam...
bool containsDeclAndLoad(Decl *D) const
Checks whether a declaration is in this context.
void removeDecl(Decl *D)
Removes a declaration from this context.
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
void localUncachedLookup(DeclarationName Name, SmallVectorImpl< NamedDecl * > &Results)
A simplistic name lookup mechanism that performs name lookup into this declaration context without co...
static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls)
A reference to a declared variable, function, enum, etc.
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name,...
ArrayRef< TemplateArgumentLoc > template_arguments() const
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
bool hadMultipleCandidates() const
Returns true if this expression refers to a function that was resolved from an overloaded set having ...
SourceLocation getLocation() const
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
bool isImmediateEscalating() const
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
SourceLocation getEndLoc() const
const DeclGroupRef getDeclGroup() const
SourceLocation getBeginLoc() const LLVM_READONLY
A simple visitor class that helps create declaration visitors.
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEndLoc() const LLVM_READONLY
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
@ FOK_None
Not a friend object.
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration.
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
const char * getDeclKindName() const
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
@ IDNS_NonMemberOperator
This declaration is a C++ operator declared in a non-class context.
@ IDNS_TagFriend
This declaration is a friend class.
@ IDNS_Ordinary
Ordinary names.
@ IDNS_ObjCProtocol
Objective C @protocol.
@ IDNS_Namespace
Namespaces, declared with 'namespace foo {}'.
@ IDNS_OrdinaryFriend
This declaration is a friend function.
@ IDNS_Tag
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
void setImplicit(bool I=true)
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
bool isInAnonymousNamespace() const
SourceLocation getBeginLoc() const LLVM_READONLY
TranslationUnitDecl * getTranslationUnitDecl()
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
void setLexicalDeclContext(DeclContext *DC)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
const IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it.
static DeclarationName getUsingDirectiveName()
Returns the name for all C++ using-directives.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
@ CXXConversionFunctionName
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
NameKind getNameKind() const
Determine what kind of name this is.
bool isEmpty() const
Evaluates true when this declaration name is empty.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
SourceLocation getBeginLoc() const LLVM_READONLY
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
void setTypeSourceInfo(TypeSourceInfo *TI)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
TypeSourceInfo * getTypeSourceInfo() const
A decomposition declaration.
SourceLocation getDefaultLoc() const
Expr * getAddrSpaceExpr() const
QualType getPointeeType() const
SourceLocation getAttributeLoc() const
Expr * getNumBitsExpr() const
A qualified reference to a name whose declaration cannot yet be resolved.
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
ArrayRef< TemplateArgumentLoc > template_arguments() const
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Expr * getSizeExpr() const
Expr * getSizeExpr() const
SourceLocation getAttributeLoc() const
QualType getElementType() const
Expr * getColumnExpr() const
Expr * getRowExpr() const
SourceLocation getAttributeLoc() const
IdentifierOrOverloadedOperator getName() const
NestedNameSpecifier getQualifier() const
Return the nested name specifier that qualifies this name.
bool hasTemplateKeyword() const
Was this template name was preceeded by the template keyword?
Expr * getSizeExpr() const
VectorKind getVectorKind() const
SourceLocation getAttributeLoc() const
QualType getElementType() const
Represents a single C99 designator.
unsigned getArrayIndex() const
bool isFieldDesignator() const
static Designator CreateArrayRangeDesignator(unsigned Index, SourceLocation LBracketLoc, SourceLocation EllipsisLoc, SourceLocation RBracketLoc)
Creates a GNU array-range designator.
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
bool isArrayRangeDesignator() const
static Designator CreateArrayDesignator(unsigned Index, SourceLocation LBracketLoc, SourceLocation RBracketLoc)
Creates an array designator.
bool isArrayDesignator() const
SourceLocation getFieldLoc() const
SourceLocation getRBracketLoc() const
const IdentifierInfo * getFieldName() const
SourceLocation getEllipsisLoc() const
SourceLocation getDotLoc() const
SourceLocation getLBracketLoc() const
Represents a C99 designated initializer expression.
Expr * getSubExpr(unsigned Idx) const
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
MutableArrayRef< Designator > designators()
Expr * getInit() const
Retrieve the initializer value.
unsigned size() const
Returns the number of designators in this initializer.
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the '=' that precedes the initializer value itself, if present.
unsigned getNumSubExprs() const
Retrieve the total number of subexpressions in this designated initializer expression,...
static DesignatedInitExpr * Create(const ASTContext &C, ArrayRef< Designator > Designators, ArrayRef< Expr * > IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
A little helper class used to produce diagnostics.
DoStmt - This represents a 'do/while' stmt.
SourceLocation getWhileLoc() const
SourceLocation getDoLoc() const
SourceLocation getRParenLoc() const
Symbolic representation of a dynamic allocation.
Represents an empty-declaration.
An instance of this object exists for each enum constant that is defined.
llvm::APSInt getInitVal() const
const Expr * getInitExpr() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
void setIntegerType(QualType T)
Set the underlying integer type.
EnumDecl * getMostRecentDecl()
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
void completeDefinition(QualType NewType, QualType PromotionType, unsigned NumPositiveBits, unsigned NumNegativeBits)
When created, the EnumDecl corresponds to a forward-declared enum.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
EnumDecl * getDefinition() const
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum.
QualType getPromotionType() const
Return the integer type that enumerators should promote to.
ExplicitCastExpr - An explicit cast written in the source code.
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
Store information needed for an explicit specifier.
ExplicitSpecKind getKind() const
const Expr * getExpr() const
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
bool cleanupsHaveSideEffects() const
ArrayRef< CleanupObject > getObjects() const
unsigned getNumObjects() const
llvm::PointerUnion< BlockDecl *, CompoundLiteralExpr * > CleanupObject
The type of objects that are kept in the cleanup.
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
ExprDependence getDependence() const
An expression trait intrinsic.
SourceLocation getBeginLoc() const LLVM_READONLY
Expr * getQueriedExpression() const
ExpressionTrait getTrait() const
SourceLocation getEndLoc() const LLVM_READONLY
virtual void CompleteType(TagDecl *Tag)
Gives the external AST source an opportunity to complete an incomplete type.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
bool isMutable() const
Determines whether this field is mutable (C++ only).
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
void setInClassInitializer(Expr *NewInit)
Set the C++11 in-class initializer for this member.
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
const VariableArrayType * getCapturedVLAType() const
Get the captured variable length array type.
void setCapturedVLAType(const VariableArrayType *VLAType)
Set the captured variable length array type for this field.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Implements support for file system lookup, file system caching, and directory search management.
SourceLocation getLocation() const
Retrieve the location of the literal.
llvm::APInt getValue() const
Returns an internal integer representation of the literal.
SourceLocation getLocation() const
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
llvm::APFloat getValue() const
ForStmt - This represents a 'for (init;cond;inc)' stmt.
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
SourceLocation getRParenLoc() const
SourceLocation getForLoc() const
SourceLocation getLParenLoc() const
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
SourceLocation getEllipsisLoc() const
Retrieves the location of the '...', if present.
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
const Expr * getSubExpr() const
static DefaultedOrDeletedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups, StringLiteral *DeletedMessage=nullptr)
Represents a function declaration or definition.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
ConstexprSpecKind getConstexprKind() const
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
void setIsPureVirtual(bool P=true)
void setDefaultedOrDeletedInfo(DefaultedOrDeletedFunctionInfo *Info)
void setFriendConstraintRefersToEnclosingTemplate(bool V=true)
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
StringLiteral * getDeletedMessage() const
Get the message that indicates why this function was deleted.
bool UsesFPIntrin() const
Determine whether the function was declared in source context that requires constrained FP intrinsics...
SourceLocation getDefaultLoc() const
ArrayRef< ParmVarDecl * > parameters() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
bool hasWrittenPrototype() const
Whether this function has a written prototype.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
void setDefaultLoc(SourceLocation NewLoc)
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
@ TK_MemberSpecialization
@ TK_DependentNonTemplate
@ TK_FunctionTemplateSpecialization
@ TK_DependentFunctionTemplateSpecialization
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool FriendConstraintRefersToEnclosingTemplate() const
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
void setInstantiatedFromDecl(FunctionDecl *FD)
Specify that this function declaration was instantiated from a FunctionDecl FD.
bool isDeletedAsWritten() const
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo *TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization.
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
FunctionDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
void setIsDestroyingOperatorDelete(bool IsDestroyingDelete)
FunctionDecl * getDefinition()
Get the definition for this declaration.
bool isTypeAwareOperatorNewOrDelete() const
Determine whether this is a type aware operator new or delete.
void setIsTypeAwareOperatorNewOrDelete(bool IsTypeAwareOperator=true)
void setRangeEnd(SourceLocation E)
bool isDefaulted() const
Whether this function is defaulted.
FunctionDecl * getInstantiatedFromDecl() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
void setDefaulted(bool D=true)
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
void setDeletedAsWritten(bool D=true, StringLiteral *Message=nullptr)
void setExplicitlyDefaulted(bool ED=true)
State that this function is explicitly defaulted.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
DeclarationNameInfo getNameInfo() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Represents a prototype with parameter type info, e.g.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > exceptions() const
ArrayRef< QualType > param_types() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary pattern.
FunctionTemplateDecl * getMostRecentDecl()
ExtInfo getExtInfo() const
QualType getReturnType() const
This represents a GCC inline-assembly statement extension.
unsigned getNumLabels() const
SourceLocation getRParenLoc() const
IdentifierInfo * getInputIdentifier(unsigned i) const
const Expr * getOutputConstraintExpr(unsigned i) const
const Expr * getInputConstraintExpr(unsigned i) const
IdentifierInfo * getOutputIdentifier(unsigned i) const
const Expr * getAsmStringExpr() const
Expr * getClobberExpr(unsigned i)
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a C11 generic selection.
TypeSourceInfo * getControllingType()
Return the controlling type of this generic selection expression.
ArrayRef< Expr * > getAssocExprs() const
bool isExprPredicate() const
Whether this generic selection uses an expression as its controlling argument.
SourceLocation getGenericLoc() const
SourceLocation getRParenLoc() const
unsigned getResultIndex() const
The zero-based index of the result expression's generic association in the generic selection's associ...
SourceLocation getDefaultLoc() const
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression accepting an expression predicate.
bool isResultDependent() const
Whether this generic selection is result-dependent.
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
ArrayRef< TypeSourceInfo * > getAssocTypeSourceInfos() const
GotoStmt - This represents a direct goto.
SourceLocation getLabelLoc() const
SourceLocation getGotoLoc() const
LabelDecl * getLabel() const
One of these records is kept for each identifier that is lexed.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
void setBuiltinID(unsigned ID)
StringRef getName() const
Return the actual identifier string.
IfStmt - This represents an if/then/else.
static IfStmt * Create(const ASTContext &Ctx, SourceLocation IL, IfStatementKind Kind, Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LPL, SourceLocation RPL, Stmt *Then, SourceLocation EL=SourceLocation(), Stmt *Else=nullptr)
Create an IfStmt.
SourceLocation getIfLoc() const
IfStatementKind getStatementKind() const
SourceLocation getElseLoc() const
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
VarDecl * getConditionVariable()
Retrieve the variable declared in this "if" statement, if any.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
const Expr * getSubExpr() const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
ArrayRef< TemplateArgument > getTemplateArguments() const
ImplicitParamKind getParameterKind() const
Returns the implicit parameter kind.
Represents an implicitly-generated value initialization of an object of a given type.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Represents a field injected from an anonymous union/struct into the parent scope.
unsigned getChainingSize() const
ArrayRef< NamedDecl * > chain() const
IndirectGotoStmt - This represents an indirect goto.
SourceLocation getGotoLoc() const
SourceLocation getStarLoc() const
Description of a constructor that was inherited from a base class.
CXXConstructorDecl * getConstructor() const
ConstructorUsingShadowDecl * getShadowDecl() const
Describes an C or C++ initializer list.
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
void setSyntacticForm(InitListExpr *Init)
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
unsigned getNumInits() const
SourceLocation getLBraceLoc() const
void setArrayFiller(Expr *filler)
InitListExpr * getSyntacticForm() const
bool hadArrayRangeDesignator() const
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
SourceLocation getRBraceLoc() const
void setInitializedFieldInUnion(FieldDecl *FD)
ArrayRef< Expr * > inits()
void sawArrayRangeDesignator(bool ARD=true)
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'.
SourceLocation getLocation() const
Retrieve the location of the literal.
ElaboratedTypeKeyword getKeyword() const
Represents the declaration of a label.
LabelStmt * getStmt() const
void setStmt(LabelStmt *T)
LabelStmt - Represents a label, which has a substatement.
LabelDecl * getDecl() const
SourceLocation getIdentLoc() const
Describes the capture of a variable or of this, or of a C++1y init-capture.
bool capturesVariable() const
Determine whether this capture handles a variable.
bool isPackExpansion() const
Determine whether this capture is a pack expansion, which captures a function parameter pack.
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis for a capture that is a pack expansion.
LambdaCaptureKind getCaptureKind() const
Determine the kind of capture.
ValueDecl * getCapturedVar() const
Retrieve the declaration of the local variable being captured.
bool isImplicit() const
Determine whether this was an implicit capture (not written between the square brackets introducing t...
SourceLocation getLocation() const
Retrieve the source location of the capture.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
static LambdaExpr * Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc, bool ExplicitParams, bool ExplicitResultType, ArrayRef< Expr * > CaptureInits, SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack)
Construct a new lambda expression.
SourceLocation getEndLoc() const LLVM_READONLY
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
SourceRange getIntroducerRange() const
Retrieve the source range covering the lambda introducer, which contains the explicit capture list su...
unsigned capture_size() const
Determine the number of captures in this lambda.
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
SourceLocation getCaptureDefaultLoc() const
Retrieve the location of this lambda's capture-default, if any.
llvm::iterator_range< capture_init_iterator > capture_inits()
Retrieve the initialization expressions for this lambda's captures.
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
unsigned getManglingNumber() const
Expr * getTemporaryExpr()
Retrieve the expression to which the temporary materialization conversion was applied.
ValueDecl * getExtendingDecl()
Represents a linkage specification.
void setRBraceLoc(SourceLocation L)
LinkageSpecLanguageIDs getLanguage() const
Return the language specified by this linkage specification.
SourceLocation getExternLoc() const
SourceLocation getRBraceLoc() const
bool hasBraces() const
Determines whether this linkage specification had braces in its syntactic form.
Represents the results of name lookup.
QualType getUnderlyingType() const
const IdentifierInfo * getMacroIdentifier() const
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
bool isBoundToLvalueReference() const
Determine whether this materialized temporary is bound to an lvalue reference; otherwise,...
LifetimeExtendedTemporaryDecl * getLifetimeExtendedTemporaryDecl()
QualType getElementType() const
Returns type of the elements being stored in the matrix.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ArrayRef< TemplateArgumentLoc > template_arguments() const
SourceLocation getOperatorLoc() const
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
NestedNameSpecifierLoc getQualifierLoc() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name,...
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
static MemberExpr * Create(const ASTContext &C, Expr *Base, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *MemberDecl, DeclAccessPair FoundDecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, QualType T, ExprValueKind VK, ExprObjectKind OK, NonOdrUseReason NOUR)
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
NestedNameSpecifier getQualifier() const
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Note: this can trigger extra deserialization when external AST sources are used.
QualType getPointeeType() const
Provides information a specialization of a member of a class template, which may be a member function...
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
This represents a decl that may have a name.
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Represents a C++ namespace alias.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
SourceLocation getAliasLoc() const
Returns the location of the alias name, i.e.
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Represent a C++ namespace.
SourceLocation getRBraceLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isInline() const
Returns true if this is an inline namespace declaration.
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace that inhabits this namespace, if any.
bool isNested() const
Returns true if this is a nested namespace declaration.
void setRBraceLoc(SourceLocation L)
Class that aids in the construction of nested-name-specifiers along with source-location information ...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
A C++ nested-name-specifier augmented with source location information.
NamespaceAndPrefixLoc getAsNamespaceAndPrefix() const
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
TypeLoc castAsTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
CXXRecordDecl * getAsMicrosoftSuper() const
NamespaceAndPrefix getAsNamespaceAndPrefix() const
const Type * getAsType() const
Kind
The kind of specifier that completes this nested name specifier.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
unsigned getDepth() const
Get the nesting depth of the template parameter.
NullStmt - This is the null statement ";": C99 6.8.3p3.
bool hasLeadingEmptyMacro() const
SourceLocation getSemiLoc() const
Represents Objective-C's @catch statement.
const VarDecl * getCatchParamDecl() const
const Stmt * getCatchBody() const
SourceLocation getAtCatchLoc() const
SourceLocation getRParenLoc() const
Represents Objective-C's @finally statement.
const Stmt * getFinallyBody() const
SourceLocation getAtFinallyLoc() const
Represents Objective-C's @synchronized statement.
const Expr * getSynchExpr() const
const CompoundStmt * getSynchBody() const
SourceLocation getAtSynchronizedLoc() const
Represents Objective-C's @throw statement.
const Expr * getThrowExpr() const
SourceLocation getThrowLoc() const LLVM_READONLY
Represents Objective-C's @try ... @catch ... @finally statement.
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
static ObjCAtTryStmt * Create(const ASTContext &Context, SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt)
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
const Stmt * getTryBody() const
Retrieve the @try body.
SourceLocation getAtTryLoc() const
Retrieve the location of the @ in the @try.
Represents Objective-C's @autoreleasepool Statement.
SourceLocation getAtLoc() const
const Stmt * getSubStmt() const
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
ObjCCategoryDecl - Represents a category declaration.
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this category.
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
ObjCCategoryImplDecl * getImplementation() const
ObjCInterfaceDecl * getClassInterface()
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
protocol_iterator protocol_end() const
ObjCProtocolList::loc_iterator protocol_loc_iterator
SourceLocation getIvarLBraceLoc() const
SourceLocation getIvarRBraceLoc() const
protocol_loc_iterator protocol_loc_begin() const
protocol_iterator protocol_begin() const
void setImplementation(ObjCCategoryImplDecl *ImplD)
ObjCProtocolList::iterator protocol_iterator
SourceLocation getCategoryNameLoc() const
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
SourceLocation getCategoryNameLoc() const
ObjCCategoryDecl * getCategoryDecl() const
SourceLocation getAtStartLoc() const
Represents Objective-C's collection statement.
SourceLocation getForLoc() const
SourceLocation getRParenLoc() const
const ObjCInterfaceDecl * getClassInterface() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
SourceLocation getIvarRBraceLoc() const
SourceLocation getSuperClassLoc() const
const ObjCInterfaceDecl * getSuperClass() const
SourceLocation getIvarLBraceLoc() const
Represents an ObjC class declaration.
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
bool isImplicitInterfaceDecl() const
isImplicitInterfaceDecl - check that this is an implicitly declared ObjCInterfaceDecl node.
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class.
ObjCCategoryDecl * FindCategoryDeclaration(const IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
protocol_loc_iterator protocol_loc_begin() const
void setImplementation(ObjCImplementationDecl *ImplD)
known_categories_range known_categories() const
void setSuperClass(TypeSourceInfo *superClass)
protocol_iterator protocol_end() const
SourceLocation getSuperClassLoc() const
Retrieve the starting location of the superclass.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this class.
ObjCProtocolList::iterator protocol_iterator
ObjCImplementationDecl * getImplementation() const
protocol_iterator protocol_begin() const
ObjCProtocolList::loc_iterator protocol_loc_iterator
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
ObjCInterfaceDecl * getSuperClass() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
TypeSourceInfo * getSuperClassTInfo() const
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
ObjCIvarDecl - Represents an ObjC instance variable.
AccessControl getAccessControl() const
bool getSynthesize() const
ObjCMethodDecl - Represents an instance or class method declaration.
ImplicitParamDecl * getSelfDecl() const
ArrayRef< ParmVarDecl * > parameters() const
unsigned param_size() const
bool isPropertyAccessor() const
param_const_iterator param_end() const
param_const_iterator param_begin() const
SourceLocation getEndLoc() const LLVM_READONLY
TypeSourceInfo * getReturnTypeSourceInfo() const
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs={})
Sets the method's parameters and selector source locations.
bool isSynthesizedAccessorStub() const
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type.
bool isInstanceMethod() const
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implicit parameters.
QualType getReturnType() const
ParmVarDecl *const * param_iterator
ObjCImplementationControl getImplementationControl() const
ObjCInterfaceDecl * getClassInterface()
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Represents one property declaration in an Objective-C interface.
void setSetterName(Selector Sel, SourceLocation Loc=SourceLocation())
SourceLocation getGetterNameLoc() const
ObjCMethodDecl * getGetterMethodDecl() const
bool isInstanceProperty() const
ObjCMethodDecl * getSetterMethodDecl() const
SourceLocation getSetterNameLoc() const
SourceLocation getAtLoc() const
void setPropertyAttributes(ObjCPropertyAttribute::Kind PRVal)
ObjCIvarDecl * getPropertyIvarDecl() const
Selector getSetterName() const
TypeSourceInfo * getTypeSourceInfo() const
void setPropertyAttributesAsWritten(ObjCPropertyAttribute::Kind PRVal)
Selector getGetterName() const
void setPropertyIvarDecl(ObjCIvarDecl *Ivar)
SourceLocation getLParenLoc() const
void setSetterMethodDecl(ObjCMethodDecl *gDecl)
ObjCPropertyAttribute::Kind getPropertyAttributesAsWritten() const
ObjCPropertyAttribute::Kind getPropertyAttributes() const
void setGetterName(Selector Sel, SourceLocation Loc=SourceLocation())
PropertyControl getPropertyImplementation() const
void setGetterMethodDecl(ObjCMethodDecl *gDecl)
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
ObjCIvarDecl * getPropertyIvarDecl() const
SourceLocation getPropertyIvarDeclLoc() const
Kind getPropertyImplementation() const
ObjCPropertyDecl * getPropertyDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents an Objective-C protocol declaration.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
void startDefinition()
Starts the definition of this Objective-C protocol.
ObjCProtocolList::iterator protocol_iterator
protocol_iterator protocol_begin() const
ObjCProtocolList::loc_iterator protocol_loc_iterator
protocol_iterator protocol_end() const
protocol_loc_iterator protocol_loc_begin() const
Represents the declaration of an Objective-C type parameter.
unsigned getIndex() const
Retrieve the index into its type parameter list.
const Type * getTypeForDecl() const
SourceLocation getColonLoc() const
Retrieve the location of the ':' separating the type parameter name from the explicitly-specified bou...
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
SourceLocation getVarianceLoc() const
Retrieve the location of the variance keyword.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
SourceLocation getRAngleLoc() const
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl * > typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
SourceLocation getLAngleLoc() const
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
Expr * getIndexExpr(unsigned Idx)
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
const OffsetOfNode & getComponent(unsigned Idx) const
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr * > exprs, SourceLocation RParenLoc)
TypeSourceInfo * getTypeSourceInfo() const
unsigned getNumExpressions() const
SourceLocation getRParenLoc() const
Return the location of the right parentheses.
unsigned getNumComponents() const
Helper class for OffsetOfExpr.
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
FieldDecl * getField() const
For a field offsetof node, returns the field.
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
@ Array
An index into an array.
@ Identifier
A field in a dependent type, known only by its name.
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
SourceLocation getBeginLoc() const LLVM_READONLY
Kind getKind() const
Determine what kind of offsetof node this is.
SourceLocation getEndLoc() const LLVM_READONLY
CXXBaseSpecifier * getBase() const
For a base class node, returns the base specifier.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
SourceLocation getLocation() const
Retrieve the location of this expression.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
SourceLocation getNameLoc() const
Gets the location of the name.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
llvm::iterator_range< decls_iterator > decls() const
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
DeclarationName getName() const
Gets the name looked up.
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
ArrayRef< TemplateArgumentLoc > template_arguments() const
A structure for storing the information associated with an overloaded template name.
Represents a C++11 pack expansion that produces a sequence of expressions.
Expr * getPattern()
Retrieve the pattern of the pack expansion.
UnsignedOrNone getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated,...
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
ParenExpr - This represents a parenthesized expression, e.g.
SourceLocation getLParen() const
Get the location of the left parentheses '('.
const Expr * getSubExpr() const
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
ArrayRef< Expr * > exprs()
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr * > Exprs, SourceLocation RParenLoc)
Create a paren list.
unsigned getNumExprs() const
Return the number of expressions in this paren list.
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
QualType getInnerType() const
Represents a parameter to a function.
bool isKNRPromoted() const
True if the value passed to this parameter must undergo K&R-style default argument promotion:
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
void setObjCDeclQualifier(ObjCDeclQualifier QTVal)
void setDefaultArg(Expr *defarg)
SourceLocation getExplicitObjectParamThisLoc() const
void setUnparsedDefaultArg()
Specify that this parameter has an unparsed default argument.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
void setUninstantiatedDefaultArg(Expr *arg)
bool isObjCMethodParameter() const
ObjCDeclQualifier getObjCDeclQualifier() const
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
bool hasUninstantiatedDefaultArg() const
void setObjCMethodScopeInfo(unsigned parameterIndex)
bool hasInheritedDefaultArg() const
void setKNRPromoted(bool promoted)
void setExplicitObjectParameterLoc(SourceLocation Loc)
Expr * getUninstantiatedDefaultArg()
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
unsigned getFunctionScopeDepth() const
void setHasInheritedDefaultArg(bool I=true)
QualType getElementType() const
QualType getPointeeType() const
[C99 6.4.2.2] - A predefined identifier such as func.
SourceLocation getBeginLoc() const
static PredefinedExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType FNTy, PredefinedIdentKind IK, bool IsTransparent, StringLiteral *SL)
Create a PredefinedExpr.
bool isTransparent() const
PredefinedIdentKind getIdentKind() const
StringLiteral * getFunctionName()
Stores the type being destroyed by a pseudo-destructor expression.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
unsigned getResultExprIndex() const
Return the index of the result-bearing expression into the semantics expressions, or PseudoObjectExpr...
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr * > semantic, unsigned resultIndex)
ArrayRef< Expr * > semantics()
unsigned getNumSemanticExprs() const
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Represents a template name as written in source code.
NestedNameSpecifier getQualifier() const
Return the nested name specifier that qualifies this name.
TemplateName getUnderlyingTemplate() const
Return the underlying template name.
bool hasTemplateKeyword() const
Whether the template name was prefixed by the "template" keyword.
Represents a struct/union/class.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
void setAnonymousStructOrUnion(bool Anon)
field_range fields() const
RecordDecl * getMostRecentDecl()
virtual void completeDefinition()
Note that the definition of this type is now complete.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Provides common interface for the Decls that can be redeclared.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
QualType getPointeeTypeAsWritten() const
Represents the body of a requires-expression.
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
SourceLocation getRBraceLoc() const
SourceLocation getRequiresKWLoc() const
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
RequiresExprBodyDecl * getBody() const
ArrayRef< concepts::Requirement * > getRequirements() const
ArrayRef< ParmVarDecl * > getLocalParameters() const
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
SourceLocation getReturnLoc() const
const VarDecl * getNRVOCandidate() const
Retrieve the variable that might be used for the named return value optimization.
static ReturnStmt * Create(const ASTContext &Ctx, SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)
Create a return statement.
Smart pointer class that efficiently represents Objective-C method names.
const IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
bool isNull() const
Determine whether this is the empty selector.
unsigned getNumArgs() const
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Expr ** getSubExprs()
Retrieve the array of expressions.
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
SourceLocation getRParenLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents an expression that computes the length of a parameter pack.
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof... expression, such as is produced f...
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
NamedDecl * getPack() const
Retrieve the parameter pack.
unsigned getPackLength() const
Retrieve the length of the parameter pack.
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
SourceLocation getBeginLoc() const
const DeclContext * getParentContext() const
If the SourceLocExpr has been resolved return the subexpression representing the resolved value.
SourceLocation getEndLoc() const
SourceLocIdentKind getIdentKind() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
FileIDAndOffset getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
bool isWrittenInBuiltinFile(SourceLocation Loc) const
Returns whether Loc is located in a <built-in> file.
FileID createFileID(FileEntryRef SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0)
Create a new FileID that represents the specified file being #included from the specified IncludePosi...
SourceLocation getComposedLoc(FileID FID, unsigned Offset) const
Form a SourceLocation from a FileID and Offset pair.
FileManager & getFileManager() const
FileID getMainFileID() const
Returns the FileID of the main source file.
unsigned getFileIDSize(FileID FID) const
The size of the SLocEntry that FID represents.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
SourceLocation createExpansionLoc(SourceLocation SpellingLoc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned Length, bool ExpansionIsTokenRange=true, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0)
Creates an expansion SLocEntry for a macro use.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
SourceLocation createMacroArgExpansionLoc(SourceLocation SpellingLoc, SourceLocation ExpansionLoc, unsigned Length)
Creates an expansion SLocEntry for the substitution of an argument into a function-like macro's body.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
One instance of this struct is kept for every file loaded or used.
Each ExpansionInfo encodes the expansion location - where the token was ultimately expanded,...
SourceLocation getExpansionLocStart() const
bool isExpansionTokenRange() const
SourceLocation getSpellingLoc() const
bool isMacroArgExpansion() const
SourceLocation getExpansionLocEnd() const
const ContentCache & getContentCache() const
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
SourceLocation getIncludeLoc() const
This is a discriminated union of FileInfo and ExpansionInfo.
const FileInfo & getFile() const
const ExpansionInfo & getExpansion() const
Represents a C++11 static_assert declaration.
SourceLocation getRParenLoc() const
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
CompoundStmt * getSubStmt()
unsigned getTemplateDepth() const
SourceLocation getRParenLoc() const
SourceLocation getLParenLoc() const
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Stmt - This represents one statement.
child_iterator child_begin()
StmtClass getStmtClass() const
child_iterator child_end()
const char * getStmtClassName() const
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
tokloc_iterator tokloc_begin() const
tokloc_iterator tokloc_end() const
StringLiteralKind getKind() const
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind, bool Pascal, QualType Ty, ArrayRef< SourceLocation > Locs)
This is the "fully general" constructor that allows representation of strings formed from one or more...
StringRef getBytes() const
Allow access to clients that need the byte representation, such as ASTWriterStmt::VisitStringLiteral(...
unsigned getNumConcatenated() const
getNumConcatenated - Get the number of string literal tokens that were concatenated in translation ph...
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
UnsignedOrNone getPackIndex() const
bool isReferenceParameter() const
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
SourceLocation getNameLoc() const
Expr * getReplacement() const
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
SourceLocation getParameterPackLocation() const
Retrieve the location of the parameter pack name.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
A structure for storing an already-substituted template template parameter pack.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
TemplateArgument getArgumentPack() const
Retrieve the template template argument pack with which this parameter was substituted.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
A structure for storing the information associated with a substituted template template parameter.
TemplateName getReplacement() const
UnsignedOrNone getPackIndex() const
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
void setNextSwitchCase(SwitchCase *SC)
SourceLocation getColonLoc() const
const SwitchCase * getNextSwitchCase() const
SwitchStmt - This represents a 'switch' stmt.
SourceLocation getSwitchLoc() const
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
static SwitchStmt * Create(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a switch statement.
VarDecl * getConditionVariable()
Retrieve the variable declared in this "switch" statement, if any.
SwitchCase * getSwitchCaseList()
Represents the declaration of a struct/union/class/enum.
SourceRange getBraceRange() const
bool isBeingDefined() const
Return true if this decl is currently being defined.
TagDecl * getDefinition() const
Returns the TagDecl that actually defines this struct/union/class/enum.
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
TypedefNameDecl * getTypedefNameForAnonDecl() const
void startDefinition()
Starts the definition of this tag declaration.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
TagKind getTagKind() const
void setBraceRange(SourceRange R)
void setCompleteDefinition(bool V=true)
True if this decl has its body fully specified.
A convenient class for passing around template argument information.
SourceLocation getRAngleLoc() const
void addArgument(const TemplateArgumentLoc &Loc)
ArrayRef< TemplateArgumentLoc > arguments() const
SourceLocation getLAngleLoc() const
A template argument list.
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Location wrapper for a TemplateArgument.
TemplateArgumentLocInfo getLocInfo() const
const TemplateArgument & getArgument() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
QualType getParamTypeForDecl() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
UnsignedOrNone getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce,...
QualType getAsType() const
Retrieve the type for a type template argument.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
QualType getIntegralType() const
Retrieve the type of the integral value.
bool getIsDefaulted() const
If returns 'true', this TemplateArgument corresponds to a default template parameter.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isCanonicalExpr() const
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ OverloadedTemplate
A set of overloaded template declarations.
@ Template
A single template declaration.
@ DependentTemplate
A dependent template name that has not been resolved to a template (or set of templates).
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
@ DeducedTemplate
A template name that refers to another TemplateName with deduced default arguments.
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
@ AssumedTemplate
An unqualified-id that has been assumed to name a function template that will be found by ADL.
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
SourceLocation getTemplateLoc() const
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
bool wasDeclaredWithTypename() const
Whether this template template parameter was declared with the 'typename' keyword.
TemplateNameKind templateParameterKind() const
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
unsigned getDepth() const
Get the nesting depth of the template parameter.
Declaration of a template type parameter.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
unsigned getIndex() const
Retrieve the index of the template parameter.
void setTypeConstraint(ConceptReference *CR, Expr *ImmediatelyDeclaredConstraint, UnsignedOrNone ArgPackSubstIndex)
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
bool isParameterPack() const
Returns whether this is a parameter pack.
unsigned getDepth() const
Retrieve the depth of the template parameter.
The top declaration context.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Declaration of an alias template.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
SourceLocation getBeginLoc() const LLVM_READONLY
Symbolic representation of typeid(T) for some type T.
const Type * getType() const
SourceLocation getBeginLoc() const
Get the begin source location.
TypeOfKind getKind() const
Returns the kind of 'typeof' type this is.
Expr * getUnderlyingExpr() const
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
bool getBoolValue() const
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
static TypeTraitExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, TypeTrait Kind, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc, bool Value)
Create a new type trait expression.
SourceLocation getEndLoc() const LLVM_READONLY
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
TypeTrait getTrait() const
Determine which type trait this expression uses.
SourceLocation getBeginLoc() const LLVM_READONLY
const APValue & getAPValue() const
bool isStoredAsBoolean() const
ExpectedType Visit(const Type *T)
The base class of the type hierarchy.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isCanonicalUnqualified() const
Determines if this type would be canonical if it had no further qualification.
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Base class for declarations which introduce a typedef-name.
TypeSourceInfo * getTypeSourceInfo() const
QualType getUnderlyingType() const
TypedefNameDecl * getDecl() const
NestedNameSpecifier getQualifier() const
bool typeMatchesDecl() const
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
SourceLocation getRParenLoc() const
SourceLocation getOperatorLoc() const
bool isArgumentType() const
TypeSourceInfo * getArgumentTypeInfo() const
UnaryExprOrTypeTrait getKind() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Expr * getSubExpr() const
bool hasStoredFPFeatures() const
Is FPFeatures in Trailing Storage?
FPOptionsOverride getStoredFPFeatures() const
Get FPFeatures from trailing storage.
static UnaryOperator * CreateEmpty(const ASTContext &C, bool hasFPFeatures)
bool canOverflow() const
Returns true if the unary operator can cause an overflow.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
SourceLocation getOperatorLoc() const
Retrieve the location of the '->' or '.' operator.
bool hasUnresolvedUsing() const
Determine whether the lookup results contain an unresolved using declaration.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
static UnresolvedMemberExpr * Create(const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
void addDecl(NamedDecl *D)
A set of unresolved declarations.
NestedNameSpecifier getQualifier() const
UnresolvedUsingTypenameDecl * getDecl() const
Represents a dependent using declaration which was marked with typename.
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Represents a dependent using declaration which was not marked with typename.
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
DeclarationNameInfo getNameInfo() const
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Represents a C++ using-declaration.
bool hasTypename() const
Return true if the using declaration has 'typename'.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
DeclarationNameInfo getNameInfo() const
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Represents C++ using-directive.
SourceLocation getUsingLoc() const
Return the location of the using keyword.
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
SourceLocation getIdentLocation() const
Returns the location of this using declaration's identifier.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Represents a C++ using-enum-declaration.
SourceLocation getEnumLoc() const
The source location of the 'enum' keyword.
TypeSourceInfo * getEnumType() const
SourceLocation getUsingLoc() const
The source location of the 'using' keyword.
Represents a pack of using declarations that a single using-declarator pack-expanded into.
NamedDecl * getInstantiatedFromUsingDecl() const
Get the using declaration from which this was instantiated.
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
UsingShadowDecl * getDecl() const
NestedNameSpecifier getQualifier() const
Represents a call to the builtin function __builtin_va_arg.
TypeSourceInfo * getWrittenTypeInfo() const
SourceLocation getBuiltinLoc() const
SourceLocation getRParenLoc() const
bool isMicrosoftABI() const
Returns whether this is really a Win64 ABI va_arg expression.
const Expr * getSubExpr() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
VarDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
bool isInlineSpecified() const
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
EvaluatedStmt * getEvaluatedStmt() const
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form,...
void setInlineSpecified()
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization,...
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
void setTSCSpec(ThreadStorageClassSpecifier TSC)
bool isInline() const
Whether this variable is (C++1z) inline.
ThreadStorageClassSpecifier getTSCSpec() const
const Expr * getInit() const
void setConstexpr(bool IC)
void setDescribedVarTemplate(VarTemplateDecl *Template)
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void setImplicitlyInline()
VarDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Declaration of a variable template.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary variable pattern.
VarTemplateDecl * getMostRecentDecl()
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
void setSpecializationKind(TemplateSpecializationKind TSK)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
void setPointOfInstantiation(SourceLocation Loc)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
VarTemplateSpecializationDecl * getMostRecentDecl()
Expr * getSizeExpr() const
unsigned getNumElements() const
VectorKind getVectorKind() const
QualType getElementType() const
WhileStmt - This represents a 'while' stmt.
SourceLocation getWhileLoc() const
SourceLocation getRParenLoc() const
VarDecl * getConditionVariable()
Retrieve the variable declared in this "while" statement, if any.
SourceLocation getLParenLoc() const
static WhileStmt * Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body, SourceLocation WL, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a while statement.
A requires-expression requirement which queries the validity and properties of an expression ('simple...
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
ConceptSpecializationExpr * getReturnTypeRequirementSubstitutedConstraintExpr() const
const ReturnTypeRequirement & getReturnTypeRequirement() const
SatisfactionStatus getSatisfactionStatus() const
SourceLocation getNoexceptLoc() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
bool hasInvalidConstraint() const
Expr * getConstraintExpr() const
StringRef getInvalidConstraintEntity()
A static requirement that can be used in a requires-expression to check properties of types and expre...
RequirementKind getKind() const
A requires-expression requirement which queries the existence of a type name or type template special...
bool isSubstitutionFailure() const
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
TypeSourceInfo * getType() const
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isa(CodeGen::Address addr)
llvm::Expected< SourceLocation > ExpectedSLoc
StructuralEquivalenceKind
Whether to perform a normal or minimal equivalence check.
llvm::Expected< const Type * > ExpectedTypePtr
CanThrowResult
Possible results from evaluation of a noexcept expression.
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
std::pair< FileID, unsigned > FileIDAndOffset
llvm::Expected< DeclarationName > ExpectedName
llvm::Expected< Decl * > ExpectedDecl
@ Property
The type of a property.
@ Result
The result type of a method or function.
llvm::Expected< QualType > ExpectedType
@ Template
We are parsing a template declaration.
@ VarTemplate
The name was classified as a variable template name.
std::pair< SourceLocation, StringRef > ConstraintSubstitutionDiagnostic
Unsatisfied constraint expressions if the template arguments could be substituted into them,...
CastKind
CastKind - The kind of operation required for a conversion.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
llvm::SmallVector< Decl *, 2 > getCanonicalForwardRedeclChain(Decl *D)
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
llvm::Expected< Expr * > ExpectedExpr
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
U cast(CodeGen::Address addr)
bool isLambdaMethod(const DeclContext *DC)
llvm::Expected< Stmt * > ExpectedStmt
static void updateFlags(const Decl *From, Decl *To)
Used as return type of getFriendCountAndPosition.
unsigned int IndexOfDecl
Index of the specific FriendDecl.
unsigned int TotalCount
Number of similar looking friends.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
const UnsatisfiedConstraintRecord * end() const
static ASTConstraintSatisfaction * Rebuild(const ASTContext &C, const ASTConstraintSatisfaction &Satisfaction)
const UnsatisfiedConstraintRecord * begin() const
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
const Expr * ConstraintExpr
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setCXXOperatorNameRange(SourceRange R)
setCXXOperatorNameRange - Sets the range of the operator name (without the operator keyword).
SourceRange getCXXOperatorNameRange() const
getCXXOperatorNameRange - Gets the range of the operator name (without the operator keyword).
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
SourceLocation getCXXLiteralOperatorNameLoc() const
getCXXLiteralOperatorNameLoc - Returns the location of the literal operator name (not the operator ke...
Structure used to store a statement, the constant value to which it was evaluated (if any),...
bool HasConstantDestruction
Whether this variable is known to have constant destruction.
bool HasConstantInitialization
Whether this variable is known to have constant initialization.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
RefQualifierKind RefQualifier
unsigned HasTrailingReturn
FunctionType::ExtInfo ExtInfo
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
NestedNameSpecifierLoc Prefix
const NamespaceBaseDecl * Namespace
bool IsEquivalent(Decl *D1, Decl *D2)
Determine whether the two declarations are structurally equivalent.
Location information for a TemplateArgument.
SourceLocation getTemplateEllipsisLoc() const
SourceLocation getTemplateKwLoc() const
TypeSourceInfo * getAsTypeSourceInfo() const
SourceLocation getTemplateNameLoc() const
StringRef SubstitutedEntity