56#include "llvm/ADT/APSInt.h"
57#include "llvm/ADT/ArrayRef.h"
58#include "llvm/ADT/DenseMap.h"
59#include "llvm/ADT/STLExtras.h"
60#include "llvm/ADT/ScopeExit.h"
61#include "llvm/ADT/SmallVector.h"
62#include "llvm/Support/Casting.h"
63#include "llvm/Support/ErrorHandling.h"
64#include "llvm/Support/MemoryBuffer.h"
75 using llvm::make_error;
90 return "NameConflict";
92 return "UnsupportedConstruct";
94 return "Unknown error";
96 llvm_unreachable(
"Invalid error code.");
97 return "Invalid error code.";
103 llvm_unreachable(
"Function not implemented.");
112 for (
auto *R :
D->getFirstDecl()->
redecls()) {
113 if (R !=
D->getFirstDecl())
114 Redecls.push_back(R);
116 Redecls.push_back(
D->getFirstDecl());
117 std::reverse(Redecls.begin(), Redecls.end());
122 if (
auto *FD = dyn_cast<FunctionDecl>(
D))
123 return getCanonicalForwardRedeclChain<FunctionDecl>(FD);
124 if (
auto *VD = dyn_cast<VarDecl>(
D))
125 return getCanonicalForwardRedeclChain<VarDecl>(VD);
126 if (
auto *TD = dyn_cast<TagDecl>(
D))
127 return getCanonicalForwardRedeclChain<TagDecl>(TD);
128 llvm_unreachable(
"Bad declaration kind");
149 bool const IgnoreChildErrors;
153 : FromDC(FromDC), IgnoreChildErrors(!
isa<
TagDecl>(FromDC)) {}
163 if (ChildErr && !IgnoreChildErrors)
164 ResultErr = joinErrors(std::move(ResultErr), std::move(ChildErr));
166 consumeError(std::move(ChildErr));
172 if (!IgnoreChildErrors || !FromDC)
180 public StmtVisitor<ASTNodeImporter, ExpectedStmt> {
184 template <
typename ImportT>
185 [[nodiscard]] Error importInto(ImportT &To,
const ImportT &From) {
190 template <
typename ImportT>
191 [[nodiscard]] Error importInto(ImportT *&To, ImportT *From) {
192 auto ToOrErr = Importer.
Import(From);
194 To = cast_or_null<ImportT>(*ToOrErr);
195 return ToOrErr.takeError();
200 template <
typename T>
204 auto ToOrErr = Importer.
Import(From);
206 return ToOrErr.takeError();
207 return cast_or_null<T>(*ToOrErr);
210 template <
typename T>
211 auto import(
const T *From) {
212 return import(
const_cast<T *
>(From));
216 template <
typename T>
218 return Importer.
Import(From);
222 template <
typename T>
226 return import(*From);
233 template <
typename ToDeclT>
struct CallOverloadedCreateFun {
234 template <
typename... Args>
decltype(
auto)
operator()(Args &&... args) {
235 return ToDeclT::Create(std::forward<Args>(args)...);
245 template <
typename ToDeclT,
typename FromDeclT,
typename... Args>
246 [[nodiscard]]
bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
251 CallOverloadedCreateFun<ToDeclT> OC;
252 return GetImportedOrCreateSpecialDecl(ToD, OC, FromD,
253 std::forward<Args>(args)...);
260 template <
typename NewDeclT,
typename ToDeclT,
typename FromDeclT,
262 [[nodiscard]]
bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
264 CallOverloadedCreateFun<NewDeclT> OC;
265 return GetImportedOrCreateSpecialDecl(ToD, OC, FromD,
266 std::forward<Args>(args)...);
270 template <
typename ToDeclT,
typename CreateFunT,
typename FromDeclT,
273 GetImportedOrCreateSpecialDecl(ToDeclT *&ToD, CreateFunT CreateFun,
274 FromDeclT *FromD, Args &&...args) {
282 ToD = CreateFun(std::forward<Args>(args)...);
285 Importer.SharedState->markAsNewDecl(ToD);
286 InitializeImportedDecl(FromD, ToD);
290 void InitializeImportedDecl(
Decl *FromD,
Decl *ToD) {
294 if (FromD->isImplicit())
302 if (
D->doesThisDeclarationHaveABody() &&
308 void addDeclToContexts(
Decl *FromD,
Decl *ToD) {
313 if (!FromD->getDescribedTemplate() &&
320 DeclContext *FromLexicalDC = FromD->getLexicalDeclContext();
324 bool Visible =
false;
337 if (
auto *FromNamed = dyn_cast<NamedDecl>(FromD)) {
338 auto *ToNamed = cast<NamedDecl>(ToD);
340 FromDC->
lookup(FromNamed->getDeclName());
341 if (llvm::is_contained(FromLookup, FromNamed))
358 updateLookupTableForTemplateParameters(
362 template <
typename TemplateParmDeclT>
363 void tryUpdateTemplateParmDeclInheritedFrom(
NamedDecl *RecentParm,
365 if (
auto *ParmT = dyn_cast<TemplateParmDeclT>(RecentParm)) {
366 if (ParmT->hasDefaultArgument()) {
367 auto *
P = cast<TemplateParmDeclT>(NewParm);
368 P->removeDefaultArgument();
369 P->setInheritedDefaultArgument(Importer.ToContext, ParmT);
397 void updateTemplateParametersInheritedFrom(
400 for (
auto [Idx, Param] : enumerate(RecentParams)) {
401 tryUpdateTemplateParmDeclInheritedFrom<NonTypeTemplateParmDecl>(
403 tryUpdateTemplateParmDeclInheritedFrom<TemplateTypeParmDecl>(
405 tryUpdateTemplateParmDeclInheritedFrom<TemplateTemplateParmDecl>(
419#define TYPE(Class, Base) \
420 ExpectedType Visit##Class##Type(const Class##Type *T);
421#include "clang/AST/TypeNodes.inc"
479 template <
typename InContainerTy>
483 template<
typename InContainerTy>
490 std::tuple<FunctionTemplateDecl *, TemplateArgsTy>;
495 template <
typename DeclTy>
508 template <
typename T>
512 bool IgnoreTemplateParmDepth =
false);
704 Err = MaybeVal.takeError();
710 template<
typename IIter,
typename OIter>
712 using ItemT = std::remove_reference_t<
decltype(*Obegin)>;
713 for (; Ibegin != Iend; ++Ibegin, ++Obegin) {
716 return ToOrErr.takeError();
719 return Error::success();
726 template<
typename InContainerTy,
typename OutContainerTy>
728 const InContainerTy &InContainer, OutContainerTy &OutContainer) {
730 InContainer.begin(), InContainer.end(), OutContainer.begin());
733 template<
typename InContainerTy,
typename OIter>
750template <
typename InContainerTy>
754 auto ToLAngleLocOrErr =
import(FromLAngleLoc);
755 if (!ToLAngleLocOrErr)
756 return ToLAngleLocOrErr.takeError();
757 auto ToRAngleLocOrErr =
import(FromRAngleLoc);
758 if (!ToRAngleLocOrErr)
759 return ToRAngleLocOrErr.takeError();
765 return Error::success();
769Error ASTNodeImporter::ImportTemplateArgumentListInfo<TemplateArgumentListInfo>(
780 return ImportTemplateArgumentListInfo(
781 From.LAngleLoc, From.RAngleLoc, From.arguments(),
Result);
793 if (Error Err = importInto(std::get<0>(
Result), FTSInfo->getTemplate()))
794 return std::move(Err);
799 return std::move(Err);
809 return std::move(Err);
812 if (!ToRequiresClause)
813 return ToRequiresClause.takeError();
816 if (!ToTemplateLocOrErr)
817 return ToTemplateLocOrErr.takeError();
819 if (!ToLAngleLocOrErr)
820 return ToLAngleLocOrErr.takeError();
822 if (!ToRAngleLocOrErr)
823 return ToRAngleLocOrErr.takeError();
844 return ToTypeOrErr.takeError();
852 return ToTypeOrErr.takeError();
859 return ToOrErr.takeError();
862 return ToTypeOrErr.takeError();
863 return TemplateArgument(dyn_cast<ValueDecl>((*ToOrErr)->getCanonicalDecl()),
870 return ToTypeOrErr.takeError();
878 return ToTypeOrErr.takeError();
881 return ToValueOrErr.takeError();
888 if (!ToTemplateOrErr)
889 return ToTemplateOrErr.takeError();
897 if (!ToTemplateOrErr)
898 return ToTemplateOrErr.takeError();
908 return ToExpr.takeError();
914 return std::move(Err);
921 llvm_unreachable(
"Invalid template argument kind");
929 return ArgOrErr.takeError();
938 return E.takeError();
944 return TSIOrErr.takeError();
946 auto ToTemplateQualifierLocOrErr =
948 if (!ToTemplateQualifierLocOrErr)
949 return ToTemplateQualifierLocOrErr.takeError();
951 if (!ToTemplateNameLocOrErr)
952 return ToTemplateNameLocOrErr.takeError();
953 auto ToTemplateEllipsisLocOrErr =
955 if (!ToTemplateEllipsisLocOrErr)
956 return ToTemplateEllipsisLocOrErr.takeError();
959 *ToTemplateNameLocOrErr, *ToTemplateEllipsisLocOrErr);
969 size_t NumDecls = DG.
end() - DG.
begin();
971 ToDecls.reserve(NumDecls);
972 for (
Decl *FromD : DG) {
973 if (
auto ToDOrErr =
import(FromD))
974 ToDecls.push_back(*ToDOrErr);
976 return ToDOrErr.takeError();
986 if (
D.isFieldDesignator()) {
991 return ToDotLocOrErr.takeError();
994 if (!ToFieldLocOrErr)
995 return ToFieldLocOrErr.takeError();
998 ToFieldName, *ToDotLocOrErr, *ToFieldLocOrErr);
1001 ExpectedSLoc ToLBracketLocOrErr =
import(
D.getLBracketLoc());
1002 if (!ToLBracketLocOrErr)
1003 return ToLBracketLocOrErr.takeError();
1005 ExpectedSLoc ToRBracketLocOrErr =
import(
D.getRBracketLoc());
1006 if (!ToRBracketLocOrErr)
1007 return ToRBracketLocOrErr.takeError();
1009 if (
D.isArrayDesignator())
1011 *ToLBracketLocOrErr,
1012 *ToRBracketLocOrErr);
1014 ExpectedSLoc ToEllipsisLocOrErr =
import(
D.getEllipsisLoc());
1015 if (!ToEllipsisLocOrErr)
1016 return ToEllipsisLocOrErr.takeError();
1018 assert(
D.isArrayRangeDesignator());
1020 D.getArrayIndex(), *ToLBracketLocOrErr, *ToEllipsisLocOrErr,
1021 *ToRBracketLocOrErr);
1026 Error Err = Error::success();
1029 auto ToConceptNameLoc =
1035 return std::move(Err);
1038 if (ASTTemplateArgs)
1040 return std::move(Err);
1058 return VarOrErr.takeError();
1063 return LocationOrErr.takeError();
1068 return std::move(Err);
1075template <
typename T>
1077 if (
Found->getLinkageInternal() != From->getLinkageInternal())
1080 if (From->hasExternalFormalLinkage())
1081 return Found->hasExternalFormalLinkage();
1084 if (From->isInAnonymousNamespace())
1085 return Found->isInAnonymousNamespace();
1087 return !
Found->isInAnonymousNamespace() &&
1088 !
Found->hasExternalFormalLinkage();
1108using namespace clang;
1117 ExpectedType UnderlyingTypeOrErr =
import(
T->getValueType());
1118 if (!UnderlyingTypeOrErr)
1119 return UnderlyingTypeOrErr.takeError();
1125 switch (
T->getKind()) {
1126#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1127 case BuiltinType::Id: \
1128 return Importer.getToContext().SingletonId;
1129#include "clang/Basic/OpenCLImageTypes.def"
1130#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1131 case BuiltinType::Id: \
1132 return Importer.getToContext().Id##Ty;
1133#include "clang/Basic/OpenCLExtensionTypes.def"
1134#define SVE_TYPE(Name, Id, SingletonId) \
1135 case BuiltinType::Id: \
1136 return Importer.getToContext().SingletonId;
1137#include "clang/Basic/AArch64SVEACLETypes.def"
1138#define PPC_VECTOR_TYPE(Name, Id, Size) \
1139 case BuiltinType::Id: \
1140 return Importer.getToContext().Id##Ty;
1141#include "clang/Basic/PPCTypes.def"
1142#define RVV_TYPE(Name, Id, SingletonId) \
1143 case BuiltinType::Id: \
1144 return Importer.getToContext().SingletonId;
1145#include "clang/Basic/RISCVVTypes.def"
1146#define WASM_TYPE(Name, Id, SingletonId) \
1147 case BuiltinType::Id: \
1148 return Importer.getToContext().SingletonId;
1149#include "clang/Basic/WebAssemblyReferenceTypes.def"
1150#define AMDGPU_TYPE(Name, Id, SingletonId) \
1151 case BuiltinType::Id: \
1152 return Importer.getToContext().SingletonId;
1153#include "clang/Basic/AMDGPUTypes.def"
1154#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1155 case BuiltinType::Id: \
1156 return Importer.getToContext().SingletonId;
1157#include "clang/Basic/HLSLIntangibleTypes.def"
1158#define SHARED_SINGLETON_TYPE(Expansion)
1159#define BUILTIN_TYPE(Id, SingletonId) \
1160 case BuiltinType::Id: return Importer.getToContext().SingletonId;
1161#include "clang/AST/BuiltinTypes.def"
1169 case BuiltinType::Char_U:
1178 case BuiltinType::Char_S:
1187 case BuiltinType::WChar_S:
1188 case BuiltinType::WChar_U:
1194 llvm_unreachable(
"Invalid BuiltinType Kind!");
1198 ExpectedType ToOriginalTypeOrErr =
import(
T->getOriginalType());
1199 if (!ToOriginalTypeOrErr)
1200 return ToOriginalTypeOrErr.takeError();
1206 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1207 if (!ToElementTypeOrErr)
1208 return ToElementTypeOrErr.takeError();
1215 if (!ToPointeeTypeOrErr)
1216 return ToPointeeTypeOrErr.takeError();
1224 if (!ToPointeeTypeOrErr)
1225 return ToPointeeTypeOrErr.takeError();
1233 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1234 if (!ToPointeeTypeOrErr)
1235 return ToPointeeTypeOrErr.takeError();
1243 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1244 if (!ToPointeeTypeOrErr)
1245 return ToPointeeTypeOrErr.takeError();
1254 if (!ToPointeeTypeOrErr)
1255 return ToPointeeTypeOrErr.takeError();
1258 if (!ClassTypeOrErr)
1259 return ClassTypeOrErr.takeError();
1267 Error Err = Error::success();
1271 return std::move(Err);
1274 ToElementType,
T->getSize(), ToSizeExpr,
T->getSizeModifier(),
1275 T->getIndexTypeCVRQualifiers());
1281 if (!ToArrayTypeOrErr)
1282 return ToArrayTypeOrErr.takeError();
1289 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1290 if (!ToElementTypeOrErr)
1291 return ToElementTypeOrErr.takeError();
1294 T->getSizeModifier(),
1295 T->getIndexTypeCVRQualifiers());
1300 Error Err = Error::success();
1305 return std::move(Err);
1307 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1308 T->getIndexTypeCVRQualifiers(), ToBracketsRange);
1311ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(
1313 Error Err = Error::success();
1318 return std::move(Err);
1323 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1324 T->getIndexTypeCVRQualifiers(), ToBracketsRange);
1327ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType(
1329 Error Err = Error::success();
1334 return std::move(Err);
1336 ToElementType, ToSizeExpr, ToAttrLoc);
1340 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1341 if (!ToElementTypeOrErr)
1342 return ToElementTypeOrErr.takeError();
1345 T->getNumElements(),
1346 T->getVectorKind());
1350 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1351 if (!ToElementTypeOrErr)
1352 return ToElementTypeOrErr.takeError();
1355 T->getNumElements());
1363 if (!ToReturnTypeOrErr)
1364 return ToReturnTypeOrErr.takeError();
1373 if (!ToReturnTypeOrErr)
1374 return ToReturnTypeOrErr.takeError();
1381 return TyOrErr.takeError();
1382 ArgTypes.push_back(*TyOrErr);
1390 return TyOrErr.takeError();
1391 ExceptionTypes.push_back(*TyOrErr);
1395 Error Err = Error::success();
1412 return std::move(Err);
1415 *ToReturnTypeOrErr, ArgTypes, ToEPI);
1420 Error Err = Error::success();
1422 auto ToPrevD =
importChecked(Err,
T->getDecl()->getPreviousDecl());
1424 return std::move(Err);
1427 ToD, cast_or_null<TypeDecl>(ToPrevD));
1432 if (!ToInnerTypeOrErr)
1433 return ToInnerTypeOrErr.takeError();
1443 return Pattern.takeError();
1446 return Index.takeError();
1453 return ToDeclOrErr.takeError();
1460 if (!ToUnderlyingTypeOrErr)
1461 return ToUnderlyingTypeOrErr.takeError();
1469 return ToExprOrErr.takeError();
1474 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnmodifiedType());
1475 if (!ToUnderlyingTypeOrErr)
1476 return ToUnderlyingTypeOrErr.takeError();
1484 return FoundOrErr.takeError();
1486 if (!UnderlyingOrErr)
1487 return UnderlyingOrErr.takeError();
1496 return ToExprOrErr.takeError();
1498 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1499 if (!ToUnderlyingTypeOrErr)
1500 return ToUnderlyingTypeOrErr.takeError();
1503 *ToExprOrErr, *ToUnderlyingTypeOrErr);
1509 if (!ToBaseTypeOrErr)
1510 return ToBaseTypeOrErr.takeError();
1512 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1513 if (!ToUnderlyingTypeOrErr)
1514 return ToUnderlyingTypeOrErr.takeError();
1517 *ToBaseTypeOrErr, *ToUnderlyingTypeOrErr,
T->getUTTKind());
1522 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1523 if (!ToDeducedTypeOrErr)
1524 return ToDeducedTypeOrErr.takeError();
1526 ExpectedDecl ToTypeConstraintConcept =
import(
T->getTypeConstraintConcept());
1527 if (!ToTypeConstraintConcept)
1528 return ToTypeConstraintConcept.takeError();
1533 return std::move(Err);
1536 *ToDeducedTypeOrErr,
T->getKeyword(),
false,
1537 false, cast_or_null<ConceptDecl>(*ToTypeConstraintConcept),
1541ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
1545 if (!ToTemplateNameOrErr)
1546 return ToTemplateNameOrErr.takeError();
1547 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1548 if (!ToDeducedTypeOrErr)
1549 return ToDeducedTypeOrErr.takeError();
1555ExpectedType ASTNodeImporter::VisitInjectedClassNameType(
1559 return ToDeclOrErr.takeError();
1563 const Type *Ty = (*ToDeclOrErr)->getTypeForDecl();
1564 assert(isa_and_nonnull<InjectedClassNameType>(Ty));
1571 return ToDeclOrErr.takeError();
1579 return ToDeclOrErr.takeError();
1585 ExpectedType ToModifiedTypeOrErr =
import(
T->getModifiedType());
1586 if (!ToModifiedTypeOrErr)
1587 return ToModifiedTypeOrErr.takeError();
1588 ExpectedType ToEquivalentTypeOrErr =
import(
T->getEquivalentType());
1589 if (!ToEquivalentTypeOrErr)
1590 return ToEquivalentTypeOrErr.takeError();
1593 *ToModifiedTypeOrErr, *ToEquivalentTypeOrErr);
1599 if (!ToWrappedTypeOrErr)
1600 return ToWrappedTypeOrErr.takeError();
1602 Error Err = Error::success();
1609 return ToDeclOrErr.takeError();
1610 CoupledDecls.emplace_back(*ToDeclOrErr, TI.isDeref());
1614 *ToWrappedTypeOrErr, CountExpr,
T->isCountInBytes(),
T->isOrNull(),
1615 ArrayRef(CoupledDecls.data(), CoupledDecls.size()));
1618ExpectedType ASTNodeImporter::VisitTemplateTypeParmType(
1622 return ToDeclOrErr.takeError();
1625 T->getDepth(),
T->getIndex(),
T->isParameterPack(), *ToDeclOrErr);
1628ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmType(
1632 return ReplacedOrErr.takeError();
1634 ExpectedType ToReplacementTypeOrErr =
import(
T->getReplacementType());
1635 if (!ToReplacementTypeOrErr)
1636 return ToReplacementTypeOrErr.takeError();
1639 *ToReplacementTypeOrErr, *ReplacedOrErr,
T->getIndex(),
1643ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmPackType(
1647 return ReplacedOrErr.takeError();
1650 if (!ToArgumentPack)
1651 return ToArgumentPack.takeError();
1654 *ReplacedOrErr,
T->getIndex(),
T->getFinal(), *ToArgumentPack);
1657ExpectedType ASTNodeImporter::VisitTemplateSpecializationType(
1659 auto ToTemplateOrErr =
import(
T->getTemplateName());
1660 if (!ToTemplateOrErr)
1661 return ToTemplateOrErr.takeError();
1666 return std::move(Err);
1673 ToCanonType = *TyOrErr;
1675 return TyOrErr.takeError();
1684 auto ToQualifierOrErr =
import(
T->getQualifier());
1685 if (!ToQualifierOrErr)
1686 return ToQualifierOrErr.takeError();
1689 if (!ToNamedTypeOrErr)
1690 return ToNamedTypeOrErr.takeError();
1693 if (!ToOwnedTagDeclOrErr)
1694 return ToOwnedTagDeclOrErr.takeError();
1699 *ToOwnedTagDeclOrErr);
1705 if (!ToPatternOrErr)
1706 return ToPatternOrErr.takeError();
1709 T->getNumExpansions(),
1713ExpectedType ASTNodeImporter::VisitDependentTemplateSpecializationType(
1715 auto ToQualifierOrErr =
import(
T->getQualifier());
1716 if (!ToQualifierOrErr)
1717 return ToQualifierOrErr.takeError();
1722 ToPack.reserve(
T->template_arguments().size());
1724 return std::move(Err);
1727 T->getKeyword(), *ToQualifierOrErr, ToName, ToPack);
1732 auto ToQualifierOrErr =
import(
T->getQualifier());
1733 if (!ToQualifierOrErr)
1734 return ToQualifierOrErr.takeError();
1743 return TyOrErr.takeError();
1755 return ToDeclOrErr.takeError();
1762 if (!ToBaseTypeOrErr)
1763 return ToBaseTypeOrErr.takeError();
1766 for (
auto TypeArg :
T->getTypeArgsAsWritten()) {
1768 TypeArgs.push_back(*TyOrErr);
1770 return TyOrErr.takeError();
1774 for (
auto *
P :
T->quals()) {
1776 Protocols.push_back(*ProtocolOrErr);
1778 return ProtocolOrErr.takeError();
1784 T->isKindOfTypeAsWritten());
1790 if (!ToPointeeTypeOrErr)
1791 return ToPointeeTypeOrErr.takeError();
1798 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1799 if (!ToUnderlyingTypeOrErr)
1800 return ToUnderlyingTypeOrErr.takeError();
1808 Error Err = Error::success();
1809 QualType ToOriginalType = importChecked(Err,
T->getOriginalType());
1810 QualType ToAdjustedType = importChecked(Err,
T->getAdjustedType());
1812 return std::move(Err);
1814 return Importer.getToContext().getAdjustedType(ToOriginalType,
1819 return Importer.getToContext().getBitIntType(
T->isUnsigned(),
1823ExpectedType clang::ASTNodeImporter::VisitBTFTagAttributedType(
1825 Error Err = Error::success();
1826 const BTFTypeTagAttr *ToBTFAttr = importChecked(Err,
T->getAttr());
1827 QualType ToWrappedType = importChecked(Err,
T->getWrappedType());
1829 return std::move(Err);
1831 return Importer.getToContext().getBTFTagAttributedType(ToBTFAttr,
1835ExpectedType clang::ASTNodeImporter::VisitConstantMatrixType(
1837 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1838 if (!ToElementTypeOrErr)
1839 return ToElementTypeOrErr.takeError();
1841 return Importer.getToContext().getConstantMatrixType(
1842 *ToElementTypeOrErr,
T->getNumRows(),
T->getNumColumns());
1845ExpectedType clang::ASTNodeImporter::VisitDependentAddressSpaceType(
1847 Error Err = Error::success();
1849 Expr *ToAddrSpaceExpr = importChecked(Err,
T->getAddrSpaceExpr());
1852 return std::move(Err);
1854 return Importer.getToContext().getDependentAddressSpaceType(
1855 ToPointeeType, ToAddrSpaceExpr, ToAttrLoc);
1858ExpectedType clang::ASTNodeImporter::VisitDependentBitIntType(
1860 ExpectedExpr ToNumBitsExprOrErr =
import(
T->getNumBitsExpr());
1861 if (!ToNumBitsExprOrErr)
1862 return ToNumBitsExprOrErr.takeError();
1863 return Importer.getToContext().getDependentBitIntType(
T->isUnsigned(),
1864 *ToNumBitsExprOrErr);
1867ExpectedType clang::ASTNodeImporter::VisitDependentSizedMatrixType(
1869 Error Err = Error::success();
1870 QualType ToElementType = importChecked(Err,
T->getElementType());
1871 Expr *ToRowExpr = importChecked(Err,
T->getRowExpr());
1872 Expr *ToColumnExpr = importChecked(Err,
T->getColumnExpr());
1875 return std::move(Err);
1877 return Importer.getToContext().getDependentSizedMatrixType(
1878 ToElementType, ToRowExpr, ToColumnExpr, ToAttrLoc);
1881ExpectedType clang::ASTNodeImporter::VisitDependentVectorType(
1883 Error Err = Error::success();
1884 QualType ToElementType = importChecked(Err,
T->getElementType());
1885 Expr *ToSizeExpr = importChecked(Err,
T->getSizeExpr());
1888 return std::move(Err);
1890 return Importer.getToContext().getDependentVectorType(
1891 ToElementType, ToSizeExpr, ToAttrLoc,
T->getVectorKind());
1894ExpectedType clang::ASTNodeImporter::VisitObjCTypeParamType(
1898 return ToDeclOrErr.takeError();
1903 if (!ToProtocolOrErr)
1904 return ToProtocolOrErr.takeError();
1905 ToProtocols.push_back(*ToProtocolOrErr);
1908 return Importer.getToContext().getObjCTypeParamType(*ToDeclOrErr,
1913 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1914 if (!ToElementTypeOrErr)
1915 return ToElementTypeOrErr.takeError();
1918 if (
T->isReadOnly())
1938 if (isa<RecordDecl>(
D) && (FunDecl = dyn_cast<FunctionDecl>(OrigDC)) &&
1940 auto getLeafPointeeType = [](
const Type *
T) {
1948 getLeafPointeeType(
P->getType().getCanonicalType().getTypePtr());
1949 auto *RT = dyn_cast<RecordType>(LeafT);
1950 if (RT && RT->getDecl() ==
D) {
1963 if (Error Err = importInto(Name,
D->getDeclName()))
1975 return Error::success();
1982 if (Error Err = importInto(Name,
D->getDeclName()))
1994 return Error::success();
1999 return Error::success();
2002 if (Error Err = importInto(ToD, FromD))
2005 if (
RecordDecl *FromRecord = dyn_cast<RecordDecl>(FromD)) {
2006 if (
RecordDecl *ToRecord = cast<RecordDecl>(ToD)) {
2007 if (FromRecord->getDefinition() && FromRecord->isCompleteDefinition() &&
2008 !ToRecord->getDefinition()) {
2013 return Error::success();
2016 if (
EnumDecl *FromEnum = dyn_cast<EnumDecl>(FromD)) {
2017 if (
EnumDecl *ToEnum = cast<EnumDecl>(ToD)) {
2018 if (FromEnum->getDefinition() && !ToEnum->getDefinition()) {
2023 return Error::success();
2026 return Error::success();
2041 return Error::success();
2047 return ToRangeOrErr.takeError();
2048 return Error::success();
2054 return LocOrErr.takeError();
2055 return Error::success();
2063 return ToTInfoOrErr.takeError();
2064 return Error::success();
2067 llvm_unreachable(
"Unknown name kind.");
2074 return ToDCOrErr.takeError();
2088 auto MightNeedReordering = [](
const Decl *
D) {
2089 return isa<FieldDecl>(
D) || isa<IndirectFieldDecl>(
D) || isa<FriendDecl>(
D);
2093 Error ChildErrors = Error::success();
2094 for (
auto *From : FromDC->
decls()) {
2095 if (!MightNeedReordering(From))
2104 if (!ImportedOrErr) {
2106 ImportedOrErr.takeError());
2109 FieldDecl *FieldFrom = dyn_cast_or_null<FieldDecl>(From);
2110 Decl *ImportedDecl = *ImportedOrErr;
2111 FieldDecl *FieldTo = dyn_cast_or_null<FieldDecl>(ImportedDecl);
2112 if (FieldFrom && FieldTo) {
2144 consumeError(std::move(ChildErrors));
2145 return ToDCOrErr.takeError();
2148 if (
const auto *FromRD = dyn_cast<RecordDecl>(FromDC)) {
2152 for (
auto *
D : FromRD->decls()) {
2153 if (!MightNeedReordering(
D))
2156 assert(
D &&
"DC contains a null decl");
2159 assert(ToDC == ToD->getLexicalDeclContext() && ToDC->
containsDecl(ToD));
2171 for (
auto *From : FromDC->
decls()) {
2172 if (MightNeedReordering(From))
2178 ImportedOrErr.takeError());
2198 if (!FromRecordDecl || !ToRecordDecl) {
2202 if (RecordFrom && RecordTo) {
2203 FromRecordDecl = RecordFrom->
getDecl();
2204 ToRecordDecl = RecordTo->getDecl();
2208 if (FromRecordDecl && ToRecordDecl) {
2214 return Error::success();
2221 return ToDCOrErr.takeError();
2227 if (!ToLexicalDCOrErr)
2228 return ToLexicalDCOrErr.takeError();
2229 ToLexicalDC = *ToLexicalDCOrErr;
2233 return Error::success();
2239 "Import implicit methods to or from non-definition");
2242 if (FromM->isImplicit()) {
2245 return ToMOrErr.takeError();
2248 return Error::success();
2257 return ToTypedefOrErr.takeError();
2259 return Error::success();
2264 auto DefinitionCompleter = [To]() {
2283 auto *FromCXXRD = cast<CXXRecordDecl>(From);
2285 ToCaptures.reserve(FromCXXRD->capture_size());
2286 for (
const auto &FromCapture : FromCXXRD->captures()) {
2287 if (
auto ToCaptureOrErr =
import(FromCapture))
2288 ToCaptures.push_back(*ToCaptureOrErr);
2290 return ToCaptureOrErr.takeError();
2292 cast<CXXRecordDecl>(To)->setCaptures(Importer.
getToContext(),
2299 DefinitionCompleter();
2303 return Error::success();
2318 auto DefinitionCompleterScopeExit =
2319 llvm::make_scope_exit(DefinitionCompleter);
2325 auto *ToCXX = dyn_cast<CXXRecordDecl>(To);
2326 auto *FromCXX = dyn_cast<CXXRecordDecl>(From);
2327 if (ToCXX && FromCXX && ToCXX->dataPtr() && FromCXX->dataPtr()) {
2329 struct CXXRecordDecl::DefinitionData &ToData = ToCXX->data();
2330 struct CXXRecordDecl::DefinitionData &FromData = FromCXX->data();
2332 #define FIELD(Name, Width, Merge) \
2333 ToData.Name = FromData.Name;
2334 #include "clang/AST/CXXRecordDeclDefinitionBits.def"
2337 ToCXX->setArgPassingRestrictions(FromCXX->getArgPassingRestrictions());
2340 for (
const auto &Base1 : FromCXX->bases()) {
2343 return TyOrErr.takeError();
2346 if (Base1.isPackExpansion()) {
2347 if (
ExpectedSLoc LocOrErr =
import(Base1.getEllipsisLoc()))
2348 EllipsisLoc = *LocOrErr;
2350 return LocOrErr.takeError();
2358 auto RangeOrErr =
import(Base1.getSourceRange());
2360 return RangeOrErr.takeError();
2362 auto TSIOrErr =
import(Base1.getTypeSourceInfo());
2364 return TSIOrErr.takeError();
2370 Base1.isBaseOfClass(),
2371 Base1.getAccessSpecifierAsWritten(),
2376 ToCXX->setBases(Bases.data(), Bases.size());
2384 return Error::success();
2389 return Error::success();
2393 return Error::success();
2397 return ToInitOrErr.takeError();
2408 return Error::success();
2416 return Error::success();
2427 return ToTypeOrErr.takeError();
2430 if (!ToPromotionTypeOrErr)
2431 return ToPromotionTypeOrErr.takeError();
2442 return Error::success();
2448 for (
const auto &Arg : FromArgs) {
2449 if (
auto ToOrErr =
import(Arg))
2450 ToArgs.push_back(*ToOrErr);
2452 return ToOrErr.takeError();
2455 return Error::success();
2461 return import(From);
2464template <
typename InContainerTy>
2467 for (
const auto &FromLoc : Container) {
2468 if (
auto ToLocOrErr =
import(FromLoc))
2471 return ToLocOrErr.takeError();
2473 return Error::success();
2483 bool IgnoreTemplateParmDepth) {
2494 false, Complain,
false,
2495 IgnoreTemplateParmDepth);
2515 return std::move(Err);
2520 return LocOrErr.takeError();
2523 if (GetImportedOrCreateDecl(ToD,
D, Importer.
getToContext(), DC, *LocOrErr))
2546 return std::move(Err);
2552 Name.getAsIdentifierInfo()))
2555 Error Err = Error::success();
2560 return std::move(Err);
2564 addDeclToContexts(
D, ToD);
2572 return LocOrErr.takeError();
2573 auto ColonLocOrErr =
import(
D->getColonLoc());
2575 return ColonLocOrErr.takeError();
2580 return DCOrErr.takeError();
2585 DC, *LocOrErr, *ColonLocOrErr))
2599 return DCOrErr.takeError();
2603 Error Err = Error::success();
2609 return std::move(Err);
2612 if (GetImportedOrCreateDecl(
2613 ToD,
D, Importer.
getToContext(), DC, ToLocation, ToAssertExpr, ToMessage,
2614 ToRParenLoc,
D->isFailed()))
2629 return std::move(Err);
2638 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2644 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2645 for (
auto *FoundDecl : FoundDecls) {
2649 if (
auto *FoundNS = dyn_cast<NamespaceDecl>(FoundDecl)) {
2650 MergeWithNamespace = FoundNS;
2651 ConflictingDecls.clear();
2655 ConflictingDecls.push_back(FoundDecl);
2658 if (!ConflictingDecls.empty()) {
2661 ConflictingDecls.size());
2663 Name = NameOrErr.get();
2665 return NameOrErr.takeError();
2671 return BeginLocOrErr.takeError();
2673 if (!RBraceLocOrErr)
2674 return RBraceLocOrErr.takeError();
2679 if (GetImportedOrCreateDecl(ToNamespace,
D, Importer.
getToContext(), DC,
2680 D->isInline(), *BeginLocOrErr,
Loc,
2681 Name.getAsIdentifierInfo(),
2682 nullptr,
D->isNested()))
2691 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2692 TU->setAnonymousNamespace(ToNamespace);
2694 cast<NamespaceDecl>(DC)->setAnonymousNamespace(ToNamespace);
2700 return std::move(Err);
2712 return std::move(Err);
2718 Error Err = Error::success();
2722 auto ToTargetNameLoc =
importChecked(Err,
D->getTargetNameLoc());
2725 return std::move(Err);
2730 if (GetImportedOrCreateDecl(
2731 ToD,
D, Importer.
getToContext(), DC, ToNamespaceLoc, ToAliasLoc,
2732 ToIdentifier, ToQualifierLoc, ToTargetNameLoc, ToNamespace))
2750 return std::move(Err);
2769 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2770 for (
auto *FoundDecl : FoundDecls) {
2773 if (
auto *FoundTypedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
2777 QualType FromUT =
D->getUnderlyingType();
2778 QualType FoundUT = FoundTypedef->getUnderlyingType();
2792 if (FromR && FoundR &&
2803 ConflictingDecls.push_back(FoundDecl);
2808 if (!ConflictingDecls.empty()) {
2810 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
2812 Name = NameOrErr.get();
2814 return NameOrErr.takeError();
2818 Error Err = Error::success();
2820 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
2823 return std::move(Err);
2830 if (GetImportedOrCreateDecl<TypeAliasDecl>(
2832 Name.getAsIdentifierInfo(), ToTypeSourceInfo))
2834 }
else if (GetImportedOrCreateDecl<TypedefDecl>(
2836 Name.getAsIdentifierInfo(), ToTypeSourceInfo))
2841 return std::move(Err);
2845 Importer.AddToLookupTable(ToTypedef);
2850 TypeAliasDecl *FromAlias = IsAlias ? cast<TypeAliasDecl>(
D) :
nullptr;
2873 return std::move(Err);
2883 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2884 for (
auto *FoundDecl : FoundDecls) {
2887 if (
auto *FoundAlias = dyn_cast<TypeAliasTemplateDecl>(FoundDecl)) {
2890 ConflictingDecls.push_back(FoundDecl);
2894 if (!ConflictingDecls.empty()) {
2896 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
2898 Name = NameOrErr.get();
2900 return NameOrErr.takeError();
2904 Error Err = Error::success();
2905 auto ToTemplateParameters =
importChecked(Err,
D->getTemplateParameters());
2906 auto ToTemplatedDecl =
importChecked(Err,
D->getTemplatedDecl());
2908 return std::move(Err);
2912 Name, ToTemplateParameters, ToTemplatedDecl))
2915 ToTemplatedDecl->setDescribedAliasTemplate(ToAlias);
2921 updateLookupTableForTemplateParameters(*ToTemplateParameters);
2932 return std::move(Err);
2939 if (
D->isGnuLocal()) {
2942 return BeginLocOrErr.takeError();
2944 Name.getAsIdentifierInfo(), *BeginLocOrErr))
2949 Name.getAsIdentifierInfo()))
2956 return ToStmtOrErr.takeError();
2958 ToLabel->
setStmt(*ToStmtOrErr);
2971 return std::move(Err);
2978 if (!SearchName &&
D->getTypedefNameForAnonDecl()) {
2979 if (Error Err = importInto(
2980 SearchName,
D->getTypedefNameForAnonDecl()->getDeclName()))
2981 return std::move(Err);
2991 Importer.findDeclsInToCtx(DC, SearchName);
2992 for (
auto *FoundDecl : FoundDecls) {
2996 if (
auto *Typedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
2997 if (
const auto *Tag = Typedef->getUnderlyingType()->getAs<
TagType>())
2998 FoundDecl = Tag->getDecl();
3001 if (
auto *FoundEnum = dyn_cast<EnumDecl>(FoundDecl)) {
3006 if (
D->isThisDeclarationADefinition() && FoundDef)
3011 ConflictingDecls.push_back(FoundDecl);
3020 if (SearchName && !ConflictingDecls.empty()) {
3022 SearchName, DC, IDNS, ConflictingDecls.data(),
3023 ConflictingDecls.size());
3025 Name = NameOrErr.get();
3027 return NameOrErr.takeError();
3031 Error Err = Error::success();
3037 return std::move(Err);
3041 if (GetImportedOrCreateDecl(
3043 Loc, Name.getAsIdentifierInfo(), PrevDecl,
D->isScoped(),
3044 D->isScopedUsingClassTag(),
D->isFixed()))
3052 addDeclToContexts(
D, D2);
3056 EnumDecl *FromInst =
D->getInstantiatedFromMemberEnum();
3058 D2->setInstantiationOfMemberEnum(*ToInstOrErr, SK);
3060 return ToInstOrErr.takeError();
3061 if (
ExpectedSLoc POIOrErr =
import(MemberInfo->getPointOfInstantiation()))
3064 return POIOrErr.takeError();
3068 if (
D->isCompleteDefinition())
3070 return std::move(Err);
3076 bool IsFriendTemplate =
false;
3077 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(
D)) {
3079 DCXX->getDescribedClassTemplate() &&
3080 DCXX->getDescribedClassTemplate()->getFriendObjectKind() !=
3090 return std::move(Err);
3097 if (!SearchName &&
D->getTypedefNameForAnonDecl()) {
3098 if (Error Err = importInto(
3099 SearchName,
D->getTypedefNameForAnonDecl()->getDeclName()))
3100 return std::move(Err);
3107 bool DependentFriend = IsFriendTemplate && IsDependentContext;
3114 Importer.findDeclsInToCtx(DC, SearchName);
3115 if (!FoundDecls.empty()) {
3118 if (
D->hasExternalLexicalStorage() && !
D->isCompleteDefinition())
3122 for (
auto *FoundDecl : FoundDecls) {
3127 if (
auto *Typedef = dyn_cast<TypedefNameDecl>(
Found)) {
3128 if (
const auto *Tag = Typedef->getUnderlyingType()->getAs<
TagType>())
3129 Found = Tag->getDecl();
3132 if (
auto *FoundRecord = dyn_cast<RecordDecl>(
Found)) {
3151 if (
D->isThisDeclarationADefinition() && FoundDef) {
3155 if (
const auto *DCXX = dyn_cast<CXXRecordDecl>(
D)) {
3156 auto *FoundCXX = dyn_cast<CXXRecordDecl>(FoundDef);
3157 assert(FoundCXX &&
"Record type mismatch");
3163 return std::move(Err);
3169 ConflictingDecls.push_back(FoundDecl);
3173 if (!ConflictingDecls.empty() && SearchName) {
3175 SearchName, DC, IDNS, ConflictingDecls.data(),
3176 ConflictingDecls.size());
3178 Name = NameOrErr.get();
3180 return NameOrErr.takeError();
3186 return BeginLocOrErr.takeError();
3191 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(
D)) {
3192 if (DCXX->isLambda()) {
3193 auto TInfoOrErr =
import(DCXX->getLambdaTypeInfo());
3195 return TInfoOrErr.takeError();
3196 if (GetImportedOrCreateSpecialDecl(
3198 DC, *TInfoOrErr,
Loc, DCXX->getLambdaDependencyKind(),
3199 DCXX->isGenericLambda(), DCXX->getLambdaCaptureDefault()))
3204 return CDeclOrErr.takeError();
3207 }
else if (DCXX->isInjectedClassName()) {
3210 const bool DelayTypeCreation =
true;
3211 if (GetImportedOrCreateDecl(
3213 *BeginLocOrErr,
Loc, Name.getAsIdentifierInfo(),
3214 cast_or_null<CXXRecordDecl>(PrevDecl), DelayTypeCreation))
3217 D2CXX, dyn_cast<CXXRecordDecl>(DC));
3219 if (GetImportedOrCreateDecl(D2CXX,
D, Importer.
getToContext(),
3220 D->getTagKind(), DC, *BeginLocOrErr,
Loc,
3221 Name.getAsIdentifierInfo(),
3222 cast_or_null<CXXRecordDecl>(PrevDecl)))
3229 addDeclToContexts(
D, D2);
3232 DCXX->getDescribedClassTemplate()) {
3234 if (Error Err = importInto(ToDescribed, FromDescribed))
3235 return std::move(Err);
3237 if (!DCXX->isInjectedClassName() && !IsFriendTemplate) {
3257 const Type *FrontTy =
3258 cast<CXXRecordDecl>(Redecls.front())->getTypeForDecl();
3261 InjSpec = InjTy->getInjectedSpecializationType();
3264 for (
auto *R : Redecls) {
3265 auto *RI = cast<CXXRecordDecl>(R);
3266 if (R != Redecls.front() ||
3267 !isa<InjectedClassNameType>(RI->getTypeForDecl()))
3268 RI->setTypeForDecl(
nullptr);
3283 DCXX->getMemberSpecializationInfo()) {
3285 MemberInfo->getTemplateSpecializationKind();
3291 return ToInstOrErr.takeError();
3294 import(MemberInfo->getPointOfInstantiation()))
3298 return POIOrErr.takeError();
3303 D->getTagKind(), DC, *BeginLocOrErr,
Loc,
3304 Name.getAsIdentifierInfo(), PrevDecl))
3307 addDeclToContexts(
D, D2);
3310 if (
auto BraceRangeOrErr =
import(
D->getBraceRange()))
3313 return BraceRangeOrErr.takeError();
3314 if (
auto QualifierLocOrErr =
import(
D->getQualifierLoc()))
3317 return QualifierLocOrErr.takeError();
3319 if (
D->isAnonymousStructOrUnion())
3322 if (
D->isCompleteDefinition())
3324 return std::move(Err);
3336 return std::move(Err);
3345 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3346 for (
auto *FoundDecl : FoundDecls) {
3350 if (
auto *FoundEnumConstant = dyn_cast<EnumConstantDecl>(FoundDecl)) {
3353 ConflictingDecls.push_back(FoundDecl);
3357 if (!ConflictingDecls.empty()) {
3359 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3361 Name = NameOrErr.get();
3363 return NameOrErr.takeError();
3369 return TypeOrErr.takeError();
3373 return InitOrErr.takeError();
3376 if (GetImportedOrCreateDecl(
3378 Name.getAsIdentifierInfo(), *TypeOrErr, *InitOrErr,
D->getInitVal()))
3379 return ToEnumerator;
3384 return ToEnumerator;
3387template <
typename DeclTy>
3390 unsigned int Num = FromD->getNumTemplateParameterLists();
3392 return Error::success();
3394 for (
unsigned int I = 0; I < Num; ++I)
3396 import(FromD->getTemplateParameterList(I)))
3397 ToTPLists[I] = *ToTPListOrErr;
3399 return ToTPListOrErr.takeError();
3400 ToD->setTemplateParameterListsInfo(Importer.ToContext, ToTPLists);
3401 return Error::success();
3409 return Error::success();
3415 return Error::success();
3421 ToFD->setInstantiationOfMemberFunction(*InstFDOrErr, TSK);
3423 return InstFDOrErr.takeError();
3429 return POIOrErr.takeError();
3431 return Error::success();
3435 auto FunctionAndArgsOrErr =
3437 if (!FunctionAndArgsOrErr)
3438 return FunctionAndArgsOrErr.takeError();
3441 Importer.
getToContext(), std::get<1>(*FunctionAndArgsOrErr));
3445 const auto *FromTAArgsAsWritten = FTSInfo->TemplateArgumentsAsWritten;
3446 if (FromTAArgsAsWritten)
3448 *FromTAArgsAsWritten, ToTAInfo))
3451 ExpectedSLoc POIOrErr =
import(FTSInfo->getPointOfInstantiation());
3453 return POIOrErr.takeError();
3459 ToFD->setFunctionTemplateSpecialization(
3460 std::get<0>(*FunctionAndArgsOrErr), ToTAList,
nullptr,
3461 TSK, FromTAArgsAsWritten ? &ToTAInfo :
nullptr, *POIOrErr);
3462 return Error::success();
3470 Candidates.
addDecl(*ToFTDOrErr);
3472 return ToFTDOrErr.takeError();
3477 const auto *FromTAArgsAsWritten = FromInfo->TemplateArgumentsAsWritten;
3478 if (FromTAArgsAsWritten)
3485 FromTAArgsAsWritten ? &ToTAInfo :
nullptr);
3486 return Error::success();
3489 llvm_unreachable(
"All cases should be covered!");
3494 auto FunctionAndArgsOrErr =
3496 if (!FunctionAndArgsOrErr)
3497 return FunctionAndArgsOrErr.takeError();
3501 std::tie(Template, ToTemplArgs) = *FunctionAndArgsOrErr;
3502 void *InsertPos =
nullptr;
3513 return ToBodyOrErr.takeError();
3515 return Error::success();
3524 assert(DCi &&
"Declaration should have a context");
3538 ToProcess.push_back(S);
3539 while (!ToProcess.empty()) {
3540 const Stmt *CurrentS = ToProcess.pop_back_val();
3542 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(CurrentS)) {
3543 if (
const Decl *
D = DeclRef->getDecl())
3546 }
else if (
const auto *
E =
3547 dyn_cast_or_null<SubstNonTypeTemplateParmExpr>(CurrentS)) {
3548 if (
const Decl *
D =
E->getAssociatedDecl())
3581class IsTypeDeclaredInsideVisitor
3582 :
public TypeVisitor<IsTypeDeclaredInsideVisitor, std::optional<bool>> {
3584 IsTypeDeclaredInsideVisitor(
const FunctionDecl *ParentDC)
3585 : ParentDC(ParentDC) {}
3591 if (std::optional<bool> Res = Visit(
T.getTypePtr()))
3594 T.getSingleStepDesugaredType(ParentDC->getParentASTContext());
3596 if (std::optional<bool> Res = Visit(DsT.
getTypePtr()))
3599 DsT =
T.getSingleStepDesugaredType(ParentDC->getParentASTContext());
3604 std::optional<bool> VisitTagType(
const TagType *
T) {
3605 if (
auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(
T->getDecl()))
3606 for (
const auto &Arg : Spec->getTemplateArgs().asArray())
3607 if (checkTemplateArgument(Arg))
3612 std::optional<bool> VisitPointerType(
const PointerType *
T) {
3617 return CheckType(
T->getPointeeTypeAsWritten());
3620 std::optional<bool> VisitTypedefType(
const TypedefType *
T) {
3626 std::optional<bool> VisitUsingType(
const UsingType *
T) {
3627 if (
T->getFoundDecl() &&
3636 for (
const auto &Arg :
T->template_arguments())
3637 if (checkTemplateArgument(Arg))
3644 return CheckType(
T->getBaseType());
3659 return CheckType(
T->getElementType());
3664 "Variable array should not occur in deduced return type of a function");
3668 llvm_unreachable(
"Incomplete array should not occur in deduced return type "
3673 llvm_unreachable(
"Dependent array should not occur in deduced return type "
3700 if (checkTemplateArgument(PackArg))
3712 llvm_unreachable(
"Unknown TemplateArgument::ArgKind enum");
3722 assert(FromFPT &&
"Must be called on FunctionProtoType");
3724 auto IsCXX11Lambda = [&]() {
3725 if (Importer.FromContext.
getLangOpts().CPlusPlus14)
3728 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
D))
3729 return cast<CXXRecordDecl>(MD->getDeclContext())->isLambda();
3734 QualType RetT = FromFPT->getReturnType();
3735 if (isa<AutoType>(RetT.
getTypePtr()) || IsCXX11Lambda()) {
3737 IsTypeDeclaredInsideVisitor Visitor(Def ? Def :
D);
3738 return Visitor.CheckType(RetT);
3755 auto RedeclIt = Redecls.begin();
3758 for (; RedeclIt != Redecls.end() && *RedeclIt !=
D; ++RedeclIt) {
3761 return ToRedeclOrErr.takeError();
3763 assert(*RedeclIt ==
D);
3771 return std::move(Err);
3783 if (
D->getTemplatedKind() ==
3786 if (!FoundFunctionOrErr)
3787 return FoundFunctionOrErr.takeError();
3788 if (
FunctionDecl *FoundFunction = *FoundFunctionOrErr) {
3789 if (
Decl *Def = FindAndMapDefinition(
D, FoundFunction))
3791 FoundByLookup = FoundFunction;
3799 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3800 for (
auto *FoundDecl : FoundDecls) {
3804 if (
auto *FoundFunction = dyn_cast<FunctionDecl>(FoundDecl)) {
3809 if (
Decl *Def = FindAndMapDefinition(
D, FoundFunction))
3811 FoundByLookup = FoundFunction;
3822 Importer.
ToDiag(
Loc, diag::warn_odr_function_type_inconsistent)
3823 << Name <<
D->getType() << FoundFunction->getType();
3824 Importer.
ToDiag(FoundFunction->getLocation(), diag::note_odr_value_here)
3825 << FoundFunction->getType();
3826 ConflictingDecls.push_back(FoundDecl);
3830 if (!ConflictingDecls.empty()) {
3832 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3834 Name = NameOrErr.get();
3836 return NameOrErr.takeError();
3846 if (FoundByLookup) {
3847 if (isa<CXXMethodDecl>(FoundByLookup)) {
3849 if (!
D->doesThisDeclarationHaveABody()) {
3851 D->getDescribedFunctionTemplate()) {
3856 "Templated function mapped to non-templated?");
3872 return std::move(Err);
3883 bool UsedDifferentProtoType =
false;
3885 QualType FromReturnTy = FromFPT->getReturnType();
3893 UsedDifferentProtoType =
true;
3904 FromEPI = DefaultEPI;
3905 UsedDifferentProtoType =
true;
3908 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
3913 Error Err = Error::success();
3916 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
3920 auto TrailingRequiresClause =
3923 return std::move(Err);
3927 for (
auto *
P :
D->parameters()) {
3929 Parameters.push_back(*ToPOrErr);
3931 return ToPOrErr.takeError();
3936 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(
D)) {
3938 importExplicitSpecifier(Err, FromConstructor->getExplicitSpecifier());
3940 return std::move(Err);
3942 if (FromConstructor->isInheritingConstructor()) {
3944 import(FromConstructor->getInheritedConstructor());
3945 if (!ImportedInheritedCtor)
3946 return ImportedInheritedCtor.takeError();
3947 ToInheritedConstructor = *ImportedInheritedCtor;
3949 if (GetImportedOrCreateDecl<CXXConstructorDecl>(
3950 ToFunction,
D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3951 ToInnerLocStart, NameInfo,
T, TInfo, ESpec,
D->UsesFPIntrin(),
3952 D->isInlineSpecified(),
D->
isImplicit(),
D->getConstexprKind(),
3953 ToInheritedConstructor, TrailingRequiresClause))
3957 Error Err = Error::success();
3959 Err,
const_cast<FunctionDecl *
>(FromDtor->getOperatorDelete()));
3960 auto ToThisArg =
importChecked(Err, FromDtor->getOperatorDeleteThisArg());
3962 return std::move(Err);
3964 if (GetImportedOrCreateDecl<CXXDestructorDecl>(
3965 ToFunction,
D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3966 ToInnerLocStart, NameInfo,
T, TInfo,
D->UsesFPIntrin(),
3967 D->isInlineSpecified(),
D->
isImplicit(),
D->getConstexprKind(),
3968 TrailingRequiresClause))
3975 dyn_cast<CXXConversionDecl>(
D)) {
3977 importExplicitSpecifier(Err, FromConversion->getExplicitSpecifier());
3979 return std::move(Err);
3980 if (GetImportedOrCreateDecl<CXXConversionDecl>(
3981 ToFunction,
D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3982 ToInnerLocStart, NameInfo,
T, TInfo,
D->UsesFPIntrin(),
3983 D->isInlineSpecified(), ESpec,
D->getConstexprKind(),
3986 }
else if (
auto *Method = dyn_cast<CXXMethodDecl>(
D)) {
3987 if (GetImportedOrCreateDecl<CXXMethodDecl>(
3988 ToFunction,
D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3989 ToInnerLocStart, NameInfo,
T, TInfo, Method->getStorageClass(),
3990 Method->UsesFPIntrin(), Method->isInlineSpecified(),
3993 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(
D)) {
3995 importExplicitSpecifier(Err, Guide->getExplicitSpecifier());
3999 return std::move(Err);
4000 if (GetImportedOrCreateDecl<CXXDeductionGuideDecl>(
4001 ToFunction,
D, Importer.
getToContext(), DC, ToInnerLocStart, ESpec,
4002 NameInfo,
T, TInfo, ToEndLoc, Ctor))
4004 cast<CXXDeductionGuideDecl>(ToFunction)
4005 ->setDeductionCandidateKind(Guide->getDeductionCandidateKind());
4007 if (GetImportedOrCreateDecl(
4008 ToFunction,
D, Importer.
getToContext(), DC, ToInnerLocStart,
4009 NameInfo,
T, TInfo,
D->getStorageClass(),
D->UsesFPIntrin(),
4010 D->isInlineSpecified(),
D->hasWrittenPrototype(),
4011 D->getConstexprKind(), TrailingRequiresClause))
4016 if (FoundByLookup) {
4029 auto Imported =
import(Msg);
4031 return Imported.takeError();
4045 D->FriendConstraintRefersToEnclosingTemplate());
4055 for (
auto *Param : Parameters) {
4056 Param->setOwningFunction(ToFunction);
4061 ToFunction->setParams(Parameters);
4068 for (
unsigned I = 0, N = Parameters.size(); I != N; ++I)
4069 ProtoLoc.setParam(I, Parameters[I]);
4075 auto ToFTOrErr =
import(FromFT);
4077 return ToFTOrErr.takeError();
4081 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(
D)) {
4082 if (
unsigned NumInitializers = FromConstructor->getNumCtorInitializers()) {
4086 FromConstructor->inits(), CtorInitializers))
4087 return std::move(Err);
4090 std::copy(CtorInitializers.begin(), CtorInitializers.end(), Memory);
4091 auto *ToCtor = cast<CXXConstructorDecl>(ToFunction);
4092 ToCtor->setCtorInitializers(Memory);
4093 ToCtor->setNumCtorInitializers(NumInitializers);
4099 return std::move(Err);
4101 if (
auto *FromCXXMethod = dyn_cast<CXXMethodDecl>(
D))
4104 return std::move(Err);
4106 if (
D->doesThisDeclarationHaveABody()) {
4110 return std::move(Err);
4114 if (UsedDifferentProtoType) {
4116 ToFunction->
setType(*TyOrErr);
4118 return TyOrErr.takeError();
4122 return TSIOrErr.takeError();
4127 addDeclToContexts(
D, ToFunction);
4130 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4133 return ToRedeclOrErr.takeError();
4167 return std::move(Err);
4172 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4173 for (
auto *FoundDecl : FoundDecls) {
4174 if (
FieldDecl *FoundField = dyn_cast<FieldDecl>(FoundDecl)) {
4182 FoundField->getType())) {
4190 if (
Expr *FromInitializer =
D->getInClassInitializer()) {
4191 if (
ExpectedExpr ToInitializerOrErr =
import(FromInitializer)) {
4194 assert(FoundField->hasInClassInitializer() &&
4195 "Field should have an in-class initializer if it has an "
4196 "expression for it.");
4197 if (!FoundField->getInClassInitializer())
4198 FoundField->setInClassInitializer(*ToInitializerOrErr);
4200 return ToInitializerOrErr.takeError();
4207 Importer.
ToDiag(
Loc, diag::warn_odr_field_type_inconsistent)
4208 << Name <<
D->getType() << FoundField->getType();
4209 Importer.
ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4210 << FoundField->getType();
4216 Error Err = Error::success();
4220 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
4222 return std::move(Err);
4223 const Type *ToCapturedVLAType =
nullptr;
4225 ToCapturedVLAType, cast_or_null<Type>(
D->getCapturedVLAType())))
4226 return std::move(Err);
4229 if (GetImportedOrCreateDecl(ToField,
D, Importer.
getToContext(), DC,
4230 ToInnerLocStart,
Loc, Name.getAsIdentifierInfo(),
4231 ToType, ToTInfo, ToBitWidth,
D->isMutable(),
4232 D->getInClassInitStyle()))
4238 if (ToCapturedVLAType)
4243 auto ToInitializer =
importChecked(Err,
D->getInClassInitializer());
4245 return std::move(Err);
4246 if (ToInitializer) {
4248 if (AlreadyImported)
4249 assert(ToInitializer == AlreadyImported &&
4250 "Duplicate import of in-class initializer.");
4265 return std::move(Err);
4270 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4271 for (
unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
4272 if (
auto *FoundField = dyn_cast<IndirectFieldDecl>(FoundDecls[I])) {
4280 FoundField->getType(),
4287 if (!Name && I < N-1)
4291 Importer.
ToDiag(
Loc, diag::warn_odr_field_type_inconsistent)
4292 << Name <<
D->getType() << FoundField->getType();
4293 Importer.
ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4294 << FoundField->getType();
4301 auto TypeOrErr =
import(
D->getType());
4303 return TypeOrErr.takeError();
4309 for (
auto *PI :
D->chain())
4311 NamedChain[i++] = *ToD;
4313 return ToD.takeError();
4317 if (GetImportedOrCreateDecl(ToIndirectField,
D, Importer.
getToContext(), DC,
4318 Loc, Name.getAsIdentifierInfo(), *TypeOrErr, CH))
4320 return ToIndirectField;
4325 return ToIndirectField;
4355 unsigned int FriendCount = 0;
4356 std::optional<unsigned int> FriendPosition;
4359 for (
FriendDecl *FoundFriend : RD->friends()) {
4360 if (FoundFriend == FD) {
4361 FriendPosition = FriendCount;
4368 assert(FriendPosition &&
"Friend decl not found in own parent.");
4370 return {FriendCount, *FriendPosition};
4377 return std::move(Err);
4382 const auto *RD = cast<CXXRecordDecl>(DC);
4384 for (
FriendDecl *ImportedFriend : RD->friends())
4386 ImportedEquivalentFriends.push_back(ImportedFriend);
4391 assert(ImportedEquivalentFriends.size() <= CountAndPosition.
TotalCount &&
4392 "Class with non-matching friends is imported, ODR check wrong?");
4393 if (ImportedEquivalentFriends.size() == CountAndPosition.
TotalCount)
4395 D, ImportedEquivalentFriends[CountAndPosition.
IndexOfDecl]);
4400 if (
NamedDecl *FriendD =
D->getFriendDecl()) {
4402 if (Error Err = importInto(ToFriendD, FriendD))
4403 return std::move(Err);
4411 if (
auto TSIOrErr =
import(
D->getFriendType()))
4414 return TSIOrErr.takeError();
4419 for (
unsigned I = 0; I <
D->NumTPLists; I++) {
4420 if (
auto ListOrErr =
import(FromTPLists[I]))
4421 ToTPLists[I] = *ListOrErr;
4423 return ListOrErr.takeError();
4428 return LocationOrErr.takeError();
4429 auto FriendLocOrErr =
import(
D->getFriendLoc());
4430 if (!FriendLocOrErr)
4431 return FriendLocOrErr.takeError();
4432 auto EllipsisLocOrErr =
import(
D->getEllipsisLoc());
4433 if (!EllipsisLocOrErr)
4434 return EllipsisLocOrErr.takeError();
4437 if (GetImportedOrCreateDecl(FrD,
D, Importer.
getToContext(), DC,
4438 *LocationOrErr, ToFU, *FriendLocOrErr,
4439 *EllipsisLocOrErr, ToTPLists))
4455 return std::move(Err);
4460 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4461 for (
auto *FoundDecl : FoundDecls) {
4462 if (
ObjCIvarDecl *FoundIvar = dyn_cast<ObjCIvarDecl>(FoundDecl)) {
4464 FoundIvar->getType())) {
4469 Importer.
ToDiag(
Loc, diag::warn_odr_ivar_type_inconsistent)
4470 << Name <<
D->getType() << FoundIvar->getType();
4471 Importer.
ToDiag(FoundIvar->getLocation(), diag::note_odr_value_here)
4472 << FoundIvar->getType();
4478 Error Err = Error::success();
4480 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
4482 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
4484 return std::move(Err);
4487 if (GetImportedOrCreateDecl(
4488 ToIvar,
D, Importer.
getToContext(), cast<ObjCContainerDecl>(DC),
4489 ToInnerLocStart,
Loc, Name.getAsIdentifierInfo(),
4490 ToType, ToTypeSourceInfo,
4491 D->getAccessControl(),ToBitWidth,
D->getSynthesize()))
4502 auto RedeclIt = Redecls.begin();
4505 for (; RedeclIt != Redecls.end() && *RedeclIt !=
D; ++RedeclIt) {
4508 return RedeclOrErr.takeError();
4510 assert(*RedeclIt ==
D);
4518 return std::move(Err);
4524 VarDecl *FoundByLookup =
nullptr;
4525 if (
D->isFileVarDecl()) {
4528 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4529 for (
auto *FoundDecl : FoundDecls) {
4533 if (
auto *FoundVar = dyn_cast<VarDecl>(FoundDecl)) {
4537 FoundVar->getType())) {
4542 if (
D->isThisDeclarationADefinition() && FoundDef)
4549 const VarDecl *FoundDInit =
nullptr;
4550 if (
D->getInit() && FoundVar->getAnyInitializer(FoundDInit))
4554 FoundByLookup = FoundVar;
4562 if (FoundArray && TArray) {
4563 if (isa<IncompleteArrayType>(FoundArray) &&
4564 isa<ConstantArrayType>(TArray)) {
4566 if (
auto TyOrErr =
import(
D->getType()))
4567 FoundVar->setType(*TyOrErr);
4569 return TyOrErr.takeError();
4571 FoundByLookup = FoundVar;
4573 }
else if (isa<IncompleteArrayType>(TArray) &&
4574 isa<ConstantArrayType>(FoundArray)) {
4575 FoundByLookup = FoundVar;
4580 Importer.
ToDiag(
Loc, diag::warn_odr_variable_type_inconsistent)
4581 << Name <<
D->getType() << FoundVar->getType();
4582 Importer.
ToDiag(FoundVar->getLocation(), diag::note_odr_value_here)
4583 << FoundVar->getType();
4584 ConflictingDecls.push_back(FoundDecl);
4588 if (!ConflictingDecls.empty()) {
4590 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
4592 Name = NameOrErr.get();
4594 return NameOrErr.takeError();
4598 Error Err = Error::success();
4600 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
4601 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
4604 return std::move(Err);
4607 if (
auto *FromDecomp = dyn_cast<DecompositionDecl>(
D)) {
4611 return std::move(Err);
4613 if (GetImportedOrCreateDecl(
4614 ToDecomp, FromDecomp, Importer.
getToContext(), DC, ToInnerLocStart,
4615 Loc, ToType, ToTypeSourceInfo,
D->getStorageClass(),
Bindings))
4620 if (GetImportedOrCreateDecl(ToVar,
D, Importer.
getToContext(), DC,
4621 ToInnerLocStart,
Loc,
4622 Name.getAsIdentifierInfo(), ToType,
4623 ToTypeSourceInfo,
D->getStorageClass()))
4631 if (
D->isInlineSpecified())
4636 if (FoundByLookup) {
4642 if (
D->getDescribedVarTemplate()) {
4643 auto ToVTOrErr =
import(
D->getDescribedVarTemplate());
4645 return ToVTOrErr.takeError();
4648 VarDecl *FromInst =
D->getInstantiatedFromStaticDataMember();
4652 return ToInstOrErr.takeError();
4653 if (
ExpectedSLoc POIOrErr =
import(MSI->getPointOfInstantiation()))
4656 return POIOrErr.takeError();
4660 return std::move(Err);
4662 if (
D->isConstexpr())
4665 addDeclToContexts(
D, ToVar);
4668 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4671 return RedeclOrErr.takeError();
4682 Error Err = Error::success();
4687 return std::move(Err);
4691 if (GetImportedOrCreateDecl(ToParm,
D, Importer.
getToContext(), DC,
4692 ToLocation, ToDeclName.getAsIdentifierInfo(),
4693 ToType,
D->getParameterKind()))
4709 return ToDefArgOrErr.takeError();
4713 if (
auto ToDefArgOrErr =
import(FromParam->
getDefaultArg()))
4716 return ToDefArgOrErr.takeError();
4719 return Error::success();
4724 Error Err = Error::success();
4729 return std::move(Err);
4738 Error Err = Error::success();
4741 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
4743 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
4745 return std::move(Err);
4748 if (GetImportedOrCreateDecl(ToParm,
D, Importer.
getToContext(), DC,
4749 ToInnerLocStart, ToLocation,
4750 ToDeclName.getAsIdentifierInfo(), ToType,
4751 ToTypeSourceInfo,
D->getStorageClass(),
4759 return std::move(Err);
4761 if (
D->isObjCMethodParameter()) {
4766 D->getFunctionScopeIndex());
4779 return std::move(Err);
4783 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4784 for (
auto *FoundDecl : FoundDecls) {
4785 if (
auto *FoundMethod = dyn_cast<ObjCMethodDecl>(FoundDecl)) {
4786 if (FoundMethod->isInstanceMethod() !=
D->isInstanceMethod())
4791 FoundMethod->getReturnType())) {
4792 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_result_type_inconsistent)
4793 <<
D->isInstanceMethod() << Name <<
D->getReturnType()
4794 << FoundMethod->getReturnType();
4795 Importer.
ToDiag(FoundMethod->getLocation(),
4796 diag::note_odr_objc_method_here)
4797 <<
D->isInstanceMethod() << Name;
4803 if (
D->param_size() != FoundMethod->param_size()) {
4804 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_num_params_inconsistent)
4805 <<
D->isInstanceMethod() << Name
4806 <<
D->param_size() << FoundMethod->param_size();
4807 Importer.
ToDiag(FoundMethod->getLocation(),
4808 diag::note_odr_objc_method_here)
4809 <<
D->isInstanceMethod() << Name;
4816 PEnd =
D->param_end(), FoundP = FoundMethod->param_begin();
4817 P != PEnd; ++
P, ++FoundP) {
4819 (*FoundP)->getType())) {
4820 Importer.
FromDiag((*P)->getLocation(),
4821 diag::warn_odr_objc_method_param_type_inconsistent)
4822 <<
D->isInstanceMethod() << Name
4823 << (*P)->getType() << (*FoundP)->getType();
4824 Importer.
ToDiag((*FoundP)->getLocation(), diag::note_odr_value_here)
4825 << (*FoundP)->getType();
4833 if (
D->isVariadic() != FoundMethod->isVariadic()) {
4834 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_variadic_inconsistent)
4835 <<
D->isInstanceMethod() << Name;
4836 Importer.
ToDiag(FoundMethod->getLocation(),
4837 diag::note_odr_objc_method_here)
4838 <<
D->isInstanceMethod() << Name;
4848 Error Err = Error::success();
4851 auto ToReturnTypeSourceInfo =
4854 return std::move(Err);
4857 if (GetImportedOrCreateDecl(
4859 Name.getObjCSelector(), ToReturnType, ToReturnTypeSourceInfo, DC,
4860 D->isInstanceMethod(),
D->isVariadic(),
D->isPropertyAccessor(),
4861 D->isSynthesizedAccessorStub(),
D->
isImplicit(),
D->isDefined(),
4862 D->getImplementationControl(),
D->hasRelatedResultType()))
4870 for (
auto *FromP :
D->parameters()) {
4872 ToParams.push_back(*ToPOrErr);
4874 return ToPOrErr.takeError();
4878 for (
auto *ToParam : ToParams) {
4879 ToParam->setOwningFunction(ToMethod);
4884 D->getSelectorLocs(FromSelLocs);
4887 return std::move(Err);
4897 if (
D->getSelfDecl())
4911 return std::move(Err);
4915 Error Err = Error::success();
4919 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
4921 return std::move(Err);
4924 if (GetImportedOrCreateDecl(
4926 ToVarianceLoc,
D->getIndex(),
4927 ToLocation, Name.getAsIdentifierInfo(),
4928 ToColonLoc, ToTypeSourceInfo))
4934 return std::move(Err);
4935 Result->setTypeForDecl(ToTypeForDecl);
4936 Result->setLexicalDeclContext(LexicalDC);
4947 return std::move(Err);
4952 if (Error Err = importInto(ToInterface,
D->getClassInterface()))
4953 return std::move(Err);
4961 Error Err = Error::success();
4963 auto ToCategoryNameLoc =
importChecked(Err,
D->getCategoryNameLoc());
4964 auto ToIvarLBraceLoc =
importChecked(Err,
D->getIvarLBraceLoc());
4965 auto ToIvarRBraceLoc =
importChecked(Err,
D->getIvarRBraceLoc());
4967 return std::move(Err);
4969 if (GetImportedOrCreateDecl(ToCategory,
D, Importer.
getToContext(), DC,
4972 Name.getAsIdentifierInfo(), ToInterface,
4985 return PListOrErr.takeError();
4991 =
D->protocol_loc_begin();
4993 FromProtoEnd =
D->protocol_end();
4994 FromProto != FromProtoEnd;
4995 ++FromProto, ++FromProtoLoc) {
4997 Protocols.push_back(*ToProtoOrErr);
4999 return ToProtoOrErr.takeError();
5001 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5002 ProtocolLocs.push_back(*ToProtoLocOrErr);
5004 return ToProtoLocOrErr.takeError();
5017 return std::move(Err);
5020 if (
D->getImplementation()) {
5022 import(
D->getImplementation()))
5025 return ToImplOrErr.takeError();
5037 return Error::success();
5050 FromProto != FromProtoEnd;
5051 ++FromProto, ++FromProtoLoc) {
5053 Protocols.push_back(*ToProtoOrErr);
5055 return ToProtoOrErr.takeError();
5057 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5058 ProtocolLocs.push_back(*ToProtoLocOrErr);
5060 return ToProtoLocOrErr.takeError();
5073 return Error::success();
5085 return ImportedDefOrErr.takeError();
5094 return std::move(Err);
5099 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5100 for (
auto *FoundDecl : FoundDecls) {
5104 if ((MergeWithProtocol = dyn_cast<ObjCProtocolDecl>(FoundDecl)))
5110 auto ToAtBeginLocOrErr =
import(
D->getAtStartLoc());
5111 if (!ToAtBeginLocOrErr)
5112 return ToAtBeginLocOrErr.takeError();
5114 if (GetImportedOrCreateDecl(ToProto,
D, Importer.
getToContext(), DC,
5115 Name.getAsIdentifierInfo(),
Loc,
5125 if (
D->isThisDeclarationADefinition())
5127 return std::move(Err);
5135 return std::move(Err);
5138 if (!ExternLocOrErr)
5139 return ExternLocOrErr.takeError();
5143 return LangLocOrErr.takeError();
5145 bool HasBraces =
D->hasBraces();
5148 if (GetImportedOrCreateDecl(ToLinkageSpec,
D, Importer.
getToContext(), DC,
5149 *ExternLocOrErr, *LangLocOrErr,
5150 D->getLanguage(), HasBraces))
5151 return ToLinkageSpec;
5155 if (!RBraceLocOrErr)
5156 return RBraceLocOrErr.takeError();
5163 return ToLinkageSpec;
5174 return ToShadowOrErr.takeError();
5185 return std::move(Err);
5189 Error Err = Error::success();
5194 return std::move(Err);
5198 return std::move(Err);
5201 if (GetImportedOrCreateDecl(ToUsing,
D, Importer.
getToContext(), DC,
5202 ToUsingLoc, ToQualifierLoc, NameInfo,
5213 ToUsing, *ToPatternOrErr);
5215 return ToPatternOrErr.takeError();
5227 return std::move(Err);
5231 Error Err = Error::success();
5237 return std::move(Err);
5240 if (GetImportedOrCreateDecl(ToUsingEnum,
D, Importer.
getToContext(), DC,
5241 ToUsingLoc, ToEnumLoc, ToNameLoc, ToEnumType))
5253 return ToPatternOrErr.takeError();
5265 return std::move(Err);
5270 if (!ToIntroducerOrErr)
5271 return ToIntroducerOrErr.takeError();
5275 return ToTargetOrErr.takeError();
5278 if (
auto *FromConstructorUsingShadow =
5279 dyn_cast<ConstructorUsingShadowDecl>(
D)) {
5280 Error Err = Error::success();
5282 Err, FromConstructorUsingShadow->getNominatedBaseClassShadowDecl());
5284 return std::move(Err);
5290 if (GetImportedOrCreateDecl<ConstructorUsingShadowDecl>(
5292 cast<UsingDecl>(*ToIntroducerOrErr),
5293 Nominated ? Nominated : *ToTargetOrErr,
5294 FromConstructorUsingShadow->constructsVirtualBase()))
5298 Name, *ToIntroducerOrErr, *ToTargetOrErr))
5309 ToShadow, *ToPatternOrErr);
5313 return ToPatternOrErr.takeError();
5327 return std::move(Err);
5331 auto ToComAncestorOrErr = Importer.
ImportContext(
D->getCommonAncestor());
5332 if (!ToComAncestorOrErr)
5333 return ToComAncestorOrErr.takeError();
5335 Error Err = Error::success();
5336 auto ToNominatedNamespace =
importChecked(Err,
D->getNominatedNamespace());
5338 auto ToNamespaceKeyLocation =
5341 auto ToIdentLocation =
importChecked(Err,
D->getIdentLocation());
5343 return std::move(Err);
5346 if (GetImportedOrCreateDecl(ToUsingDir,
D, Importer.
getToContext(), DC,
5348 ToNamespaceKeyLocation,
5351 ToNominatedNamespace, *ToComAncestorOrErr))
5366 return std::move(Err);
5370 auto ToInstantiatedFromUsingOrErr =
5371 Importer.
Import(
D->getInstantiatedFromUsingDecl());
5372 if (!ToInstantiatedFromUsingOrErr)
5373 return ToInstantiatedFromUsingOrErr.takeError();
5376 return std::move(Err);
5379 if (GetImportedOrCreateDecl(ToUsingPack,
D, Importer.
getToContext(), DC,
5380 cast<NamedDecl>(*ToInstantiatedFromUsingOrErr),
5384 addDeclToContexts(
D, ToUsingPack);
5396 return std::move(Err);
5400 Error Err = Error::success();
5406 return std::move(Err);
5410 return std::move(Err);
5413 if (GetImportedOrCreateDecl(ToUsingValue,
D, Importer.
getToContext(), DC,
5414 ToUsingLoc, ToQualifierLoc, NameInfo,
5416 return ToUsingValue;
5422 return ToUsingValue;
5432 return std::move(Err);
5436 Error Err = Error::success();
5442 return std::move(Err);
5445 if (GetImportedOrCreateDecl(ToUsing,
D, Importer.
getToContext(), DC,
5446 ToUsingLoc, ToTypenameLoc,
5447 ToQualifierLoc,
Loc, Name, ToEllipsisLoc))
5458 Decl* ToD =
nullptr;
5459 switch (
D->getBuiltinTemplateKind()) {
5467 assert(ToD &&
"BuiltinTemplateDecl of unsupported kind!");
5478 if (
auto FromSuperOrErr =
import(FromSuper))
5479 FromSuper = *FromSuperOrErr;
5481 return FromSuperOrErr.takeError();
5485 if ((
bool)FromSuper != (
bool)ToSuper ||
5488 diag::warn_odr_objc_superclass_inconsistent)
5495 diag::note_odr_objc_missing_superclass);
5498 diag::note_odr_objc_superclass)
5502 diag::note_odr_objc_missing_superclass);
5508 return Error::success();
5519 return SuperTInfoOrErr.takeError();
5530 FromProto != FromProtoEnd;
5531 ++FromProto, ++FromProtoLoc) {
5533 Protocols.push_back(*ToProtoOrErr);
5535 return ToProtoOrErr.takeError();
5537 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5538 ProtocolLocs.push_back(*ToProtoLocOrErr);
5540 return ToProtoLocOrErr.takeError();
5551 auto ToCatOrErr =
import(Cat);
5553 return ToCatOrErr.takeError();
5562 return ToImplOrErr.takeError();
5569 return Error::success();
5578 for (
auto *fromTypeParam : *list) {
5579 if (
auto toTypeParamOrErr =
import(fromTypeParam))
5580 toTypeParams.push_back(*toTypeParamOrErr);
5582 return toTypeParamOrErr.takeError();
5586 if (!LAngleLocOrErr)
5587 return LAngleLocOrErr.takeError();
5590 if (!RAngleLocOrErr)
5591 return RAngleLocOrErr.takeError();
5608 return ImportedDefOrErr.takeError();
5617 return std::move(Err);
5623 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5624 for (
auto *FoundDecl : FoundDecls) {
5628 if ((MergeWithIface = dyn_cast<ObjCInterfaceDecl>(FoundDecl)))
5636 if (!AtBeginLocOrErr)
5637 return AtBeginLocOrErr.takeError();
5639 if (GetImportedOrCreateDecl(
5641 *AtBeginLocOrErr, Name.getAsIdentifierInfo(),
5643 nullptr,
Loc,
D->isImplicitInterfaceDecl()))
5651 if (
auto ToPListOrErr =
5655 return ToPListOrErr.takeError();
5657 if (
D->isThisDeclarationADefinition())
5659 return std::move(Err);
5667 if (Error Err = importInto(
Category,
D->getCategoryDecl()))
5668 return std::move(Err);
5674 return std::move(Err);
5676 Error Err = Error::success();
5679 auto ToCategoryNameLoc =
importChecked(Err,
D->getCategoryNameLoc());
5681 return std::move(Err);
5683 if (GetImportedOrCreateDecl(
5686 ToLocation, ToAtStartLoc, ToCategoryNameLoc))
5691 Category->setImplementation(ToImpl);
5696 return std::move(Err);
5705 if (Error Err = importInto(Iface,
D->getClassInterface()))
5706 return std::move(Err);
5710 if (Error Err = importInto(Super,
D->getSuperClass()))
5711 return std::move(Err);
5719 return std::move(Err);
5721 Error Err = Error::success();
5724 auto ToSuperClassLoc =
importChecked(Err,
D->getSuperClassLoc());
5725 auto ToIvarLBraceLoc =
importChecked(Err,
D->getIvarLBraceLoc());
5726 auto ToIvarRBraceLoc =
importChecked(Err,
D->getIvarRBraceLoc());
5728 return std::move(Err);
5730 if (GetImportedOrCreateDecl(Impl,
D, Importer.
getToContext(),
5754 diag::warn_odr_objc_superclass_inconsistent)
5760 diag::note_odr_objc_superclass)
5764 diag::note_odr_objc_missing_superclass);
5765 if (
D->getSuperClass())
5767 diag::note_odr_objc_superclass)
5768 <<
D->getSuperClass()->getDeclName();
5771 diag::note_odr_objc_missing_superclass);
5779 return std::move(Err);
5791 return std::move(Err);
5796 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5797 for (
auto *FoundDecl : FoundDecls) {
5798 if (
auto *FoundProp = dyn_cast<ObjCPropertyDecl>(FoundDecl)) {
5801 if (FoundProp->isInstanceProperty() !=
D->isInstanceProperty())
5806 FoundProp->getType())) {
5807 Importer.
ToDiag(
Loc, diag::warn_odr_objc_property_type_inconsistent)
5808 << Name <<
D->getType() << FoundProp->getType();
5809 Importer.
ToDiag(FoundProp->getLocation(), diag::note_odr_value_here)
5810 << FoundProp->getType();
5823 Error Err = Error::success();
5825 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
5829 return std::move(Err);
5833 if (GetImportedOrCreateDecl(
5835 Name.getAsIdentifierInfo(), ToAtLoc,
5836 ToLParenLoc, ToType,
5837 ToTypeSourceInfo,
D->getPropertyImplementation()))
5842 auto ToGetterNameLoc =
importChecked(Err,
D->getGetterNameLoc());
5843 auto ToSetterNameLoc =
importChecked(Err,
D->getSetterNameLoc());
5844 auto ToGetterMethodDecl =
importChecked(Err,
D->getGetterMethodDecl());
5845 auto ToSetterMethodDecl =
importChecked(Err,
D->getSetterMethodDecl());
5846 auto ToPropertyIvarDecl =
importChecked(Err,
D->getPropertyIvarDecl());
5848 return std::move(Err);
5855 D->getPropertyAttributesAsWritten());
5867 if (Error Err = importInto(
Property,
D->getPropertyDecl()))
5868 return std::move(Err);
5872 return std::move(Err);
5874 auto *InImpl = cast<ObjCImplDecl>(LexicalDC);
5878 if (Error Err = importInto(Ivar,
D->getPropertyIvarDecl()))
5879 return std::move(Err);
5882 = InImpl->FindPropertyImplDecl(
Property->getIdentifier(),
5886 Error Err = Error::success();
5889 auto ToPropertyIvarDeclLoc =
5892 return std::move(Err);
5894 if (GetImportedOrCreateDecl(ToImpl,
D, Importer.
getToContext(), DC,
5897 D->getPropertyImplementation(), Ivar,
5898 ToPropertyIvarDeclLoc))
5908 diag::warn_odr_objc_property_impl_kind_inconsistent)
5913 diag::note_odr_objc_property_impl_kind)
5914 <<
D->getPropertyDecl()->getDeclName()
5924 diag::warn_odr_objc_synthesize_ivar_inconsistent)
5928 Importer.
FromDiag(
D->getPropertyIvarDeclLoc(),
5929 diag::note_odr_objc_synthesize_ivar_here)
5930 <<
D->getPropertyIvarDecl()->getDeclName();
5950 return BeginLocOrErr.takeError();
5954 return LocationOrErr.takeError();
5957 if (GetImportedOrCreateDecl(
5960 *BeginLocOrErr, *LocationOrErr,
5961 D->getDepth(),
D->getIndex(), Importer.
Import(
D->getIdentifier()),
5963 D->hasTypeConstraint()))
5969 Error Err = Error::success();
5970 auto ToConceptRef =
importChecked(Err, TC->getConceptReference());
5971 auto ToIDC =
importChecked(Err, TC->getImmediatelyDeclaredConstraint());
5973 return std::move(Err);
5978 if (
D->hasDefaultArgument()) {
5980 import(
D->getDefaultArgument());
5981 if (!ToDefaultArgOrErr)
5982 return ToDefaultArgOrErr.takeError();
5992 Error Err = Error::success();
5996 auto ToTypeSourceInfo =
importChecked(Err,
D->getTypeSourceInfo());
5997 auto ToInnerLocStart =
importChecked(Err,
D->getInnerLocStart());
5999 return std::move(Err);
6002 if (GetImportedOrCreateDecl(ToD,
D, Importer.
getToContext(),
6004 ToInnerLocStart, ToLocation,
D->getDepth(),
6006 ToDeclName.getAsIdentifierInfo(), ToType,
6010 if (
D->hasDefaultArgument()) {
6012 import(
D->getDefaultArgument());
6013 if (!ToDefaultArgOrErr)
6014 return ToDefaultArgOrErr.takeError();
6024 auto NameOrErr =
import(
D->getDeclName());
6026 return NameOrErr.takeError();
6031 return LocationOrErr.takeError();
6034 auto TemplateParamsOrErr =
import(
D->getTemplateParameters());
6035 if (!TemplateParamsOrErr)
6036 return TemplateParamsOrErr.takeError();
6039 if (GetImportedOrCreateDecl(
6043 (*NameOrErr).getAsIdentifierInfo(),
D->wasDeclaredWithTypename(),
6044 *TemplateParamsOrErr))
6047 if (
D->hasDefaultArgument()) {
6049 import(
D->getDefaultArgument());
6050 if (!ToDefaultArgOrErr)
6051 return ToDefaultArgOrErr.takeError();
6061 assert(
D->getTemplatedDecl() &&
"Should be called on templates only");
6062 auto *ToTemplatedDef =
D->getTemplatedDecl()->getDefinition();
6063 if (!ToTemplatedDef)
6066 return cast_or_null<T>(TemplateWithDef);
6077 return std::move(Err);
6091 bool DependentFriend = IsDependentFriend(
D);
6098 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6099 for (
auto *FoundDecl : FoundDecls) {
6105 auto *FoundTemplate = dyn_cast<ClassTemplateDecl>(
Found);
6106 if (FoundTemplate) {
6111 bool IgnoreTemplateParmDepth =
6115 IgnoreTemplateParmDepth)) {
6116 if (DependentFriend || IsDependentFriend(FoundTemplate))
6121 if (
D->isThisDeclarationADefinition() && TemplateWithDef)
6124 FoundByLookup = FoundTemplate;
6129 ConflictingDecls.push_back(FoundDecl);
6133 if (!ConflictingDecls.empty()) {
6136 ConflictingDecls.size());
6138 Name = NameOrErr.get();
6140 return NameOrErr.takeError();
6146 auto TemplateParamsOrErr =
import(
D->getTemplateParameters());
6147 if (!TemplateParamsOrErr)
6148 return TemplateParamsOrErr.takeError();
6152 if (Error Err = importInto(ToTemplated, FromTemplated))
6153 return std::move(Err);
6158 *TemplateParamsOrErr, ToTemplated))
6166 addDeclToContexts(
D, D2);
6167 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6169 if (FoundByLookup) {
6183 "Found decl must have its templated decl set");
6186 if (ToTemplated != PrevTemplated)
6192 updateTemplateParametersInheritedFrom(*(Recent->getTemplateParameters()),
6193 **TemplateParamsOrErr);
6202 if (Error Err = importInto(ClassTemplate,
D->getSpecializedTemplate()))
6203 return std::move(Err);
6208 return std::move(Err);
6214 return std::move(Err);
6217 void *InsertPos =
nullptr;
6220 dyn_cast<ClassTemplatePartialSpecializationDecl>(
D);
6228 return ToTPListOrErr.takeError();
6229 ToTPList = *ToTPListOrErr;
6239 if (
D->isThisDeclarationADefinition() && PrevDefinition) {
6243 for (
auto *FromField :
D->fields()) {
6244 auto ToOrErr =
import(FromField);
6246 return ToOrErr.takeError();
6252 auto ToOrErr =
import(FromM);
6254 return ToOrErr.takeError();
6262 return PrevDefinition;
6273 return BeginLocOrErr.takeError();
6276 return IdLocOrErr.takeError();
6280 if (
const auto *ASTTemplateArgs =
D->getTemplateArgsAsWritten()) {
6282 return std::move(Err);
6289 if (Error Err = importInto(
6291 return std::move(Err);
6294 if (GetImportedOrCreateDecl<ClassTemplatePartialSpecializationDecl>(
6295 D2,
D, Importer.
getToContext(),
D->getTagKind(), DC, *BeginLocOrErr,
6296 *IdLocOrErr, ToTPList, ClassTemplate,
6299 cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl)))
6304 auto *PartSpec2 = cast<ClassTemplatePartialSpecializationDecl>(D2);
6311 PartSpec2->setInstantiatedFromMember(*ToInstOrErr);
6313 return ToInstOrErr.takeError();
6315 updateLookupTableForTemplateParameters(*ToTPList);
6317 if (GetImportedOrCreateDecl(
6319 *BeginLocOrErr, *IdLocOrErr, ClassTemplate, TemplateArgs,
6340 if (
auto BraceRangeOrErr =
import(
D->getBraceRange()))
6343 return BraceRangeOrErr.takeError();
6346 return std::move(Err);
6349 if (
auto LocOrErr =
import(
D->getQualifierLoc()))
6352 return LocOrErr.takeError();
6354 if (
D->getTemplateArgsAsWritten())
6357 if (
auto LocOrErr =
import(
D->getTemplateKeywordLoc()))
6360 return LocOrErr.takeError();
6362 if (
auto LocOrErr =
import(
D->getExternKeywordLoc()))
6365 return LocOrErr.takeError();
6367 if (
D->getPointOfInstantiation().isValid()) {
6368 if (
auto POIOrErr =
import(
D->getPointOfInstantiation()))
6371 return POIOrErr.takeError();
6376 if (
auto P =
D->getInstantiatedFrom()) {
6378 if (
auto CTDorErr =
import(CTD))
6381 auto *CTPSD = cast<ClassTemplatePartialSpecializationDecl *>(
P);
6382 auto CTPSDOrErr =
import(CTPSD);
6384 return CTPSDOrErr.takeError();
6387 for (
unsigned I = 0; I < DArgs.
size(); ++I) {
6389 if (
auto ArgOrErr =
import(DArg))
6390 D2ArgsVec[I] = *ArgOrErr;
6392 return ArgOrErr.takeError();
6400 if (
D->isCompleteDefinition())
6402 return std::move(Err);
6414 return std::move(Err);
6420 "Variable templates cannot be declared at function scope");
6423 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6425 for (
auto *FoundDecl : FoundDecls) {
6429 if (
VarTemplateDecl *FoundTemplate = dyn_cast<VarTemplateDecl>(FoundDecl)) {
6432 D->getTemplatedDecl()))
6439 assert(FoundTemplate->getDeclContext()->isRecord() &&
6440 "Member variable template imported as non-member, "
6441 "inconsistent imported AST?");
6444 if (!
D->isThisDeclarationADefinition())
6447 if (FoundDef &&
D->isThisDeclarationADefinition())
6450 FoundByLookup = FoundTemplate;
6453 ConflictingDecls.push_back(FoundDecl);
6457 if (!ConflictingDecls.empty()) {
6460 ConflictingDecls.size());
6462 Name = NameOrErr.get();
6464 return NameOrErr.takeError();
6467 VarDecl *DTemplated =
D->getTemplatedDecl();
6473 return TypeOrErr.takeError();
6477 if (Error Err = importInto(ToTemplated, DTemplated))
6478 return std::move(Err);
6481 auto TemplateParamsOrErr =
import(
D->getTemplateParameters());
6482 if (!TemplateParamsOrErr)
6483 return TemplateParamsOrErr.takeError();
6487 Name, *TemplateParamsOrErr, ToTemplated))
6496 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6498 if (FoundByLookup) {
6502 auto *PrevTemplated =
6504 if (ToTemplated != PrevTemplated)
6509 updateTemplateParametersInheritedFrom(*(Recent->getTemplateParameters()),
6510 **TemplateParamsOrErr);
6522 auto RedeclIt = Redecls.begin();
6525 for (; RedeclIt != Redecls.end() && *RedeclIt !=
D; ++RedeclIt) {
6528 return RedeclOrErr.takeError();
6530 assert(*RedeclIt ==
D);
6533 if (Error Err = importInto(VarTemplate,
D->getSpecializedTemplate()))
6534 return std::move(Err);
6539 return std::move(Err);
6544 return BeginLocOrErr.takeError();
6548 return IdLocOrErr.takeError();
6554 return std::move(Err);
6557 void *InsertPos =
nullptr;
6560 if (FoundSpecialization) {
6568 "Member variable template specialization imported as non-member, "
6569 "inconsistent imported AST?");
6572 if (!
D->isThisDeclarationADefinition())
6577 if (FoundDef &&
D->isThisDeclarationADefinition())
6588 if (
const auto *Args =
D->getTemplateArgsAsWritten()) {
6590 return std::move(Err);
6595 if (
auto *FromPartial = dyn_cast<PartVarSpecDecl>(
D)) {
6596 auto ToTPListOrErr =
import(FromPartial->getTemplateParameters());
6598 return ToTPListOrErr.takeError();
6600 PartVarSpecDecl *ToPartial;
6601 if (GetImportedOrCreateDecl(ToPartial,
D, Importer.
getToContext(), DC,
6602 *BeginLocOrErr, *IdLocOrErr, *ToTPListOrErr,
6604 D->getStorageClass(), TemplateArgs))
6608 import(FromPartial->getInstantiatedFromMember()))
6611 return ToInstOrErr.takeError();
6613 if (FromPartial->isMemberSpecialization())
6614 ToPartial->setMemberSpecialization();
6622 if (GetImportedOrCreateDecl(D2,
D, Importer.
getToContext(), DC,
6623 *BeginLocOrErr, *IdLocOrErr, VarTemplate,
6624 QualType(),
nullptr,
D->getStorageClass(),
6635 if (Error Err = importInto(
T,
D->getType()))
6636 return std::move(Err);
6639 auto TInfoOrErr =
import(
D->getTypeSourceInfo());
6641 return TInfoOrErr.takeError();
6644 if (
D->getPointOfInstantiation().isValid()) {
6645 if (
ExpectedSLoc POIOrErr =
import(
D->getPointOfInstantiation()))
6648 return POIOrErr.takeError();
6653 if (
D->getTemplateArgsAsWritten())
6656 if (
auto LocOrErr =
import(
D->getQualifierLoc()))
6659 return LocOrErr.takeError();
6661 if (
D->isConstexpr())
6667 return std::move(Err);
6669 if (FoundSpecialization)
6672 addDeclToContexts(
D, D2);
6675 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
6678 return RedeclOrErr.takeError();
6692 return std::move(Err);
6704 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6705 for (
auto *FoundDecl : FoundDecls) {
6709 if (
auto *FoundTemplate = dyn_cast<FunctionTemplateDecl>(FoundDecl)) {
6715 if (
D->isThisDeclarationADefinition() && TemplateWithDef)
6718 FoundByLookup = FoundTemplate;
6726 auto ParamsOrErr =
import(
D->getTemplateParameters());
6728 return ParamsOrErr.takeError();
6732 if (Error Err = importInto(TemplatedFD,
D->getTemplatedDecl()))
6733 return std::move(Err);
6750 OldParamDC.reserve(Params->
size());
6751 llvm::transform(*Params, std::back_inserter(OldParamDC),
6755 if (GetImportedOrCreateDecl(ToFunc,
D, Importer.
getToContext(), DC,
Loc, Name,
6756 Params, TemplatedFD))
6762 ToFunc->setLexicalDeclContext(LexicalDC);
6763 addDeclToContexts(
D, ToFunc);
6766 if (
LT && !OldParamDC.empty()) {
6767 for (
unsigned int I = 0; I < OldParamDC.size(); ++I)
6771 if (FoundByLookup) {
6776 "Found decl must have its templated decl set");
6777 auto *PrevTemplated =
6779 if (TemplatedFD != PrevTemplated)
6782 ToFunc->setPreviousDecl(Recent);
6784 updateTemplateParametersInheritedFrom(*(Recent->getTemplateParameters()),
6796 Importer.
FromDiag(S->getBeginLoc(), diag::err_unsupported_ast_node)
6797 << S->getStmtClassName();
6806 for (
unsigned I = 0,
E = S->getNumOutputs(); I !=
E; I++) {
6810 Names.push_back(ToII);
6813 for (
unsigned I = 0,
E = S->getNumInputs(); I !=
E; I++) {
6817 Names.push_back(ToII);
6821 for (
unsigned I = 0,
E = S->getNumClobbers(); I !=
E; I++) {
6822 if (
auto ClobberOrErr =
import(S->getClobberStringLiteral(I)))
6823 Clobbers.push_back(*ClobberOrErr);
6825 return ClobberOrErr.takeError();
6830 for (
unsigned I = 0,
E = S->getNumOutputs(); I !=
E; I++) {
6831 if (
auto OutputOrErr =
import(S->getOutputConstraintLiteral(I)))
6832 Constraints.push_back(*OutputOrErr);
6834 return OutputOrErr.takeError();
6837 for (
unsigned I = 0,
E = S->getNumInputs(); I !=
E; I++) {
6838 if (
auto InputOrErr =
import(S->getInputConstraintLiteral(I)))
6839 Constraints.push_back(*InputOrErr);
6841 return InputOrErr.takeError();
6847 return std::move(Err);
6851 return std::move(Err);
6854 S->labels(), Exprs.begin() + S->getNumOutputs() + S->getNumInputs()))
6855 return std::move(Err);
6859 return AsmLocOrErr.takeError();
6860 auto AsmStrOrErr =
import(S->getAsmString());
6862 return AsmStrOrErr.takeError();
6863 ExpectedSLoc RParenLocOrErr =
import(S->getRParenLoc());
6864 if (!RParenLocOrErr)
6865 return RParenLocOrErr.takeError();
6878 S->getNumClobbers(),
6886 Error Err = Error::success();
6891 return std::move(Err);
6897 if (!ToSemiLocOrErr)
6898 return ToSemiLocOrErr.takeError();
6900 *ToSemiLocOrErr, S->hasLeadingEmptyMacro());
6907 return std::move(Err);
6909 ExpectedSLoc ToLBracLocOrErr =
import(S->getLBracLoc());
6910 if (!ToLBracLocOrErr)
6911 return ToLBracLocOrErr.takeError();
6913 ExpectedSLoc ToRBracLocOrErr =
import(S->getRBracLoc());
6914 if (!ToRBracLocOrErr)
6915 return ToRBracLocOrErr.takeError();
6920 *ToLBracLocOrErr, *ToRBracLocOrErr);
6925 Error Err = Error::success();
6930 auto ToEllipsisLoc =
importChecked(Err, S->getEllipsisLoc());
6933 return std::move(Err);
6936 ToCaseLoc, ToEllipsisLoc, ToColonLoc);
6937 ToStmt->setSubStmt(ToSubStmt);
6944 Error Err = Error::success();
6949 return std::move(Err);
6952 ToDefaultLoc, ToColonLoc, ToSubStmt);
6957 Error Err = Error::success();
6962 return std::move(Err);
6965 ToIdentLoc, ToLabelDecl, ToSubStmt);
6970 if (!ToAttrLocOrErr)
6971 return ToAttrLocOrErr.takeError();
6975 return std::move(Err);
6977 if (!ToSubStmtOrErr)
6978 return ToSubStmtOrErr.takeError();
6981 Importer.
getToContext(), *ToAttrLocOrErr, ToAttrs, *ToSubStmtOrErr);
6986 Error Err = Error::success();
6989 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
6997 return std::move(Err);
7000 ToInit, ToConditionVariable, ToCond, ToLParenLoc,
7001 ToRParenLoc, ToThen, ToElseLoc, ToElse);
7006 Error Err = Error::success();
7008 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
7015 return std::move(Err);
7019 ToCond, ToLParenLoc, ToRParenLoc);
7020 ToStmt->setBody(ToBody);
7021 ToStmt->setSwitchLoc(ToSwitchLoc);
7025 for (
SwitchCase *SC = S->getSwitchCaseList(); SC !=
nullptr;
7026 SC = SC->getNextSwitchCase()) {
7029 return ToSCOrErr.takeError();
7030 if (LastChainedSwitchCase)
7033 ToStmt->setSwitchCaseList(*ToSCOrErr);
7034 LastChainedSwitchCase = *ToSCOrErr;
7042 Error Err = Error::success();
7043 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
7050 return std::move(Err);
7053 ToBody, ToWhileLoc, ToLParenLoc, ToRParenLoc);
7058 Error Err = Error::success();
7065 return std::move(Err);
7068 ToBody, ToCond, ToDoLoc, ToWhileLoc, ToRParenLoc);
7073 Error Err = Error::success();
7076 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
7083 return std::move(Err);
7087 ToInit, ToCond, ToConditionVariable, ToInc, ToBody, ToForLoc, ToLParenLoc,
7093 Error Err = Error::success();
7098 return std::move(Err);
7101 ToLabel, ToGotoLoc, ToLabelLoc);
7106 Error Err = Error::success();
7111 return std::move(Err);
7114 ToGotoLoc, ToStarLoc, ToTarget);
7118 ExpectedSLoc ToContinueLocOrErr =
import(S->getContinueLoc());
7119 if (!ToContinueLocOrErr)
7120 return ToContinueLocOrErr.takeError();
7125 auto ToBreakLocOrErr =
import(S->getBreakLoc());
7126 if (!ToBreakLocOrErr)
7127 return ToBreakLocOrErr.takeError();
7133 Error Err = Error::success();
7136 auto ToNRVOCandidate =
importChecked(Err, S->getNRVOCandidate());
7138 return std::move(Err);
7146 Error Err = Error::success();
7148 auto ToExceptionDecl =
importChecked(Err, S->getExceptionDecl());
7149 auto ToHandlerBlock =
importChecked(Err, S->getHandlerBlock());
7151 return std::move(Err);
7154 ToCatchLoc, ToExceptionDecl, ToHandlerBlock);
7160 return ToTryLocOrErr.takeError();
7162 ExpectedStmt ToTryBlockOrErr =
import(S->getTryBlock());
7163 if (!ToTryBlockOrErr)
7164 return ToTryBlockOrErr.takeError();
7167 for (
unsigned HI = 0, HE = S->getNumHandlers(); HI != HE; ++HI) {
7169 if (
auto ToHandlerOrErr =
import(FromHandler))
7170 ToHandlers[HI] = *ToHandlerOrErr;
7172 return ToHandlerOrErr.takeError();
7176 cast<CompoundStmt>(*ToTryBlockOrErr), ToHandlers);
7181 Error Err = Error::success();
7188 auto ToLoopVarStmt =
importChecked(Err, S->getLoopVarStmt());
7195 return std::move(Err);
7198 ToInit, ToRangeStmt, ToBeginStmt, ToEndStmt, ToCond, ToInc, ToLoopVarStmt,
7199 ToBody, ToForLoc, ToCoawaitLoc, ToColonLoc, ToRParenLoc);
7204 Error Err = Error::success();
7211 return std::move(Err);
7222 Error Err = Error::success();
7225 auto ToCatchParamDecl =
importChecked(Err, S->getCatchParamDecl());
7228 return std::move(Err);
7231 ToAtCatchLoc, ToRParenLoc, ToCatchParamDecl, ToCatchBody);
7235 ExpectedSLoc ToAtFinallyLocOrErr =
import(S->getAtFinallyLoc());
7236 if (!ToAtFinallyLocOrErr)
7237 return ToAtFinallyLocOrErr.takeError();
7238 ExpectedStmt ToAtFinallyStmtOrErr =
import(S->getFinallyBody());
7239 if (!ToAtFinallyStmtOrErr)
7240 return ToAtFinallyStmtOrErr.takeError();
7242 *ToAtFinallyStmtOrErr);
7247 Error Err = Error::success();
7250 auto ToFinallyStmt =
importChecked(Err, S->getFinallyStmt());
7252 return std::move(Err);
7255 for (
unsigned CI = 0, CE = S->getNumCatchStmts(); CI != CE; ++CI) {
7257 if (
ExpectedStmt ToCatchStmtOrErr =
import(FromCatchStmt))
7258 ToCatchStmts[CI] = *ToCatchStmtOrErr;
7260 return ToCatchStmtOrErr.takeError();
7264 ToAtTryLoc, ToTryBody,
7265 ToCatchStmts.begin(), ToCatchStmts.size(),
7272 Error Err = Error::success();
7273 auto ToAtSynchronizedLoc =
importChecked(Err, S->getAtSynchronizedLoc());
7277 return std::move(Err);
7280 ToAtSynchronizedLoc, ToSynchExpr, ToSynchBody);
7284 ExpectedSLoc ToThrowLocOrErr =
import(S->getThrowLoc());
7285 if (!ToThrowLocOrErr)
7286 return ToThrowLocOrErr.takeError();
7287 ExpectedExpr ToThrowExprOrErr =
import(S->getThrowExpr());
7288 if (!ToThrowExprOrErr)
7289 return ToThrowExprOrErr.takeError();
7291 *ToThrowLocOrErr, *ToThrowExprOrErr);
7298 return ToAtLocOrErr.takeError();
7300 if (!ToSubStmtOrErr)
7301 return ToSubStmtOrErr.takeError();
7316 Error Err = Error::success();
7321 return std::move(Err);
7322 auto ParentContextOrErr = Importer.
ImportContext(
E->getParentContext());
7323 if (!ParentContextOrErr)
7324 return ParentContextOrErr.takeError();
7328 RParenLoc, *ParentContextOrErr);
7333 Error Err = Error::success();
7336 auto ToWrittenTypeInfo =
importChecked(Err,
E->getWrittenTypeInfo());
7340 return std::move(Err);
7343 ToBuiltinLoc, ToSubExpr, ToWrittenTypeInfo, ToRParenLoc, ToType,
7344 E->isMicrosoftABI());
7349 Error Err = Error::success();
7357 return std::move(Err);
7364 bool CondIsTrue = !
E->isConditionDependent() &&
E->isConditionTrue();
7367 ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType, VK, OK,
7368 ToRParenLoc, CondIsTrue);
7372 Error Err = Error::success();
7379 return std::move(Err);
7387 Error Err = Error::success();
7391 const unsigned NumSubExprs =
E->getNumSubExprs();
7395 ToSubExprs.resize(NumSubExprs);
7398 return std::move(Err);
7401 Importer.
getToContext(), ToSubExprs, ToType, ToBeginLoc, ToRParenLoc);
7407 return TypeOrErr.takeError();
7411 return BeginLocOrErr.takeError();
7418 Error Err = Error::success();
7420 Expr *ToControllingExpr =
nullptr;
7422 if (
E->isExprPredicate())
7426 assert((ToControllingExpr || ToControllingType) &&
7427 "Either the controlling expr or type must be nonnull");
7431 return std::move(Err);
7436 return std::move(Err);
7441 return std::move(Err);
7444 if (
E->isResultDependent()) {
7445 if (ToControllingExpr) {
7447 ToCtx, ToGenericLoc, ToControllingExpr,
llvm::ArrayRef(ToAssocTypes),
7452 ToCtx, ToGenericLoc, ToControllingType,
llvm::ArrayRef(ToAssocTypes),
7457 if (ToControllingExpr) {
7459 ToCtx, ToGenericLoc, ToControllingExpr,
llvm::ArrayRef(ToAssocTypes),
7464 ToCtx, ToGenericLoc, ToControllingType,
llvm::ArrayRef(ToAssocTypes),
7471 Error Err = Error::success();
7476 return std::move(Err);
7479 E->getIdentKind(),
E->isTransparent(),
7485 Error Err = Error::success();
7487 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
7492 return std::move(Err);
7495 if (
E->getDecl() !=
E->getFoundDecl()) {
7496 auto FoundDOrErr =
import(
E->getFoundDecl());
7498 return FoundDOrErr.takeError();
7499 ToFoundD = *FoundDOrErr;
7504 if (
E->hasExplicitTemplateArgs()) {
7507 E->template_arguments(), ToTAInfo))
7508 return std::move(Err);
7509 ToResInfo = &ToTAInfo;
7513 Importer.
getToContext(), ToQualifierLoc, ToTemplateKeywordLoc, ToDecl,
7514 E->refersToEnclosingVariableOrCapture(), ToLocation, ToType,
7516 if (
E->hadMultipleCandidates())
7517 ToE->setHadMultipleCandidates(
true);
7518 ToE->setIsImmediateEscalating(
E->isImmediateEscalating());
7525 return TypeOrErr.takeError();
7533 return ToInitOrErr.takeError();
7535 ExpectedSLoc ToEqualOrColonLocOrErr =
import(
E->getEqualOrColonLoc());
7536 if (!ToEqualOrColonLocOrErr)
7537 return ToEqualOrColonLocOrErr.takeError();
7541 for (
unsigned I = 1, N =
E->getNumSubExprs(); I < N; I++) {
7543 ToIndexExprs[I - 1] = *ToArgOrErr;
7545 return ToArgOrErr.takeError();
7550 return std::move(Err);
7554 ToIndexExprs, *ToEqualOrColonLocOrErr,
7555 E->usesGNUSyntax(), *ToInitOrErr);
7562 return ToTypeOrErr.takeError();
7565 if (!ToLocationOrErr)
7566 return ToLocationOrErr.takeError();
7569 *ToTypeOrErr, *ToLocationOrErr);
7575 return ToTypeOrErr.takeError();
7578 if (!ToLocationOrErr)
7579 return ToLocationOrErr.takeError();
7582 Importer.
getToContext(),
E->getValue(), *ToTypeOrErr, *ToLocationOrErr);
7589 return ToTypeOrErr.takeError();
7592 if (!ToLocationOrErr)
7593 return ToLocationOrErr.takeError();
7597 *ToTypeOrErr, *ToLocationOrErr);
7601 auto ToTypeOrErr =
import(
E->
getType());
7603 return ToTypeOrErr.takeError();
7606 if (!ToSubExprOrErr)
7607 return ToSubExprOrErr.takeError();
7610 *ToSubExprOrErr, *ToTypeOrErr);
7614 auto ToTypeOrErr =
import(
E->
getType());
7616 return ToTypeOrErr.takeError();
7619 if (!ToLocationOrErr)
7620 return ToLocationOrErr.takeError();
7623 Importer.
getToContext(),
E->getValue(), *ToTypeOrErr, *ToLocationOrErr,
7630 return ToTypeOrErr.takeError();
7633 if (!ToLocationOrErr)
7634 return ToLocationOrErr.takeError();
7637 E->getValue(),
E->getKind(), *ToTypeOrErr, *ToLocationOrErr);
7643 return ToTypeOrErr.takeError();
7647 E->tokloc_begin(),
E->tokloc_end(), ToLocations.begin()))
7648 return std::move(Err);
7652 *ToTypeOrErr, ToLocations.data(), ToLocations.size());
7657 Error Err = Error::success();
7659 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
7663 return std::move(Err);
7667 ToInitializer,
E->isFileScope());
7672 Error Err = Error::success();
7677 return std::move(Err);
7681 E->getSubExprs(),
E->getSubExprs() +
E->getNumSubExprs(),
7683 return std::move(Err);
7687 ToBuiltinLoc, ToExprs, ToType,
E->getOp(), ToRParenLoc);
7691 Error Err = Error::success();
7697 return std::move(Err);
7700 ToAmpAmpLoc, ToLabelLoc, ToLabel, ToType);
7703 Error Err = Error::success();
7707 return std::move(Err);
7712 Error Err = Error::success();
7717 return std::move(Err);
7720 ParenExpr(ToLParen, ToRParen, ToSubExpr);
7726 return std::move(Err);
7729 if (!ToLParenLocOrErr)
7730 return ToLParenLocOrErr.takeError();
7733 if (!ToRParenLocOrErr)
7734 return ToRParenLocOrErr.takeError();
7737 ToExprs, *ToRParenLocOrErr);
7741 Error Err = Error::success();
7747 return std::move(Err);
7750 StmtExpr(ToSubStmt, ToType, ToLParenLoc, ToRParenLoc,
7751 E->getTemplateDepth());
7755 Error Err = Error::success();
7760 return std::move(Err);
7763 E->hasStoredFPFeatures());
7764 UO->setType(ToType);
7765 UO->setSubExpr(ToSubExpr);
7766 UO->setOpcode(
E->getOpcode());
7767 UO->setOperatorLoc(ToOperatorLoc);
7768 UO->setCanOverflow(
E->canOverflow());
7769 if (
E->hasStoredFPFeatures())
7770 UO->setStoredFPFeatures(
E->getStoredFPFeatures());
7778 Error Err = Error::success();
7783 return std::move(Err);
7785 if (
E->isArgumentType()) {
7787 import(
E->getArgumentTypeInfo());
7788 if (!ToArgumentTypeInfoOrErr)
7789 return ToArgumentTypeInfoOrErr.takeError();
7792 E->getKind(), *ToArgumentTypeInfoOrErr, ToType, ToOperatorLoc,
7796 ExpectedExpr ToArgumentExprOrErr =
import(
E->getArgumentExpr());
7797 if (!ToArgumentExprOrErr)
7798 return ToArgumentExprOrErr.takeError();
7801 E->getKind(), *ToArgumentExprOrErr, ToType, ToOperatorLoc, ToRParenLoc);
7805 Error Err = Error::success();
7811 return std::move(Err);
7814 Importer.
getToContext(), ToLHS, ToRHS,
E->getOpcode(), ToType,
7816 E->getFPFeatures());
7820 Error Err = Error::success();
7828 return std::move(Err);
7831 ToCond, ToQuestionLoc, ToLHS, ToColonLoc, ToRHS, ToType,
7837 Error Err = Error::success();
7847 return std::move(Err);
7850 ToCommon, ToOpaqueValue, ToCond, ToTrueExpr, ToFalseExpr,
7857 Error Err = Error::success();
7860 return std::move(Err);
7867 Error Err = Error::success();
7869 auto ToQueriedTypeSourceInfo =
7871 auto ToDimensionExpression =
importChecked(Err,
E->getDimensionExpression());
7875 return std::move(Err);
7878 ToBeginLoc,
E->getTrait(), ToQueriedTypeSourceInfo,
E->getValue(),
7879 ToDimensionExpression, ToEndLoc, ToType);
7883 Error Err = Error::success();
7885 auto ToQueriedExpression =
importChecked(Err,
E->getQueriedExpression());
7889 return std::move(Err);
7892 ToBeginLoc,
E->getTrait(), ToQueriedExpression,
E->getValue(),
7897 Error Err = Error::success();
7902 return std::move(Err);
7909 Error Err = Error::success();
7915 return std::move(Err);
7924 Error Err = Error::success();
7928 auto ToComputationLHSType =
importChecked(Err,
E->getComputationLHSType());
7929 auto ToComputationResultType =
7933 return std::move(Err);
7936 Importer.
getToContext(), ToLHS, ToRHS,
E->getOpcode(), ToType,
7939 ToComputationLHSType, ToComputationResultType);
7946 if (
auto SpecOrErr =
import(*I))
7947 Path.push_back(*SpecOrErr);
7949 return SpecOrErr.takeError();
7957 return ToTypeOrErr.takeError();
7960 if (!ToSubExprOrErr)
7961 return ToSubExprOrErr.takeError();
7964 if (!ToBasePathOrErr)
7965 return ToBasePathOrErr.takeError();
7968 Importer.
getToContext(), *ToTypeOrErr,
E->getCastKind(), *ToSubExprOrErr,
7973 Error Err = Error::success();
7976 auto ToTypeInfoAsWritten =
importChecked(Err,
E->getTypeInfoAsWritten());
7978 return std::move(Err);
7981 if (!ToBasePathOrErr)
7982 return ToBasePathOrErr.takeError();
7986 case Stmt::CStyleCastExprClass: {
7987 auto *CCE = cast<CStyleCastExpr>(
E);
7988 ExpectedSLoc ToLParenLocOrErr =
import(CCE->getLParenLoc());
7989 if (!ToLParenLocOrErr)
7990 return ToLParenLocOrErr.takeError();
7991 ExpectedSLoc ToRParenLocOrErr =
import(CCE->getRParenLoc());
7992 if (!ToRParenLocOrErr)
7993 return ToRParenLocOrErr.takeError();
7996 ToSubExpr, ToBasePath, CCE->getFPFeatures(), ToTypeInfoAsWritten,
7997 *ToLParenLocOrErr, *ToRParenLocOrErr);
8000 case Stmt::CXXFunctionalCastExprClass: {
8001 auto *FCE = cast<CXXFunctionalCastExpr>(
E);
8002 ExpectedSLoc ToLParenLocOrErr =
import(FCE->getLParenLoc());
8003 if (!ToLParenLocOrErr)
8004 return ToLParenLocOrErr.takeError();
8005 ExpectedSLoc ToRParenLocOrErr =
import(FCE->getRParenLoc());
8006 if (!ToRParenLocOrErr)
8007 return ToRParenLocOrErr.takeError();
8010 E->getCastKind(), ToSubExpr, ToBasePath, FCE->getFPFeatures(),
8011 *ToLParenLocOrErr, *ToRParenLocOrErr);
8014 case Stmt::ObjCBridgedCastExprClass: {
8015 auto *OCE = cast<ObjCBridgedCastExpr>(
E);
8016 ExpectedSLoc ToLParenLocOrErr =
import(OCE->getLParenLoc());
8017 if (!ToLParenLocOrErr)
8018 return ToLParenLocOrErr.takeError();
8019 ExpectedSLoc ToBridgeKeywordLocOrErr =
import(OCE->getBridgeKeywordLoc());
8020 if (!ToBridgeKeywordLocOrErr)
8021 return ToBridgeKeywordLocOrErr.takeError();
8023 *ToLParenLocOrErr, OCE->getBridgeKind(),
E->getCastKind(),
8024 *ToBridgeKeywordLocOrErr, ToTypeInfoAsWritten, ToSubExpr);
8026 case Stmt::BuiltinBitCastExprClass: {
8027 auto *BBC = cast<BuiltinBitCastExpr>(
E);
8028 ExpectedSLoc ToKWLocOrErr =
import(BBC->getBeginLoc());
8030 return ToKWLocOrErr.takeError();
8031 ExpectedSLoc ToRParenLocOrErr =
import(BBC->getEndLoc());
8032 if (!ToRParenLocOrErr)
8033 return ToRParenLocOrErr.takeError();
8036 ToTypeInfoAsWritten, *ToKWLocOrErr, *ToRParenLocOrErr);
8039 llvm_unreachable(
"Cast expression of unsupported type!");
8046 for (
int I = 0, N =
E->getNumComponents(); I < N; ++I) {
8052 Error Err = Error::success();
8056 return std::move(Err);
8065 auto ToBSOrErr =
import(FromNode.
getBase());
8067 return ToBSOrErr.takeError();
8072 auto ToFieldOrErr =
import(FromNode.
getField());
8074 return ToFieldOrErr.takeError();
8075 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, *ToFieldOrErr, ToEndLoc));
8080 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, ToII, ToEndLoc));
8087 for (
int I = 0, N =
E->getNumExpressions(); I < N; ++I) {
8089 if (!ToIndexExprOrErr)
8090 return ToIndexExprOrErr.takeError();
8091 ToExprs[I] = *ToIndexExprOrErr;
8094 Error Err = Error::success();
8096 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
8100 return std::move(Err);
8103 Importer.
getToContext(), ToType, ToOperatorLoc, ToTypeSourceInfo, ToNodes,
8104 ToExprs, ToRParenLoc);
8108 Error Err = Error::success();
8114 return std::move(Err);
8123 ToType, ToOperand, ToCanThrow, ToBeginLoc, ToEndLoc);
8127 Error Err = Error::success();
8132 return std::move(Err);
8135 ToSubExpr, ToType, ToThrowLoc,
E->isThrownVariableInScope());
8140 if (!ToUsedLocOrErr)
8141 return ToUsedLocOrErr.takeError();
8143 auto ToParamOrErr =
import(
E->getParam());
8145 return ToParamOrErr.takeError();
8147 auto UsedContextOrErr = Importer.
ImportContext(
E->getUsedContext());
8148 if (!UsedContextOrErr)
8149 return UsedContextOrErr.takeError();
8159 std::optional<ParmVarDecl *> FromParam =
8161 assert(FromParam &&
"ParmVarDecl was not imported?");
8164 return std::move(Err);
8166 Expr *RewrittenInit =
nullptr;
8167 if (
E->hasRewrittenInit()) {
8170 return ExprOrErr.takeError();
8171 RewrittenInit = ExprOrErr.get();
8174 *ToParamOrErr, RewrittenInit,
8180 Error Err = Error::success();
8182 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
8185 return std::move(Err);
8188 ToType, ToTypeSourceInfo, ToRParenLoc);
8194 if (!ToSubExprOrErr)
8195 return ToSubExprOrErr.takeError();
8197 auto ToDtorOrErr =
import(
E->getTemporary()->getDestructor());
8199 return ToDtorOrErr.takeError();
8209 Error Err = Error::success();
8212 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
8213 auto ToParenOrBraceRange =
importChecked(Err,
E->getParenOrBraceRange());
8215 return std::move(Err);
8219 return std::move(Err);
8222 Importer.
getToContext(), ToConstructor, ToType, ToTypeSourceInfo, ToArgs,
8223 ToParenOrBraceRange,
E->hadMultipleCandidates(),
8224 E->isListInitialization(),
E->isStdInitListInitialization(),
8225 E->requiresZeroInitialization());
8232 return std::move(Err);
8234 Error Err = Error::success();
8238 return std::move(Err);
8242 if (GetImportedOrCreateDecl(To,
D, Temporary, ExtendingDecl,
8243 D->getManglingNumber()))
8253 Error Err = Error::success();
8256 Err,
E->getLifetimeExtendedTemporaryDecl() ?
nullptr :
E->getSubExpr());
8257 auto ToMaterializedDecl =
8260 return std::move(Err);
8262 if (!ToTemporaryExpr)
8263 ToTemporaryExpr = cast<Expr>(ToMaterializedDecl->getTemporaryExpr());
8266 ToType, ToTemporaryExpr,
E->isBoundToLvalueReference(),
8267 ToMaterializedDecl);
8273 Error Err = Error::success();
8278 return std::move(Err);
8281 ToType, ToPattern, ToEllipsisLoc,
E->getNumExpansions());
8285 Error Err = Error::success();
8291 return std::move(Err);
8293 std::optional<unsigned> Length;
8295 Length =
E->getPackLength();
8298 if (
E->isPartiallySubstituted()) {
8300 ToPartialArguments))
8301 return std::move(Err);
8305 Importer.
getToContext(), ToOperatorLoc, ToPack, ToPackLoc, ToRParenLoc,
8306 Length, ToPartialArguments);
8311 Error Err = Error::success();
8313 auto ToOperatorDelete =
importChecked(Err,
E->getOperatorDelete());
8318 auto ToAllocatedTypeSourceInfo =
8321 auto ToDirectInitRange =
importChecked(Err,
E->getDirectInitRange());
8323 return std::move(Err);
8328 return std::move(Err);
8332 ToOperatorDelete,
E->passAlignment(),
E->doesUsualArrayDeleteWantSize(),
8333 ToPlacementArgs, ToTypeIdParens, ToArraySize,
E->getInitializationStyle(),
8334 ToInitializer, ToType, ToAllocatedTypeSourceInfo, ToSourceRange,
8339 Error Err = Error::success();
8341 auto ToOperatorDelete =
importChecked(Err,
E->getOperatorDelete());
8345 return std::move(Err);
8348 ToType,
E->isGlobalDelete(),
E->isArrayForm(),
E->isArrayFormAsWritten(),
8349 E->doesUsualArrayDeleteWantSize(), ToOperatorDelete, ToArgument,
8354 Error Err = Error::success();
8358 auto ToParenOrBraceRange =
importChecked(Err,
E->getParenOrBraceRange());
8360 return std::move(Err);
8364 return std::move(Err);
8367 Importer.
getToContext(), ToType, ToLocation, ToConstructor,
8368 E->isElidable(), ToArgs,
E->hadMultipleCandidates(),
8369 E->isListInitialization(),
E->isStdInitListInitialization(),
8370 E->requiresZeroInitialization(),
E->getConstructionKind(),
8371 ToParenOrBraceRange);
8378 if (!ToSubExprOrErr)
8379 return ToSubExprOrErr.takeError();
8383 return std::move(Err);
8386 Importer.
getToContext(), *ToSubExprOrErr,
E->cleanupsHaveSideEffects(),
8391 Error Err = Error::success();
8396 return std::move(Err);
8400 return std::move(Err);
8404 E->getFPFeatures());
8410 return ToTypeOrErr.takeError();
8413 if (!ToLocationOrErr)
8414 return ToLocationOrErr.takeError();
8417 *ToTypeOrErr,
E->isImplicit());
8423 return ToTypeOrErr.takeError();
8426 if (!ToLocationOrErr)
8427 return ToLocationOrErr.takeError();
8430 *ToTypeOrErr, *ToLocationOrErr);
8434 Error Err = Error::success();
8438 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
8442 auto ToName =
importChecked(Err,
E->getMemberNameInfo().getName());
8443 auto ToLoc =
importChecked(Err,
E->getMemberNameInfo().getLoc());
8445 return std::move(Err);
8453 if (
E->hasExplicitTemplateArgs()) {
8456 E->template_arguments(), ToTAInfo))
8457 return std::move(Err);
8458 ResInfo = &ToTAInfo;
8462 ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8463 ToMemberDecl, ToFoundDecl, ToMemberNameInfo,
8470 Error Err = Error::success();
8474 auto ToScopeTypeInfo =
importChecked(Err,
E->getScopeTypeInfo());
8475 auto ToColonColonLoc =
importChecked(Err,
E->getColonColonLoc());
8478 return std::move(Err);
8483 ExpectedSLoc ToDestroyedTypeLocOrErr =
import(
E->getDestroyedTypeLoc());
8484 if (!ToDestroyedTypeLocOrErr)
8485 return ToDestroyedTypeLocOrErr.takeError();
8488 if (
auto ToTIOrErr =
import(
E->getDestroyedTypeInfo()))
8491 return ToTIOrErr.takeError();
8495 Importer.
getToContext(), ToBase,
E->isArrow(), ToOperatorLoc,
8496 ToQualifierLoc, ToScopeTypeInfo, ToColonColonLoc, ToTildeLoc, Storage);
8501 Error Err = Error::success();
8505 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
8506 auto ToFirstQualifierFoundInScope =
8509 return std::move(Err);
8511 Expr *ToBase =
nullptr;
8512 if (!
E->isImplicitAccess()) {
8514 ToBase = *ToBaseOrErr;
8516 return ToBaseOrErr.takeError();
8521 if (
E->hasExplicitTemplateArgs()) {
8524 E->template_arguments(), ToTAInfo))
8525 return std::move(Err);
8526 ResInfo = &ToTAInfo;
8531 return std::move(Err);
8537 return std::move(Err);
8540 Importer.
getToContext(), ToBase, ToType,
E->isArrow(), ToOperatorLoc,
8541 ToQualifierLoc, ToTemplateKeywordLoc, ToFirstQualifierFoundInScope,
8542 ToMemberNameInfo, ResInfo);
8547 Error Err = Error::success();
8549 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
8555 return std::move(Err);
8559 return std::move(Err);
8563 if (
E->hasExplicitTemplateArgs()) {
8566 return std::move(Err);
8567 ResInfo = &ToTAInfo;
8571 Importer.
getToContext(), ToQualifierLoc, ToTemplateKeywordLoc,
8572 ToNameInfo, ResInfo);
8577 Error Err = Error::success();
8581 auto ToTypeSourceInfo =
importChecked(Err,
E->getTypeSourceInfo());
8583 return std::move(Err);
8588 return std::move(Err);
8591 Importer.
getToContext(), ToType, ToTypeSourceInfo, ToLParenLoc,
8598 if (!ToNamingClassOrErr)
8599 return ToNamingClassOrErr.takeError();
8601 auto ToQualifierLocOrErr =
import(
E->getQualifierLoc());
8602 if (!ToQualifierLocOrErr)
8603 return ToQualifierLocOrErr.takeError();
8605 Error Err = Error::success();
8609 return std::move(Err);
8614 return std::move(Err);
8617 for (
auto *
D :
E->decls())
8618 if (
auto ToDOrErr =
import(
D))
8619 ToDecls.
addDecl(cast<NamedDecl>(*ToDOrErr));
8621 return ToDOrErr.takeError();
8623 if (
E->hasExplicitTemplateArgs()) {
8626 E->getLAngleLoc(),
E->getRAngleLoc(),
E->template_arguments(),
8628 return std::move(Err);
8630 ExpectedSLoc ToTemplateKeywordLocOrErr =
import(
E->getTemplateKeywordLoc());
8631 if (!ToTemplateKeywordLocOrErr)
8632 return ToTemplateKeywordLocOrErr.takeError();
8634 const bool KnownDependent =
8636 ExprDependence::TypeValue;
8638 Importer.
getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8639 *ToTemplateKeywordLocOrErr, ToNameInfo,
E->requiresADL(), &ToTAInfo,
8640 ToDecls.
begin(), ToDecls.
end(), KnownDependent,
8645 Importer.
getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8646 ToNameInfo,
E->requiresADL(), ToDecls.
begin(), ToDecls.
end(),
8653 Error Err = Error::success();
8657 auto ToTemplateKeywordLoc =
importChecked(Err,
E->getTemplateKeywordLoc());
8661 return std::move(Err);
8666 return std::move(Err);
8669 for (
Decl *
D :
E->decls())
8670 if (
auto ToDOrErr =
import(
D))
8671 ToDecls.
addDecl(cast<NamedDecl>(*ToDOrErr));
8673 return ToDOrErr.takeError();
8677 if (
E->hasExplicitTemplateArgs()) {
8679 E->copyTemplateArgumentsInto(FromTAInfo);
8681 return std::move(Err);
8682 ResInfo = &ToTAInfo;
8685 Expr *ToBase =
nullptr;
8686 if (!
E->isImplicitAccess()) {
8688 ToBase = *ToBaseOrErr;
8690 return ToBaseOrErr.takeError();
8694 Importer.
getToContext(),
E->hasUnresolvedUsing(), ToBase, ToType,
8695 E->isArrow(), ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8696 ToNameInfo, ResInfo, ToDecls.
begin(), ToDecls.
end());
8700 Error Err = Error::success();
8705 return std::move(Err);
8707 unsigned NumArgs =
E->getNumArgs();
8710 return std::move(Err);
8712 if (
const auto *OCE = dyn_cast<CXXOperatorCallExpr>(
E)) {
8714 Importer.
getToContext(), OCE->getOperator(), ToCallee, ToArgs, ToType,
8715 OCE->getValueKind(), ToRParenLoc, OCE->getFPFeatures(),
8716 OCE->getADLCallKind());
8721 0,
E->getADLCallKind());
8726 auto ToClassOrErr =
import(FromClass);
8728 return ToClassOrErr.takeError();
8731 auto ToCallOpOrErr =
import(
E->getCallOperator());
8733 return ToCallOpOrErr.takeError();
8737 return std::move(Err);
8739 Error Err = Error::success();
8740 auto ToIntroducerRange =
importChecked(Err,
E->getIntroducerRange());
8741 auto ToCaptureDefaultLoc =
importChecked(Err,
E->getCaptureDefaultLoc());
8744 return std::move(Err);
8747 E->getCaptureDefault(), ToCaptureDefaultLoc,
8748 E->hasExplicitParameters(),
8749 E->hasExplicitResultType(), ToCaptureInits,
8755 Error Err = Error::success();
8760 return std::move(Err);
8764 return std::move(Err);
8768 ToCtx, ToLBraceLoc, ToExprs, ToRBraceLoc);
8771 if (
E->hasArrayFiller()) {
8772 if (
ExpectedExpr ToFillerOrErr =
import(
E->getArrayFiller()))
8775 return ToFillerOrErr.takeError();
8778 if (
FieldDecl *FromFD =
E->getInitializedFieldInUnion()) {
8779 if (
auto ToFDOrErr =
import(FromFD))
8782 return ToFDOrErr.takeError();
8786 if (
auto ToSyntFormOrErr =
import(SyntForm))
8789 return ToSyntFormOrErr.takeError();
8803 return ToTypeOrErr.takeError();
8806 if (!ToSubExprOrErr)
8807 return ToSubExprOrErr.takeError();
8810 *ToTypeOrErr, *ToSubExprOrErr);
8815 Error Err = Error::success();
8820 return std::move(Err);
8823 ToLocation, ToType, ToConstructor,
E->constructsVBase(),
8824 E->inheritedFromVBase());
8828 Error Err = Error::success();
8833 return std::move(Err);
8836 ToType, ToCommonExpr, ToSubExpr);
8842 return ToTypeOrErr.takeError();
8848 if (!ToBeginLocOrErr)
8849 return ToBeginLocOrErr.takeError();
8851 auto ToFieldOrErr =
import(
E->getField());
8853 return ToFieldOrErr.takeError();
8855 auto UsedContextOrErr = Importer.
ImportContext(
E->getUsedContext());
8856 if (!UsedContextOrErr)
8857 return UsedContextOrErr.takeError();
8861 "Field should have in-class initializer if there is a default init "
8862 "expression that uses it.");
8867 auto ToInClassInitializerOrErr =
8868 import(
E->getField()->getInClassInitializer());
8869 if (!ToInClassInitializerOrErr)
8870 return ToInClassInitializerOrErr.takeError();
8874 Expr *RewrittenInit =
nullptr;
8875 if (
E->hasRewrittenInit()) {
8878 return ExprOrErr.takeError();
8879 RewrittenInit = ExprOrErr.get();
8883 ToField, *UsedContextOrErr, RewrittenInit);
8887 Error Err = Error::success();
8890 auto ToTypeInfoAsWritten =
importChecked(Err,
E->getTypeInfoAsWritten());
8893 auto ToAngleBrackets =
importChecked(Err,
E->getAngleBrackets());
8895 return std::move(Err);
8900 if (!ToBasePathOrErr)
8901 return ToBasePathOrErr.takeError();
8903 if (
auto CCE = dyn_cast<CXXStaticCastExpr>(
E)) {
8905 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8906 ToTypeInfoAsWritten, CCE->getFPFeatures(), ToOperatorLoc, ToRParenLoc,
8908 }
else if (isa<CXXDynamicCastExpr>(
E)) {
8910 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8911 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8912 }
else if (isa<CXXReinterpretCastExpr>(
E)) {
8914 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8915 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8916 }
else if (isa<CXXConstCastExpr>(
E)) {
8918 Importer.
getToContext(), ToType, VK, ToSubExpr, ToTypeInfoAsWritten,
8919 ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8921 llvm_unreachable(
"Unknown cast type");
8922 return make_error<ASTImportError>();
8928 Error Err = Error::success();
8931 auto ToAssociatedDecl =
importChecked(Err,
E->getAssociatedDecl());
8934 return std::move(Err);
8937 ToType,
E->
getValueKind(), ToExprLoc, ToReplacement, ToAssociatedDecl,
8938 E->getIndex(),
E->getPackIndex(),
E->isReferenceParameter());
8942 Error Err = Error::success();
8947 return std::move(Err);
8951 return std::move(Err);
8958 Importer.
getToContext(), ToType, ToBeginLoc,
E->getTrait(), ToArgs,
8965 return ToTypeOrErr.takeError();
8968 if (!ToSourceRangeOrErr)
8969 return ToSourceRangeOrErr.takeError();
8971 if (
E->isTypeOperand()) {
8972 if (
auto ToTSIOrErr =
import(
E->getTypeOperandSourceInfo()))
8974 *ToTypeOrErr, *ToTSIOrErr, *ToSourceRangeOrErr);
8976 return ToTSIOrErr.takeError();
8979 ExpectedExpr ToExprOperandOrErr =
import(
E->getExprOperand());
8980 if (!ToExprOperandOrErr)
8981 return ToExprOperandOrErr.takeError();
8984 *ToTypeOrErr, *ToExprOperandOrErr, *ToSourceRangeOrErr);
8988 Error Err = Error::success();
8999 return std::move(Err);
9002 CXXFoldExpr(ToType, ToCallee, ToLParenLoc, ToLHS,
E->getOperator(),
9003 ToEllipsisLoc, ToRHS, ToRParenLoc,
E->getNumExpansions());
9008 Error ImportErrors = Error::success();
9010 if (
auto ImportedOrErr =
import(FromOverriddenMethod))
9012 (*ImportedOrErr)->getCanonicalDecl()));
9015 joinErrors(std::move(ImportErrors), ImportedOrErr.takeError());
9017 return ImportErrors;
9023 std::shared_ptr<ASTImporterSharedState> SharedState)
9024 : SharedState(SharedState), ToContext(ToContext), FromContext(FromContext),
9025 ToFileManager(ToFileManager), FromFileManager(FromFileManager),
9030 this->SharedState = std::make_shared<ASTImporterSharedState>();
9040 assert(F && (isa<FieldDecl>(*F) || isa<IndirectFieldDecl>(*F)) &&
9041 "Try to get field index for non-field.");
9045 return std::nullopt;
9048 for (
const auto *
D : Owner->decls()) {
9052 if (isa<FieldDecl>(*
D) || isa<IndirectFieldDecl>(*
D))
9056 llvm_unreachable(
"Field was not found in its parent context.");
9058 return std::nullopt;
9071 if (SharedState->getLookupTable()) {
9073 SharedState->getLookupTable()->lookup(ReDC, Name);
9077 FoundDeclsTy
Result(NoloadLookupResult.
begin(), NoloadLookupResult.
end());
9094void ASTImporter::AddToLookupTable(
Decl *ToD) {
9095 SharedState->addDeclToLookup(ToD);
9101 return Importer.
Visit(FromD);
9125 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
9126 ImportedTypes.find(FromT);
9127 if (Pos != ImportedTypes.end())
9134 return ToTOrErr.takeError();
9137 ImportedTypes[FromT] = ToTOrErr->getTypePtr();
9139 return ToTOrErr->getTypePtr();
9148 return ToTyOrErr.takeError();
9161 return TOrErr.takeError();
9164 return BeginLocOrErr.takeError();
9173template <
typename T>
struct AttrArgImporter {
9174 AttrArgImporter(
const AttrArgImporter<T> &) =
delete;
9175 AttrArgImporter(AttrArgImporter<T> &&) =
default;
9176 AttrArgImporter<T> &operator=(
const AttrArgImporter<T> &) =
delete;
9177 AttrArgImporter<T> &operator=(AttrArgImporter<T> &&) =
default;
9180 : To(I.importChecked(Err, From)) {}
9182 const T &value() {
return To; }
9193template <
typename T>
struct AttrArgArrayImporter {
9194 AttrArgArrayImporter(
const AttrArgArrayImporter<T> &) =
delete;
9195 AttrArgArrayImporter(AttrArgArrayImporter<T> &&) =
default;
9196 AttrArgArrayImporter<T> &operator=(
const AttrArgArrayImporter<T> &) =
delete;
9197 AttrArgArrayImporter<T> &operator=(AttrArgArrayImporter<T> &&) =
default;
9200 const llvm::iterator_range<T *> &From,
9201 unsigned ArraySize) {
9204 To.reserve(ArraySize);
9208 T *value() {
return To.data(); }
9215 Error Err{Error::success()};
9216 Attr *ToAttr =
nullptr;
9221 AttrImporter(
ASTImporter &I) : Importer(I), NImporter(I) {}
9224 template <
typename T>
T *castAttrAs() {
return cast<T>(ToAttr); }
9225 template <
typename T>
const T *castAttrAs()
const {
return cast<T>(ToAttr); }
9230 template <
class T> AttrArgImporter<T> importArg(
const T &From) {
9231 return AttrArgImporter<T>(NImporter, Err, From);
9237 template <
typename T>
9238 AttrArgArrayImporter<T> importArrayArg(
const llvm::iterator_range<T *> &From,
9239 unsigned ArraySize) {
9240 return AttrArgArrayImporter<T>(NImporter, Err, From, ArraySize);
9251 template <
typename T,
typename... Arg>
9252 void importAttr(
const T *FromAttr, Arg &&...ImportedArg) {
9253 static_assert(std::is_base_of<Attr, T>::value,
9254 "T should be subclass of Attr.");
9255 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9259 Importer.
Import(FromAttr->getScopeName());
9269 FromAttr->getParsedKind(), FromAttr->getForm());
9273 std::forward<Arg>(ImportedArg)..., ToI);
9277 if (
auto *ToInheritableAttr = dyn_cast<InheritableAttr>(ToAttr))
9278 ToInheritableAttr->setInherited(FromAttr->isInherited());
9284 void cloneAttr(
const Attr *FromAttr) {
9285 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9299 return std::move(Err);
9300 assert(ToAttr &&
"Attribute should be created.");
9307 AttrImporter AI(*
this);
9310 switch (FromAttr->
getKind()) {
9311 case attr::Aligned: {
9312 auto *From = cast<AlignedAttr>(FromAttr);
9313 if (From->isAlignmentExpr())
9314 AI.importAttr(From,
true, AI.importArg(From->getAlignmentExpr()).value());
9316 AI.importAttr(From,
false,
9317 AI.importArg(From->getAlignmentType()).value());
9321 case attr::AlignValue: {
9322 auto *From = cast<AlignValueAttr>(FromAttr);
9323 AI.importAttr(From, AI.importArg(From->getAlignment()).value());
9327 case attr::Format: {
9328 const auto *From = cast<FormatAttr>(FromAttr);
9329 AI.importAttr(From,
Import(From->getType()), From->getFormatIdx(),
9330 From->getFirstArg());
9334 case attr::EnableIf: {
9335 const auto *From = cast<EnableIfAttr>(FromAttr);
9336 AI.importAttr(From, AI.importArg(From->getCond()).value(),
9337 From->getMessage());
9341 case attr::AssertCapability: {
9342 const auto *From = cast<AssertCapabilityAttr>(FromAttr);
9344 AI.importArrayArg(From->args(), From->args_size()).value(),
9348 case attr::AcquireCapability: {
9349 const auto *From = cast<AcquireCapabilityAttr>(FromAttr);
9351 AI.importArrayArg(From->args(), From->args_size()).value(),
9355 case attr::TryAcquireCapability: {
9356 const auto *From = cast<TryAcquireCapabilityAttr>(FromAttr);
9357 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9358 AI.importArrayArg(From->args(), From->args_size()).value(),
9362 case attr::ReleaseCapability: {
9363 const auto *From = cast<ReleaseCapabilityAttr>(FromAttr);
9365 AI.importArrayArg(From->args(), From->args_size()).value(),
9369 case attr::RequiresCapability: {
9370 const auto *From = cast<RequiresCapabilityAttr>(FromAttr);
9372 AI.importArrayArg(From->args(), From->args_size()).value(),
9376 case attr::GuardedBy: {
9377 const auto *From = cast<GuardedByAttr>(FromAttr);
9378 AI.importAttr(From, AI.importArg(From->getArg()).value());
9381 case attr::PtGuardedBy: {
9382 const auto *From = cast<PtGuardedByAttr>(FromAttr);
9383 AI.importAttr(From, AI.importArg(From->getArg()).value());
9386 case attr::AcquiredAfter: {
9387 const auto *From = cast<AcquiredAfterAttr>(FromAttr);
9389 AI.importArrayArg(From->args(), From->args_size()).value(),
9393 case attr::AcquiredBefore: {
9394 const auto *From = cast<AcquiredBeforeAttr>(FromAttr);
9396 AI.importArrayArg(From->args(), From->args_size()).value(),
9400 case attr::AssertExclusiveLock: {
9401 const auto *From = cast<AssertExclusiveLockAttr>(FromAttr);
9403 AI.importArrayArg(From->args(), From->args_size()).value(),
9407 case attr::AssertSharedLock: {
9408 const auto *From = cast<AssertSharedLockAttr>(FromAttr);
9410 AI.importArrayArg(From->args(), From->args_size()).value(),
9414 case attr::ExclusiveTrylockFunction: {
9415 const auto *From = cast<ExclusiveTrylockFunctionAttr>(FromAttr);
9416 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9417 AI.importArrayArg(From->args(), From->args_size()).value(),
9421 case attr::SharedTrylockFunction: {
9422 const auto *From = cast<SharedTrylockFunctionAttr>(FromAttr);
9423 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9424 AI.importArrayArg(From->args(), From->args_size()).value(),
9428 case attr::LockReturned: {
9429 const auto *From = cast<LockReturnedAttr>(FromAttr);
9430 AI.importAttr(From, AI.importArg(From->getArg()).value());
9433 case attr::LocksExcluded: {
9434 const auto *From = cast<LocksExcludedAttr>(FromAttr);
9436 AI.importArrayArg(From->args(), From->args_size()).value(),
9444 AI.cloneAttr(FromAttr);
9449 return std::move(AI).getResult();
9453 return ImportedDecls.lookup(FromD);
9457 auto FromDPos = ImportedFromDecls.find(ToD);
9458 if (FromDPos == ImportedFromDecls.end())
9460 return FromDPos->second->getTranslationUnitDecl();
9468 ImportPath.
push(FromD);
9469 auto ImportPathBuilder =
9470 llvm::make_scope_exit([
this]() { ImportPath.
pop(); });
9475 return make_error<ASTImportError>(*Error);
9481 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9483 return make_error<ASTImportError>(*Error);
9500 auto Pos = ImportedDecls.find(FromD);
9501 if (Pos != ImportedDecls.end()) {
9504 auto *ToD = Pos->second;
9505 ImportedDecls.erase(Pos);
9517 auto PosF = ImportedFromDecls.find(ToD);
9518 if (PosF != ImportedFromDecls.end()) {
9523 SharedState->removeDeclFromLookup(ToD);
9524 ImportedFromDecls.erase(PosF);
9536 handleAllErrors(ToDOrErr.takeError(),
9540 if (Pos != ImportedDecls.end())
9541 SharedState->setImportDeclError(Pos->second, ErrOut);
9545 for (
const auto &
Path : SavedImportPaths[FromD]) {
9548 Decl *PrevFromDi = FromD;
9551 if (FromDi == FromD)
9558 PrevFromDi = FromDi;
9562 auto Ii = ImportedDecls.find(FromDi);
9563 if (Ii != ImportedDecls.end())
9564 SharedState->setImportDeclError(Ii->second, ErrOut);
9569 SavedImportPaths.erase(FromD);
9572 return make_error<ASTImportError>(ErrOut);
9584 return make_error<ASTImportError>(*Err);
9590 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9592 return make_error<ASTImportError>(*Error);
9595 assert(ImportedDecls.count(FromD) != 0 &&
"Missing call to MapImported?");
9599 auto ToAttrOrErr =
Import(FromAttr);
9603 return ToAttrOrErr.takeError();
9610 SavedImportPaths.erase(FromD);
9625 return ToDCOrErr.takeError();
9626 auto *ToDC = cast<DeclContext>(*ToDCOrErr);
9630 if (
auto *ToRecord = dyn_cast<RecordDecl>(ToDC)) {
9631 auto *FromRecord = cast<RecordDecl>(FromDC);
9632 if (ToRecord->isCompleteDefinition())
9640 if (FromRecord->getASTContext().getExternalSource() &&
9641 !FromRecord->isCompleteDefinition())
9642 FromRecord->getASTContext().getExternalSource()->CompleteType(FromRecord);
9644 if (FromRecord->isCompleteDefinition())
9647 return std::move(Err);
9648 }
else if (
auto *ToEnum = dyn_cast<EnumDecl>(ToDC)) {
9649 auto *FromEnum = cast<EnumDecl>(FromDC);
9650 if (ToEnum->isCompleteDefinition()) {
9652 }
else if (FromEnum->isCompleteDefinition()) {
9655 return std::move(Err);
9659 }
else if (
auto *ToClass = dyn_cast<ObjCInterfaceDecl>(ToDC)) {
9660 auto *FromClass = cast<ObjCInterfaceDecl>(FromDC);
9661 if (ToClass->getDefinition()) {
9666 return std::move(Err);
9670 }
else if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(ToDC)) {
9671 auto *FromProto = cast<ObjCProtocolDecl>(FromDC);
9672 if (ToProto->getDefinition()) {
9677 return std::move(Err);
9688 return cast_or_null<Expr>(*ToSOrErr);
9690 return ToSOrErr.takeError();
9698 llvm::DenseMap<Stmt *, Stmt *>::iterator Pos = ImportedStmts.find(FromS);
9699 if (Pos != ImportedStmts.end())
9708 if (
auto *ToE = dyn_cast<Expr>(*ToSOrErr)) {
9709 auto *FromE = cast<Expr>(FromS);
9712 ToE->setValueKind(FromE->getValueKind());
9713 ToE->setObjectKind(FromE->getObjectKind());
9714 ToE->setDependence(FromE->getDependence());
9718 ImportedStmts[FromS] = *ToSOrErr;
9729 return std::move(Err);
9733 assert(FromNNS->
getAsIdentifier() &&
"NNS should contain identifier.");
9740 cast<NamespaceDecl>(*NSOrErr));
9742 return NSOrErr.takeError();
9747 cast<NamespaceAliasDecl>(*NSADOrErr));
9749 return NSADOrErr.takeError();
9757 cast<CXXRecordDecl>(*RDOrErr));
9759 return RDOrErr.takeError();
9769 return TyOrErr.takeError();
9773 llvm_unreachable(
"Invalid nested name specifier kind");
9785 NestedNames.push_back(NNS);
9791 while (!NestedNames.empty()) {
9792 NNS = NestedNames.pop_back_val();
9795 return std::move(Err);
9802 return std::move(Err);
9806 return std::move(Err);
9822 ToLocalBeginLoc, ToLocalEndLoc);
9829 return std::move(Err);
9849 if (!ToSourceRangeOrErr)
9850 return ToSourceRangeOrErr.takeError();
9853 ToSourceRangeOrErr->getBegin(),
9854 ToSourceRangeOrErr->getEnd());
9866 return TemplateName(cast<TemplateDecl>((*ToTemplateOrErr)->getCanonicalDecl()));
9868 return ToTemplateOrErr.takeError();
9873 for (
auto *I : *FromStorage) {
9874 if (
auto ToOrErr =
Import(I))
9875 ToTemplates.
addDecl(cast<NamedDecl>(*ToOrErr));
9877 return ToOrErr.takeError();
9887 return DeclNameOrErr.takeError();
9894 if (!QualifierOrErr)
9895 return QualifierOrErr.takeError();
9898 return TNOrErr.takeError();
9906 if (!QualifierOrErr)
9907 return QualifierOrErr.takeError();
9922 if (!ReplacementOrErr)
9923 return ReplacementOrErr.takeError();
9926 if (!AssociatedDeclOrErr)
9927 return AssociatedDeclOrErr.takeError();
9930 *ReplacementOrErr, *AssociatedDeclOrErr, Subst->
getIndex(),
9941 return ArgPackOrErr.takeError();
9944 if (!AssociatedDeclOrErr)
9945 return AssociatedDeclOrErr.takeError();
9948 *ArgPackOrErr, *AssociatedDeclOrErr, SubstPack->
getIndex(),
9954 return UsingOrError.takeError();
9955 return TemplateName(cast<UsingShadowDecl>(*UsingOrError));
9959 llvm_unreachable(
"Invalid template name kind");
9972 return ToFileIDOrErr.takeError();
9980 return std::move(Err);
9982 return std::move(Err);
9988 llvm::DenseMap<FileID, FileID>::iterator Pos = ImportedFileIDs.find(FromID);
9989 if (Pos != ImportedFileIDs.end())
10002 return ToSpLoc.takeError();
10005 return ToExLocS.takeError();
10015 return ToExLocE.takeError();
10021 if (!IsBuiltin && !
Cache->BufferOverridden) {
10025 return ToIncludeLoc.takeError();
10036 if (
Cache->OrigEntry &&
Cache->OrigEntry->getDir()) {
10047 ToID = ToSM.
createFileID(*Entry, ToIncludeLocOrFakeLoc,
10054 std::optional<llvm::MemoryBufferRef> FromBuf =
10060 std::unique_ptr<llvm::MemoryBuffer> ToBuf =
10061 llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(),
10062 FromBuf->getBufferIdentifier());
10068 assert(ToID.
isValid() &&
"Unexpected invalid fileID was created.");
10070 ImportedFileIDs[FromID] = ToID;
10077 return ToExprOrErr.takeError();
10080 if (!LParenLocOrErr)
10081 return LParenLocOrErr.takeError();
10084 if (!RParenLocOrErr)
10085 return RParenLocOrErr.takeError();
10090 return ToTInfoOrErr.takeError();
10095 return std::move(Err);
10098 ToContext, *ToTInfoOrErr, From->
isBaseVirtual(), *LParenLocOrErr,
10099 *ToExprOrErr, *RParenLocOrErr, EllipsisLoc);
10103 return ToFieldOrErr.takeError();
10106 if (!MemberLocOrErr)
10107 return MemberLocOrErr.takeError();
10110 ToContext, cast_or_null<FieldDecl>(*ToFieldOrErr), *MemberLocOrErr,
10111 *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10114 if (!ToIFieldOrErr)
10115 return ToIFieldOrErr.takeError();
10118 if (!MemberLocOrErr)
10119 return MemberLocOrErr.takeError();
10122 ToContext, cast_or_null<IndirectFieldDecl>(*ToIFieldOrErr),
10123 *MemberLocOrErr, *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10127 return ToTInfoOrErr.takeError();
10129 return new (ToContext)
10131 *ToExprOrErr, *RParenLocOrErr);
10134 return make_error<ASTImportError>();
10140 auto Pos = ImportedCXXBaseSpecifiers.find(BaseSpec);
10141 if (Pos != ImportedCXXBaseSpecifiers.end())
10142 return Pos->second;
10145 if (!ToSourceRange)
10146 return ToSourceRange.takeError();
10149 return ToTSI.takeError();
10151 if (!ToEllipsisLoc)
10152 return ToEllipsisLoc.takeError();
10156 ImportedCXXBaseSpecifiers[BaseSpec] =
Imported;
10168 return ToOrErr.takeError();
10169 Decl *To = *ToOrErr;
10171 auto *FromDC = cast<DeclContext>(From);
10174 if (
auto *ToRecord = dyn_cast<RecordDecl>(To)) {
10175 if (!ToRecord->getDefinition()) {
10177 cast<RecordDecl>(FromDC), ToRecord,
10182 if (
auto *ToEnum = dyn_cast<EnumDecl>(To)) {
10183 if (!ToEnum->getDefinition()) {
10189 if (
auto *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
10190 if (!ToIFace->getDefinition()) {
10192 cast<ObjCInterfaceDecl>(FromDC), ToIFace,
10197 if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
10198 if (!ToProto->getDefinition()) {
10200 cast<ObjCProtocolDecl>(FromDC), ToProto,
10222 return ToSelOrErr.takeError();
10229 return ToTyOrErr.takeError();
10237 return ToTyOrErr.takeError();
10243 cast<TemplateDecl>(*ToTemplateOrErr));
10245 return ToTemplateOrErr.takeError();
10253 return ToTyOrErr.takeError();
10269 llvm_unreachable(
"Invalid DeclarationName Kind!");
10290 for (
unsigned I = 1, N = FromSel.
getNumArgs(); I < N; ++I)
10298 llvm::Error Err = llvm::Error::success();
10299 auto ImportLoop = [&](
const APValue *From,
APValue *To,
unsigned Size) {
10300 for (
unsigned Idx = 0; Idx < Size; Idx++) {
10305 switch (FromValue.
getKind()) {
10319 ImportLoop(((
const APValue::Vec *)(
const char *)&FromValue.Data)->Elts,
10326 ImportLoop(((
const APValue::Arr *)(
const char *)&FromValue.Data)->Elts,
10327 ((
const APValue::Arr *)(
const char *)&
Result.Data)->Elts,
10334 ((
const APValue::StructData *)(
const char *)&FromValue.Data)->Elts,
10335 ((
const APValue::StructData *)(
const char *)&
Result.Data)->Elts,
10343 return std::move(Err);
10344 Result.setUnion(cast<FieldDecl>(ImpFDecl), ImpValue);
10348 Result.MakeAddrLabelDiff();
10352 return std::move(Err);
10353 Result.setAddrLabelDiff(cast<AddrLabelExpr>(ImpLHS),
10354 cast<AddrLabelExpr>(ImpRHS));
10358 const Decl *ImpMemPtrDecl =
10361 return std::move(Err);
10363 Result.setMemberPointerUninit(
10364 cast<const ValueDecl>(ImpMemPtrDecl),
10368 Result.getMemberPointerPath();
10373 return std::move(Err);
10383 "in C++20 dynamic allocation are transient so they shouldn't "
10384 "appear in the AST");
10386 if (
const auto *
E =
10391 return std::move(Err);
10401 return std::move(Err);
10413 return std::move(Err);
10427 for (
unsigned LoopIdx = 0; LoopIdx < PathLength; LoopIdx++) {
10430 FromPath[LoopIdx].getAsBaseOrMember().getPointer();
10433 return std::move(Err);
10434 if (
auto *RD = dyn_cast<CXXRecordDecl>(
FromDecl))
10437 FromElemTy = cast<ValueDecl>(
FromDecl)->getType();
10439 ImpDecl, FromPath[LoopIdx].getAsBaseOrMember().getInt()));
10444 FromPath[LoopIdx].getAsArrayIndex());
10452 return std::move(Err);
10460 unsigned NumDecls) {
10470 if (LastDiagFromFrom)
10473 LastDiagFromFrom =
false;
10478 if (!LastDiagFromFrom)
10481 LastDiagFromFrom =
true;
10486 if (
auto *ID = dyn_cast<ObjCInterfaceDecl>(
D)) {
10487 if (!ID->getDefinition())
10488 ID->startDefinition();
10490 else if (
auto *PD = dyn_cast<ObjCProtocolDecl>(
D)) {
10491 if (!PD->getDefinition())
10492 PD->startDefinition();
10494 else if (
auto *TD = dyn_cast<TagDecl>(
D)) {
10495 if (!TD->getDefinition() && !TD->isBeingDefined()) {
10496 TD->startDefinition();
10497 TD->setCompleteDefinition(
true);
10501 assert(0 &&
"CompleteDecl called on a Decl that can't be completed");
10506 llvm::DenseMap<Decl *, Decl *>::iterator Pos = ImportedDecls.find(From);
10507 assert((Pos == ImportedDecls.end() || Pos->second == To) &&
10508 "Try to import an already imported Decl");
10509 if (Pos != ImportedDecls.end())
10510 return Pos->second;
10511 ImportedDecls[From] = To;
10514 ImportedFromDecls[To] = From;
10519 AddToLookupTable(To);
10523std::optional<ASTImportError>
10525 auto Pos = ImportDeclErrors.find(FromD);
10526 if (Pos != ImportDeclErrors.end())
10527 return Pos->second;
10529 return std::nullopt;
10533 auto InsertRes = ImportDeclErrors.insert({From, Error});
10537 assert(InsertRes.second || InsertRes.first->second.Error == Error.Error);
10542 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
10544 if (Pos != ImportedTypes.end()) {
10549 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::@1655::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.
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType) 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 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
QualType getPackExpansionType(QualType Pattern, std::optional< unsigned > NumExpansions, bool ExpectPackInType=true)
Form a pack expansion type with the given pattern.
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 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 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.
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, std::optional< unsigned > PackIndex) const
Retrieve a substitution-result type.
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.
llvm::DenseSet< std::pair< Decl *, Decl * > > NonEquivalentDeclSet
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.
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.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
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=std::nullopt)
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=std::nullopt)
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() 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,...
@ 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.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
Declaration of a template type parameter.
void setTypeConstraint(ConceptReference *CR, Expr *ImmediatelyDeclaredConstraint)
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter.
The top declaration context.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Declaration of an alias template.
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.
void updateFlags(const Decl *From, Decl *To)
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__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...
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