56#include "llvm/ADT/ArrayRef.h"
57#include "llvm/ADT/DenseMap.h"
58#include "llvm/ADT/STLExtras.h"
59#include "llvm/ADT/ScopeExit.h"
60#include "llvm/ADT/SmallVector.h"
61#include "llvm/Support/ErrorHandling.h"
62#include "llvm/Support/MemoryBuffer.h"
73 using llvm::make_error;
88 return "NameConflict";
90 return "UnsupportedConstruct";
92 return "Unknown error";
94 llvm_unreachable(
"Invalid error code.");
95 return "Invalid error code.";
101 llvm_unreachable(
"Function not implemented.");
110 for (
auto *R :
D->getFirstDecl()->
redecls()) {
111 if (R !=
D->getFirstDecl())
112 Redecls.push_back(R);
114 Redecls.push_back(
D->getFirstDecl());
115 std::reverse(Redecls.begin(), Redecls.end());
120 if (
auto *FD = dyn_cast<FunctionDecl>(
D))
121 return getCanonicalForwardRedeclChain<FunctionDecl>(FD);
122 if (
auto *VD = dyn_cast<VarDecl>(
D))
123 return getCanonicalForwardRedeclChain<VarDecl>(VD);
124 if (
auto *TD = dyn_cast<TagDecl>(
D))
125 return getCanonicalForwardRedeclChain<TagDecl>(TD);
126 llvm_unreachable(
"Bad declaration kind");
147 bool const IgnoreChildErrors;
151 : FromDC(FromDC), IgnoreChildErrors(!
isa<
TagDecl>(FromDC)) {}
161 if (ChildErr && !IgnoreChildErrors)
162 ResultErr = joinErrors(std::move(ResultErr), std::move(ChildErr));
164 consumeError(std::move(ChildErr));
170 if (!IgnoreChildErrors || !FromDC)
178 public StmtVisitor<ASTNodeImporter, ExpectedStmt> {
182 template <
typename ImportT>
183 [[nodiscard]] Error importInto(ImportT &To,
const ImportT &From) {
188 template <
typename ImportT>
189 [[nodiscard]] Error importInto(ImportT *&To, ImportT *From) {
190 auto ToOrErr = Importer.
Import(From);
192 To = cast_or_null<ImportT>(*ToOrErr);
193 return ToOrErr.takeError();
198 template <
typename T>
202 auto ToOrErr = Importer.
Import(From);
204 return ToOrErr.takeError();
205 return cast_or_null<T>(*ToOrErr);
208 template <
typename T>
209 auto import(
const T *From) {
210 return import(
const_cast<T *
>(From));
214 template <
typename T>
216 return Importer.
Import(From);
220 template <
typename T>
224 return import(*From);
231 template <
typename ToDeclT>
struct CallOverloadedCreateFun {
232 template <
typename... Args>
decltype(
auto)
operator()(Args &&... args) {
233 return ToDeclT::Create(std::forward<Args>(args)...);
243 template <
typename ToDeclT,
typename FromDeclT,
typename... Args>
244 [[nodiscard]]
bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
249 CallOverloadedCreateFun<ToDeclT> OC;
250 return GetImportedOrCreateSpecialDecl(ToD, OC, FromD,
251 std::forward<Args>(args)...);
258 template <
typename NewDeclT,
typename ToDeclT,
typename FromDeclT,
260 [[nodiscard]]
bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
262 CallOverloadedCreateFun<NewDeclT> OC;
263 return GetImportedOrCreateSpecialDecl(ToD, OC, FromD,
264 std::forward<Args>(args)...);
268 template <
typename ToDeclT,
typename CreateFunT,
typename FromDeclT,
271 GetImportedOrCreateSpecialDecl(ToDeclT *&ToD, CreateFunT CreateFun,
272 FromDeclT *FromD, Args &&...args) {
280 ToD = CreateFun(std::forward<Args>(args)...);
283 Importer.SharedState->markAsNewDecl(ToD);
284 InitializeImportedDecl(FromD, ToD);
288 void InitializeImportedDecl(
Decl *FromD,
Decl *ToD) {
292 if (FromD->isImplicit())
300 if (
D->doesThisDeclarationHaveABody() &&
306 void addDeclToContexts(
Decl *FromD,
Decl *ToD) {
311 if (!FromD->getDescribedTemplate() &&
318 DeclContext *FromLexicalDC = FromD->getLexicalDeclContext();
322 bool Visible =
false;
335 if (
auto *FromNamed = dyn_cast<NamedDecl>(FromD)) {
336 auto *ToNamed = cast<NamedDecl>(ToD);
338 FromDC->
lookup(FromNamed->getDeclName());
339 if (llvm::is_contained(FromLookup, FromNamed))
356 updateLookupTableForTemplateParameters(
360 template <
typename TemplateParmDeclT>
361 Error importTemplateParameterDefaultArgument(
const TemplateParmDeclT *
D,
362 TemplateParmDeclT *ToD) {
363 if (
D->hasDefaultArgument()) {
364 if (
D->defaultArgumentWasInherited()) {
366 import(
D->getDefaultArgStorage().getInheritedFrom());
367 if (!ToInheritedFromOrErr)
368 return ToInheritedFromOrErr.takeError();
369 TemplateParmDeclT *ToInheritedFrom = *ToInheritedFromOrErr;
370 if (!ToInheritedFrom->hasDefaultArgument()) {
374 import(
D->getDefaultArgStorage()
376 ->getDefaultArgument());
377 if (!ToInheritedDefaultArgOrErr)
378 return ToInheritedDefaultArgOrErr.takeError();
379 ToInheritedFrom->setDefaultArgument(Importer.
getToContext(),
380 *ToInheritedDefaultArgOrErr);
382 ToD->setInheritedDefaultArgument(ToD->getASTContext(),
386 import(
D->getDefaultArgument());
387 if (!ToDefaultArgOrErr)
388 return ToDefaultArgOrErr.takeError();
391 if (!ToD->hasDefaultArgument())
396 return Error::success();
408#define TYPE(Class, Base) \
409 ExpectedType Visit##Class##Type(const Class##Type *T);
410#include "clang/AST/TypeNodes.inc"
468 template <
typename InContainerTy>
472 template<
typename InContainerTy>
479 std::tuple<FunctionTemplateDecl *, TemplateArgsTy>;
484 template <
typename DeclTy>
497 template <
typename T>
501 bool IgnoreTemplateParmDepth =
false);
693 Err = MaybeVal.takeError();
699 template<
typename IIter,
typename OIter>
701 using ItemT = std::remove_reference_t<
decltype(*Obegin)>;
702 for (; Ibegin != Iend; ++Ibegin, ++Obegin) {
705 return ToOrErr.takeError();
708 return Error::success();
715 template<
typename InContainerTy,
typename OutContainerTy>
717 const InContainerTy &InContainer, OutContainerTy &OutContainer) {
719 InContainer.begin(), InContainer.end(), OutContainer.begin());
722 template<
typename InContainerTy,
typename OIter>
739template <
typename InContainerTy>
743 auto ToLAngleLocOrErr =
import(FromLAngleLoc);
744 if (!ToLAngleLocOrErr)
745 return ToLAngleLocOrErr.takeError();
746 auto ToRAngleLocOrErr =
import(FromRAngleLoc);
747 if (!ToRAngleLocOrErr)
748 return ToRAngleLocOrErr.takeError();
754 return Error::success();
758Error ASTNodeImporter::ImportTemplateArgumentListInfo<TemplateArgumentListInfo>(
769 return ImportTemplateArgumentListInfo(
770 From.LAngleLoc, From.RAngleLoc, From.arguments(),
Result);
782 if (Error Err = importInto(std::get<0>(
Result), FTSInfo->getTemplate()))
783 return std::move(Err);
788 return std::move(Err);
798 return std::move(Err);
801 if (!ToRequiresClause)
802 return ToRequiresClause.takeError();
805 if (!ToTemplateLocOrErr)
806 return ToTemplateLocOrErr.takeError();
808 if (!ToLAngleLocOrErr)
809 return ToLAngleLocOrErr.takeError();
811 if (!ToRAngleLocOrErr)
812 return ToRAngleLocOrErr.takeError();
833 return ToTypeOrErr.takeError();
841 return ToTypeOrErr.takeError();
848 return ToOrErr.takeError();
851 return ToTypeOrErr.takeError();
852 return TemplateArgument(dyn_cast<ValueDecl>((*ToOrErr)->getCanonicalDecl()),
859 return ToTypeOrErr.takeError();
867 return ToTypeOrErr.takeError();
870 return ToValueOrErr.takeError();
877 if (!ToTemplateOrErr)
878 return ToTemplateOrErr.takeError();
886 if (!ToTemplateOrErr)
887 return ToTemplateOrErr.takeError();
897 return ToExpr.takeError();
903 return std::move(Err);
910 llvm_unreachable(
"Invalid template argument kind");
918 return ArgOrErr.takeError();
927 return E.takeError();
933 return TSIOrErr.takeError();
935 auto ToTemplateQualifierLocOrErr =
937 if (!ToTemplateQualifierLocOrErr)
938 return ToTemplateQualifierLocOrErr.takeError();
940 if (!ToTemplateNameLocOrErr)
941 return ToTemplateNameLocOrErr.takeError();
942 auto ToTemplateEllipsisLocOrErr =
944 if (!ToTemplateEllipsisLocOrErr)
945 return ToTemplateEllipsisLocOrErr.takeError();
948 *ToTemplateNameLocOrErr, *ToTemplateEllipsisLocOrErr);
958 size_t NumDecls = DG.
end() - DG.
begin();
960 ToDecls.reserve(NumDecls);
961 for (
Decl *FromD : DG) {
962 if (
auto ToDOrErr =
import(FromD))
963 ToDecls.push_back(*ToDOrErr);
965 return ToDOrErr.takeError();
975 if (
D.isFieldDesignator()) {
980 return ToDotLocOrErr.takeError();
983 if (!ToFieldLocOrErr)
984 return ToFieldLocOrErr.takeError();
987 ToFieldName, *ToDotLocOrErr, *ToFieldLocOrErr);
990 ExpectedSLoc ToLBracketLocOrErr =
import(
D.getLBracketLoc());
991 if (!ToLBracketLocOrErr)
992 return ToLBracketLocOrErr.takeError();
994 ExpectedSLoc ToRBracketLocOrErr =
import(
D.getRBracketLoc());
995 if (!ToRBracketLocOrErr)
996 return ToRBracketLocOrErr.takeError();
998 if (
D.isArrayDesignator())
1000 *ToLBracketLocOrErr,
1001 *ToRBracketLocOrErr);
1003 ExpectedSLoc ToEllipsisLocOrErr =
import(
D.getEllipsisLoc());
1004 if (!ToEllipsisLocOrErr)
1005 return ToEllipsisLocOrErr.takeError();
1007 assert(
D.isArrayRangeDesignator());
1009 D.getArrayIndex(), *ToLBracketLocOrErr, *ToEllipsisLocOrErr,
1010 *ToRBracketLocOrErr);
1015 Error Err = Error::success();
1018 auto ToConceptNameLoc =
1024 return std::move(Err);
1027 if (ASTTemplateArgs)
1029 return std::move(Err);
1047 return VarOrErr.takeError();
1052 return LocationOrErr.takeError();
1057 return std::move(Err);
1064template <
typename T>
1066 if (
Found->getLinkageInternal() != From->getLinkageInternal())
1069 if (From->hasExternalFormalLinkage())
1070 return Found->hasExternalFormalLinkage();
1073 if (From->isInAnonymousNamespace())
1074 return Found->isInAnonymousNamespace();
1076 return !
Found->isInAnonymousNamespace() &&
1077 !
Found->hasExternalFormalLinkage();
1097using namespace clang;
1106 ExpectedType UnderlyingTypeOrErr =
import(
T->getValueType());
1107 if (!UnderlyingTypeOrErr)
1108 return UnderlyingTypeOrErr.takeError();
1114 switch (
T->getKind()) {
1115#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1116 case BuiltinType::Id: \
1117 return Importer.getToContext().SingletonId;
1118#include "clang/Basic/OpenCLImageTypes.def"
1119#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1120 case BuiltinType::Id: \
1121 return Importer.getToContext().Id##Ty;
1122#include "clang/Basic/OpenCLExtensionTypes.def"
1123#define SVE_TYPE(Name, Id, SingletonId) \
1124 case BuiltinType::Id: \
1125 return Importer.getToContext().SingletonId;
1126#include "clang/Basic/AArch64SVEACLETypes.def"
1127#define PPC_VECTOR_TYPE(Name, Id, Size) \
1128 case BuiltinType::Id: \
1129 return Importer.getToContext().Id##Ty;
1130#include "clang/Basic/PPCTypes.def"
1131#define RVV_TYPE(Name, Id, SingletonId) \
1132 case BuiltinType::Id: \
1133 return Importer.getToContext().SingletonId;
1134#include "clang/Basic/RISCVVTypes.def"
1135#define WASM_TYPE(Name, Id, SingletonId) \
1136 case BuiltinType::Id: \
1137 return Importer.getToContext().SingletonId;
1138#include "clang/Basic/WebAssemblyReferenceTypes.def"
1139#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1140 case BuiltinType::Id: \
1141 return Importer.getToContext().SingletonId;
1142#include "clang/Basic/AMDGPUTypes.def"
1143#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1144 case BuiltinType::Id: \
1145 return Importer.getToContext().SingletonId;
1146#include "clang/Basic/HLSLIntangibleTypes.def"
1147#define SHARED_SINGLETON_TYPE(Expansion)
1148#define BUILTIN_TYPE(Id, SingletonId) \
1149 case BuiltinType::Id: return Importer.getToContext().SingletonId;
1150#include "clang/AST/BuiltinTypes.def"
1158 case BuiltinType::Char_U:
1167 case BuiltinType::Char_S:
1176 case BuiltinType::WChar_S:
1177 case BuiltinType::WChar_U:
1183 llvm_unreachable(
"Invalid BuiltinType Kind!");
1187 ExpectedType ToOriginalTypeOrErr =
import(
T->getOriginalType());
1188 if (!ToOriginalTypeOrErr)
1189 return ToOriginalTypeOrErr.takeError();
1195 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1196 if (!ToElementTypeOrErr)
1197 return ToElementTypeOrErr.takeError();
1204 if (!ToPointeeTypeOrErr)
1205 return ToPointeeTypeOrErr.takeError();
1213 if (!ToPointeeTypeOrErr)
1214 return ToPointeeTypeOrErr.takeError();
1222 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1223 if (!ToPointeeTypeOrErr)
1224 return ToPointeeTypeOrErr.takeError();
1232 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1233 if (!ToPointeeTypeOrErr)
1234 return ToPointeeTypeOrErr.takeError();
1243 if (!ToPointeeTypeOrErr)
1244 return ToPointeeTypeOrErr.takeError();
1247 if (!ClassTypeOrErr)
1248 return ClassTypeOrErr.takeError();
1256 Error Err = Error::success();
1260 return std::move(Err);
1263 ToElementType,
T->getSize(), ToSizeExpr,
T->getSizeModifier(),
1264 T->getIndexTypeCVRQualifiers());
1270 if (!ToArrayTypeOrErr)
1271 return ToArrayTypeOrErr.takeError();
1278 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1279 if (!ToElementTypeOrErr)
1280 return ToElementTypeOrErr.takeError();
1283 T->getSizeModifier(),
1284 T->getIndexTypeCVRQualifiers());
1289 Error Err = Error::success();
1294 return std::move(Err);
1296 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1297 T->getIndexTypeCVRQualifiers(), ToBracketsRange);
1300ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(
1302 Error Err = Error::success();
1307 return std::move(Err);
1312 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1313 T->getIndexTypeCVRQualifiers(), ToBracketsRange);
1316ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType(
1318 Error Err = Error::success();
1323 return std::move(Err);
1325 ToElementType, ToSizeExpr, ToAttrLoc);
1329 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1330 if (!ToElementTypeOrErr)
1331 return ToElementTypeOrErr.takeError();
1334 T->getNumElements(),
1335 T->getVectorKind());
1339 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1340 if (!ToElementTypeOrErr)
1341 return ToElementTypeOrErr.takeError();
1344 T->getNumElements());
1352 if (!ToReturnTypeOrErr)
1353 return ToReturnTypeOrErr.takeError();
1362 if (!ToReturnTypeOrErr)
1363 return ToReturnTypeOrErr.takeError();
1370 return TyOrErr.takeError();
1371 ArgTypes.push_back(*TyOrErr);
1379 return TyOrErr.takeError();
1380 ExceptionTypes.push_back(*TyOrErr);
1384 Error Err = Error::success();
1401 return std::move(Err);
1404 *ToReturnTypeOrErr, ArgTypes, ToEPI);
1409 Error Err = Error::success();
1411 auto ToPrevD =
importChecked(Err,
T->getDecl()->getPreviousDecl());
1413 return std::move(Err);
1416 ToD, cast_or_null<TypeDecl>(ToPrevD));
1421 if (!ToInnerTypeOrErr)
1422 return ToInnerTypeOrErr.takeError();
1432 return Pattern.takeError();
1435 return Index.takeError();
1442 return ToDeclOrErr.takeError();
1449 if (!ToUnderlyingTypeOrErr)
1450 return ToUnderlyingTypeOrErr.takeError();
1458 return ToExprOrErr.takeError();
1463 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnmodifiedType());
1464 if (!ToUnderlyingTypeOrErr)
1465 return ToUnderlyingTypeOrErr.takeError();
1473 return FoundOrErr.takeError();
1475 if (!UnderlyingOrErr)
1476 return UnderlyingOrErr.takeError();
1485 return ToExprOrErr.takeError();
1487 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1488 if (!ToUnderlyingTypeOrErr)
1489 return ToUnderlyingTypeOrErr.takeError();
1492 *ToExprOrErr, *ToUnderlyingTypeOrErr);
1498 if (!ToBaseTypeOrErr)
1499 return ToBaseTypeOrErr.takeError();
1501 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1502 if (!ToUnderlyingTypeOrErr)
1503 return ToUnderlyingTypeOrErr.takeError();
1506 *ToBaseTypeOrErr, *ToUnderlyingTypeOrErr,
T->getUTTKind());
1511 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1512 if (!ToDeducedTypeOrErr)
1513 return ToDeducedTypeOrErr.takeError();
1515 ExpectedDecl ToTypeConstraintConcept =
import(
T->getTypeConstraintConcept());
1516 if (!ToTypeConstraintConcept)
1517 return ToTypeConstraintConcept.takeError();
1522 return std::move(Err);
1525 *ToDeducedTypeOrErr,
T->getKeyword(),
false,
1526 false, cast_or_null<ConceptDecl>(*ToTypeConstraintConcept),
1530ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
1534 if (!ToTemplateNameOrErr)
1535 return ToTemplateNameOrErr.takeError();
1536 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1537 if (!ToDeducedTypeOrErr)
1538 return ToDeducedTypeOrErr.takeError();
1544ExpectedType ASTNodeImporter::VisitInjectedClassNameType(
1548 return ToDeclOrErr.takeError();
1552 const Type *Ty = (*ToDeclOrErr)->getTypeForDecl();
1553 assert(isa_and_nonnull<InjectedClassNameType>(Ty));
1560 return ToDeclOrErr.takeError();
1568 return ToDeclOrErr.takeError();
1574 ExpectedType ToModifiedTypeOrErr =
import(
T->getModifiedType());
1575 if (!ToModifiedTypeOrErr)
1576 return ToModifiedTypeOrErr.takeError();
1577 ExpectedType ToEquivalentTypeOrErr =
import(
T->getEquivalentType());
1578 if (!ToEquivalentTypeOrErr)
1579 return ToEquivalentTypeOrErr.takeError();
1582 T->getAttrKind(), *ToModifiedTypeOrErr, *ToEquivalentTypeOrErr,
1589 if (!ToWrappedTypeOrErr)
1590 return ToWrappedTypeOrErr.takeError();
1592 Error Err = Error::success();
1599 return ToDeclOrErr.takeError();
1600 CoupledDecls.emplace_back(*ToDeclOrErr, TI.isDeref());
1604 *ToWrappedTypeOrErr, CountExpr,
T->isCountInBytes(),
T->isOrNull(),
1605 ArrayRef(CoupledDecls.data(), CoupledDecls.size()));
1608ExpectedType ASTNodeImporter::VisitTemplateTypeParmType(
1612 return ToDeclOrErr.takeError();
1615 T->getDepth(),
T->getIndex(),
T->isParameterPack(), *ToDeclOrErr);
1618ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmType(
1622 return ReplacedOrErr.takeError();
1624 ExpectedType ToReplacementTypeOrErr =
import(
T->getReplacementType());
1625 if (!ToReplacementTypeOrErr)
1626 return ToReplacementTypeOrErr.takeError();
1629 *ToReplacementTypeOrErr, *ReplacedOrErr,
T->getIndex(),
T->getPackIndex(),
1630 T->getSubstitutionFlag());
1633ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmPackType(
1637 return ReplacedOrErr.takeError();
1640 if (!ToArgumentPack)
1641 return ToArgumentPack.takeError();
1644 *ReplacedOrErr,
T->getIndex(),
T->getFinal(), *ToArgumentPack);
1647ExpectedType ASTNodeImporter::VisitTemplateSpecializationType(
1649 auto ToTemplateOrErr =
import(
T->getTemplateName());
1650 if (!ToTemplateOrErr)
1651 return ToTemplateOrErr.takeError();
1656 return std::move(Err);
1663 ToCanonType = *TyOrErr;
1665 return TyOrErr.takeError();
1674 auto ToQualifierOrErr =
import(
T->getQualifier());
1675 if (!ToQualifierOrErr)
1676 return ToQualifierOrErr.takeError();
1679 if (!ToNamedTypeOrErr)
1680 return ToNamedTypeOrErr.takeError();
1683 if (!ToOwnedTagDeclOrErr)
1684 return ToOwnedTagDeclOrErr.takeError();
1689 *ToOwnedTagDeclOrErr);
1695 if (!ToPatternOrErr)
1696 return ToPatternOrErr.takeError();
1699 T->getNumExpansions(),
1703ExpectedType ASTNodeImporter::VisitDependentTemplateSpecializationType(
1705 auto ToQualifierOrErr =
import(
T->getQualifier());
1706 if (!ToQualifierOrErr)
1707 return ToQualifierOrErr.takeError();
1712 ToPack.reserve(
T->template_arguments().size());
1714 return std::move(Err);
1717 T->getKeyword(), *ToQualifierOrErr, ToName, ToPack);
1722 auto ToQualifierOrErr =
import(
T->getQualifier());
1723 if (!ToQualifierOrErr)
1724 return ToQualifierOrErr.takeError();
1733 return TyOrErr.takeError();
1745 return ToDeclOrErr.takeError();
1752 if (!ToBaseTypeOrErr)
1753 return ToBaseTypeOrErr.takeError();
1756 for (
auto TypeArg :
T->getTypeArgsAsWritten()) {
1758 TypeArgs.push_back(*TyOrErr);
1760 return TyOrErr.takeError();
1764 for (
auto *
P :
T->quals()) {
1766 Protocols.push_back(*ProtocolOrErr);
1768 return ProtocolOrErr.takeError();
1774 T->isKindOfTypeAsWritten());
1780 if (!ToPointeeTypeOrErr)
1781 return ToPointeeTypeOrErr.takeError();
1788 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1789 if (!ToUnderlyingTypeOrErr)
1790 return ToUnderlyingTypeOrErr.takeError();
1798 Error Err = Error::success();
1799 QualType ToOriginalType = importChecked(Err,
T->getOriginalType());
1800 QualType ToAdjustedType = importChecked(Err,
T->getAdjustedType());
1802 return std::move(Err);
1804 return Importer.getToContext().getAdjustedType(ToOriginalType,
1809 return Importer.getToContext().getBitIntType(
T->isUnsigned(),
1813ExpectedType clang::ASTNodeImporter::VisitBTFTagAttributedType(
1815 Error Err = Error::success();
1816 const BTFTypeTagAttr *ToBTFAttr = importChecked(Err,
T->getAttr());
1817 QualType ToWrappedType = importChecked(Err,
T->getWrappedType());
1819 return std::move(Err);
1821 return Importer.getToContext().getBTFTagAttributedType(ToBTFAttr,
1825ExpectedType clang::ASTNodeImporter::VisitHLSLAttributedResourceType(
1827 Error Err = Error::success();
1829 QualType ToWrappedType = importChecked(Err,
T->getWrappedType());
1830 QualType ToContainedType = importChecked(Err,
T->getContainedType());
1832 return std::move(Err);
1834 return Importer.getToContext().getHLSLAttributedResourceType(
1835 ToWrappedType, ToContainedType, ToAttrs);
1838ExpectedType clang::ASTNodeImporter::VisitConstantMatrixType(
1840 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1841 if (!ToElementTypeOrErr)
1842 return ToElementTypeOrErr.takeError();
1844 return Importer.getToContext().getConstantMatrixType(
1845 *ToElementTypeOrErr,
T->getNumRows(),
T->getNumColumns());
1848ExpectedType clang::ASTNodeImporter::VisitDependentAddressSpaceType(
1850 Error Err = Error::success();
1852 Expr *ToAddrSpaceExpr = importChecked(Err,
T->getAddrSpaceExpr());
1855 return std::move(Err);
1857 return Importer.getToContext().getDependentAddressSpaceType(
1858 ToPointeeType, ToAddrSpaceExpr, ToAttrLoc);
1861ExpectedType clang::ASTNodeImporter::VisitDependentBitIntType(
1863 ExpectedExpr ToNumBitsExprOrErr =
import(
T->getNumBitsExpr());
1864 if (!ToNumBitsExprOrErr)
1865 return ToNumBitsExprOrErr.takeError();
1866 return Importer.getToContext().getDependentBitIntType(
T->isUnsigned(),
1867 *ToNumBitsExprOrErr);
1870ExpectedType clang::ASTNodeImporter::VisitDependentSizedMatrixType(
1872 Error Err = Error::success();
1873 QualType ToElementType = importChecked(Err,
T->getElementType());
1874 Expr *ToRowExpr = importChecked(Err,
T->getRowExpr());
1875 Expr *ToColumnExpr = importChecked(Err,
T->getColumnExpr());
1878 return std::move(Err);
1880 return Importer.getToContext().getDependentSizedMatrixType(
1881 ToElementType, ToRowExpr, ToColumnExpr, ToAttrLoc);
1884ExpectedType clang::ASTNodeImporter::VisitDependentVectorType(
1886 Error Err = Error::success();
1887 QualType ToElementType = importChecked(Err,
T->getElementType());
1888 Expr *ToSizeExpr = importChecked(Err,
T->getSizeExpr());
1891 return std::move(Err);
1893 return Importer.getToContext().getDependentVectorType(
1894 ToElementType, ToSizeExpr, ToAttrLoc,
T->getVectorKind());
1897ExpectedType clang::ASTNodeImporter::VisitObjCTypeParamType(
1901 return ToDeclOrErr.takeError();
1906 if (!ToProtocolOrErr)
1907 return ToProtocolOrErr.takeError();
1908 ToProtocols.push_back(*ToProtocolOrErr);
1911 return Importer.getToContext().getObjCTypeParamType(*ToDeclOrErr,
1916 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1917 if (!ToElementTypeOrErr)
1918 return ToElementTypeOrErr.takeError();
1921 if (
T->isReadOnly())
1941 if (isa<RecordDecl>(
D) && (FunDecl = dyn_cast<FunctionDecl>(OrigDC)) &&
1943 auto getLeafPointeeType = [](
const Type *
T) {
1951 getLeafPointeeType(
P->getType().getCanonicalType().getTypePtr());
1952 auto *RT = dyn_cast<RecordType>(LeafT);
1953 if (RT && RT->getDecl() ==
D) {
1966 if (Error Err = importInto(Name,
D->getDeclName()))
1978 return Error::success();
1985 if (Error Err = importInto(Name,
D->getDeclName()))
1997 return Error::success();
2002 return Error::success();
2005 if (Error Err = importInto(ToD, FromD))
2008 if (
RecordDecl *FromRecord = dyn_cast<RecordDecl>(FromD)) {
2009 if (
RecordDecl *ToRecord = cast<RecordDecl>(ToD)) {
2010 if (FromRecord->getDefinition() && FromRecord->isCompleteDefinition() &&
2011 !ToRecord->getDefinition()) {
2016 return Error::success();
2019 if (
EnumDecl *FromEnum = dyn_cast<EnumDecl>(FromD)) {
2020 if (
EnumDecl *ToEnum = cast<EnumDecl>(ToD)) {
2021 if (FromEnum->getDefinition() && !ToEnum->getDefinition()) {
2026 return Error::success();
2029 return Error::success();
2044 return Error::success();
2050 return ToRangeOrErr.takeError();
2051 return Error::success();
2057 return LocOrErr.takeError();
2058 return Error::success();
2066 return ToTInfoOrErr.takeError();
2067 return Error::success();
2070 llvm_unreachable(
"Unknown name kind.");
2077 return ToDCOrErr.takeError();
2091 auto MightNeedReordering = [](
const Decl *
D) {
2092 return isa<FieldDecl>(
D) || isa<IndirectFieldDecl>(
D) || isa<FriendDecl>(
D);
2096 Error ChildErrors = Error::success();
2097 for (
auto *From : FromDC->
decls()) {
2098 if (!MightNeedReordering(From))
2107 if (!ImportedOrErr) {
2109 ImportedOrErr.takeError());
2112 FieldDecl *FieldFrom = dyn_cast_or_null<FieldDecl>(From);
2113 Decl *ImportedDecl = *ImportedOrErr;
2114 FieldDecl *FieldTo = dyn_cast_or_null<FieldDecl>(ImportedDecl);
2115 if (FieldFrom && FieldTo) {
2147 consumeError(std::move(ChildErrors));
2148 return ToDCOrErr.takeError();
2151 if (
const auto *FromRD = dyn_cast<RecordDecl>(FromDC)) {
2155 for (
auto *
D : FromRD->decls()) {
2156 if (!MightNeedReordering(
D))
2159 assert(
D &&
"DC contains a null decl");
2162 assert(ToDC == ToD->getLexicalDeclContext() && ToDC->
containsDecl(ToD));
2174 for (
auto *From : FromDC->
decls()) {
2175 if (MightNeedReordering(From))
2181 ImportedOrErr.takeError());
2201 if (!FromRecordDecl || !ToRecordDecl) {
2205 if (RecordFrom && RecordTo) {
2206 FromRecordDecl = RecordFrom->
getDecl();
2207 ToRecordDecl = RecordTo->getDecl();
2211 if (FromRecordDecl && ToRecordDecl) {
2217 return Error::success();
2224 return ToDCOrErr.takeError();
2230 if (!ToLexicalDCOrErr)
2231 return ToLexicalDCOrErr.takeError();
2232 ToLexicalDC = *ToLexicalDCOrErr;
2236 return Error::success();
2242 "Import implicit methods to or from non-definition");
2245 if (FromM->isImplicit()) {
2248 return ToMOrErr.takeError();
2251 return Error::success();
2260 return ToTypedefOrErr.takeError();
2262 return Error::success();
2267 auto DefinitionCompleter = [To]() {
2286 auto *FromCXXRD = cast<CXXRecordDecl>(From);
2288 ToCaptures.reserve(FromCXXRD->capture_size());
2289 for (
const auto &FromCapture : FromCXXRD->captures()) {
2290 if (
auto ToCaptureOrErr =
import(FromCapture))
2291 ToCaptures.push_back(*ToCaptureOrErr);
2293 return ToCaptureOrErr.takeError();
2295 cast<CXXRecordDecl>(To)->setCaptures(Importer.
getToContext(),
2302 DefinitionCompleter();
2306 return Error::success();
2321 auto DefinitionCompleterScopeExit =
2322 llvm::make_scope_exit(DefinitionCompleter);
2328 auto *ToCXX = dyn_cast<CXXRecordDecl>(To);
2329 auto *FromCXX = dyn_cast<CXXRecordDecl>(From);
2330 if (ToCXX && FromCXX && ToCXX->dataPtr() && FromCXX->dataPtr()) {
2332 struct CXXRecordDecl::DefinitionData &ToData = ToCXX->data();
2333 struct CXXRecordDecl::DefinitionData &FromData = FromCXX->data();
2335 #define FIELD(Name, Width, Merge) \
2336 ToData.Name = FromData.Name;
2337 #include "clang/AST/CXXRecordDeclDefinitionBits.def"
2340 ToCXX->setArgPassingRestrictions(FromCXX->getArgPassingRestrictions());
2343 for (
const auto &Base1 : FromCXX->bases()) {
2346 return TyOrErr.takeError();
2349 if (Base1.isPackExpansion()) {
2350 if (
ExpectedSLoc LocOrErr =
import(Base1.getEllipsisLoc()))
2351 EllipsisLoc = *LocOrErr;
2353 return LocOrErr.takeError();
2361 auto RangeOrErr =
import(Base1.getSourceRange());
2363 return RangeOrErr.takeError();
2365 auto TSIOrErr =
import(Base1.getTypeSourceInfo());
2367 return TSIOrErr.takeError();
2373 Base1.isBaseOfClass(),
2374 Base1.getAccessSpecifierAsWritten(),
2379 ToCXX->setBases(Bases.data(), Bases.size());
2387 return Error::success();
2392 return Error::success();
2396 return Error::success();
2400 return ToInitOrErr.takeError();
2411 return Error::success();
2419 return Error::success();
2430 return ToTypeOrErr.takeError();
2433 if (!ToPromotionTypeOrErr)
2434 return ToPromotionTypeOrErr.takeError();
2445 return Error::success();
2451 for (
const auto &Arg : FromArgs) {
2452 if (
auto ToOrErr =
import(Arg))
2453 ToArgs.push_back(*ToOrErr);
2455 return ToOrErr.takeError();
2458 return Error::success();
2464 return import(From);
2467template <
typename InContainerTy>
2470 for (
const auto &FromLoc : Container) {
2471 if (
auto ToLocOrErr =
import(FromLoc))
2474 return ToLocOrErr.takeError();
2476 return Error::success();
2486 bool IgnoreTemplateParmDepth) {
2497 false, Complain,
false,
2498 IgnoreTemplateParmDepth);
2518 return std::move(Err);
2523 return LocOrErr.takeError();
2526 if (GetImportedOrCreateDecl(ToD,
D, Importer.
getToContext(), DC, *LocOrErr))
2549 return std::move(Err);
2555 Name.getAsIdentifierInfo()))
2558 Error Err = Error::success();
2563 return std::move(Err);
2567 addDeclToContexts(
D, ToD);
2575 return LocOrErr.takeError();
2576 auto ColonLocOrErr =
import(
D->getColonLoc());
2578 return ColonLocOrErr.takeError();
2583 return DCOrErr.takeError();
2588 DC, *LocOrErr, *ColonLocOrErr))
2602 return DCOrErr.takeError();
2606 Error Err = Error::success();
2612 return std::move(Err);
2615 if (GetImportedOrCreateDecl(
2616 ToD,
D, Importer.
getToContext(), DC, ToLocation, ToAssertExpr, ToMessage,
2617 ToRParenLoc,
D->isFailed()))
2632 return std::move(Err);
2641 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2647 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2648 for (
auto *FoundDecl : FoundDecls) {
2652 if (
auto *FoundNS = dyn_cast<NamespaceDecl>(FoundDecl)) {
2653 MergeWithNamespace = FoundNS;
2654 ConflictingDecls.clear();
2658 ConflictingDecls.push_back(FoundDecl);
2661 if (!ConflictingDecls.empty()) {
2664 ConflictingDecls.size());
2666 Name = NameOrErr.get();
2668 return NameOrErr.takeError();
2674 return BeginLocOrErr.takeError();
2676 if (!RBraceLocOrErr)
2677 return RBraceLocOrErr.takeError();
2682 if (GetImportedOrCreateDecl(ToNamespace,
D, Importer.
getToContext(), DC,
2683 D->isInline(), *BeginLocOrErr,
Loc,
2684 Name.getAsIdentifierInfo(),
2685 nullptr,
D->isNested()))
2694 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2695 TU->setAnonymousNamespace(ToNamespace);
2697 cast<NamespaceDecl>(DC)->setAnonymousNamespace(ToNamespace);
2703 return std::move(Err);
2715 return std::move(Err);
2721 Error Err = Error::success();
2725 auto ToTargetNameLoc =
importChecked(Err,
D->getTargetNameLoc());
2728 return std::move(Err);
2733 if (GetImportedOrCreateDecl(
2734 ToD,
D, Importer.
getToContext(), DC, ToNamespaceLoc, ToAliasLoc,
2735 ToIdentifier, ToQualifierLoc, ToTargetNameLoc, ToNamespace))
2753 return std::move(Err);
2772 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2773 for (
auto *FoundDecl : FoundDecls) {
2776 if (
auto *FoundTypedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
2780 QualType FromUT =
D->getUnderlyingType();
2781 QualType FoundUT = FoundTypedef->getUnderlyingType();
2795 if (FromR && FoundR &&
2806 ConflictingDecls.push_back(FoundDecl);
2811 if (!ConflictingDecls.empty()) {
2813 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
2815 Name = NameOrErr.get();
2817 return NameOrErr.takeError();
2821 Error Err = Error::success();
2823 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
2826 return std::move(Err);
2833 if (GetImportedOrCreateDecl<TypeAliasDecl>(
2835 Name.getAsIdentifierInfo(), ToTypeSourceInfo))
2837 }
else if (GetImportedOrCreateDecl<TypedefDecl>(
2839 Name.getAsIdentifierInfo(), ToTypeSourceInfo))
2844 return std::move(Err);
2848 Importer.AddToLookupTable(ToTypedef);
2853 TypeAliasDecl *FromAlias = IsAlias ? cast<TypeAliasDecl>(
D) :
nullptr;
2876 return std::move(Err);
2886 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2887 for (
auto *FoundDecl : FoundDecls) {
2890 if (
auto *FoundAlias = dyn_cast<TypeAliasTemplateDecl>(FoundDecl)) {
2893 ConflictingDecls.push_back(FoundDecl);
2897 if (!ConflictingDecls.empty()) {
2899 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
2901 Name = NameOrErr.get();
2903 return NameOrErr.takeError();
2907 Error Err = Error::success();
2908 auto ToTemplateParameters =
importChecked(Err,
D->getTemplateParameters());
2909 auto ToTemplatedDecl =
importChecked(Err,
D->getTemplatedDecl());
2911 return std::move(Err);
2915 Name, ToTemplateParameters, ToTemplatedDecl))
2918 ToTemplatedDecl->setDescribedAliasTemplate(ToAlias);
2924 updateLookupTableForTemplateParameters(*ToTemplateParameters);
2935 return std::move(Err);
2942 if (
D->isGnuLocal()) {
2945 return BeginLocOrErr.takeError();
2947 Name.getAsIdentifierInfo(), *BeginLocOrErr))
2952 Name.getAsIdentifierInfo()))
2959 return ToStmtOrErr.takeError();
2961 ToLabel->
setStmt(*ToStmtOrErr);
2974 return std::move(Err);
2981 if (!SearchName &&
D->getTypedefNameForAnonDecl()) {
2982 if (Error Err = importInto(
2983 SearchName,
D->getTypedefNameForAnonDecl()->getDeclName()))
2984 return std::move(Err);
2994 Importer.findDeclsInToCtx(DC, SearchName);
2995 for (
auto *FoundDecl : FoundDecls) {
2999 if (
auto *Typedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
3000 if (
const auto *Tag = Typedef->getUnderlyingType()->getAs<
TagType>())
3001 FoundDecl = Tag->getDecl();
3004 if (
auto *FoundEnum = dyn_cast<EnumDecl>(FoundDecl)) {
3009 if (
D->isThisDeclarationADefinition() && FoundDef)
3014 ConflictingDecls.push_back(FoundDecl);
3023 if (SearchName && !ConflictingDecls.empty()) {
3025 SearchName, DC, IDNS, ConflictingDecls.data(),
3026 ConflictingDecls.size());
3028 Name = NameOrErr.get();
3030 return NameOrErr.takeError();
3034 Error Err = Error::success();
3040 return std::move(Err);
3044 if (GetImportedOrCreateDecl(
3046 Loc, Name.getAsIdentifierInfo(), PrevDecl,
D->isScoped(),
3047 D->isScopedUsingClassTag(),
D->isFixed()))
3055 addDeclToContexts(
D, D2);
3059 EnumDecl *FromInst =
D->getInstantiatedFromMemberEnum();
3061 D2->setInstantiationOfMemberEnum(*ToInstOrErr, SK);
3063 return ToInstOrErr.takeError();
3064 if (
ExpectedSLoc POIOrErr =
import(MemberInfo->getPointOfInstantiation()))
3067 return POIOrErr.takeError();
3071 if (
D->isCompleteDefinition())
3073 return std::move(Err);
3079 bool IsFriendTemplate =
false;
3080 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(
D)) {
3082 DCXX->getDescribedClassTemplate() &&
3083 DCXX->getDescribedClassTemplate()->getFriendObjectKind() !=
3093 return std::move(Err);
3100 if (!SearchName &&
D->getTypedefNameForAnonDecl()) {
3101 if (Error Err = importInto(
3102 SearchName,
D->getTypedefNameForAnonDecl()->getDeclName()))
3103 return std::move(Err);
3110 bool DependentFriend = IsFriendTemplate && IsDependentContext;
3117 Importer.findDeclsInToCtx(DC, SearchName);
3118 if (!FoundDecls.empty()) {
3121 if (
D->hasExternalLexicalStorage() && !
D->isCompleteDefinition())
3125 for (
auto *FoundDecl : FoundDecls) {
3130 if (
auto *Typedef = dyn_cast<TypedefNameDecl>(
Found)) {
3131 if (
const auto *Tag = Typedef->getUnderlyingType()->getAs<
TagType>())
3132 Found = Tag->getDecl();
3135 if (
auto *FoundRecord = dyn_cast<RecordDecl>(
Found)) {
3154 if (
D->isThisDeclarationADefinition() && FoundDef) {
3158 if (
const auto *DCXX = dyn_cast<CXXRecordDecl>(
D)) {
3159 auto *FoundCXX = dyn_cast<CXXRecordDecl>(FoundDef);
3160 assert(FoundCXX &&
"Record type mismatch");
3166 return std::move(Err);
3172 ConflictingDecls.push_back(FoundDecl);
3176 if (!ConflictingDecls.empty() && SearchName) {
3178 SearchName, DC, IDNS, ConflictingDecls.data(),
3179 ConflictingDecls.size());
3181 Name = NameOrErr.get();
3183 return NameOrErr.takeError();
3189 return BeginLocOrErr.takeError();
3194 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(
D)) {
3195 if (DCXX->isLambda()) {
3196 auto TInfoOrErr =
import(DCXX->getLambdaTypeInfo());
3198 return TInfoOrErr.takeError();
3199 if (GetImportedOrCreateSpecialDecl(
3201 DC, *TInfoOrErr,
Loc, DCXX->getLambdaDependencyKind(),
3202 DCXX->isGenericLambda(), DCXX->getLambdaCaptureDefault()))
3207 return CDeclOrErr.takeError();
3210 }
else if (DCXX->isInjectedClassName()) {
3213 const bool DelayTypeCreation =
true;
3214 if (GetImportedOrCreateDecl(
3216 *BeginLocOrErr,
Loc, Name.getAsIdentifierInfo(),
3217 cast_or_null<CXXRecordDecl>(PrevDecl), DelayTypeCreation))
3220 D2CXX, dyn_cast<CXXRecordDecl>(DC));
3222 if (GetImportedOrCreateDecl(D2CXX,
D, Importer.
getToContext(),
3223 D->getTagKind(), DC, *BeginLocOrErr,
Loc,
3224 Name.getAsIdentifierInfo(),
3225 cast_or_null<CXXRecordDecl>(PrevDecl)))
3232 addDeclToContexts(
D, D2);
3235 DCXX->getDescribedClassTemplate()) {
3237 if (Error Err = importInto(ToDescribed, FromDescribed))
3238 return std::move(Err);
3240 if (!DCXX->isInjectedClassName() && !IsFriendTemplate) {
3260 const Type *FrontTy =
3261 cast<CXXRecordDecl>(Redecls.front())->getTypeForDecl();
3264 InjSpec = InjTy->getInjectedSpecializationType();
3267 for (
auto *R : Redecls) {
3268 auto *RI = cast<CXXRecordDecl>(R);
3269 if (R != Redecls.front() ||
3270 !isa<InjectedClassNameType>(RI->getTypeForDecl()))
3271 RI->setTypeForDecl(
nullptr);
3286 DCXX->getMemberSpecializationInfo()) {
3288 MemberInfo->getTemplateSpecializationKind();
3294 return ToInstOrErr.takeError();
3297 import(MemberInfo->getPointOfInstantiation()))
3301 return POIOrErr.takeError();
3306 D->getTagKind(), DC, *BeginLocOrErr,
Loc,
3307 Name.getAsIdentifierInfo(), PrevDecl))
3310 addDeclToContexts(
D, D2);
3313 if (
auto BraceRangeOrErr =
import(
D->getBraceRange()))
3316 return BraceRangeOrErr.takeError();
3317 if (
auto QualifierLocOrErr =
import(
D->getQualifierLoc()))
3320 return QualifierLocOrErr.takeError();
3322 if (
D->isAnonymousStructOrUnion())
3325 if (
D->isCompleteDefinition())
3327 return std::move(Err);
3339 return std::move(Err);
3348 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3349 for (
auto *FoundDecl : FoundDecls) {
3353 if (
auto *FoundEnumConstant = dyn_cast<EnumConstantDecl>(FoundDecl)) {
3356 ConflictingDecls.push_back(FoundDecl);
3360 if (!ConflictingDecls.empty()) {
3362 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3364 Name = NameOrErr.get();
3366 return NameOrErr.takeError();
3372 return TypeOrErr.takeError();
3376 return InitOrErr.takeError();
3379 if (GetImportedOrCreateDecl(
3381 Name.getAsIdentifierInfo(), *TypeOrErr, *InitOrErr,
D->getInitVal()))
3382 return ToEnumerator;
3387 return ToEnumerator;
3390template <
typename DeclTy>
3393 unsigned int Num = FromD->getNumTemplateParameterLists();
3395 return Error::success();
3397 for (
unsigned int I = 0; I <
Num; ++I)
3399 import(FromD->getTemplateParameterList(I)))
3400 ToTPLists[I] = *ToTPListOrErr;
3402 return ToTPListOrErr.takeError();
3403 ToD->setTemplateParameterListsInfo(Importer.ToContext, ToTPLists);
3404 return Error::success();
3412 return Error::success();
3418 return Error::success();
3424 ToFD->setInstantiationOfMemberFunction(*InstFDOrErr, TSK);
3426 return InstFDOrErr.takeError();
3432 return POIOrErr.takeError();
3434 return Error::success();
3438 auto FunctionAndArgsOrErr =
3440 if (!FunctionAndArgsOrErr)
3441 return FunctionAndArgsOrErr.takeError();
3444 Importer.
getToContext(), std::get<1>(*FunctionAndArgsOrErr));
3448 const auto *FromTAArgsAsWritten = FTSInfo->TemplateArgumentsAsWritten;
3449 if (FromTAArgsAsWritten)
3451 *FromTAArgsAsWritten, ToTAInfo))
3454 ExpectedSLoc POIOrErr =
import(FTSInfo->getPointOfInstantiation());
3456 return POIOrErr.takeError();
3462 ToFD->setFunctionTemplateSpecialization(
3463 std::get<0>(*FunctionAndArgsOrErr), ToTAList,
nullptr,
3464 TSK, FromTAArgsAsWritten ? &ToTAInfo :
nullptr, *POIOrErr);
3465 return Error::success();
3473 Candidates.
addDecl(*ToFTDOrErr);
3475 return ToFTDOrErr.takeError();
3480 const auto *FromTAArgsAsWritten = FromInfo->TemplateArgumentsAsWritten;
3481 if (FromTAArgsAsWritten)
3488 FromTAArgsAsWritten ? &ToTAInfo :
nullptr);
3489 return Error::success();
3492 llvm_unreachable(
"All cases should be covered!");
3497 auto FunctionAndArgsOrErr =
3499 if (!FunctionAndArgsOrErr)
3500 return FunctionAndArgsOrErr.takeError();
3504 std::tie(Template, ToTemplArgs) = *FunctionAndArgsOrErr;
3505 void *InsertPos =
nullptr;
3516 return ToBodyOrErr.takeError();
3518 return Error::success();
3527 assert(DCi &&
"Declaration should have a context");
3541 ToProcess.push_back(S);
3542 while (!ToProcess.empty()) {
3543 const Stmt *CurrentS = ToProcess.pop_back_val();
3545 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(CurrentS)) {
3546 if (
const Decl *
D = DeclRef->getDecl())
3549 }
else if (
const auto *
E =
3550 dyn_cast_or_null<SubstNonTypeTemplateParmExpr>(CurrentS)) {
3551 if (
const Decl *
D =
E->getAssociatedDecl())
3584class IsTypeDeclaredInsideVisitor
3585 :
public TypeVisitor<IsTypeDeclaredInsideVisitor, std::optional<bool>> {
3587 IsTypeDeclaredInsideVisitor(
const FunctionDecl *ParentDC)
3588 : ParentDC(ParentDC) {}
3594 if (std::optional<bool> Res = Visit(
T.getTypePtr()))
3597 T.getSingleStepDesugaredType(ParentDC->getParentASTContext());
3599 if (std::optional<bool> Res = Visit(DsT.
getTypePtr()))
3602 DsT =
T.getSingleStepDesugaredType(ParentDC->getParentASTContext());
3607 std::optional<bool> VisitTagType(
const TagType *
T) {
3608 if (
auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(
T->getDecl()))
3609 for (
const auto &Arg : Spec->getTemplateArgs().asArray())
3610 if (checkTemplateArgument(Arg))
3615 std::optional<bool> VisitPointerType(
const PointerType *
T) {
3620 return CheckType(
T->getPointeeTypeAsWritten());
3623 std::optional<bool> VisitTypedefType(
const TypedefType *
T) {
3629 std::optional<bool> VisitUsingType(
const UsingType *
T) {
3630 if (
T->getFoundDecl() &&
3639 for (
const auto &Arg :
T->template_arguments())
3640 if (checkTemplateArgument(Arg))
3647 return CheckType(
T->getBaseType());
3662 return CheckType(
T->getElementType());
3667 "Variable array should not occur in deduced return type of a function");
3671 llvm_unreachable(
"Incomplete array should not occur in deduced return type "
3676 llvm_unreachable(
"Dependent array should not occur in deduced return type "
3703 if (checkTemplateArgument(PackArg))
3715 llvm_unreachable(
"Unknown TemplateArgument::ArgKind enum");
3725 assert(FromFPT &&
"Must be called on FunctionProtoType");
3727 auto IsCXX11Lambda = [&]() {
3728 if (Importer.FromContext.
getLangOpts().CPlusPlus14)
3731 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
D))
3732 return cast<CXXRecordDecl>(MD->getDeclContext())->isLambda();
3737 QualType RetT = FromFPT->getReturnType();
3738 if (isa<AutoType>(RetT.
getTypePtr()) || IsCXX11Lambda()) {
3740 IsTypeDeclaredInsideVisitor Visitor(Def ? Def :
D);
3741 return Visitor.CheckType(RetT);
3758 auto RedeclIt = Redecls.begin();
3761 for (; RedeclIt != Redecls.end() && *RedeclIt !=
D; ++RedeclIt) {
3764 return ToRedeclOrErr.takeError();
3766 assert(*RedeclIt ==
D);
3774 return std::move(Err);
3786 if (
D->getTemplatedKind() ==
3789 if (!FoundFunctionOrErr)
3790 return FoundFunctionOrErr.takeError();
3791 if (
FunctionDecl *FoundFunction = *FoundFunctionOrErr) {
3792 if (
Decl *Def = FindAndMapDefinition(
D, FoundFunction))
3794 FoundByLookup = FoundFunction;
3802 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3803 for (
auto *FoundDecl : FoundDecls) {
3807 if (
auto *FoundFunction = dyn_cast<FunctionDecl>(FoundDecl)) {
3812 if (
Decl *Def = FindAndMapDefinition(
D, FoundFunction))
3814 FoundByLookup = FoundFunction;
3825 Importer.
ToDiag(
Loc, diag::warn_odr_function_type_inconsistent)
3826 << Name <<
D->getType() << FoundFunction->getType();
3827 Importer.
ToDiag(FoundFunction->getLocation(), diag::note_odr_value_here)
3828 << FoundFunction->getType();
3829 ConflictingDecls.push_back(FoundDecl);
3833 if (!ConflictingDecls.empty()) {
3835 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3837 Name = NameOrErr.get();
3839 return NameOrErr.takeError();
3849 if (FoundByLookup) {
3850 if (isa<CXXMethodDecl>(FoundByLookup)) {
3852 if (!
D->doesThisDeclarationHaveABody()) {
3854 D->getDescribedFunctionTemplate()) {
3859 "Templated function mapped to non-templated?");
3875 return std::move(Err);
3886 bool UsedDifferentProtoType =
false;
3888 QualType FromReturnTy = FromFPT->getReturnType();
3896 UsedDifferentProtoType =
true;
3907 FromEPI = DefaultEPI;
3908 UsedDifferentProtoType =
true;
3911 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
3916 Error Err = Error::success();
3919 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
3923 auto TrailingRequiresClause =
3926 return std::move(Err);
3930 for (
auto *
P :
D->parameters()) {
3932 Parameters.push_back(*ToPOrErr);
3934 return ToPOrErr.takeError();
3939 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(
D)) {
3941 importExplicitSpecifier(Err, FromConstructor->getExplicitSpecifier());
3943 return std::move(Err);
3945 if (FromConstructor->isInheritingConstructor()) {
3947 import(FromConstructor->getInheritedConstructor());
3948 if (!ImportedInheritedCtor)
3949 return ImportedInheritedCtor.takeError();
3950 ToInheritedConstructor = *ImportedInheritedCtor;
3952 if (GetImportedOrCreateDecl<CXXConstructorDecl>(
3953 ToFunction,
D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3954 ToInnerLocStart, NameInfo,
T, TInfo, ESpec,
D->UsesFPIntrin(),
3955 D->isInlineSpecified(),
D->
isImplicit(),
D->getConstexprKind(),
3956 ToInheritedConstructor, TrailingRequiresClause))
3960 Error Err = Error::success();
3962 Err,
const_cast<FunctionDecl *
>(FromDtor->getOperatorDelete()));
3963 auto ToThisArg =
importChecked(Err, FromDtor->getOperatorDeleteThisArg());
3965 return std::move(Err);
3967 if (GetImportedOrCreateDecl<CXXDestructorDecl>(
3968 ToFunction,
D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3969 ToInnerLocStart, NameInfo,
T, TInfo,
D->UsesFPIntrin(),
3970 D->isInlineSpecified(),
D->
isImplicit(),
D->getConstexprKind(),
3971 TrailingRequiresClause))
3978 dyn_cast<CXXConversionDecl>(
D)) {
3980 importExplicitSpecifier(Err, FromConversion->getExplicitSpecifier());
3982 return std::move(Err);
3983 if (GetImportedOrCreateDecl<CXXConversionDecl>(
3984 ToFunction,
D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3985 ToInnerLocStart, NameInfo,
T, TInfo,
D->UsesFPIntrin(),
3986 D->isInlineSpecified(), ESpec,
D->getConstexprKind(),
3989 }
else if (
auto *Method = dyn_cast<CXXMethodDecl>(
D)) {
3990 if (GetImportedOrCreateDecl<CXXMethodDecl>(
3991 ToFunction,
D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3992 ToInnerLocStart, NameInfo,
T, TInfo, Method->getStorageClass(),
3993 Method->UsesFPIntrin(), Method->isInlineSpecified(),
3996 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(
D)) {
3998 importExplicitSpecifier(Err, Guide->getExplicitSpecifier());
4002 return std::move(Err);
4003 if (GetImportedOrCreateDecl<CXXDeductionGuideDecl>(
4004 ToFunction,
D, Importer.
getToContext(), DC, ToInnerLocStart, ESpec,
4005 NameInfo,
T, TInfo, ToEndLoc, Ctor))
4007 cast<CXXDeductionGuideDecl>(ToFunction)
4008 ->setDeductionCandidateKind(Guide->getDeductionCandidateKind());
4010 if (GetImportedOrCreateDecl(
4011 ToFunction,
D, Importer.
getToContext(), DC, ToInnerLocStart,
4012 NameInfo,
T, TInfo,
D->getStorageClass(),
D->UsesFPIntrin(),
4013 D->isInlineSpecified(),
D->hasWrittenPrototype(),
4014 D->getConstexprKind(), TrailingRequiresClause))
4019 if (FoundByLookup) {
4032 auto Imported =
import(Msg);
4034 return Imported.takeError();
4048 D->FriendConstraintRefersToEnclosingTemplate());
4058 for (
auto *Param : Parameters) {
4059 Param->setOwningFunction(ToFunction);
4064 ToFunction->setParams(Parameters);
4071 for (
unsigned I = 0, N = Parameters.size(); I != N; ++I)
4072 ProtoLoc.setParam(I, Parameters[I]);
4078 auto ToFTOrErr =
import(FromFT);
4080 return ToFTOrErr.takeError();
4084 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(
D)) {
4085 if (
unsigned NumInitializers = FromConstructor->getNumCtorInitializers()) {
4089 FromConstructor->inits(), CtorInitializers))
4090 return std::move(Err);
4093 std::copy(CtorInitializers.begin(), CtorInitializers.end(), Memory);
4094 auto *ToCtor = cast<CXXConstructorDecl>(ToFunction);
4095 ToCtor->setCtorInitializers(Memory);
4096 ToCtor->setNumCtorInitializers(NumInitializers);
4102 return std::move(Err);
4104 if (
auto *FromCXXMethod = dyn_cast<CXXMethodDecl>(
D))
4107 return std::move(Err);
4109 if (
D->doesThisDeclarationHaveABody()) {
4113 return std::move(Err);
4117 if (UsedDifferentProtoType) {
4119 ToFunction->
setType(*TyOrErr);
4121 return TyOrErr.takeError();
4125 return TSIOrErr.takeError();
4130 addDeclToContexts(
D, ToFunction);
4133 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4136 return ToRedeclOrErr.takeError();
4170 return std::move(Err);
4175 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4176 for (
auto *FoundDecl : FoundDecls) {
4177 if (
FieldDecl *FoundField = dyn_cast<FieldDecl>(FoundDecl)) {
4185 FoundField->getType())) {
4193 if (
Expr *FromInitializer =
D->getInClassInitializer()) {
4194 if (
ExpectedExpr ToInitializerOrErr =
import(FromInitializer)) {
4197 assert(FoundField->hasInClassInitializer() &&
4198 "Field should have an in-class initializer if it has an "
4199 "expression for it.");
4200 if (!FoundField->getInClassInitializer())
4201 FoundField->setInClassInitializer(*ToInitializerOrErr);
4203 return ToInitializerOrErr.takeError();
4210 Importer.
ToDiag(
Loc, diag::warn_odr_field_type_inconsistent)
4211 << Name <<
D->getType() << FoundField->getType();
4212 Importer.
ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4213 << FoundField->getType();
4219 Error Err = Error::success();
4223 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
4225 return std::move(Err);
4226 const Type *ToCapturedVLAType =
nullptr;
4228 ToCapturedVLAType, cast_or_null<Type>(
D->getCapturedVLAType())))
4229 return std::move(Err);
4232 if (GetImportedOrCreateDecl(ToField,
D, Importer.
getToContext(), DC,
4233 ToInnerLocStart,
Loc, Name.getAsIdentifierInfo(),
4234 ToType, ToTInfo, ToBitWidth,
D->isMutable(),
4235 D->getInClassInitStyle()))
4241 if (ToCapturedVLAType)
4246 auto ToInitializer =
importChecked(Err,
D->getInClassInitializer());
4248 return std::move(Err);
4249 if (ToInitializer) {
4251 if (AlreadyImported)
4252 assert(ToInitializer == AlreadyImported &&
4253 "Duplicate import of in-class initializer.");
4268 return std::move(Err);
4273 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4274 for (
unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
4275 if (
auto *FoundField = dyn_cast<IndirectFieldDecl>(FoundDecls[I])) {
4283 FoundField->getType(),
4290 if (!Name && I < N-1)
4294 Importer.
ToDiag(
Loc, diag::warn_odr_field_type_inconsistent)
4295 << Name <<
D->getType() << FoundField->getType();
4296 Importer.
ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4297 << FoundField->getType();
4304 auto TypeOrErr =
import(
D->getType());
4306 return TypeOrErr.takeError();
4312 for (
auto *PI :
D->chain())
4314 NamedChain[i++] = *ToD;
4316 return ToD.takeError();
4320 if (GetImportedOrCreateDecl(ToIndirectField,
D, Importer.
getToContext(), DC,
4321 Loc, Name.getAsIdentifierInfo(), *TypeOrErr, CH))
4323 return ToIndirectField;
4328 return ToIndirectField;
4358 unsigned int FriendCount = 0;
4359 std::optional<unsigned int> FriendPosition;
4362 for (
FriendDecl *FoundFriend : RD->friends()) {
4363 if (FoundFriend == FD) {
4364 FriendPosition = FriendCount;
4371 assert(FriendPosition &&
"Friend decl not found in own parent.");
4373 return {FriendCount, *FriendPosition};
4380 return std::move(Err);
4385 const auto *RD = cast<CXXRecordDecl>(DC);
4387 for (
FriendDecl *ImportedFriend : RD->friends())
4389 ImportedEquivalentFriends.push_back(ImportedFriend);
4394 assert(ImportedEquivalentFriends.size() <= CountAndPosition.
TotalCount &&
4395 "Class with non-matching friends is imported, ODR check wrong?");
4396 if (ImportedEquivalentFriends.size() == CountAndPosition.
TotalCount)
4398 D, ImportedEquivalentFriends[CountAndPosition.
IndexOfDecl]);
4403 if (
NamedDecl *FriendD =
D->getFriendDecl()) {
4405 if (Error Err = importInto(ToFriendD, FriendD))
4406 return std::move(Err);
4414 if (
auto TSIOrErr =
import(
D->getFriendType()))
4417 return TSIOrErr.takeError();
4422 for (
unsigned I = 0; I <
D->NumTPLists; I++) {
4423 if (
auto ListOrErr =
import(FromTPLists[I]))
4424 ToTPLists[I] = *ListOrErr;
4426 return ListOrErr.takeError();
4431 return LocationOrErr.takeError();
4432 auto FriendLocOrErr =
import(
D->getFriendLoc());
4433 if (!FriendLocOrErr)
4434 return FriendLocOrErr.takeError();
4435 auto EllipsisLocOrErr =
import(
D->getEllipsisLoc());
4436 if (!EllipsisLocOrErr)
4437 return EllipsisLocOrErr.takeError();
4440 if (GetImportedOrCreateDecl(FrD,
D, Importer.
getToContext(), DC,
4441 *LocationOrErr, ToFU, *FriendLocOrErr,
4442 *EllipsisLocOrErr, ToTPLists))
4458 return std::move(Err);
4463 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4464 for (
auto *FoundDecl : FoundDecls) {
4465 if (
ObjCIvarDecl *FoundIvar = dyn_cast<ObjCIvarDecl>(FoundDecl)) {
4467 FoundIvar->getType())) {
4472 Importer.
ToDiag(
Loc, diag::warn_odr_ivar_type_inconsistent)
4473 << Name <<
D->getType() << FoundIvar->getType();
4474 Importer.
ToDiag(FoundIvar->getLocation(), diag::note_odr_value_here)
4475 << FoundIvar->getType();
4481 Error Err = Error::success();
4483 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
4485 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
4487 return std::move(Err);
4490 if (GetImportedOrCreateDecl(
4491 ToIvar,
D, Importer.
getToContext(), cast<ObjCContainerDecl>(DC),
4492 ToInnerLocStart,
Loc, Name.getAsIdentifierInfo(),
4493 ToType, ToTypeSourceInfo,
4494 D->getAccessControl(),ToBitWidth,
D->getSynthesize()))
4505 auto RedeclIt = Redecls.begin();
4508 for (; RedeclIt != Redecls.end() && *RedeclIt !=
D; ++RedeclIt) {
4511 return RedeclOrErr.takeError();
4513 assert(*RedeclIt ==
D);
4521 return std::move(Err);
4527 VarDecl *FoundByLookup =
nullptr;
4528 if (
D->isFileVarDecl()) {
4531 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4532 for (
auto *FoundDecl : FoundDecls) {
4536 if (
auto *FoundVar = dyn_cast<VarDecl>(FoundDecl)) {
4540 FoundVar->getType())) {
4545 if (
D->isThisDeclarationADefinition() && FoundDef)
4552 const VarDecl *FoundDInit =
nullptr;
4553 if (
D->getInit() && FoundVar->getAnyInitializer(FoundDInit))
4557 FoundByLookup = FoundVar;
4565 if (FoundArray && TArray) {
4566 if (isa<IncompleteArrayType>(FoundArray) &&
4567 isa<ConstantArrayType>(TArray)) {
4569 if (
auto TyOrErr =
import(
D->getType()))
4570 FoundVar->setType(*TyOrErr);
4572 return TyOrErr.takeError();
4574 FoundByLookup = FoundVar;
4576 }
else if (isa<IncompleteArrayType>(TArray) &&
4577 isa<ConstantArrayType>(FoundArray)) {
4578 FoundByLookup = FoundVar;
4583 Importer.
ToDiag(
Loc, diag::warn_odr_variable_type_inconsistent)
4584 << Name <<
D->getType() << FoundVar->getType();
4585 Importer.
ToDiag(FoundVar->getLocation(), diag::note_odr_value_here)
4586 << FoundVar->getType();
4587 ConflictingDecls.push_back(FoundDecl);
4591 if (!ConflictingDecls.empty()) {
4593 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
4595 Name = NameOrErr.get();
4597 return NameOrErr.takeError();
4601 Error Err = Error::success();
4603 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
4604 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
4607 return std::move(Err);
4610 if (
auto *FromDecomp = dyn_cast<DecompositionDecl>(
D)) {
4614 return std::move(Err);
4616 if (GetImportedOrCreateDecl(
4617 ToDecomp, FromDecomp, Importer.
getToContext(), DC, ToInnerLocStart,
4618 Loc, ToType, ToTypeSourceInfo,
D->getStorageClass(),
Bindings))
4623 if (GetImportedOrCreateDecl(ToVar,
D, Importer.
getToContext(), DC,
4624 ToInnerLocStart,
Loc,
4625 Name.getAsIdentifierInfo(), ToType,
4626 ToTypeSourceInfo,
D->getStorageClass()))
4634 if (
D->isInlineSpecified())
4639 if (FoundByLookup) {
4645 if (
D->getDescribedVarTemplate()) {
4646 auto ToVTOrErr =
import(
D->getDescribedVarTemplate());
4648 return ToVTOrErr.takeError();
4651 VarDecl *FromInst =
D->getInstantiatedFromStaticDataMember();
4655 return ToInstOrErr.takeError();
4656 if (
ExpectedSLoc POIOrErr =
import(MSI->getPointOfInstantiation()))
4659 return POIOrErr.takeError();
4663 return std::move(Err);
4665 if (
D->isConstexpr())
4668 addDeclToContexts(
D, ToVar);
4671 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4674 return RedeclOrErr.takeError();
4685 Error Err = Error::success();
4690 return std::move(Err);
4694 if (GetImportedOrCreateDecl(ToParm,
D, Importer.
getToContext(), DC,
4695 ToLocation, ToDeclName.getAsIdentifierInfo(),
4696 ToType,
D->getParameterKind()))
4712 return ToDefArgOrErr.takeError();
4716 if (
auto ToDefArgOrErr =
import(FromParam->
getDefaultArg()))
4719 return ToDefArgOrErr.takeError();
4722 return Error::success();
4727 Error Err = Error::success();
4732 return std::move(Err);
4741 Error Err = Error::success();
4744 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
4746 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
4748 return std::move(Err);
4751 if (GetImportedOrCreateDecl(ToParm,
D, Importer.
getToContext(), DC,
4752 ToInnerLocStart, ToLocation,
4753 ToDeclName.getAsIdentifierInfo(), ToType,
4754 ToTypeSourceInfo,
D->getStorageClass(),
4762 return std::move(Err);
4764 if (
D->isObjCMethodParameter()) {
4769 D->getFunctionScopeIndex());
4782 return std::move(Err);
4786 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4787 for (
auto *FoundDecl : FoundDecls) {
4788 if (
auto *FoundMethod = dyn_cast<ObjCMethodDecl>(FoundDecl)) {
4789 if (FoundMethod->isInstanceMethod() !=
D->isInstanceMethod())
4794 FoundMethod->getReturnType())) {
4795 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_result_type_inconsistent)
4796 <<
D->isInstanceMethod() << Name <<
D->getReturnType()
4797 << FoundMethod->getReturnType();
4798 Importer.
ToDiag(FoundMethod->getLocation(),
4799 diag::note_odr_objc_method_here)
4800 <<
D->isInstanceMethod() << Name;
4806 if (
D->param_size() != FoundMethod->param_size()) {
4807 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_num_params_inconsistent)
4808 <<
D->isInstanceMethod() << Name
4809 <<
D->param_size() << FoundMethod->param_size();
4810 Importer.
ToDiag(FoundMethod->getLocation(),
4811 diag::note_odr_objc_method_here)
4812 <<
D->isInstanceMethod() << Name;
4819 PEnd =
D->param_end(), FoundP = FoundMethod->param_begin();
4820 P != PEnd; ++
P, ++FoundP) {
4822 (*FoundP)->getType())) {
4823 Importer.
FromDiag((*P)->getLocation(),
4824 diag::warn_odr_objc_method_param_type_inconsistent)
4825 <<
D->isInstanceMethod() << Name
4826 << (*P)->getType() << (*FoundP)->getType();
4827 Importer.
ToDiag((*FoundP)->getLocation(), diag::note_odr_value_here)
4828 << (*FoundP)->getType();
4836 if (
D->isVariadic() != FoundMethod->isVariadic()) {
4837 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_variadic_inconsistent)
4838 <<
D->isInstanceMethod() << Name;
4839 Importer.
ToDiag(FoundMethod->getLocation(),
4840 diag::note_odr_objc_method_here)
4841 <<
D->isInstanceMethod() << Name;
4851 Error Err = Error::success();
4854 auto ToReturnTypeSourceInfo =
4857 return std::move(Err);
4860 if (GetImportedOrCreateDecl(
4862 Name.getObjCSelector(), ToReturnType, ToReturnTypeSourceInfo, DC,
4863 D->isInstanceMethod(),
D->isVariadic(),
D->isPropertyAccessor(),
4864 D->isSynthesizedAccessorStub(),
D->
isImplicit(),
D->isDefined(),
4865 D->getImplementationControl(),
D->hasRelatedResultType()))
4873 for (
auto *FromP :
D->parameters()) {
4875 ToParams.push_back(*ToPOrErr);
4877 return ToPOrErr.takeError();
4881 for (
auto *ToParam : ToParams) {
4882 ToParam->setOwningFunction(ToMethod);
4887 D->getSelectorLocs(FromSelLocs);
4890 return std::move(Err);
4900 if (
D->getSelfDecl())
4914 return std::move(Err);
4918 Error Err = Error::success();
4922 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
4924 return std::move(Err);
4927 if (GetImportedOrCreateDecl(
4929 ToVarianceLoc,
D->getIndex(),
4930 ToLocation, Name.getAsIdentifierInfo(),
4931 ToColonLoc, ToTypeSourceInfo))
4937 return std::move(Err);
4938 Result->setTypeForDecl(ToTypeForDecl);
4939 Result->setLexicalDeclContext(LexicalDC);
4950 return std::move(Err);
4955 if (Error Err = importInto(ToInterface,
D->getClassInterface()))
4956 return std::move(Err);
4964 Error Err = Error::success();
4966 auto ToCategoryNameLoc =
importChecked(Err,
D->getCategoryNameLoc());
4967 auto ToIvarLBraceLoc =
importChecked(Err,
D->getIvarLBraceLoc());
4968 auto ToIvarRBraceLoc =
importChecked(Err,
D->getIvarRBraceLoc());
4970 return std::move(Err);
4972 if (GetImportedOrCreateDecl(ToCategory,
D, Importer.
getToContext(), DC,
4975 Name.getAsIdentifierInfo(), ToInterface,
4988 return PListOrErr.takeError();
4994 =
D->protocol_loc_begin();
4996 FromProtoEnd =
D->protocol_end();
4997 FromProto != FromProtoEnd;
4998 ++FromProto, ++FromProtoLoc) {
5000 Protocols.push_back(*ToProtoOrErr);
5002 return ToProtoOrErr.takeError();
5004 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5005 ProtocolLocs.push_back(*ToProtoLocOrErr);
5007 return ToProtoLocOrErr.takeError();
5020 return std::move(Err);
5023 if (
D->getImplementation()) {
5025 import(
D->getImplementation()))
5028 return ToImplOrErr.takeError();
5040 return Error::success();
5053 FromProto != FromProtoEnd;
5054 ++FromProto, ++FromProtoLoc) {
5056 Protocols.push_back(*ToProtoOrErr);
5058 return ToProtoOrErr.takeError();
5060 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5061 ProtocolLocs.push_back(*ToProtoLocOrErr);
5063 return ToProtoLocOrErr.takeError();
5076 return Error::success();
5088 return ImportedDefOrErr.takeError();
5097 return std::move(Err);
5102 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5103 for (
auto *FoundDecl : FoundDecls) {
5107 if ((MergeWithProtocol = dyn_cast<ObjCProtocolDecl>(FoundDecl)))
5113 auto ToAtBeginLocOrErr =
import(
D->getAtStartLoc());
5114 if (!ToAtBeginLocOrErr)
5115 return ToAtBeginLocOrErr.takeError();
5117 if (GetImportedOrCreateDecl(ToProto,
D, Importer.
getToContext(), DC,
5118 Name.getAsIdentifierInfo(),
Loc,
5128 if (
D->isThisDeclarationADefinition())
5130 return std::move(Err);
5138 return std::move(Err);
5141 if (!ExternLocOrErr)
5142 return ExternLocOrErr.takeError();
5146 return LangLocOrErr.takeError();
5148 bool HasBraces =
D->hasBraces();
5151 if (GetImportedOrCreateDecl(ToLinkageSpec,
D, Importer.
getToContext(), DC,
5152 *ExternLocOrErr, *LangLocOrErr,
5153 D->getLanguage(), HasBraces))
5154 return ToLinkageSpec;
5158 if (!RBraceLocOrErr)
5159 return RBraceLocOrErr.takeError();
5166 return ToLinkageSpec;
5177 return ToShadowOrErr.takeError();
5188 return std::move(Err);
5192 Error Err = Error::success();
5197 return std::move(Err);
5201 return std::move(Err);
5204 if (GetImportedOrCreateDecl(ToUsing,
D, Importer.
getToContext(), DC,
5205 ToUsingLoc, ToQualifierLoc, NameInfo,
5216 ToUsing, *ToPatternOrErr);
5218 return ToPatternOrErr.takeError();
5230 return std::move(Err);
5234 Error Err = Error::success();
5240 return std::move(Err);
5243 if (GetImportedOrCreateDecl(ToUsingEnum,
D, Importer.
getToContext(), DC,
5244 ToUsingLoc, ToEnumLoc, ToNameLoc, ToEnumType))
5256 return ToPatternOrErr.takeError();
5268 return std::move(Err);
5273 if (!ToIntroducerOrErr)
5274 return ToIntroducerOrErr.takeError();
5278 return ToTargetOrErr.takeError();
5281 if (
auto *FromConstructorUsingShadow =
5282 dyn_cast<ConstructorUsingShadowDecl>(
D)) {
5283 Error Err = Error::success();
5285 Err, FromConstructorUsingShadow->getNominatedBaseClassShadowDecl());
5287 return std::move(Err);
5293 if (GetImportedOrCreateDecl<ConstructorUsingShadowDecl>(
5295 cast<UsingDecl>(*ToIntroducerOrErr),
5296 Nominated ? Nominated : *ToTargetOrErr,
5297 FromConstructorUsingShadow->constructsVirtualBase()))
5301 Name, *ToIntroducerOrErr, *ToTargetOrErr))
5312 ToShadow, *ToPatternOrErr);
5316 return ToPatternOrErr.takeError();
5330 return std::move(Err);
5334 auto ToComAncestorOrErr = Importer.
ImportContext(
D->getCommonAncestor());
5335 if (!ToComAncestorOrErr)
5336 return ToComAncestorOrErr.takeError();
5338 Error Err = Error::success();
5339 auto ToNominatedNamespace =
importChecked(Err,
D->getNominatedNamespace());
5341 auto ToNamespaceKeyLocation =
5344 auto ToIdentLocation =
importChecked(Err,
D->getIdentLocation());
5346 return std::move(Err);
5349 if (GetImportedOrCreateDecl(ToUsingDir,
D, Importer.
getToContext(), DC,
5351 ToNamespaceKeyLocation,
5354 ToNominatedNamespace, *ToComAncestorOrErr))
5369 return std::move(Err);
5373 auto ToInstantiatedFromUsingOrErr =
5374 Importer.
Import(
D->getInstantiatedFromUsingDecl());
5375 if (!ToInstantiatedFromUsingOrErr)
5376 return ToInstantiatedFromUsingOrErr.takeError();
5379 return std::move(Err);
5382 if (GetImportedOrCreateDecl(ToUsingPack,
D, Importer.
getToContext(), DC,
5383 cast<NamedDecl>(*ToInstantiatedFromUsingOrErr),
5387 addDeclToContexts(
D, ToUsingPack);
5399 return std::move(Err);
5403 Error Err = Error::success();
5409 return std::move(Err);
5413 return std::move(Err);
5416 if (GetImportedOrCreateDecl(ToUsingValue,
D, Importer.
getToContext(), DC,
5417 ToUsingLoc, ToQualifierLoc, NameInfo,
5419 return ToUsingValue;
5425 return ToUsingValue;
5435 return std::move(Err);
5439 Error Err = Error::success();
5445 return std::move(Err);
5448 if (GetImportedOrCreateDecl(ToUsing,
D, Importer.
getToContext(), DC,
5449 ToUsingLoc, ToTypenameLoc,
5450 ToQualifierLoc,
Loc, Name, ToEllipsisLoc))
5461 Decl* ToD =
nullptr;
5462 switch (
D->getBuiltinTemplateKind()) {
5473 assert(ToD &&
"BuiltinTemplateDecl of unsupported kind!");
5484 if (
auto FromSuperOrErr =
import(FromSuper))
5485 FromSuper = *FromSuperOrErr;
5487 return FromSuperOrErr.takeError();
5491 if ((
bool)FromSuper != (
bool)ToSuper ||
5494 diag::warn_odr_objc_superclass_inconsistent)
5501 diag::note_odr_objc_missing_superclass);
5504 diag::note_odr_objc_superclass)
5508 diag::note_odr_objc_missing_superclass);
5514 return Error::success();
5525 return SuperTInfoOrErr.takeError();
5536 FromProto != FromProtoEnd;
5537 ++FromProto, ++FromProtoLoc) {
5539 Protocols.push_back(*ToProtoOrErr);
5541 return ToProtoOrErr.takeError();
5543 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5544 ProtocolLocs.push_back(*ToProtoLocOrErr);
5546 return ToProtoLocOrErr.takeError();
5557 auto ToCatOrErr =
import(Cat);
5559 return ToCatOrErr.takeError();
5568 return ToImplOrErr.takeError();
5575 return Error::success();
5584 for (
auto *fromTypeParam : *list) {
5585 if (
auto toTypeParamOrErr =
import(fromTypeParam))
5586 toTypeParams.push_back(*toTypeParamOrErr);
5588 return toTypeParamOrErr.takeError();
5592 if (!LAngleLocOrErr)
5593 return LAngleLocOrErr.takeError();
5596 if (!RAngleLocOrErr)
5597 return RAngleLocOrErr.takeError();
5614 return ImportedDefOrErr.takeError();
5623 return std::move(Err);
5629 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5630 for (
auto *FoundDecl : FoundDecls) {
5634 if ((MergeWithIface = dyn_cast<ObjCInterfaceDecl>(FoundDecl)))
5642 if (!AtBeginLocOrErr)
5643 return AtBeginLocOrErr.takeError();
5645 if (GetImportedOrCreateDecl(
5647 *AtBeginLocOrErr, Name.getAsIdentifierInfo(),
5649 nullptr,
Loc,
D->isImplicitInterfaceDecl()))
5657 if (
auto ToPListOrErr =
5661 return ToPListOrErr.takeError();
5663 if (
D->isThisDeclarationADefinition())
5665 return std::move(Err);
5673 if (Error Err = importInto(
Category,
D->getCategoryDecl()))
5674 return std::move(Err);
5680 return std::move(Err);
5682 Error Err = Error::success();
5685 auto ToCategoryNameLoc =
importChecked(Err,
D->getCategoryNameLoc());
5687 return std::move(Err);
5689 if (GetImportedOrCreateDecl(
5692 ToLocation, ToAtStartLoc, ToCategoryNameLoc))
5697 Category->setImplementation(ToImpl);
5702 return std::move(Err);
5711 if (Error Err = importInto(Iface,
D->getClassInterface()))
5712 return std::move(Err);
5716 if (Error Err = importInto(Super,
D->getSuperClass()))
5717 return std::move(Err);
5725 return std::move(Err);
5727 Error Err = Error::success();
5730 auto ToSuperClassLoc =
importChecked(Err,
D->getSuperClassLoc());
5731 auto ToIvarLBraceLoc =
importChecked(Err,
D->getIvarLBraceLoc());
5732 auto ToIvarRBraceLoc =
importChecked(Err,
D->getIvarRBraceLoc());
5734 return std::move(Err);
5736 if (GetImportedOrCreateDecl(Impl,
D, Importer.
getToContext(),
5760 diag::warn_odr_objc_superclass_inconsistent)
5766 diag::note_odr_objc_superclass)
5770 diag::note_odr_objc_missing_superclass);
5771 if (
D->getSuperClass())
5773 diag::note_odr_objc_superclass)
5774 <<
D->getSuperClass()->getDeclName();
5777 diag::note_odr_objc_missing_superclass);
5785 return std::move(Err);
5797 return std::move(Err);
5802 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5803 for (
auto *FoundDecl : FoundDecls) {
5804 if (
auto *FoundProp = dyn_cast<ObjCPropertyDecl>(FoundDecl)) {
5807 if (FoundProp->isInstanceProperty() !=
D->isInstanceProperty())
5812 FoundProp->getType())) {
5813 Importer.
ToDiag(
Loc, diag::warn_odr_objc_property_type_inconsistent)
5814 << Name <<
D->getType() << FoundProp->getType();
5815 Importer.
ToDiag(FoundProp->getLocation(), diag::note_odr_value_here)
5816 << FoundProp->getType();
5829 Error Err = Error::success();
5831 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
5835 return std::move(Err);
5839 if (GetImportedOrCreateDecl(
5841 Name.getAsIdentifierInfo(), ToAtLoc,
5842 ToLParenLoc, ToType,
5843 ToTypeSourceInfo,
D->getPropertyImplementation()))
5848 auto ToGetterNameLoc =
importChecked(Err,
D->getGetterNameLoc());
5849 auto ToSetterNameLoc =
importChecked(Err,
D->getSetterNameLoc());
5850 auto ToGetterMethodDecl =
importChecked(Err,
D->getGetterMethodDecl());
5851 auto ToSetterMethodDecl =
importChecked(Err,
D->getSetterMethodDecl());
5852 auto ToPropertyIvarDecl =
importChecked(Err,
D->getPropertyIvarDecl());
5854 return std::move(Err);
5861 D->getPropertyAttributesAsWritten());
5873 if (Error Err = importInto(
Property,
D->getPropertyDecl()))
5874 return std::move(Err);
5878 return std::move(Err);
5880 auto *InImpl = cast<ObjCImplDecl>(LexicalDC);
5884 if (Error Err = importInto(Ivar,
D->getPropertyIvarDecl()))
5885 return std::move(Err);
5888 = InImpl->FindPropertyImplDecl(
Property->getIdentifier(),
5892 Error Err = Error::success();
5895 auto ToPropertyIvarDeclLoc =
5898 return std::move(Err);
5900 if (GetImportedOrCreateDecl(ToImpl,
D, Importer.
getToContext(), DC,
5903 D->getPropertyImplementation(), Ivar,
5904 ToPropertyIvarDeclLoc))
5914 diag::warn_odr_objc_property_impl_kind_inconsistent)
5919 diag::note_odr_objc_property_impl_kind)
5920 <<
D->getPropertyDecl()->getDeclName()
5930 diag::warn_odr_objc_synthesize_ivar_inconsistent)
5934 Importer.
FromDiag(
D->getPropertyIvarDeclLoc(),
5935 diag::note_odr_objc_synthesize_ivar_here)
5936 <<
D->getPropertyIvarDecl()->getDeclName();
5956 return BeginLocOrErr.takeError();
5960 return LocationOrErr.takeError();
5963 if (GetImportedOrCreateDecl(
5966 *BeginLocOrErr, *LocationOrErr,
5967 D->getDepth(),
D->getIndex(), Importer.
Import(
D->getIdentifier()),
5969 D->hasTypeConstraint()))
5975 Error Err = Error::success();
5976 auto ToConceptRef =
importChecked(Err, TC->getConceptReference());
5977 auto ToIDC =
importChecked(Err, TC->getImmediatelyDeclaredConstraint());
5979 return std::move(Err);
5984 if (Error Err = importTemplateParameterDefaultArgument(
D, ToD))
5993 Error Err = Error::success();
5997 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
5998 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
6000 return std::move(Err);
6003 if (GetImportedOrCreateDecl(ToD,
D, Importer.
getToContext(),
6005 ToInnerLocStart, ToLocation,
D->getDepth(),
6007 ToDeclName.getAsIdentifierInfo(), ToType,
6011 Err = importTemplateParameterDefaultArgument(
D, ToD);
6021 auto NameOrErr =
import(
D->getDeclName());
6023 return NameOrErr.takeError();
6028 return LocationOrErr.takeError();
6031 auto TemplateParamsOrErr =
import(
D->getTemplateParameters());
6032 if (!TemplateParamsOrErr)
6033 return TemplateParamsOrErr.takeError();
6036 if (GetImportedOrCreateDecl(
6040 (*NameOrErr).getAsIdentifierInfo(),
D->wasDeclaredWithTypename(),
6041 *TemplateParamsOrErr))
6044 if (Error Err = importTemplateParameterDefaultArgument(
D, ToD))
6053 assert(
D->getTemplatedDecl() &&
"Should be called on templates only");
6054 auto *ToTemplatedDef =
D->getTemplatedDecl()->getDefinition();
6055 if (!ToTemplatedDef)
6058 return cast_or_null<T>(TemplateWithDef);
6069 return std::move(Err);
6083 bool DependentFriend = IsDependentFriend(
D);
6090 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6091 for (
auto *FoundDecl : FoundDecls) {
6096 auto *FoundTemplate = dyn_cast<ClassTemplateDecl>(FoundDecl);
6097 if (FoundTemplate) {
6102 bool IgnoreTemplateParmDepth =
6106 IgnoreTemplateParmDepth)) {
6107 if (DependentFriend || IsDependentFriend(FoundTemplate))
6112 if (
D->isThisDeclarationADefinition() && TemplateWithDef)
6115 FoundByLookup = FoundTemplate;
6133 ConflictingDecls.push_back(FoundDecl);
6137 if (!ConflictingDecls.empty()) {
6140 ConflictingDecls.size());
6142 Name = NameOrErr.get();
6144 return NameOrErr.takeError();
6150 auto TemplateParamsOrErr =
import(
D->getTemplateParameters());
6151 if (!TemplateParamsOrErr)
6152 return TemplateParamsOrErr.takeError();
6156 if (Error Err = importInto(ToTemplated, FromTemplated))
6157 return std::move(Err);
6162 *TemplateParamsOrErr, ToTemplated))
6170 addDeclToContexts(
D, D2);
6171 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6173 if (FoundByLookup) {
6187 "Found decl must have its templated decl set");
6190 if (ToTemplated != PrevTemplated)
6203 if (Error Err = importInto(ClassTemplate,
D->getSpecializedTemplate()))
6204 return std::move(Err);
6209 return std::move(Err);
6215 return std::move(Err);
6218 void *InsertPos =
nullptr;
6221 dyn_cast<ClassTemplatePartialSpecializationDecl>(
D);
6229 return ToTPListOrErr.takeError();
6230 ToTPList = *ToTPListOrErr;
6240 if (
D->isThisDeclarationADefinition() && PrevDefinition) {
6244 for (
auto *FromField :
D->fields()) {
6245 auto ToOrErr =
import(FromField);
6247 return ToOrErr.takeError();
6253 auto ToOrErr =
import(FromM);
6255 return ToOrErr.takeError();
6263 return PrevDefinition;
6274 return BeginLocOrErr.takeError();
6277 return IdLocOrErr.takeError();
6281 if (
const auto *ASTTemplateArgs =
D->getTemplateArgsAsWritten()) {
6283 return std::move(Err);
6290 if (Error Err = importInto(
6292 return std::move(Err);
6295 if (GetImportedOrCreateDecl<ClassTemplatePartialSpecializationDecl>(
6296 D2,
D, Importer.
getToContext(),
D->getTagKind(), DC, *BeginLocOrErr,
6297 *IdLocOrErr, ToTPList, ClassTemplate,
6300 cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl)))
6305 auto *PartSpec2 = cast<ClassTemplatePartialSpecializationDecl>(D2);
6312 PartSpec2->setInstantiatedFromMember(*ToInstOrErr);
6314 return ToInstOrErr.takeError();
6316 updateLookupTableForTemplateParameters(*ToTPList);
6318 if (GetImportedOrCreateDecl(
6320 *BeginLocOrErr, *IdLocOrErr, ClassTemplate, TemplateArgs,
6341 if (
auto BraceRangeOrErr =
import(
D->getBraceRange()))
6344 return BraceRangeOrErr.takeError();
6347 return std::move(Err);
6350 if (
auto LocOrErr =
import(
D->getQualifierLoc()))
6353 return LocOrErr.takeError();
6355 if (
D->getTemplateArgsAsWritten())
6358 if (
auto LocOrErr =
import(
D->getTemplateKeywordLoc()))
6361 return LocOrErr.takeError();
6363 if (
auto LocOrErr =
import(
D->getExternKeywordLoc()))
6366 return LocOrErr.takeError();
6368 if (
D->getPointOfInstantiation().isValid()) {
6369 if (
auto POIOrErr =
import(
D->getPointOfInstantiation()))
6372 return POIOrErr.takeError();
6377 if (
auto P =
D->getInstantiatedFrom()) {
6379 if (
auto CTDorErr =
import(CTD))
6382 auto *CTPSD = cast<ClassTemplatePartialSpecializationDecl *>(
P);
6383 auto CTPSDOrErr =
import(CTPSD);
6385 return CTPSDOrErr.takeError();
6388 for (
unsigned I = 0; I < DArgs.
size(); ++I) {
6390 if (
auto ArgOrErr =
import(DArg))
6391 D2ArgsVec[I] = *ArgOrErr;
6393 return ArgOrErr.takeError();
6401 if (
D->isCompleteDefinition())
6403 return std::move(Err);
6415 return std::move(Err);
6421 "Variable templates cannot be declared at function scope");
6424 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6426 for (
auto *FoundDecl : FoundDecls) {
6430 if (
VarTemplateDecl *FoundTemplate = dyn_cast<VarTemplateDecl>(FoundDecl)) {
6433 D->getTemplatedDecl()))
6440 assert(FoundTemplate->getDeclContext()->isRecord() &&
6441 "Member variable template imported as non-member, "
6442 "inconsistent imported AST?");
6445 if (!
D->isThisDeclarationADefinition())
6448 if (FoundDef &&
D->isThisDeclarationADefinition())
6451 FoundByLookup = FoundTemplate;
6454 ConflictingDecls.push_back(FoundDecl);
6458 if (!ConflictingDecls.empty()) {
6461 ConflictingDecls.size());
6463 Name = NameOrErr.get();
6465 return NameOrErr.takeError();
6468 VarDecl *DTemplated =
D->getTemplatedDecl();
6474 return TypeOrErr.takeError();
6478 if (Error Err = importInto(ToTemplated, DTemplated))
6479 return std::move(Err);
6482 auto TemplateParamsOrErr =
import(
D->getTemplateParameters());
6483 if (!TemplateParamsOrErr)
6484 return TemplateParamsOrErr.takeError();
6488 Name, *TemplateParamsOrErr, ToTemplated))
6497 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6499 if (FoundByLookup) {
6503 auto *PrevTemplated =
6505 if (ToTemplated != PrevTemplated)
6520 auto RedeclIt = Redecls.begin();
6523 for (; RedeclIt != Redecls.end() && *RedeclIt !=
D; ++RedeclIt) {
6526 return RedeclOrErr.takeError();
6528 assert(*RedeclIt ==
D);
6531 if (Error Err = importInto(VarTemplate,
D->getSpecializedTemplate()))
6532 return std::move(Err);
6537 return std::move(Err);
6542 return BeginLocOrErr.takeError();
6546 return IdLocOrErr.takeError();
6552 return std::move(Err);
6555 void *InsertPos =
nullptr;
6558 if (FoundSpecialization) {
6566 "Member variable template specialization imported as non-member, "
6567 "inconsistent imported AST?");
6570 if (!
D->isThisDeclarationADefinition())
6575 if (FoundDef &&
D->isThisDeclarationADefinition())
6586 if (
const auto *Args =
D->getTemplateArgsAsWritten()) {
6588 return std::move(Err);
6593 if (
auto *FromPartial = dyn_cast<PartVarSpecDecl>(
D)) {
6594 auto ToTPListOrErr =
import(FromPartial->getTemplateParameters());
6596 return ToTPListOrErr.takeError();
6598 PartVarSpecDecl *ToPartial;
6599 if (GetImportedOrCreateDecl(ToPartial,
D, Importer.
getToContext(), DC,
6600 *BeginLocOrErr, *IdLocOrErr, *ToTPListOrErr,
6602 D->getStorageClass(), TemplateArgs))
6606 import(FromPartial->getInstantiatedFromMember()))
6609 return ToInstOrErr.takeError();
6611 if (FromPartial->isMemberSpecialization())
6612 ToPartial->setMemberSpecialization();
6620 if (GetImportedOrCreateDecl(D2,
D, Importer.
getToContext(), DC,
6621 *BeginLocOrErr, *IdLocOrErr, VarTemplate,
6622 QualType(),
nullptr,
D->getStorageClass(),
6633 if (Error Err = importInto(
T,
D->getType()))
6634 return std::move(Err);
6637 auto TInfoOrErr =
import(
D->getTypeSourceInfo());
6639 return TInfoOrErr.takeError();
6642 if (
D->getPointOfInstantiation().isValid()) {
6643 if (
ExpectedSLoc POIOrErr =
import(
D->getPointOfInstantiation()))
6646 return POIOrErr.takeError();
6651 if (
D->getTemplateArgsAsWritten())
6654 if (
auto LocOrErr =
import(
D->getQualifierLoc()))
6657 return LocOrErr.takeError();
6659 if (
D->isConstexpr())
6665 return std::move(Err);
6667 if (FoundSpecialization)
6670 addDeclToContexts(
D, D2);
6673 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
6676 return RedeclOrErr.takeError();
6690 return std::move(Err);
6702 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6703 for (
auto *FoundDecl : FoundDecls) {
6707 if (
auto *FoundTemplate = dyn_cast<FunctionTemplateDecl>(FoundDecl)) {
6713 if (
D->isThisDeclarationADefinition() && TemplateWithDef)
6716 FoundByLookup = FoundTemplate;
6724 auto ParamsOrErr =
import(
D->getTemplateParameters());
6726 return ParamsOrErr.takeError();
6730 if (Error Err = importInto(TemplatedFD,
D->getTemplatedDecl()))
6731 return std::move(Err);
6748 OldParamDC.reserve(Params->
size());
6749 llvm::transform(*Params, std::back_inserter(OldParamDC),
6753 if (GetImportedOrCreateDecl(ToFunc,
D, Importer.
getToContext(), DC,
Loc, Name,
6754 Params, TemplatedFD))
6760 ToFunc->setLexicalDeclContext(LexicalDC);
6761 addDeclToContexts(
D, ToFunc);
6764 if (
LT && !OldParamDC.empty()) {
6765 for (
unsigned int I = 0; I < OldParamDC.size(); ++I)
6769 if (FoundByLookup) {
6774 "Found decl must have its templated decl set");
6775 auto *PrevTemplated =
6777 if (TemplatedFD != PrevTemplated)
6780 ToFunc->setPreviousDecl(Recent);
6791 Importer.
FromDiag(S->getBeginLoc(), diag::err_unsupported_ast_node)
6792 << S->getStmtClassName();
6801 for (
unsigned I = 0,
E = S->getNumOutputs(); I !=
E; I++) {
6805 Names.push_back(ToII);
6808 for (
unsigned I = 0,
E = S->getNumInputs(); I !=
E; I++) {
6812 Names.push_back(ToII);
6816 for (
unsigned I = 0,
E = S->getNumClobbers(); I !=
E; I++) {
6817 if (
auto ClobberOrErr =
import(S->getClobberStringLiteral(I)))
6818 Clobbers.push_back(*ClobberOrErr);
6820 return ClobberOrErr.takeError();
6825 for (
unsigned I = 0,
E = S->getNumOutputs(); I !=
E; I++) {
6826 if (
auto OutputOrErr =
import(S->getOutputConstraintLiteral(I)))
6827 Constraints.push_back(*OutputOrErr);
6829 return OutputOrErr.takeError();
6832 for (
unsigned I = 0,
E = S->getNumInputs(); I !=
E; I++) {
6833 if (
auto InputOrErr =
import(S->getInputConstraintLiteral(I)))
6834 Constraints.push_back(*InputOrErr);
6836 return InputOrErr.takeError();
6842 return std::move(Err);
6846 return std::move(Err);
6849 S->labels(), Exprs.begin() + S->getNumOutputs() + S->getNumInputs()))
6850 return std::move(Err);
6854 return AsmLocOrErr.takeError();
6855 auto AsmStrOrErr =
import(S->getAsmString());
6857 return AsmStrOrErr.takeError();
6858 ExpectedSLoc RParenLocOrErr =
import(S->getRParenLoc());
6859 if (!RParenLocOrErr)
6860 return RParenLocOrErr.takeError();
6873 S->getNumClobbers(),
6881 Error Err = Error::success();
6886 return std::move(Err);
6892 if (!ToSemiLocOrErr)
6893 return ToSemiLocOrErr.takeError();
6895 *ToSemiLocOrErr, S->hasLeadingEmptyMacro());
6902 return std::move(Err);
6904 ExpectedSLoc ToLBracLocOrErr =
import(S->getLBracLoc());
6905 if (!ToLBracLocOrErr)
6906 return ToLBracLocOrErr.takeError();
6908 ExpectedSLoc ToRBracLocOrErr =
import(S->getRBracLoc());
6909 if (!ToRBracLocOrErr)
6910 return ToRBracLocOrErr.takeError();
6915 *ToLBracLocOrErr, *ToRBracLocOrErr);
6920 Error Err = Error::success();
6925 auto ToEllipsisLoc =
importChecked(Err, S->getEllipsisLoc());
6928 return std::move(Err);
6931 ToCaseLoc, ToEllipsisLoc, ToColonLoc);
6932 ToStmt->setSubStmt(ToSubStmt);
6939 Error Err = Error::success();
6944 return std::move(Err);
6947 ToDefaultLoc, ToColonLoc, ToSubStmt);
6952 Error Err = Error::success();
6957 return std::move(Err);
6960 ToIdentLoc, ToLabelDecl, ToSubStmt);
6965 if (!ToAttrLocOrErr)
6966 return ToAttrLocOrErr.takeError();
6970 return std::move(Err);
6972 if (!ToSubStmtOrErr)
6973 return ToSubStmtOrErr.takeError();
6976 Importer.
getToContext(), *ToAttrLocOrErr, ToAttrs, *ToSubStmtOrErr);
6981 Error Err = Error::success();
6984 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
6992 return std::move(Err);
6995 ToInit, ToConditionVariable, ToCond, ToLParenLoc,
6996 ToRParenLoc, ToThen, ToElseLoc, ToElse);
7001 Error Err = Error::success();
7003 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
7010 return std::move(Err);
7014 ToCond, ToLParenLoc, ToRParenLoc);
7015 ToStmt->setBody(ToBody);
7016 ToStmt->setSwitchLoc(ToSwitchLoc);
7020 for (
SwitchCase *SC = S->getSwitchCaseList(); SC !=
nullptr;
7021 SC = SC->getNextSwitchCase()) {
7024 return ToSCOrErr.takeError();
7025 if (LastChainedSwitchCase)
7028 ToStmt->setSwitchCaseList(*ToSCOrErr);
7029 LastChainedSwitchCase = *ToSCOrErr;
7037 Error Err = Error::success();
7038 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
7045 return std::move(Err);
7048 ToBody, ToWhileLoc, ToLParenLoc, ToRParenLoc);
7053 Error Err = Error::success();
7060 return std::move(Err);
7063 ToBody, ToCond, ToDoLoc, ToWhileLoc, ToRParenLoc);
7068 Error Err = Error::success();
7071 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
7078 return std::move(Err);
7082 ToInit, ToCond, ToConditionVariable, ToInc, ToBody, ToForLoc, ToLParenLoc,
7088 Error Err = Error::success();
7093 return std::move(Err);
7096 ToLabel, ToGotoLoc, ToLabelLoc);
7101 Error Err = Error::success();
7106 return std::move(Err);
7109 ToGotoLoc, ToStarLoc, ToTarget);
7113 ExpectedSLoc ToContinueLocOrErr =
import(S->getContinueLoc());
7114 if (!ToContinueLocOrErr)
7115 return ToContinueLocOrErr.takeError();
7120 auto ToBreakLocOrErr =
import(S->getBreakLoc());
7121 if (!ToBreakLocOrErr)
7122 return ToBreakLocOrErr.takeError();
7128 Error Err = Error::success();
7131 auto ToNRVOCandidate =
importChecked(Err, S->getNRVOCandidate());
7133 return std::move(Err);
7141 Error Err = Error::success();
7143 auto ToExceptionDecl =
importChecked(Err, S->getExceptionDecl());
7144 auto ToHandlerBlock =
importChecked(Err, S->getHandlerBlock());
7146 return std::move(Err);
7149 ToCatchLoc, ToExceptionDecl, ToHandlerBlock);
7155 return ToTryLocOrErr.takeError();
7157 ExpectedStmt ToTryBlockOrErr =
import(S->getTryBlock());
7158 if (!ToTryBlockOrErr)
7159 return ToTryBlockOrErr.takeError();
7162 for (
unsigned HI = 0, HE = S->getNumHandlers(); HI != HE; ++HI) {
7164 if (
auto ToHandlerOrErr =
import(FromHandler))
7165 ToHandlers[HI] = *ToHandlerOrErr;
7167 return ToHandlerOrErr.takeError();
7171 cast<CompoundStmt>(*ToTryBlockOrErr), ToHandlers);
7176 Error Err = Error::success();
7183 auto ToLoopVarStmt =
importChecked(Err, S->getLoopVarStmt());
7190 return std::move(Err);
7193 ToInit, ToRangeStmt, ToBeginStmt, ToEndStmt, ToCond, ToInc, ToLoopVarStmt,
7194 ToBody, ToForLoc, ToCoawaitLoc, ToColonLoc, ToRParenLoc);
7199 Error Err = Error::success();
7206 return std::move(Err);
7217 Error Err = Error::success();
7220 auto ToCatchParamDecl =
importChecked(Err, S->getCatchParamDecl());
7223 return std::move(Err);
7226 ToAtCatchLoc, ToRParenLoc, ToCatchParamDecl, ToCatchBody);
7230 ExpectedSLoc ToAtFinallyLocOrErr =
import(S->getAtFinallyLoc());
7231 if (!ToAtFinallyLocOrErr)
7232 return ToAtFinallyLocOrErr.takeError();
7233 ExpectedStmt ToAtFinallyStmtOrErr =
import(S->getFinallyBody());
7234 if (!ToAtFinallyStmtOrErr)
7235 return ToAtFinallyStmtOrErr.takeError();
7237 *ToAtFinallyStmtOrErr);
7242 Error Err = Error::success();
7245 auto ToFinallyStmt =
importChecked(Err, S->getFinallyStmt());
7247 return std::move(Err);
7250 for (
unsigned CI = 0, CE = S->getNumCatchStmts(); CI != CE; ++CI) {
7252 if (
ExpectedStmt ToCatchStmtOrErr =
import(FromCatchStmt))
7253 ToCatchStmts[CI] = *ToCatchStmtOrErr;
7255 return ToCatchStmtOrErr.takeError();
7259 ToAtTryLoc, ToTryBody,
7260 ToCatchStmts.begin(), ToCatchStmts.size(),
7267 Error Err = Error::success();
7268 auto ToAtSynchronizedLoc =
importChecked(Err, S->getAtSynchronizedLoc());
7272 return std::move(Err);
7275 ToAtSynchronizedLoc, ToSynchExpr, ToSynchBody);
7279 ExpectedSLoc ToThrowLocOrErr =
import(S->getThrowLoc());
7280 if (!ToThrowLocOrErr)
7281 return ToThrowLocOrErr.takeError();
7282 ExpectedExpr ToThrowExprOrErr =
import(S->getThrowExpr());
7283 if (!ToThrowExprOrErr)
7284 return ToThrowExprOrErr.takeError();
7286 *ToThrowLocOrErr, *ToThrowExprOrErr);
7293 return ToAtLocOrErr.takeError();
7295 if (!ToSubStmtOrErr)
7296 return ToSubStmtOrErr.takeError();
7311 Error Err = Error::success();
7316 return std::move(Err);
7317 auto ParentContextOrErr = Importer.
ImportContext(
E->getParentContext());
7318 if (!ParentContextOrErr)
7319 return ParentContextOrErr.takeError();
7323 RParenLoc, *ParentContextOrErr);
7328 Error Err = Error::success();
7331 auto ToWrittenTypeInfo =
importChecked(Err,
E->getWrittenTypeInfo());
7335 return std::move(Err);
7338 ToBuiltinLoc, ToSubExpr, ToWrittenTypeInfo, ToRParenLoc, ToType,
7339 E->isMicrosoftABI());
7344 Error Err = Error::success();
7352 return std::move(Err);
7359 bool CondIsTrue = !
E->isConditionDependent() &&
E->isConditionTrue();
7362 ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType, VK, OK,
7363 ToRParenLoc, CondIsTrue);
7367 Error Err = Error::success();
7374 return std::move(Err);
7382 Error Err = Error::success();
7386 const unsigned NumSubExprs =
E->getNumSubExprs();
7390 ToSubExprs.resize(NumSubExprs);
7393 return std::move(Err);
7396 Importer.
getToContext(), ToSubExprs, ToType, ToBeginLoc, ToRParenLoc);
7402 return TypeOrErr.takeError();
7406 return BeginLocOrErr.takeError();
7413 Error Err = Error::success();
7415 Expr *ToControllingExpr =
nullptr;
7417 if (
E->isExprPredicate())
7421 assert((ToControllingExpr || ToControllingType) &&
7422 "Either the controlling expr or type must be nonnull");
7426 return std::move(Err);
7431 return std::move(Err);
7436 return std::move(Err);
7439 if (
E->isResultDependent()) {
7440 if (ToControllingExpr) {
7442 ToCtx, ToGenericLoc, ToControllingExpr,
llvm::ArrayRef(ToAssocTypes),
7447 ToCtx, ToGenericLoc, ToControllingType,
llvm::ArrayRef(ToAssocTypes),
7452 if (ToControllingExpr) {
7454 ToCtx, ToGenericLoc, ToControllingExpr,
llvm::ArrayRef(ToAssocTypes),
7459 ToCtx, ToGenericLoc, ToControllingType,
llvm::ArrayRef(ToAssocTypes),
7466 Error Err = Error::success();
7471 return std::move(Err);
7474 E->getIdentKind(),
E->isTransparent(),
7480 Error Err = Error::success();
7482 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
7487 return std::move(Err);
7490 if (
E->getDecl() !=
E->getFoundDecl()) {
7491 auto FoundDOrErr =
import(
E->getFoundDecl());
7493 return FoundDOrErr.takeError();
7494 ToFoundD = *FoundDOrErr;
7499 if (
E->hasExplicitTemplateArgs()) {
7502 E->template_arguments(), ToTAInfo))
7503 return std::move(Err);
7504 ToResInfo = &ToTAInfo;
7508 Importer.
getToContext(), ToQualifierLoc, ToTemplateKeywordLoc, ToDecl,
7509 E->refersToEnclosingVariableOrCapture(), ToLocation, ToType,
7511 if (
E->hadMultipleCandidates())
7512 ToE->setHadMultipleCandidates(
true);
7513 ToE->setIsImmediateEscalating(
E->isImmediateEscalating());
7520 return TypeOrErr.takeError();
7528 return ToInitOrErr.takeError();
7530 ExpectedSLoc ToEqualOrColonLocOrErr =
import(
E->getEqualOrColonLoc());
7531 if (!ToEqualOrColonLocOrErr)
7532 return ToEqualOrColonLocOrErr.takeError();
7536 for (
unsigned I = 1, N =
E->getNumSubExprs(); I < N; I++) {
7538 ToIndexExprs[I - 1] = *ToArgOrErr;
7540 return ToArgOrErr.takeError();
7545 return std::move(Err);
7549 ToIndexExprs, *ToEqualOrColonLocOrErr,
7550 E->usesGNUSyntax(), *ToInitOrErr);
7557 return ToTypeOrErr.takeError();
7560 if (!ToLocationOrErr)
7561 return ToLocationOrErr.takeError();
7564 *ToTypeOrErr, *ToLocationOrErr);
7570 return ToTypeOrErr.takeError();
7573 if (!ToLocationOrErr)
7574 return ToLocationOrErr.takeError();
7577 Importer.
getToContext(),
E->getValue(), *ToTypeOrErr, *ToLocationOrErr);
7584 return ToTypeOrErr.takeError();
7587 if (!ToLocationOrErr)
7588 return ToLocationOrErr.takeError();
7592 *ToTypeOrErr, *ToLocationOrErr);
7596 auto ToTypeOrErr =
import(
E->
getType());
7598 return ToTypeOrErr.takeError();
7601 if (!ToSubExprOrErr)
7602 return ToSubExprOrErr.takeError();
7605 *ToSubExprOrErr, *ToTypeOrErr);
7609 auto ToTypeOrErr =
import(
E->
getType());
7611 return ToTypeOrErr.takeError();
7614 if (!ToLocationOrErr)
7615 return ToLocationOrErr.takeError();
7618 Importer.
getToContext(),
E->getValue(), *ToTypeOrErr, *ToLocationOrErr,
7625 return ToTypeOrErr.takeError();
7628 if (!ToLocationOrErr)
7629 return ToLocationOrErr.takeError();
7632 E->getValue(),
E->getKind(), *ToTypeOrErr, *ToLocationOrErr);
7638 return ToTypeOrErr.takeError();
7642 E->tokloc_begin(),
E->tokloc_end(), ToLocations.begin()))
7643 return std::move(Err);
7647 *ToTypeOrErr, ToLocations.data(), ToLocations.size());
7652 Error Err = Error::success();
7654 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
7658 return std::move(Err);
7662 ToInitializer,
E->isFileScope());
7667 Error Err = Error::success();
7672 return std::move(Err);
7676 E->getSubExprs(),
E->getSubExprs() +
E->getNumSubExprs(),
7678 return std::move(Err);
7682 ToBuiltinLoc, ToExprs, ToType,
E->getOp(), ToRParenLoc);
7686 Error Err = Error::success();
7692 return std::move(Err);
7695 ToAmpAmpLoc, ToLabelLoc, ToLabel, ToType);
7698 Error Err = Error::success();
7702 return std::move(Err);
7707 Error Err = Error::success();
7712 return std::move(Err);
7715 ParenExpr(ToLParen, ToRParen, ToSubExpr);
7721 return std::move(Err);
7724 if (!ToLParenLocOrErr)
7725 return ToLParenLocOrErr.takeError();
7728 if (!ToRParenLocOrErr)
7729 return ToRParenLocOrErr.takeError();
7732 ToExprs, *ToRParenLocOrErr);
7736 Error Err = Error::success();
7742 return std::move(Err);
7745 StmtExpr(ToSubStmt, ToType, ToLParenLoc, ToRParenLoc,
7746 E->getTemplateDepth());
7750 Error Err = Error::success();
7755 return std::move(Err);
7758 E->hasStoredFPFeatures());
7759 UO->setType(ToType);
7760 UO->setSubExpr(ToSubExpr);
7761 UO->setOpcode(
E->getOpcode());
7762 UO->setOperatorLoc(ToOperatorLoc);
7763 UO->setCanOverflow(
E->canOverflow());
7764 if (
E->hasStoredFPFeatures())
7765 UO->setStoredFPFeatures(
E->getStoredFPFeatures());
7773 Error Err = Error::success();
7778 return std::move(Err);
7780 if (
E->isArgumentType()) {
7782 import(
E->getArgumentTypeInfo());
7783 if (!ToArgumentTypeInfoOrErr)
7784 return ToArgumentTypeInfoOrErr.takeError();
7787 E->getKind(), *ToArgumentTypeInfoOrErr, ToType, ToOperatorLoc,
7791 ExpectedExpr ToArgumentExprOrErr =
import(
E->getArgumentExpr());
7792 if (!ToArgumentExprOrErr)
7793 return ToArgumentExprOrErr.takeError();
7796 E->getKind(), *ToArgumentExprOrErr, ToType, ToOperatorLoc, ToRParenLoc);
7800 Error Err = Error::success();
7806 return std::move(Err);
7809 Importer.
getToContext(), ToLHS, ToRHS,
E->getOpcode(), ToType,
7811 E->getFPFeatures());
7815 Error Err = Error::success();
7823 return std::move(Err);
7826 ToCond, ToQuestionLoc, ToLHS, ToColonLoc, ToRHS, ToType,
7832 Error Err = Error::success();
7842 return std::move(Err);
7845 ToCommon, ToOpaqueValue, ToCond, ToTrueExpr, ToFalseExpr,
7852 Error Err = Error::success();
7855 return std::move(Err);
7862 Error Err = Error::success();
7864 auto ToQueriedTypeSourceInfo =
7866 auto ToDimensionExpression =
importChecked(Err,
E->getDimensionExpression());
7870 return std::move(Err);
7873 ToBeginLoc,
E->getTrait(), ToQueriedTypeSourceInfo,
E->getValue(),
7874 ToDimensionExpression, ToEndLoc, ToType);
7878 Error Err = Error::success();
7880 auto ToQueriedExpression =
importChecked(Err,
E->getQueriedExpression());
7884 return std::move(Err);
7887 ToBeginLoc,
E->getTrait(), ToQueriedExpression,
E->getValue(),
7892 Error Err = Error::success();
7897 return std::move(Err);
7904 Error Err = Error::success();
7910 return std::move(Err);
7919 Error Err = Error::success();
7923 auto ToComputationLHSType =
importChecked(Err,
E->getComputationLHSType());
7924 auto ToComputationResultType =
7928 return std::move(Err);
7931 Importer.
getToContext(), ToLHS, ToRHS,
E->getOpcode(), ToType,
7934 ToComputationLHSType, ToComputationResultType);
7941 if (
auto SpecOrErr =
import(*I))
7942 Path.push_back(*SpecOrErr);
7944 return SpecOrErr.takeError();
7952 return ToTypeOrErr.takeError();
7955 if (!ToSubExprOrErr)
7956 return ToSubExprOrErr.takeError();
7959 if (!ToBasePathOrErr)
7960 return ToBasePathOrErr.takeError();
7963 Importer.
getToContext(), *ToTypeOrErr,
E->getCastKind(), *ToSubExprOrErr,
7968 Error Err = Error::success();
7971 auto ToTypeInfoAsWritten =
importChecked(Err,
E->getTypeInfoAsWritten());
7973 return std::move(Err);
7976 if (!ToBasePathOrErr)
7977 return ToBasePathOrErr.takeError();
7981 case Stmt::CStyleCastExprClass: {
7982 auto *CCE = cast<CStyleCastExpr>(
E);
7983 ExpectedSLoc ToLParenLocOrErr =
import(CCE->getLParenLoc());
7984 if (!ToLParenLocOrErr)
7985 return ToLParenLocOrErr.takeError();
7986 ExpectedSLoc ToRParenLocOrErr =
import(CCE->getRParenLoc());
7987 if (!ToRParenLocOrErr)
7988 return ToRParenLocOrErr.takeError();
7991 ToSubExpr, ToBasePath, CCE->getFPFeatures(), ToTypeInfoAsWritten,
7992 *ToLParenLocOrErr, *ToRParenLocOrErr);
7995 case Stmt::CXXFunctionalCastExprClass: {
7996 auto *FCE = cast<CXXFunctionalCastExpr>(
E);
7997 ExpectedSLoc ToLParenLocOrErr =
import(FCE->getLParenLoc());
7998 if (!ToLParenLocOrErr)
7999 return ToLParenLocOrErr.takeError();
8000 ExpectedSLoc ToRParenLocOrErr =
import(FCE->getRParenLoc());
8001 if (!ToRParenLocOrErr)
8002 return ToRParenLocOrErr.takeError();
8005 E->getCastKind(), ToSubExpr, ToBasePath, FCE->getFPFeatures(),
8006 *ToLParenLocOrErr, *ToRParenLocOrErr);
8009 case Stmt::ObjCBridgedCastExprClass: {
8010 auto *OCE = cast<ObjCBridgedCastExpr>(
E);
8011 ExpectedSLoc ToLParenLocOrErr =
import(OCE->getLParenLoc());
8012 if (!ToLParenLocOrErr)
8013 return ToLParenLocOrErr.takeError();
8014 ExpectedSLoc ToBridgeKeywordLocOrErr =
import(OCE->getBridgeKeywordLoc());
8015 if (!ToBridgeKeywordLocOrErr)
8016 return ToBridgeKeywordLocOrErr.takeError();
8018 *ToLParenLocOrErr, OCE->getBridgeKind(),
E->getCastKind(),
8019 *ToBridgeKeywordLocOrErr, ToTypeInfoAsWritten, ToSubExpr);
8021 case Stmt::BuiltinBitCastExprClass: {
8022 auto *BBC = cast<BuiltinBitCastExpr>(
E);
8023 ExpectedSLoc ToKWLocOrErr =
import(BBC->getBeginLoc());
8025 return ToKWLocOrErr.takeError();
8026 ExpectedSLoc ToRParenLocOrErr =
import(BBC->getEndLoc());
8027 if (!ToRParenLocOrErr)
8028 return ToRParenLocOrErr.takeError();
8031 ToTypeInfoAsWritten, *ToKWLocOrErr, *ToRParenLocOrErr);
8034 llvm_unreachable(
"Cast expression of unsupported type!");
8041 for (
int I = 0, N =
E->getNumComponents(); I < N; ++I) {
8047 Error Err = Error::success();
8051 return std::move(Err);
8060 auto ToBSOrErr =
import(FromNode.
getBase());
8062 return ToBSOrErr.takeError();
8067 auto ToFieldOrErr =
import(FromNode.
getField());
8069 return ToFieldOrErr.takeError();
8070 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, *ToFieldOrErr, ToEndLoc));
8075 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, ToII, ToEndLoc));
8082 for (
int I = 0, N =
E->getNumExpressions(); I < N; ++I) {
8084 if (!ToIndexExprOrErr)
8085 return ToIndexExprOrErr.takeError();
8086 ToExprs[I] = *ToIndexExprOrErr;
8089 Error Err = Error::success();
8091 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
8095 return std::move(Err);
8098 Importer.
getToContext(), ToType, ToOperatorLoc, ToTypeSourceInfo, ToNodes,
8099 ToExprs, ToRParenLoc);
8103 Error Err = Error::success();
8109 return std::move(Err);
8118 ToType, ToOperand, ToCanThrow, ToBeginLoc, ToEndLoc);
8122 Error Err = Error::success();
8127 return std::move(Err);
8130 ToSubExpr, ToType, ToThrowLoc,
E->isThrownVariableInScope());
8135 if (!ToUsedLocOrErr)
8136 return ToUsedLocOrErr.takeError();
8138 auto ToParamOrErr =
import(
E->getParam());
8140 return ToParamOrErr.takeError();
8142 auto UsedContextOrErr = Importer.
ImportContext(
E->getUsedContext());
8143 if (!UsedContextOrErr)
8144 return UsedContextOrErr.takeError();
8154 std::optional<ParmVarDecl *> FromParam =
8156 assert(FromParam &&
"ParmVarDecl was not imported?");
8159 return std::move(Err);
8161 Expr *RewrittenInit =
nullptr;
8162 if (
E->hasRewrittenInit()) {
8165 return ExprOrErr.takeError();
8166 RewrittenInit = ExprOrErr.get();
8169 *ToParamOrErr, RewrittenInit,
8175 Error Err = Error::success();
8177 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
8180 return std::move(Err);
8183 ToType, ToTypeSourceInfo, ToRParenLoc);
8189 if (!ToSubExprOrErr)
8190 return ToSubExprOrErr.takeError();
8192 auto ToDtorOrErr =
import(
E->getTemporary()->getDestructor());
8194 return ToDtorOrErr.takeError();
8204 Error Err = Error::success();
8207 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
8208 auto ToParenOrBraceRange =
importChecked(Err,
E->getParenOrBraceRange());
8210 return std::move(Err);
8214 return std::move(Err);
8217 Importer.
getToContext(), ToConstructor, ToType, ToTypeSourceInfo, ToArgs,
8218 ToParenOrBraceRange,
E->hadMultipleCandidates(),
8219 E->isListInitialization(),
E->isStdInitListInitialization(),
8220 E->requiresZeroInitialization());
8227 return std::move(Err);
8229 Error Err = Error::success();
8233 return std::move(Err);
8237 if (GetImportedOrCreateDecl(To,
D, Temporary, ExtendingDecl,
8238 D->getManglingNumber()))
8248 Error Err = Error::success();
8251 Err,
E->getLifetimeExtendedTemporaryDecl() ?
nullptr :
E->getSubExpr());
8252 auto ToMaterializedDecl =
8255 return std::move(Err);
8257 if (!ToTemporaryExpr)
8258 ToTemporaryExpr = cast<Expr>(ToMaterializedDecl->getTemporaryExpr());
8261 ToType, ToTemporaryExpr,
E->isBoundToLvalueReference(),
8262 ToMaterializedDecl);
8268 Error Err = Error::success();
8273 return std::move(Err);
8276 ToType, ToPattern, ToEllipsisLoc,
E->getNumExpansions());
8280 Error Err = Error::success();
8286 return std::move(Err);
8288 std::optional<unsigned> Length;
8290 Length =
E->getPackLength();
8293 if (
E->isPartiallySubstituted()) {
8295 ToPartialArguments))
8296 return std::move(Err);
8300 Importer.
getToContext(), ToOperatorLoc, ToPack, ToPackLoc, ToRParenLoc,
8301 Length, ToPartialArguments);
8306 Error Err = Error::success();
8308 auto ToOperatorDelete =
importChecked(Err,
E->getOperatorDelete());
8313 auto ToAllocatedTypeSourceInfo =
8316 auto ToDirectInitRange =
importChecked(Err,
E->getDirectInitRange());
8318 return std::move(Err);
8323 return std::move(Err);
8327 ToOperatorDelete,
E->passAlignment(),
E->doesUsualArrayDeleteWantSize(),
8328 ToPlacementArgs, ToTypeIdParens, ToArraySize,
E->getInitializationStyle(),
8329 ToInitializer, ToType, ToAllocatedTypeSourceInfo, ToSourceRange,
8334 Error Err = Error::success();
8336 auto ToOperatorDelete =
importChecked(Err,
E->getOperatorDelete());
8340 return std::move(Err);
8343 ToType,
E->isGlobalDelete(),
E->isArrayForm(),
E->isArrayFormAsWritten(),
8344 E->doesUsualArrayDeleteWantSize(), ToOperatorDelete, ToArgument,
8349 Error Err = Error::success();
8353 auto ToParenOrBraceRange =
importChecked(Err,
E->getParenOrBraceRange());
8355 return std::move(Err);
8359 return std::move(Err);
8362 Importer.
getToContext(), ToType, ToLocation, ToConstructor,
8363 E->isElidable(), ToArgs,
E->hadMultipleCandidates(),
8364 E->isListInitialization(),
E->isStdInitListInitialization(),
8365 E->requiresZeroInitialization(),
E->getConstructionKind(),
8366 ToParenOrBraceRange);
8373 if (!ToSubExprOrErr)
8374 return ToSubExprOrErr.takeError();
8378 return std::move(Err);
8381 Importer.
getToContext(), *ToSubExprOrErr,
E->cleanupsHaveSideEffects(),
8386 Error Err = Error::success();
8391 return std::move(Err);
8395 return std::move(Err);
8399 E->getFPFeatures());
8405 return ToTypeOrErr.takeError();
8408 if (!ToLocationOrErr)
8409 return ToLocationOrErr.takeError();
8412 *ToTypeOrErr,
E->isImplicit());
8418 return ToTypeOrErr.takeError();
8421 if (!ToLocationOrErr)
8422 return ToLocationOrErr.takeError();
8425 *ToTypeOrErr, *ToLocationOrErr);
8429 Error Err = Error::success();
8433 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
8437 auto ToName =
importChecked(Err,
E->getMemberNameInfo().getName());
8438 auto ToLoc =
importChecked(Err,
E->getMemberNameInfo().getLoc());
8440 return std::move(Err);
8448 if (
E->hasExplicitTemplateArgs()) {
8451 E->template_arguments(), ToTAInfo))
8452 return std::move(Err);
8453 ResInfo = &ToTAInfo;
8457 ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8458 ToMemberDecl, ToFoundDecl, ToMemberNameInfo,
8465 Error Err = Error::success();
8469 auto ToScopeTypeInfo =
importChecked(Err,
E->getScopeTypeInfo());
8470 auto ToColonColonLoc =
importChecked(Err,
E->getColonColonLoc());
8473 return std::move(Err);
8478 ExpectedSLoc ToDestroyedTypeLocOrErr =
import(
E->getDestroyedTypeLoc());
8479 if (!ToDestroyedTypeLocOrErr)
8480 return ToDestroyedTypeLocOrErr.takeError();
8483 if (
auto ToTIOrErr =
import(
E->getDestroyedTypeInfo()))
8486 return ToTIOrErr.takeError();
8490 Importer.
getToContext(), ToBase,
E->isArrow(), ToOperatorLoc,
8491 ToQualifierLoc, ToScopeTypeInfo, ToColonColonLoc, ToTildeLoc, Storage);
8496 Error Err = Error::success();
8500 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
8501 auto ToFirstQualifierFoundInScope =
8504 return std::move(Err);
8506 Expr *ToBase =
nullptr;
8507 if (!
E->isImplicitAccess()) {
8509 ToBase = *ToBaseOrErr;
8511 return ToBaseOrErr.takeError();
8516 if (
E->hasExplicitTemplateArgs()) {
8519 E->template_arguments(), ToTAInfo))
8520 return std::move(Err);
8521 ResInfo = &ToTAInfo;
8526 return std::move(Err);
8532 return std::move(Err);
8535 Importer.
getToContext(), ToBase, ToType,
E->isArrow(), ToOperatorLoc,
8536 ToQualifierLoc, ToTemplateKeywordLoc, ToFirstQualifierFoundInScope,
8537 ToMemberNameInfo, ResInfo);
8542 Error Err = Error::success();
8544 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
8550 return std::move(Err);
8554 return std::move(Err);
8558 if (
E->hasExplicitTemplateArgs()) {
8561 return std::move(Err);
8562 ResInfo = &ToTAInfo;
8566 Importer.
getToContext(), ToQualifierLoc, ToTemplateKeywordLoc,
8567 ToNameInfo, ResInfo);
8572 Error Err = Error::success();
8576 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
8578 return std::move(Err);
8583 return std::move(Err);
8586 Importer.
getToContext(), ToType, ToTypeSourceInfo, ToLParenLoc,
8593 if (!ToNamingClassOrErr)
8594 return ToNamingClassOrErr.takeError();
8596 auto ToQualifierLocOrErr =
import(
E->getQualifierLoc());
8597 if (!ToQualifierLocOrErr)
8598 return ToQualifierLocOrErr.takeError();
8600 Error Err = Error::success();
8604 return std::move(Err);
8609 return std::move(Err);
8612 for (
auto *
D :
E->decls())
8613 if (
auto ToDOrErr =
import(
D))
8614 ToDecls.
addDecl(cast<NamedDecl>(*ToDOrErr));
8616 return ToDOrErr.takeError();
8618 if (
E->hasExplicitTemplateArgs()) {
8621 E->getLAngleLoc(),
E->getRAngleLoc(),
E->template_arguments(),
8623 return std::move(Err);
8625 ExpectedSLoc ToTemplateKeywordLocOrErr =
import(
E->getTemplateKeywordLoc());
8626 if (!ToTemplateKeywordLocOrErr)
8627 return ToTemplateKeywordLocOrErr.takeError();
8629 const bool KnownDependent =
8631 ExprDependence::TypeValue;
8633 Importer.
getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8634 *ToTemplateKeywordLocOrErr, ToNameInfo,
E->requiresADL(), &ToTAInfo,
8635 ToDecls.
begin(), ToDecls.
end(), KnownDependent,
8640 Importer.
getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8641 ToNameInfo,
E->requiresADL(), ToDecls.
begin(), ToDecls.
end(),
8648 Error Err = Error::success();
8652 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
8656 return std::move(Err);
8661 return std::move(Err);
8664 for (
Decl *
D :
E->decls())
8665 if (
auto ToDOrErr =
import(
D))
8666 ToDecls.
addDecl(cast<NamedDecl>(*ToDOrErr));
8668 return ToDOrErr.takeError();
8672 if (
E->hasExplicitTemplateArgs()) {
8674 E->copyTemplateArgumentsInto(FromTAInfo);
8676 return std::move(Err);
8677 ResInfo = &ToTAInfo;
8680 Expr *ToBase =
nullptr;
8681 if (!
E->isImplicitAccess()) {
8683 ToBase = *ToBaseOrErr;
8685 return ToBaseOrErr.takeError();
8689 Importer.
getToContext(),
E->hasUnresolvedUsing(), ToBase, ToType,
8690 E->isArrow(), ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8691 ToNameInfo, ResInfo, ToDecls.
begin(), ToDecls.
end());
8695 Error Err = Error::success();
8700 return std::move(Err);
8702 unsigned NumArgs =
E->getNumArgs();
8705 return std::move(Err);
8707 if (
const auto *OCE = dyn_cast<CXXOperatorCallExpr>(
E)) {
8709 Importer.
getToContext(), OCE->getOperator(), ToCallee, ToArgs, ToType,
8710 OCE->getValueKind(), ToRParenLoc, OCE->getFPFeatures(),
8711 OCE->getADLCallKind());
8716 0,
E->getADLCallKind());
8721 auto ToClassOrErr =
import(FromClass);
8723 return ToClassOrErr.takeError();
8726 auto ToCallOpOrErr =
import(
E->getCallOperator());
8728 return ToCallOpOrErr.takeError();
8732 return std::move(Err);
8734 Error Err = Error::success();
8735 auto ToIntroducerRange =
importChecked(Err,
E->getIntroducerRange());
8736 auto ToCaptureDefaultLoc =
importChecked(Err,
E->getCaptureDefaultLoc());
8739 return std::move(Err);
8742 E->getCaptureDefault(), ToCaptureDefaultLoc,
8743 E->hasExplicitParameters(),
8744 E->hasExplicitResultType(), ToCaptureInits,
8750 Error Err = Error::success();
8755 return std::move(Err);
8759 return std::move(Err);
8763 ToCtx, ToLBraceLoc, ToExprs, ToRBraceLoc);
8766 if (
E->hasArrayFiller()) {
8767 if (
ExpectedExpr ToFillerOrErr =
import(
E->getArrayFiller()))
8770 return ToFillerOrErr.takeError();
8773 if (
FieldDecl *FromFD =
E->getInitializedFieldInUnion()) {
8774 if (
auto ToFDOrErr =
import(FromFD))
8777 return ToFDOrErr.takeError();
8781 if (
auto ToSyntFormOrErr =
import(SyntForm))
8784 return ToSyntFormOrErr.takeError();
8798 return ToTypeOrErr.takeError();
8801 if (!ToSubExprOrErr)
8802 return ToSubExprOrErr.takeError();
8805 *ToTypeOrErr, *ToSubExprOrErr);
8810 Error Err = Error::success();
8815 return std::move(Err);
8818 ToLocation, ToType, ToConstructor,
E->constructsVBase(),
8819 E->inheritedFromVBase());
8823 Error Err = Error::success();
8828 return std::move(Err);
8831 ToType, ToCommonExpr, ToSubExpr);
8837 return ToTypeOrErr.takeError();
8843 if (!ToBeginLocOrErr)
8844 return ToBeginLocOrErr.takeError();
8846 auto ToFieldOrErr =
import(
E->getField());
8848 return ToFieldOrErr.takeError();
8850 auto UsedContextOrErr = Importer.
ImportContext(
E->getUsedContext());
8851 if (!UsedContextOrErr)
8852 return UsedContextOrErr.takeError();
8856 "Field should have in-class initializer if there is a default init "
8857 "expression that uses it.");
8862 auto ToInClassInitializerOrErr =
8863 import(
E->getField()->getInClassInitializer());
8864 if (!ToInClassInitializerOrErr)
8865 return ToInClassInitializerOrErr.takeError();
8869 Expr *RewrittenInit =
nullptr;
8870 if (
E->hasRewrittenInit()) {
8873 return ExprOrErr.takeError();
8874 RewrittenInit = ExprOrErr.get();
8878 ToField, *UsedContextOrErr, RewrittenInit);
8882 Error Err = Error::success();
8885 auto ToTypeInfoAsWritten =
importChecked(Err,
E->getTypeInfoAsWritten());
8888 auto ToAngleBrackets =
importChecked(Err,
E->getAngleBrackets());
8890 return std::move(Err);
8895 if (!ToBasePathOrErr)
8896 return ToBasePathOrErr.takeError();
8898 if (
auto CCE = dyn_cast<CXXStaticCastExpr>(
E)) {
8900 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8901 ToTypeInfoAsWritten, CCE->getFPFeatures(), ToOperatorLoc, ToRParenLoc,
8903 }
else if (isa<CXXDynamicCastExpr>(
E)) {
8905 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8906 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8907 }
else if (isa<CXXReinterpretCastExpr>(
E)) {
8909 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8910 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8911 }
else if (isa<CXXConstCastExpr>(
E)) {
8913 Importer.
getToContext(), ToType, VK, ToSubExpr, ToTypeInfoAsWritten,
8914 ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8916 llvm_unreachable(
"Unknown cast type");
8917 return make_error<ASTImportError>();
8923 Error Err = Error::success();
8926 auto ToAssociatedDecl =
importChecked(Err,
E->getAssociatedDecl());
8929 return std::move(Err);
8932 ToType,
E->
getValueKind(), ToExprLoc, ToReplacement, ToAssociatedDecl,
8933 E->getIndex(),
E->getPackIndex(),
E->isReferenceParameter());
8937 Error Err = Error::success();
8942 return std::move(Err);
8946 return std::move(Err);
8953 Importer.
getToContext(), ToType, ToBeginLoc,
E->getTrait(), ToArgs,
8960 return ToTypeOrErr.takeError();
8963 if (!ToSourceRangeOrErr)
8964 return ToSourceRangeOrErr.takeError();
8966 if (
E->isTypeOperand()) {
8967 if (
auto ToTSIOrErr =
import(
E->getTypeOperandSourceInfo()))
8969 *ToTypeOrErr, *ToTSIOrErr, *ToSourceRangeOrErr);
8971 return ToTSIOrErr.takeError();
8974 ExpectedExpr ToExprOperandOrErr =
import(
E->getExprOperand());
8975 if (!ToExprOperandOrErr)
8976 return ToExprOperandOrErr.takeError();
8979 *ToTypeOrErr, *ToExprOperandOrErr, *ToSourceRangeOrErr);
8983 Error Err = Error::success();
8994 return std::move(Err);
8997 CXXFoldExpr(ToType, ToCallee, ToLParenLoc, ToLHS,
E->getOperator(),
8998 ToEllipsisLoc, ToRHS, ToRParenLoc,
E->getNumExpansions());
9003 Error ImportErrors = Error::success();
9005 if (
auto ImportedOrErr =
import(FromOverriddenMethod))
9007 (*ImportedOrErr)->getCanonicalDecl()));
9010 joinErrors(std::move(ImportErrors), ImportedOrErr.takeError());
9012 return ImportErrors;
9018 std::shared_ptr<ASTImporterSharedState> SharedState)
9019 : SharedState(SharedState), ToContext(ToContext), FromContext(FromContext),
9020 ToFileManager(ToFileManager), FromFileManager(FromFileManager),
9025 this->SharedState = std::make_shared<ASTImporterSharedState>();
9035 assert(F && (isa<FieldDecl>(*F) || isa<IndirectFieldDecl>(*F)) &&
9036 "Try to get field index for non-field.");
9040 return std::nullopt;
9043 for (
const auto *
D : Owner->decls()) {
9047 if (isa<FieldDecl>(*
D) || isa<IndirectFieldDecl>(*
D))
9051 llvm_unreachable(
"Field was not found in its parent context.");
9053 return std::nullopt;
9066 if (SharedState->getLookupTable()) {
9068 SharedState->getLookupTable()->lookup(ReDC, Name);
9072 FoundDeclsTy
Result(NoloadLookupResult.
begin(), NoloadLookupResult.
end());
9089void ASTImporter::AddToLookupTable(
Decl *ToD) {
9090 SharedState->addDeclToLookup(ToD);
9096 return Importer.
Visit(FromD);
9120 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
9121 ImportedTypes.find(FromT);
9122 if (Pos != ImportedTypes.end())
9129 return ToTOrErr.takeError();
9132 ImportedTypes[FromT] = ToTOrErr->getTypePtr();
9134 return ToTOrErr->getTypePtr();
9143 return ToTyOrErr.takeError();
9156 return TOrErr.takeError();
9159 return BeginLocOrErr.takeError();
9168template <
typename T>
struct AttrArgImporter {
9169 AttrArgImporter(
const AttrArgImporter<T> &) =
delete;
9170 AttrArgImporter(AttrArgImporter<T> &&) =
default;
9171 AttrArgImporter<T> &operator=(
const AttrArgImporter<T> &) =
delete;
9172 AttrArgImporter<T> &operator=(AttrArgImporter<T> &&) =
default;
9175 : To(I.importChecked(Err, From)) {}
9177 const T &value() {
return To; }
9188template <
typename T>
struct AttrArgArrayImporter {
9189 AttrArgArrayImporter(
const AttrArgArrayImporter<T> &) =
delete;
9190 AttrArgArrayImporter(AttrArgArrayImporter<T> &&) =
default;
9191 AttrArgArrayImporter<T> &operator=(
const AttrArgArrayImporter<T> &) =
delete;
9192 AttrArgArrayImporter<T> &operator=(AttrArgArrayImporter<T> &&) =
default;
9195 const llvm::iterator_range<T *> &From,
9196 unsigned ArraySize) {
9199 To.reserve(ArraySize);
9203 T *value() {
return To.data(); }
9210 Error Err{Error::success()};
9211 Attr *ToAttr =
nullptr;
9216 AttrImporter(
ASTImporter &I) : Importer(I), NImporter(I) {}
9219 template <
typename T>
T *castAttrAs() {
return cast<T>(ToAttr); }
9220 template <
typename T>
const T *castAttrAs()
const {
return cast<T>(ToAttr); }
9225 template <
class T> AttrArgImporter<T> importArg(
const T &From) {
9226 return AttrArgImporter<T>(NImporter, Err, From);
9232 template <
typename T>
9233 AttrArgArrayImporter<T> importArrayArg(
const llvm::iterator_range<T *> &From,
9234 unsigned ArraySize) {
9235 return AttrArgArrayImporter<T>(NImporter, Err, From, ArraySize);
9246 template <
typename T,
typename... Arg>
9247 void importAttr(
const T *FromAttr, Arg &&...ImportedArg) {
9248 static_assert(std::is_base_of<Attr, T>::value,
9249 "T should be subclass of Attr.");
9250 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9254 Importer.
Import(FromAttr->getScopeName());
9264 FromAttr->getParsedKind(), FromAttr->getForm());
9268 std::forward<Arg>(ImportedArg)..., ToI);
9272 if (
auto *ToInheritableAttr = dyn_cast<InheritableAttr>(ToAttr))
9273 ToInheritableAttr->setInherited(FromAttr->isInherited());
9279 void cloneAttr(
const Attr *FromAttr) {
9280 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9294 return std::move(Err);
9295 assert(ToAttr &&
"Attribute should be created.");
9302 AttrImporter AI(*
this);
9305 switch (FromAttr->
getKind()) {
9306 case attr::Aligned: {
9307 auto *From = cast<AlignedAttr>(FromAttr);
9308 if (From->isAlignmentExpr())
9309 AI.importAttr(From,
true, AI.importArg(From->getAlignmentExpr()).value());
9311 AI.importAttr(From,
false,
9312 AI.importArg(From->getAlignmentType()).value());
9316 case attr::AlignValue: {
9317 auto *From = cast<AlignValueAttr>(FromAttr);
9318 AI.importAttr(From, AI.importArg(From->getAlignment()).value());
9322 case attr::Format: {
9323 const auto *From = cast<FormatAttr>(FromAttr);
9324 AI.importAttr(From,
Import(From->getType()), From->getFormatIdx(),
9325 From->getFirstArg());
9329 case attr::EnableIf: {
9330 const auto *From = cast<EnableIfAttr>(FromAttr);
9331 AI.importAttr(From, AI.importArg(From->getCond()).value(),
9332 From->getMessage());
9336 case attr::AssertCapability: {
9337 const auto *From = cast<AssertCapabilityAttr>(FromAttr);
9339 AI.importArrayArg(From->args(), From->args_size()).value(),
9343 case attr::AcquireCapability: {
9344 const auto *From = cast<AcquireCapabilityAttr>(FromAttr);
9346 AI.importArrayArg(From->args(), From->args_size()).value(),
9350 case attr::TryAcquireCapability: {
9351 const auto *From = cast<TryAcquireCapabilityAttr>(FromAttr);
9352 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9353 AI.importArrayArg(From->args(), From->args_size()).value(),
9357 case attr::ReleaseCapability: {
9358 const auto *From = cast<ReleaseCapabilityAttr>(FromAttr);
9360 AI.importArrayArg(From->args(), From->args_size()).value(),
9364 case attr::RequiresCapability: {
9365 const auto *From = cast<RequiresCapabilityAttr>(FromAttr);
9367 AI.importArrayArg(From->args(), From->args_size()).value(),
9371 case attr::GuardedBy: {
9372 const auto *From = cast<GuardedByAttr>(FromAttr);
9373 AI.importAttr(From, AI.importArg(From->getArg()).value());
9376 case attr::PtGuardedBy: {
9377 const auto *From = cast<PtGuardedByAttr>(FromAttr);
9378 AI.importAttr(From, AI.importArg(From->getArg()).value());
9381 case attr::AcquiredAfter: {
9382 const auto *From = cast<AcquiredAfterAttr>(FromAttr);
9384 AI.importArrayArg(From->args(), From->args_size()).value(),
9388 case attr::AcquiredBefore: {
9389 const auto *From = cast<AcquiredBeforeAttr>(FromAttr);
9391 AI.importArrayArg(From->args(), From->args_size()).value(),
9395 case attr::AssertExclusiveLock: {
9396 const auto *From = cast<AssertExclusiveLockAttr>(FromAttr);
9398 AI.importArrayArg(From->args(), From->args_size()).value(),
9402 case attr::AssertSharedLock: {
9403 const auto *From = cast<AssertSharedLockAttr>(FromAttr);
9405 AI.importArrayArg(From->args(), From->args_size()).value(),
9409 case attr::ExclusiveTrylockFunction: {
9410 const auto *From = cast<ExclusiveTrylockFunctionAttr>(FromAttr);
9411 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9412 AI.importArrayArg(From->args(), From->args_size()).value(),
9416 case attr::SharedTrylockFunction: {
9417 const auto *From = cast<SharedTrylockFunctionAttr>(FromAttr);
9418 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9419 AI.importArrayArg(From->args(), From->args_size()).value(),
9423 case attr::LockReturned: {
9424 const auto *From = cast<LockReturnedAttr>(FromAttr);
9425 AI.importAttr(From, AI.importArg(From->getArg()).value());
9428 case attr::LocksExcluded: {
9429 const auto *From = cast<LocksExcludedAttr>(FromAttr);
9431 AI.importArrayArg(From->args(), From->args_size()).value(),
9439 AI.cloneAttr(FromAttr);
9444 return std::move(AI).getResult();
9448 return ImportedDecls.lookup(FromD);
9452 auto FromDPos = ImportedFromDecls.find(ToD);
9453 if (FromDPos == ImportedFromDecls.end())
9455 return FromDPos->second->getTranslationUnitDecl();
9463 ImportPath.
push(FromD);
9464 auto ImportPathBuilder =
9465 llvm::make_scope_exit([
this]() { ImportPath.
pop(); });
9470 return make_error<ASTImportError>(*Error);
9476 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9478 return make_error<ASTImportError>(*Error);
9495 auto Pos = ImportedDecls.find(FromD);
9496 if (Pos != ImportedDecls.end()) {
9499 auto *ToD = Pos->second;
9500 ImportedDecls.erase(Pos);
9512 auto PosF = ImportedFromDecls.find(ToD);
9513 if (PosF != ImportedFromDecls.end()) {
9518 SharedState->removeDeclFromLookup(ToD);
9519 ImportedFromDecls.erase(PosF);
9531 handleAllErrors(ToDOrErr.takeError(),
9535 if (Pos != ImportedDecls.end())
9536 SharedState->setImportDeclError(Pos->second, ErrOut);
9540 for (
const auto &
Path : SavedImportPaths[FromD]) {
9543 Decl *PrevFromDi = FromD;
9546 if (FromDi == FromD)
9553 PrevFromDi = FromDi;
9557 auto Ii = ImportedDecls.find(FromDi);
9558 if (Ii != ImportedDecls.end())
9559 SharedState->setImportDeclError(Ii->second, ErrOut);
9564 SavedImportPaths.erase(FromD);
9567 return make_error<ASTImportError>(ErrOut);
9579 return make_error<ASTImportError>(*Err);
9585 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9587 return make_error<ASTImportError>(*Error);
9590 assert(ImportedDecls.count(FromD) != 0 &&
"Missing call to MapImported?");
9594 auto ToAttrOrErr =
Import(FromAttr);
9598 return ToAttrOrErr.takeError();
9605 SavedImportPaths.erase(FromD);
9620 return ToDCOrErr.takeError();
9621 auto *ToDC = cast<DeclContext>(*ToDCOrErr);
9625 if (
auto *ToRecord = dyn_cast<RecordDecl>(ToDC)) {
9626 auto *FromRecord = cast<RecordDecl>(FromDC);
9627 if (ToRecord->isCompleteDefinition())
9635 if (FromRecord->getASTContext().getExternalSource() &&
9636 !FromRecord->isCompleteDefinition())
9637 FromRecord->getASTContext().getExternalSource()->CompleteType(FromRecord);
9639 if (FromRecord->isCompleteDefinition())
9642 return std::move(Err);
9643 }
else if (
auto *ToEnum = dyn_cast<EnumDecl>(ToDC)) {
9644 auto *FromEnum = cast<EnumDecl>(FromDC);
9645 if (ToEnum->isCompleteDefinition()) {
9647 }
else if (FromEnum->isCompleteDefinition()) {
9650 return std::move(Err);
9654 }
else if (
auto *ToClass = dyn_cast<ObjCInterfaceDecl>(ToDC)) {
9655 auto *FromClass = cast<ObjCInterfaceDecl>(FromDC);
9656 if (ToClass->getDefinition()) {
9661 return std::move(Err);
9665 }
else if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(ToDC)) {
9666 auto *FromProto = cast<ObjCProtocolDecl>(FromDC);
9667 if (ToProto->getDefinition()) {
9672 return std::move(Err);
9683 return cast_or_null<Expr>(*ToSOrErr);
9685 return ToSOrErr.takeError();
9693 llvm::DenseMap<Stmt *, Stmt *>::iterator Pos = ImportedStmts.find(FromS);
9694 if (Pos != ImportedStmts.end())
9703 if (
auto *ToE = dyn_cast<Expr>(*ToSOrErr)) {
9704 auto *FromE = cast<Expr>(FromS);
9707 ToE->setValueKind(FromE->getValueKind());
9708 ToE->setObjectKind(FromE->getObjectKind());
9709 ToE->setDependence(FromE->getDependence());
9713 ImportedStmts[FromS] = *ToSOrErr;
9724 return std::move(Err);
9728 assert(FromNNS->
getAsIdentifier() &&
"NNS should contain identifier.");
9735 cast<NamespaceDecl>(*NSOrErr));
9737 return NSOrErr.takeError();
9742 cast<NamespaceAliasDecl>(*NSADOrErr));
9744 return NSADOrErr.takeError();
9752 cast<CXXRecordDecl>(*RDOrErr));
9754 return RDOrErr.takeError();
9764 return TyOrErr.takeError();
9768 llvm_unreachable(
"Invalid nested name specifier kind");
9780 NestedNames.push_back(NNS);
9786 while (!NestedNames.empty()) {
9787 NNS = NestedNames.pop_back_val();
9790 return std::move(Err);
9797 return std::move(Err);
9801 return std::move(Err);
9817 ToLocalBeginLoc, ToLocalEndLoc);
9824 return std::move(Err);
9844 if (!ToSourceRangeOrErr)
9845 return ToSourceRangeOrErr.takeError();
9848 ToSourceRangeOrErr->getBegin(),
9849 ToSourceRangeOrErr->getEnd());
9861 return TemplateName(cast<TemplateDecl>((*ToTemplateOrErr)->getCanonicalDecl()));
9863 return ToTemplateOrErr.takeError();
9868 for (
auto *I : *FromStorage) {
9869 if (
auto ToOrErr =
Import(I))
9870 ToTemplates.
addDecl(cast<NamedDecl>(*ToOrErr));
9872 return ToOrErr.takeError();
9882 return DeclNameOrErr.takeError();
9889 if (!QualifierOrErr)
9890 return QualifierOrErr.takeError();
9893 return TNOrErr.takeError();
9901 if (!QualifierOrErr)
9902 return QualifierOrErr.takeError();
9917 if (!ReplacementOrErr)
9918 return ReplacementOrErr.takeError();
9921 if (!AssociatedDeclOrErr)
9922 return AssociatedDeclOrErr.takeError();
9925 *ReplacementOrErr, *AssociatedDeclOrErr, Subst->
getIndex(),
9936 return ArgPackOrErr.takeError();
9939 if (!AssociatedDeclOrErr)
9940 return AssociatedDeclOrErr.takeError();
9943 *ArgPackOrErr, *AssociatedDeclOrErr, SubstPack->
getIndex(),
9949 return UsingOrError.takeError();
9950 return TemplateName(cast<UsingShadowDecl>(*UsingOrError));
9953 llvm_unreachable(
"Unexpected DeducedTemplate");
9956 llvm_unreachable(
"Invalid template name kind");
9969 return ToFileIDOrErr.takeError();
9977 return std::move(Err);
9979 return std::move(Err);
9985 llvm::DenseMap<FileID, FileID>::iterator Pos = ImportedFileIDs.find(FromID);
9986 if (Pos != ImportedFileIDs.end())
9999 return ToSpLoc.takeError();
10002 return ToExLocS.takeError();
10012 return ToExLocE.takeError();
10018 if (!IsBuiltin && !
Cache->BufferOverridden) {
10022 return ToIncludeLoc.takeError();
10033 if (
Cache->OrigEntry &&
Cache->OrigEntry->getDir()) {
10044 ToID = ToSM.
createFileID(*Entry, ToIncludeLocOrFakeLoc,
10051 std::optional<llvm::MemoryBufferRef> FromBuf =
10057 std::unique_ptr<llvm::MemoryBuffer> ToBuf =
10058 llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(),
10059 FromBuf->getBufferIdentifier());
10065 assert(ToID.
isValid() &&
"Unexpected invalid fileID was created.");
10067 ImportedFileIDs[FromID] = ToID;
10074 return ToExprOrErr.takeError();
10077 if (!LParenLocOrErr)
10078 return LParenLocOrErr.takeError();
10081 if (!RParenLocOrErr)
10082 return RParenLocOrErr.takeError();
10087 return ToTInfoOrErr.takeError();
10092 return std::move(Err);
10095 ToContext, *ToTInfoOrErr, From->
isBaseVirtual(), *LParenLocOrErr,
10096 *ToExprOrErr, *RParenLocOrErr, EllipsisLoc);
10100 return ToFieldOrErr.takeError();
10103 if (!MemberLocOrErr)
10104 return MemberLocOrErr.takeError();
10107 ToContext, cast_or_null<FieldDecl>(*ToFieldOrErr), *MemberLocOrErr,
10108 *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10111 if (!ToIFieldOrErr)
10112 return ToIFieldOrErr.takeError();
10115 if (!MemberLocOrErr)
10116 return MemberLocOrErr.takeError();
10119 ToContext, cast_or_null<IndirectFieldDecl>(*ToIFieldOrErr),
10120 *MemberLocOrErr, *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10124 return ToTInfoOrErr.takeError();
10126 return new (ToContext)
10128 *ToExprOrErr, *RParenLocOrErr);
10131 return make_error<ASTImportError>();
10137 auto Pos = ImportedCXXBaseSpecifiers.find(BaseSpec);
10138 if (Pos != ImportedCXXBaseSpecifiers.end())
10139 return Pos->second;
10142 if (!ToSourceRange)
10143 return ToSourceRange.takeError();
10146 return ToTSI.takeError();
10148 if (!ToEllipsisLoc)
10149 return ToEllipsisLoc.takeError();
10153 ImportedCXXBaseSpecifiers[BaseSpec] =
Imported;
10165 return ToOrErr.takeError();
10166 Decl *To = *ToOrErr;
10168 auto *FromDC = cast<DeclContext>(From);
10171 if (
auto *ToRecord = dyn_cast<RecordDecl>(To)) {
10172 if (!ToRecord->getDefinition()) {
10174 cast<RecordDecl>(FromDC), ToRecord,
10179 if (
auto *ToEnum = dyn_cast<EnumDecl>(To)) {
10180 if (!ToEnum->getDefinition()) {
10186 if (
auto *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
10187 if (!ToIFace->getDefinition()) {
10189 cast<ObjCInterfaceDecl>(FromDC), ToIFace,
10194 if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
10195 if (!ToProto->getDefinition()) {
10197 cast<ObjCProtocolDecl>(FromDC), ToProto,
10219 return ToSelOrErr.takeError();
10226 return ToTyOrErr.takeError();
10234 return ToTyOrErr.takeError();
10240 cast<TemplateDecl>(*ToTemplateOrErr));
10242 return ToTemplateOrErr.takeError();
10250 return ToTyOrErr.takeError();
10266 llvm_unreachable(
"Invalid DeclarationName Kind!");
10287 for (
unsigned I = 1, N = FromSel.
getNumArgs(); I < N; ++I)
10295 llvm::Error Err = llvm::Error::success();
10296 auto ImportLoop = [&](
const APValue *From,
APValue *To,
unsigned Size) {
10297 for (
unsigned Idx = 0; Idx < Size; Idx++) {
10302 switch (FromValue.
getKind()) {
10316 ImportLoop(((
const APValue::Vec *)(
const char *)&FromValue.Data)->Elts,
10323 ImportLoop(((
const APValue::Arr *)(
const char *)&FromValue.Data)->Elts,
10324 ((
const APValue::Arr *)(
const char *)&
Result.Data)->Elts,
10331 ((
const APValue::StructData *)(
const char *)&FromValue.Data)->Elts,
10332 ((
const APValue::StructData *)(
const char *)&
Result.Data)->Elts,
10340 return std::move(Err);
10341 Result.setUnion(cast<FieldDecl>(ImpFDecl), ImpValue);
10345 Result.MakeAddrLabelDiff();
10349 return std::move(Err);
10350 Result.setAddrLabelDiff(cast<AddrLabelExpr>(ImpLHS),
10351 cast<AddrLabelExpr>(ImpRHS));
10355 const Decl *ImpMemPtrDecl =
10358 return std::move(Err);
10360 Result.setMemberPointerUninit(
10361 cast<const ValueDecl>(ImpMemPtrDecl),
10365 Result.getMemberPointerPath();
10370 return std::move(Err);
10380 "in C++20 dynamic allocation are transient so they shouldn't "
10381 "appear in the AST");
10383 if (
const auto *
E =
10388 return std::move(Err);
10398 return std::move(Err);
10410 return std::move(Err);
10424 for (
unsigned LoopIdx = 0; LoopIdx < PathLength; LoopIdx++) {
10427 FromPath[LoopIdx].getAsBaseOrMember().getPointer();
10430 return std::move(Err);
10431 if (
auto *RD = dyn_cast<CXXRecordDecl>(
FromDecl))
10434 FromElemTy = cast<ValueDecl>(
FromDecl)->getType();
10436 ImpDecl, FromPath[LoopIdx].getAsBaseOrMember().getInt()));
10441 FromPath[LoopIdx].getAsArrayIndex());
10449 return std::move(Err);
10457 unsigned NumDecls) {
10467 if (LastDiagFromFrom)
10470 LastDiagFromFrom =
false;
10475 if (!LastDiagFromFrom)
10478 LastDiagFromFrom =
true;
10483 if (
auto *ID = dyn_cast<ObjCInterfaceDecl>(
D)) {
10484 if (!ID->getDefinition())
10485 ID->startDefinition();
10487 else if (
auto *PD = dyn_cast<ObjCProtocolDecl>(
D)) {
10488 if (!PD->getDefinition())
10489 PD->startDefinition();
10491 else if (
auto *TD = dyn_cast<TagDecl>(
D)) {
10492 if (!TD->getDefinition() && !TD->isBeingDefined()) {
10493 TD->startDefinition();
10494 TD->setCompleteDefinition(
true);
10498 assert(0 &&
"CompleteDecl called on a Decl that can't be completed");
10503 llvm::DenseMap<Decl *, Decl *>::iterator Pos = ImportedDecls.find(From);
10504 assert((Pos == ImportedDecls.end() || Pos->second == To) &&
10505 "Try to import an already imported Decl");
10506 if (Pos != ImportedDecls.end())
10507 return Pos->second;
10508 ImportedDecls[From] = To;
10511 ImportedFromDecls[To] = From;
10516 AddToLookupTable(To);
10520std::optional<ASTImportError>
10522 auto Pos = ImportDeclErrors.find(FromD);
10523 if (Pos != ImportDeclErrors.end())
10524 return Pos->second;
10526 return std::nullopt;
10530 auto InsertRes = ImportDeclErrors.insert({From, Error});
10534 assert(InsertRes.second || InsertRes.first->second.Error == Error.Error);
10539 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
10541 if (Pos != ImportedTypes.end()) {
10546 llvm::consumeError(ToFromOrErr.takeError());
Defines the clang::ASTContext interface.
ASTImporterLookupTable & LT
static FriendCountAndPosition getFriendCountAndPosition(ASTImporter &Importer, FriendDecl *FD)
static bool IsEquivalentFriend(ASTImporter &Importer, FriendDecl *FD1, FriendDecl *FD2)
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)
Defines enum values for all the target-independent builtin functions.
enum clang::sema::@1712::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 ...
QualType getUsingType(const UsingShadowDecl *Found, QualType Underlying) const
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.
BuiltinTemplateDecl * getBuiltinCommonTypeDecl() const
BuiltinTemplateDecl * getMakeIntegerSeqDecl() const
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 getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, ConceptDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, ArrayRef< TemplateArgumentLoc > Args) const
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.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
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 getTemplateSpecializationType(TemplateName T, ArrayRef< TemplateArgument > Args, QualType Canon=QualType()) const
QualType getRecordType(const RecordDecl *Decl) const
QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const
getInjectedClassNameType - Return the unique reference to the injected class name type for the specif...
QualType getVariableArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a variable array of the specified element type.
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
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)
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, std::optional< unsigned > PackIndex, SubstTemplateTypeParmTypeFlag Flag=SubstTemplateTypeParmTypeFlag::None) 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 getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
TemplateName getSubstTemplateTemplateParm(TemplateName replacement, Decl *AssociatedDecl, unsigned Index, std::optional< unsigned > PackIndex) 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.
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 getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
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...
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)
Retrieve a.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
QualType getPackExpansionType(QualType Pattern, std::optional< unsigned > NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const
Legacy interface: cannot provide type arguments or __kindof.
QualType getDependentSizedArrayType(QualType EltTy, Expr *NumElts, ArraySizeModifier ASM, unsigned IndexTypeQuals, SourceRange Brackets) const
Return a non-unique reference to the type for a dependently-sized array of the specified element type...
UsingShadowDecl * getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst)
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
CanQualType UnsignedCharTy
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
QualType getPackIndexingType(QualType Pattern, Expr *IndexExpr, bool FullySubstituted=false, ArrayRef< QualType > Expansions={}, int Index=-1) const
QualType getUnaryTransformType(QualType BaseType, QualType UnderlyingType, UnaryTransformType::UTTKind UKind) const
Unary type transforms.
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.
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
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
BuiltinTemplateDecl * getTypePackElementDecl() const
QualType getTypeOfType(QualType QT, TypeOfKind Kind) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes.
QualType getDecltypeType(Expr *e, QualType UnderlyingType) const
C++11 decltype.
QualType getTypedefType(const TypedefNameDecl *Decl, QualType Underlying=QualType()) const
Return the unique reference to the type for the specified typedef-name decl.
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
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
static std::optional< unsigned > getFieldIndex(Decl *F)
Determine the index of a field in its parent record.
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)
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)
ExpectedStmt VisitObjCAtTryStmt(ObjCAtTryStmt *S)
ExpectedStmt VisitUnaryOperator(UnaryOperator *E)
Error ImportTemplateParameterLists(const DeclTy *FromD, DeclTy *ToD)
Error ImportDeclContext(DeclContext *FromDC, bool ForceImport=false)
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 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)
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 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)
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)
ExpectedDecl VisitImportDecl(ImportDecl *D)
Error ImportFunctionDeclBody(FunctionDecl *FromFD, FunctionDecl *ToFD)
ExpectedStmt VisitArraySubscriptExpr(ArraySubscriptExpr *E)
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.
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, bool ShouldPassAlignment, 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.
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
ClassTemplateDecl * getMostRecentDecl()
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
QualType getInjectedClassNameSpecialization()
Retrieve the template specialization type of the injected-class-name for this class template.
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...
QualType getInjectedSpecializationType() const
Retrieves the injected specialization type for this partial specialization.
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)
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
ConceptDecl * getNamedConcept() const
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
SourceLocation getTemplateKWLoc() const
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.
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...
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.
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 dependent template name that cannot be resolved prior to template instantiation.
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
bool isIdentifier() const
Determine whether this template name refers to an identifier.
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
Represents a template specialization type whose template cannot be resolved, e.g.
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, llvm::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 a type that was referred to using an elaborated type keyword, e.g., struct S,...
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.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
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 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 * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
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.
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.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning 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.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, const IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
SpecifierKind
The kind of specifier that completes this nested name specifier.
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
@ TypeSpec
A type, stored as a Type*.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Identifier
An identifier, stored as an IdentifierInfo*.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace, stored as a NamespaceDecl*.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
static NestedNameSpecifier * SuperSpecifier(const ASTContext &Context, CXXRecordDecl *RD)
Returns the nested name specifier representing the __super scope for the given CXXRecordDecl.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
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.
QualType getCanonicalType() const
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.
TemplateName getUnderlyingTemplate() const
Return the underlying template name.
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this 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 * getDecl() 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.
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, std::optional< unsigned > 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.
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.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
SourceLocation createExpansionLoc(SourceLocation SpellingLoc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned Length, bool ExpansionIsTokenRange=true, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0)
Creates an expansion SLocEntry for a macro use.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
SourceLocation createMacroArgExpansionLoc(SourceLocation SpellingLoc, SourceLocation ExpansionLoc, unsigned Length)
Creates an expansion SLocEntry for the substitution of an argument into a function-like macro's body.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
One instance of this struct is kept for every file loaded or used.
Each ExpansionInfo encodes the expansion location - where the token was ultimately expanded,...
SourceLocation getExpansionLocStart() const
bool isExpansionTokenRange() const
SourceLocation getSpellingLoc() const
bool isMacroArgExpansion() const
SourceLocation getExpansionLocEnd() const
const ContentCache & getContentCache() const
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
SourceLocation getIncludeLoc() const
This is a discriminated union of FileInfo and ExpansionInfo.
const FileInfo & getFile() const
const ExpansionInfo & getExpansion() const
Represents a C++11 static_assert declaration.
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, const SourceLocation *Loc, unsigned NumConcatenated)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
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
std::optional< unsigned > 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)
llvm::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
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.
std::optional< unsigned > 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.
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)
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...
void setTypeForDecl(const Type *TD)
const Type * getTypeForDecl() const
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.
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...
QualType getCanonicalTypeInternal() const
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
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
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.
void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
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.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
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.
@ Property
The type of a property.
@ Result
The result type of a method or function.
@ BTK__type_pack_element
This names the __type_pack_element BuiltinTemplateDecl.
@ BTK__builtin_common_type
This names the __builtin_common_type BuiltinTemplateDecl.
@ BTK__make_integer_seq
This names the __make_integer_seq BuiltinTemplateDecl.
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...
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.
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)
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
bool IsEquivalent(Decl *D1, Decl *D2)
Determine whether the two declarations are structurally equivalent.
Location information for a TemplateArgument.
SourceLocation getTemplateEllipsisLoc() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
TypeSourceInfo * getAsTypeSourceInfo() const
SourceLocation getTemplateNameLoc() const