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.");
111 for (
auto *R :
D->getFirstDecl()->
redecls()) {
112 if (R !=
D->getFirstDecl())
113 Redecls.push_back(R);
115 Redecls.push_back(
D->getFirstDecl());
116 std::reverse(Redecls.begin(), Redecls.end());
121 if (
auto *FD = dyn_cast<FunctionDecl>(
D))
122 return getCanonicalForwardRedeclChain<FunctionDecl>(FD);
123 if (
auto *VD = dyn_cast<VarDecl>(
D))
124 return getCanonicalForwardRedeclChain<VarDecl>(VD);
125 if (
auto *TD = dyn_cast<TagDecl>(
D))
126 return getCanonicalForwardRedeclChain<TagDecl>(TD);
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)
179 public StmtVisitor<ASTNodeImporter, ExpectedStmt> {
183 template <
typename ImportT>
184 [[nodiscard]] Error importInto(ImportT &To,
const ImportT &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) {
281 ToD = CreateFun(std::forward<Args>(args)...);
284 Importer.SharedState->markAsNewDecl(ToD);
285 InitializeImportedDecl(FromD, ToD);
289 void InitializeImportedDecl(
Decl *FromD,
Decl *ToD) {
293 if (FromD->isImplicit())
301 if (
D->doesThisDeclarationHaveABody() &&
307 void addDeclToContexts(
Decl *FromD,
Decl *ToD) {
312 if (!FromD->getDescribedTemplate() &&
319 DeclContext *FromLexicalDC = FromD->getLexicalDeclContext();
323 bool Visible =
false;
336 if (
auto *FromNamed = dyn_cast<NamedDecl>(FromD)) {
337 auto *ToNamed = cast<NamedDecl>(ToD);
339 FromDC->
lookup(FromNamed->getDeclName());
340 if (llvm::is_contained(FromLookup, FromNamed))
357 updateLookupTableForTemplateParameters(
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())
397 return Error::success();
409#define TYPE(Class, Base) \
410 ExpectedType Visit##Class##Type(const Class##Type *T);
411#include "clang/AST/TypeNodes.inc"
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);
710 Err = MaybeVal.takeError();
716 template<
typename IIter,
typename OIter>
718 using ItemT = std::remove_reference_t<
decltype(*Obegin)>;
719 for (; Ibegin != Iend; ++Ibegin, ++Obegin) {
722 return ToOrErr.takeError();
725 return Error::success();
732 template<
typename InContainerTy,
typename OutContainerTy>
734 const InContainerTy &InContainer, OutContainerTy &OutContainer) {
736 InContainer.begin(), InContainer.end(), OutContainer.begin());
739 template<
typename InContainerTy,
typename OIter>
756template <
typename InContainerTy>
760 auto ToLAngleLocOrErr =
import(FromLAngleLoc);
761 if (!ToLAngleLocOrErr)
762 return ToLAngleLocOrErr.takeError();
763 auto ToRAngleLocOrErr =
import(FromRAngleLoc);
764 if (!ToRAngleLocOrErr)
765 return ToRAngleLocOrErr.takeError();
771 return Error::success();
775Error ASTNodeImporter::ImportTemplateArgumentListInfo<TemplateArgumentListInfo>(
786 return ImportTemplateArgumentListInfo(
787 From.LAngleLoc, From.RAngleLoc, From.arguments(),
Result);
799 if (Error Err = importInto(std::get<0>(
Result), FTSInfo->getTemplate()))
800 return std::move(Err);
805 return std::move(Err);
815 return std::move(Err);
818 if (!ToRequiresClause)
819 return ToRequiresClause.takeError();
822 if (!ToTemplateLocOrErr)
823 return ToTemplateLocOrErr.takeError();
825 if (!ToLAngleLocOrErr)
826 return ToLAngleLocOrErr.takeError();
828 if (!ToRAngleLocOrErr)
829 return ToRAngleLocOrErr.takeError();
850 return ToTypeOrErr.takeError();
858 return ToTypeOrErr.takeError();
865 return ToOrErr.takeError();
868 return ToTypeOrErr.takeError();
869 return TemplateArgument(dyn_cast<ValueDecl>((*ToOrErr)->getCanonicalDecl()),
876 return ToTypeOrErr.takeError();
884 return ToTypeOrErr.takeError();
887 return ToValueOrErr.takeError();
894 if (!ToTemplateOrErr)
895 return ToTemplateOrErr.takeError();
903 if (!ToTemplateOrErr)
904 return ToTemplateOrErr.takeError();
915 return ToExpr.takeError();
921 return std::move(Err);
927 llvm_unreachable(
"Invalid template argument kind");
935 return ArgOrErr.takeError();
944 return E.takeError();
950 return TSIOrErr.takeError();
953 if (!ToTemplateKWLocOrErr)
954 return ToTemplateKWLocOrErr.takeError();
956 if (!ToTemplateQualifierLocOrErr)
957 return ToTemplateQualifierLocOrErr.takeError();
959 if (!ToTemplateNameLocOrErr)
960 return ToTemplateNameLocOrErr.takeError();
961 auto ToTemplateEllipsisLocOrErr =
963 if (!ToTemplateEllipsisLocOrErr)
964 return ToTemplateEllipsisLocOrErr.takeError();
967 *ToTemplateQualifierLocOrErr, *ToTemplateNameLocOrErr,
968 *ToTemplateEllipsisLocOrErr);
978 size_t NumDecls = DG.
end() - DG.
begin();
980 ToDecls.reserve(NumDecls);
981 for (
Decl *FromD : DG) {
982 if (
auto ToDOrErr =
import(FromD))
983 ToDecls.push_back(*ToDOrErr);
985 return ToDOrErr.takeError();
995 if (
D.isFieldDesignator()) {
1000 return ToDotLocOrErr.takeError();
1003 if (!ToFieldLocOrErr)
1004 return ToFieldLocOrErr.takeError();
1007 ToFieldName, *ToDotLocOrErr, *ToFieldLocOrErr);
1010 ExpectedSLoc ToLBracketLocOrErr =
import(
D.getLBracketLoc());
1011 if (!ToLBracketLocOrErr)
1012 return ToLBracketLocOrErr.takeError();
1014 ExpectedSLoc ToRBracketLocOrErr =
import(
D.getRBracketLoc());
1015 if (!ToRBracketLocOrErr)
1016 return ToRBracketLocOrErr.takeError();
1018 if (
D.isArrayDesignator())
1020 *ToLBracketLocOrErr,
1021 *ToRBracketLocOrErr);
1023 ExpectedSLoc ToEllipsisLocOrErr =
import(
D.getEllipsisLoc());
1024 if (!ToEllipsisLocOrErr)
1025 return ToEllipsisLocOrErr.takeError();
1027 assert(
D.isArrayRangeDesignator());
1029 D.getArrayIndex(), *ToLBracketLocOrErr, *ToEllipsisLocOrErr,
1030 *ToRBracketLocOrErr);
1035 Error Err = Error::success();
1038 auto ToConceptNameLoc =
1044 return std::move(Err);
1047 if (ASTTemplateArgs)
1049 return std::move(Err);
1061 char *ToStore =
new (Importer.
getToContext())
char[FromStr.size()];
1062 std::copy(FromStr.begin(), FromStr.end(), ToStore);
1063 return StringRef(ToStore, FromStr.size());
1075 return ToSecondExpr.takeError();
1076 ToSat.
Details.emplace_back(ToSecondExpr.get());
1078 auto Pair =
Record->dyn_cast<std::pair<SourceLocation, StringRef> *>();
1082 return ToPairFirst.takeError();
1087 ToPairFirst.get(), ToPairSecond});
1091 return Error::success();
1096ASTNodeImporter::import(
1101 return ToLoc.takeError();
1110 using namespace concepts;
1115 return DiagOrErr.takeError();
1116 return new (Importer.
getToContext()) TypeRequirement(*DiagOrErr);
1120 return ToType.takeError();
1121 return new (Importer.
getToContext()) TypeRequirement(*ToType);
1127 using namespace concepts;
1129 bool IsRKSimple = From->
getKind() == Requirement::RK_Simple;
1132 std::optional<ExprRequirement::ReturnTypeRequirement> Req;
1138 const ExprRequirement::ReturnTypeRequirement &FromTypeRequirement =
1141 if (FromTypeRequirement.isTypeConstraint()) {
1142 const bool IsDependent = FromTypeRequirement.
isDependent();
1144 import(FromTypeRequirement.getTypeConstraintTemplateParameterList());
1146 return ParamsOrErr.takeError();
1147 if (Status >= ExprRequirement::SS_ConstraintsNotSatisfied) {
1148 auto SubstConstraintExprOrErr =
1150 if (!SubstConstraintExprOrErr)
1151 return SubstConstraintExprOrErr.takeError();
1152 SubstitutedConstraintExpr = SubstConstraintExprOrErr.get();
1154 Req.emplace(ParamsOrErr.get(), IsDependent);
1155 }
else if (FromTypeRequirement.isSubstitutionFailure()) {
1156 auto DiagOrErr =
import(FromTypeRequirement.getSubstitutionDiagnostic());
1158 return DiagOrErr.takeError();
1159 Req.emplace(DiagOrErr.get());
1166 if (!NoexceptLocOrErr)
1167 return NoexceptLocOrErr.takeError();
1169 if (Status == ExprRequirement::SS_ExprSubstitutionFailure) {
1172 return DiagOrErr.takeError();
1174 *DiagOrErr, IsRKSimple, *NoexceptLocOrErr, std::move(*Req));
1178 return ExprOrErr.takeError();
1180 *ExprOrErr, IsRKSimple, *NoexceptLocOrErr, std::move(*Req), Status,
1181 SubstitutedConstraintExpr);
1187 using namespace concepts;
1197 NestedRequirement(ToEntity, ToSatisfaction);
1201 return ToExpr.takeError();
1202 if (ToExpr.get()->isInstantiationDependent()) {
1203 return new (Importer.
getToContext()) NestedRequirement(ToExpr.get());
1208 return std::move(Err);
1209 return new (Importer.
getToContext()) NestedRequirement(
1218 switch (FromRequire->
getKind()) {
1226 cast<concepts::NestedRequirement>(FromRequire));
1228 llvm_unreachable(
"Unhandled requirement kind");
1238 return VarOrErr.takeError();
1243 return LocationOrErr.takeError();
1248 return std::move(Err);
1255template <
typename T>
1257 if (
Found->getLinkageInternal() != From->getLinkageInternal())
1260 if (From->hasExternalFormalLinkage())
1261 return Found->hasExternalFormalLinkage();
1264 if (From->isInAnonymousNamespace())
1265 return Found->isInAnonymousNamespace();
1267 return !
Found->isInAnonymousNamespace() &&
1268 !
Found->hasExternalFormalLinkage();
1288using namespace clang;
1297 ExpectedType UnderlyingTypeOrErr =
import(
T->getValueType());
1298 if (!UnderlyingTypeOrErr)
1299 return UnderlyingTypeOrErr.takeError();
1305 switch (
T->getKind()) {
1306#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1307 case BuiltinType::Id: \
1308 return Importer.getToContext().SingletonId;
1309#include "clang/Basic/OpenCLImageTypes.def"
1310#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1311 case BuiltinType::Id: \
1312 return Importer.getToContext().Id##Ty;
1313#include "clang/Basic/OpenCLExtensionTypes.def"
1314#define SVE_TYPE(Name, Id, SingletonId) \
1315 case BuiltinType::Id: \
1316 return Importer.getToContext().SingletonId;
1317#include "clang/Basic/AArch64ACLETypes.def"
1318#define PPC_VECTOR_TYPE(Name, Id, Size) \
1319 case BuiltinType::Id: \
1320 return Importer.getToContext().Id##Ty;
1321#include "clang/Basic/PPCTypes.def"
1322#define RVV_TYPE(Name, Id, SingletonId) \
1323 case BuiltinType::Id: \
1324 return Importer.getToContext().SingletonId;
1325#include "clang/Basic/RISCVVTypes.def"
1326#define WASM_TYPE(Name, Id, SingletonId) \
1327 case BuiltinType::Id: \
1328 return Importer.getToContext().SingletonId;
1329#include "clang/Basic/WebAssemblyReferenceTypes.def"
1330#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1331 case BuiltinType::Id: \
1332 return Importer.getToContext().SingletonId;
1333#include "clang/Basic/AMDGPUTypes.def"
1334#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1335 case BuiltinType::Id: \
1336 return Importer.getToContext().SingletonId;
1337#include "clang/Basic/HLSLIntangibleTypes.def"
1338#define SHARED_SINGLETON_TYPE(Expansion)
1339#define BUILTIN_TYPE(Id, SingletonId) \
1340 case BuiltinType::Id: return Importer.getToContext().SingletonId;
1341#include "clang/AST/BuiltinTypes.def"
1349 case BuiltinType::Char_U:
1358 case BuiltinType::Char_S:
1367 case BuiltinType::WChar_S:
1368 case BuiltinType::WChar_U:
1374 llvm_unreachable(
"Invalid BuiltinType Kind!");
1378 ExpectedType ToOriginalTypeOrErr =
import(
T->getOriginalType());
1379 if (!ToOriginalTypeOrErr)
1380 return ToOriginalTypeOrErr.takeError();
1386 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1387 if (!ToElementTypeOrErr)
1388 return ToElementTypeOrErr.takeError();
1395 if (!ToPointeeTypeOrErr)
1396 return ToPointeeTypeOrErr.takeError();
1404 if (!ToPointeeTypeOrErr)
1405 return ToPointeeTypeOrErr.takeError();
1413 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1414 if (!ToPointeeTypeOrErr)
1415 return ToPointeeTypeOrErr.takeError();
1423 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1424 if (!ToPointeeTypeOrErr)
1425 return ToPointeeTypeOrErr.takeError();
1434 if (!ToPointeeTypeOrErr)
1435 return ToPointeeTypeOrErr.takeError();
1437 auto QualifierOrErr =
import(
T->getQualifier());
1438 if (!QualifierOrErr)
1439 return QualifierOrErr.takeError();
1441 auto ClsOrErr =
import(
T->getMostRecentCXXRecordDecl());
1443 return ClsOrErr.takeError();
1446 *ToPointeeTypeOrErr, *QualifierOrErr, *ClsOrErr);
1451 Error Err = Error::success();
1455 return std::move(Err);
1458 ToElementType,
T->getSize(), ToSizeExpr,
T->getSizeModifier(),
1459 T->getIndexTypeCVRQualifiers());
1465 if (!ToArrayTypeOrErr)
1466 return ToArrayTypeOrErr.takeError();
1473 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1474 if (!ToElementTypeOrErr)
1475 return ToElementTypeOrErr.takeError();
1478 T->getSizeModifier(),
1479 T->getIndexTypeCVRQualifiers());
1484 Error Err = Error::success();
1488 return std::move(Err);
1490 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1491 T->getIndexTypeCVRQualifiers());
1494ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(
1496 Error Err = Error::success();
1500 return std::move(Err);
1505 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1506 T->getIndexTypeCVRQualifiers());
1509ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType(
1511 Error Err = Error::success();
1516 return std::move(Err);
1518 ToElementType, ToSizeExpr, ToAttrLoc);
1522 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1523 if (!ToElementTypeOrErr)
1524 return ToElementTypeOrErr.takeError();
1527 T->getNumElements(),
1528 T->getVectorKind());
1532 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1533 if (!ToElementTypeOrErr)
1534 return ToElementTypeOrErr.takeError();
1537 T->getNumElements());
1545 if (!ToReturnTypeOrErr)
1546 return ToReturnTypeOrErr.takeError();
1555 if (!ToReturnTypeOrErr)
1556 return ToReturnTypeOrErr.takeError();
1563 return TyOrErr.takeError();
1564 ArgTypes.push_back(*TyOrErr);
1572 return TyOrErr.takeError();
1573 ExceptionTypes.push_back(*TyOrErr);
1577 Error Err = Error::success();
1594 return std::move(Err);
1597 *ToReturnTypeOrErr, ArgTypes, ToEPI);
1602 Error Err = Error::success();
1606 return std::move(Err);
1616 if (!ToInnerTypeOrErr)
1617 return ToInnerTypeOrErr.takeError();
1627 return Pattern.takeError();
1630 return Index.takeError();
1637 return ToDeclOrErr.takeError();
1639 auto ToQualifierOrErr =
import(
T->getQualifier());
1640 if (!ToQualifierOrErr)
1641 return ToQualifierOrErr.takeError();
1644 T->typeMatchesDecl() ?
QualType() : import(
T->desugar());
1645 if (!ToUnderlyingTypeOrErr)
1646 return ToUnderlyingTypeOrErr.takeError();
1649 T->getKeyword(), *ToQualifierOrErr, *ToDeclOrErr, *ToUnderlyingTypeOrErr);
1655 return ToExprOrErr.takeError();
1660 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnmodifiedType());
1661 if (!ToUnderlyingTypeOrErr)
1662 return ToUnderlyingTypeOrErr.takeError();
1668 Error Err = Error::success();
1673 return std::move(Err);
1682 return ToExprOrErr.takeError();
1684 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1685 if (!ToUnderlyingTypeOrErr)
1686 return ToUnderlyingTypeOrErr.takeError();
1689 *ToExprOrErr, *ToUnderlyingTypeOrErr);
1695 if (!ToBaseTypeOrErr)
1696 return ToBaseTypeOrErr.takeError();
1698 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1699 if (!ToUnderlyingTypeOrErr)
1700 return ToUnderlyingTypeOrErr.takeError();
1703 *ToBaseTypeOrErr, *ToUnderlyingTypeOrErr,
T->getUTTKind());
1708 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1709 if (!ToDeducedTypeOrErr)
1710 return ToDeducedTypeOrErr.takeError();
1712 ExpectedDecl ToTypeConstraintConcept =
import(
T->getTypeConstraintConcept());
1713 if (!ToTypeConstraintConcept)
1714 return ToTypeConstraintConcept.takeError();
1719 return std::move(Err);
1722 *ToDeducedTypeOrErr,
T->getKeyword(),
false,
1723 false, cast_or_null<ConceptDecl>(*ToTypeConstraintConcept),
1727ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
1731 if (!ToTemplateNameOrErr)
1732 return ToTemplateNameOrErr.takeError();
1733 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1734 if (!ToDeducedTypeOrErr)
1735 return ToDeducedTypeOrErr.takeError();
1738 T->getKeyword(), *ToTemplateNameOrErr, *ToDeducedTypeOrErr,
1745 return ToDeclOrErr.takeError();
1750 auto ToQualifierOrErr =
import(
T->getQualifier());
1751 if (!ToQualifierOrErr)
1752 return ToQualifierOrErr.takeError();
1755 *ToDeclOrErr,
T->isTagOwned());
1759 return VisitTagType(
T);
1763 return VisitTagType(
T);
1768 return VisitTagType(
T);
1772 ExpectedType ToModifiedTypeOrErr =
import(
T->getModifiedType());
1773 if (!ToModifiedTypeOrErr)
1774 return ToModifiedTypeOrErr.takeError();
1775 ExpectedType ToEquivalentTypeOrErr =
import(
T->getEquivalentType());
1776 if (!ToEquivalentTypeOrErr)
1777 return ToEquivalentTypeOrErr.takeError();
1780 T->getAttrKind(), *ToModifiedTypeOrErr, *ToEquivalentTypeOrErr,
1787 if (!ToWrappedTypeOrErr)
1788 return ToWrappedTypeOrErr.takeError();
1790 Error Err = Error::success();
1797 return ToDeclOrErr.takeError();
1798 CoupledDecls.emplace_back(*ToDeclOrErr, TI.isDeref());
1802 *ToWrappedTypeOrErr, CountExpr,
T->isCountInBytes(),
T->isOrNull(),
1806ExpectedType ASTNodeImporter::VisitTemplateTypeParmType(
1810 return ToDeclOrErr.takeError();
1813 T->getDepth(),
T->getIndex(),
T->isParameterPack(), *ToDeclOrErr);
1816ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmType(
1820 return ReplacedOrErr.takeError();
1822 ExpectedType ToReplacementTypeOrErr =
import(
T->getReplacementType());
1823 if (!ToReplacementTypeOrErr)
1824 return ToReplacementTypeOrErr.takeError();
1827 *ToReplacementTypeOrErr, *ReplacedOrErr,
T->getIndex(),
T->getPackIndex(),
1831ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmPackType(
1835 return ReplacedOrErr.takeError();
1838 if (!ToArgumentPack)
1839 return ToArgumentPack.takeError();
1842 *ReplacedOrErr,
T->getIndex(),
T->getFinal(), *ToArgumentPack);
1845ExpectedType ASTNodeImporter::VisitSubstBuiltinTemplatePackType(
1848 if (!ToArgumentPack)
1849 return ToArgumentPack.takeError();
1853ExpectedType ASTNodeImporter::VisitTemplateSpecializationType(
1855 auto ToTemplateOrErr =
import(
T->getTemplateName());
1856 if (!ToTemplateOrErr)
1857 return ToTemplateOrErr.takeError();
1862 return std::move(Err);
1866 if (!ToUnderlyingOrErr)
1867 return ToUnderlyingOrErr.takeError();
1869 T->getKeyword(), *ToTemplateOrErr, ToTemplateArgs, {},
1870 *ToUnderlyingOrErr);
1876 if (!ToPatternOrErr)
1877 return ToPatternOrErr.takeError();
1880 T->getNumExpansions(),
1884ExpectedType ASTNodeImporter::VisitDependentTemplateSpecializationType(
1888 if (!QualifierOrErr)
1889 return QualifierOrErr.takeError();
1892 ToPack.reserve(
T->template_arguments().size());
1894 return std::move(Err);
1905 auto ToQualifierOrErr =
import(
T->getQualifier());
1906 if (!ToQualifierOrErr)
1907 return ToQualifierOrErr.takeError();
1911 *ToQualifierOrErr, Name);
1918 return ToDeclOrErr.takeError();
1925 if (!ToBaseTypeOrErr)
1926 return ToBaseTypeOrErr.takeError();
1929 for (
auto TypeArg :
T->getTypeArgsAsWritten()) {
1931 TypeArgs.push_back(*TyOrErr);
1933 return TyOrErr.takeError();
1937 for (
auto *
P :
T->quals()) {
1939 Protocols.push_back(*ProtocolOrErr);
1941 return ProtocolOrErr.takeError();
1947 T->isKindOfTypeAsWritten());
1953 if (!ToPointeeTypeOrErr)
1954 return ToPointeeTypeOrErr.takeError();
1961 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1962 if (!ToUnderlyingTypeOrErr)
1963 return ToUnderlyingTypeOrErr.takeError();
1971 Error Err = Error::success();
1972 QualType ToOriginalType = importChecked(Err,
T->getOriginalType());
1973 QualType ToAdjustedType = importChecked(Err,
T->getAdjustedType());
1975 return std::move(Err);
1977 return Importer.getToContext().getAdjustedType(ToOriginalType,
1982 return Importer.getToContext().getBitIntType(
T->isUnsigned(),
1986ExpectedType clang::ASTNodeImporter::VisitBTFTagAttributedType(
1988 Error Err = Error::success();
1989 const BTFTypeTagAttr *ToBTFAttr = importChecked(Err,
T->getAttr());
1990 QualType ToWrappedType = importChecked(Err,
T->getWrappedType());
1992 return std::move(Err);
1994 return Importer.getToContext().getBTFTagAttributedType(ToBTFAttr,
1998ExpectedType clang::ASTNodeImporter::VisitHLSLAttributedResourceType(
2000 Error Err = Error::success();
2002 QualType ToWrappedType = importChecked(Err,
T->getWrappedType());
2003 QualType ToContainedType = importChecked(Err,
T->getContainedType());
2005 return std::move(Err);
2007 return Importer.getToContext().getHLSLAttributedResourceType(
2008 ToWrappedType, ToContainedType, ToAttrs);
2011ExpectedType clang::ASTNodeImporter::VisitHLSLInlineSpirvType(
2013 Error Err = Error::success();
2017 uint32_t ToAlignment =
T->getAlignment();
2021 for (
auto &Operand :
T->getOperands()) {
2025 case SpirvOperandKind::ConstantId:
2027 importChecked(Err,
Operand.getResultType()),
Operand.getValue()));
2029 case SpirvOperandKind::Literal:
2032 case SpirvOperandKind::TypeId:
2034 importChecked(Err,
Operand.getResultType())));
2037 llvm_unreachable(
"Invalid SpirvOperand kind");
2041 return std::move(Err);
2044 return Importer.getToContext().getHLSLInlineSpirvType(
2045 ToOpcode, ToSize, ToAlignment, ToOperands);
2048ExpectedType clang::ASTNodeImporter::VisitConstantMatrixType(
2050 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
2051 if (!ToElementTypeOrErr)
2052 return ToElementTypeOrErr.takeError();
2054 return Importer.getToContext().getConstantMatrixType(
2055 *ToElementTypeOrErr,
T->getNumRows(),
T->getNumColumns());
2058ExpectedType clang::ASTNodeImporter::VisitDependentAddressSpaceType(
2060 Error Err = Error::success();
2062 Expr *ToAddrSpaceExpr = importChecked(Err,
T->getAddrSpaceExpr());
2065 return std::move(Err);
2067 return Importer.getToContext().getDependentAddressSpaceType(
2068 ToPointeeType, ToAddrSpaceExpr, ToAttrLoc);
2071ExpectedType clang::ASTNodeImporter::VisitDependentBitIntType(
2073 ExpectedExpr ToNumBitsExprOrErr =
import(
T->getNumBitsExpr());
2074 if (!ToNumBitsExprOrErr)
2075 return ToNumBitsExprOrErr.takeError();
2076 return Importer.getToContext().getDependentBitIntType(
T->isUnsigned(),
2077 *ToNumBitsExprOrErr);
2080ExpectedType clang::ASTNodeImporter::VisitPredefinedSugarType(
2082 return Importer.getToContext().getPredefinedSugarType(
T->getKind());
2085ExpectedType clang::ASTNodeImporter::VisitDependentSizedMatrixType(
2087 Error Err = Error::success();
2088 QualType ToElementType = importChecked(Err,
T->getElementType());
2089 Expr *ToRowExpr = importChecked(Err,
T->getRowExpr());
2090 Expr *ToColumnExpr = importChecked(Err,
T->getColumnExpr());
2093 return std::move(Err);
2095 return Importer.getToContext().getDependentSizedMatrixType(
2096 ToElementType, ToRowExpr, ToColumnExpr, ToAttrLoc);
2099ExpectedType clang::ASTNodeImporter::VisitDependentVectorType(
2101 Error Err = Error::success();
2102 QualType ToElementType = importChecked(Err,
T->getElementType());
2103 Expr *ToSizeExpr = importChecked(Err,
T->getSizeExpr());
2106 return std::move(Err);
2108 return Importer.getToContext().getDependentVectorType(
2109 ToElementType, ToSizeExpr, ToAttrLoc,
T->getVectorKind());
2112ExpectedType clang::ASTNodeImporter::VisitObjCTypeParamType(
2116 return ToDeclOrErr.takeError();
2121 if (!ToProtocolOrErr)
2122 return ToProtocolOrErr.takeError();
2123 ToProtocols.push_back(*ToProtocolOrErr);
2126 return Importer.getToContext().getObjCTypeParamType(*ToDeclOrErr,
2131 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
2132 if (!ToElementTypeOrErr)
2133 return ToElementTypeOrErr.takeError();
2136 if (
T->isReadOnly())
2156 if (isa<RecordDecl>(
D) && (FunDecl = dyn_cast<FunctionDecl>(OrigDC)) &&
2158 auto getLeafPointeeType = [](
const Type *
T) {
2166 getLeafPointeeType(
P->getType().getCanonicalType().getTypePtr());
2167 auto *RT = dyn_cast<RecordType>(LeafT);
2168 if (RT && RT->getOriginalDecl() ==
D) {
2181 if (Error Err = importInto(Name,
D->getDeclName()))
2193 return Error::success();
2200 if (Error Err = importInto(Name,
D->getDeclName()))
2212 return Error::success();
2217 return Error::success();
2220 if (Error Err = importInto(ToD, FromD))
2223 if (
RecordDecl *FromRecord = dyn_cast<RecordDecl>(FromD)) {
2224 if (
RecordDecl *ToRecord = cast<RecordDecl>(ToD)) {
2225 if (FromRecord->getDefinition() && FromRecord->isCompleteDefinition() &&
2226 !ToRecord->getDefinition()) {
2231 return Error::success();
2234 if (
EnumDecl *FromEnum = dyn_cast<EnumDecl>(FromD)) {
2235 if (
EnumDecl *ToEnum = cast<EnumDecl>(ToD)) {
2236 if (FromEnum->getDefinition() && !ToEnum->getDefinition()) {
2241 return Error::success();
2244 return Error::success();
2259 return Error::success();
2265 return ToRangeOrErr.takeError();
2266 return Error::success();
2272 return LocOrErr.takeError();
2273 return Error::success();
2281 return ToTInfoOrErr.takeError();
2282 return Error::success();
2285 llvm_unreachable(
"Unknown name kind.");
2292 return ToDCOrErr.takeError();
2306 auto MightNeedReordering = [](
const Decl *
D) {
2307 return isa<FieldDecl>(
D) || isa<IndirectFieldDecl>(
D) || isa<FriendDecl>(
D);
2311 Error ChildErrors = Error::success();
2312 for (
auto *From : FromDC->
decls()) {
2313 if (!MightNeedReordering(From))
2322 if (!ImportedOrErr) {
2324 ImportedOrErr.takeError());
2327 FieldDecl *FieldFrom = dyn_cast_or_null<FieldDecl>(From);
2328 Decl *ImportedDecl = *ImportedOrErr;
2329 FieldDecl *FieldTo = dyn_cast_or_null<FieldDecl>(ImportedDecl);
2330 if (FieldFrom && FieldTo) {
2362 consumeError(std::move(ChildErrors));
2363 return ToDCOrErr.takeError();
2366 if (
const auto *FromRD = dyn_cast<RecordDecl>(FromDC)) {
2370 for (
auto *
D : FromRD->decls()) {
2371 if (!MightNeedReordering(
D))
2374 assert(
D &&
"DC contains a null decl");
2377 assert(ToDC == ToD->getLexicalDeclContext() && ToDC->
containsDecl(ToD));
2389 for (
auto *From : FromDC->
decls()) {
2390 if (MightNeedReordering(From))
2396 ImportedOrErr.takeError());
2416 if (!FromRecordDecl || !ToRecordDecl) {
2420 if (RecordFrom && RecordTo) {
2422 ToRecordDecl = RecordTo->getOriginalDecl();
2426 if (FromRecordDecl && ToRecordDecl) {
2432 return Error::success();
2439 return ToDCOrErr.takeError();
2445 if (!ToLexicalDCOrErr)
2446 return ToLexicalDCOrErr.takeError();
2447 ToLexicalDC = *ToLexicalDCOrErr;
2451 return Error::success();
2457 "Import implicit methods to or from non-definition");
2460 if (FromM->isImplicit()) {
2463 return ToMOrErr.takeError();
2466 return Error::success();
2475 return ToTypedefOrErr.takeError();
2477 return Error::success();
2482 auto DefinitionCompleter = [To]() {
2501 auto *FromCXXRD = cast<CXXRecordDecl>(From);
2503 ToCaptures.reserve(FromCXXRD->capture_size());
2504 for (
const auto &FromCapture : FromCXXRD->captures()) {
2505 if (
auto ToCaptureOrErr =
import(FromCapture))
2506 ToCaptures.push_back(*ToCaptureOrErr);
2508 return ToCaptureOrErr.takeError();
2510 cast<CXXRecordDecl>(To)->setCaptures(Importer.
getToContext(),
2517 DefinitionCompleter();
2521 return Error::success();
2536 auto DefinitionCompleterScopeExit =
2537 llvm::make_scope_exit(DefinitionCompleter);
2543 auto *ToCXX = dyn_cast<CXXRecordDecl>(To);
2544 auto *FromCXX = dyn_cast<CXXRecordDecl>(From);
2545 if (ToCXX && FromCXX && ToCXX->dataPtr() && FromCXX->dataPtr()) {
2547 struct CXXRecordDecl::DefinitionData &ToData = ToCXX->data();
2548 struct CXXRecordDecl::DefinitionData &FromData = FromCXX->data();
2550 #define FIELD(Name, Width, Merge) \
2551 ToData.Name = FromData.Name;
2552 #include "clang/AST/CXXRecordDeclDefinitionBits.def"
2555 ToCXX->setArgPassingRestrictions(FromCXX->getArgPassingRestrictions());
2558 for (
const auto &Base1 : FromCXX->bases()) {
2561 return TyOrErr.takeError();
2564 if (Base1.isPackExpansion()) {
2565 if (
ExpectedSLoc LocOrErr =
import(Base1.getEllipsisLoc()))
2566 EllipsisLoc = *LocOrErr;
2568 return LocOrErr.takeError();
2576 auto RangeOrErr =
import(Base1.getSourceRange());
2578 return RangeOrErr.takeError();
2580 auto TSIOrErr =
import(Base1.getTypeSourceInfo());
2582 return TSIOrErr.takeError();
2588 Base1.isBaseOfClass(),
2589 Base1.getAccessSpecifierAsWritten(),
2594 ToCXX->setBases(Bases.data(), Bases.size());
2602 return Error::success();
2607 return Error::success();
2611 return Error::success();
2615 return ToInitOrErr.takeError();
2626 return Error::success();
2634 return Error::success();
2645 return ToTypeOrErr.takeError();
2648 if (!ToPromotionTypeOrErr)
2649 return ToPromotionTypeOrErr.takeError();
2660 return Error::success();
2666 for (
const auto &Arg : FromArgs) {
2667 if (
auto ToOrErr =
import(Arg))
2668 ToArgs.push_back(*ToOrErr);
2670 return ToOrErr.takeError();
2673 return Error::success();
2679 return import(From);
2682template <
typename InContainerTy>
2685 for (
const auto &FromLoc : Container) {
2686 if (
auto ToLocOrErr =
import(FromLoc))
2689 return ToLocOrErr.takeError();
2691 return Error::success();
2701 bool IgnoreTemplateParmDepth) {
2713 false, Complain,
false,
2714 IgnoreTemplateParmDepth);
2715 return Ctx.IsEquivalent(From, To);
2734 return std::move(Err);
2739 return LocOrErr.takeError();
2742 if (GetImportedOrCreateDecl(ToD,
D, Importer.
getToContext(), DC, *LocOrErr))
2765 return std::move(Err);
2771 Name.getAsIdentifierInfo(),
D->getType()))
2774 Error Err = Error::success();
2779 return std::move(Err);
2783 addDeclToContexts(
D, ToD);
2791 return LocOrErr.takeError();
2792 auto ColonLocOrErr =
import(
D->getColonLoc());
2794 return ColonLocOrErr.takeError();
2799 return DCOrErr.takeError();
2804 DC, *LocOrErr, *ColonLocOrErr))
2818 return DCOrErr.takeError();
2822 Error Err = Error::success();
2828 return std::move(Err);
2831 if (GetImportedOrCreateDecl(
2832 ToD,
D, Importer.
getToContext(), DC, ToLocation, ToAssertExpr, ToMessage,
2833 ToRParenLoc,
D->isFailed()))
2848 return std::move(Err);
2857 if (
auto *TU = dyn_cast<TranslationUnitDecl>(EnclosingDC))
2860 MergeWithNamespace =
2864 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2865 for (
auto *FoundDecl : FoundDecls) {
2869 if (
auto *FoundNS = dyn_cast<NamespaceDecl>(FoundDecl)) {
2870 MergeWithNamespace = FoundNS;
2871 ConflictingDecls.clear();
2875 ConflictingDecls.push_back(FoundDecl);
2878 if (!ConflictingDecls.empty()) {
2881 ConflictingDecls.size());
2883 Name = NameOrErr.get();
2885 return NameOrErr.takeError();
2891 return BeginLocOrErr.takeError();
2893 if (!RBraceLocOrErr)
2894 return RBraceLocOrErr.takeError();
2899 if (GetImportedOrCreateDecl(ToNamespace,
D, Importer.
getToContext(), DC,
2900 D->isInline(), *BeginLocOrErr,
Loc,
2901 Name.getAsIdentifierInfo(),
2902 nullptr,
D->isNested()))
2911 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2912 TU->setAnonymousNamespace(ToNamespace);
2914 cast<NamespaceDecl>(DC)->setAnonymousNamespace(ToNamespace);
2920 return std::move(Err);
2932 return std::move(Err);
2938 Error Err = Error::success();
2942 auto ToTargetNameLoc =
importChecked(Err,
D->getTargetNameLoc());
2945 return std::move(Err);
2950 if (GetImportedOrCreateDecl(
2951 ToD,
D, Importer.
getToContext(), DC, ToNamespaceLoc, ToAliasLoc,
2952 ToIdentifier, ToQualifierLoc, ToTargetNameLoc, ToNamespace))
2970 return std::move(Err);
2989 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2990 for (
auto *FoundDecl : FoundDecls) {
2993 if (
auto *FoundTypedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
2997 QualType FromUT =
D->getUnderlyingType();
2998 QualType FoundUT = FoundTypedef->getUnderlyingType();
3012 if (FromR && FoundR &&
3023 ConflictingDecls.push_back(FoundDecl);
3028 if (!ConflictingDecls.empty()) {
3030 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3032 Name = NameOrErr.get();
3034 return NameOrErr.takeError();
3038 Error Err = Error::success();
3040 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
3043 return std::move(Err);
3050 if (GetImportedOrCreateDecl<TypeAliasDecl>(
3052 Name.getAsIdentifierInfo(), ToTypeSourceInfo))
3054 }
else if (GetImportedOrCreateDecl<TypedefDecl>(
3056 Name.getAsIdentifierInfo(), ToTypeSourceInfo))
3061 return std::move(Err);
3065 Importer.AddToLookupTable(ToTypedef);
3070 TypeAliasDecl *FromAlias = IsAlias ? cast<TypeAliasDecl>(
D) :
nullptr;
3093 return std::move(Err);
3103 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3104 for (
auto *FoundDecl : FoundDecls) {
3107 if (
auto *FoundAlias = dyn_cast<TypeAliasTemplateDecl>(FoundDecl)) {
3110 ConflictingDecls.push_back(FoundDecl);
3114 if (!ConflictingDecls.empty()) {
3116 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3118 Name = NameOrErr.get();
3120 return NameOrErr.takeError();
3124 Error Err = Error::success();
3125 auto ToTemplateParameters =
importChecked(Err,
D->getTemplateParameters());
3126 auto ToTemplatedDecl =
importChecked(Err,
D->getTemplatedDecl());
3128 return std::move(Err);
3132 Name, ToTemplateParameters, ToTemplatedDecl))
3135 ToTemplatedDecl->setDescribedAliasTemplate(ToAlias);
3141 updateLookupTableForTemplateParameters(*ToTemplateParameters);
3152 return std::move(Err);
3159 if (
D->isGnuLocal()) {
3162 return BeginLocOrErr.takeError();
3164 Name.getAsIdentifierInfo(), *BeginLocOrErr))
3169 Name.getAsIdentifierInfo()))
3176 return ToStmtOrErr.takeError();
3178 ToLabel->
setStmt(*ToStmtOrErr);
3191 return std::move(Err);
3198 if (!SearchName &&
D->getTypedefNameForAnonDecl()) {
3199 if (Error Err = importInto(
3200 SearchName,
D->getTypedefNameForAnonDecl()->getDeclName()))
3201 return std::move(Err);
3211 Importer.findDeclsInToCtx(DC, SearchName);
3212 for (
auto *FoundDecl : FoundDecls) {
3216 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
3217 if (
const auto *Tag =
Typedef->getUnderlyingType()->getAs<
TagType>())
3218 FoundDecl = Tag->getOriginalDecl();
3221 if (
auto *FoundEnum = dyn_cast<EnumDecl>(FoundDecl)) {
3226 if (
D->isThisDeclarationADefinition() && FoundDef)
3231 ConflictingDecls.push_back(FoundDecl);
3240 if (SearchName && !ConflictingDecls.empty()) {
3242 SearchName, DC, IDNS, ConflictingDecls.data(),
3243 ConflictingDecls.size());
3245 Name = NameOrErr.get();
3247 return NameOrErr.takeError();
3251 Error Err = Error::success();
3257 return std::move(Err);
3261 if (GetImportedOrCreateDecl(
3263 Loc, Name.getAsIdentifierInfo(), PrevDecl,
D->isScoped(),
3264 D->isScopedUsingClassTag(),
D->isFixed()))
3272 addDeclToContexts(
D, D2);
3276 EnumDecl *FromInst =
D->getInstantiatedFromMemberEnum();
3278 D2->setInstantiationOfMemberEnum(*ToInstOrErr, SK);
3280 return ToInstOrErr.takeError();
3281 if (
ExpectedSLoc POIOrErr =
import(MemberInfo->getPointOfInstantiation()))
3284 return POIOrErr.takeError();
3288 if (
D->isCompleteDefinition())
3290 return std::move(Err);
3296 bool IsFriendTemplate =
false;
3297 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(
D)) {
3299 DCXX->getDescribedClassTemplate() &&
3300 DCXX->getDescribedClassTemplate()->getFriendObjectKind() !=
3310 return std::move(Err);
3317 if (!SearchName &&
D->getTypedefNameForAnonDecl()) {
3318 if (Error Err = importInto(
3319 SearchName,
D->getTypedefNameForAnonDecl()->getDeclName()))
3320 return std::move(Err);
3327 bool DependentFriend = IsFriendTemplate && IsDependentContext;
3334 Importer.findDeclsInToCtx(DC, SearchName);
3335 if (!FoundDecls.empty()) {
3338 if (
D->hasExternalLexicalStorage() && !
D->isCompleteDefinition())
3342 for (
auto *FoundDecl : FoundDecls) {
3347 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Found)) {
3348 if (
const auto *Tag =
Typedef->getUnderlyingType()->getAs<
TagType>())
3349 Found = Tag->getOriginalDecl();
3352 if (
auto *FoundRecord = dyn_cast<RecordDecl>(
Found)) {
3371 if (
D->isThisDeclarationADefinition() && FoundDef) {
3375 if (
const auto *DCXX = dyn_cast<CXXRecordDecl>(
D)) {
3376 auto *FoundCXX = dyn_cast<CXXRecordDecl>(FoundDef);
3377 assert(FoundCXX &&
"Record type mismatch");
3383 return std::move(Err);
3390 ConflictingDecls.push_back(FoundDecl);
3394 if (!ConflictingDecls.empty() && SearchName) {
3396 SearchName, DC, IDNS, ConflictingDecls.data(),
3397 ConflictingDecls.size());
3399 Name = NameOrErr.get();
3401 return NameOrErr.takeError();
3407 return BeginLocOrErr.takeError();
3412 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(
D)) {
3413 if (DCXX->isLambda()) {
3414 auto TInfoOrErr =
import(DCXX->getLambdaTypeInfo());
3416 return TInfoOrErr.takeError();
3417 if (GetImportedOrCreateSpecialDecl(
3419 DC, *TInfoOrErr,
Loc, DCXX->getLambdaDependencyKind(),
3420 DCXX->isGenericLambda(), DCXX->getLambdaCaptureDefault()))
3425 return CDeclOrErr.takeError();
3429 if (GetImportedOrCreateDecl(D2CXX,
D, Importer.
getToContext(),
3430 D->getTagKind(), DC, *BeginLocOrErr,
Loc,
3431 Name.getAsIdentifierInfo(),
3432 cast_or_null<CXXRecordDecl>(PrevDecl)))
3439 addDeclToContexts(
D, D2);
3442 DCXX->getDescribedClassTemplate()) {
3444 if (Error Err = importInto(ToDescribed, FromDescribed))
3445 return std::move(Err);
3448 DCXX->getMemberSpecializationInfo()) {
3450 MemberInfo->getTemplateSpecializationKind();
3456 return ToInstOrErr.takeError();
3459 import(MemberInfo->getPointOfInstantiation()))
3463 return POIOrErr.takeError();
3468 D->getTagKind(), DC, *BeginLocOrErr,
Loc,
3469 Name.getAsIdentifierInfo(), PrevDecl))
3472 addDeclToContexts(
D, D2);
3475 if (
auto BraceRangeOrErr =
import(
D->getBraceRange()))
3478 return BraceRangeOrErr.takeError();
3479 if (
auto QualifierLocOrErr =
import(
D->getQualifierLoc()))
3482 return QualifierLocOrErr.takeError();
3484 if (
D->isAnonymousStructOrUnion())
3487 if (
D->isCompleteDefinition())
3489 return std::move(Err);
3501 return std::move(Err);
3510 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3511 for (
auto *FoundDecl : FoundDecls) {
3515 if (
auto *FoundEnumConstant = dyn_cast<EnumConstantDecl>(FoundDecl)) {
3518 ConflictingDecls.push_back(FoundDecl);
3522 if (!ConflictingDecls.empty()) {
3524 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3526 Name = NameOrErr.get();
3528 return NameOrErr.takeError();
3534 return TypeOrErr.takeError();
3538 return InitOrErr.takeError();
3541 if (GetImportedOrCreateDecl(
3543 Name.getAsIdentifierInfo(), *TypeOrErr, *InitOrErr,
D->getInitVal()))
3544 return ToEnumerator;
3549 return ToEnumerator;
3552template <
typename DeclTy>
3555 unsigned int Num = FromD->getNumTemplateParameterLists();
3557 return Error::success();
3559 for (
unsigned int I = 0; I <
Num; ++I)
3561 import(FromD->getTemplateParameterList(I)))
3562 ToTPLists[I] = *ToTPListOrErr;
3564 return ToTPListOrErr.takeError();
3565 ToD->setTemplateParameterListsInfo(Importer.ToContext, ToTPLists);
3566 return Error::success();
3574 return Error::success();
3580 return Error::success();
3586 ToFD->setInstantiationOfMemberFunction(*InstFDOrErr, TSK);
3588 return InstFDOrErr.takeError();
3594 return POIOrErr.takeError();
3596 return Error::success();
3600 auto FunctionAndArgsOrErr =
3602 if (!FunctionAndArgsOrErr)
3603 return FunctionAndArgsOrErr.takeError();
3606 Importer.
getToContext(), std::get<1>(*FunctionAndArgsOrErr));
3610 const auto *FromTAArgsAsWritten = FTSInfo->TemplateArgumentsAsWritten;
3611 if (FromTAArgsAsWritten)
3613 *FromTAArgsAsWritten, ToTAInfo))
3616 ExpectedSLoc POIOrErr =
import(FTSInfo->getPointOfInstantiation());
3618 return POIOrErr.takeError();
3624 ToFD->setFunctionTemplateSpecialization(
3625 std::get<0>(*FunctionAndArgsOrErr), ToTAList,
nullptr,
3626 TSK, FromTAArgsAsWritten ? &ToTAInfo :
nullptr, *POIOrErr);
3627 return Error::success();
3635 Candidates.
addDecl(*ToFTDOrErr);
3637 return ToFTDOrErr.takeError();
3642 const auto *FromTAArgsAsWritten = FromInfo->TemplateArgumentsAsWritten;
3643 if (FromTAArgsAsWritten)
3650 FromTAArgsAsWritten ? &ToTAInfo :
nullptr);
3651 return Error::success();
3654 llvm_unreachable(
"All cases should be covered!");
3659 auto FunctionAndArgsOrErr =
3661 if (!FunctionAndArgsOrErr)
3662 return FunctionAndArgsOrErr.takeError();
3666 std::tie(
Template, ToTemplArgs) = *FunctionAndArgsOrErr;
3667 void *InsertPos =
nullptr;
3668 auto *FoundSpec =
Template->findSpecialization(ToTemplArgs, InsertPos);
3678 return ToBodyOrErr.takeError();
3680 return Error::success();
3689 assert(DCi &&
"Declaration should have a context");
3703 ToProcess.push_back(S);
3704 while (!ToProcess.empty()) {
3705 const Stmt *CurrentS = ToProcess.pop_back_val();
3707 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(CurrentS)) {
3708 if (
const Decl *
D = DeclRef->getDecl())
3711 }
else if (
const auto *
E =
3712 dyn_cast_or_null<SubstNonTypeTemplateParmExpr>(CurrentS)) {
3713 if (
const Decl *
D =
E->getAssociatedDecl())
3746class IsTypeDeclaredInsideVisitor
3747 :
public TypeVisitor<IsTypeDeclaredInsideVisitor, std::optional<bool>> {
3749 IsTypeDeclaredInsideVisitor(
const FunctionDecl *ParentDC)
3750 : ParentDC(ParentDC) {}
3756 if (std::optional<bool> Res = Visit(
T.getTypePtr()))
3759 T.getSingleStepDesugaredType(ParentDC->getParentASTContext());
3761 if (std::optional<bool> Res = Visit(DsT.
getTypePtr()))
3764 DsT =
T.getSingleStepDesugaredType(ParentDC->getParentASTContext());
3769 std::optional<bool> VisitTagType(
const TagType *
T) {
3771 dyn_cast<ClassTemplateSpecializationDecl>(
T->getOriginalDecl()))
3772 for (
const auto &Arg : Spec->getTemplateArgs().asArray())
3773 if (checkTemplateArgument(Arg))
3778 std::optional<bool> VisitPointerType(
const PointerType *
T) {
3783 return CheckType(
T->getPointeeTypeAsWritten());
3786 std::optional<bool> VisitTypedefType(
const TypedefType *
T) {
3790 std::optional<bool> VisitUsingType(
const UsingType *
T) {
3796 for (
const auto &Arg :
T->template_arguments())
3797 if (checkTemplateArgument(Arg))
3804 return CheckType(
T->getBaseType());
3819 return CheckType(
T->getElementType());
3824 "Variable array should not occur in deduced return type of a function");
3828 llvm_unreachable(
"Incomplete array should not occur in deduced return type "
3833 llvm_unreachable(
"Dependent array should not occur in deduced return type "
3860 if (checkTemplateArgument(PackArg))
3872 llvm_unreachable(
"Unknown TemplateArgument::ArgKind enum");
3882 assert(FromFPT &&
"Must be called on FunctionProtoType");
3884 auto IsCXX11Lambda = [&]() {
3885 if (Importer.FromContext.
getLangOpts().CPlusPlus14)
3891 QualType RetT = FromFPT->getReturnType();
3892 if (isa<AutoType>(RetT.
getTypePtr()) || IsCXX11Lambda()) {
3894 IsTypeDeclaredInsideVisitor Visitor(Def ? Def :
D);
3895 return Visitor.CheckType(RetT);
3912 auto RedeclIt = Redecls.begin();
3915 for (; RedeclIt != Redecls.end() && *RedeclIt !=
D; ++RedeclIt) {
3918 return ToRedeclOrErr.takeError();
3920 assert(*RedeclIt ==
D);
3928 return std::move(Err);
3940 if (
D->getTemplatedKind() ==
3943 if (!FoundFunctionOrErr)
3944 return FoundFunctionOrErr.takeError();
3945 if (
FunctionDecl *FoundFunction = *FoundFunctionOrErr) {
3946 if (
Decl *Def = FindAndMapDefinition(
D, FoundFunction))
3948 FoundByLookup = FoundFunction;
3956 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3957 for (
auto *FoundDecl : FoundDecls) {
3961 if (
auto *FoundFunction = dyn_cast<FunctionDecl>(FoundDecl)) {
3966 if (
Decl *Def = FindAndMapDefinition(
D, FoundFunction))
3968 FoundByLookup = FoundFunction;
3979 Importer.
ToDiag(
Loc, diag::warn_odr_function_type_inconsistent)
3980 << Name <<
D->getType() << FoundFunction->getType();
3981 Importer.
ToDiag(FoundFunction->getLocation(), diag::note_odr_value_here)
3982 << FoundFunction->getType();
3983 ConflictingDecls.push_back(FoundDecl);
3987 if (!ConflictingDecls.empty()) {
3989 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3991 Name = NameOrErr.get();
3993 return NameOrErr.takeError();
4003 if (FoundByLookup) {
4004 if (isa<CXXMethodDecl>(FoundByLookup)) {
4006 if (!
D->doesThisDeclarationHaveABody()) {
4008 D->getDescribedFunctionTemplate()) {
4013 "Templated function mapped to non-templated?");
4029 return std::move(Err);
4040 bool UsedDifferentProtoType =
false;
4042 QualType FromReturnTy = FromFPT->getReturnType();
4050 UsedDifferentProtoType =
true;
4061 FromEPI = DefaultEPI;
4062 UsedDifferentProtoType =
true;
4065 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
4070 Error Err = Error::success();
4073 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
4081 return std::move(Err);
4085 for (
auto *
P :
D->parameters()) {
4087 Parameters.push_back(*ToPOrErr);
4089 return ToPOrErr.takeError();
4094 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(
D)) {
4096 importExplicitSpecifier(Err, FromConstructor->getExplicitSpecifier());
4098 return std::move(Err);
4100 if (FromConstructor->isInheritingConstructor()) {
4102 import(FromConstructor->getInheritedConstructor());
4103 if (!ImportedInheritedCtor)
4104 return ImportedInheritedCtor.takeError();
4105 ToInheritedConstructor = *ImportedInheritedCtor;
4107 if (GetImportedOrCreateDecl<CXXConstructorDecl>(
4108 ToFunction,
D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
4109 ToInnerLocStart, NameInfo,
T, TInfo, ESpec,
D->UsesFPIntrin(),
4110 D->isInlineSpecified(),
D->
isImplicit(),
D->getConstexprKind(),
4111 ToInheritedConstructor, TrailingRequiresClause))
4115 Error Err = Error::success();
4117 Err,
const_cast<FunctionDecl *
>(FromDtor->getOperatorDelete()));
4118 auto ToThisArg =
importChecked(Err, FromDtor->getOperatorDeleteThisArg());
4120 return std::move(Err);
4122 if (GetImportedOrCreateDecl<CXXDestructorDecl>(
4123 ToFunction,
D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
4124 ToInnerLocStart, NameInfo,
T, TInfo,
D->UsesFPIntrin(),
4125 D->isInlineSpecified(),
D->
isImplicit(),
D->getConstexprKind(),
4126 TrailingRequiresClause))
4133 dyn_cast<CXXConversionDecl>(
D)) {
4135 importExplicitSpecifier(Err, FromConversion->getExplicitSpecifier());
4137 return std::move(Err);
4138 if (GetImportedOrCreateDecl<CXXConversionDecl>(
4139 ToFunction,
D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
4140 ToInnerLocStart, NameInfo,
T, TInfo,
D->UsesFPIntrin(),
4141 D->isInlineSpecified(), ESpec,
D->getConstexprKind(),
4144 }
else if (
auto *
Method = dyn_cast<CXXMethodDecl>(
D)) {
4145 if (GetImportedOrCreateDecl<CXXMethodDecl>(
4146 ToFunction,
D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
4147 ToInnerLocStart, NameInfo,
T, TInfo,
Method->getStorageClass(),
4151 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(
D)) {
4153 importExplicitSpecifier(Err, Guide->getExplicitSpecifier());
4159 return std::move(Err);
4160 if (GetImportedOrCreateDecl<CXXDeductionGuideDecl>(
4161 ToFunction,
D, Importer.
getToContext(), DC, ToInnerLocStart, ESpec,
4162 NameInfo,
T, TInfo, ToEndLoc, Ctor,
4163 Guide->getDeductionCandidateKind(), TrailingRequiresClause,
4167 if (GetImportedOrCreateDecl(
4168 ToFunction,
D, Importer.
getToContext(), DC, ToInnerLocStart,
4169 NameInfo,
T, TInfo,
D->getStorageClass(),
D->UsesFPIntrin(),
4170 D->isInlineSpecified(),
D->hasWrittenPrototype(),
4171 D->getConstexprKind(), TrailingRequiresClause))
4176 if (FoundByLookup) {
4189 auto Imported =
import(Msg);
4191 return Imported.takeError();
4205 D->FriendConstraintRefersToEnclosingTemplate());
4208 D->isTypeAwareOperatorNewOrDelete());
4218 for (
auto *Param : Parameters) {
4219 Param->setOwningFunction(ToFunction);
4224 ToFunction->setParams(Parameters);
4231 for (
unsigned I = 0, N = Parameters.size(); I != N; ++I)
4232 ProtoLoc.setParam(I, Parameters[I]);
4238 auto ToFTOrErr =
import(FromFT);
4240 return ToFTOrErr.takeError();
4244 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(
D)) {
4245 if (
unsigned NumInitializers = FromConstructor->getNumCtorInitializers()) {
4249 FromConstructor->inits(), CtorInitializers))
4250 return std::move(Err);
4253 llvm::copy(CtorInitializers, Memory);
4254 auto *ToCtor = cast<CXXConstructorDecl>(ToFunction);
4255 ToCtor->setCtorInitializers(Memory);
4256 ToCtor->setNumCtorInitializers(NumInitializers);
4262 return std::move(Err);
4264 if (
auto *FromCXXMethod = dyn_cast<CXXMethodDecl>(
D))
4267 return std::move(Err);
4269 if (
D->doesThisDeclarationHaveABody()) {
4273 return std::move(Err);
4277 if (UsedDifferentProtoType) {
4279 ToFunction->
setType(*TyOrErr);
4281 return TyOrErr.takeError();
4285 return TSIOrErr.takeError();
4290 addDeclToContexts(
D, ToFunction);
4293 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4296 return ToRedeclOrErr.takeError();
4330 return std::move(Err);
4335 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4336 for (
auto *FoundDecl : FoundDecls) {
4337 if (
FieldDecl *FoundField = dyn_cast<FieldDecl>(FoundDecl)) {
4345 FoundField->getType())) {
4353 if (
Expr *FromInitializer =
D->getInClassInitializer()) {
4354 if (
ExpectedExpr ToInitializerOrErr =
import(FromInitializer)) {
4357 assert(FoundField->hasInClassInitializer() &&
4358 "Field should have an in-class initializer if it has an "
4359 "expression for it.");
4360 if (!FoundField->getInClassInitializer())
4361 FoundField->setInClassInitializer(*ToInitializerOrErr);
4363 return ToInitializerOrErr.takeError();
4370 Importer.
ToDiag(
Loc, diag::warn_odr_field_type_inconsistent)
4371 << Name <<
D->getType() << FoundField->getType();
4372 Importer.
ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4373 << FoundField->getType();
4379 Error Err = Error::success();
4383 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
4385 return std::move(Err);
4386 const Type *ToCapturedVLAType =
nullptr;
4388 ToCapturedVLAType, cast_or_null<Type>(
D->getCapturedVLAType())))
4389 return std::move(Err);
4392 if (GetImportedOrCreateDecl(ToField,
D, Importer.
getToContext(), DC,
4393 ToInnerLocStart,
Loc, Name.getAsIdentifierInfo(),
4394 ToType, ToTInfo, ToBitWidth,
D->isMutable(),
4395 D->getInClassInitStyle()))
4401 if (ToCapturedVLAType)
4406 auto ToInitializer =
importChecked(Err,
D->getInClassInitializer());
4408 return std::move(Err);
4409 if (ToInitializer) {
4411 if (AlreadyImported)
4412 assert(ToInitializer == AlreadyImported &&
4413 "Duplicate import of in-class initializer.");
4428 return std::move(Err);
4433 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4434 for (
unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
4435 if (
auto *FoundField = dyn_cast<IndirectFieldDecl>(FoundDecls[I])) {
4443 FoundField->getType(),
4450 if (!Name && I < N-1)
4454 Importer.
ToDiag(
Loc, diag::warn_odr_field_type_inconsistent)
4455 << Name <<
D->getType() << FoundField->getType();
4456 Importer.
ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4457 << FoundField->getType();
4464 auto TypeOrErr =
import(
D->getType());
4466 return TypeOrErr.takeError();
4472 for (
auto *PI :
D->chain())
4474 NamedChain[i++] = *ToD;
4476 return ToD.takeError();
4480 if (GetImportedOrCreateDecl(ToIndirectField,
D, Importer.
getToContext(), DC,
4481 Loc, Name.getAsIdentifierInfo(), *TypeOrErr, CH))
4483 return ToIndirectField;
4488 return ToIndirectField;
4514 return Ctx.IsEquivalent(FD1, FD2);
4519 unsigned int FriendCount = 0;
4523 for (
FriendDecl *FoundFriend : RD->friends()) {
4524 if (FoundFriend == FD) {
4525 FriendPosition = FriendCount;
4532 assert(FriendPosition &&
"Friend decl not found in own parent.");
4534 return {FriendCount, *FriendPosition};
4541 return std::move(Err);
4546 const auto *RD = cast<CXXRecordDecl>(DC);
4548 for (
FriendDecl *ImportedFriend : RD->friends())
4550 ImportedEquivalentFriends.push_back(ImportedFriend);
4555 assert(ImportedEquivalentFriends.size() <= CountAndPosition.
TotalCount &&
4556 "Class with non-matching friends is imported, ODR check wrong?");
4557 if (ImportedEquivalentFriends.size() == CountAndPosition.
TotalCount)
4559 D, ImportedEquivalentFriends[CountAndPosition.
IndexOfDecl]);
4564 if (
NamedDecl *FriendD =
D->getFriendDecl()) {
4566 if (Error Err = importInto(ToFriendD, FriendD))
4567 return std::move(Err);
4575 if (
auto TSIOrErr =
import(
D->getFriendType()))
4578 return TSIOrErr.takeError();
4582 auto **FromTPLists =
D->getTrailingObjects();
4583 for (
unsigned I = 0; I <
D->NumTPLists; I++) {
4584 if (
auto ListOrErr =
import(FromTPLists[I]))
4585 ToTPLists[I] = *ListOrErr;
4587 return ListOrErr.takeError();
4592 return LocationOrErr.takeError();
4593 auto FriendLocOrErr =
import(
D->getFriendLoc());
4594 if (!FriendLocOrErr)
4595 return FriendLocOrErr.takeError();
4596 auto EllipsisLocOrErr =
import(
D->getEllipsisLoc());
4597 if (!EllipsisLocOrErr)
4598 return EllipsisLocOrErr.takeError();
4601 if (GetImportedOrCreateDecl(FrD,
D, Importer.
getToContext(), DC,
4602 *LocationOrErr, ToFU, *FriendLocOrErr,
4603 *EllipsisLocOrErr, ToTPLists))
4619 return std::move(Err);
4624 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4625 for (
auto *FoundDecl : FoundDecls) {
4626 if (
ObjCIvarDecl *FoundIvar = dyn_cast<ObjCIvarDecl>(FoundDecl)) {
4628 FoundIvar->getType())) {
4633 Importer.
ToDiag(
Loc, diag::warn_odr_ivar_type_inconsistent)
4634 << Name <<
D->getType() << FoundIvar->getType();
4635 Importer.
ToDiag(FoundIvar->getLocation(), diag::note_odr_value_here)
4636 << FoundIvar->getType();
4642 Error Err = Error::success();
4644 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
4646 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
4648 return std::move(Err);
4651 if (GetImportedOrCreateDecl(
4652 ToIvar,
D, Importer.
getToContext(), cast<ObjCContainerDecl>(DC),
4653 ToInnerLocStart,
Loc, Name.getAsIdentifierInfo(),
4654 ToType, ToTypeSourceInfo,
4655 D->getAccessControl(),ToBitWidth,
D->getSynthesize()))
4666 auto RedeclIt = Redecls.begin();
4669 for (; RedeclIt != Redecls.end() && *RedeclIt !=
D; ++RedeclIt) {
4672 return RedeclOrErr.takeError();
4674 assert(*RedeclIt ==
D);
4682 return std::move(Err);
4688 VarDecl *FoundByLookup =
nullptr;
4689 if (
D->isFileVarDecl()) {
4692 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4693 for (
auto *FoundDecl : FoundDecls) {
4697 if (
auto *FoundVar = dyn_cast<VarDecl>(FoundDecl)) {
4701 FoundVar->getType())) {
4706 if (
D->isThisDeclarationADefinition() && FoundDef)
4713 const VarDecl *FoundDInit =
nullptr;
4714 if (
D->getInit() && FoundVar->getAnyInitializer(FoundDInit))
4718 FoundByLookup = FoundVar;
4726 if (FoundArray && TArray) {
4727 if (isa<IncompleteArrayType>(FoundArray) &&
4728 isa<ConstantArrayType>(TArray)) {
4730 if (
auto TyOrErr =
import(
D->getType()))
4731 FoundVar->setType(*TyOrErr);
4733 return TyOrErr.takeError();
4735 FoundByLookup = FoundVar;
4737 }
else if (isa<IncompleteArrayType>(TArray) &&
4738 isa<ConstantArrayType>(FoundArray)) {
4739 FoundByLookup = FoundVar;
4744 Importer.
ToDiag(
Loc, diag::warn_odr_variable_type_inconsistent)
4745 << Name <<
D->getType() << FoundVar->getType();
4746 Importer.
ToDiag(FoundVar->getLocation(), diag::note_odr_value_here)
4747 << FoundVar->getType();
4748 ConflictingDecls.push_back(FoundDecl);
4752 if (!ConflictingDecls.empty()) {
4754 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
4756 Name = NameOrErr.get();
4758 return NameOrErr.takeError();
4762 Error Err = Error::success();
4764 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
4765 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
4768 return std::move(Err);
4771 if (
auto *FromDecomp = dyn_cast<DecompositionDecl>(
D)) {
4775 return std::move(Err);
4777 if (GetImportedOrCreateDecl(
4778 ToDecomp, FromDecomp, Importer.
getToContext(), DC, ToInnerLocStart,
4779 Loc, ToType, ToTypeSourceInfo,
D->getStorageClass(),
Bindings))
4784 if (GetImportedOrCreateDecl(ToVar,
D, Importer.
getToContext(), DC,
4785 ToInnerLocStart,
Loc,
4786 Name.getAsIdentifierInfo(), ToType,
4787 ToTypeSourceInfo,
D->getStorageClass()))
4795 if (
D->isInlineSpecified())
4800 if (FoundByLookup) {
4806 if (
D->getDescribedVarTemplate()) {
4807 auto ToVTOrErr =
import(
D->getDescribedVarTemplate());
4809 return ToVTOrErr.takeError();
4812 VarDecl *FromInst =
D->getInstantiatedFromStaticDataMember();
4816 return ToInstOrErr.takeError();
4817 if (
ExpectedSLoc POIOrErr =
import(MSI->getPointOfInstantiation()))
4820 return POIOrErr.takeError();
4824 return std::move(Err);
4826 if (
D->isConstexpr())
4829 addDeclToContexts(
D, ToVar);
4832 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4835 return RedeclOrErr.takeError();
4846 Error Err = Error::success();
4851 return std::move(Err);
4855 if (GetImportedOrCreateDecl(ToParm,
D, Importer.
getToContext(), DC,
4856 ToLocation, ToDeclName.getAsIdentifierInfo(),
4857 ToType,
D->getParameterKind()))
4868 return LocOrErr.takeError();
4877 return ToDefArgOrErr.takeError();
4881 if (
auto ToDefArgOrErr =
import(FromParam->
getDefaultArg()))
4884 return ToDefArgOrErr.takeError();
4887 return Error::success();
4892 Error Err = Error::success();
4897 return std::move(Err);
4906 Error Err = Error::success();
4909 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
4911 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
4913 return std::move(Err);
4916 if (GetImportedOrCreateDecl(ToParm,
D, Importer.
getToContext(), DC,
4917 ToInnerLocStart, ToLocation,
4918 ToDeclName.getAsIdentifierInfo(), ToType,
4919 ToTypeSourceInfo,
D->getStorageClass(),
4927 return std::move(Err);
4929 if (
D->isObjCMethodParameter()) {
4934 D->getFunctionScopeIndex());
4947 return std::move(Err);
4951 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4952 for (
auto *FoundDecl : FoundDecls) {
4953 if (
auto *FoundMethod = dyn_cast<ObjCMethodDecl>(FoundDecl)) {
4954 if (FoundMethod->isInstanceMethod() !=
D->isInstanceMethod())
4959 FoundMethod->getReturnType())) {
4960 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_result_type_inconsistent)
4961 <<
D->isInstanceMethod() << Name <<
D->getReturnType()
4962 << FoundMethod->getReturnType();
4963 Importer.
ToDiag(FoundMethod->getLocation(),
4964 diag::note_odr_objc_method_here)
4965 <<
D->isInstanceMethod() << Name;
4971 if (
D->param_size() != FoundMethod->param_size()) {
4972 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_num_params_inconsistent)
4973 <<
D->isInstanceMethod() << Name
4974 <<
D->param_size() << FoundMethod->param_size();
4975 Importer.
ToDiag(FoundMethod->getLocation(),
4976 diag::note_odr_objc_method_here)
4977 <<
D->isInstanceMethod() << Name;
4984 PEnd =
D->param_end(), FoundP = FoundMethod->param_begin();
4985 P != PEnd; ++
P, ++FoundP) {
4987 (*FoundP)->getType())) {
4988 Importer.
FromDiag((*P)->getLocation(),
4989 diag::warn_odr_objc_method_param_type_inconsistent)
4990 <<
D->isInstanceMethod() << Name
4991 << (*P)->getType() << (*FoundP)->getType();
4992 Importer.
ToDiag((*FoundP)->getLocation(), diag::note_odr_value_here)
4993 << (*FoundP)->getType();
5001 if (
D->isVariadic() != FoundMethod->isVariadic()) {
5002 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_variadic_inconsistent)
5003 <<
D->isInstanceMethod() << Name;
5004 Importer.
ToDiag(FoundMethod->getLocation(),
5005 diag::note_odr_objc_method_here)
5006 <<
D->isInstanceMethod() << Name;
5016 Error Err = Error::success();
5019 auto ToReturnTypeSourceInfo =
5022 return std::move(Err);
5025 if (GetImportedOrCreateDecl(
5027 Name.getObjCSelector(), ToReturnType, ToReturnTypeSourceInfo, DC,
5028 D->isInstanceMethod(),
D->isVariadic(),
D->isPropertyAccessor(),
5029 D->isSynthesizedAccessorStub(),
D->
isImplicit(),
D->isDefined(),
5030 D->getImplementationControl(),
D->hasRelatedResultType()))
5038 for (
auto *FromP :
D->parameters()) {
5040 ToParams.push_back(*ToPOrErr);
5042 return ToPOrErr.takeError();
5046 for (
auto *ToParam : ToParams) {
5047 ToParam->setOwningFunction(ToMethod);
5052 D->getSelectorLocs(FromSelLocs);
5055 return std::move(Err);
5065 if (
D->getSelfDecl())
5079 return std::move(Err);
5083 Error Err = Error::success();
5087 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
5089 return std::move(Err);
5092 if (GetImportedOrCreateDecl(
5094 ToVarianceLoc,
D->getIndex(),
5095 ToLocation, Name.getAsIdentifierInfo(),
5096 ToColonLoc, ToTypeSourceInfo))
5102 return std::move(Err);
5103 Result->setTypeForDecl(ToTypeForDecl);
5104 Result->setLexicalDeclContext(LexicalDC);
5115 return std::move(Err);
5120 if (Error Err = importInto(ToInterface,
D->getClassInterface()))
5121 return std::move(Err);
5129 Error Err = Error::success();
5131 auto ToCategoryNameLoc =
importChecked(Err,
D->getCategoryNameLoc());
5132 auto ToIvarLBraceLoc =
importChecked(Err,
D->getIvarLBraceLoc());
5133 auto ToIvarRBraceLoc =
importChecked(Err,
D->getIvarRBraceLoc());
5135 return std::move(Err);
5137 if (GetImportedOrCreateDecl(ToCategory,
D, Importer.
getToContext(), DC,
5140 Name.getAsIdentifierInfo(), ToInterface,
5153 return PListOrErr.takeError();
5159 =
D->protocol_loc_begin();
5161 FromProtoEnd =
D->protocol_end();
5162 FromProto != FromProtoEnd;
5163 ++FromProto, ++FromProtoLoc) {
5165 Protocols.push_back(*ToProtoOrErr);
5167 return ToProtoOrErr.takeError();
5169 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5170 ProtocolLocs.push_back(*ToProtoLocOrErr);
5172 return ToProtoLocOrErr.takeError();
5185 return std::move(Err);
5188 if (
D->getImplementation()) {
5190 import(
D->getImplementation()))
5193 return ToImplOrErr.takeError();
5205 return Error::success();
5218 FromProto != FromProtoEnd;
5219 ++FromProto, ++FromProtoLoc) {
5221 Protocols.push_back(*ToProtoOrErr);
5223 return ToProtoOrErr.takeError();
5225 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5226 ProtocolLocs.push_back(*ToProtoLocOrErr);
5228 return ToProtoLocOrErr.takeError();
5241 return Error::success();
5253 return ImportedDefOrErr.takeError();
5262 return std::move(Err);
5267 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5268 for (
auto *FoundDecl : FoundDecls) {
5272 if ((MergeWithProtocol = dyn_cast<ObjCProtocolDecl>(FoundDecl)))
5278 auto ToAtBeginLocOrErr =
import(
D->getAtStartLoc());
5279 if (!ToAtBeginLocOrErr)
5280 return ToAtBeginLocOrErr.takeError();
5282 if (GetImportedOrCreateDecl(ToProto,
D, Importer.
getToContext(), DC,
5283 Name.getAsIdentifierInfo(),
Loc,
5293 if (
D->isThisDeclarationADefinition())
5295 return std::move(Err);
5303 return std::move(Err);
5306 if (!ExternLocOrErr)
5307 return ExternLocOrErr.takeError();
5311 return LangLocOrErr.takeError();
5313 bool HasBraces =
D->hasBraces();
5316 if (GetImportedOrCreateDecl(ToLinkageSpec,
D, Importer.
getToContext(), DC,
5317 *ExternLocOrErr, *LangLocOrErr,
5318 D->getLanguage(), HasBraces))
5319 return ToLinkageSpec;
5323 if (!RBraceLocOrErr)
5324 return RBraceLocOrErr.takeError();
5331 return ToLinkageSpec;
5342 return ToShadowOrErr.takeError();
5353 return std::move(Err);
5357 Error Err = Error::success();
5362 return std::move(Err);
5366 return std::move(Err);
5369 if (GetImportedOrCreateDecl(ToUsing,
D, Importer.
getToContext(), DC,
5370 ToUsingLoc, ToQualifierLoc, NameInfo,
5381 ToUsing, *ToPatternOrErr);
5383 return ToPatternOrErr.takeError();
5395 return std::move(Err);
5399 Error Err = Error::success();
5405 return std::move(Err);
5408 if (GetImportedOrCreateDecl(ToUsingEnum,
D, Importer.
getToContext(), DC,
5409 ToUsingLoc, ToEnumLoc, ToNameLoc, ToEnumType))
5421 return ToPatternOrErr.takeError();
5433 return std::move(Err);
5438 if (!ToIntroducerOrErr)
5439 return ToIntroducerOrErr.takeError();
5443 return ToTargetOrErr.takeError();
5446 if (
auto *FromConstructorUsingShadow =
5447 dyn_cast<ConstructorUsingShadowDecl>(
D)) {
5448 Error Err = Error::success();
5450 Err, FromConstructorUsingShadow->getNominatedBaseClassShadowDecl());
5452 return std::move(Err);
5458 if (GetImportedOrCreateDecl<ConstructorUsingShadowDecl>(
5460 cast<UsingDecl>(*ToIntroducerOrErr),
5461 Nominated ? Nominated : *ToTargetOrErr,
5462 FromConstructorUsingShadow->constructsVirtualBase()))
5466 Name, *ToIntroducerOrErr, *ToTargetOrErr))
5477 ToShadow, *ToPatternOrErr);
5481 return ToPatternOrErr.takeError();
5495 return std::move(Err);
5499 auto ToComAncestorOrErr = Importer.
ImportContext(
D->getCommonAncestor());
5500 if (!ToComAncestorOrErr)
5501 return ToComAncestorOrErr.takeError();
5503 Error Err = Error::success();
5504 auto ToNominatedNamespace =
importChecked(Err,
D->getNominatedNamespace());
5506 auto ToNamespaceKeyLocation =
5509 auto ToIdentLocation =
importChecked(Err,
D->getIdentLocation());
5511 return std::move(Err);
5514 if (GetImportedOrCreateDecl(ToUsingDir,
D, Importer.
getToContext(), DC,
5516 ToNamespaceKeyLocation,
5519 ToNominatedNamespace, *ToComAncestorOrErr))
5534 return std::move(Err);
5538 auto ToInstantiatedFromUsingOrErr =
5539 Importer.
Import(
D->getInstantiatedFromUsingDecl());
5540 if (!ToInstantiatedFromUsingOrErr)
5541 return ToInstantiatedFromUsingOrErr.takeError();
5544 return std::move(Err);
5547 if (GetImportedOrCreateDecl(ToUsingPack,
D, Importer.
getToContext(), DC,
5548 cast<NamedDecl>(*ToInstantiatedFromUsingOrErr),
5552 addDeclToContexts(
D, ToUsingPack);
5564 return std::move(Err);
5568 Error Err = Error::success();
5574 return std::move(Err);
5578 return std::move(Err);
5581 if (GetImportedOrCreateDecl(ToUsingValue,
D, Importer.
getToContext(), DC,
5582 ToUsingLoc, ToQualifierLoc, NameInfo,
5584 return ToUsingValue;
5590 return ToUsingValue;
5600 return std::move(Err);
5604 Error Err = Error::success();
5610 return std::move(Err);
5613 if (GetImportedOrCreateDecl(ToUsing,
D, Importer.
getToContext(), DC,
5614 ToUsingLoc, ToTypenameLoc,
5615 ToQualifierLoc,
Loc, Name, ToEllipsisLoc))
5626 Decl* ToD =
nullptr;
5627 switch (
D->getBuiltinTemplateKind()) {
5628#define BuiltinTemplate(BTName) \
5629 case BuiltinTemplateKind::BTK##BTName: \
5630 ToD = Importer.getToContext().get##BTName##Decl(); \
5632#include "clang/Basic/BuiltinTemplates.inc"
5634 assert(ToD &&
"BuiltinTemplateDecl of unsupported kind!");
5645 if (
auto FromSuperOrErr =
import(FromSuper))
5646 FromSuper = *FromSuperOrErr;
5648 return FromSuperOrErr.takeError();
5652 if ((
bool)FromSuper != (
bool)ToSuper ||
5655 diag::warn_odr_objc_superclass_inconsistent)
5662 diag::note_odr_objc_missing_superclass);
5665 diag::note_odr_objc_superclass)
5669 diag::note_odr_objc_missing_superclass);
5675 return Error::success();
5686 return SuperTInfoOrErr.takeError();
5697 FromProto != FromProtoEnd;
5698 ++FromProto, ++FromProtoLoc) {
5700 Protocols.push_back(*ToProtoOrErr);
5702 return ToProtoOrErr.takeError();
5704 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5705 ProtocolLocs.push_back(*ToProtoLocOrErr);
5707 return ToProtoLocOrErr.takeError();
5718 auto ToCatOrErr =
import(Cat);
5720 return ToCatOrErr.takeError();
5729 return ToImplOrErr.takeError();
5736 return Error::success();
5745 for (
auto *fromTypeParam : *list) {
5746 if (
auto toTypeParamOrErr =
import(fromTypeParam))
5747 toTypeParams.push_back(*toTypeParamOrErr);
5749 return toTypeParamOrErr.takeError();
5753 if (!LAngleLocOrErr)
5754 return LAngleLocOrErr.takeError();
5757 if (!RAngleLocOrErr)
5758 return RAngleLocOrErr.takeError();
5775 return ImportedDefOrErr.takeError();
5784 return std::move(Err);
5790 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5791 for (
auto *FoundDecl : FoundDecls) {
5795 if ((MergeWithIface = dyn_cast<ObjCInterfaceDecl>(FoundDecl)))
5803 if (!AtBeginLocOrErr)
5804 return AtBeginLocOrErr.takeError();
5806 if (GetImportedOrCreateDecl(
5808 *AtBeginLocOrErr, Name.getAsIdentifierInfo(),
5810 nullptr,
Loc,
D->isImplicitInterfaceDecl()))
5818 if (
auto ToPListOrErr =
5822 return ToPListOrErr.takeError();
5824 if (
D->isThisDeclarationADefinition())
5826 return std::move(Err);
5834 if (Error Err = importInto(
Category,
D->getCategoryDecl()))
5835 return std::move(Err);
5841 return std::move(Err);
5843 Error Err = Error::success();
5846 auto ToCategoryNameLoc =
importChecked(Err,
D->getCategoryNameLoc());
5848 return std::move(Err);
5850 if (GetImportedOrCreateDecl(
5853 ToLocation, ToAtStartLoc, ToCategoryNameLoc))
5858 Category->setImplementation(ToImpl);
5863 return std::move(Err);
5872 if (Error Err = importInto(Iface,
D->getClassInterface()))
5873 return std::move(Err);
5877 if (Error Err = importInto(Super,
D->getSuperClass()))
5878 return std::move(Err);
5886 return std::move(Err);
5888 Error Err = Error::success();
5891 auto ToSuperClassLoc =
importChecked(Err,
D->getSuperClassLoc());
5892 auto ToIvarLBraceLoc =
importChecked(Err,
D->getIvarLBraceLoc());
5893 auto ToIvarRBraceLoc =
importChecked(Err,
D->getIvarRBraceLoc());
5895 return std::move(Err);
5897 if (GetImportedOrCreateDecl(Impl,
D, Importer.
getToContext(),
5921 diag::warn_odr_objc_superclass_inconsistent)
5927 diag::note_odr_objc_superclass)
5931 diag::note_odr_objc_missing_superclass);
5932 if (
D->getSuperClass())
5934 diag::note_odr_objc_superclass)
5935 <<
D->getSuperClass()->getDeclName();
5938 diag::note_odr_objc_missing_superclass);
5946 return std::move(Err);
5958 return std::move(Err);
5963 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5964 for (
auto *FoundDecl : FoundDecls) {
5965 if (
auto *FoundProp = dyn_cast<ObjCPropertyDecl>(FoundDecl)) {
5968 if (FoundProp->isInstanceProperty() !=
D->isInstanceProperty())
5973 FoundProp->getType())) {
5974 Importer.
ToDiag(
Loc, diag::warn_odr_objc_property_type_inconsistent)
5975 << Name <<
D->getType() << FoundProp->getType();
5976 Importer.
ToDiag(FoundProp->getLocation(), diag::note_odr_value_here)
5977 << FoundProp->getType();
5990 Error Err = Error::success();
5992 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
5996 return std::move(Err);
6000 if (GetImportedOrCreateDecl(
6002 Name.getAsIdentifierInfo(), ToAtLoc,
6003 ToLParenLoc, ToType,
6004 ToTypeSourceInfo,
D->getPropertyImplementation()))
6009 auto ToGetterNameLoc =
importChecked(Err,
D->getGetterNameLoc());
6010 auto ToSetterNameLoc =
importChecked(Err,
D->getSetterNameLoc());
6011 auto ToGetterMethodDecl =
importChecked(Err,
D->getGetterMethodDecl());
6012 auto ToSetterMethodDecl =
importChecked(Err,
D->getSetterMethodDecl());
6013 auto ToPropertyIvarDecl =
importChecked(Err,
D->getPropertyIvarDecl());
6015 return std::move(Err);
6022 D->getPropertyAttributesAsWritten());
6034 if (Error Err = importInto(
Property,
D->getPropertyDecl()))
6035 return std::move(Err);
6039 return std::move(Err);
6041 auto *InImpl = cast<ObjCImplDecl>(LexicalDC);
6045 if (Error Err = importInto(Ivar,
D->getPropertyIvarDecl()))
6046 return std::move(Err);
6049 = InImpl->FindPropertyImplDecl(
Property->getIdentifier(),
6053 Error Err = Error::success();
6056 auto ToPropertyIvarDeclLoc =
6059 return std::move(Err);
6061 if (GetImportedOrCreateDecl(ToImpl,
D, Importer.
getToContext(), DC,
6064 D->getPropertyImplementation(), Ivar,
6065 ToPropertyIvarDeclLoc))
6075 diag::warn_odr_objc_property_impl_kind_inconsistent)
6080 diag::note_odr_objc_property_impl_kind)
6081 <<
D->getPropertyDecl()->getDeclName()
6091 diag::warn_odr_objc_synthesize_ivar_inconsistent)
6095 Importer.
FromDiag(
D->getPropertyIvarDeclLoc(),
6096 diag::note_odr_objc_synthesize_ivar_here)
6097 <<
D->getPropertyIvarDecl()->getDeclName();
6117 return BeginLocOrErr.takeError();
6121 return LocationOrErr.takeError();
6124 if (GetImportedOrCreateDecl(
6127 *BeginLocOrErr, *LocationOrErr,
6128 D->getDepth(),
D->getIndex(), Importer.
Import(
D->getIdentifier()),
6130 D->hasTypeConstraint()))
6136 Error Err = Error::success();
6137 auto ToConceptRef =
importChecked(Err, TC->getConceptReference());
6138 auto ToIDC =
importChecked(Err, TC->getImmediatelyDeclaredConstraint());
6140 return std::move(Err);
6145 if (Error Err = importTemplateParameterDefaultArgument(
D, ToD))
6154 Error Err = Error::success();
6158 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
6159 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
6161 return std::move(Err);
6164 if (GetImportedOrCreateDecl(ToD,
D, Importer.
getToContext(),
6166 ToInnerLocStart, ToLocation,
D->getDepth(),
6168 ToDeclName.getAsIdentifierInfo(), ToType,
6172 Err = importTemplateParameterDefaultArgument(
D, ToD);
6181 bool IsCanonical =
false;
6188 auto NameOrErr =
import(
D->getDeclName());
6190 return NameOrErr.takeError();
6195 return LocationOrErr.takeError();
6198 auto TemplateParamsOrErr =
import(
D->getTemplateParameters());
6199 if (!TemplateParamsOrErr)
6200 return TemplateParamsOrErr.takeError();
6203 if (GetImportedOrCreateDecl(
6207 (*NameOrErr).getAsIdentifierInfo(),
D->templateParameterKind(),
6208 D->wasDeclaredWithTypename(), *TemplateParamsOrErr))
6211 if (Error Err = importTemplateParameterDefaultArgument(
D, ToD))
6224 assert(
D->getTemplatedDecl() &&
"Should be called on templates only");
6225 auto *ToTemplatedDef =
D->getTemplatedDecl()->getDefinition();
6226 if (!ToTemplatedDef)
6229 return cast_or_null<T>(TemplateWithDef);
6240 return std::move(Err);
6252 TD->getLexicalDeclContext()->isDependentContext();
6254 bool DependentFriend = IsDependentFriend(
D);
6261 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6262 for (
auto *FoundDecl : FoundDecls) {
6267 auto *FoundTemplate = dyn_cast<ClassTemplateDecl>(FoundDecl);
6268 if (FoundTemplate) {
6273 bool IgnoreTemplateParmDepth =
6277 IgnoreTemplateParmDepth)) {
6278 if (DependentFriend || IsDependentFriend(FoundTemplate))
6283 if (
D->isThisDeclarationADefinition() && TemplateWithDef)
6286 FoundByLookup = FoundTemplate;
6304 ConflictingDecls.push_back(FoundDecl);
6308 if (!ConflictingDecls.empty()) {
6311 ConflictingDecls.size());
6313 Name = NameOrErr.get();
6315 return NameOrErr.takeError();
6321 auto TemplateParamsOrErr =
import(
D->getTemplateParameters());
6322 if (!TemplateParamsOrErr)
6323 return TemplateParamsOrErr.takeError();
6327 if (Error Err = importInto(ToTemplated, FromTemplated))
6328 return std::move(Err);
6333 *TemplateParamsOrErr, ToTemplated))
6341 addDeclToContexts(
D, D2);
6342 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6344 if (FoundByLookup) {
6358 "Found decl must have its templated decl set");
6361 if (ToTemplated != PrevTemplated)
6374 if (Error Err = importInto(ClassTemplate,
D->getSpecializedTemplate()))
6375 return std::move(Err);
6380 return std::move(Err);
6386 return std::move(Err);
6389 void *InsertPos =
nullptr;
6392 dyn_cast<ClassTemplatePartialSpecializationDecl>(
D);
6400 return ToTPListOrErr.takeError();
6401 ToTPList = *ToTPListOrErr;
6411 if (
D->isThisDeclarationADefinition() && PrevDefinition) {
6415 for (
auto *FromField :
D->fields()) {
6416 auto ToOrErr =
import(FromField);
6418 return ToOrErr.takeError();
6424 auto ToOrErr =
import(FromM);
6426 return ToOrErr.takeError();
6434 return PrevDefinition;
6445 return BeginLocOrErr.takeError();
6448 return IdLocOrErr.takeError();
6452 if (
const auto *ASTTemplateArgs =
D->getTemplateArgsAsWritten()) {
6454 return std::move(Err);
6460 if (GetImportedOrCreateDecl<ClassTemplatePartialSpecializationDecl>(
6461 D2,
D, Importer.
getToContext(),
D->getTagKind(), DC, *BeginLocOrErr,
6462 *IdLocOrErr, ToTPList, ClassTemplate,
ArrayRef(TemplateArgs),
6464 cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl)))
6469 auto *PartSpec2 = cast<ClassTemplatePartialSpecializationDecl>(D2);
6470 if (!ClassTemplate->findPartialSpecialization(TemplateArgs, ToTPList,
6473 ClassTemplate->AddPartialSpecialization(PartSpec2, InsertPos);
6476 PartSpec2->setInstantiatedFromMember(*ToInstOrErr);
6478 return ToInstOrErr.takeError();
6480 updateLookupTableForTemplateParameters(*ToTPList);
6482 if (GetImportedOrCreateDecl(D2,
D, Importer.
getToContext(),
D->getTagKind(),
6483 DC, *BeginLocOrErr, *IdLocOrErr, ClassTemplate,
6484 TemplateArgs,
D->hasStrictPackMatch(),
6505 if (
auto BraceRangeOrErr =
import(
D->getBraceRange()))
6508 return BraceRangeOrErr.takeError();
6511 return std::move(Err);
6514 if (
auto LocOrErr =
import(
D->getQualifierLoc()))
6517 return LocOrErr.takeError();
6519 if (
D->getTemplateArgsAsWritten())
6522 if (
auto LocOrErr =
import(
D->getTemplateKeywordLoc()))
6525 return LocOrErr.takeError();
6527 if (
auto LocOrErr =
import(
D->getExternKeywordLoc()))
6530 return LocOrErr.takeError();
6532 if (
D->getPointOfInstantiation().isValid()) {
6533 if (
auto POIOrErr =
import(
D->getPointOfInstantiation()))
6536 return POIOrErr.takeError();
6541 if (
auto P =
D->getInstantiatedFrom()) {
6542 if (
auto *CTD = dyn_cast<ClassTemplateDecl *>(
P)) {
6543 if (
auto CTDorErr =
import(CTD))
6546 auto *CTPSD = cast<ClassTemplatePartialSpecializationDecl *>(
P);
6547 auto CTPSDOrErr =
import(CTPSD);
6549 return CTPSDOrErr.takeError();
6552 for (
unsigned I = 0; I < DArgs.
size(); ++I) {
6554 if (
auto ArgOrErr =
import(DArg))
6555 D2ArgsVec[I] = *ArgOrErr;
6557 return ArgOrErr.takeError();
6565 if (
D->isCompleteDefinition())
6567 return std::move(Err);
6579 return std::move(Err);
6585 "Variable templates cannot be declared at function scope");
6588 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6590 for (
auto *FoundDecl : FoundDecls) {
6594 if (
VarTemplateDecl *FoundTemplate = dyn_cast<VarTemplateDecl>(FoundDecl)) {
6597 D->getTemplatedDecl()))
6604 assert(FoundTemplate->getDeclContext()->isRecord() &&
6605 "Member variable template imported as non-member, "
6606 "inconsistent imported AST?");
6609 if (!
D->isThisDeclarationADefinition())
6612 if (FoundDef &&
D->isThisDeclarationADefinition())
6615 FoundByLookup = FoundTemplate;
6618 ConflictingDecls.push_back(FoundDecl);
6622 if (!ConflictingDecls.empty()) {
6625 ConflictingDecls.size());
6627 Name = NameOrErr.get();
6629 return NameOrErr.takeError();
6632 VarDecl *DTemplated =
D->getTemplatedDecl();
6638 return TypeOrErr.takeError();
6642 if (Error Err = importInto(ToTemplated, DTemplated))
6643 return std::move(Err);
6646 auto TemplateParamsOrErr =
import(
D->getTemplateParameters());
6647 if (!TemplateParamsOrErr)
6648 return TemplateParamsOrErr.takeError();
6652 Name, *TemplateParamsOrErr, ToTemplated))
6661 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6663 if (FoundByLookup) {
6667 auto *PrevTemplated =
6669 if (ToTemplated != PrevTemplated)
6684 auto RedeclIt = Redecls.begin();
6687 for (; RedeclIt != Redecls.end() && *RedeclIt !=
D; ++RedeclIt) {
6690 return RedeclOrErr.takeError();
6692 assert(*RedeclIt ==
D);
6695 if (Error Err = importInto(
VarTemplate,
D->getSpecializedTemplate()))
6696 return std::move(Err);
6701 return std::move(Err);
6706 return BeginLocOrErr.takeError();
6710 return IdLocOrErr.takeError();
6716 return std::move(Err);
6719 void *InsertPos =
nullptr;
6721 VarTemplate->findSpecialization(TemplateArgs, InsertPos);
6722 if (FoundSpecialization) {
6730 "Member variable template specialization imported as non-member, "
6731 "inconsistent imported AST?");
6734 if (!
D->isThisDeclarationADefinition())
6739 if (FoundDef &&
D->isThisDeclarationADefinition())
6750 if (
const auto *Args =
D->getTemplateArgsAsWritten()) {
6752 return std::move(Err);
6757 if (
auto *FromPartial = dyn_cast<PartVarSpecDecl>(
D)) {
6758 auto ToTPListOrErr =
import(FromPartial->getTemplateParameters());
6760 return ToTPListOrErr.takeError();
6762 PartVarSpecDecl *ToPartial;
6763 if (GetImportedOrCreateDecl(ToPartial,
D, Importer.
getToContext(), DC,
6764 *BeginLocOrErr, *IdLocOrErr, *ToTPListOrErr,
6766 D->getStorageClass(), TemplateArgs))
6770 import(FromPartial->getInstantiatedFromMember()))
6773 return ToInstOrErr.takeError();
6775 if (FromPartial->isMemberSpecialization())
6776 ToPartial->setMemberSpecialization();
6784 if (GetImportedOrCreateDecl(D2,
D, Importer.
getToContext(), DC,
6786 QualType(),
nullptr,
D->getStorageClass(),
6793 if (!
VarTemplate->findSpecialization(TemplateArgs, InsertPos))
6797 if (Error Err = importInto(
T,
D->getType()))
6798 return std::move(Err);
6801 auto TInfoOrErr =
import(
D->getTypeSourceInfo());
6803 return TInfoOrErr.takeError();
6806 if (
D->getPointOfInstantiation().isValid()) {
6807 if (
ExpectedSLoc POIOrErr =
import(
D->getPointOfInstantiation()))
6810 return POIOrErr.takeError();
6815 if (
D->getTemplateArgsAsWritten())
6818 if (
auto LocOrErr =
import(
D->getQualifierLoc()))
6821 return LocOrErr.takeError();
6823 if (
D->isConstexpr())
6829 return std::move(Err);
6831 if (FoundSpecialization)
6834 addDeclToContexts(
D, D2);
6837 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
6840 return RedeclOrErr.takeError();
6854 return std::move(Err);
6866 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6867 for (
auto *FoundDecl : FoundDecls) {
6871 if (
auto *FoundTemplate = dyn_cast<FunctionTemplateDecl>(FoundDecl)) {
6877 if (
D->isThisDeclarationADefinition() && TemplateWithDef)
6880 FoundByLookup = FoundTemplate;
6888 auto ParamsOrErr =
import(
D->getTemplateParameters());
6890 return ParamsOrErr.takeError();
6894 if (Error Err = importInto(TemplatedFD,
D->getTemplatedDecl()))
6895 return std::move(Err);
6912 OldParamDC.reserve(Params->
size());
6913 llvm::transform(*Params, std::back_inserter(OldParamDC),
6917 if (GetImportedOrCreateDecl(ToFunc,
D, Importer.
getToContext(), DC,
Loc, Name,
6918 Params, TemplatedFD))
6932 ToFunc->setLexicalDeclContext(LexicalDC);
6933 addDeclToContexts(
D, ToFunc);
6936 if (
LT && !OldParamDC.empty()) {
6937 for (
unsigned int I = 0; I < OldParamDC.size(); ++I)
6941 if (FoundByLookup) {
6946 "Found decl must have its templated decl set");
6947 auto *PrevTemplated =
6949 if (TemplatedFD != PrevTemplated)
6952 ToFunc->setPreviousDecl(Recent);
6963 auto ToTemplateParameters =
importChecked(Err,
D->getTemplateParameters());
6964 auto ConstraintExpr =
importChecked(Err,
D->getConstraintExpr());
6966 return std::move(Err);
6969 if (GetImportedOrCreateDecl(To,
D, Importer.
getToContext(), DC, LocationOrErr,
6970 NameDeclOrErr, ToTemplateParameters,
6984 return std::move(Err);
6987 if (GetImportedOrCreateDecl(To,
D, Importer.
getToContext(), DC, RequiresLoc))
7000 return std::move(Err);
7004 return std::move(Err);
7007 if (GetImportedOrCreateDecl(To,
D, Importer.
getToContext(), DC, ToSL, ToArgs))
7019 Importer.
FromDiag(S->getBeginLoc(), diag::err_unsupported_ast_node)
7020 << S->getStmtClassName();
7029 for (
unsigned I = 0,
E = S->getNumOutputs(); I !=
E; I++) {
7033 Names.push_back(ToII);
7036 for (
unsigned I = 0,
E = S->getNumInputs(); I !=
E; I++) {
7040 Names.push_back(ToII);
7044 for (
unsigned I = 0,
E = S->getNumClobbers(); I !=
E; I++) {
7045 if (
auto ClobberOrErr =
import(S->getClobberExpr(I)))
7046 Clobbers.push_back(*ClobberOrErr);
7048 return ClobberOrErr.takeError();
7053 for (
unsigned I = 0,
E = S->getNumOutputs(); I !=
E; I++) {
7054 if (
auto OutputOrErr =
import(S->getOutputConstraintExpr(I)))
7055 Constraints.push_back(*OutputOrErr);
7057 return OutputOrErr.takeError();
7060 for (
unsigned I = 0,
E = S->getNumInputs(); I !=
E; I++) {
7061 if (
auto InputOrErr =
import(S->getInputConstraintExpr(I)))
7062 Constraints.push_back(*InputOrErr);
7064 return InputOrErr.takeError();
7070 return std::move(Err);
7074 return std::move(Err);
7077 S->labels(), Exprs.begin() + S->getNumOutputs() + S->getNumInputs()))
7078 return std::move(Err);
7082 return AsmLocOrErr.takeError();
7083 auto AsmStrOrErr =
import(S->getAsmStringExpr());
7085 return AsmStrOrErr.takeError();
7086 ExpectedSLoc RParenLocOrErr =
import(S->getRParenLoc());
7087 if (!RParenLocOrErr)
7088 return RParenLocOrErr.takeError();
7101 S->getNumClobbers(),
7109 Error Err = Error::success();
7114 return std::move(Err);
7120 if (!ToSemiLocOrErr)
7121 return ToSemiLocOrErr.takeError();
7123 *ToSemiLocOrErr, S->hasLeadingEmptyMacro());
7130 return std::move(Err);
7132 ExpectedSLoc ToLBracLocOrErr =
import(S->getLBracLoc());
7133 if (!ToLBracLocOrErr)
7134 return ToLBracLocOrErr.takeError();
7136 ExpectedSLoc ToRBracLocOrErr =
import(S->getRBracLoc());
7137 if (!ToRBracLocOrErr)
7138 return ToRBracLocOrErr.takeError();
7143 *ToLBracLocOrErr, *ToRBracLocOrErr);
7148 Error Err = Error::success();
7153 auto ToEllipsisLoc =
importChecked(Err, S->getEllipsisLoc());
7156 return std::move(Err);
7159 ToCaseLoc, ToEllipsisLoc, ToColonLoc);
7160 ToStmt->setSubStmt(ToSubStmt);
7167 Error Err = Error::success();
7172 return std::move(Err);
7175 ToDefaultLoc, ToColonLoc, ToSubStmt);
7180 Error Err = Error::success();
7185 return std::move(Err);
7188 ToIdentLoc, ToLabelDecl, ToSubStmt);
7193 if (!ToAttrLocOrErr)
7194 return ToAttrLocOrErr.takeError();
7198 return std::move(Err);
7200 if (!ToSubStmtOrErr)
7201 return ToSubStmtOrErr.takeError();
7204 Importer.
getToContext(), *ToAttrLocOrErr, ToAttrs, *ToSubStmtOrErr);
7209 Error Err = Error::success();
7212 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
7220 return std::move(Err);
7223 ToInit, ToConditionVariable, ToCond, ToLParenLoc,
7224 ToRParenLoc, ToThen, ToElseLoc, ToElse);
7229 Error Err = Error::success();
7231 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
7238 return std::move(Err);
7242 ToCond, ToLParenLoc, ToRParenLoc);
7243 ToStmt->setBody(ToBody);
7244 ToStmt->setSwitchLoc(ToSwitchLoc);
7248 for (
SwitchCase *SC = S->getSwitchCaseList(); SC !=
nullptr;
7249 SC = SC->getNextSwitchCase()) {
7252 return ToSCOrErr.takeError();
7253 if (LastChainedSwitchCase)
7256 ToStmt->setSwitchCaseList(*ToSCOrErr);
7257 LastChainedSwitchCase = *ToSCOrErr;
7265 Error Err = Error::success();
7266 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
7273 return std::move(Err);
7276 ToBody, ToWhileLoc, ToLParenLoc, ToRParenLoc);
7281 Error Err = Error::success();
7288 return std::move(Err);
7291 ToBody, ToCond, ToDoLoc, ToWhileLoc, ToRParenLoc);
7296 Error Err = Error::success();
7299 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
7306 return std::move(Err);
7310 ToInit, ToCond, ToConditionVariable, ToInc, ToBody, ToForLoc, ToLParenLoc,
7316 Error Err = Error::success();
7321 return std::move(Err);
7324 ToLabel, ToGotoLoc, ToLabelLoc);
7329 Error Err = Error::success();
7334 return std::move(Err);
7337 ToGotoLoc, ToStarLoc, ToTarget);
7340template <
typename StmtClass>
7343 Error Err = Error::success();
7344 auto ToLoc = NodeImporter.
importChecked(Err, S->getKwLoc());
7345 auto ToLabelLoc = S->hasLabelTarget()
7348 auto ToDecl = S->hasLabelTarget()
7352 return std::move(Err);
7353 return new (Importer.
getToContext()) StmtClass(ToLoc, ToLabelLoc, ToDecl);
7366 Error Err = Error::success();
7369 auto ToNRVOCandidate =
importChecked(Err, S->getNRVOCandidate());
7371 return std::move(Err);
7379 Error Err = Error::success();
7381 auto ToExceptionDecl =
importChecked(Err, S->getExceptionDecl());
7382 auto ToHandlerBlock =
importChecked(Err, S->getHandlerBlock());
7384 return std::move(Err);
7387 ToCatchLoc, ToExceptionDecl, ToHandlerBlock);
7393 return ToTryLocOrErr.takeError();
7395 ExpectedStmt ToTryBlockOrErr =
import(S->getTryBlock());
7396 if (!ToTryBlockOrErr)
7397 return ToTryBlockOrErr.takeError();
7400 for (
unsigned HI = 0, HE = S->getNumHandlers(); HI != HE; ++HI) {
7402 if (
auto ToHandlerOrErr =
import(FromHandler))
7403 ToHandlers[HI] = *ToHandlerOrErr;
7405 return ToHandlerOrErr.takeError();
7409 cast<CompoundStmt>(*ToTryBlockOrErr), ToHandlers);
7414 Error Err = Error::success();
7421 auto ToLoopVarStmt =
importChecked(Err, S->getLoopVarStmt());
7428 return std::move(Err);
7431 ToInit, ToRangeStmt, ToBeginStmt, ToEndStmt, ToCond, ToInc, ToLoopVarStmt,
7432 ToBody, ToForLoc, ToCoawaitLoc, ToColonLoc, ToRParenLoc);
7437 Error Err = Error::success();
7444 return std::move(Err);
7455 Error Err = Error::success();
7458 auto ToCatchParamDecl =
importChecked(Err, S->getCatchParamDecl());
7461 return std::move(Err);
7464 ToAtCatchLoc, ToRParenLoc, ToCatchParamDecl, ToCatchBody);
7468 ExpectedSLoc ToAtFinallyLocOrErr =
import(S->getAtFinallyLoc());
7469 if (!ToAtFinallyLocOrErr)
7470 return ToAtFinallyLocOrErr.takeError();
7471 ExpectedStmt ToAtFinallyStmtOrErr =
import(S->getFinallyBody());
7472 if (!ToAtFinallyStmtOrErr)
7473 return ToAtFinallyStmtOrErr.takeError();
7475 *ToAtFinallyStmtOrErr);
7480 Error Err = Error::success();
7483 auto ToFinallyStmt =
importChecked(Err, S->getFinallyStmt());
7485 return std::move(Err);
7488 for (
unsigned CI = 0, CE = S->getNumCatchStmts(); CI != CE; ++CI) {
7490 if (
ExpectedStmt ToCatchStmtOrErr =
import(FromCatchStmt))
7491 ToCatchStmts[CI] = *ToCatchStmtOrErr;
7493 return ToCatchStmtOrErr.takeError();
7497 ToAtTryLoc, ToTryBody,
7498 ToCatchStmts.begin(), ToCatchStmts.size(),
7505 Error Err = Error::success();
7506 auto ToAtSynchronizedLoc =
importChecked(Err, S->getAtSynchronizedLoc());
7510 return std::move(Err);
7513 ToAtSynchronizedLoc, ToSynchExpr, ToSynchBody);
7517 ExpectedSLoc ToThrowLocOrErr =
import(S->getThrowLoc());
7518 if (!ToThrowLocOrErr)
7519 return ToThrowLocOrErr.takeError();
7520 ExpectedExpr ToThrowExprOrErr =
import(S->getThrowExpr());
7521 if (!ToThrowExprOrErr)
7522 return ToThrowExprOrErr.takeError();
7524 *ToThrowLocOrErr, *ToThrowExprOrErr);
7531 return ToAtLocOrErr.takeError();
7533 if (!ToSubStmtOrErr)
7534 return ToSubStmtOrErr.takeError();
7549 Error Err = Error::success();
7554 return std::move(Err);
7555 auto ParentContextOrErr = Importer.
ImportContext(
E->getParentContext());
7556 if (!ParentContextOrErr)
7557 return ParentContextOrErr.takeError();
7561 RParenLoc, *ParentContextOrErr);
7566 Error Err = Error::success();
7569 auto ToWrittenTypeInfo =
importChecked(Err,
E->getWrittenTypeInfo());
7573 return std::move(Err);
7576 ToBuiltinLoc, ToSubExpr, ToWrittenTypeInfo, ToRParenLoc, ToType,
7577 E->isMicrosoftABI());
7582 Error Err = Error::success();
7590 return std::move(Err);
7597 bool CondIsTrue = !
E->isConditionDependent() &&
E->isConditionTrue();
7600 ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType,
VK, OK,
7601 ToRParenLoc, CondIsTrue);
7605 Error Err = Error::success();
7612 return std::move(Err);
7617 E->getStoredFPFeaturesOrDefault());
7621 Error Err = Error::success();
7625 const unsigned NumSubExprs =
E->getNumSubExprs();
7629 ToSubExprs.resize(NumSubExprs);
7632 return std::move(Err);
7635 Importer.
getToContext(), ToSubExprs, ToType, ToBeginLoc, ToRParenLoc);
7641 return TypeOrErr.takeError();
7645 return BeginLocOrErr.takeError();
7652 Error Err = Error::success();
7654 Expr *ToControllingExpr =
nullptr;
7656 if (
E->isExprPredicate())
7660 assert((ToControllingExpr || ToControllingType) &&
7661 "Either the controlling expr or type must be nonnull");
7665 return std::move(Err);
7670 return std::move(Err);
7675 return std::move(Err);
7678 if (
E->isResultDependent()) {
7679 if (ToControllingExpr) {
7681 ToCtx, ToGenericLoc, ToControllingExpr,
ArrayRef(ToAssocTypes),
7682 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7686 ToCtx, ToGenericLoc, ToControllingType,
ArrayRef(ToAssocTypes),
7687 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7691 if (ToControllingExpr) {
7693 ToCtx, ToGenericLoc, ToControllingExpr,
ArrayRef(ToAssocTypes),
7694 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7698 ToCtx, ToGenericLoc, ToControllingType,
ArrayRef(ToAssocTypes),
7699 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7705 Error Err = Error::success();
7710 return std::move(Err);
7713 E->getIdentKind(),
E->isTransparent(),
7719 Error Err = Error::success();
7721 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
7726 return std::move(Err);
7729 if (
E->getDecl() !=
E->getFoundDecl()) {
7730 auto FoundDOrErr =
import(
E->getFoundDecl());
7732 return FoundDOrErr.takeError();
7733 ToFoundD = *FoundDOrErr;
7738 if (
E->hasExplicitTemplateArgs()) {
7741 E->template_arguments(), ToTAInfo))
7742 return std::move(Err);
7743 ToResInfo = &ToTAInfo;
7747 Importer.
getToContext(), ToQualifierLoc, ToTemplateKeywordLoc, ToDecl,
7748 E->refersToEnclosingVariableOrCapture(), ToLocation, ToType,
7750 if (
E->hadMultipleCandidates())
7751 ToE->setHadMultipleCandidates(
true);
7752 ToE->setIsImmediateEscalating(
E->isImmediateEscalating());
7759 return TypeOrErr.takeError();
7767 return ToInitOrErr.takeError();
7769 ExpectedSLoc ToEqualOrColonLocOrErr =
import(
E->getEqualOrColonLoc());
7770 if (!ToEqualOrColonLocOrErr)
7771 return ToEqualOrColonLocOrErr.takeError();
7775 for (
unsigned I = 1, N =
E->getNumSubExprs(); I < N; I++) {
7777 ToIndexExprs[I - 1] = *ToArgOrErr;
7779 return ToArgOrErr.takeError();
7784 return std::move(Err);
7788 ToIndexExprs, *ToEqualOrColonLocOrErr,
7789 E->usesGNUSyntax(), *ToInitOrErr);
7796 return ToTypeOrErr.takeError();
7799 if (!ToLocationOrErr)
7800 return ToLocationOrErr.takeError();
7803 *ToTypeOrErr, *ToLocationOrErr);
7809 return ToTypeOrErr.takeError();
7812 if (!ToLocationOrErr)
7813 return ToLocationOrErr.takeError();
7816 Importer.
getToContext(),
E->getValue(), *ToTypeOrErr, *ToLocationOrErr);
7823 return ToTypeOrErr.takeError();
7826 if (!ToLocationOrErr)
7827 return ToLocationOrErr.takeError();
7831 *ToTypeOrErr, *ToLocationOrErr);
7835 auto ToTypeOrErr =
import(
E->
getType());
7837 return ToTypeOrErr.takeError();
7840 if (!ToSubExprOrErr)
7841 return ToSubExprOrErr.takeError();
7844 *ToSubExprOrErr, *ToTypeOrErr);
7848 auto ToTypeOrErr =
import(
E->
getType());
7850 return ToTypeOrErr.takeError();
7853 if (!ToLocationOrErr)
7854 return ToLocationOrErr.takeError();
7857 Importer.
getToContext(),
E->getValue(), *ToTypeOrErr, *ToLocationOrErr,
7864 return ToTypeOrErr.takeError();
7867 if (!ToLocationOrErr)
7868 return ToLocationOrErr.takeError();
7871 E->getValue(),
E->getKind(), *ToTypeOrErr, *ToLocationOrErr);
7877 return ToTypeOrErr.takeError();
7881 E->tokloc_begin(),
E->tokloc_end(), ToLocations.begin()))
7882 return std::move(Err);
7885 E->getKind(),
E->isPascal(), *ToTypeOrErr,
7891 Error Err = Error::success();
7893 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
7897 return std::move(Err);
7901 ToInitializer,
E->isFileScope());
7906 Error Err = Error::success();
7911 return std::move(Err);
7915 E->getSubExprs(),
E->getSubExprs() +
E->getNumSubExprs(),
7917 return std::move(Err);
7921 ToBuiltinLoc, ToExprs, ToType,
E->getOp(), ToRParenLoc);
7925 Error Err = Error::success();
7931 return std::move(Err);
7934 ToAmpAmpLoc, ToLabelLoc, ToLabel, ToType);
7937 Error Err = Error::success();
7941 return std::move(Err);
7946 Error Err = Error::success();
7951 return std::move(Err);
7954 ParenExpr(ToLParen, ToRParen, ToSubExpr);
7960 return std::move(Err);
7963 if (!ToLParenLocOrErr)
7964 return ToLParenLocOrErr.takeError();
7967 if (!ToRParenLocOrErr)
7968 return ToRParenLocOrErr.takeError();
7971 ToExprs, *ToRParenLocOrErr);
7975 Error Err = Error::success();
7981 return std::move(Err);
7984 StmtExpr(ToSubStmt, ToType, ToLParenLoc, ToRParenLoc,
7985 E->getTemplateDepth());
7989 Error Err = Error::success();
7994 return std::move(Err);
7997 E->hasStoredFPFeatures());
7998 UO->setType(ToType);
7999 UO->setSubExpr(ToSubExpr);
8000 UO->setOpcode(
E->getOpcode());
8001 UO->setOperatorLoc(ToOperatorLoc);
8002 UO->setCanOverflow(
E->canOverflow());
8003 if (
E->hasStoredFPFeatures())
8004 UO->setStoredFPFeatures(
E->getStoredFPFeatures());
8012 Error Err = Error::success();
8017 return std::move(Err);
8019 if (
E->isArgumentType()) {
8021 import(
E->getArgumentTypeInfo());
8022 if (!ToArgumentTypeInfoOrErr)
8023 return ToArgumentTypeInfoOrErr.takeError();
8026 E->getKind(), *ToArgumentTypeInfoOrErr, ToType, ToOperatorLoc,
8030 ExpectedExpr ToArgumentExprOrErr =
import(
E->getArgumentExpr());
8031 if (!ToArgumentExprOrErr)
8032 return ToArgumentExprOrErr.takeError();
8035 E->getKind(), *ToArgumentExprOrErr, ToType, ToOperatorLoc, ToRParenLoc);
8039 Error Err = Error::success();
8045 return std::move(Err);
8048 Importer.
getToContext(), ToLHS, ToRHS,
E->getOpcode(), ToType,
8050 E->getFPFeatures());
8054 Error Err = Error::success();
8062 return std::move(Err);
8065 ToCond, ToQuestionLoc, ToLHS, ToColonLoc, ToRHS, ToType,
8071 Error Err = Error::success();
8081 return std::move(Err);
8084 ToCommon, ToOpaqueValue, ToCond, ToTrueExpr, ToFalseExpr,
8091 Error Err = Error::success();
8094 return std::move(Err);
8101 Error Err = Error::success();
8103 auto ToQueriedTypeSourceInfo =
8105 auto ToDimensionExpression =
importChecked(Err,
E->getDimensionExpression());
8109 return std::move(Err);
8112 ToBeginLoc,
E->getTrait(), ToQueriedTypeSourceInfo,
E->getValue(),
8113 ToDimensionExpression, ToEndLoc, ToType);
8117 Error Err = Error::success();
8119 auto ToQueriedExpression =
importChecked(Err,
E->getQueriedExpression());
8123 return std::move(Err);
8126 ToBeginLoc,
E->getTrait(), ToQueriedExpression,
E->getValue(),
8131 Error Err = Error::success();
8136 return std::move(Err);
8143 Error Err = Error::success();
8149 return std::move(Err);
8158 Error Err = Error::success();
8162 auto ToComputationLHSType =
importChecked(Err,
E->getComputationLHSType());
8163 auto ToComputationResultType =
8167 return std::move(Err);
8170 Importer.
getToContext(), ToLHS, ToRHS,
E->getOpcode(), ToType,
8173 ToComputationLHSType, ToComputationResultType);
8180 if (
auto SpecOrErr =
import(*I))
8181 Path.push_back(*SpecOrErr);
8183 return SpecOrErr.takeError();
8191 return ToTypeOrErr.takeError();
8194 if (!ToSubExprOrErr)
8195 return ToSubExprOrErr.takeError();
8198 if (!ToBasePathOrErr)
8199 return ToBasePathOrErr.takeError();
8202 Importer.
getToContext(), *ToTypeOrErr,
E->getCastKind(), *ToSubExprOrErr,
8207 Error Err = Error::success();
8210 auto ToTypeInfoAsWritten =
importChecked(Err,
E->getTypeInfoAsWritten());
8212 return std::move(Err);
8215 if (!ToBasePathOrErr)
8216 return ToBasePathOrErr.takeError();
8220 case Stmt::CStyleCastExprClass: {
8221 auto *CCE = cast<CStyleCastExpr>(
E);
8222 ExpectedSLoc ToLParenLocOrErr =
import(CCE->getLParenLoc());
8223 if (!ToLParenLocOrErr)
8224 return ToLParenLocOrErr.takeError();
8225 ExpectedSLoc ToRParenLocOrErr =
import(CCE->getRParenLoc());
8226 if (!ToRParenLocOrErr)
8227 return ToRParenLocOrErr.takeError();
8230 ToSubExpr, ToBasePath, CCE->getFPFeatures(), ToTypeInfoAsWritten,
8231 *ToLParenLocOrErr, *ToRParenLocOrErr);
8234 case Stmt::CXXFunctionalCastExprClass: {
8235 auto *FCE = cast<CXXFunctionalCastExpr>(
E);
8236 ExpectedSLoc ToLParenLocOrErr =
import(FCE->getLParenLoc());
8237 if (!ToLParenLocOrErr)
8238 return ToLParenLocOrErr.takeError();
8239 ExpectedSLoc ToRParenLocOrErr =
import(FCE->getRParenLoc());
8240 if (!ToRParenLocOrErr)
8241 return ToRParenLocOrErr.takeError();
8244 E->getCastKind(), ToSubExpr, ToBasePath, FCE->getFPFeatures(),
8245 *ToLParenLocOrErr, *ToRParenLocOrErr);
8248 case Stmt::ObjCBridgedCastExprClass: {
8249 auto *OCE = cast<ObjCBridgedCastExpr>(
E);
8250 ExpectedSLoc ToLParenLocOrErr =
import(OCE->getLParenLoc());
8251 if (!ToLParenLocOrErr)
8252 return ToLParenLocOrErr.takeError();
8253 ExpectedSLoc ToBridgeKeywordLocOrErr =
import(OCE->getBridgeKeywordLoc());
8254 if (!ToBridgeKeywordLocOrErr)
8255 return ToBridgeKeywordLocOrErr.takeError();
8257 *ToLParenLocOrErr, OCE->getBridgeKind(),
E->getCastKind(),
8258 *ToBridgeKeywordLocOrErr, ToTypeInfoAsWritten, ToSubExpr);
8260 case Stmt::BuiltinBitCastExprClass: {
8261 auto *BBC = cast<BuiltinBitCastExpr>(
E);
8262 ExpectedSLoc ToKWLocOrErr =
import(BBC->getBeginLoc());
8264 return ToKWLocOrErr.takeError();
8265 ExpectedSLoc ToRParenLocOrErr =
import(BBC->getEndLoc());
8266 if (!ToRParenLocOrErr)
8267 return ToRParenLocOrErr.takeError();
8270 ToTypeInfoAsWritten, *ToKWLocOrErr, *ToRParenLocOrErr);
8273 llvm_unreachable(
"Cast expression of unsupported type!");
8280 for (
int I = 0, N =
E->getNumComponents(); I < N; ++I) {
8286 Error Err = Error::success();
8290 return std::move(Err);
8299 auto ToBSOrErr =
import(FromNode.
getBase());
8301 return ToBSOrErr.takeError();
8306 auto ToFieldOrErr =
import(FromNode.
getField());
8308 return ToFieldOrErr.takeError();
8309 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, *ToFieldOrErr, ToEndLoc));
8314 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, ToII, ToEndLoc));
8321 for (
int I = 0, N =
E->getNumExpressions(); I < N; ++I) {
8323 if (!ToIndexExprOrErr)
8324 return ToIndexExprOrErr.takeError();
8325 ToExprs[I] = *ToIndexExprOrErr;
8328 Error Err = Error::success();
8330 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
8334 return std::move(Err);
8337 Importer.
getToContext(), ToType, ToOperatorLoc, ToTypeSourceInfo, ToNodes,
8338 ToExprs, ToRParenLoc);
8342 Error Err = Error::success();
8348 return std::move(Err);
8357 ToType, ToOperand, ToCanThrow, ToBeginLoc, ToEndLoc);
8361 Error Err = Error::success();
8366 return std::move(Err);
8369 ToSubExpr, ToType, ToThrowLoc,
E->isThrownVariableInScope());
8374 if (!ToUsedLocOrErr)
8375 return ToUsedLocOrErr.takeError();
8377 auto ToParamOrErr =
import(
E->getParam());
8379 return ToParamOrErr.takeError();
8381 auto UsedContextOrErr = Importer.
ImportContext(
E->getUsedContext());
8382 if (!UsedContextOrErr)
8383 return UsedContextOrErr.takeError();
8393 std::optional<ParmVarDecl *> FromParam =
8395 assert(FromParam &&
"ParmVarDecl was not imported?");
8398 return std::move(Err);
8400 Expr *RewrittenInit =
nullptr;
8401 if (
E->hasRewrittenInit()) {
8404 return ExprOrErr.takeError();
8405 RewrittenInit = ExprOrErr.get();
8408 *ToParamOrErr, RewrittenInit,
8414 Error Err = Error::success();
8416 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
8419 return std::move(Err);
8422 ToType, ToTypeSourceInfo, ToRParenLoc);
8428 if (!ToSubExprOrErr)
8429 return ToSubExprOrErr.takeError();
8431 auto ToDtorOrErr =
import(
E->getTemporary()->getDestructor());
8433 return ToDtorOrErr.takeError();
8443 Error Err = Error::success();
8446 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
8447 auto ToParenOrBraceRange =
importChecked(Err,
E->getParenOrBraceRange());
8449 return std::move(Err);
8453 return std::move(Err);
8456 Importer.
getToContext(), ToConstructor, ToType, ToTypeSourceInfo, ToArgs,
8457 ToParenOrBraceRange,
E->hadMultipleCandidates(),
8458 E->isListInitialization(),
E->isStdInitListInitialization(),
8459 E->requiresZeroInitialization());
8466 return std::move(Err);
8468 Error Err = Error::success();
8472 return std::move(Err);
8476 if (GetImportedOrCreateDecl(To,
D, Temporary, ExtendingDecl,
8477 D->getManglingNumber()))
8487 Error Err = Error::success();
8490 Err,
E->getLifetimeExtendedTemporaryDecl() ?
nullptr :
E->getSubExpr());
8491 auto ToMaterializedDecl =
8494 return std::move(Err);
8496 if (!ToTemporaryExpr)
8497 ToTemporaryExpr = cast<Expr>(ToMaterializedDecl->getTemporaryExpr());
8500 ToType, ToTemporaryExpr,
E->isBoundToLvalueReference(),
8501 ToMaterializedDecl);
8507 Error Err = Error::success();
8511 return std::move(Err);
8518 Error Err = Error::success();
8524 return std::move(Err);
8528 Length =
E->getPackLength();
8531 if (
E->isPartiallySubstituted()) {
8533 ToPartialArguments))
8534 return std::move(Err);
8538 Importer.
getToContext(), ToOperatorLoc, ToPack, ToPackLoc, ToRParenLoc,
8539 Length, ToPartialArguments);
8544 Error Err = Error::success();
8546 auto ToOperatorDelete =
importChecked(Err,
E->getOperatorDelete());
8551 auto ToAllocatedTypeSourceInfo =
8554 auto ToDirectInitRange =
importChecked(Err,
E->getDirectInitRange());
8556 return std::move(Err);
8561 return std::move(Err);
8565 ToOperatorDelete,
E->implicitAllocationParameters(),
8566 E->doesUsualArrayDeleteWantSize(), ToPlacementArgs, ToTypeIdParens,
8567 ToArraySize,
E->getInitializationStyle(), ToInitializer, ToType,
8568 ToAllocatedTypeSourceInfo, ToSourceRange, ToDirectInitRange);
8572 Error Err = Error::success();
8574 auto ToOperatorDelete =
importChecked(Err,
E->getOperatorDelete());
8578 return std::move(Err);
8581 ToType,
E->isGlobalDelete(),
E->isArrayForm(),
E->isArrayFormAsWritten(),
8582 E->doesUsualArrayDeleteWantSize(), ToOperatorDelete, ToArgument,
8587 Error Err = Error::success();
8591 auto ToParenOrBraceRange =
importChecked(Err,
E->getParenOrBraceRange());
8593 return std::move(Err);
8597 return std::move(Err);
8600 Importer.
getToContext(), ToType, ToLocation, ToConstructor,
8601 E->isElidable(), ToArgs,
E->hadMultipleCandidates(),
8602 E->isListInitialization(),
E->isStdInitListInitialization(),
8603 E->requiresZeroInitialization(),
E->getConstructionKind(),
8604 ToParenOrBraceRange);
8611 if (!ToSubExprOrErr)
8612 return ToSubExprOrErr.takeError();
8616 return std::move(Err);
8619 Importer.
getToContext(), *ToSubExprOrErr,
E->cleanupsHaveSideEffects(),
8624 Error Err = Error::success();
8629 return std::move(Err);
8633 return std::move(Err);
8637 E->getFPFeatures());
8643 return ToTypeOrErr.takeError();
8646 if (!ToLocationOrErr)
8647 return ToLocationOrErr.takeError();
8650 *ToTypeOrErr,
E->isImplicit());
8656 return ToTypeOrErr.takeError();
8659 if (!ToLocationOrErr)
8660 return ToLocationOrErr.takeError();
8663 *ToTypeOrErr, *ToLocationOrErr);
8667 Error Err = Error::success();
8671 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
8675 auto ToName =
importChecked(Err,
E->getMemberNameInfo().getName());
8676 auto ToLoc =
importChecked(Err,
E->getMemberNameInfo().getLoc());
8678 return std::move(Err);
8686 if (
E->hasExplicitTemplateArgs()) {
8689 E->template_arguments(), ToTAInfo))
8690 return std::move(Err);
8691 ResInfo = &ToTAInfo;
8695 ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8696 ToMemberDecl, ToFoundDecl, ToMemberNameInfo,
8703 Error Err = Error::success();
8707 auto ToScopeTypeInfo =
importChecked(Err,
E->getScopeTypeInfo());
8708 auto ToColonColonLoc =
importChecked(Err,
E->getColonColonLoc());
8711 return std::move(Err);
8716 ExpectedSLoc ToDestroyedTypeLocOrErr =
import(
E->getDestroyedTypeLoc());
8717 if (!ToDestroyedTypeLocOrErr)
8718 return ToDestroyedTypeLocOrErr.takeError();
8721 if (
auto ToTIOrErr =
import(
E->getDestroyedTypeInfo()))
8724 return ToTIOrErr.takeError();
8728 Importer.
getToContext(), ToBase,
E->isArrow(), ToOperatorLoc,
8729 ToQualifierLoc, ToScopeTypeInfo, ToColonColonLoc, ToTildeLoc, Storage);
8734 Error Err = Error::success();
8738 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
8739 auto ToFirstQualifierFoundInScope =
8742 return std::move(Err);
8744 Expr *ToBase =
nullptr;
8745 if (!
E->isImplicitAccess()) {
8747 ToBase = *ToBaseOrErr;
8749 return ToBaseOrErr.takeError();
8754 if (
E->hasExplicitTemplateArgs()) {
8757 E->template_arguments(), ToTAInfo))
8758 return std::move(Err);
8759 ResInfo = &ToTAInfo;
8764 return std::move(Err);
8770 return std::move(Err);
8773 Importer.
getToContext(), ToBase, ToType,
E->isArrow(), ToOperatorLoc,
8774 ToQualifierLoc, ToTemplateKeywordLoc, ToFirstQualifierFoundInScope,
8775 ToMemberNameInfo, ResInfo);
8780 Error Err = Error::success();
8782 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
8788 return std::move(Err);
8792 return std::move(Err);
8796 if (
E->hasExplicitTemplateArgs()) {
8799 return std::move(Err);
8800 ResInfo = &ToTAInfo;
8804 Importer.
getToContext(), ToQualifierLoc, ToTemplateKeywordLoc,
8805 ToNameInfo, ResInfo);
8810 Error Err = Error::success();
8814 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
8816 return std::move(Err);
8821 return std::move(Err);
8824 Importer.
getToContext(), ToType, ToTypeSourceInfo, ToLParenLoc,
8825 ArrayRef(ToArgs), ToRParenLoc,
E->isListInitialization());
8831 if (!ToNamingClassOrErr)
8832 return ToNamingClassOrErr.takeError();
8834 auto ToQualifierLocOrErr =
import(
E->getQualifierLoc());
8835 if (!ToQualifierLocOrErr)
8836 return ToQualifierLocOrErr.takeError();
8838 Error Err = Error::success();
8842 return std::move(Err);
8847 return std::move(Err);
8850 for (
auto *
D :
E->decls())
8851 if (
auto ToDOrErr =
import(
D))
8852 ToDecls.
addDecl(cast<NamedDecl>(*ToDOrErr));
8854 return ToDOrErr.takeError();
8856 if (
E->hasExplicitTemplateArgs()) {
8859 E->getLAngleLoc(),
E->getRAngleLoc(),
E->template_arguments(),
8861 return std::move(Err);
8863 ExpectedSLoc ToTemplateKeywordLocOrErr =
import(
E->getTemplateKeywordLoc());
8864 if (!ToTemplateKeywordLocOrErr)
8865 return ToTemplateKeywordLocOrErr.takeError();
8867 const bool KnownDependent =
8869 ExprDependence::TypeValue;
8871 Importer.
getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8872 *ToTemplateKeywordLocOrErr, ToNameInfo,
E->requiresADL(), &ToTAInfo,
8873 ToDecls.
begin(), ToDecls.
end(), KnownDependent,
8878 Importer.
getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8879 ToNameInfo,
E->requiresADL(), ToDecls.
begin(), ToDecls.
end(),
8886 Error Err = Error::success();
8890 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
8894 return std::move(Err);
8899 return std::move(Err);
8902 for (
Decl *
D :
E->decls())
8903 if (
auto ToDOrErr =
import(
D))
8904 ToDecls.
addDecl(cast<NamedDecl>(*ToDOrErr));
8906 return ToDOrErr.takeError();
8910 if (
E->hasExplicitTemplateArgs()) {
8912 E->copyTemplateArgumentsInto(FromTAInfo);
8914 return std::move(Err);
8915 ResInfo = &ToTAInfo;
8918 Expr *ToBase =
nullptr;
8919 if (!
E->isImplicitAccess()) {
8921 ToBase = *ToBaseOrErr;
8923 return ToBaseOrErr.takeError();
8927 Importer.
getToContext(),
E->hasUnresolvedUsing(), ToBase, ToType,
8928 E->isArrow(), ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8929 ToNameInfo, ResInfo, ToDecls.
begin(), ToDecls.
end());
8933 Error Err = Error::success();
8938 return std::move(Err);
8940 unsigned NumArgs =
E->getNumArgs();
8943 return std::move(Err);
8945 if (
const auto *OCE = dyn_cast<CXXOperatorCallExpr>(
E)) {
8947 Importer.
getToContext(), OCE->getOperator(), ToCallee, ToArgs, ToType,
8948 OCE->getValueKind(), ToRParenLoc, OCE->getFPFeatures(),
8949 OCE->getADLCallKind());
8954 0,
E->getADLCallKind());
8959 auto ToClassOrErr =
import(FromClass);
8961 return ToClassOrErr.takeError();
8964 auto ToCallOpOrErr =
import(
E->getCallOperator());
8966 return ToCallOpOrErr.takeError();
8970 return std::move(Err);
8972 Error Err = Error::success();
8973 auto ToIntroducerRange =
importChecked(Err,
E->getIntroducerRange());
8974 auto ToCaptureDefaultLoc =
importChecked(Err,
E->getCaptureDefaultLoc());
8977 return std::move(Err);
8980 E->getCaptureDefault(), ToCaptureDefaultLoc,
8981 E->hasExplicitParameters(),
8982 E->hasExplicitResultType(), ToCaptureInits,
8988 Error Err = Error::success();
8993 return std::move(Err);
8997 return std::move(Err);
9001 ToCtx, ToLBraceLoc, ToExprs, ToRBraceLoc);
9004 if (
E->hasArrayFiller()) {
9005 if (
ExpectedExpr ToFillerOrErr =
import(
E->getArrayFiller()))
9008 return ToFillerOrErr.takeError();
9011 if (
FieldDecl *FromFD =
E->getInitializedFieldInUnion()) {
9012 if (
auto ToFDOrErr =
import(FromFD))
9015 return ToFDOrErr.takeError();
9019 if (
auto ToSyntFormOrErr =
import(SyntForm))
9022 return ToSyntFormOrErr.takeError();
9036 return ToTypeOrErr.takeError();
9039 if (!ToSubExprOrErr)
9040 return ToSubExprOrErr.takeError();
9043 *ToTypeOrErr, *ToSubExprOrErr);
9048 Error Err = Error::success();
9053 return std::move(Err);
9056 ToLocation, ToType, ToConstructor,
E->constructsVBase(),
9057 E->inheritedFromVBase());
9061 Error Err = Error::success();
9066 return std::move(Err);
9069 ToType, ToCommonExpr, ToSubExpr);
9075 return ToTypeOrErr.takeError();
9081 if (!ToBeginLocOrErr)
9082 return ToBeginLocOrErr.takeError();
9084 auto ToFieldOrErr =
import(
E->getField());
9086 return ToFieldOrErr.takeError();
9088 auto UsedContextOrErr = Importer.
ImportContext(
E->getUsedContext());
9089 if (!UsedContextOrErr)
9090 return UsedContextOrErr.takeError();
9094 "Field should have in-class initializer if there is a default init "
9095 "expression that uses it.");
9100 auto ToInClassInitializerOrErr =
9101 import(
E->getField()->getInClassInitializer());
9102 if (!ToInClassInitializerOrErr)
9103 return ToInClassInitializerOrErr.takeError();
9107 Expr *RewrittenInit =
nullptr;
9108 if (
E->hasRewrittenInit()) {
9111 return ExprOrErr.takeError();
9112 RewrittenInit = ExprOrErr.get();
9116 ToField, *UsedContextOrErr, RewrittenInit);
9120 Error Err = Error::success();
9123 auto ToTypeInfoAsWritten =
importChecked(Err,
E->getTypeInfoAsWritten());
9126 auto ToAngleBrackets =
importChecked(Err,
E->getAngleBrackets());
9128 return std::move(Err);
9133 if (!ToBasePathOrErr)
9134 return ToBasePathOrErr.takeError();
9136 if (
auto CCE = dyn_cast<CXXStaticCastExpr>(
E)) {
9138 Importer.
getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9139 ToTypeInfoAsWritten, CCE->getFPFeatures(), ToOperatorLoc, ToRParenLoc,
9141 }
else if (isa<CXXDynamicCastExpr>(
E)) {
9143 Importer.
getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9144 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9145 }
else if (isa<CXXReinterpretCastExpr>(
E)) {
9147 Importer.
getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9148 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9149 }
else if (isa<CXXConstCastExpr>(
E)) {
9151 Importer.
getToContext(), ToType,
VK, ToSubExpr, ToTypeInfoAsWritten,
9152 ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9154 llvm_unreachable(
"Unknown cast type");
9155 return make_error<ASTImportError>();
9161 Error Err = Error::success();
9164 auto ToAssociatedDecl =
importChecked(Err,
E->getAssociatedDecl());
9167 return std::move(Err);
9170 ToType,
E->
getValueKind(), ToNameLoc, ToReplacement, ToAssociatedDecl,
9171 E->getIndex(),
E->getPackIndex(),
E->isReferenceParameter(),
9176 Error Err = Error::success();
9181 return std::move(Err);
9185 return std::move(Err);
9187 if (
E->isStoredAsBoolean()) {
9192 E->getTrait(), ToArgs, ToEndLoc, ToValue);
9195 E->getTrait(), ToArgs, ToEndLoc,
9202 return ToTypeOrErr.takeError();
9205 if (!ToSourceRangeOrErr)
9206 return ToSourceRangeOrErr.takeError();
9208 if (
E->isTypeOperand()) {
9209 if (
auto ToTSIOrErr =
import(
E->getTypeOperandSourceInfo()))
9211 *ToTypeOrErr, *ToTSIOrErr, *ToSourceRangeOrErr);
9213 return ToTSIOrErr.takeError();
9216 ExpectedExpr ToExprOperandOrErr =
import(
E->getExprOperand());
9217 if (!ToExprOperandOrErr)
9218 return ToExprOperandOrErr.takeError();
9221 *ToTypeOrErr, *ToExprOperandOrErr, *ToSourceRangeOrErr);
9225 Error Err = Error::success();
9236 return std::move(Err);
9239 CXXFoldExpr(ToType, ToCallee, ToLParenLoc, ToLHS,
E->getOperator(),
9240 ToEllipsisLoc, ToRHS, ToRParenLoc,
E->getNumExpansions());
9244 Error Err = Error::success();
9252 return std::move(Err);
9256 return std::move(Err);
9258 E->getRequirements().size());
9261 return std::move(Err);
9263 LParenLoc, LocalParameters, RParenLoc,
9264 Requirements, RBraceLoc);
9269 Error Err = Error::success();
9273 return std::move(Err);
9281 return std::move(Err);
9289 Error ImportErrors = Error::success();
9291 if (
auto ImportedOrErr =
import(FromOverriddenMethod))
9293 (*ImportedOrErr)->getCanonicalDecl()));
9296 joinErrors(std::move(ImportErrors), ImportedOrErr.takeError());
9298 return ImportErrors;
9304 std::shared_ptr<ASTImporterSharedState> SharedState)
9305 : SharedState(SharedState), ToContext(ToContext), FromContext(FromContext),
9306 ToFileManager(ToFileManager), FromFileManager(FromFileManager),
9311 this->SharedState = std::make_shared<ASTImporterSharedState>();
9321 assert(F && (isa<FieldDecl>(*F) || isa<IndirectFieldDecl>(*F)) &&
9322 "Try to get field index for non-field.");
9326 return std::nullopt;
9329 for (
const auto *
D : Owner->decls()) {
9333 if (isa<FieldDecl>(*
D) || isa<IndirectFieldDecl>(*
D))
9337 llvm_unreachable(
"Field was not found in its parent context.");
9339 return std::nullopt;
9352 if (SharedState->getLookupTable()) {
9359 getCanonicalForwardRedeclChain<NamespaceDecl>(
9360 dyn_cast<NamespaceDecl>(ReDC));
9361 for (
auto *
D : NSChain) {
9363 SharedState->getLookupTable()->lookup(dyn_cast<NamespaceDecl>(
D),
9370 SharedState->getLookupTable()->lookup(ReDC, Name);
9375 FoundDeclsTy
Result(NoloadLookupResult.
begin(), NoloadLookupResult.
end());
9392void ASTImporter::AddToLookupTable(
Decl *ToD) {
9393 SharedState->addDeclToLookup(ToD);
9399 return Importer.
Visit(FromD);
9423 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
9424 ImportedTypes.find(FromT);
9425 if (Pos != ImportedTypes.end())
9432 return ToTOrErr.takeError();
9435 ImportedTypes[FromT] = ToTOrErr->getTypePtr();
9437 return ToTOrErr->getTypePtr();
9446 return ToTyOrErr.takeError();
9459 return TOrErr.takeError();
9462 return BeginLocOrErr.takeError();
9471template <
typename T>
struct AttrArgImporter {
9472 AttrArgImporter(
const AttrArgImporter<T> &) =
delete;
9473 AttrArgImporter(AttrArgImporter<T> &&) =
default;
9474 AttrArgImporter<T> &operator=(
const AttrArgImporter<T> &) =
delete;
9475 AttrArgImporter<T> &operator=(AttrArgImporter<T> &&) =
default;
9478 : To(I.importChecked(Err, From)) {}
9480 const T &value() {
return To; }
9491template <
typename T>
struct AttrArgArrayImporter {
9492 AttrArgArrayImporter(
const AttrArgArrayImporter<T> &) =
delete;
9493 AttrArgArrayImporter(AttrArgArrayImporter<T> &&) =
default;
9494 AttrArgArrayImporter<T> &operator=(
const AttrArgArrayImporter<T> &) =
delete;
9495 AttrArgArrayImporter<T> &operator=(AttrArgArrayImporter<T> &&) =
default;
9498 const llvm::iterator_range<T *> &From,
9499 unsigned ArraySize) {
9502 To.reserve(ArraySize);
9506 T *value() {
return To.data(); }
9513 Error Err{Error::success()};
9514 Attr *ToAttr =
nullptr;
9519 AttrImporter(
ASTImporter &I) : Importer(I), NImporter(I) {}
9522 template <
typename T>
T *castAttrAs() {
return cast<T>(ToAttr); }
9523 template <
typename T>
const T *castAttrAs()
const {
return cast<T>(ToAttr); }
9528 template <
class T> AttrArgImporter<T> importArg(
const T &From) {
9529 return AttrArgImporter<T>(NImporter, Err, From);
9535 template <
typename T>
9536 AttrArgArrayImporter<T> importArrayArg(
const llvm::iterator_range<T *> &From,
9537 unsigned ArraySize) {
9538 return AttrArgArrayImporter<T>(NImporter, Err, From, ArraySize);
9549 template <
typename T,
typename... Arg>
9550 void importAttr(
const T *FromAttr, Arg &&...ImportedArg) {
9551 static_assert(std::is_base_of<Attr, T>::value,
9552 "T should be subclass of Attr.");
9553 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9557 Importer.
Import(FromAttr->getScopeName());
9568 FromAttr->getParsedKind(), FromAttr->getForm());
9572 std::forward<Arg>(ImportedArg)..., ToI);
9576 if (
auto *ToInheritableAttr = dyn_cast<InheritableAttr>(ToAttr))
9577 ToInheritableAttr->setInherited(FromAttr->isInherited());
9583 void cloneAttr(
const Attr *FromAttr) {
9584 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9598 return std::move(Err);
9599 assert(ToAttr &&
"Attribute should be created.");
9606 AttrImporter AI(*
this);
9609 switch (FromAttr->
getKind()) {
9610 case attr::Aligned: {
9611 auto *From = cast<AlignedAttr>(FromAttr);
9612 if (From->isAlignmentExpr())
9613 AI.importAttr(From,
true, AI.importArg(From->getAlignmentExpr()).value());
9615 AI.importAttr(From,
false,
9616 AI.importArg(From->getAlignmentType()).value());
9620 case attr::AlignValue: {
9621 auto *From = cast<AlignValueAttr>(FromAttr);
9622 AI.importAttr(From, AI.importArg(From->getAlignment()).value());
9626 case attr::Format: {
9627 const auto *From = cast<FormatAttr>(FromAttr);
9628 AI.importAttr(From,
Import(From->getType()), From->getFormatIdx(),
9629 From->getFirstArg());
9633 case attr::EnableIf: {
9634 const auto *From = cast<EnableIfAttr>(FromAttr);
9635 AI.importAttr(From, AI.importArg(From->getCond()).value(),
9636 From->getMessage());
9640 case attr::AssertCapability: {
9641 const auto *From = cast<AssertCapabilityAttr>(FromAttr);
9643 AI.importArrayArg(From->args(), From->args_size()).value(),
9647 case attr::AcquireCapability: {
9648 const auto *From = cast<AcquireCapabilityAttr>(FromAttr);
9650 AI.importArrayArg(From->args(), From->args_size()).value(),
9654 case attr::TryAcquireCapability: {
9655 const auto *From = cast<TryAcquireCapabilityAttr>(FromAttr);
9656 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9657 AI.importArrayArg(From->args(), From->args_size()).value(),
9661 case attr::ReleaseCapability: {
9662 const auto *From = cast<ReleaseCapabilityAttr>(FromAttr);
9664 AI.importArrayArg(From->args(), From->args_size()).value(),
9668 case attr::RequiresCapability: {
9669 const auto *From = cast<RequiresCapabilityAttr>(FromAttr);
9671 AI.importArrayArg(From->args(), From->args_size()).value(),
9675 case attr::GuardedBy: {
9676 const auto *From = cast<GuardedByAttr>(FromAttr);
9677 AI.importAttr(From, AI.importArg(From->getArg()).value());
9680 case attr::PtGuardedBy: {
9681 const auto *From = cast<PtGuardedByAttr>(FromAttr);
9682 AI.importAttr(From, AI.importArg(From->getArg()).value());
9685 case attr::AcquiredAfter: {
9686 const auto *From = cast<AcquiredAfterAttr>(FromAttr);
9688 AI.importArrayArg(From->args(), From->args_size()).value(),
9692 case attr::AcquiredBefore: {
9693 const auto *From = cast<AcquiredBeforeAttr>(FromAttr);
9695 AI.importArrayArg(From->args(), From->args_size()).value(),
9699 case attr::LockReturned: {
9700 const auto *From = cast<LockReturnedAttr>(FromAttr);
9701 AI.importAttr(From, AI.importArg(From->getArg()).value());
9704 case attr::LocksExcluded: {
9705 const auto *From = cast<LocksExcludedAttr>(FromAttr);
9707 AI.importArrayArg(From->args(), From->args_size()).value(),
9715 AI.cloneAttr(FromAttr);
9720 return std::move(AI).getResult();
9724 return ImportedDecls.lookup(FromD);
9728 auto FromDPos = ImportedFromDecls.find(ToD);
9729 if (FromDPos == ImportedFromDecls.end())
9731 return FromDPos->second->getTranslationUnitDecl();
9739 ImportPath.
push(FromD);
9740 auto ImportPathBuilder =
9741 llvm::make_scope_exit([
this]() { ImportPath.
pop(); });
9746 return make_error<ASTImportError>(*Error);
9752 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9754 return make_error<ASTImportError>(*Error);
9771 auto Pos = ImportedDecls.find(FromD);
9772 if (Pos != ImportedDecls.end()) {
9775 auto *ToD = Pos->second;
9776 ImportedDecls.erase(Pos);
9788 auto PosF = ImportedFromDecls.find(ToD);
9789 if (PosF != ImportedFromDecls.end()) {
9794 SharedState->removeDeclFromLookup(ToD);
9795 ImportedFromDecls.erase(PosF);
9807 handleAllErrors(ToDOrErr.takeError(),
9811 if (Pos != ImportedDecls.end())
9812 SharedState->setImportDeclError(Pos->second, ErrOut);
9816 for (
const auto &
Path : SavedImportPaths[FromD]) {
9819 Decl *PrevFromDi = FromD;
9822 if (FromDi == FromD)
9829 PrevFromDi = FromDi;
9833 auto Ii = ImportedDecls.find(FromDi);
9834 if (Ii != ImportedDecls.end())
9835 SharedState->setImportDeclError(Ii->second, ErrOut);
9840 SavedImportPaths.erase(FromD);
9843 return make_error<ASTImportError>(ErrOut);
9855 return make_error<ASTImportError>(*Err);
9861 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9863 return make_error<ASTImportError>(*Error);
9866 assert(ImportedDecls.count(FromD) != 0 &&
"Missing call to MapImported?");
9870 auto ToAttrOrErr =
Import(FromAttr);
9874 return ToAttrOrErr.takeError();
9881 SavedImportPaths.erase(FromD);
9896 return ToDCOrErr.takeError();
9897 auto *ToDC = cast<DeclContext>(*ToDCOrErr);
9901 if (
auto *ToRecord = dyn_cast<RecordDecl>(ToDC)) {
9902 auto *FromRecord = cast<RecordDecl>(FromDC);
9903 if (ToRecord->isCompleteDefinition())
9911 if (FromRecord->getASTContext().getExternalSource() &&
9912 !FromRecord->isCompleteDefinition())
9913 FromRecord->getASTContext().getExternalSource()->CompleteType(FromRecord);
9915 if (FromRecord->isCompleteDefinition())
9918 return std::move(Err);
9919 }
else if (
auto *ToEnum = dyn_cast<EnumDecl>(ToDC)) {
9920 auto *FromEnum = cast<EnumDecl>(FromDC);
9921 if (ToEnum->isCompleteDefinition()) {
9923 }
else if (FromEnum->isCompleteDefinition()) {
9926 return std::move(Err);
9930 }
else if (
auto *ToClass = dyn_cast<ObjCInterfaceDecl>(ToDC)) {
9931 auto *FromClass = cast<ObjCInterfaceDecl>(FromDC);
9932 if (ToClass->getDefinition()) {
9937 return std::move(Err);
9941 }
else if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(ToDC)) {
9942 auto *FromProto = cast<ObjCProtocolDecl>(FromDC);
9943 if (ToProto->getDefinition()) {
9948 return std::move(Err);
9959 return cast_or_null<Expr>(*ToSOrErr);
9961 return ToSOrErr.takeError();
9969 llvm::DenseMap<Stmt *, Stmt *>::iterator Pos = ImportedStmts.find(FromS);
9970 if (Pos != ImportedStmts.end())
9979 if (
auto *ToE = dyn_cast<Expr>(*ToSOrErr)) {
9980 auto *FromE = cast<Expr>(FromS);
9983 ToE->setValueKind(FromE->getValueKind());
9984 ToE->setObjectKind(FromE->getObjectKind());
9985 ToE->setDependence(FromE->getDependence());
9989 ImportedStmts[FromS] = *ToSOrErr;
10000 auto NSOrErr =
Import(Namespace);
10002 return NSOrErr.takeError();
10003 auto PrefixOrErr =
Import(Prefix);
10005 return PrefixOrErr.takeError();
10013 return RDOrErr.takeError();
10018 return TyOrErr.takeError();
10021 llvm_unreachable(
"Invalid nested name specifier kind");
10033 NestedNames.push_back(NNS);
10039 while (!NestedNames.empty()) {
10040 NNS = NestedNames.pop_back_val();
10043 return std::move(Err);
10050 return std::move(Err);
10054 return std::move(Err);
10060 ToLocalBeginLoc, ToLocalEndLoc);
10066 return std::move(Err);
10079 if (!ToSourceRangeOrErr)
10080 return ToSourceRangeOrErr.takeError();
10083 ToSourceRangeOrErr->getBegin(),
10084 ToSourceRangeOrErr->getEnd());
10088 llvm_unreachable(
"unexpected null nested name specifier");
10099 return TemplateName(cast<TemplateDecl>((*ToTemplateOrErr)->getCanonicalDecl()));
10101 return ToTemplateOrErr.takeError();
10106 for (
auto *I : *FromStorage) {
10107 if (
auto ToOrErr =
Import(I))
10108 ToTemplates.
addDecl(cast<NamedDecl>(*ToOrErr));
10110 return ToOrErr.takeError();
10113 ToTemplates.
end());
10119 if (!DeclNameOrErr)
10120 return DeclNameOrErr.takeError();
10127 if (!QualifierOrErr)
10128 return QualifierOrErr.takeError();
10131 return TNOrErr.takeError();
10139 if (!QualifierOrErr)
10140 return QualifierOrErr.takeError();
10149 if (!ReplacementOrErr)
10150 return ReplacementOrErr.takeError();
10153 if (!AssociatedDeclOrErr)
10154 return AssociatedDeclOrErr.takeError();
10157 *ReplacementOrErr, *AssociatedDeclOrErr, Subst->
getIndex(),
10165 auto ArgPackOrErr =
10168 return ArgPackOrErr.takeError();
10171 if (!AssociatedDeclOrErr)
10172 return AssociatedDeclOrErr.takeError();
10175 *ArgPackOrErr, *AssociatedDeclOrErr, SubstPack->
getIndex(),
10181 return UsingOrError.takeError();
10182 return TemplateName(cast<UsingShadowDecl>(*UsingOrError));
10185 llvm_unreachable(
"Unexpected DeducedTemplate");
10188 llvm_unreachable(
"Invalid template name kind");
10200 if (!ToFileIDOrErr)
10201 return ToFileIDOrErr.takeError();
10209 return std::move(Err);
10211 return std::move(Err);
10217 llvm::DenseMap<FileID, FileID>::iterator Pos = ImportedFileIDs.find(FromID);
10218 if (Pos != ImportedFileIDs.end())
10219 return Pos->second;
10231 return ToSpLoc.takeError();
10234 return ToExLocS.takeError();
10244 return ToExLocE.takeError();
10250 if (!IsBuiltin && !
Cache->BufferOverridden) {
10254 return ToIncludeLoc.takeError();
10265 if (
Cache->OrigEntry &&
Cache->OrigEntry->getDir()) {
10276 ToID = ToSM.
createFileID(*Entry, ToIncludeLocOrFakeLoc,
10283 std::optional<llvm::MemoryBufferRef> FromBuf =
10289 std::unique_ptr<llvm::MemoryBuffer> ToBuf =
10290 llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(),
10291 FromBuf->getBufferIdentifier());
10297 assert(ToID.
isValid() &&
"Unexpected invalid fileID was created.");
10299 ImportedFileIDs[FromID] = ToID;
10306 return ToExprOrErr.takeError();
10309 if (!LParenLocOrErr)
10310 return LParenLocOrErr.takeError();
10313 if (!RParenLocOrErr)
10314 return RParenLocOrErr.takeError();
10319 return ToTInfoOrErr.takeError();
10324 return std::move(Err);
10327 ToContext, *ToTInfoOrErr, From->
isBaseVirtual(), *LParenLocOrErr,
10328 *ToExprOrErr, *RParenLocOrErr, EllipsisLoc);
10332 return ToFieldOrErr.takeError();
10335 if (!MemberLocOrErr)
10336 return MemberLocOrErr.takeError();
10339 ToContext, cast_or_null<FieldDecl>(*ToFieldOrErr), *MemberLocOrErr,
10340 *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10343 if (!ToIFieldOrErr)
10344 return ToIFieldOrErr.takeError();
10347 if (!MemberLocOrErr)
10348 return MemberLocOrErr.takeError();
10351 ToContext, cast_or_null<IndirectFieldDecl>(*ToIFieldOrErr),
10352 *MemberLocOrErr, *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10356 return ToTInfoOrErr.takeError();
10358 return new (ToContext)
10360 *ToExprOrErr, *RParenLocOrErr);
10363 return make_error<ASTImportError>();
10369 auto Pos = ImportedCXXBaseSpecifiers.find(BaseSpec);
10370 if (Pos != ImportedCXXBaseSpecifiers.end())
10371 return Pos->second;
10374 if (!ToSourceRange)
10375 return ToSourceRange.takeError();
10378 return ToTSI.takeError();
10380 if (!ToEllipsisLoc)
10381 return ToEllipsisLoc.takeError();
10385 ImportedCXXBaseSpecifiers[BaseSpec] =
Imported;
10397 return ToOrErr.takeError();
10398 Decl *To = *ToOrErr;
10400 auto *FromDC = cast<DeclContext>(From);
10403 if (
auto *ToRecord = dyn_cast<RecordDecl>(To)) {
10404 if (!ToRecord->getDefinition()) {
10406 cast<RecordDecl>(FromDC), ToRecord,
10411 if (
auto *ToEnum = dyn_cast<EnumDecl>(To)) {
10412 if (!ToEnum->getDefinition()) {
10418 if (
auto *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
10419 if (!ToIFace->getDefinition()) {
10421 cast<ObjCInterfaceDecl>(FromDC), ToIFace,
10426 if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
10427 if (!ToProto->getDefinition()) {
10429 cast<ObjCProtocolDecl>(FromDC), ToProto,
10451 return ToSelOrErr.takeError();
10458 return ToTyOrErr.takeError();
10466 return ToTyOrErr.takeError();
10472 cast<TemplateDecl>(*ToTemplateOrErr));
10474 return ToTemplateOrErr.takeError();
10482 return ToTyOrErr.takeError();
10498 llvm_unreachable(
"Invalid DeclarationName Kind!");
10526 for (
unsigned I = 1, N = FromSel.
getNumArgs(); I < N; ++I)
10534 llvm::Error Err = llvm::Error::success();
10535 auto ImportLoop = [&](
const APValue *From,
APValue *To,
unsigned Size) {
10536 for (
unsigned Idx = 0; Idx < Size; Idx++) {
10541 switch (FromValue.
getKind()) {
10555 ImportLoop(((
const APValue::Vec *)(
const char *)&FromValue.Data)->Elts,
10562 ImportLoop(((
const APValue::Arr *)(
const char *)&FromValue.Data)->Elts,
10563 ((
const APValue::Arr *)(
const char *)&
Result.Data)->Elts,
10570 ((
const APValue::StructData *)(
const char *)&FromValue.Data)->Elts,
10571 ((
const APValue::StructData *)(
const char *)&
Result.Data)->Elts,
10579 return std::move(Err);
10580 Result.setUnion(cast<FieldDecl>(ImpFDecl), ImpValue);
10584 Result.MakeAddrLabelDiff();
10588 return std::move(Err);
10589 Result.setAddrLabelDiff(cast<AddrLabelExpr>(ImpLHS),
10590 cast<AddrLabelExpr>(ImpRHS));
10594 const Decl *ImpMemPtrDecl =
10597 return std::move(Err);
10599 Result.setMemberPointerUninit(
10600 cast<const ValueDecl>(ImpMemPtrDecl),
10608 return std::move(Err);
10618 "in C++20 dynamic allocation are transient so they shouldn't "
10619 "appear in the AST");
10621 if (
const auto *
E =
10626 return std::move(Err);
10636 return std::move(Err);
10648 return std::move(Err);
10661 for (
unsigned LoopIdx = 0; LoopIdx < PathLength; LoopIdx++) {
10664 FromPath[LoopIdx].getAsBaseOrMember().getPointer();
10667 return std::move(Err);
10668 if (
auto *RD = dyn_cast<CXXRecordDecl>(
FromDecl))
10671 FromElemTy = cast<ValueDecl>(
FromDecl)->getType();
10673 ImpDecl, FromPath[LoopIdx].getAsBaseOrMember().getInt()));
10678 FromPath[LoopIdx].getAsArrayIndex());
10686 return std::move(Err);
10694 unsigned NumDecls) {
10704 if (LastDiagFromFrom)
10707 LastDiagFromFrom =
false;
10712 if (!LastDiagFromFrom)
10715 LastDiagFromFrom =
true;
10720 if (
auto *ID = dyn_cast<ObjCInterfaceDecl>(
D)) {
10721 if (!ID->getDefinition())
10722 ID->startDefinition();
10724 else if (
auto *PD = dyn_cast<ObjCProtocolDecl>(
D)) {
10725 if (!PD->getDefinition())
10726 PD->startDefinition();
10728 else if (
auto *TD = dyn_cast<TagDecl>(
D)) {
10729 if (!TD->getDefinition() && !TD->isBeingDefined()) {
10730 TD->startDefinition();
10731 TD->setCompleteDefinition(
true);
10735 assert(0 &&
"CompleteDecl called on a Decl that can't be completed");
10740 auto [Pos, Inserted] = ImportedDecls.try_emplace(From, To);
10741 assert((Inserted || Pos->second == To) &&
10742 "Try to import an already imported Decl");
10744 return Pos->second;
10747 ImportedFromDecls[To] = From;
10752 AddToLookupTable(To);
10756std::optional<ASTImportError>
10758 auto Pos = ImportDeclErrors.find(FromD);
10759 if (Pos != ImportDeclErrors.end())
10760 return Pos->second;
10762 return std::nullopt;
10766 auto InsertRes = ImportDeclErrors.insert({From, Error});
10770 assert(InsertRes.second || InsertRes.first->second.Error == Error.Error);
10775 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
10777 if (Pos != ImportedTypes.end()) {
10782 llvm::consumeError(ToFromOrErr.takeError());
10787 getToContext().getLangOpts(), FromContext, ToContext, NonEquivalentDecls,
10789 return Ctx.IsEquivalent(From, To);
Defines the clang::ASTContext interface.
ASTImporterLookupTable & LT
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.
enum clang::sema::@1840::IndirectLocalPathEntry::EntryKind Kind
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.
const NamedDecl * FromDecl
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 ...
SourceManager & getSourceManager()
TranslationUnitDecl * getTranslationUnitDecl() const
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
QualType getParenType(QualType NamedType) const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
void setInstantiatedFromUsingDecl(NamedDecl *Inst, NamedDecl *Pattern)
Remember that the using decl Inst is an instantiation of the using decl Pattern of a class template.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
NamedDecl * getInstantiatedFromUsingDecl(NamedDecl *Inst)
If the given using decl Inst is an instantiation of another (possibly unresolved) using decl,...
DeclarationNameTable DeclarationNames
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, const DependentTemplateStorage &Name, ArrayRef< TemplateArgumentLoc > Args) const
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
QualType getSubstBuiltinTemplatePack(const TemplateArgument &ArgPack)
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getCountAttributedType(QualType T, Expr *CountExpr, bool CountInBytes, bool OrNull, ArrayRef< TypeCoupledDeclRefInfo > DependentDecls) const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
void setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst, UsingShadowDecl *Pattern)
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
TemplateName getDependentTemplateName(const DependentTemplateStorage &Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template operat...
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
Retrieve a substitution-result type.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UsingShadowDecl *D, QualType UnderlyingType=QualType()) const
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
SelectorTable & Selectors
QualType getMacroQualifiedType(QualType UnderlyingTy, const IdentifierInfo *MacroII) const
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
TemplateTemplateParmDecl * insertCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *CanonTTP) const
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier NNS, const IdentifierInfo *Name) const
void setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst, UsingEnumDecl *Pattern)
Remember that the using enum decl Inst is an instantiation of the using enum decl Pattern of a class ...
UsingEnumDecl * getInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst)
If the given using-enum decl Inst is an instantiation of another using-enum decl, return it.
QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
TemplateTemplateParmDecl * findCanonicalTemplateTemplateParmDeclInternal(TemplateTemplateParmDecl *TTP) const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl, unsigned Index, bool Final, const TemplateArgument &ArgPack)
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< QualType > Expansions={}, UnsignedOrNone Index=std::nullopt) const
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a variable array of the specified element type.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, TemplateDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getPackExpansionType(QualType Pattern, UnsignedOrNone NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
CanQualType UnsignedCharTy
QualType getTypedefType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypedefNameDecl *Decl, QualType UnderlyingType=QualType(), std::optional< bool > TypeMatchesDeclOrNone=std::nullopt) const
Return the unique reference to the type for the specified typedef-name decl.
QualType getTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Underlying=QualType()) const
TemplateName getQualifiedTemplateName(NestedNameSpecifier Qualifier, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getMemberPointerType(QualType T, NestedNameSpecifier Qualifier, const CXXRecordDecl *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
QualType getTagType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TagDecl *TD, bool OwnsTag) const
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
CanQualType getCanonicalUnresolvedUsingType(const UnresolvedUsingTypenameDecl *D) const
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type.
DiagnosticsEngine & getDiagnostics() const
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
QualType getUnresolvedUsingType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const UnresolvedUsingTypenameDecl *D) const
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
QualType getDeducedTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
CanQualType getCanonicalTagType(const TagDecl *TD) const
QualType getTypeOfType(QualType QT, TypeOfKind Kind) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes.
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
TemplateName getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl, unsigned Index, UnsignedOrNone PackIndex, bool Final) const
unsigned char getFixedPointScale(QualType Ty) const
QualType getIncompleteArrayType(QualType EltTy, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return a unique reference to the type for an incomplete array of the specified element type.
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
TemplateName getAssumedTemplateName(DeclarationName Name) const
Retrieve a template name representing an unqualified-id that has been assumed to name a template for ...
QualType getTypeOfExprType(Expr *E, TypeOfKind Kind) const
C23 feature and GCC extension.
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).
void update(NamedDecl *ND, DeclContext *OldDC)
void updateForced(NamedDecl *ND, DeclContext *OldDC)
bool hasCycleAtBack() const
Returns true if the last element can be found earlier in the path.
VecTy copyCycleAtBack() const
Returns the copy of the cycle.
Imports selected nodes from one AST context into another context, merging AST nodes where appropriate...
ASTContext & getFromContext() const
Retrieve the context that AST nodes are being imported from.
NonEquivalentDeclSet & getNonEquivalentDecls()
Return the set of declarations that we know are not equivalent.
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.
llvm::DenseSet< std::tuple< Decl *, Decl *, int > > NonEquivalentDeclSet
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.
virtual bool returnWithErrorInTest()
Used only in unittests to verify the behaviour of the error handling.
std::optional< DeclT * > getImportedFromDecl(const DeclT *ToD) const
Return the declaration in the "from" context from which the declaration in the "to" context was impor...
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 importInto(ImportT &To, const ImportT &From)
Import the given object, returns the result.
virtual Decl * GetOriginalDecl(Decl *To)
Called by StructuralEquivalenceContext.
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.
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 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)
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)
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)
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)
std::tuple< FunctionTemplateDecl *, TemplateArgsTy > FunctionTemplateAndArgsTy
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)
ExpectedStmt VisitBreakStmt(BreakStmt *S)
Represents an access specifier followed by colon ':'.
AddrLabelExpr - The GNU address of label extension, representing &&label.
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons.
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Represents a loop initializing the elements of an array.
Represents a constant array type that does not decay to a pointer when used as a function parameter.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() 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,...
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.
static AttributedStmt * Create(const ASTContext &C, SourceLocation Loc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
An attributed type is a type to which a type attribute has been applied.
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Represents a C++ declaration that introduces decls from somewhere else.
void addShadowDecl(UsingShadowDecl *S)
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
A builtin binary operation expression such as "x + y" or "x <= y".
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
A binding in a decomposition declaration.
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.
A fixed int type of a specified bitwidth.
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...
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.
static CXXBindTemporaryExpr * Create(const ASTContext &C, CXXTemporary *Temp, Expr *SubExpr)
A boolean literal, per ([C++ lex.bool] Boolean literals).
static CXXBoolLiteralExpr * Create(const ASTContext &C, bool Val, QualType Ty, SourceLocation Loc)
CXXCatchStmt - This represents a C++ catch block.
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.
void setIsImmediateEscalating(bool Set)
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.
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]).
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
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.
Represents a delete expression for memory deallocation and destructor calls, e.g.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
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)
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.
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
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.
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.
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.
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
The null pointer literal (C++11 [lex.nullptr])
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 C++ pseudo-destructor (C++ [expr.pseudo]).
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)
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
void setDescribedClassTemplate(ClassTemplateDecl *Template)
void setLambdaNumbering(LambdaNumbering Numbering)
Set the mangling numbers and context declaration 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.
An expression "T()" which creates an rvalue of a non-class type T.
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)
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)
A C++ throw-expression (C++ [except.throw]).
CXXTryStmt - A C++ try block, including all handlers.
static CXXTryStmt * Create(const ASTContext &C, SourceLocation tryLoc, CompoundStmt *tryBlock, ArrayRef< Stmt * > handlers)
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
static CXXUnresolvedConstructExpr * Create(const ASTContext &Context, QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool IsListInit)
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.
CaseStmt - Represent a case statement.
static CaseStmt * Create(const ASTContext &Ctx, Expr *lhs, Expr *rhs, SourceLocation caseLoc, SourceLocation ellipsisLoc, SourceLocation colonLoc)
Build a case statement.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
path_iterator path_begin()
CharUnits - This is an opaque type for sizes expressed in character units.
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.
Declaration of a class template.
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...
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...
void setPointOfInstantiation(SourceLocation Loc)
void setExternKeywordLoc(SourceLocation Loc)
Sets the location of the extern keyword.
void setSpecializationKind(TemplateSpecializationKind TSK)
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
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.
Complex values, per C99 6.2.5p11.
CompoundAssignOperator - For compound assignments (e.g.
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())
CompoundLiteralExpr - [C99 6.5.2.5].
CompoundStmt - This represents a group of statements like { stmt stmt }.
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)
Declaration of a C++20 concept.
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)
ConditionalOperator - The ?: ternary operator.
Represents the canonical version of C arrays with a specified constant size.
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
static ConstantExpr * Create(const ASTContext &Context, Expr *E, const APValue &Result)
Represents a concrete matrix type with constant number of rows and columns.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
std::pair< SourceLocation, StringRef > SubstitutionDiagnostic
llvm::SmallVector< Detail, 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...
static ConvertVectorExpr * Create(const ASTContext &C, Expr *SrcExpr, TypeSourceInfo *TI, QualType DstType, ExprValueKind VK, ExprObjectKind OK, SourceLocation BuiltinLoc, SourceLocation RParenLoc, FPOptionsOverride FPFeatures)
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
Represents a pointer type decayed from an array or function type.
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
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.
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.
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.
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)
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
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.
bool isParameterPack() const
Whether this declaration is a parameter pack.
bool isInIdentifierNamespace(unsigned NS) const
@ 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)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
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.
void setTypeSourceInfo(TypeSourceInfo *TI)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
Represents the type decltype(expr) (C++11).
A decomposition declaration.
Represents a C++17 deduced template specialization type.
Represents an extended address space qualifier where the input address space value is dependent.
Represents a qualified type name for which the type name is dependent.
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)
Represents an array type in C++ whose size is a value-dependent expression.
Represents an extended vector type where either the type or size is dependent.
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Represents a template specialization type whose template cannot be resolved, e.g.
Represents a dependent template name that cannot be resolved prior to template instantiation.
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?
Represents a vector type where either the type or size is dependent.
Represents a single C99 designator.
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.
static Designator CreateArrayDesignator(unsigned Index, SourceLocation LBracketLoc, SourceLocation RBracketLoc)
Creates an array designator.
Represents a C99 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.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void notePriorDiagnosticFrom(const DiagnosticsEngine &Other)
Note that the prior diagnostic was emitted by some other DiagnosticsEngine, and we may be attaching a...
DoStmt - This represents a 'do/while' stmt.
Symbolic representation of a dynamic allocation.
Represents an empty-declaration.
An instance of this object exists for each enum constant that is defined.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
void setIntegerType(QualType T)
Set the underlying integer type.
EnumDecl * getMostRecentDecl()
void completeDefinition(QualType NewType, QualType PromotionType, unsigned NumPositiveBits, unsigned NumNegativeBits)
When created, the EnumDecl corresponds to a forward-declared enum.
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.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
ExplicitCastExpr - An explicit cast written in the source code.
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...
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.
ExtVectorType - Extended vector type.
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.
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.
void setInClassInitializer(Expr *NewInit)
Set the C++11 in-class initializer for this member.
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.
OptionalFileEntryRef getOptionalFileRef(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Get a FileEntryRef if it exists, without doing anything on error.
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
ForStmt - This represents a 'for (init;cond;inc)' stmt.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
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.
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)
ArrayRef< ParmVarDecl * > parameters() const
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)
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
@ TK_MemberSpecialization
@ TK_DependentNonTemplate
@ TK_FunctionTemplateSpecialization
@ TK_DependentFunctionTemplateSpecialization
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.
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo *TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization.
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
void setIsDestroyingOperatorDelete(bool IsDestroyingDelete)
void setIsTypeAwareOperatorNewOrDelete(bool IsTypeAwareOperator=true)
void setRangeEnd(SourceLocation E)
FunctionDecl * getInstantiatedFromDecl() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
void setDefaulted(bool D=true)
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,...
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
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.
FunctionTemplateDecl * getMostRecentDecl()
ExtInfo getExtInfo() const
QualType getReturnType() const
This represents a GCC inline-assembly statement extension.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Represents a C11 generic selection.
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.
GotoStmt - This represents a direct goto.
Represents an arbitrary, user-specified SPIR-V type instruction.
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.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
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.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
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)
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 C array with an unspecified size.
Represents a field injected from an anonymous union/struct into the parent scope.
IndirectGotoStmt - This represents an indirect goto.
Description of a constructor that was inherited from a base class.
CXXConstructorDecl * getConstructor() const
ConstructorUsingShadowDecl * getShadowDecl() const
Describes an C or C++ initializer list.
void setSyntacticForm(InitListExpr *Init)
void setArrayFiller(Expr *filler)
void setInitializedFieldInUnion(FieldDecl *FD)
void sawArrayRangeDesignator(bool ARD=true)
The injected class name of a C++ class template or class template partial specialization.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
An lvalue reference type, per C++11 [dcl.ref].
Represents the declaration of a label.
void setStmt(LabelStmt *T)
LabelStmt - Represents a label, which has a substatement.
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.
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
Represents a linkage specification.
void setRBraceLoc(SourceLocation L)
Represents the results of name lookup.
Sugar type that represents a type that was qualified by a qualifier written as a macro invocation.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
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)
A pointer to member type per C++ 8.3.3 - Pointers to members.
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.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Represents a C++ namespace alias.
Represent a C++ namespace.
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace that inhabits this namespace, if any.
void setRBraceLoc(SourceLocation L)
Class that aids in the construction of nested-name-specifiers along with source-location information ...
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.
NullStmt - This is the null statement ";": C99 6.8.3p3.
Represents Objective-C's @catch statement.
Represents Objective-C's @finally statement.
Represents Objective-C's @synchronized statement.
Represents Objective-C's @throw statement.
Represents Objective-C's @try ... @catch ... @finally statement.
static ObjCAtTryStmt * Create(const ASTContext &Context, SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt)
Represents Objective-C's @autoreleasepool Statement.
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.
void setImplementation(ObjCCategoryImplDecl *ImplD)
ObjCProtocolList::iterator protocol_iterator
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Represents Objective-C's collection statement.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
const ObjCInterfaceDecl * getSuperClass() 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.
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.
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this class.
ObjCProtocolList::iterator protocol_iterator
ObjCImplementationDecl * getImplementation() const
protocol_iterator protocol_begin() const
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
Interfaces are the core concept in Objective-C for object oriented design.
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCMethodDecl - Represents an instance or class method declaration.
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs={})
Sets the method's parameters and selector source locations.
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implicit parameters.
ParmVarDecl *const * param_iterator
ObjCInterfaceDecl * getClassInterface()
Represents a pointer to an Objective C object.
Represents a class type in Objective C.
Represents one property declaration in an Objective-C interface.
void setSetterName(Selector Sel, SourceLocation Loc=SourceLocation())
void setPropertyAttributes(ObjCPropertyAttribute::Kind PRVal)
void setPropertyAttributesAsWritten(ObjCPropertyAttribute::Kind PRVal)
void setPropertyIvarDecl(ObjCIvarDecl *Ivar)
void setSetterMethodDecl(ObjCMethodDecl *gDecl)
void setGetterName(Selector Sel, SourceLocation Loc=SourceLocation())
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
Represents an Objective-C protocol declaration.
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
protocol_iterator protocol_end() const
protocol_loc_iterator protocol_loc_begin() const
Represents the declaration of an Objective-C type parameter.
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
Represents a type parameter type in Objective C.
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr * > exprs, SourceLocation RParenLoc)
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.
A structure for storing the information associated with an overloaded template name.
Represents a C++11 pack expansion that produces a sequence of expressions.
Represents a pack expansion of types.
ParenExpr - This represents a parenthesized expression, e.g.
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr * > Exprs, SourceLocation RParenLoc)
Create a paren list.
Sugar for parentheses used when specifying types.
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:
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)
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.
void setHasInheritedDefaultArg(bool I=true)
PointerType - C99 6.7.5.1 - Pointer Declarators.
[C99 6.4.2.2] - A predefined identifier such as func.
static PredefinedExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType FNTy, PredefinedIdentKind IK, bool IsTransparent, StringLiteral *SL)
Create a PredefinedExpr.
Stores the type being destroyed by a pseudo-destructor expression.
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.
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.
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
void setAnonymousStructOrUnion(bool Anon)
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.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getOriginalDecl() const
Provides common interface for the Decls that can be redeclared.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Base for LValueReferenceType and RValueReferenceType.
Represents the body of a requires-expression.
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
static ReturnStmt * Create(const ASTContext &Ctx, SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)
Create a return statement.
Selector getSelector(unsigned NumArgs, const IdentifierInfo **IIV)
Can create any sort of selector.
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
static std::enable_if_t< std::is_base_of_v< Attr, AttrInfo >, SourceLocation > getAttrLoc(const AttrInfo &AL)
A helper function to provide Attribute Location for the Attr types AND the ParsedAttr.
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Represents an expression that computes the length of a parameter pack.
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Encodes a location in the source.
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
static SpirvOperand createConstant(QualType ResultType, llvm::APInt Val)
static SpirvOperand createType(QualType T)
static SpirvOperand createLiteral(llvm::APInt Val)
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.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
child_iterator child_begin()
StmtClass getStmtClass() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
child_iterator child_end()
const char * getStmtClassName() const
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
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...
Represents the result of substituting a builtin template as a pack.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
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.
Represents the result of substituting a set of types for a template type parameter pack.
Represents the result of substituting a type for a template type parameter.
void setNextSwitchCase(SwitchCase *SC)
SwitchStmt - This represents a 'switch' stmt.
static SwitchStmt * Create(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a switch statement.
Represents the declaration of a struct/union/class/enum.
bool isBeingDefined() const
Return true if this decl is currently being defined.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
TypedefNameDecl * getTypedefNameForAnonDecl() const
void startDefinition()
Starts the definition of this tag declaration.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
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.
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.
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
Represents a type template specialization; the template must be a class template, a type alias templa...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Declaration of a template type parameter.
void setTypeConstraint(ConceptReference *CR, Expr *ImmediatelyDeclaredConstraint, UnsignedOrNone ArgPackSubstIndex)
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.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
[BoundsSafety] Represents information of declarations referenced by the arguments of the counted_by a...
Symbolic representation of typeid(T) for some type T.
const Type * getType() const
SourceLocation getBeginLoc() const
Get the begin source location.
Represents a typeof (or typeof) expression (a C23 feature and GCC extension) or a typeof_unqual expre...
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
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.
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.
ExpectedType Visit(const Type *T)
Performs the operation associated with this visitor object.
The base class of the type hierarchy.
const Type * getPointeeOrArrayElementType() const
If this is a pointer type, return the pointee type.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isPointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
const char * getTypeClassName() const
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.
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
static UnaryOperator * CreateEmpty(const ASTContext &C, bool hasFPFeatures)
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
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.
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)
void addDecl(NamedDecl *D)
A set of unresolved declarations.
Represents the dependent type named by a dependently-scoped typename using declaration,...
Represents a dependent using declaration which was marked with typename.
Represents a dependent using declaration which was not marked with typename.
Represents a C++ using-declaration.
Represents C++ using-directive.
Represents a C++ using-enum-declaration.
Represents a pack of using declarations that a single using-declarator pack-expanded into.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Represents a call to the builtin function __builtin_va_arg.
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.
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
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()
void setTSCSpec(ThreadStorageClassSpecifier TSC)
const Expr * getInit() const
void setConstexpr(bool IC)
void setDescribedVarTemplate(VarTemplateDecl *Template)
void setImplicitlyInline()
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.
VarTemplateDecl * getMostRecentDecl()
void setInstantiatedFromMember(VarTemplatePartialSpecializationDecl *PartialSpec)
Represents a variable template specialization, which refers to a variable template with a given set o...
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
void setSpecializationKind(TemplateSpecializationKind TSK)
void setPointOfInstantiation(SourceLocation Loc)
VarTemplateSpecializationDecl * getMostRecentDecl()
Represents a C array with a specified size that is not an integer-constant-expression.
Represents a GCC generic vector type.
WhileStmt - This represents a 'while' stmt.
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.
bool isa(CodeGen::Address addr)
std::pair< FileID, unsigned > FileIDAndOffset
StructuralEquivalenceKind
Whether to perform a normal or minimal equivalence check.
CanThrowResult
Possible results from evaluation of a noexcept expression.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
@ Property
The type of a property.
@ Result
The result type of a method or function.
@ Template
We are parsing a template declaration.
@ VarTemplate
The name was classified as a variable template name.
CastKind
CastKind - The kind of operation required for a conversion.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
const FunctionProtoType * T
llvm::SmallVector< Decl *, 2 > getCanonicalForwardRedeclChain(Decl *D)
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...
bool isLambdaMethod(const DeclContext *DC)
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
Information about how a lambda is numbered within its context.
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
Location information for a TemplateArgument.
SourceLocation getTemplateEllipsisLoc() const
SourceLocation getTemplateKwLoc() const
TypeSourceInfo * getAsTypeSourceInfo() const
SourceLocation getTemplateNameLoc() const
StringRef SubstitutedEntity