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.");
114 Redecls.push_back(R);
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())
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(
371#define TYPE(Class, Base) \
372 ExpectedType Visit##Class##Type(const Class##Type *T);
373#include "clang/AST/TypeNodes.inc"
431 template <
typename InContainerTy>
435 template<
typename InContainerTy>
442 std::tuple<FunctionTemplateDecl *, TemplateArgsTy>;
459 template <
typename T>
463 bool IgnoreTemplateParmDepth =
false);
655 Err = MaybeVal.takeError();
661 template<
typename IIter,
typename OIter>
663 using ItemT = std::remove_reference_t<
decltype(*Obegin)>;
664 for (; Ibegin != Iend; ++Ibegin, ++Obegin) {
667 return ToOrErr.takeError();
670 return Error::success();
677 template<
typename InContainerTy,
typename OutContainerTy>
679 const InContainerTy &InContainer, OutContainerTy &OutContainer) {
681 InContainer.begin(), InContainer.end(), OutContainer.begin());
684 template<
typename InContainerTy,
typename OIter>
701template <
typename InContainerTy>
705 auto ToLAngleLocOrErr =
import(FromLAngleLoc);
706 if (!ToLAngleLocOrErr)
707 return ToLAngleLocOrErr.takeError();
708 auto ToRAngleLocOrErr =
import(FromRAngleLoc);
709 if (!ToRAngleLocOrErr)
710 return ToRAngleLocOrErr.takeError();
716 return Error::success();
720Error ASTNodeImporter::ImportTemplateArgumentListInfo<TemplateArgumentListInfo>(
731 return ImportTemplateArgumentListInfo(
732 From.LAngleLoc, From.RAngleLoc, From.arguments(),
Result);
744 if (Error Err = importInto(std::get<0>(
Result), FTSInfo->getTemplate()))
745 return std::move(Err);
750 return std::move(Err);
760 return std::move(Err);
763 if (!ToRequiresClause)
764 return ToRequiresClause.takeError();
767 if (!ToTemplateLocOrErr)
768 return ToTemplateLocOrErr.takeError();
770 if (!ToLAngleLocOrErr)
771 return ToLAngleLocOrErr.takeError();
773 if (!ToRAngleLocOrErr)
774 return ToRAngleLocOrErr.takeError();
795 return ToTypeOrErr.takeError();
803 return ToTypeOrErr.takeError();
810 return ToOrErr.takeError();
813 return ToTypeOrErr.takeError();
814 return TemplateArgument(dyn_cast<ValueDecl>((*ToOrErr)->getCanonicalDecl()),
821 return ToTypeOrErr.takeError();
829 return ToTypeOrErr.takeError();
832 return ToValueOrErr.takeError();
839 if (!ToTemplateOrErr)
840 return ToTemplateOrErr.takeError();
848 if (!ToTemplateOrErr)
849 return ToTemplateOrErr.takeError();
859 return ToExpr.takeError();
865 return std::move(Err);
872 llvm_unreachable(
"Invalid template argument kind");
880 return ArgOrErr.takeError();
889 return E.takeError();
895 return TSIOrErr.takeError();
897 auto ToTemplateQualifierLocOrErr =
899 if (!ToTemplateQualifierLocOrErr)
900 return ToTemplateQualifierLocOrErr.takeError();
902 if (!ToTemplateNameLocOrErr)
903 return ToTemplateNameLocOrErr.takeError();
904 auto ToTemplateEllipsisLocOrErr =
906 if (!ToTemplateEllipsisLocOrErr)
907 return ToTemplateEllipsisLocOrErr.takeError();
910 *ToTemplateNameLocOrErr, *ToTemplateEllipsisLocOrErr);
920 size_t NumDecls = DG.
end() - DG.
begin();
922 ToDecls.reserve(NumDecls);
923 for (
Decl *FromD : DG) {
924 if (
auto ToDOrErr =
import(FromD))
925 ToDecls.push_back(*ToDOrErr);
927 return ToDOrErr.takeError();
942 return ToDotLocOrErr.takeError();
945 if (!ToFieldLocOrErr)
946 return ToFieldLocOrErr.takeError();
949 ToFieldName, *ToDotLocOrErr, *ToFieldLocOrErr);
953 if (!ToLBracketLocOrErr)
954 return ToLBracketLocOrErr.takeError();
957 if (!ToRBracketLocOrErr)
958 return ToRBracketLocOrErr.takeError();
963 *ToRBracketLocOrErr);
966 if (!ToEllipsisLocOrErr)
967 return ToEllipsisLocOrErr.takeError();
972 *ToRBracketLocOrErr);
977 Error Err = Error::success();
980 auto ToConceptNameLoc =
986 return std::move(Err);
991 return std::move(Err);
1009 return VarOrErr.takeError();
1014 return LocationOrErr.takeError();
1019 return std::move(Err);
1026template <
typename T>
1028 if (Found->getLinkageInternal() != From->getLinkageInternal())
1031 if (From->hasExternalFormalLinkage())
1032 return Found->hasExternalFormalLinkage();
1035 if (From->isInAnonymousNamespace())
1036 return Found->isInAnonymousNamespace();
1038 return !Found->isInAnonymousNamespace() &&
1039 !Found->hasExternalFormalLinkage();
1059using namespace clang;
1068 ExpectedType UnderlyingTypeOrErr =
import(
T->getValueType());
1069 if (!UnderlyingTypeOrErr)
1070 return UnderlyingTypeOrErr.takeError();
1076 switch (
T->getKind()) {
1077#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1078 case BuiltinType::Id: \
1079 return Importer.getToContext().SingletonId;
1080#include "clang/Basic/OpenCLImageTypes.def"
1081#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1082 case BuiltinType::Id: \
1083 return Importer.getToContext().Id##Ty;
1084#include "clang/Basic/OpenCLExtensionTypes.def"
1085#define SVE_TYPE(Name, Id, SingletonId) \
1086 case BuiltinType::Id: \
1087 return Importer.getToContext().SingletonId;
1088#include "clang/Basic/AArch64SVEACLETypes.def"
1089#define PPC_VECTOR_TYPE(Name, Id, Size) \
1090 case BuiltinType::Id: \
1091 return Importer.getToContext().Id##Ty;
1092#include "clang/Basic/PPCTypes.def"
1093#define RVV_TYPE(Name, Id, SingletonId) \
1094 case BuiltinType::Id: \
1095 return Importer.getToContext().SingletonId;
1096#include "clang/Basic/RISCVVTypes.def"
1097#define WASM_TYPE(Name, Id, SingletonId) \
1098 case BuiltinType::Id: \
1099 return Importer.getToContext().SingletonId;
1100#include "clang/Basic/WebAssemblyReferenceTypes.def"
1101#define SHARED_SINGLETON_TYPE(Expansion)
1102#define BUILTIN_TYPE(Id, SingletonId) \
1103 case BuiltinType::Id: return Importer.getToContext().SingletonId;
1104#include "clang/AST/BuiltinTypes.def"
1112 case BuiltinType::Char_U:
1121 case BuiltinType::Char_S:
1130 case BuiltinType::WChar_S:
1131 case BuiltinType::WChar_U:
1137 llvm_unreachable(
"Invalid BuiltinType Kind!");
1141 ExpectedType ToOriginalTypeOrErr =
import(
T->getOriginalType());
1142 if (!ToOriginalTypeOrErr)
1143 return ToOriginalTypeOrErr.takeError();
1149 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1150 if (!ToElementTypeOrErr)
1151 return ToElementTypeOrErr.takeError();
1158 if (!ToPointeeTypeOrErr)
1159 return ToPointeeTypeOrErr.takeError();
1167 if (!ToPointeeTypeOrErr)
1168 return ToPointeeTypeOrErr.takeError();
1176 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1177 if (!ToPointeeTypeOrErr)
1178 return ToPointeeTypeOrErr.takeError();
1186 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1187 if (!ToPointeeTypeOrErr)
1188 return ToPointeeTypeOrErr.takeError();
1197 if (!ToPointeeTypeOrErr)
1198 return ToPointeeTypeOrErr.takeError();
1201 if (!ClassTypeOrErr)
1202 return ClassTypeOrErr.takeError();
1210 Error Err = Error::success();
1214 return std::move(Err);
1217 ToElementType,
T->getSize(), ToSizeExpr,
T->getSizeModifier(),
1218 T->getIndexTypeCVRQualifiers());
1224 if (!ToArrayTypeOrErr)
1225 return ToArrayTypeOrErr.takeError();
1232 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1233 if (!ToElementTypeOrErr)
1234 return ToElementTypeOrErr.takeError();
1237 T->getSizeModifier(),
1238 T->getIndexTypeCVRQualifiers());
1243 Error Err = Error::success();
1248 return std::move(Err);
1250 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1251 T->getIndexTypeCVRQualifiers(), ToBracketsRange);
1254ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(
1256 Error Err = Error::success();
1261 return std::move(Err);
1266 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1267 T->getIndexTypeCVRQualifiers(), ToBracketsRange);
1270ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType(
1272 Error Err = Error::success();
1277 return std::move(Err);
1279 ToElementType, ToSizeExpr, ToAttrLoc);
1283 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1284 if (!ToElementTypeOrErr)
1285 return ToElementTypeOrErr.takeError();
1288 T->getNumElements(),
1289 T->getVectorKind());
1293 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1294 if (!ToElementTypeOrErr)
1295 return ToElementTypeOrErr.takeError();
1298 T->getNumElements());
1306 if (!ToReturnTypeOrErr)
1307 return ToReturnTypeOrErr.takeError();
1316 if (!ToReturnTypeOrErr)
1317 return ToReturnTypeOrErr.takeError();
1324 return TyOrErr.takeError();
1325 ArgTypes.push_back(*TyOrErr);
1333 return TyOrErr.takeError();
1334 ExceptionTypes.push_back(*TyOrErr);
1338 Error Err = Error::success();
1355 return std::move(Err);
1358 *ToReturnTypeOrErr, ArgTypes, ToEPI);
1363 Error Err = Error::success();
1365 auto ToPrevD =
importChecked(Err,
T->getDecl()->getPreviousDecl());
1367 return std::move(Err);
1370 ToD, cast_or_null<TypeDecl>(ToPrevD));
1375 if (!ToInnerTypeOrErr)
1376 return ToInnerTypeOrErr.takeError();
1386 return Pattern.takeError();
1389 return Index.takeError();
1396 return ToDeclOrErr.takeError();
1403 if (!ToUnderlyingTypeOrErr)
1404 return ToUnderlyingTypeOrErr.takeError();
1412 return ToExprOrErr.takeError();
1417 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnmodifiedType());
1418 if (!ToUnderlyingTypeOrErr)
1419 return ToUnderlyingTypeOrErr.takeError();
1427 return FoundOrErr.takeError();
1429 if (!UnderlyingOrErr)
1430 return UnderlyingOrErr.takeError();
1439 return ToExprOrErr.takeError();
1441 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1442 if (!ToUnderlyingTypeOrErr)
1443 return ToUnderlyingTypeOrErr.takeError();
1446 *ToExprOrErr, *ToUnderlyingTypeOrErr);
1452 if (!ToBaseTypeOrErr)
1453 return ToBaseTypeOrErr.takeError();
1455 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1456 if (!ToUnderlyingTypeOrErr)
1457 return ToUnderlyingTypeOrErr.takeError();
1460 *ToBaseTypeOrErr, *ToUnderlyingTypeOrErr,
T->getUTTKind());
1465 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1466 if (!ToDeducedTypeOrErr)
1467 return ToDeducedTypeOrErr.takeError();
1469 ExpectedDecl ToTypeConstraintConcept =
import(
T->getTypeConstraintConcept());
1470 if (!ToTypeConstraintConcept)
1471 return ToTypeConstraintConcept.takeError();
1476 return std::move(Err);
1479 *ToDeducedTypeOrErr,
T->getKeyword(),
false,
1480 false, cast_or_null<ConceptDecl>(*ToTypeConstraintConcept),
1484ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
1488 if (!ToTemplateNameOrErr)
1489 return ToTemplateNameOrErr.takeError();
1490 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1491 if (!ToDeducedTypeOrErr)
1492 return ToDeducedTypeOrErr.takeError();
1498ExpectedType ASTNodeImporter::VisitInjectedClassNameType(
1502 return ToDeclOrErr.takeError();
1506 const Type *Ty = (*ToDeclOrErr)->getTypeForDecl();
1507 assert(Ty && isa<InjectedClassNameType>(Ty));
1514 return ToDeclOrErr.takeError();
1522 return ToDeclOrErr.takeError();
1528 ExpectedType ToModifiedTypeOrErr =
import(
T->getModifiedType());
1529 if (!ToModifiedTypeOrErr)
1530 return ToModifiedTypeOrErr.takeError();
1531 ExpectedType ToEquivalentTypeOrErr =
import(
T->getEquivalentType());
1532 if (!ToEquivalentTypeOrErr)
1533 return ToEquivalentTypeOrErr.takeError();
1536 *ToModifiedTypeOrErr, *ToEquivalentTypeOrErr);
1542 if (!ToWrappedTypeOrErr)
1543 return ToWrappedTypeOrErr.takeError();
1545 Error Err = Error::success();
1549 for (
auto TI :
T->dependent_decls()) {
1552 return ToDeclOrErr.takeError();
1553 CoupledDecls.emplace_back(*ToDeclOrErr, TI.isDeref());
1557 *ToWrappedTypeOrErr, CountExpr,
T->isCountInBytes(),
T->isOrNull(),
1558 ArrayRef(CoupledDecls.data(), CoupledDecls.size()));
1561ExpectedType ASTNodeImporter::VisitTemplateTypeParmType(
1565 return ToDeclOrErr.takeError();
1568 T->getDepth(),
T->getIndex(),
T->isParameterPack(), *ToDeclOrErr);
1571ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmType(
1575 return ReplacedOrErr.takeError();
1577 ExpectedType ToReplacementTypeOrErr =
import(
T->getReplacementType());
1578 if (!ToReplacementTypeOrErr)
1579 return ToReplacementTypeOrErr.takeError();
1582 *ToReplacementTypeOrErr, *ReplacedOrErr,
T->getIndex(),
1586ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmPackType(
1590 return ReplacedOrErr.takeError();
1593 if (!ToArgumentPack)
1594 return ToArgumentPack.takeError();
1597 *ReplacedOrErr,
T->getIndex(),
T->getFinal(), *ToArgumentPack);
1600ExpectedType ASTNodeImporter::VisitTemplateSpecializationType(
1602 auto ToTemplateOrErr =
import(
T->getTemplateName());
1603 if (!ToTemplateOrErr)
1604 return ToTemplateOrErr.takeError();
1609 return std::move(Err);
1616 ToCanonType = *TyOrErr;
1618 return TyOrErr.takeError();
1627 auto ToQualifierOrErr =
import(
T->getQualifier());
1628 if (!ToQualifierOrErr)
1629 return ToQualifierOrErr.takeError();
1632 if (!ToNamedTypeOrErr)
1633 return ToNamedTypeOrErr.takeError();
1636 if (!ToOwnedTagDeclOrErr)
1637 return ToOwnedTagDeclOrErr.takeError();
1642 *ToOwnedTagDeclOrErr);
1648 if (!ToPatternOrErr)
1649 return ToPatternOrErr.takeError();
1652 T->getNumExpansions(),
1656ExpectedType ASTNodeImporter::VisitDependentTemplateSpecializationType(
1658 auto ToQualifierOrErr =
import(
T->getQualifier());
1659 if (!ToQualifierOrErr)
1660 return ToQualifierOrErr.takeError();
1665 ToPack.reserve(
T->template_arguments().size());
1667 return std::move(Err);
1670 T->getKeyword(), *ToQualifierOrErr, ToName, ToPack);
1675 auto ToQualifierOrErr =
import(
T->getQualifier());
1676 if (!ToQualifierOrErr)
1677 return ToQualifierOrErr.takeError();
1686 return TyOrErr.takeError();
1698 return ToDeclOrErr.takeError();
1705 if (!ToBaseTypeOrErr)
1706 return ToBaseTypeOrErr.takeError();
1709 for (
auto TypeArg :
T->getTypeArgsAsWritten()) {
1711 TypeArgs.push_back(*TyOrErr);
1713 return TyOrErr.takeError();
1717 for (
auto *
P :
T->quals()) {
1719 Protocols.push_back(*ProtocolOrErr);
1721 return ProtocolOrErr.takeError();
1727 T->isKindOfTypeAsWritten());
1733 if (!ToPointeeTypeOrErr)
1734 return ToPointeeTypeOrErr.takeError();
1741 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1742 if (!ToUnderlyingTypeOrErr)
1743 return ToUnderlyingTypeOrErr.takeError();
1751 Error Err = Error::success();
1752 QualType ToOriginalType = importChecked(Err,
T->getOriginalType());
1753 QualType ToAdjustedType = importChecked(Err,
T->getAdjustedType());
1755 return std::move(Err);
1757 return Importer.getToContext().getAdjustedType(ToOriginalType,
1762 return Importer.getToContext().getBitIntType(
T->isUnsigned(),
1766ExpectedType clang::ASTNodeImporter::VisitBTFTagAttributedType(
1768 Error Err = Error::success();
1769 const BTFTypeTagAttr *ToBTFAttr = importChecked(Err,
T->getAttr());
1770 QualType ToWrappedType = importChecked(Err,
T->getWrappedType());
1772 return std::move(Err);
1774 return Importer.getToContext().getBTFTagAttributedType(ToBTFAttr,
1778ExpectedType clang::ASTNodeImporter::VisitConstantMatrixType(
1780 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1781 if (!ToElementTypeOrErr)
1782 return ToElementTypeOrErr.takeError();
1784 return Importer.getToContext().getConstantMatrixType(
1785 *ToElementTypeOrErr,
T->getNumRows(),
T->getNumColumns());
1788ExpectedType clang::ASTNodeImporter::VisitDependentAddressSpaceType(
1790 Error Err = Error::success();
1792 Expr *ToAddrSpaceExpr = importChecked(Err,
T->getAddrSpaceExpr());
1795 return std::move(Err);
1797 return Importer.getToContext().getDependentAddressSpaceType(
1798 ToPointeeType, ToAddrSpaceExpr, ToAttrLoc);
1801ExpectedType clang::ASTNodeImporter::VisitDependentBitIntType(
1803 ExpectedExpr ToNumBitsExprOrErr =
import(
T->getNumBitsExpr());
1804 if (!ToNumBitsExprOrErr)
1805 return ToNumBitsExprOrErr.takeError();
1806 return Importer.getToContext().getDependentBitIntType(
T->isUnsigned(),
1807 *ToNumBitsExprOrErr);
1810ExpectedType clang::ASTNodeImporter::VisitDependentSizedMatrixType(
1812 Error Err = Error::success();
1813 QualType ToElementType = importChecked(Err,
T->getElementType());
1814 Expr *ToRowExpr = importChecked(Err,
T->getRowExpr());
1815 Expr *ToColumnExpr = importChecked(Err,
T->getColumnExpr());
1818 return std::move(Err);
1820 return Importer.getToContext().getDependentSizedMatrixType(
1821 ToElementType, ToRowExpr, ToColumnExpr, ToAttrLoc);
1824ExpectedType clang::ASTNodeImporter::VisitDependentVectorType(
1826 Error Err = Error::success();
1827 QualType ToElementType = importChecked(Err,
T->getElementType());
1828 Expr *ToSizeExpr = importChecked(Err,
T->getSizeExpr());
1831 return std::move(Err);
1833 return Importer.getToContext().getDependentVectorType(
1834 ToElementType, ToSizeExpr, ToAttrLoc,
T->getVectorKind());
1837ExpectedType clang::ASTNodeImporter::VisitObjCTypeParamType(
1841 return ToDeclOrErr.takeError();
1846 if (!ToProtocolOrErr)
1847 return ToProtocolOrErr.takeError();
1848 ToProtocols.push_back(*ToProtocolOrErr);
1851 return Importer.getToContext().getObjCTypeParamType(*ToDeclOrErr,
1856 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1857 if (!ToElementTypeOrErr)
1858 return ToElementTypeOrErr.takeError();
1861 if (
T->isReadOnly())
1881 if (isa<RecordDecl>(D) && (FunDecl = dyn_cast<FunctionDecl>(OrigDC)) &&
1883 auto getLeafPointeeType = [](
const Type *
T) {
1891 getLeafPointeeType(
P->getType().getCanonicalType().getTypePtr());
1892 auto *RT = dyn_cast<RecordType>(LeafT);
1893 if (RT && RT->getDecl() == D) {
1906 if (Error Err = importInto(Name, D->
getDeclName()))
1910 if (Error Err = importInto(Loc, D->
getLocation()))
1918 return Error::success();
1925 if (Error Err = importInto(Name, D->
getDeclName()))
1929 if (Error Err = importInto(Loc, D->
getLocation()))
1937 return Error::success();
1942 return Error::success();
1945 if (Error Err = importInto(ToD, FromD))
1948 if (
RecordDecl *FromRecord = dyn_cast<RecordDecl>(FromD)) {
1949 if (
RecordDecl *ToRecord = cast<RecordDecl>(ToD)) {
1950 if (FromRecord->getDefinition() && FromRecord->isCompleteDefinition() &&
1951 !ToRecord->getDefinition()) {
1956 return Error::success();
1959 if (
EnumDecl *FromEnum = dyn_cast<EnumDecl>(FromD)) {
1960 if (
EnumDecl *ToEnum = cast<EnumDecl>(ToD)) {
1961 if (FromEnum->getDefinition() && !ToEnum->getDefinition()) {
1966 return Error::success();
1969 return Error::success();
1984 return Error::success();
1990 return ToRangeOrErr.takeError();
1991 return Error::success();
1997 return LocOrErr.takeError();
1998 return Error::success();
2006 return ToTInfoOrErr.takeError();
2007 return Error::success();
2010 llvm_unreachable(
"Unknown name kind.");
2017 return ToDCOrErr.takeError();
2031 auto MightNeedReordering = [](
const Decl *D) {
2032 return isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D) || isa<FriendDecl>(D);
2036 Error ChildErrors = Error::success();
2037 for (
auto *From : FromDC->
decls()) {
2038 if (!MightNeedReordering(From))
2047 if (!ImportedOrErr) {
2049 ImportedOrErr.takeError());
2052 FieldDecl *FieldFrom = dyn_cast_or_null<FieldDecl>(From);
2053 Decl *ImportedDecl = *ImportedOrErr;
2054 FieldDecl *FieldTo = dyn_cast_or_null<FieldDecl>(ImportedDecl);
2055 if (FieldFrom && FieldTo) {
2087 consumeError(std::move(ChildErrors));
2088 return ToDCOrErr.takeError();
2091 if (
const auto *FromRD = dyn_cast<RecordDecl>(FromDC)) {
2095 for (
auto *D : FromRD->decls()) {
2096 if (!MightNeedReordering(D))
2099 assert(D &&
"DC contains a null decl");
2102 assert(ToDC == ToD->getLexicalDeclContext() && ToDC->
containsDecl(ToD));
2114 for (
auto *From : FromDC->
decls()) {
2115 if (MightNeedReordering(From))
2121 ImportedOrErr.takeError());
2141 if (!FromRecordDecl || !ToRecordDecl) {
2145 if (RecordFrom && RecordTo) {
2146 FromRecordDecl = RecordFrom->
getDecl();
2147 ToRecordDecl = RecordTo->getDecl();
2151 if (FromRecordDecl && ToRecordDecl) {
2157 return Error::success();
2164 return ToDCOrErr.takeError();
2170 if (!ToLexicalDCOrErr)
2171 return ToLexicalDCOrErr.takeError();
2172 ToLexicalDC = *ToLexicalDCOrErr;
2176 return Error::success();
2182 "Import implicit methods to or from non-definition");
2185 if (FromM->isImplicit()) {
2188 return ToMOrErr.takeError();
2191 return Error::success();
2200 return ToTypedefOrErr.takeError();
2202 return Error::success();
2207 auto DefinitionCompleter = [To]() {
2226 auto *FromCXXRD = cast<CXXRecordDecl>(From);
2228 ToCaptures.reserve(FromCXXRD->capture_size());
2229 for (
const auto &FromCapture : FromCXXRD->captures()) {
2230 if (
auto ToCaptureOrErr =
import(FromCapture))
2231 ToCaptures.push_back(*ToCaptureOrErr);
2233 return ToCaptureOrErr.takeError();
2235 cast<CXXRecordDecl>(To)->setCaptures(Importer.
getToContext(),
2242 DefinitionCompleter();
2246 return Error::success();
2261 auto DefinitionCompleterScopeExit =
2262 llvm::make_scope_exit(DefinitionCompleter);
2268 auto *ToCXX = dyn_cast<CXXRecordDecl>(To);
2269 auto *FromCXX = dyn_cast<CXXRecordDecl>(From);
2270 if (ToCXX && FromCXX && ToCXX->dataPtr() && FromCXX->dataPtr()) {
2272 struct CXXRecordDecl::DefinitionData &ToData = ToCXX->data();
2273 struct CXXRecordDecl::DefinitionData &FromData = FromCXX->data();
2275 #define FIELD(Name, Width, Merge) \
2276 ToData.Name = FromData.Name;
2277 #include "clang/AST/CXXRecordDeclDefinitionBits.def"
2280 ToCXX->setArgPassingRestrictions(FromCXX->getArgPassingRestrictions());
2283 for (
const auto &Base1 : FromCXX->bases()) {
2286 return TyOrErr.takeError();
2289 if (Base1.isPackExpansion()) {
2290 if (
ExpectedSLoc LocOrErr =
import(Base1.getEllipsisLoc()))
2291 EllipsisLoc = *LocOrErr;
2293 return LocOrErr.takeError();
2301 auto RangeOrErr =
import(Base1.getSourceRange());
2303 return RangeOrErr.takeError();
2305 auto TSIOrErr =
import(Base1.getTypeSourceInfo());
2307 return TSIOrErr.takeError();
2313 Base1.isBaseOfClass(),
2314 Base1.getAccessSpecifierAsWritten(),
2319 ToCXX->setBases(Bases.data(), Bases.size());
2327 return Error::success();
2332 return Error::success();
2336 return Error::success();
2340 return ToInitOrErr.takeError();
2351 return Error::success();
2359 return Error::success();
2370 return ToTypeOrErr.takeError();
2373 if (!ToPromotionTypeOrErr)
2374 return ToPromotionTypeOrErr.takeError();
2385 return Error::success();
2391 for (
const auto &Arg : FromArgs) {
2392 if (
auto ToOrErr =
import(Arg))
2393 ToArgs.push_back(*ToOrErr);
2395 return ToOrErr.takeError();
2398 return Error::success();
2404 return import(From);
2407template <
typename InContainerTy>
2410 for (
const auto &FromLoc : Container) {
2411 if (
auto ToLocOrErr =
import(FromLoc))
2414 return ToLocOrErr.takeError();
2416 return Error::success();
2426 bool IgnoreTemplateParmDepth) {
2437 false, Complain,
false,
2438 IgnoreTemplateParmDepth);
2458 return std::move(Err);
2463 return LocOrErr.takeError();
2466 if (GetImportedOrCreateDecl(ToD, D, Importer.
getToContext(), DC, *LocOrErr))
2489 return std::move(Err);
2494 if (GetImportedOrCreateDecl(ToD, D, Importer.
getToContext(), DC, Loc,
2495 Name.getAsIdentifierInfo()))
2498 Error Err = Error::success();
2503 return std::move(Err);
2507 addDeclToContexts(D, ToD);
2515 return LocOrErr.takeError();
2518 return ColonLocOrErr.takeError();
2523 return DCOrErr.takeError();
2528 DC, *LocOrErr, *ColonLocOrErr))
2542 return DCOrErr.takeError();
2546 Error Err = Error::success();
2552 return std::move(Err);
2555 if (GetImportedOrCreateDecl(
2556 ToD, D, Importer.
getToContext(), DC, ToLocation, ToAssertExpr, ToMessage,
2572 return std::move(Err);
2581 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2587 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2588 for (
auto *FoundDecl : FoundDecls) {
2592 if (
auto *FoundNS = dyn_cast<NamespaceDecl>(FoundDecl)) {
2593 MergeWithNamespace = FoundNS;
2594 ConflictingDecls.clear();
2598 ConflictingDecls.push_back(FoundDecl);
2601 if (!ConflictingDecls.empty()) {
2604 ConflictingDecls.size());
2606 Name = NameOrErr.get();
2608 return NameOrErr.takeError();
2614 return BeginLocOrErr.takeError();
2616 if (!RBraceLocOrErr)
2617 return RBraceLocOrErr.takeError();
2622 if (GetImportedOrCreateDecl(ToNamespace, D, Importer.
getToContext(), DC,
2623 D->
isInline(), *BeginLocOrErr, Loc,
2624 Name.getAsIdentifierInfo(),
2634 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2635 TU->setAnonymousNamespace(ToNamespace);
2637 cast<NamespaceDecl>(DC)->setAnonymousNamespace(ToNamespace);
2643 return std::move(Err);
2654 if (Error Err =
ImportDeclParts(D, DC, LexicalDC, Name, LookupD, Loc))
2655 return std::move(Err);
2661 Error Err = Error::success();
2668 return std::move(Err);
2673 if (GetImportedOrCreateDecl(
2674 ToD, D, Importer.
getToContext(), DC, ToNamespaceLoc, ToAliasLoc,
2675 ToIdentifier, ToQualifierLoc, ToTargetNameLoc, ToNamespace))
2693 return std::move(Err);
2712 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2713 for (
auto *FoundDecl : FoundDecls) {
2716 if (
auto *FoundTypedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
2721 QualType FoundUT = FoundTypedef->getUnderlyingType();
2735 if (FromR && FoundR &&
2746 ConflictingDecls.push_back(FoundDecl);
2751 if (!ConflictingDecls.empty()) {
2753 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
2755 Name = NameOrErr.get();
2757 return NameOrErr.takeError();
2761 Error Err = Error::success();
2766 return std::move(Err);
2773 if (GetImportedOrCreateDecl<TypeAliasDecl>(
2774 ToTypedef, D, Importer.
getToContext(), DC, ToBeginLoc, Loc,
2775 Name.getAsIdentifierInfo(), ToTypeSourceInfo))
2777 }
else if (GetImportedOrCreateDecl<TypedefDecl>(
2778 ToTypedef, D, Importer.
getToContext(), DC, ToBeginLoc, Loc,
2779 Name.getAsIdentifierInfo(), ToTypeSourceInfo))
2784 return std::move(Err);
2788 Importer.AddToLookupTable(ToTypedef);
2793 TypeAliasDecl *FromAlias = IsAlias ? cast<TypeAliasDecl>(D) :
nullptr;
2816 return std::move(Err);
2826 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2827 for (
auto *FoundDecl : FoundDecls) {
2830 if (
auto *FoundAlias = dyn_cast<TypeAliasTemplateDecl>(FoundDecl)) {
2833 ConflictingDecls.push_back(FoundDecl);
2837 if (!ConflictingDecls.empty()) {
2839 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
2841 Name = NameOrErr.get();
2843 return NameOrErr.takeError();
2847 Error Err = Error::success();
2851 return std::move(Err);
2854 if (GetImportedOrCreateDecl(ToAlias, D, Importer.
getToContext(), DC, Loc,
2855 Name, ToTemplateParameters, ToTemplatedDecl))
2858 ToTemplatedDecl->setDescribedAliasTemplate(ToAlias);
2864 updateLookupTableForTemplateParameters(*ToTemplateParameters);
2875 return std::move(Err);
2885 return BeginLocOrErr.takeError();
2886 if (GetImportedOrCreateDecl(ToLabel, D, Importer.
getToContext(), DC, Loc,
2887 Name.getAsIdentifierInfo(), *BeginLocOrErr))
2891 if (GetImportedOrCreateDecl(ToLabel, D, Importer.
getToContext(), DC, Loc,
2892 Name.getAsIdentifierInfo()))
2899 return ToStmtOrErr.takeError();
2901 ToLabel->
setStmt(*ToStmtOrErr);
2914 return std::move(Err);
2922 if (Error Err = importInto(
2924 return std::move(Err);
2934 Importer.findDeclsInToCtx(DC, SearchName);
2935 for (
auto *FoundDecl : FoundDecls) {
2939 if (
auto *Typedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
2940 if (
const auto *Tag = Typedef->getUnderlyingType()->getAs<
TagType>())
2941 FoundDecl = Tag->getDecl();
2944 if (
auto *FoundEnum = dyn_cast<EnumDecl>(FoundDecl)) {
2954 ConflictingDecls.push_back(FoundDecl);
2958 if (!ConflictingDecls.empty()) {
2960 SearchName, DC, IDNS, ConflictingDecls.data(),
2961 ConflictingDecls.size());
2963 Name = NameOrErr.get();
2965 return NameOrErr.takeError();
2969 Error Err = Error::success();
2975 return std::move(Err);
2979 if (GetImportedOrCreateDecl(
2981 Loc, Name.getAsIdentifierInfo(), PrevDecl, D->
isScoped(),
2990 addDeclToContexts(D, D2);
2996 D2->setInstantiationOfMemberEnum(*ToInstOrErr, SK);
2998 return ToInstOrErr.takeError();
2999 if (
ExpectedSLoc POIOrErr =
import(MemberInfo->getPointOfInstantiation()))
3002 return POIOrErr.takeError();
3008 return std::move(Err);
3014 bool IsFriendTemplate =
false;
3015 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3017 DCXX->getDescribedClassTemplate() &&
3018 DCXX->getDescribedClassTemplate()->getFriendObjectKind() !=
3028 return std::move(Err);
3036 if (Error Err = importInto(
3038 return std::move(Err);
3045 bool DependentFriend = IsFriendTemplate && IsDependentContext;
3052 Importer.findDeclsInToCtx(DC, SearchName);
3053 if (!FoundDecls.empty()) {
3060 for (
auto *FoundDecl : FoundDecls) {
3064 Decl *Found = FoundDecl;
3065 if (
auto *Typedef = dyn_cast<TypedefNameDecl>(Found)) {
3066 if (
const auto *Tag = Typedef->getUnderlyingType()->getAs<
TagType>())
3067 Found = Tag->getDecl();
3070 if (
auto *FoundRecord = dyn_cast<RecordDecl>(Found)) {
3093 if (
const auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3094 auto *FoundCXX = dyn_cast<CXXRecordDecl>(FoundDef);
3095 assert(FoundCXX &&
"Record type mismatch");
3101 return std::move(Err);
3107 ConflictingDecls.push_back(FoundDecl);
3111 if (!ConflictingDecls.empty() && SearchName) {
3113 SearchName, DC, IDNS, ConflictingDecls.data(),
3114 ConflictingDecls.size());
3116 Name = NameOrErr.get();
3118 return NameOrErr.takeError();
3124 return BeginLocOrErr.takeError();
3129 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3130 if (DCXX->isLambda()) {
3131 auto TInfoOrErr =
import(DCXX->getLambdaTypeInfo());
3133 return TInfoOrErr.takeError();
3134 if (GetImportedOrCreateSpecialDecl(
3136 DC, *TInfoOrErr, Loc, DCXX->getLambdaDependencyKind(),
3137 DCXX->isGenericLambda(), DCXX->getLambdaCaptureDefault()))
3142 return CDeclOrErr.takeError();
3145 }
else if (DCXX->isInjectedClassName()) {
3148 const bool DelayTypeCreation =
true;
3149 if (GetImportedOrCreateDecl(
3151 *BeginLocOrErr, Loc, Name.getAsIdentifierInfo(),
3152 cast_or_null<CXXRecordDecl>(PrevDecl), DelayTypeCreation))
3155 D2CXX, dyn_cast<CXXRecordDecl>(DC));
3157 if (GetImportedOrCreateDecl(D2CXX, D, Importer.
getToContext(),
3159 Name.getAsIdentifierInfo(),
3160 cast_or_null<CXXRecordDecl>(PrevDecl)))
3167 addDeclToContexts(D, D2);
3170 DCXX->getDescribedClassTemplate()) {
3172 if (Error Err = importInto(ToDescribed, FromDescribed))
3173 return std::move(Err);
3175 if (!DCXX->isInjectedClassName() && !IsFriendTemplate) {
3182 auto *
Record = dyn_cast<CXXRecordDecl>(Found);
3195 const Type *FrontTy =
3196 cast<CXXRecordDecl>(Redecls.front())->getTypeForDecl();
3199 InjSpec = InjTy->getInjectedSpecializationType();
3202 for (
auto *R : Redecls) {
3203 auto *RI = cast<CXXRecordDecl>(R);
3204 if (R != Redecls.front() ||
3205 !isa<InjectedClassNameType>(RI->getTypeForDecl()))
3206 RI->setTypeForDecl(
nullptr);
3221 DCXX->getMemberSpecializationInfo()) {
3223 MemberInfo->getTemplateSpecializationKind();
3229 return ToInstOrErr.takeError();
3232 import(MemberInfo->getPointOfInstantiation()))
3236 return POIOrErr.takeError();
3240 if (GetImportedOrCreateDecl(D2, D, Importer.
getToContext(),
3242 Name.getAsIdentifierInfo(), PrevDecl))
3245 addDeclToContexts(D, D2);
3251 return BraceRangeOrErr.takeError();
3255 return QualifierLocOrErr.takeError();
3262 return std::move(Err);
3274 return std::move(Err);
3283 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3284 for (
auto *FoundDecl : FoundDecls) {
3288 if (
auto *FoundEnumConstant = dyn_cast<EnumConstantDecl>(FoundDecl)) {
3290 return Importer.
MapImported(D, FoundEnumConstant);
3291 ConflictingDecls.push_back(FoundDecl);
3295 if (!ConflictingDecls.empty()) {
3297 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3299 Name = NameOrErr.get();
3301 return NameOrErr.takeError();
3307 return TypeOrErr.takeError();
3311 return InitOrErr.takeError();
3314 if (GetImportedOrCreateDecl(
3315 ToEnumerator, D, Importer.
getToContext(), cast<EnumDecl>(DC), Loc,
3316 Name.getAsIdentifierInfo(), *TypeOrErr, *InitOrErr, D->
getInitVal()))
3317 return ToEnumerator;
3322 return ToEnumerator;
3329 return Error::success();
3331 for (
unsigned int I = 0; I < Num; ++I)
3334 ToTPLists[I] = *ToTPListOrErr;
3336 return ToTPListOrErr.takeError();
3338 return Error::success();
3346 return Error::success();
3352 return Error::success();
3358 ToFD->setInstantiationOfMemberFunction(*InstFDOrErr, TSK);
3360 return InstFDOrErr.takeError();
3366 return POIOrErr.takeError();
3368 return Error::success();
3372 auto FunctionAndArgsOrErr =
3374 if (!FunctionAndArgsOrErr)
3375 return FunctionAndArgsOrErr.takeError();
3378 Importer.
getToContext(), std::get<1>(*FunctionAndArgsOrErr));
3382 const auto *FromTAArgsAsWritten = FTSInfo->TemplateArgumentsAsWritten;
3383 if (FromTAArgsAsWritten)
3385 *FromTAArgsAsWritten, ToTAInfo))
3388 ExpectedSLoc POIOrErr =
import(FTSInfo->getPointOfInstantiation());
3390 return POIOrErr.takeError();
3396 ToFD->setFunctionTemplateSpecialization(
3397 std::get<0>(*FunctionAndArgsOrErr), ToTAList,
nullptr,
3398 TSK, FromTAArgsAsWritten ? &ToTAInfo :
nullptr, *POIOrErr);
3399 return Error::success();
3407 Candidates.
addDecl(*ToFTDOrErr);
3409 return ToFTDOrErr.takeError();
3414 const auto *FromTAArgsAsWritten = FromInfo->TemplateArgumentsAsWritten;
3415 if (FromTAArgsAsWritten)
3422 FromTAArgsAsWritten ? &ToTAInfo :
nullptr);
3423 return Error::success();
3426 llvm_unreachable(
"All cases should be covered!");
3431 auto FunctionAndArgsOrErr =
3433 if (!FunctionAndArgsOrErr)
3434 return FunctionAndArgsOrErr.takeError();
3438 std::tie(Template, ToTemplArgs) = *FunctionAndArgsOrErr;
3439 void *InsertPos =
nullptr;
3450 return ToBodyOrErr.takeError();
3452 return Error::success();
3458 const DeclContext *DCi = dyn_cast<DeclContext>(D);
3461 assert(DCi &&
"Declaration should have a context");
3475 ToProcess.push_back(S);
3476 while (!ToProcess.empty()) {
3477 const Stmt *CurrentS = ToProcess.pop_back_val();
3479 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(CurrentS)) {
3480 if (
const Decl *D = DeclRef->getDecl())
3483 }
else if (
const auto *E =
3484 dyn_cast_or_null<SubstNonTypeTemplateParmExpr>(CurrentS)) {
3485 if (
const Decl *D = E->getAssociatedDecl())
3518class IsTypeDeclaredInsideVisitor
3519 :
public TypeVisitor<IsTypeDeclaredInsideVisitor, std::optional<bool>> {
3521 IsTypeDeclaredInsideVisitor(
const FunctionDecl *ParentDC)
3522 : ParentDC(ParentDC) {}
3528 if (std::optional<bool> Res = Visit(
T.getTypePtr()))
3531 T.getSingleStepDesugaredType(ParentDC->getParentASTContext());
3533 if (std::optional<bool> Res = Visit(DsT.
getTypePtr()))
3536 DsT =
T.getSingleStepDesugaredType(ParentDC->getParentASTContext());
3541 std::optional<bool> VisitTagType(
const TagType *
T) {
3542 if (
auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(
T->getDecl()))
3543 for (
const auto &Arg : Spec->getTemplateArgs().asArray())
3544 if (checkTemplateArgument(Arg))
3549 std::optional<bool> VisitPointerType(
const PointerType *
T) {
3554 return CheckType(
T->getPointeeTypeAsWritten());
3557 std::optional<bool> VisitTypedefType(
const TypedefType *
T) {
3563 std::optional<bool> VisitUsingType(
const UsingType *
T) {
3564 if (
T->getFoundDecl() &&
3573 for (
const auto &Arg :
T->template_arguments())
3574 if (checkTemplateArgument(Arg))
3592 return CheckType(
T->getElementType());
3597 "Variable array should not occur in deduced return type of a function");
3601 llvm_unreachable(
"Incomplete array should not occur in deduced return type "
3606 llvm_unreachable(
"Dependent array should not occur in deduced return type "
3633 if (checkTemplateArgument(PackArg))
3645 llvm_unreachable(
"Unknown TemplateArgument::ArgKind enum");
3655 assert(FromFPT &&
"Must be called on FunctionProtoType");
3657 auto IsCXX11LambdaWithouTrailingReturn = [&]() {
3658 if (Importer.FromContext.
getLangOpts().CPlusPlus14)
3661 if (FromFPT->hasTrailingReturn())
3664 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D))
3665 return cast<CXXRecordDecl>(MD->getDeclContext())->isLambda();
3670 QualType RetT = FromFPT->getReturnType();
3671 if (isa<AutoType>(RetT.
getTypePtr()) || IsCXX11LambdaWithouTrailingReturn()) {
3673 IsTypeDeclaredInsideVisitor Visitor(Def ? Def : D);
3674 return Visitor.CheckType(RetT);
3691 auto RedeclIt = Redecls.begin();
3694 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
3697 return ToRedeclOrErr.takeError();
3699 assert(*RedeclIt == D);
3707 return std::move(Err);
3722 if (!FoundFunctionOrErr)
3723 return FoundFunctionOrErr.takeError();
3724 if (
FunctionDecl *FoundFunction = *FoundFunctionOrErr) {
3725 if (
Decl *Def = FindAndMapDefinition(D, FoundFunction))
3727 FoundByLookup = FoundFunction;
3735 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3736 for (
auto *FoundDecl : FoundDecls) {
3740 if (
auto *FoundFunction = dyn_cast<FunctionDecl>(FoundDecl)) {
3745 if (
Decl *Def = FindAndMapDefinition(D, FoundFunction))
3747 FoundByLookup = FoundFunction;
3758 Importer.
ToDiag(Loc, diag::warn_odr_function_type_inconsistent)
3759 << Name << D->
getType() << FoundFunction->getType();
3760 Importer.
ToDiag(FoundFunction->getLocation(), diag::note_odr_value_here)
3761 << FoundFunction->getType();
3762 ConflictingDecls.push_back(FoundDecl);
3766 if (!ConflictingDecls.empty()) {
3768 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3770 Name = NameOrErr.get();
3772 return NameOrErr.takeError();
3782 if (FoundByLookup) {
3783 if (isa<CXXMethodDecl>(FoundByLookup)) {
3792 "Templated function mapped to non-templated?");
3808 return std::move(Err);
3819 bool UsedDifferentProtoType =
false;
3821 QualType FromReturnTy = FromFPT->getReturnType();
3829 UsedDifferentProtoType =
true;
3840 FromEPI = DefaultEPI;
3841 UsedDifferentProtoType =
true;
3844 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
3849 Error Err = Error::success();
3856 auto TrailingRequiresClause =
3859 return std::move(Err);
3865 Parameters.push_back(*ToPOrErr);
3867 return ToPOrErr.takeError();
3872 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
3874 importExplicitSpecifier(Err, FromConstructor->getExplicitSpecifier());
3876 return std::move(Err);
3878 if (FromConstructor->isInheritingConstructor()) {
3880 import(FromConstructor->getInheritedConstructor());
3881 if (!ImportedInheritedCtor)
3882 return ImportedInheritedCtor.takeError();
3883 ToInheritedConstructor = *ImportedInheritedCtor;
3885 if (GetImportedOrCreateDecl<CXXConstructorDecl>(
3886 ToFunction, D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3887 ToInnerLocStart, NameInfo,
T, TInfo, ESpec, D->
UsesFPIntrin(),
3889 ToInheritedConstructor, TrailingRequiresClause))
3893 Error Err = Error::success();
3895 Err,
const_cast<FunctionDecl *
>(FromDtor->getOperatorDelete()));
3896 auto ToThisArg =
importChecked(Err, FromDtor->getOperatorDeleteThisArg());
3898 return std::move(Err);
3900 if (GetImportedOrCreateDecl<CXXDestructorDecl>(
3901 ToFunction, D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3904 TrailingRequiresClause))
3911 dyn_cast<CXXConversionDecl>(D)) {
3913 importExplicitSpecifier(Err, FromConversion->getExplicitSpecifier());
3915 return std::move(Err);
3916 if (GetImportedOrCreateDecl<CXXConversionDecl>(
3917 ToFunction, D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3922 }
else if (
auto *Method = dyn_cast<CXXMethodDecl>(D)) {
3923 if (GetImportedOrCreateDecl<CXXMethodDecl>(
3924 ToFunction, D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3925 ToInnerLocStart, NameInfo,
T, TInfo, Method->getStorageClass(),
3926 Method->UsesFPIntrin(), Method->isInlineSpecified(),
3929 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(D)) {
3931 importExplicitSpecifier(Err, Guide->getExplicitSpecifier());
3935 return std::move(Err);
3936 if (GetImportedOrCreateDecl<CXXDeductionGuideDecl>(
3937 ToFunction, D, Importer.
getToContext(), DC, ToInnerLocStart, ESpec,
3938 NameInfo,
T, TInfo, ToEndLoc, Ctor))
3940 cast<CXXDeductionGuideDecl>(ToFunction)
3941 ->setDeductionCandidateKind(Guide->getDeductionCandidateKind());
3943 if (GetImportedOrCreateDecl(
3944 ToFunction, D, Importer.
getToContext(), DC, ToInnerLocStart,
3952 if (FoundByLookup) {
3965 auto Imported =
import(Msg);
3967 return Imported.takeError();
3991 for (
auto *Param : Parameters) {
3992 Param->setOwningFunction(ToFunction);
3997 ToFunction->setParams(Parameters);
4004 for (
unsigned I = 0, N = Parameters.size(); I != N; ++I)
4005 ProtoLoc.setParam(I, Parameters[I]);
4011 auto ToFTOrErr =
import(FromFT);
4013 return ToFTOrErr.takeError();
4017 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
4018 if (
unsigned NumInitializers = FromConstructor->getNumCtorInitializers()) {
4022 FromConstructor->inits(), CtorInitializers))
4023 return std::move(Err);
4026 std::copy(CtorInitializers.begin(), CtorInitializers.end(), Memory);
4027 auto *ToCtor = cast<CXXConstructorDecl>(ToFunction);
4028 ToCtor->setCtorInitializers(Memory);
4029 ToCtor->setNumCtorInitializers(NumInitializers);
4035 return std::move(Err);
4037 if (
auto *FromCXXMethod = dyn_cast<CXXMethodDecl>(D))
4040 return std::move(Err);
4046 return std::move(Err);
4050 if (UsedDifferentProtoType) {
4052 ToFunction->
setType(*TyOrErr);
4054 return TyOrErr.takeError();
4058 return TSIOrErr.takeError();
4063 addDeclToContexts(D, ToFunction);
4066 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4069 return ToRedeclOrErr.takeError();
4103 return std::move(Err);
4108 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4109 for (
auto *FoundDecl : FoundDecls) {
4110 if (
FieldDecl *FoundField = dyn_cast<FieldDecl>(FoundDecl)) {
4118 FoundField->getType())) {
4127 if (
ExpectedExpr ToInitializerOrErr =
import(FromInitializer)) {
4130 assert(FoundField->hasInClassInitializer() &&
4131 "Field should have an in-class initializer if it has an "
4132 "expression for it.");
4133 if (!FoundField->getInClassInitializer())
4134 FoundField->setInClassInitializer(*ToInitializerOrErr);
4136 return ToInitializerOrErr.takeError();
4143 Importer.
ToDiag(Loc, diag::warn_odr_field_type_inconsistent)
4144 << Name << D->
getType() << FoundField->getType();
4145 Importer.
ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4146 << FoundField->getType();
4152 Error Err = Error::success();
4158 return std::move(Err);
4159 const Type *ToCapturedVLAType =
nullptr;
4162 return std::move(Err);
4165 if (GetImportedOrCreateDecl(ToField, D, Importer.
getToContext(), DC,
4166 ToInnerLocStart, Loc, Name.getAsIdentifierInfo(),
4167 ToType, ToTInfo, ToBitWidth, D->
isMutable(),
4174 Err = Importer.ImportAttrs(ToField, D);
4176 return std::move(Err);
4180 if (ToCapturedVLAType)
4187 return std::move(Err);
4188 if (ToInitializer) {
4190 if (AlreadyImported)
4191 assert(ToInitializer == AlreadyImported &&
4192 "Duplicate import of in-class initializer.");
4207 return std::move(Err);
4212 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4213 for (
unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
4214 if (
auto *FoundField = dyn_cast<IndirectFieldDecl>(FoundDecls[I])) {
4222 FoundField->getType(),
4229 if (!Name && I < N-1)
4233 Importer.
ToDiag(Loc, diag::warn_odr_field_type_inconsistent)
4234 << Name << D->
getType() << FoundField->getType();
4235 Importer.
ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4236 << FoundField->getType();
4243 auto TypeOrErr =
import(D->
getType());
4245 return TypeOrErr.takeError();
4251 for (
auto *PI : D->
chain())
4253 NamedChain[i++] = *ToD;
4255 return ToD.takeError();
4259 if (GetImportedOrCreateDecl(ToIndirectField, D, Importer.
getToContext(), DC,
4260 Loc, Name.getAsIdentifierInfo(), *TypeOrErr, CH))
4262 return ToIndirectField;
4267 return ToIndirectField;
4297 unsigned int FriendCount = 0;
4298 std::optional<unsigned int> FriendPosition;
4301 for (
FriendDecl *FoundFriend : RD->friends()) {
4302 if (FoundFriend == FD) {
4303 FriendPosition = FriendCount;
4310 assert(FriendPosition &&
"Friend decl not found in own parent.");
4312 return {FriendCount, *FriendPosition};
4319 return std::move(Err);
4324 const auto *RD = cast<CXXRecordDecl>(DC);
4326 for (
FriendDecl *ImportedFriend : RD->friends())
4328 ImportedEquivalentFriends.push_back(ImportedFriend);
4333 assert(ImportedEquivalentFriends.size() <= CountAndPosition.
TotalCount &&
4334 "Class with non-matching friends is imported, ODR check wrong?");
4335 if (ImportedEquivalentFriends.size() == CountAndPosition.
TotalCount)
4337 D, ImportedEquivalentFriends[CountAndPosition.
IndexOfDecl]);
4344 if (Error Err = importInto(ToFriendD, FriendD))
4345 return std::move(Err);
4356 return TSIOrErr.takeError();
4361 for (
unsigned I = 0; I < D->NumTPLists; I++) {
4362 if (
auto ListOrErr =
import(FromTPLists[I]))
4363 ToTPLists[I] = *ListOrErr;
4365 return ListOrErr.takeError();
4370 return LocationOrErr.takeError();
4372 if (!FriendLocOrErr)
4373 return FriendLocOrErr.takeError();
4376 if (GetImportedOrCreateDecl(FrD, D, Importer.
getToContext(), DC,
4377 *LocationOrErr, ToFU,
4378 *FriendLocOrErr, ToTPLists))
4394 return std::move(Err);
4399 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4400 for (
auto *FoundDecl : FoundDecls) {
4401 if (
ObjCIvarDecl *FoundIvar = dyn_cast<ObjCIvarDecl>(FoundDecl)) {
4403 FoundIvar->getType())) {
4408 Importer.
ToDiag(Loc, diag::warn_odr_ivar_type_inconsistent)
4409 << Name << D->
getType() << FoundIvar->getType();
4410 Importer.
ToDiag(FoundIvar->getLocation(), diag::note_odr_value_here)
4411 << FoundIvar->getType();
4417 Error Err = Error::success();
4423 return std::move(Err);
4426 if (GetImportedOrCreateDecl(
4427 ToIvar, D, Importer.
getToContext(), cast<ObjCContainerDecl>(DC),
4428 ToInnerLocStart, Loc, Name.getAsIdentifierInfo(),
4429 ToType, ToTypeSourceInfo,
4441 auto RedeclIt = Redecls.begin();
4444 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
4447 return RedeclOrErr.takeError();
4449 assert(*RedeclIt == D);
4457 return std::move(Err);
4463 VarDecl *FoundByLookup =
nullptr;
4467 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4468 for (
auto *FoundDecl : FoundDecls) {
4472 if (
auto *FoundVar = dyn_cast<VarDecl>(FoundDecl)) {
4476 FoundVar->getType())) {
4488 const VarDecl *FoundDInit =
nullptr;
4489 if (D->
getInit() && FoundVar->getAnyInitializer(FoundDInit))
4493 FoundByLookup = FoundVar;
4501 if (FoundArray && TArray) {
4502 if (isa<IncompleteArrayType>(FoundArray) &&
4503 isa<ConstantArrayType>(TArray)) {
4505 if (
auto TyOrErr =
import(D->
getType()))
4506 FoundVar->setType(*TyOrErr);
4508 return TyOrErr.takeError();
4510 FoundByLookup = FoundVar;
4512 }
else if (isa<IncompleteArrayType>(TArray) &&
4513 isa<ConstantArrayType>(FoundArray)) {
4514 FoundByLookup = FoundVar;
4519 Importer.
ToDiag(Loc, diag::warn_odr_variable_type_inconsistent)
4520 << Name << D->
getType() << FoundVar->getType();
4521 Importer.
ToDiag(FoundVar->getLocation(), diag::note_odr_value_here)
4522 << FoundVar->getType();
4523 ConflictingDecls.push_back(FoundDecl);
4527 if (!ConflictingDecls.empty()) {
4529 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
4531 Name = NameOrErr.get();
4533 return NameOrErr.takeError();
4537 Error Err = Error::success();
4543 return std::move(Err);
4546 if (
auto *FromDecomp = dyn_cast<DecompositionDecl>(D)) {
4550 return std::move(Err);
4552 if (GetImportedOrCreateDecl(
4553 ToDecomp, FromDecomp, Importer.
getToContext(), DC, ToInnerLocStart,
4559 if (GetImportedOrCreateDecl(ToVar, D, Importer.
getToContext(), DC,
4560 ToInnerLocStart, Loc,
4561 Name.getAsIdentifierInfo(), ToType,
4575 if (FoundByLookup) {
4584 return ToVTOrErr.takeError();
4591 return ToInstOrErr.takeError();
4592 if (
ExpectedSLoc POIOrErr =
import(MSI->getPointOfInstantiation()))
4595 return POIOrErr.takeError();
4599 return std::move(Err);
4604 addDeclToContexts(D, ToVar);
4607 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4610 return RedeclOrErr.takeError();
4621 Error Err = Error::success();
4626 return std::move(Err);
4630 if (GetImportedOrCreateDecl(ToParm, D, Importer.
getToContext(), DC,
4631 ToLocation, ToDeclName.getAsIdentifierInfo(),
4648 return ToDefArgOrErr.takeError();
4652 if (
auto ToDefArgOrErr =
import(FromParam->
getDefaultArg()))
4655 return ToDefArgOrErr.takeError();
4658 return Error::success();
4663 Error Err = Error::success();
4668 return std::move(Err);
4677 Error Err = Error::success();
4684 return std::move(Err);
4687 if (GetImportedOrCreateDecl(ToParm, D, Importer.
getToContext(), DC,
4688 ToInnerLocStart, ToLocation,
4689 ToDeclName.getAsIdentifierInfo(), ToType,
4698 return std::move(Err);
4718 return std::move(Err);
4722 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4723 for (
auto *FoundDecl : FoundDecls) {
4724 if (
auto *FoundMethod = dyn_cast<ObjCMethodDecl>(FoundDecl)) {
4730 FoundMethod->getReturnType())) {
4731 Importer.
ToDiag(Loc, diag::warn_odr_objc_method_result_type_inconsistent)
4733 << FoundMethod->getReturnType();
4734 Importer.
ToDiag(FoundMethod->getLocation(),
4735 diag::note_odr_objc_method_here)
4742 if (D->
param_size() != FoundMethod->param_size()) {
4743 Importer.
ToDiag(Loc, diag::warn_odr_objc_method_num_params_inconsistent)
4745 << D->
param_size() << FoundMethod->param_size();
4746 Importer.
ToDiag(FoundMethod->getLocation(),
4747 diag::note_odr_objc_method_here)
4755 PEnd = D->
param_end(), FoundP = FoundMethod->param_begin();
4756 P != PEnd; ++
P, ++FoundP) {
4758 (*FoundP)->getType())) {
4759 Importer.
FromDiag((*P)->getLocation(),
4760 diag::warn_odr_objc_method_param_type_inconsistent)
4762 << (*P)->getType() << (*FoundP)->getType();
4763 Importer.
ToDiag((*FoundP)->getLocation(), diag::note_odr_value_here)
4764 << (*FoundP)->getType();
4772 if (D->
isVariadic() != FoundMethod->isVariadic()) {
4773 Importer.
ToDiag(Loc, diag::warn_odr_objc_method_variadic_inconsistent)
4775 Importer.
ToDiag(FoundMethod->getLocation(),
4776 diag::note_odr_objc_method_here)
4787 Error Err = Error::success();
4790 auto ToReturnTypeSourceInfo =
4793 return std::move(Err);
4796 if (GetImportedOrCreateDecl(
4798 Name.getObjCSelector(), ToReturnType, ToReturnTypeSourceInfo, DC,
4811 ToParams.push_back(*ToPOrErr);
4813 return ToPOrErr.takeError();
4817 for (
auto *ToParam : ToParams) {
4818 ToParam->setOwningFunction(ToMethod);
4826 return std::move(Err);
4850 return std::move(Err);
4854 Error Err = Error::success();
4860 return std::move(Err);
4863 if (GetImportedOrCreateDecl(
4866 ToLocation, Name.getAsIdentifierInfo(),
4867 ToColonLoc, ToTypeSourceInfo))
4873 return std::move(Err);
4874 Result->setTypeForDecl(ToTypeForDecl);
4875 Result->setLexicalDeclContext(LexicalDC);
4886 return std::move(Err);
4892 return std::move(Err);
4900 Error Err = Error::success();
4906 return std::move(Err);
4908 if (GetImportedOrCreateDecl(ToCategory, D, Importer.
getToContext(), DC,
4911 Name.getAsIdentifierInfo(), ToInterface,
4924 return PListOrErr.takeError();
4933 FromProto != FromProtoEnd;
4934 ++FromProto, ++FromProtoLoc) {
4936 Protocols.push_back(*ToProtoOrErr);
4938 return ToProtoOrErr.takeError();
4940 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
4941 ProtocolLocs.push_back(*ToProtoLocOrErr);
4943 return ToProtoLocOrErr.takeError();
4956 return std::move(Err);
4964 return ToImplOrErr.takeError();
4976 return Error::success();
4989 FromProto != FromProtoEnd;
4990 ++FromProto, ++FromProtoLoc) {
4992 Protocols.push_back(*ToProtoOrErr);
4994 return ToProtoOrErr.takeError();
4996 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
4997 ProtocolLocs.push_back(*ToProtoLocOrErr);
4999 return ToProtoLocOrErr.takeError();
5012 return Error::success();
5022 return Importer.
MapImported(D, *ImportedDefOrErr);
5024 return ImportedDefOrErr.takeError();
5033 return std::move(Err);
5038 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5039 for (
auto *FoundDecl : FoundDecls) {
5043 if ((MergeWithProtocol = dyn_cast<ObjCProtocolDecl>(FoundDecl)))
5050 if (!ToAtBeginLocOrErr)
5051 return ToAtBeginLocOrErr.takeError();
5053 if (GetImportedOrCreateDecl(ToProto, D, Importer.
getToContext(), DC,
5054 Name.getAsIdentifierInfo(), Loc,
5066 return std::move(Err);
5074 return std::move(Err);
5077 if (!ExternLocOrErr)
5078 return ExternLocOrErr.takeError();
5082 return LangLocOrErr.takeError();
5087 if (GetImportedOrCreateDecl(ToLinkageSpec, D, Importer.
getToContext(), DC,
5088 *ExternLocOrErr, *LangLocOrErr,
5090 return ToLinkageSpec;
5094 if (!RBraceLocOrErr)
5095 return RBraceLocOrErr.takeError();
5102 return ToLinkageSpec;
5113 return ToShadowOrErr.takeError();
5124 return std::move(Err);
5128 Error Err = Error::success();
5133 return std::move(Err);
5137 return std::move(Err);
5140 if (GetImportedOrCreateDecl(ToUsing, D, Importer.
getToContext(), DC,
5141 ToUsingLoc, ToQualifierLoc, NameInfo,
5152 ToUsing, *ToPatternOrErr);
5154 return ToPatternOrErr.takeError();
5166 return std::move(Err);
5170 Error Err = Error::success();
5176 return std::move(Err);
5179 if (GetImportedOrCreateDecl(ToUsingEnum, D, Importer.
getToContext(), DC,
5180 ToUsingLoc, ToEnumLoc, ToNameLoc, ToEnumType))
5192 return ToPatternOrErr.takeError();
5204 return std::move(Err);
5209 if (!ToIntroducerOrErr)
5210 return ToIntroducerOrErr.takeError();
5214 return ToTargetOrErr.takeError();
5217 if (
auto *FromConstructorUsingShadow =
5218 dyn_cast<ConstructorUsingShadowDecl>(D)) {
5219 Error Err = Error::success();
5221 Err, FromConstructorUsingShadow->getNominatedBaseClassShadowDecl());
5223 return std::move(Err);
5229 if (GetImportedOrCreateDecl<ConstructorUsingShadowDecl>(
5231 cast<UsingDecl>(*ToIntroducerOrErr),
5232 Nominated ? Nominated : *ToTargetOrErr,
5233 FromConstructorUsingShadow->constructsVirtualBase()))
5236 if (GetImportedOrCreateDecl(ToShadow, D, Importer.
getToContext(), DC, Loc,
5237 Name, *ToIntroducerOrErr, *ToTargetOrErr))
5248 ToShadow, *ToPatternOrErr);
5252 return ToPatternOrErr.takeError();
5266 return std::move(Err);
5271 if (!ToComAncestorOrErr)
5272 return ToComAncestorOrErr.takeError();
5274 Error Err = Error::success();
5277 auto ToNamespaceKeyLocation =
5282 return std::move(Err);
5285 if (GetImportedOrCreateDecl(ToUsingDir, D, Importer.
getToContext(), DC,
5287 ToNamespaceKeyLocation,
5290 ToNominatedNamespace, *ToComAncestorOrErr))
5305 return std::move(Err);
5309 auto ToInstantiatedFromUsingOrErr =
5311 if (!ToInstantiatedFromUsingOrErr)
5312 return ToInstantiatedFromUsingOrErr.takeError();
5315 return std::move(Err);
5318 if (GetImportedOrCreateDecl(ToUsingPack, D, Importer.
getToContext(), DC,
5319 cast<NamedDecl>(*ToInstantiatedFromUsingOrErr),
5323 addDeclToContexts(D, ToUsingPack);
5335 return std::move(Err);
5339 Error Err = Error::success();
5345 return std::move(Err);
5349 return std::move(Err);
5352 if (GetImportedOrCreateDecl(ToUsingValue, D, Importer.
getToContext(), DC,
5353 ToUsingLoc, ToQualifierLoc, NameInfo,
5355 return ToUsingValue;
5361 return ToUsingValue;
5371 return std::move(Err);
5375 Error Err = Error::success();
5381 return std::move(Err);
5384 if (GetImportedOrCreateDecl(ToUsing, D, Importer.
getToContext(), DC,
5385 ToUsingLoc, ToTypenameLoc,
5386 ToQualifierLoc, Loc, Name, ToEllipsisLoc))
5397 Decl* ToD =
nullptr;
5406 assert(ToD &&
"BuiltinTemplateDecl of unsupported kind!");
5417 if (
auto FromSuperOrErr =
import(FromSuper))
5418 FromSuper = *FromSuperOrErr;
5420 return FromSuperOrErr.takeError();
5424 if ((
bool)FromSuper != (
bool)ToSuper ||
5427 diag::warn_odr_objc_superclass_inconsistent)
5434 diag::note_odr_objc_missing_superclass);
5437 diag::note_odr_objc_superclass)
5441 diag::note_odr_objc_missing_superclass);
5447 return Error::success();
5458 return SuperTInfoOrErr.takeError();
5469 FromProto != FromProtoEnd;
5470 ++FromProto, ++FromProtoLoc) {
5472 Protocols.push_back(*ToProtoOrErr);
5474 return ToProtoOrErr.takeError();
5476 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5477 ProtocolLocs.push_back(*ToProtoLocOrErr);
5479 return ToProtoLocOrErr.takeError();
5490 auto ToCatOrErr =
import(Cat);
5492 return ToCatOrErr.takeError();
5501 return ToImplOrErr.takeError();
5508 return Error::success();
5517 for (
auto *fromTypeParam : *list) {
5518 if (
auto toTypeParamOrErr =
import(fromTypeParam))
5519 toTypeParams.push_back(*toTypeParamOrErr);
5521 return toTypeParamOrErr.takeError();
5525 if (!LAngleLocOrErr)
5526 return LAngleLocOrErr.takeError();
5529 if (!RAngleLocOrErr)
5530 return RAngleLocOrErr.takeError();
5545 return Importer.
MapImported(D, *ImportedDefOrErr);
5547 return ImportedDefOrErr.takeError();
5556 return std::move(Err);
5562 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5563 for (
auto *FoundDecl : FoundDecls) {
5567 if ((MergeWithIface = dyn_cast<ObjCInterfaceDecl>(FoundDecl)))
5575 if (!AtBeginLocOrErr)
5576 return AtBeginLocOrErr.takeError();
5578 if (GetImportedOrCreateDecl(
5580 *AtBeginLocOrErr, Name.getAsIdentifierInfo(),
5590 if (
auto ToPListOrErr =
5594 return ToPListOrErr.takeError();
5598 return std::move(Err);
5607 return std::move(Err);
5613 return std::move(Err);
5615 Error Err = Error::success();
5620 return std::move(Err);
5622 if (GetImportedOrCreateDecl(
5625 ToLocation, ToAtStartLoc, ToCategoryNameLoc))
5630 Category->setImplementation(ToImpl);
5635 return std::move(Err);
5645 return std::move(Err);
5650 return std::move(Err);
5658 return std::move(Err);
5660 Error Err = Error::success();
5667 return std::move(Err);
5669 if (GetImportedOrCreateDecl(Impl, D, Importer.
getToContext(),
5693 diag::warn_odr_objc_superclass_inconsistent)
5699 diag::note_odr_objc_superclass)
5703 diag::note_odr_objc_missing_superclass);
5706 diag::note_odr_objc_superclass)
5710 diag::note_odr_objc_missing_superclass);
5718 return std::move(Err);
5730 return std::move(Err);
5735 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5736 for (
auto *FoundDecl : FoundDecls) {
5737 if (
auto *FoundProp = dyn_cast<ObjCPropertyDecl>(FoundDecl)) {
5745 FoundProp->getType())) {
5746 Importer.
ToDiag(Loc, diag::warn_odr_objc_property_type_inconsistent)
5747 << Name << D->
getType() << FoundProp->getType();
5748 Importer.
ToDiag(FoundProp->getLocation(), diag::note_odr_value_here)
5749 << FoundProp->getType();
5762 Error Err = Error::success();
5768 return std::move(Err);
5772 if (GetImportedOrCreateDecl(
5774 Name.getAsIdentifierInfo(), ToAtLoc,
5775 ToLParenLoc, ToType,
5787 return std::move(Err);
5807 return std::move(Err);
5811 return std::move(Err);
5813 auto *InImpl = cast<ObjCImplDecl>(LexicalDC);
5818 return std::move(Err);
5821 = InImpl->FindPropertyImplDecl(
Property->getIdentifier(),
5825 Error Err = Error::success();
5828 auto ToPropertyIvarDeclLoc =
5831 return std::move(Err);
5833 if (GetImportedOrCreateDecl(ToImpl, D, Importer.
getToContext(), DC,
5837 ToPropertyIvarDeclLoc))
5847 diag::warn_odr_objc_property_impl_kind_inconsistent)
5852 diag::note_odr_objc_property_impl_kind)
5863 diag::warn_odr_objc_synthesize_ivar_inconsistent)
5868 diag::note_odr_objc_synthesize_ivar_here)
5889 return BeginLocOrErr.takeError();
5893 return LocationOrErr.takeError();
5896 if (GetImportedOrCreateDecl(
5899 *BeginLocOrErr, *LocationOrErr,
5908 Error Err = Error::success();
5909 auto ToConceptRef =
importChecked(Err, TC->getConceptReference());
5910 auto ToIDC =
importChecked(Err, TC->getImmediatelyDeclaredConstraint());
5912 return std::move(Err);
5920 if (!ToDefaultArgOrErr)
5921 return ToDefaultArgOrErr.takeError();
5931 Error Err = Error::success();
5938 return std::move(Err);
5941 if (GetImportedOrCreateDecl(ToD, D, Importer.
getToContext(),
5943 ToInnerLocStart, ToLocation, D->
getDepth(),
5945 ToDeclName.getAsIdentifierInfo(), ToType,
5951 if (!ToDefaultArgOrErr)
5952 return ToDefaultArgOrErr.takeError();
5964 return NameOrErr.takeError();
5969 return LocationOrErr.takeError();
5973 if (!TemplateParamsOrErr)
5974 return TemplateParamsOrErr.takeError();
5977 if (GetImportedOrCreateDecl(
5982 *TemplateParamsOrErr))
5988 if (!ToDefaultArgOrErr)
5989 return ToDefaultArgOrErr.takeError();
5999 assert(D->getTemplatedDecl() &&
"Should be called on templates only");
6000 auto *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();
6001 if (!ToTemplatedDef)
6003 auto *TemplateWithDef = ToTemplatedDef->getDescribedTemplate();
6004 return cast_or_null<T>(TemplateWithDef);
6015 return std::move(Err);
6029 bool DependentFriend = IsDependentFriend(D);
6036 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6037 for (
auto *FoundDecl : FoundDecls) {
6042 Decl *Found = FoundDecl;
6043 auto *FoundTemplate = dyn_cast<ClassTemplateDecl>(Found);
6044 if (FoundTemplate) {
6049 bool IgnoreTemplateParmDepth =
6053 IgnoreTemplateParmDepth)) {
6054 if (DependentFriend || IsDependentFriend(FoundTemplate))
6062 FoundByLookup = FoundTemplate;
6067 ConflictingDecls.push_back(FoundDecl);
6071 if (!ConflictingDecls.empty()) {
6074 ConflictingDecls.size());
6076 Name = NameOrErr.get();
6078 return NameOrErr.takeError();
6085 if (!TemplateParamsOrErr)
6086 return TemplateParamsOrErr.takeError();
6090 if (Error Err = importInto(ToTemplated, FromTemplated))
6091 return std::move(Err);
6095 if (GetImportedOrCreateDecl(D2, D, Importer.
getToContext(), DC, Loc, Name,
6096 *TemplateParamsOrErr, ToTemplated))
6104 addDeclToContexts(D, D2);
6105 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6107 if (FoundByLookup) {
6121 "Found decl must have its templated decl set");
6124 if (ToTemplated != PrevTemplated)
6138 return std::move(Err);
6143 return std::move(Err);
6149 return std::move(Err);
6152 void *InsertPos =
nullptr;
6155 dyn_cast<ClassTemplatePartialSpecializationDecl>(D);
6163 return ToTPListOrErr.takeError();
6164 ToTPList = *ToTPListOrErr;
6178 for (
auto *FromField : D->
fields()) {
6179 auto ToOrErr =
import(FromField);
6181 return ToOrErr.takeError();
6187 auto ToOrErr =
import(FromM);
6189 return ToOrErr.takeError();
6197 return PrevDefinition;
6208 return BeginLocOrErr.takeError();
6211 return IdLocOrErr.takeError();
6220 return std::move(Err);
6223 if (Error Err = importInto(
6225 return std::move(Err);
6228 if (GetImportedOrCreateDecl<ClassTemplatePartialSpecializationDecl>(
6230 *IdLocOrErr, ToTPList, ClassTemplate,
6231 llvm::ArrayRef(TemplateArgs.data(), TemplateArgs.size()), ToTAInfo,
6233 cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl)))
6238 auto *PartSpec2 = cast<ClassTemplatePartialSpecializationDecl>(D2);
6245 PartSpec2->setInstantiatedFromMember(*ToInstOrErr);
6247 return ToInstOrErr.takeError();
6249 updateLookupTableForTemplateParameters(*ToTPList);
6251 if (GetImportedOrCreateDecl(
6253 *BeginLocOrErr, *IdLocOrErr, ClassTemplate, TemplateArgs,
6277 return BraceRangeOrErr.takeError();
6283 return LocOrErr.takeError();
6286 if (
auto TInfoOrErr =
import(TSI))
6289 return TInfoOrErr.takeError();
6294 return LocOrErr.takeError();
6299 return LocOrErr.takeError();
6306 return POIOrErr.takeError();
6313 if (
auto CTDorErr =
import(CTD))
6316 auto *CTPSD = cast<ClassTemplatePartialSpecializationDecl *>(
P);
6317 auto CTPSDOrErr =
import(CTPSD);
6319 return CTPSDOrErr.takeError();
6322 for (
unsigned I = 0; I < DArgs.
size(); ++I) {
6324 if (
auto ArgOrErr =
import(DArg))
6325 D2ArgsVec[I] = *ArgOrErr;
6327 return ArgOrErr.takeError();
6337 return std::move(Err);
6349 return std::move(Err);
6355 "Variable templates cannot be declared at function scope");
6358 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6360 for (
auto *FoundDecl : FoundDecls) {
6364 if (
VarTemplateDecl *FoundTemplate = dyn_cast<VarTemplateDecl>(FoundDecl)) {
6374 assert(FoundTemplate->getDeclContext()->isRecord() &&
6375 "Member variable template imported as non-member, "
6376 "inconsistent imported AST?");
6385 FoundByLookup = FoundTemplate;
6388 ConflictingDecls.push_back(FoundDecl);
6392 if (!ConflictingDecls.empty()) {
6395 ConflictingDecls.size());
6397 Name = NameOrErr.get();
6399 return NameOrErr.takeError();
6408 return TypeOrErr.takeError();
6412 if (Error Err = importInto(ToTemplated, DTemplated))
6413 return std::move(Err);
6417 if (!TemplateParamsOrErr)
6418 return TemplateParamsOrErr.takeError();
6421 if (GetImportedOrCreateDecl(ToVarTD, D, Importer.
getToContext(), DC, Loc,
6422 Name, *TemplateParamsOrErr, ToTemplated))
6431 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6433 if (FoundByLookup) {
6437 auto *PrevTemplated =
6439 if (ToTemplated != PrevTemplated)
6454 auto RedeclIt = Redecls.begin();
6457 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
6460 return RedeclOrErr.takeError();
6462 assert(*RedeclIt == D);
6466 return std::move(Err);
6471 return std::move(Err);
6476 return BeginLocOrErr.takeError();
6480 return IdLocOrErr.takeError();
6486 return std::move(Err);
6489 void *InsertPos =
nullptr;
6492 if (FoundSpecialization) {
6500 "Member variable template specialization imported as non-member, "
6501 "inconsistent imported AST?");
6505 return Importer.
MapImported(D, FoundSpecialization);
6522 return std::move(Err);
6527 if (
auto *FromPartial = dyn_cast<PartVarSpecDecl>(D)) {
6530 const auto *FromTAArgsAsWritten = FromPartial->getTemplateArgsAsWritten();
6534 return std::move(Err);
6536 auto ToTPListOrErr =
import(FromPartial->getTemplateParameters());
6538 return ToTPListOrErr.takeError();
6540 PartVarSpecDecl *ToPartial;
6541 if (GetImportedOrCreateDecl(ToPartial, D, Importer.
getToContext(), DC,
6542 *BeginLocOrErr, *IdLocOrErr, *ToTPListOrErr,
6548 import(FromPartial->getInstantiatedFromMember()))
6549 ToPartial->setInstantiatedFromMember(*ToInstOrErr);
6551 return ToInstOrErr.takeError();
6553 if (FromPartial->isMemberSpecialization())
6554 ToPartial->setMemberSpecialization();
6562 if (GetImportedOrCreateDecl(D2, D, Importer.
getToContext(), DC,
6563 *BeginLocOrErr, *IdLocOrErr, VarTemplate,
6570 if (Error Err = importInto(
T, D->
getType()))
6571 return std::move(Err);
6576 return TInfoOrErr.takeError();
6583 return POIOrErr.takeError();
6592 return LocOrErr.takeError();
6600 return std::move(Err);
6602 if (FoundSpecialization)
6607 addDeclToContexts(D, D2);
6610 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
6613 return RedeclOrErr.takeError();
6627 return std::move(Err);
6639 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6640 for (
auto *FoundDecl : FoundDecls) {
6644 if (
auto *FoundTemplate = dyn_cast<FunctionTemplateDecl>(FoundDecl)) {
6653 FoundByLookup = FoundTemplate;
6663 return ParamsOrErr.takeError();
6668 return std::move(Err);
6685 OldParamDC.reserve(Params->
size());
6686 llvm::transform(*Params, std::back_inserter(OldParamDC),
6690 if (GetImportedOrCreateDecl(ToFunc, D, Importer.
getToContext(), DC, Loc, Name,
6691 Params, TemplatedFD))
6697 ToFunc->setLexicalDeclContext(LexicalDC);
6698 addDeclToContexts(D, ToFunc);
6701 if (
LT && !OldParamDC.empty()) {
6702 for (
unsigned int I = 0; I < OldParamDC.size(); ++I)
6706 if (FoundByLookup) {
6711 "Found decl must have its templated decl set");
6712 auto *PrevTemplated =
6714 if (TemplatedFD != PrevTemplated)
6717 ToFunc->setPreviousDecl(Recent);
6728 Importer.
FromDiag(S->getBeginLoc(), diag::err_unsupported_ast_node)
6729 << S->getStmtClassName();
6738 for (
unsigned I = 0, E = S->getNumOutputs(); I != E; I++) {
6742 Names.push_back(ToII);
6745 for (
unsigned I = 0, E = S->getNumInputs(); I != E; I++) {
6749 Names.push_back(ToII);
6753 for (
unsigned I = 0, E = S->getNumClobbers(); I != E; I++) {
6754 if (
auto ClobberOrErr =
import(S->getClobberStringLiteral(I)))
6755 Clobbers.push_back(*ClobberOrErr);
6757 return ClobberOrErr.takeError();
6762 for (
unsigned I = 0, E = S->getNumOutputs(); I != E; I++) {
6763 if (
auto OutputOrErr =
import(S->getOutputConstraintLiteral(I)))
6764 Constraints.push_back(*OutputOrErr);
6766 return OutputOrErr.takeError();
6769 for (
unsigned I = 0, E = S->getNumInputs(); I != E; I++) {
6770 if (
auto InputOrErr =
import(S->getInputConstraintLiteral(I)))
6771 Constraints.push_back(*InputOrErr);
6773 return InputOrErr.takeError();
6779 return std::move(Err);
6783 return std::move(Err);
6786 S->labels(), Exprs.begin() + S->getNumOutputs() + S->getNumInputs()))
6787 return std::move(Err);
6791 return AsmLocOrErr.takeError();
6792 auto AsmStrOrErr =
import(S->getAsmString());
6794 return AsmStrOrErr.takeError();
6795 ExpectedSLoc RParenLocOrErr =
import(S->getRParenLoc());
6796 if (!RParenLocOrErr)
6797 return RParenLocOrErr.takeError();
6810 S->getNumClobbers(),
6818 Error Err = Error::success();
6823 return std::move(Err);
6829 if (!ToSemiLocOrErr)
6830 return ToSemiLocOrErr.takeError();
6832 *ToSemiLocOrErr, S->hasLeadingEmptyMacro());
6839 return std::move(Err);
6841 ExpectedSLoc ToLBracLocOrErr =
import(S->getLBracLoc());
6842 if (!ToLBracLocOrErr)
6843 return ToLBracLocOrErr.takeError();
6845 ExpectedSLoc ToRBracLocOrErr =
import(S->getRBracLoc());
6846 if (!ToRBracLocOrErr)
6847 return ToRBracLocOrErr.takeError();
6852 *ToLBracLocOrErr, *ToRBracLocOrErr);
6857 Error Err = Error::success();
6862 auto ToEllipsisLoc =
importChecked(Err, S->getEllipsisLoc());
6865 return std::move(Err);
6868 ToCaseLoc, ToEllipsisLoc, ToColonLoc);
6869 ToStmt->setSubStmt(ToSubStmt);
6876 Error Err = Error::success();
6881 return std::move(Err);
6884 ToDefaultLoc, ToColonLoc, ToSubStmt);
6889 Error Err = Error::success();
6894 return std::move(Err);
6897 ToIdentLoc, ToLabelDecl, ToSubStmt);
6902 if (!ToAttrLocOrErr)
6903 return ToAttrLocOrErr.takeError();
6907 return std::move(Err);
6909 if (!ToSubStmtOrErr)
6910 return ToSubStmtOrErr.takeError();
6913 Importer.
getToContext(), *ToAttrLocOrErr, ToAttrs, *ToSubStmtOrErr);
6918 Error Err = Error::success();
6921 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
6929 return std::move(Err);
6932 ToInit, ToConditionVariable, ToCond, ToLParenLoc,
6933 ToRParenLoc, ToThen, ToElseLoc, ToElse);
6938 Error Err = Error::success();
6940 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
6947 return std::move(Err);
6951 ToCond, ToLParenLoc, ToRParenLoc);
6952 ToStmt->setBody(ToBody);
6953 ToStmt->setSwitchLoc(ToSwitchLoc);
6957 for (
SwitchCase *SC = S->getSwitchCaseList(); SC !=
nullptr;
6958 SC = SC->getNextSwitchCase()) {
6961 return ToSCOrErr.takeError();
6962 if (LastChainedSwitchCase)
6965 ToStmt->setSwitchCaseList(*ToSCOrErr);
6966 LastChainedSwitchCase = *ToSCOrErr;
6974 Error Err = Error::success();
6975 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
6982 return std::move(Err);
6985 ToBody, ToWhileLoc, ToLParenLoc, ToRParenLoc);
6990 Error Err = Error::success();
6997 return std::move(Err);
7000 ToBody, ToCond, ToDoLoc, ToWhileLoc, ToRParenLoc);
7005 Error Err = Error::success();
7008 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
7015 return std::move(Err);
7019 ToInit, ToCond, ToConditionVariable, ToInc, ToBody, ToForLoc, ToLParenLoc,
7025 Error Err = Error::success();
7030 return std::move(Err);
7033 ToLabel, ToGotoLoc, ToLabelLoc);
7038 Error Err = Error::success();
7043 return std::move(Err);
7046 ToGotoLoc, ToStarLoc, ToTarget);
7050 ExpectedSLoc ToContinueLocOrErr =
import(S->getContinueLoc());
7051 if (!ToContinueLocOrErr)
7052 return ToContinueLocOrErr.takeError();
7057 auto ToBreakLocOrErr =
import(S->getBreakLoc());
7058 if (!ToBreakLocOrErr)
7059 return ToBreakLocOrErr.takeError();
7065 Error Err = Error::success();
7068 auto ToNRVOCandidate =
importChecked(Err, S->getNRVOCandidate());
7070 return std::move(Err);
7078 Error Err = Error::success();
7080 auto ToExceptionDecl =
importChecked(Err, S->getExceptionDecl());
7081 auto ToHandlerBlock =
importChecked(Err, S->getHandlerBlock());
7083 return std::move(Err);
7086 ToCatchLoc, ToExceptionDecl, ToHandlerBlock);
7092 return ToTryLocOrErr.takeError();
7094 ExpectedStmt ToTryBlockOrErr =
import(S->getTryBlock());
7095 if (!ToTryBlockOrErr)
7096 return ToTryBlockOrErr.takeError();
7099 for (
unsigned HI = 0, HE = S->getNumHandlers(); HI != HE; ++HI) {
7101 if (
auto ToHandlerOrErr =
import(FromHandler))
7102 ToHandlers[HI] = *ToHandlerOrErr;
7104 return ToHandlerOrErr.takeError();
7108 cast<CompoundStmt>(*ToTryBlockOrErr), ToHandlers);
7113 Error Err = Error::success();
7120 auto ToLoopVarStmt =
importChecked(Err, S->getLoopVarStmt());
7127 return std::move(Err);
7130 ToInit, ToRangeStmt, ToBeginStmt, ToEndStmt, ToCond, ToInc, ToLoopVarStmt,
7131 ToBody, ToForLoc, ToCoawaitLoc, ToColonLoc, ToRParenLoc);
7136 Error Err = Error::success();
7143 return std::move(Err);
7154 Error Err = Error::success();
7157 auto ToCatchParamDecl =
importChecked(Err, S->getCatchParamDecl());
7160 return std::move(Err);
7163 ToAtCatchLoc, ToRParenLoc, ToCatchParamDecl, ToCatchBody);
7167 ExpectedSLoc ToAtFinallyLocOrErr =
import(S->getAtFinallyLoc());
7168 if (!ToAtFinallyLocOrErr)
7169 return ToAtFinallyLocOrErr.takeError();
7170 ExpectedStmt ToAtFinallyStmtOrErr =
import(S->getFinallyBody());
7171 if (!ToAtFinallyStmtOrErr)
7172 return ToAtFinallyStmtOrErr.takeError();
7174 *ToAtFinallyStmtOrErr);
7179 Error Err = Error::success();
7182 auto ToFinallyStmt =
importChecked(Err, S->getFinallyStmt());
7184 return std::move(Err);
7187 for (
unsigned CI = 0, CE = S->getNumCatchStmts(); CI != CE; ++CI) {
7189 if (
ExpectedStmt ToCatchStmtOrErr =
import(FromCatchStmt))
7190 ToCatchStmts[CI] = *ToCatchStmtOrErr;
7192 return ToCatchStmtOrErr.takeError();
7196 ToAtTryLoc, ToTryBody,
7197 ToCatchStmts.begin(), ToCatchStmts.size(),
7204 Error Err = Error::success();
7205 auto ToAtSynchronizedLoc =
importChecked(Err, S->getAtSynchronizedLoc());
7209 return std::move(Err);
7212 ToAtSynchronizedLoc, ToSynchExpr, ToSynchBody);
7216 ExpectedSLoc ToThrowLocOrErr =
import(S->getThrowLoc());
7217 if (!ToThrowLocOrErr)
7218 return ToThrowLocOrErr.takeError();
7219 ExpectedExpr ToThrowExprOrErr =
import(S->getThrowExpr());
7220 if (!ToThrowExprOrErr)
7221 return ToThrowExprOrErr.takeError();
7223 *ToThrowLocOrErr, *ToThrowExprOrErr);
7230 return ToAtLocOrErr.takeError();
7232 if (!ToSubStmtOrErr)
7233 return ToSubStmtOrErr.takeError();
7248 Error Err = Error::success();
7253 return std::move(Err);
7255 if (!ParentContextOrErr)
7256 return ParentContextOrErr.takeError();
7260 RParenLoc, *ParentContextOrErr);
7265 Error Err = Error::success();
7272 return std::move(Err);
7275 ToBuiltinLoc, ToSubExpr, ToWrittenTypeInfo, ToRParenLoc, ToType,
7281 Error Err = Error::success();
7289 return std::move(Err);
7299 ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType, VK, OK,
7300 ToRParenLoc, CondIsTrue);
7304 Error Err = Error::success();
7311 return std::move(Err);
7319 Error Err = Error::success();
7327 ToSubExprs.resize(NumSubExprs);
7330 return std::move(Err);
7333 Importer.
getToContext(), ToSubExprs, ToType, ToBeginLoc, ToRParenLoc);
7339 return TypeOrErr.takeError();
7343 return BeginLocOrErr.takeError();
7350 Error Err = Error::success();
7352 Expr *ToControllingExpr =
nullptr;
7358 assert((ToControllingExpr || ToControllingType) &&
7359 "Either the controlling expr or type must be nonnull");
7363 return std::move(Err);
7368 return std::move(Err);
7373 return std::move(Err);
7377 if (ToControllingExpr) {
7379 ToCtx, ToGenericLoc, ToControllingExpr,
llvm::ArrayRef(ToAssocTypes),
7384 ToCtx, ToGenericLoc, ToControllingType,
llvm::ArrayRef(ToAssocTypes),
7389 if (ToControllingExpr) {
7391 ToCtx, ToGenericLoc, ToControllingExpr,
llvm::ArrayRef(ToAssocTypes),
7396 ToCtx, ToGenericLoc, ToControllingType,
llvm::ArrayRef(ToAssocTypes),
7403 Error Err = Error::success();
7408 return std::move(Err);
7417 Error Err = Error::success();
7424 return std::move(Err);
7430 return FoundDOrErr.takeError();
7431 ToFoundD = *FoundDOrErr;
7440 return std::move(Err);
7441 ToResInfo = &ToTAInfo;
7445 Importer.
getToContext(), ToQualifierLoc, ToTemplateKeywordLoc, ToDecl,
7449 ToE->setHadMultipleCandidates(
true);
7457 return TypeOrErr.takeError();
7465 return ToInitOrErr.takeError();
7468 if (!ToEqualOrColonLocOrErr)
7469 return ToEqualOrColonLocOrErr.takeError();
7475 ToIndexExprs[I - 1] = *ToArgOrErr;
7477 return ToArgOrErr.takeError();
7482 return std::move(Err);
7486 ToIndexExprs, *ToEqualOrColonLocOrErr,
7494 return ToTypeOrErr.takeError();
7497 if (!ToLocationOrErr)
7498 return ToLocationOrErr.takeError();
7501 *ToTypeOrErr, *ToLocationOrErr);
7507 return ToTypeOrErr.takeError();
7510 if (!ToLocationOrErr)
7511 return ToLocationOrErr.takeError();
7521 return ToTypeOrErr.takeError();
7524 if (!ToLocationOrErr)
7525 return ToLocationOrErr.takeError();
7529 *ToTypeOrErr, *ToLocationOrErr);
7533 auto ToTypeOrErr =
import(E->
getType());
7535 return ToTypeOrErr.takeError();
7538 if (!ToSubExprOrErr)
7539 return ToSubExprOrErr.takeError();
7542 *ToSubExprOrErr, *ToTypeOrErr);
7546 auto ToTypeOrErr =
import(E->
getType());
7548 return ToTypeOrErr.takeError();
7551 if (!ToLocationOrErr)
7552 return ToLocationOrErr.takeError();
7562 return ToTypeOrErr.takeError();
7565 if (!ToLocationOrErr)
7566 return ToLocationOrErr.takeError();
7575 return ToTypeOrErr.takeError();
7580 return std::move(Err);
7584 *ToTypeOrErr, ToLocations.data(), ToLocations.size());
7589 Error Err = Error::success();
7595 return std::move(Err);
7598 ToLParenLoc, ToTypeSourceInfo, ToType, E->
getValueKind(),
7604 Error Err = Error::success();
7609 return std::move(Err);
7615 return std::move(Err);
7619 ToBuiltinLoc, ToExprs, ToType, E->
getOp(), ToRParenLoc);
7623 Error Err = Error::success();
7629 return std::move(Err);
7632 ToAmpAmpLoc, ToLabelLoc, ToLabel, ToType);
7635 Error Err = Error::success();
7639 return std::move(Err);
7644 Error Err = Error::success();
7649 return std::move(Err);
7652 ParenExpr(ToLParen, ToRParen, ToSubExpr);
7658 return std::move(Err);
7661 if (!ToLParenLocOrErr)
7662 return ToLParenLocOrErr.takeError();
7665 if (!ToRParenLocOrErr)
7666 return ToRParenLocOrErr.takeError();
7669 ToExprs, *ToRParenLocOrErr);
7673 Error Err = Error::success();
7679 return std::move(Err);
7682 StmtExpr(ToSubStmt, ToType, ToLParenLoc, ToRParenLoc,
7687 Error Err = Error::success();
7692 return std::move(Err);
7696 UO->setType(ToType);
7697 UO->setSubExpr(ToSubExpr);
7699 UO->setOperatorLoc(ToOperatorLoc);
7710 Error Err = Error::success();
7715 return std::move(Err);
7720 if (!ToArgumentTypeInfoOrErr)
7721 return ToArgumentTypeInfoOrErr.takeError();
7724 E->
getKind(), *ToArgumentTypeInfoOrErr, ToType, ToOperatorLoc,
7729 if (!ToArgumentExprOrErr)
7730 return ToArgumentExprOrErr.takeError();
7733 E->
getKind(), *ToArgumentExprOrErr, ToType, ToOperatorLoc, ToRParenLoc);
7737 Error Err = Error::success();
7743 return std::move(Err);
7752 Error Err = Error::success();
7760 return std::move(Err);
7763 ToCond, ToQuestionLoc, ToLHS, ToColonLoc, ToRHS, ToType,
7769 Error Err = Error::success();
7779 return std::move(Err);
7782 ToCommon, ToOpaqueValue, ToCond, ToTrueExpr, ToFalseExpr,
7789 Error Err = Error::success();
7792 return std::move(Err);
7799 Error Err = Error::success();
7801 auto ToQueriedTypeSourceInfo =
7807 return std::move(Err);
7811 ToDimensionExpression, ToEndLoc, ToType);
7815 Error Err = Error::success();
7821 return std::move(Err);
7829 Error Err = Error::success();
7834 return std::move(Err);
7841 Error Err = Error::success();
7847 return std::move(Err);
7856 Error Err = Error::success();
7861 auto ToComputationResultType =
7865 return std::move(Err);
7871 ToComputationLHSType, ToComputationResultType);
7878 if (
auto SpecOrErr =
import(*I))
7879 Path.push_back(*SpecOrErr);
7881 return SpecOrErr.takeError();
7889 return ToTypeOrErr.takeError();
7892 if (!ToSubExprOrErr)
7893 return ToSubExprOrErr.takeError();
7896 if (!ToBasePathOrErr)
7897 return ToBasePathOrErr.takeError();
7905 Error Err = Error::success();
7910 return std::move(Err);
7913 if (!ToBasePathOrErr)
7914 return ToBasePathOrErr.takeError();
7918 case Stmt::CStyleCastExprClass: {
7919 auto *CCE = cast<CStyleCastExpr>(E);
7920 ExpectedSLoc ToLParenLocOrErr =
import(CCE->getLParenLoc());
7921 if (!ToLParenLocOrErr)
7922 return ToLParenLocOrErr.takeError();
7923 ExpectedSLoc ToRParenLocOrErr =
import(CCE->getRParenLoc());
7924 if (!ToRParenLocOrErr)
7925 return ToRParenLocOrErr.takeError();
7928 ToSubExpr, ToBasePath, CCE->getFPFeatures(), ToTypeInfoAsWritten,
7929 *ToLParenLocOrErr, *ToRParenLocOrErr);
7932 case Stmt::CXXFunctionalCastExprClass: {
7933 auto *FCE = cast<CXXFunctionalCastExpr>(E);
7934 ExpectedSLoc ToLParenLocOrErr =
import(FCE->getLParenLoc());
7935 if (!ToLParenLocOrErr)
7936 return ToLParenLocOrErr.takeError();
7937 ExpectedSLoc ToRParenLocOrErr =
import(FCE->getRParenLoc());
7938 if (!ToRParenLocOrErr)
7939 return ToRParenLocOrErr.takeError();
7942 E->
getCastKind(), ToSubExpr, ToBasePath, FCE->getFPFeatures(),
7943 *ToLParenLocOrErr, *ToRParenLocOrErr);
7946 case Stmt::ObjCBridgedCastExprClass: {
7947 auto *OCE = cast<ObjCBridgedCastExpr>(E);
7948 ExpectedSLoc ToLParenLocOrErr =
import(OCE->getLParenLoc());
7949 if (!ToLParenLocOrErr)
7950 return ToLParenLocOrErr.takeError();
7951 ExpectedSLoc ToBridgeKeywordLocOrErr =
import(OCE->getBridgeKeywordLoc());
7952 if (!ToBridgeKeywordLocOrErr)
7953 return ToBridgeKeywordLocOrErr.takeError();
7955 *ToLParenLocOrErr, OCE->getBridgeKind(), E->
getCastKind(),
7956 *ToBridgeKeywordLocOrErr, ToTypeInfoAsWritten, ToSubExpr);
7958 case Stmt::BuiltinBitCastExprClass: {
7959 auto *BBC = cast<BuiltinBitCastExpr>(E);
7960 ExpectedSLoc ToKWLocOrErr =
import(BBC->getBeginLoc());
7962 return ToKWLocOrErr.takeError();
7963 ExpectedSLoc ToRParenLocOrErr =
import(BBC->getEndLoc());
7964 if (!ToRParenLocOrErr)
7965 return ToRParenLocOrErr.takeError();
7968 ToTypeInfoAsWritten, *ToKWLocOrErr, *ToRParenLocOrErr);
7971 llvm_unreachable(
"Cast expression of unsupported type!");
7984 Error Err = Error::success();
7988 return std::move(Err);
7997 auto ToBSOrErr =
import(FromNode.
getBase());
7999 return ToBSOrErr.takeError();
8004 auto ToFieldOrErr =
import(FromNode.
getField());
8006 return ToFieldOrErr.takeError();
8007 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, *ToFieldOrErr, ToEndLoc));
8012 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, ToII, ToEndLoc));
8021 if (!ToIndexExprOrErr)
8022 return ToIndexExprOrErr.takeError();
8023 ToExprs[I] = *ToIndexExprOrErr;
8026 Error Err = Error::success();
8032 return std::move(Err);
8035 Importer.
getToContext(), ToType, ToOperatorLoc, ToTypeSourceInfo, ToNodes,
8036 ToExprs, ToRParenLoc);
8040 Error Err = Error::success();
8046 return std::move(Err);
8055 ToType, ToOperand, ToCanThrow, ToBeginLoc, ToEndLoc);
8059 Error Err = Error::success();
8064 return std::move(Err);
8072 if (!ToUsedLocOrErr)
8073 return ToUsedLocOrErr.takeError();
8075 auto ToParamOrErr =
import(E->
getParam());
8077 return ToParamOrErr.takeError();
8080 if (!UsedContextOrErr)
8081 return UsedContextOrErr.takeError();
8091 std::optional<ParmVarDecl *> FromParam =
8093 assert(FromParam &&
"ParmVarDecl was not imported?");
8096 return std::move(Err);
8098 Expr *RewrittenInit =
nullptr;
8102 return ExprOrErr.takeError();
8103 RewrittenInit = ExprOrErr.get();
8106 *ToParamOrErr, RewrittenInit,
8112 Error Err = Error::success();
8117 return std::move(Err);
8120 ToType, ToTypeSourceInfo, ToRParenLoc);
8126 if (!ToSubExprOrErr)
8127 return ToSubExprOrErr.takeError();
8131 return ToDtorOrErr.takeError();
8141 Error Err = Error::success();
8147 return std::move(Err);
8151 return std::move(Err);
8154 Importer.
getToContext(), ToConstructor, ToType, ToTypeSourceInfo, ToArgs,
8164 return std::move(Err);
8166 Error Err = Error::success();
8170 return std::move(Err);
8174 if (GetImportedOrCreateDecl(To, D, Temporary, ExtendingDecl,
8185 Error Err = Error::success();
8189 auto ToMaterializedDecl =
8192 return std::move(Err);
8194 if (!ToTemporaryExpr)
8195 ToTemporaryExpr = cast<Expr>(ToMaterializedDecl->getTemporaryExpr());
8199 ToMaterializedDecl);
8205 Error Err = Error::success();
8210 return std::move(Err);
8217 Error Err = Error::success();
8223 return std::move(Err);
8225 std::optional<unsigned> Length;
8232 ToPartialArguments))
8233 return std::move(Err);
8237 Importer.
getToContext(), ToOperatorLoc, ToPack, ToPackLoc, ToRParenLoc,
8238 Length, ToPartialArguments);
8243 Error Err = Error::success();
8250 auto ToAllocatedTypeSourceInfo =
8255 return std::move(Err);
8260 return std::move(Err);
8266 ToInitializer, ToType, ToAllocatedTypeSourceInfo, ToSourceRange,
8271 Error Err = Error::success();
8277 return std::move(Err);
8286 Error Err = Error::success();
8292 return std::move(Err);
8296 return std::move(Err);
8299 Importer.
getToContext(), ToType, ToLocation, ToConstructor,
8303 ToParenOrBraceRange);
8310 if (!ToSubExprOrErr)
8311 return ToSubExprOrErr.takeError();
8315 return std::move(Err);
8323 Error Err = Error::success();
8328 return std::move(Err);
8332 return std::move(Err);
8342 return ToTypeOrErr.takeError();
8345 if (!ToLocationOrErr)
8346 return ToLocationOrErr.takeError();
8355 return ToTypeOrErr.takeError();
8358 if (!ToLocationOrErr)
8359 return ToLocationOrErr.takeError();
8362 *ToTypeOrErr, *ToLocationOrErr);
8366 Error Err = Error::success();
8377 return std::move(Err);
8389 return std::move(Err);
8390 ResInfo = &ToTAInfo;
8394 ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8395 ToMemberDecl, ToFoundDecl, ToMemberNameInfo,
8402 Error Err = Error::success();
8410 return std::move(Err);
8416 if (!ToDestroyedTypeLocOrErr)
8417 return ToDestroyedTypeLocOrErr.takeError();
8423 return ToTIOrErr.takeError();
8428 ToQualifierLoc, ToScopeTypeInfo, ToColonColonLoc, ToTildeLoc, Storage);
8433 Error Err = Error::success();
8438 auto ToFirstQualifierFoundInScope =
8441 return std::move(Err);
8443 Expr *ToBase =
nullptr;
8446 ToBase = *ToBaseOrErr;
8448 return ToBaseOrErr.takeError();
8457 return std::move(Err);
8458 ResInfo = &ToTAInfo;
8463 return std::move(Err);
8469 return std::move(Err);
8473 ToQualifierLoc, ToTemplateKeywordLoc, ToFirstQualifierFoundInScope,
8474 ToMemberNameInfo, ResInfo);
8479 Error Err = Error::success();
8487 return std::move(Err);
8491 return std::move(Err);
8498 return std::move(Err);
8499 ResInfo = &ToTAInfo;
8503 Importer.
getToContext(), ToQualifierLoc, ToTemplateKeywordLoc,
8504 ToNameInfo, ResInfo);
8509 Error Err = Error::success();
8515 return std::move(Err);
8520 return std::move(Err);
8523 Importer.
getToContext(), ToType, ToTypeSourceInfo, ToLParenLoc,
8530 if (!ToNamingClassOrErr)
8531 return ToNamingClassOrErr.takeError();
8534 if (!ToQualifierLocOrErr)
8535 return ToQualifierLocOrErr.takeError();
8537 Error Err = Error::success();
8541 return std::move(Err);
8546 return std::move(Err);
8549 for (
auto *D : E->
decls())
8550 if (
auto ToDOrErr =
import(D))
8551 ToDecls.
addDecl(cast<NamedDecl>(*ToDOrErr));
8553 return ToDOrErr.takeError();
8560 return std::move(Err);
8563 if (!ToTemplateKeywordLocOrErr)
8564 return ToTemplateKeywordLocOrErr.takeError();
8566 const bool KnownDependent =
8568 ExprDependence::TypeValue;
8570 Importer.
getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8571 *ToTemplateKeywordLocOrErr, ToNameInfo, E->
requiresADL(), &ToTAInfo,
8572 ToDecls.
begin(), ToDecls.
end(), KnownDependent);
8576 Importer.
getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8583 Error Err = Error::success();
8591 return std::move(Err);
8596 return std::move(Err);
8600 if (
auto ToDOrErr =
import(D))
8601 ToDecls.
addDecl(cast<NamedDecl>(*ToDOrErr));
8603 return ToDOrErr.takeError();
8611 return std::move(Err);
8612 ResInfo = &ToTAInfo;
8615 Expr *ToBase =
nullptr;
8618 ToBase = *ToBaseOrErr;
8620 return ToBaseOrErr.takeError();
8625 E->
isArrow(), ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8626 ToNameInfo, ResInfo, ToDecls.
begin(), ToDecls.
end());
8630 Error Err = Error::success();
8635 return std::move(Err);
8640 return std::move(Err);
8642 if (
const auto *OCE = dyn_cast<CXXOperatorCallExpr>(E)) {
8644 Importer.
getToContext(), OCE->getOperator(), ToCallee, ToArgs, ToType,
8645 OCE->getValueKind(), ToRParenLoc, OCE->getFPFeatures(),
8646 OCE->getADLCallKind());
8656 auto ToClassOrErr =
import(FromClass);
8658 return ToClassOrErr.takeError();
8663 return ToCallOpOrErr.takeError();
8667 return std::move(Err);
8669 Error Err = Error::success();
8674 return std::move(Err);
8685 Error Err = Error::success();
8690 return std::move(Err);
8694 return std::move(Err);
8698 ToCtx, ToLBraceLoc, ToExprs, ToRBraceLoc);
8705 return ToFillerOrErr.takeError();
8709 if (
auto ToFDOrErr =
import(FromFD))
8712 return ToFDOrErr.takeError();
8716 if (
auto ToSyntFormOrErr =
import(SyntForm))
8719 return ToSyntFormOrErr.takeError();
8733 return ToTypeOrErr.takeError();
8736 if (!ToSubExprOrErr)
8737 return ToSubExprOrErr.takeError();
8740 *ToTypeOrErr, *ToSubExprOrErr);
8745 Error Err = Error::success();
8750 return std::move(Err);
8758 Error Err = Error::success();
8763 return std::move(Err);
8766 ToType, ToCommonExpr, ToSubExpr);
8772 return ToTypeOrErr.takeError();
8778 if (!ToBeginLocOrErr)
8779 return ToBeginLocOrErr.takeError();
8781 auto ToFieldOrErr =
import(E->
getField());
8783 return ToFieldOrErr.takeError();
8786 if (!UsedContextOrErr)
8787 return UsedContextOrErr.takeError();
8791 "Field should have in-class initializer if there is a default init "
8792 "expression that uses it.");
8797 auto ToInClassInitializerOrErr =
8799 if (!ToInClassInitializerOrErr)
8800 return ToInClassInitializerOrErr.takeError();
8804 Expr *RewrittenInit =
nullptr;
8808 return ExprOrErr.takeError();
8809 RewrittenInit = ExprOrErr.get();
8813 ToField, *UsedContextOrErr, RewrittenInit);
8817 Error Err = Error::success();
8825 return std::move(Err);
8830 if (!ToBasePathOrErr)
8831 return ToBasePathOrErr.takeError();
8833 if (
auto CCE = dyn_cast<CXXStaticCastExpr>(E)) {
8835 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8836 ToTypeInfoAsWritten, CCE->getFPFeatures(), ToOperatorLoc, ToRParenLoc,
8838 }
else if (isa<CXXDynamicCastExpr>(E)) {
8840 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8841 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8842 }
else if (isa<CXXReinterpretCastExpr>(E)) {
8844 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8845 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8846 }
else if (isa<CXXConstCastExpr>(E)) {
8848 Importer.
getToContext(), ToType, VK, ToSubExpr, ToTypeInfoAsWritten,
8849 ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8851 llvm_unreachable(
"Unknown cast type");
8852 return make_error<ASTImportError>();
8858 Error Err = Error::success();
8864 return std::move(Err);
8867 ToType, E->
getValueKind(), ToExprLoc, ToReplacement, ToAssociatedDecl,
8872 Error Err = Error::success();
8877 return std::move(Err);
8881 return std::move(Err);
8895 return ToTypeOrErr.takeError();
8898 if (!ToSourceRangeOrErr)
8899 return ToSourceRangeOrErr.takeError();
8904 *ToTypeOrErr, *ToTSIOrErr, *ToSourceRangeOrErr);
8906 return ToTSIOrErr.takeError();
8910 if (!ToExprOperandOrErr)
8911 return ToExprOperandOrErr.takeError();
8914 *ToTypeOrErr, *ToExprOperandOrErr, *ToSourceRangeOrErr);
8918 Error Err = Error::success();
8929 return std::move(Err);
8938 Error ImportErrors = Error::success();
8940 if (
auto ImportedOrErr =
import(FromOverriddenMethod))
8942 (*ImportedOrErr)->getCanonicalDecl()));
8945 joinErrors(std::move(ImportErrors), ImportedOrErr.takeError());
8947 return ImportErrors;
8953 std::shared_ptr<ASTImporterSharedState> SharedState)
8954 : SharedState(SharedState), ToContext(ToContext), FromContext(FromContext),
8955 ToFileManager(ToFileManager), FromFileManager(FromFileManager),
8960 this->SharedState = std::make_shared<ASTImporterSharedState>();
8970 assert(F && (isa<FieldDecl>(*F) || isa<IndirectFieldDecl>(*F)) &&
8971 "Try to get field index for non-field.");
8975 return std::nullopt;
8978 for (
const auto *D : Owner->decls()) {
8982 if (isa<FieldDecl>(*D) || isa<IndirectFieldDecl>(*D))
8986 llvm_unreachable(
"Field was not found in its parent context.");
8988 return std::nullopt;
9001 if (SharedState->getLookupTable()) {
9003 SharedState->getLookupTable()->lookup(ReDC, Name);
9007 FoundDeclsTy
Result(NoloadLookupResult.
begin(), NoloadLookupResult.
end());
9024void ASTImporter::AddToLookupTable(
Decl *ToD) {
9025 SharedState->addDeclToLookup(ToD);
9031 return Importer.
Visit(FromD);
9055 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
9056 ImportedTypes.find(FromT);
9057 if (Pos != ImportedTypes.end())
9064 return ToTOrErr.takeError();
9067 ImportedTypes[FromT] = ToTOrErr->getTypePtr();
9069 return ToTOrErr->getTypePtr();
9078 return ToTyOrErr.takeError();
9091 return TOrErr.takeError();
9094 return BeginLocOrErr.takeError();
9103template <
typename T>
struct AttrArgImporter {
9104 AttrArgImporter(
const AttrArgImporter<T> &) =
delete;
9105 AttrArgImporter(AttrArgImporter<T> &&) =
default;
9106 AttrArgImporter<T> &operator=(
const AttrArgImporter<T> &) =
delete;
9107 AttrArgImporter<T> &operator=(AttrArgImporter<T> &&) =
default;
9110 : To(I.importChecked(Err, From)) {}
9112 const T &value() {
return To; }
9123template <
typename T>
struct AttrArgArrayImporter {
9124 AttrArgArrayImporter(
const AttrArgArrayImporter<T> &) =
delete;
9125 AttrArgArrayImporter(AttrArgArrayImporter<T> &&) =
default;
9126 AttrArgArrayImporter<T> &operator=(
const AttrArgArrayImporter<T> &) =
delete;
9127 AttrArgArrayImporter<T> &operator=(AttrArgArrayImporter<T> &&) =
default;
9130 const llvm::iterator_range<T *> &From,
9131 unsigned ArraySize) {
9134 To.reserve(ArraySize);
9138 T *value() {
return To.data(); }
9145 Error Err{Error::success()};
9146 Attr *ToAttr =
nullptr;
9151 AttrImporter(
ASTImporter &I) : Importer(I), NImporter(I) {}
9154 template <
typename T>
T *castAttrAs() {
return cast<T>(ToAttr); }
9155 template <
typename T>
const T *castAttrAs()
const {
return cast<T>(ToAttr); }
9160 template <
class T> AttrArgImporter<T> importArg(
const T &From) {
9161 return AttrArgImporter<T>(NImporter, Err, From);
9167 template <
typename T>
9168 AttrArgArrayImporter<T> importArrayArg(
const llvm::iterator_range<T *> &From,
9169 unsigned ArraySize) {
9170 return AttrArgArrayImporter<T>(NImporter, Err, From, ArraySize);
9181 template <
typename T,
typename... Arg>
9182 void importAttr(
const T *FromAttr, Arg &&...ImportedArg) {
9183 static_assert(std::is_base_of<Attr, T>::value,
9184 "T should be subclass of Attr.");
9185 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9189 Importer.
Import(FromAttr->getScopeName());
9199 FromAttr->getParsedKind(), FromAttr->getForm());
9203 std::forward<Arg>(ImportedArg)..., ToI);
9207 if (
auto *ToInheritableAttr = dyn_cast<InheritableAttr>(ToAttr))
9208 ToInheritableAttr->setInherited(FromAttr->isInherited());
9214 void cloneAttr(
const Attr *FromAttr) {
9215 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9229 return std::move(Err);
9230 assert(ToAttr &&
"Attribute should be created.");
9237 AttrImporter AI(*
this);
9240 switch (FromAttr->
getKind()) {
9241 case attr::Aligned: {
9242 auto *From = cast<AlignedAttr>(FromAttr);
9243 if (From->isAlignmentExpr())
9244 AI.importAttr(From,
true, AI.importArg(From->getAlignmentExpr()).value());
9246 AI.importAttr(From,
false,
9247 AI.importArg(From->getAlignmentType()).value());
9251 case attr::AlignValue: {
9252 auto *From = cast<AlignValueAttr>(FromAttr);
9253 AI.importAttr(From, AI.importArg(From->getAlignment()).value());
9257 case attr::Format: {
9258 const auto *From = cast<FormatAttr>(FromAttr);
9259 AI.importAttr(From,
Import(From->getType()), From->getFormatIdx(),
9260 From->getFirstArg());
9264 case attr::EnableIf: {
9265 const auto *From = cast<EnableIfAttr>(FromAttr);
9266 AI.importAttr(From, AI.importArg(From->getCond()).value(),
9267 From->getMessage());
9271 case attr::AssertCapability: {
9272 const auto *From = cast<AssertCapabilityAttr>(FromAttr);
9274 AI.importArrayArg(From->args(), From->args_size()).value(),
9278 case attr::AcquireCapability: {
9279 const auto *From = cast<AcquireCapabilityAttr>(FromAttr);
9281 AI.importArrayArg(From->args(), From->args_size()).value(),
9285 case attr::TryAcquireCapability: {
9286 const auto *From = cast<TryAcquireCapabilityAttr>(FromAttr);
9287 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9288 AI.importArrayArg(From->args(), From->args_size()).value(),
9292 case attr::ReleaseCapability: {
9293 const auto *From = cast<ReleaseCapabilityAttr>(FromAttr);
9295 AI.importArrayArg(From->args(), From->args_size()).value(),
9299 case attr::RequiresCapability: {
9300 const auto *From = cast<RequiresCapabilityAttr>(FromAttr);
9302 AI.importArrayArg(From->args(), From->args_size()).value(),
9306 case attr::GuardedBy: {
9307 const auto *From = cast<GuardedByAttr>(FromAttr);
9308 AI.importAttr(From, AI.importArg(From->getArg()).value());
9311 case attr::PtGuardedBy: {
9312 const auto *From = cast<PtGuardedByAttr>(FromAttr);
9313 AI.importAttr(From, AI.importArg(From->getArg()).value());
9316 case attr::AcquiredAfter: {
9317 const auto *From = cast<AcquiredAfterAttr>(FromAttr);
9319 AI.importArrayArg(From->args(), From->args_size()).value(),
9323 case attr::AcquiredBefore: {
9324 const auto *From = cast<AcquiredBeforeAttr>(FromAttr);
9326 AI.importArrayArg(From->args(), From->args_size()).value(),
9330 case attr::AssertExclusiveLock: {
9331 const auto *From = cast<AssertExclusiveLockAttr>(FromAttr);
9333 AI.importArrayArg(From->args(), From->args_size()).value(),
9337 case attr::AssertSharedLock: {
9338 const auto *From = cast<AssertSharedLockAttr>(FromAttr);
9340 AI.importArrayArg(From->args(), From->args_size()).value(),
9344 case attr::ExclusiveTrylockFunction: {
9345 const auto *From = cast<ExclusiveTrylockFunctionAttr>(FromAttr);
9346 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9347 AI.importArrayArg(From->args(), From->args_size()).value(),
9351 case attr::SharedTrylockFunction: {
9352 const auto *From = cast<SharedTrylockFunctionAttr>(FromAttr);
9353 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9354 AI.importArrayArg(From->args(), From->args_size()).value(),
9358 case attr::LockReturned: {
9359 const auto *From = cast<LockReturnedAttr>(FromAttr);
9360 AI.importAttr(From, AI.importArg(From->getArg()).value());
9363 case attr::LocksExcluded: {
9364 const auto *From = cast<LocksExcludedAttr>(FromAttr);
9366 AI.importArrayArg(From->args(), From->args_size()).value(),
9374 AI.cloneAttr(FromAttr);
9379 return std::move(AI).getResult();
9383 return ImportedDecls.lookup(FromD);
9387 auto FromDPos = ImportedFromDecls.find(ToD);
9388 if (FromDPos == ImportedFromDecls.end())
9390 return FromDPos->second->getTranslationUnitDecl();
9393Error ASTImporter::ImportAttrs(
Decl *ToD,
Decl *FromD) {
9395 return Error::success();
9397 auto ToAttrOrErr =
Import(FromAttr);
9401 return ToAttrOrErr.takeError();
9403 return Error::success();
9411 ImportPath.
push(FromD);
9412 auto ImportPathBuilder =
9413 llvm::make_scope_exit([
this]() { ImportPath.
pop(); });
9418 return make_error<ASTImportError>(*Error);
9424 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9426 return make_error<ASTImportError>(*Error);
9443 auto Pos = ImportedDecls.find(FromD);
9444 if (Pos != ImportedDecls.end()) {
9447 auto *ToD = Pos->second;
9448 ImportedDecls.erase(Pos);
9460 auto PosF = ImportedFromDecls.find(ToD);
9461 if (PosF != ImportedFromDecls.end()) {
9466 SharedState->removeDeclFromLookup(ToD);
9467 ImportedFromDecls.erase(PosF);
9479 handleAllErrors(ToDOrErr.takeError(),
9483 if (Pos != ImportedDecls.end())
9484 SharedState->setImportDeclError(Pos->second, ErrOut);
9488 for (
const auto &Path : SavedImportPaths[FromD]) {
9491 Decl *PrevFromDi = FromD;
9492 for (
Decl *FromDi : Path) {
9494 if (FromDi == FromD)
9501 PrevFromDi = FromDi;
9505 auto Ii = ImportedDecls.find(FromDi);
9506 if (Ii != ImportedDecls.end())
9507 SharedState->setImportDeclError(Ii->second, ErrOut);
9512 SavedImportPaths.erase(FromD);
9515 return make_error<ASTImportError>(ErrOut);
9527 return make_error<ASTImportError>(*Err);
9533 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9535 return make_error<ASTImportError>(*Error);
9538 assert(ImportedDecls.count(FromD) != 0 &&
"Missing call to MapImported?");
9539 if (
auto Error = ImportAttrs(ToD, FromD))
9540 return std::move(Error);
9546 SavedImportPaths.erase(FromD);
9561 return ToDCOrErr.takeError();
9562 auto *ToDC = cast<DeclContext>(*ToDCOrErr);
9566 if (
auto *ToRecord = dyn_cast<RecordDecl>(ToDC)) {
9567 auto *FromRecord = cast<RecordDecl>(FromDC);
9568 if (ToRecord->isCompleteDefinition())
9576 if (FromRecord->getASTContext().getExternalSource() &&
9577 !FromRecord->isCompleteDefinition())
9578 FromRecord->getASTContext().getExternalSource()->CompleteType(FromRecord);
9580 if (FromRecord->isCompleteDefinition())
9583 return std::move(Err);
9584 }
else if (
auto *ToEnum = dyn_cast<EnumDecl>(ToDC)) {
9585 auto *FromEnum = cast<EnumDecl>(FromDC);
9586 if (ToEnum->isCompleteDefinition()) {
9588 }
else if (FromEnum->isCompleteDefinition()) {
9591 return std::move(Err);
9595 }
else if (
auto *ToClass = dyn_cast<ObjCInterfaceDecl>(ToDC)) {
9596 auto *FromClass = cast<ObjCInterfaceDecl>(FromDC);
9597 if (ToClass->getDefinition()) {
9602 return std::move(Err);
9606 }
else if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(ToDC)) {
9607 auto *FromProto = cast<ObjCProtocolDecl>(FromDC);
9608 if (ToProto->getDefinition()) {
9613 return std::move(Err);
9624 return cast_or_null<Expr>(*ToSOrErr);
9626 return ToSOrErr.takeError();
9634 llvm::DenseMap<Stmt *, Stmt *>::iterator Pos = ImportedStmts.find(FromS);
9635 if (Pos != ImportedStmts.end())
9644 if (
auto *ToE = dyn_cast<Expr>(*ToSOrErr)) {
9645 auto *FromE = cast<Expr>(FromS);
9648 ToE->setValueKind(FromE->getValueKind());
9649 ToE->setObjectKind(FromE->getObjectKind());
9650 ToE->setDependence(FromE->getDependence());
9654 ImportedStmts[FromS] = *ToSOrErr;
9665 return std::move(Err);
9669 assert(FromNNS->
getAsIdentifier() &&
"NNS should contain identifier.");
9676 cast<NamespaceDecl>(*NSOrErr));
9678 return NSOrErr.takeError();
9683 cast<NamespaceAliasDecl>(*NSADOrErr));
9685 return NSADOrErr.takeError();
9693 cast<CXXRecordDecl>(*RDOrErr));
9695 return RDOrErr.takeError();
9705 return TyOrErr.takeError();
9709 llvm_unreachable(
"Invalid nested name specifier kind");
9721 NestedNames.push_back(NNS);
9727 while (!NestedNames.empty()) {
9728 NNS = NestedNames.pop_back_val();
9731 return std::move(Err);
9738 return std::move(Err);
9742 return std::move(Err);
9758 ToLocalBeginLoc, ToLocalEndLoc);
9765 return std::move(Err);
9785 if (!ToSourceRangeOrErr)
9786 return ToSourceRangeOrErr.takeError();
9789 ToSourceRangeOrErr->getBegin(),
9790 ToSourceRangeOrErr->getEnd());
9802 return TemplateName(cast<TemplateDecl>((*ToTemplateOrErr)->getCanonicalDecl()));
9804 return ToTemplateOrErr.takeError();
9809 for (
auto *I : *FromStorage) {
9810 if (
auto ToOrErr =
Import(I))
9811 ToTemplates.
addDecl(cast<NamedDecl>(*ToOrErr));
9813 return ToOrErr.takeError();
9823 return DeclNameOrErr.takeError();
9830 if (!QualifierOrErr)
9831 return QualifierOrErr.takeError();
9834 return TNOrErr.takeError();
9842 if (!QualifierOrErr)
9843 return QualifierOrErr.takeError();
9858 if (!ReplacementOrErr)
9859 return ReplacementOrErr.takeError();
9862 if (!AssociatedDeclOrErr)
9863 return AssociatedDeclOrErr.takeError();
9866 *ReplacementOrErr, *AssociatedDeclOrErr, Subst->
getIndex(),
9877 return ArgPackOrErr.takeError();
9880 if (!AssociatedDeclOrErr)
9881 return AssociatedDeclOrErr.takeError();
9884 *ArgPackOrErr, *AssociatedDeclOrErr, SubstPack->
getIndex(),
9890 return UsingOrError.takeError();
9891 return TemplateName(cast<UsingShadowDecl>(*UsingOrError));
9895 llvm_unreachable(
"Invalid template name kind");
9908 return ToFileIDOrErr.takeError();
9916 return std::move(Err);
9918 return std::move(Err);
9924 llvm::DenseMap<FileID, FileID>::iterator Pos = ImportedFileIDs.find(FromID);
9925 if (Pos != ImportedFileIDs.end())
9938 return ToSpLoc.takeError();
9941 return ToExLocS.takeError();
9951 return ToExLocE.takeError();
9957 if (!IsBuiltin && !
Cache->BufferOverridden) {
9961 return ToIncludeLoc.takeError();
9972 if (
Cache->OrigEntry &&
Cache->OrigEntry->getDir()) {
9983 ToID = ToSM.
createFileID(*Entry, ToIncludeLocOrFakeLoc,
9990 std::optional<llvm::MemoryBufferRef> FromBuf =
9996 std::unique_ptr<llvm::MemoryBuffer> ToBuf =
9997 llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(),
9998 FromBuf->getBufferIdentifier());
10004 assert(ToID.
isValid() &&
"Unexpected invalid fileID was created.");
10006 ImportedFileIDs[FromID] = ToID;
10013 return ToExprOrErr.takeError();
10016 if (!LParenLocOrErr)
10017 return LParenLocOrErr.takeError();
10020 if (!RParenLocOrErr)
10021 return RParenLocOrErr.takeError();
10026 return ToTInfoOrErr.takeError();
10031 return std::move(Err);
10034 ToContext, *ToTInfoOrErr, From->
isBaseVirtual(), *LParenLocOrErr,
10035 *ToExprOrErr, *RParenLocOrErr, EllipsisLoc);
10039 return ToFieldOrErr.takeError();
10042 if (!MemberLocOrErr)
10043 return MemberLocOrErr.takeError();
10046 ToContext, cast_or_null<FieldDecl>(*ToFieldOrErr), *MemberLocOrErr,
10047 *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10050 if (!ToIFieldOrErr)
10051 return ToIFieldOrErr.takeError();
10054 if (!MemberLocOrErr)
10055 return MemberLocOrErr.takeError();
10058 ToContext, cast_or_null<IndirectFieldDecl>(*ToIFieldOrErr),
10059 *MemberLocOrErr, *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10063 return ToTInfoOrErr.takeError();
10065 return new (ToContext)
10067 *ToExprOrErr, *RParenLocOrErr);
10070 return make_error<ASTImportError>();
10076 auto Pos = ImportedCXXBaseSpecifiers.find(BaseSpec);
10077 if (Pos != ImportedCXXBaseSpecifiers.end())
10078 return Pos->second;
10081 if (!ToSourceRange)
10082 return ToSourceRange.takeError();
10085 return ToTSI.takeError();
10087 if (!ToEllipsisLoc)
10088 return ToEllipsisLoc.takeError();
10092 ImportedCXXBaseSpecifiers[BaseSpec] =
Imported;
10104 return ToOrErr.takeError();
10105 Decl *To = *ToOrErr;
10107 auto *FromDC = cast<DeclContext>(From);
10110 if (
auto *ToRecord = dyn_cast<RecordDecl>(To)) {
10111 if (!ToRecord->getDefinition()) {
10113 cast<RecordDecl>(FromDC), ToRecord,
10118 if (
auto *ToEnum = dyn_cast<EnumDecl>(To)) {
10119 if (!ToEnum->getDefinition()) {
10125 if (
auto *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
10126 if (!ToIFace->getDefinition()) {
10128 cast<ObjCInterfaceDecl>(FromDC), ToIFace,
10133 if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
10134 if (!ToProto->getDefinition()) {
10136 cast<ObjCProtocolDecl>(FromDC), ToProto,
10158 return ToSelOrErr.takeError();
10165 return ToTyOrErr.takeError();
10173 return ToTyOrErr.takeError();
10179 cast<TemplateDecl>(*ToTemplateOrErr));
10181 return ToTemplateOrErr.takeError();
10189 return ToTyOrErr.takeError();
10205 llvm_unreachable(
"Invalid DeclarationName Kind!");
10226 for (
unsigned I = 1, N = FromSel.
getNumArgs(); I < N; ++I)
10234 llvm::Error Err = llvm::Error::success();
10235 auto ImportLoop = [&](
const APValue *From,
APValue *To,
unsigned Size) {
10236 for (
unsigned Idx = 0; Idx < Size; Idx++) {
10241 switch (FromValue.
getKind()) {
10255 ImportLoop(((
const APValue::Vec *)(
const char *)&FromValue.Data)->Elts,
10262 ImportLoop(((
const APValue::Arr *)(
const char *)&FromValue.Data)->Elts,
10263 ((
const APValue::Arr *)(
const char *)&
Result.Data)->Elts,
10270 ((
const APValue::StructData *)(
const char *)&FromValue.Data)->Elts,
10271 ((
const APValue::StructData *)(
const char *)&
Result.Data)->Elts,
10279 return std::move(Err);
10280 Result.setUnion(cast<FieldDecl>(ImpFDecl), ImpValue);
10284 Result.MakeAddrLabelDiff();
10288 return std::move(Err);
10289 Result.setAddrLabelDiff(cast<AddrLabelExpr>(ImpLHS),
10290 cast<AddrLabelExpr>(ImpRHS));
10294 const Decl *ImpMemPtrDecl =
10297 return std::move(Err);
10299 Result.setMemberPointerUninit(
10300 cast<const ValueDecl>(ImpMemPtrDecl),
10304 Result.getMemberPointerPath();
10309 return std::move(Err);
10319 "in C++20 dynamic allocation are transient so they shouldn't "
10320 "appear in the AST");
10322 if (
const auto *E =
10324 FromElemTy = E->getType();
10327 return std::move(Err);
10337 return std::move(Err);
10349 return std::move(Err);
10363 for (
unsigned LoopIdx = 0; LoopIdx < PathLength; LoopIdx++) {
10366 FromPath[LoopIdx].getAsBaseOrMember().getPointer();
10369 return std::move(Err);
10370 if (
auto *RD = dyn_cast<CXXRecordDecl>(
FromDecl))
10373 FromElemTy = cast<ValueDecl>(
FromDecl)->getType();
10375 ImpDecl, FromPath[LoopIdx].getAsBaseOrMember().getInt()));
10380 FromPath[LoopIdx].getAsArrayIndex());
10388 return std::move(Err);
10396 unsigned NumDecls) {
10406 if (LastDiagFromFrom)
10409 LastDiagFromFrom =
false;
10414 if (!LastDiagFromFrom)
10417 LastDiagFromFrom =
true;
10422 if (
auto *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
10423 if (!ID->getDefinition())
10424 ID->startDefinition();
10426 else if (
auto *PD = dyn_cast<ObjCProtocolDecl>(D)) {
10427 if (!PD->getDefinition())
10428 PD->startDefinition();
10430 else if (
auto *TD = dyn_cast<TagDecl>(D)) {
10431 if (!TD->getDefinition() && !TD->isBeingDefined()) {
10432 TD->startDefinition();
10433 TD->setCompleteDefinition(
true);
10437 assert(0 &&
"CompleteDecl called on a Decl that can't be completed");
10442 llvm::DenseMap<Decl *, Decl *>::iterator Pos = ImportedDecls.find(From);
10443 assert((Pos == ImportedDecls.end() || Pos->second == To) &&
10444 "Try to import an already imported Decl");
10445 if (Pos != ImportedDecls.end())
10446 return Pos->second;
10447 ImportedDecls[From] = To;
10450 ImportedFromDecls[To] = From;
10455 AddToLookupTable(To);
10459std::optional<ASTImportError>
10461 auto Pos = ImportDeclErrors.find(FromD);
10462 if (Pos != ImportDeclErrors.end())
10463 return Pos->second;
10465 return std::nullopt;
10469 auto InsertRes = ImportDeclErrors.insert({From, Error});
10473 assert(InsertRes.second || InsertRes.first->second.Error == Error.Error);
10478 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
10480 if (Pos != ImportedTypes.end()) {
10485 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.
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
llvm::APInt getValue() const
unsigned getVersion() const
QualType getTypeInfoType() const
static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo)
unsigned getCallIndex() const
A non-discriminated union of a base, field, or array index.
static LValuePathEntry ArrayIndex(uint64_t Index)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
const LValueBase getLValueBase() const
ArrayRef< LValuePathEntry > getLValuePath() const
const FieldDecl * getUnionField() const
unsigned getStructNumFields() const
llvm::PointerIntPair< const Decl *, 1, bool > BaseOrMemberType
A FieldDecl or CXXRecordDecl, along with a flag indicating whether we mean a virtual or non-virtual b...
ValueKind getKind() const
bool isLValueOnePastTheEnd() const
bool isMemberPointerToDerivedMember() const
unsigned getArrayInitializedElts() const
unsigned getStructNumBases() const
bool hasLValuePath() const
const ValueDecl * getMemberPointerDecl() const
APValue & getUnionValue()
const AddrLabelExpr * getAddrLabelDiffRHS() const
CharUnits & getLValueOffset()
unsigned getVectorLength() const
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
unsigned getArraySize() const
@ Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
@ None
There is no such object (it's outside its lifetime).
bool isNullPointer() const
const AddrLabelExpr * getAddrLabelDiffLHS() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType 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.
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 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)
Error ImportTemplateParameterLists(const DeclaratorDecl *FromD, DeclaratorDecl *ToD)
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)
SourceLocation getColonLoc() const
SourceLocation getQuestionLoc() const
Represents an access specifier followed by colon ':'.
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
AddrLabelExpr - The GNU address of label extension, representing &&label.
SourceLocation getAmpAmpLoc() const
SourceLocation getLabelLoc() const
LabelDecl * getLabel() const
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.
OpaqueValueExpr * getCommonExpr() const
Get the common subexpression shared by all initializations (the source array).
Expr * getSubExpr() const
Get the initializer to use for each array element.
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.
SourceLocation getRBracketLoc() const
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
uint64_t getValue() const
SourceLocation getEndLoc() const LLVM_READONLY
ArrayTypeTrait getTrait() const
Expr * getDimensionExpression() const
TypeSourceInfo * getQueriedTypeSourceInfo() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents an array type, per C99 6.7.5.2 - Array Declarators.
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,...
SourceLocation getRParenLoc() const
static unsigned getNumSubExprs(AtomicOp Op)
Determine the number of arguments the specified atomic builtin should have.
SourceLocation getBuiltinLoc() const
Attr - This represents one attribute.
attr::Kind getKind() const
void setPackExpansion(bool PE)
Attr * clone(ASTContext &C) const
SourceRange getRange() const
void setRange(SourceRange R)
void setAttrName(const IdentifierInfo *AttrNameII)
const IdentifierInfo * getAttrName() const
Represents an attribute applied to a statement.
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)
shadow_range shadows() const
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value.
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression which will be evaluated if the condition evaluates to true; th...
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
A builtin binary operation expression such as "x + y" or "x <= y".
SourceLocation getOperatorLoc() const
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
FPOptionsOverride getFPFeatures() const
A binding in a decomposition declaration.
ValueDecl * getDecomposedDecl() const
Get the decomposition declaration that this binding represents a decomposition of.
Expr * getBinding() const
Get the expression to which this declaration is bound.
void setBinding(QualType DeclaredType, Expr *Binding)
Set the binding for this BindingDecl, along with its declared type (which should be a possibly-cv-qua...
void setDecomposedDecl(ValueDecl *Decomposed)
Set the decomposed variable for this BindingDecl.
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...
BuiltinTemplateKind getBuiltinTemplateKind() const
This class is used for builtin types like 'int'.
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
Represents a base class of a C++ class.
AccessSpecifier getAccessSpecifierAsWritten() const
Retrieves the access specifier as written in the source code (which may mean that no access specifier...
SourceLocation getEllipsisLoc() const
For a pack expansion, determine the location of the ellipsis.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
TypeSourceInfo * getTypeSourceInfo() const
Retrieves the type and source location of the base class.
bool isBaseOfClass() const
Determine whether this base class is a base of a class declared with the 'class' keyword (vs.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
Represents binding an expression to a temporary.
CXXTemporary * getTemporary()
static CXXBindTemporaryExpr * Create(const ASTContext &C, CXXTemporary *Temp, Expr *SubExpr)
const Expr * getSubExpr() const
A boolean literal, per ([C++ lex.bool] Boolean literals).
static CXXBoolLiteralExpr * Create(const ASTContext &C, bool Val, QualType Ty, SourceLocation Loc)
SourceLocation getLocation() const
CXXCatchStmt - This represents a C++ catch block.
static CXXConstCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Represents a call to a C++ constructor.
SourceRange getParenOrBraceRange() const
void setIsImmediateEscalating(bool Set)
bool isElidable() const
Whether this construction is elidable.
bool hadMultipleCandidates() const
Whether the referred constructor was resolved from an overloaded set having size greater than 1.
static CXXConstructExpr * Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr * > Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, CXXConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Create a C++ construction expression.
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
bool isImmediateEscalating() const
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called.
SourceLocation getLocation() const
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
CXXConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Represents a C++ constructor within a class.
Represents a C++ conversion function within a class.
Represents a C++ base or member initializer.
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
Expr * getInit() const
Get the initializer.
SourceLocation getRParenLoc() const
SourceLocation getEllipsisLoc() const
SourceLocation getLParenLoc() const
bool isPackExpansion() const
Determine whether this initializer is a pack expansion.
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
bool isMemberInitializer() const
Determine whether this initializer is initializing a non-static data member.
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
bool isIndirectMemberInitializer() const
SourceLocation getMemberLocation() const
IndirectFieldDecl * getIndirectMember() const
bool isBaseVirtual() const
Returns whether the base is virtual or not.
Represents a C++ deduction guide declaration.
A default argument (C++ [dcl.fct.default]).
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
const ParmVarDecl * getParam() const
Expr * getRewrittenExpr()
const DeclContext * getUsedContext() const
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
bool hasRewrittenInit() const
A use of a default initializer in a constructor or in aggregate initialization.
static CXXDefaultInitExpr * Create(const ASTContext &Ctx, SourceLocation Loc, FieldDecl *Field, DeclContext *UsedContext, Expr *RewrittenInitExpr)
Field is the non-static data member whose default initializer is used by this expression.
const DeclContext * getUsedContext() const
const Expr * getRewrittenExpr() const
Retrieve the initializing expression with evaluated immediate calls, if any.
bool hasRewrittenInit() const
FieldDecl * getField()
Get the field whose initializer will be used.
SourceLocation getBeginLoc() const
Represents a delete expression for memory deallocation and destructor calls, e.g.
FunctionDecl * getOperatorDelete() const
SourceLocation getBeginLoc() const
bool isGlobalDelete() const
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
bool isArrayFormAsWritten() const
Represents a C++ member access expression where the actual member referenced could not be resolved be...
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
SourceLocation getOperatorLoc() const
Retrieve the location of the '->' or '.' operator.
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
SourceLocation getMemberLoc() const
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the member name, with source location information.
bool isImplicitAccess() const
True if this is an implicit access, i.e.
ArrayRef< TemplateArgumentLoc > template_arguments() const
Represents a C++ destructor within a class.
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg)
static CXXDynamicCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Represents a folding of a pack over an operator.
UnresolvedLookupExpr * getCallee() const
std::optional< unsigned > getNumExpansions() const
SourceLocation getLParenLoc() const
SourceLocation getEllipsisLoc() const
SourceLocation getRParenLoc() const
BinaryOperatorKind getOperator() const
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.
bool constructsVBase() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will call.
SourceLocation getLocation() const LLVM_READONLY
bool inheritedFromVBase() const
Determine whether the inherited constructor is inherited from a virtual base of the object we constru...
Represents a call to a member function that may be written either with member call syntax (e....
static CXXMemberCallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RP, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0)
Represents a static or instance method of a struct/union/class.
void addOverriddenMethod(const CXXMethodDecl *MD)
overridden_method_range overridden_methods() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Abstract class common to all of the C++ "named"/"keyword" casts.
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
SourceRange getAngleBrackets() const LLVM_READONLY
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
SourceRange getDirectInitRange() const
llvm::iterator_range< arg_iterator > placement_arguments()
std::optional< Expr * > getArraySize()
This might return std::nullopt even if isArray() returns true, since there might not be an array size...
CXXNewInitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
bool passAlignment() const
Indicates whether the required alignment should be implicitly passed to the allocation function.
FunctionDecl * getOperatorDelete() const
unsigned getNumPlacementArgs() const
TypeSourceInfo * getAllocatedTypeSourceInfo() const
SourceRange getSourceRange() const
SourceRange getTypeIdParens() const
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
FunctionDecl * getOperatorNew() const
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.
Expr * getInitializer()
The initializer of this new-expression.
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
SourceLocation getEndLoc() const
Expr * getOperand() const
SourceLocation getBeginLoc() const
The null pointer literal (C++11 [lex.nullptr])
SourceLocation getLocation() const
static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptionsOverride FPFeatures, ADLCallKind UsesADL=NotADL)
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
TypeSourceInfo * getDestroyedTypeInfo() const
Retrieve the source location information for the type being destroyed.
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise,...
TypeSourceInfo * getScopeTypeInfo() const
Retrieve the scope type in a qualified pseudo-destructor expression.
SourceLocation getTildeLoc() const
Retrieve the location of the '~'.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieves the nested-name-specifier that qualifies the type name, with source-location information.
SourceLocation getDestroyedTypeLoc() const
Retrieve the starting location of the type being destroyed.
SourceLocation getColonColonLoc() const
Retrieve the location of the '::' in a qualified pseudo-destructor expression.
SourceLocation getOperatorLoc() const
Retrieve the location of the '.' or '->' operator.
const IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
Represents a C++ struct/union/class.
CXXRecordDecl * getMostRecentDecl()
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
method_range methods() const
CXXRecordDecl * getDefinition() const
static CXXRecordDecl * CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, unsigned DependencyKind, bool IsGeneric, LambdaCaptureDefault CaptureDefault)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
void 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.
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
bool isReversed() const
Determine whether this expression was rewritten in reverse form.
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type.
TypeSourceInfo * getTypeSourceInfo() const
SourceLocation getRParenLoc() const
static CXXStaticCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, FPOptionsOverride FPO, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Represents a C++ functional cast expression that builds a temporary object.
static CXXTemporaryObjectExpr * Create(const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty, TypeSourceInfo *TSI, ArrayRef< Expr * > Args, SourceRange ParenOrBraceRange, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization)
TypeSourceInfo * getTypeSourceInfo() const
Represents a C++ temporary.
const CXXDestructorDecl * getDestructor() const
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
Represents the this expression in C++.
static CXXThisExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType Ty, bool IsImplicit)
SourceLocation getLocation() const
A C++ throw-expression (C++ [except.throw]).
const Expr * getSubExpr() const
SourceLocation getThrowLoc() const
bool isThrownVariableInScope() const
Determines whether the variable thrown by this expression (if any!) is within the innermost try block...
CXXTryStmt - A C++ try block, including all handlers.
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...
bool isTypeOperand() const
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Expr * getExprOperand() const
SourceRange getSourceRange() const LLVM_READONLY
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
bool isListInitialization() const
Determine whether this expression models list-initialization.
static CXXUnresolvedConstructExpr * Create(const ASTContext &Context, QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool IsListInit)
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
unsigned getNumArgs() const
Retrieve the number of arguments.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
ADLCallKind getADLCallKind() const
FPOptionsOverride getFPFeatures() const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
SourceLocation getRParenLoc() const
CaseStmt - Represent a case statement.
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()
CastKind getCastKind() const
FPOptionsOverride getFPFeatures() const
CharUnits - This is an opaque type for sizes expressed in character units.
SourceLocation getLocation() const
unsigned getValue() const
CharacterLiteralKind getKind() const
How to handle import errors that occur when import of a child declaration of a DeclContext fails.
bool ignoreChildErrorOnParent(Decl *FromChildD) const
Determine if import failure of a child does not cause import failure of its parent.
ChildErrorHandlingStrategy(const Decl *FromD)
void handleChildImportResult(Error &ResultErr, Error &&ChildErr)
Process the import result of a child (of the current declaration).
ChildErrorHandlingStrategy(const DeclContext *FromDC)
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
SourceLocation getBuiltinLoc() const
bool isConditionDependent() const
bool isConditionTrue() const
isConditionTrue - Return whether the condition is true (i.e.
SourceLocation getRParenLoc() const
Declaration of a class template.
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
ClassTemplateDecl * getMostRecentDecl()
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary class pattern.
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
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.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Get the template arguments as written.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a class template specialization, which refers to a class template with a given set of temp...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
void setPointOfInstantiation(SourceLocation Loc)
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
void setSpecializationKind(TemplateSpecializationKind TSK)
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this class template specialization is an instantiation of a template (rather than an explicit spec...
void setExternLoc(SourceLocation Loc)
Sets the location of the extern 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,...
Complex values, per C99 6.2.5p11.
CompoundAssignOperator - For compound assignments (e.g.
QualType getComputationLHSType() const
static CompoundAssignOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures, QualType CompLHSType=QualType(), QualType CompResultType=QualType())
QualType getComputationResultType() const
CompoundLiteralExpr - [C99 6.5.2.5].
SourceLocation getLParenLoc() const
const Expr * getInitializer() const
TypeSourceInfo * getTypeSourceInfo() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
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.
Expr * getCond() const
getCond - Return the expression representing the condition for the ?: 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...
APValue getAPValueResult() const
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...
SourceLocation getRParenLoc() const
getRParenLoc - Return the location of final right parenthesis.
SourceLocation getBuiltinLoc() const
getBuiltinLoc - Return the location of the __builtin_convertvector token.
TypeSourceInfo * getTypeSourceInfo() const
getTypeSourceInfo - Return the destination type.
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
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)
NamedDecl * getDecl() const
AccessSpecifier getAccess() const
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDeclInternal(Decl *D)
Add the declaration D into this context, but suppress searches for external declarations with the sam...
bool containsDeclAndLoad(Decl *D) const
Checks whether a declaration is in this context.
void removeDecl(Decl *D)
Removes a declaration from this context.
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
void localUncachedLookup(DeclarationName Name, SmallVectorImpl< NamedDecl * > &Results)
A simplistic name lookup mechanism that performs name lookup into this declaration context without co...
static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls)
A reference to a declared variable, function, enum, etc.
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name,...
ArrayRef< TemplateArgumentLoc > template_arguments() const
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
bool hadMultipleCandidates() const
Returns true if this expression refers to a function that was resolved from an overloaded set having ...
SourceLocation getLocation() const
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
bool isImmediateEscalating() const
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
A simple visitor class that helps create declaration visitors.
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEndLoc() const LLVM_READONLY
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 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)
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.
Represents a ValueDecl that came out of a declarator.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
TemplateParameterList * getTemplateParameterList(unsigned index) const
SourceLocation getBeginLoc() const LLVM_READONLY
unsigned getNumTemplateParameterLists() const
void setTypeSourceInfo(TypeSourceInfo *TI)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
TypeSourceInfo * getTypeSourceInfo() const
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
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)
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
ArrayRef< TemplateArgumentLoc > template_arguments() const
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
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.
unsigned getArrayIndex() const
bool isFieldDesignator() const
static Designator CreateArrayRangeDesignator(unsigned Index, SourceLocation LBracketLoc, SourceLocation EllipsisLoc, SourceLocation RBracketLoc)
Creates a GNU array-range designator.
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
bool isArrayRangeDesignator() const
static Designator CreateArrayDesignator(unsigned Index, SourceLocation LBracketLoc, SourceLocation RBracketLoc)
Creates an array designator.
bool isArrayDesignator() const
SourceLocation getFieldLoc() const
SourceLocation getRBracketLoc() const
const IdentifierInfo * getFieldName() const
SourceLocation getEllipsisLoc() const
SourceLocation getDotLoc() const
SourceLocation getLBracketLoc() const
Represents a C99 designated initializer expression.
Expr * getSubExpr(unsigned Idx) const
llvm::MutableArrayRef< Designator > designators()
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
static DesignatedInitExpr * Create(const ASTContext &C, llvm::ArrayRef< Designator > Designators, ArrayRef< Expr * > IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
Expr * getInit() const
Retrieve the initializer value.
unsigned size() const
Returns the number of designators in this initializer.
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the '=' that precedes the initializer value itself, if present.
unsigned getNumSubExprs() const
Retrieve the total number of subexpressions in this designated initializer expression,...
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.
llvm::APSInt getInitVal() const
const Expr * getInitExpr() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
void setIntegerType(QualType T)
Set the underlying integer type.
EnumDecl * getMostRecentDecl()
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
void completeDefinition(QualType NewType, QualType PromotionType, unsigned NumPositiveBits, unsigned NumNegativeBits)
When created, the EnumDecl corresponds to a forward-declared enum.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
EnumDecl * getDefinition() const
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum.
QualType getPromotionType() const
Return the integer type that enumerators should promote to.
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.
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
Store information needed for an explicit specifier.
ExplicitSpecKind getKind() const
const Expr * getExpr() const
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
bool cleanupsHaveSideEffects() const
ArrayRef< CleanupObject > getObjects() const
unsigned getNumObjects() const
llvm::PointerUnion< BlockDecl *, CompoundLiteralExpr * > CleanupObject
The type of objects that are kept in the cleanup.
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
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.
SourceLocation getBeginLoc() const LLVM_READONLY
Expr * getQueriedExpression() const
ExpressionTrait getTrait() const
SourceLocation getEndLoc() const LLVM_READONLY
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.
bool isMutable() const
Determines whether this field is mutable (C++ only).
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
void setInClassInitializer(Expr *NewInit)
Set the C++11 in-class initializer for this member.
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
const VariableArrayType * getCapturedVLAType() const
Get the captured variable length array type.
void setCapturedVLAType(const VariableArrayType *VLAType)
Set the captured variable length array type for this field.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Implements support for file system lookup, file system caching, and directory search management.
OptionalFileEntryRef getOptionalFileRef(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Get a FileEntryRef if it exists, without doing anything on error.
SourceLocation getLocation() const
Retrieve the location of the literal.
SourceLocation getLocation() const
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
llvm::APFloat getValue() const
ForStmt - This represents a 'for (init;cond;inc)' stmt.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
const Expr * getSubExpr() const
static DefaultedOrDeletedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups, StringLiteral *DeletedMessage=nullptr)
Represents a function declaration or definition.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
ConstexprSpecKind getConstexprKind() const
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
void setIsPureVirtual(bool P=true)
void setDefaultedOrDeletedInfo(DefaultedOrDeletedFunctionInfo *Info)
void setFriendConstraintRefersToEnclosingTemplate(bool V=true)
StringLiteral * getDeletedMessage() const
Get the message that indicates why this function was deleted.
bool UsesFPIntrin() const
Determine whether the function was declared in source context that requires constrained FP intrinsics...
SourceLocation getDefaultLoc() const
ArrayRef< ParmVarDecl * > parameters() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
bool hasWrittenPrototype() const
Whether this function has a written prototype.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
void setDefaultLoc(SourceLocation NewLoc)
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
@ TK_MemberSpecialization
@ TK_DependentNonTemplate
@ TK_FunctionTemplateSpecialization
@ TK_DependentFunctionTemplateSpecialization
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool FriendConstraintRefersToEnclosingTemplate() const
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
void setInstantiatedFromDecl(FunctionDecl *FD)
Specify that this function declaration was instantiated from a FunctionDecl FD.
bool isDeletedAsWritten() const
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo *TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization.
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
FunctionDecl * getDefinition()
Get the definition for this declaration.
void setRangeEnd(SourceLocation E)
bool isDefaulted() const
Whether this function is defaulted.
FunctionDecl * getInstantiatedFromDecl() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
void setDefaulted(bool D=true)
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
void setDeletedAsWritten(bool D=true, StringLiteral *Message=nullptr)
void setExplicitlyDefaulted(bool ED=true)
State that this function is explicitly defaulted.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
DeclarationNameInfo getNameInfo() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
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.
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary pattern.
FunctionTemplateDecl * getMostRecentDecl()
ExtInfo getExtInfo() const
QualType getReturnType() const
This represents a GCC inline-assembly statement extension.
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a C11 generic selection.
TypeSourceInfo * getControllingType()
Return the controlling type of this generic selection expression.
ArrayRef< Expr * > getAssocExprs() const
bool isExprPredicate() const
Whether this generic selection uses an expression as its controlling argument.
SourceLocation getGenericLoc() const
SourceLocation getRParenLoc() const
unsigned getResultIndex() const
The zero-based index of the result expression's generic association in the generic selection's associ...
SourceLocation getDefaultLoc() const
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression accepting an expression predicate.
bool isResultDependent() const
Whether this generic selection is result-dependent.
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
ArrayRef< TypeSourceInfo * > getAssocTypeSourceInfos() const
GotoStmt - This represents a direct goto.
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....
const Expr * getSubExpr() const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
ImplicitParamKind getParameterKind() const
Returns the implicit parameter kind.
Represents an implicitly-generated value initialization of an object of a given type.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Represents a C array with an unspecified size.
Represents a field injected from an anonymous union/struct into the parent scope.
unsigned getChainingSize() const
ArrayRef< NamedDecl * > chain() const
IndirectGotoStmt - This represents an indirect goto.
Description of a constructor that was inherited from a base class.
CXXConstructorDecl * getConstructor() const
ConstructorUsingShadowDecl * getShadowDecl() const
Describes an C or C++ initializer list.
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
void setSyntacticForm(InitListExpr *Init)
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
unsigned getNumInits() const
SourceLocation getLBraceLoc() const
void setArrayFiller(Expr *filler)
InitListExpr * getSyntacticForm() const
bool hadArrayRangeDesignator() const
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
SourceLocation getRBraceLoc() const
void setInitializedFieldInUnion(FieldDecl *FD)
ArrayRef< Expr * > inits()
void sawArrayRangeDesignator(bool ARD=true)
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'.
SourceLocation getLocation() const
Retrieve the location of the literal.
An lvalue reference type, per C++11 [dcl.ref].
Represents the declaration of a label.
LabelStmt * getStmt() const
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.
SourceLocation getEndLoc() const LLVM_READONLY
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
SourceRange getIntroducerRange() const
Retrieve the source range covering the lambda introducer, which contains the explicit capture list su...
unsigned capture_size() const
Determine the number of captures in this lambda.
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
SourceLocation getCaptureDefaultLoc() const
Retrieve the location of this lambda's capture-default, if any.
llvm::iterator_range< capture_init_iterator > capture_inits()
Retrieve the initialization expressions for this lambda's captures.
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
unsigned getManglingNumber() const
Expr * getTemporaryExpr()
Retrieve the expression to which the temporary materialization conversion was applied.
ValueDecl * getExtendingDecl()
Represents a linkage specification.
void setRBraceLoc(SourceLocation L)
LinkageSpecLanguageIDs getLanguage() const
Return the language specified by this linkage specification.
SourceLocation getExternLoc() const
SourceLocation getRBraceLoc() const
bool hasBraces() const
Determines whether this linkage specification had braces in its syntactic form.
Represents the results of name lookup.
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.
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
bool isBoundToLvalueReference() const
Determine whether this materialized temporary is bound to an lvalue reference; otherwise,...
LifetimeExtendedTemporaryDecl * getLifetimeExtendedTemporaryDecl()
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ArrayRef< TemplateArgumentLoc > template_arguments() const
SourceLocation getOperatorLoc() const
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
NestedNameSpecifierLoc getQualifierLoc() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name,...
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why? This is only meaningful if the named memb...
static MemberExpr * Create(const ASTContext &C, Expr *Base, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *MemberDecl, DeclAccessPair FoundDecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, QualType T, ExprValueKind VK, ExprObjectKind OK, NonOdrUseReason NOUR)
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
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.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Represents a C++ namespace alias.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
SourceLocation getAliasLoc() const
Returns the location of the alias name, i.e.
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Represent a C++ namespace.
SourceLocation getRBraceLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isInline() const
Returns true if this is an inline namespace declaration.
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
bool isNested() const
Returns true if this is a nested namespace declaration.
void setRBraceLoc(SourceLocation L)
Class that aids in the construction of nested-name-specifiers along with source-location information ...
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.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
void setDefaultArgument(Expr *DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
unsigned getDepth() const
Get the nesting depth of the template parameter.
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.
ObjCCategoryImplDecl * getImplementation() const
ObjCInterfaceDecl * getClassInterface()
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
protocol_iterator protocol_end() const
SourceLocation getIvarLBraceLoc() const
SourceLocation getIvarRBraceLoc() const
protocol_loc_iterator protocol_loc_begin() const
protocol_iterator protocol_begin() const
void setImplementation(ObjCCategoryImplDecl *ImplD)
ObjCProtocolList::iterator protocol_iterator
SourceLocation getCategoryNameLoc() const
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
SourceLocation getCategoryNameLoc() const
ObjCCategoryDecl * getCategoryDecl() const
SourceLocation getAtStartLoc() const
Represents Objective-C's collection statement.
const ObjCInterfaceDecl * getClassInterface() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
SourceLocation getIvarRBraceLoc() const
SourceLocation getSuperClassLoc() const
const ObjCInterfaceDecl * getSuperClass() const
SourceLocation getIvarLBraceLoc() const
Represents an ObjC class declaration.
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
bool isImplicitInterfaceDecl() const
isImplicitInterfaceDecl - check that this is an implicitly declared ObjCInterfaceDecl node.
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class.
ObjCCategoryDecl * FindCategoryDeclaration(const IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
protocol_loc_iterator protocol_loc_begin() const
void setImplementation(ObjCImplementationDecl *ImplD)
known_categories_range known_categories() const
void setSuperClass(TypeSourceInfo *superClass)
protocol_iterator protocol_end() const
SourceLocation getSuperClassLoc() const
Retrieve the starting location of the superclass.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this class.
ObjCProtocolList::iterator protocol_iterator
ObjCImplementationDecl * getImplementation() const
protocol_iterator protocol_begin() const
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.
AccessControl getAccessControl() const
bool getSynthesize() const
ObjCMethodDecl - Represents an instance or class method declaration.
ImplicitParamDecl * getSelfDecl() const
ArrayRef< ParmVarDecl * > parameters() const
unsigned param_size() const
bool isPropertyAccessor() const
param_const_iterator param_end() const
param_const_iterator param_begin() const
SourceLocation getEndLoc() const LLVM_READONLY
TypeSourceInfo * getReturnTypeSourceInfo() const
bool isSynthesizedAccessorStub() const
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type.
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs=std::nullopt)
Sets the method's parameters and selector source locations.
bool isInstanceMethod() const
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implicit parameters.
QualType getReturnType() const
ParmVarDecl *const * param_iterator
ObjCImplementationControl getImplementationControl() const
ObjCInterfaceDecl * getClassInterface()
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
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())
SourceLocation getGetterNameLoc() const
ObjCMethodDecl * getGetterMethodDecl() const
bool isInstanceProperty() const
ObjCMethodDecl * getSetterMethodDecl() const
SourceLocation getSetterNameLoc() const
SourceLocation getAtLoc() const
void setPropertyAttributes(ObjCPropertyAttribute::Kind PRVal)
ObjCIvarDecl * getPropertyIvarDecl() const
Selector getSetterName() const
TypeSourceInfo * getTypeSourceInfo() const
void setPropertyAttributesAsWritten(ObjCPropertyAttribute::Kind PRVal)
Selector getGetterName() const
void setPropertyIvarDecl(ObjCIvarDecl *Ivar)
SourceLocation getLParenLoc() const
void setSetterMethodDecl(ObjCMethodDecl *gDecl)
ObjCPropertyAttribute::Kind getPropertyAttributesAsWritten() const
ObjCPropertyAttribute::Kind getPropertyAttributes() const
void setGetterName(Selector Sel, SourceLocation Loc=SourceLocation())
PropertyControl getPropertyImplementation() const
void setGetterMethodDecl(ObjCMethodDecl *gDecl)
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
ObjCIvarDecl * getPropertyIvarDecl() const
SourceLocation getPropertyIvarDeclLoc() const
Kind getPropertyImplementation() const
ObjCPropertyDecl * getPropertyDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents an Objective-C protocol declaration.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
void startDefinition()
Starts the definition of this Objective-C protocol.
ObjCProtocolList::iterator protocol_iterator
protocol_iterator protocol_begin() const
protocol_iterator protocol_end() const
protocol_loc_iterator protocol_loc_begin() const
Represents the declaration of an Objective-C type parameter.
unsigned getIndex() const
Retrieve the index into its type parameter list.
SourceLocation getColonLoc() const
Retrieve the location of the ':' separating the type parameter name from the explicitly-specified bou...
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
SourceLocation getVarianceLoc() const
Retrieve the location of the variance keyword.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
SourceLocation getRAngleLoc() const
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl * > typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
SourceLocation getLAngleLoc() const
Represents a type parameter type in Objective C.
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
Expr * getIndexExpr(unsigned Idx)
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
const OffsetOfNode & getComponent(unsigned Idx) const
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr * > exprs, SourceLocation RParenLoc)
TypeSourceInfo * getTypeSourceInfo() const
unsigned getNumExpressions() const
SourceLocation getRParenLoc() const
Return the location of the right parentheses.
unsigned getNumComponents() const
Helper class for OffsetOfExpr.
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
FieldDecl * getField() const
For a field offsetof node, returns the field.
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
@ Array
An index into an array.
@ Identifier
A field in a dependent type, known only by its name.
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
SourceLocation getBeginLoc() const LLVM_READONLY
Kind getKind() const
Determine what kind of offsetof node this is.
SourceLocation getEndLoc() const LLVM_READONLY
CXXBaseSpecifier * getBase() const
For a base class node, returns the base specifier.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
SourceLocation getLocation() const
Retrieve the location of this expression.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
SourceLocation getNameLoc() const
Gets the location of the name.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
llvm::iterator_range< decls_iterator > decls() const
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
DeclarationName getName() const
Gets the name looked up.
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
ArrayRef< TemplateArgumentLoc > template_arguments() const
A structure for storing the information associated with an overloaded template name.
Represents a C++11 pack expansion that produces a sequence of expressions.
Expr * getPattern()
Retrieve the pattern of the pack expansion.
std::optional< unsigned > getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated,...
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Represents a pack expansion of types.
ParenExpr - This represents a parethesized expression, e.g.
SourceLocation getLParen() const
Get the location of the left parentheses '('.
const Expr * getSubExpr() const
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
ArrayRef< Expr * > exprs()
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr * > Exprs, SourceLocation RParenLoc)
Create a paren list.
unsigned getNumExprs() const
Return the number of expressions in this paren list.
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
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:
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
void setObjCDeclQualifier(ObjCDeclQualifier QTVal)
void setDefaultArg(Expr *defarg)
SourceLocation getExplicitObjectParamThisLoc() const
void setUnparsedDefaultArg()
Specify that this parameter has an unparsed default argument.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
void setUninstantiatedDefaultArg(Expr *arg)
bool isObjCMethodParameter() const
ObjCDeclQualifier getObjCDeclQualifier() const
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
bool hasUninstantiatedDefaultArg() const
void setObjCMethodScopeInfo(unsigned parameterIndex)
bool hasInheritedDefaultArg() const
void setKNRPromoted(bool promoted)
void setExplicitObjectParameterLoc(SourceLocation Loc)
Expr * getUninstantiatedDefaultArg()
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
unsigned getFunctionScopeDepth() const
void setHasInheritedDefaultArg(bool I=true)
PointerType - C99 6.7.5.1 - Pointer Declarators.
[C99 6.4.2.2] - A predefined identifier such as func.
SourceLocation getBeginLoc() const
static PredefinedExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType FNTy, PredefinedIdentKind IK, bool IsTransparent, StringLiteral *SL)
Create a PredefinedExpr.
bool isTransparent() const
PredefinedIdentKind getIdentKind() const
StringLiteral * getFunctionName()
Stores the type being destroyed by a pseudo-destructor expression.
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 that was expressed as a qualified name.
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)
field_range fields() const
RecordDecl * getMostRecentDecl()
virtual void completeDefinition()
Note that the definition of this type is now complete.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
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 * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
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
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Expr ** getSubExprs()
Retrieve the array of expressions.
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
SourceLocation getRParenLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents an expression that computes the length of a parameter pack.
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof... expression, such as is produced f...
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, std::optional< unsigned > Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs=std::nullopt)
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
NamedDecl * getPack() const
Retrieve the parameter pack.
unsigned getPackLength() const
Retrieve the length of the parameter pack.
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
SourceLocation getBeginLoc() const
const DeclContext * getParentContext() const
If the SourceLocExpr has been resolved return the subexpression representing the resolved value.
SourceLocation getEndLoc() const
SourceLocIdentKind getIdentKind() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
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.
SourceLocation getRParenLoc() const
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
CompoundStmt * getSubStmt()
unsigned getTemplateDepth() const
SourceLocation getRParenLoc() const
SourceLocation getLParenLoc() const
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Stmt - This represents one statement.
child_iterator child_begin()
StmtClass getStmtClass() const
child_iterator child_end()
const char * getStmtClassName() const
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
tokloc_iterator tokloc_begin() const
tokloc_iterator tokloc_end() const
StringLiteralKind getKind() const
StringRef getBytes() const
Allow access to clients that need the byte representation, such as ASTWriterStmt::VisitStringLiteral(...
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...
unsigned getNumConcatenated() const
getNumConcatenated - Get the number of string literal tokens that were concatenated in translation ph...
Represents a reference to a non-type template parameter that has been substituted with a template arg...
std::optional< unsigned > getPackIndex() const
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
bool isReferenceParameter() const
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Expr * getReplacement() const
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.
SourceRange getBraceRange() const
bool isBeingDefined() const
Return true if this decl is currently being defined.
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
TypedefNameDecl * getTypedefNameForAnonDecl() const
void startDefinition()
Starts the definition of this tag declaration.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
TagKind getTagKind() const
void setBraceRange(SourceRange R)
void setCompleteDefinition(bool V=true)
True if this decl has its body fully specified.
A convenient class for passing around template argument information.
SourceLocation getRAngleLoc() const
void addArgument(const TemplateArgumentLoc &Loc)
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.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
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.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
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.
bool wasDeclaredWithTypename() const
Whether this template template parameter was declared with the 'typename' keyword.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
unsigned getDepth() const
Get the nesting depth of the template parameter.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Declaration of a template type parameter.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
unsigned getIndex() const
Retrieve the index of the template parameter.
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
TypeSourceInfo * getDefaultArgumentInfo() const
Retrieves the default argument's source information, if any.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
void setDefaultArgument(TypeSourceInfo *DefArg)
Set the default argument for this template parameter.
bool isParameterPack() const
Returns whether this is a parameter pack.
unsigned getDepth() const
Retrieve the depth of the template parameter.
void setTypeConstraint(ConceptReference *CR, Expr *ImmediatelyDeclaredConstraint)
The top declaration context.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Declaration of an alias template.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
void setTypeForDecl(const Type *TD)
const Type * getTypeForDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
Symbolic representation of typeid(T) for some type T.
const Type * getType() const
SourceLocation getBeginLoc() const
Get the begin source location.
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.
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
static TypeTraitExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, TypeTrait Kind, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc, bool Value)
Create a new type trait expression.
SourceLocation getEndLoc() const LLVM_READONLY
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
TypeTrait getTrait() const
Determine which type trait this expression uses.
SourceLocation getBeginLoc() const LLVM_READONLY
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.
TypeSourceInfo * getTypeSourceInfo() const
QualType getUnderlyingType() const
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
SourceLocation getRParenLoc() const
SourceLocation getOperatorLoc() const
bool isArgumentType() const
TypeSourceInfo * getArgumentTypeInfo() const
UnaryExprOrTypeTrait getKind() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Expr * getSubExpr() const
bool hasStoredFPFeatures() const
Is FPFeatures in Trailing Storage?
FPOptionsOverride getStoredFPFeatures() const
Get FPFeatures from trailing storage.
static UnaryOperator * CreateEmpty(const ASTContext &C, bool hasFPFeatures)
bool canOverflow() const
Returns true if the unary operator can cause an overflow.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent)
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
SourceLocation getOperatorLoc() const
Retrieve the location of the '->' or '.' operator.
bool hasUnresolvedUsing() const
Determine whether the lookup results contain an unresolved using declaration.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
static UnresolvedMemberExpr * Create(const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
void addDecl(NamedDecl *D)
A set of unresolved declarations.
Represents the dependent type named by a dependently-scoped typename using declaration,...
Represents a dependent using declaration which was marked with typename.
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Represents a dependent using declaration which was not marked with typename.
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
DeclarationNameInfo getNameInfo() const
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Represents a C++ using-declaration.
bool hasTypename() const
Return true if the using declaration has 'typename'.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
DeclarationNameInfo getNameInfo() const
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Represents C++ using-directive.
SourceLocation getUsingLoc() const
Return the location of the using keyword.
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
SourceLocation getIdentLocation() const
Returns the location of this using declaration's identifier.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Represents a C++ using-enum-declaration.
SourceLocation getEnumLoc() const
The source location of the 'enum' keyword.
TypeSourceInfo * getEnumType() const
SourceLocation getUsingLoc() const
The source location of the 'using' keyword.
Represents a pack of using declarations that a single using-declarator pack-expanded into.
NamedDecl * getInstantiatedFromUsingDecl() const
Get the using declaration from which this was instantiated.
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
Represents a call to the builtin function __builtin_va_arg.
TypeSourceInfo * getWrittenTypeInfo() const
SourceLocation getBuiltinLoc() const
SourceLocation getRParenLoc() const
bool isMicrosoftABI() const
Returns whether this is really a Win64 ABI va_arg expression.
const Expr * getSubExpr() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
bool isInlineSpecified() const
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
EvaluatedStmt * getEvaluatedStmt() const
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form,...
void setInlineSpecified()
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization,...
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
void setTSCSpec(ThreadStorageClassSpecifier TSC)
bool isInline() const
Whether this variable is (C++1z) inline.
ThreadStorageClassSpecifier getTSCSpec() const
const Expr * getInit() const
void setConstexpr(bool IC)
void setDescribedVarTemplate(VarTemplateDecl *Template)
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void setImplicitlyInline()
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.
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary variable pattern.
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
VarTemplateDecl * getMostRecentDecl()
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setSpecializationKind(TemplateSpecializationKind TSK)
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
void setPointOfInstantiation(SourceLocation Loc)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
const ASTTemplateArgumentListInfo * getTemplateArgsInfo() const
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