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>;
447 template <
typename DeclTy>
460 template <
typename T>
464 bool IgnoreTemplateParmDepth =
false);
656 Err = MaybeVal.takeError();
662 template<
typename IIter,
typename OIter>
664 using ItemT = std::remove_reference_t<
decltype(*Obegin)>;
665 for (; Ibegin != Iend; ++Ibegin, ++Obegin) {
668 return ToOrErr.takeError();
671 return Error::success();
678 template<
typename InContainerTy,
typename OutContainerTy>
680 const InContainerTy &InContainer, OutContainerTy &OutContainer) {
682 InContainer.begin(), InContainer.end(), OutContainer.begin());
685 template<
typename InContainerTy,
typename OIter>
702template <
typename InContainerTy>
706 auto ToLAngleLocOrErr =
import(FromLAngleLoc);
707 if (!ToLAngleLocOrErr)
708 return ToLAngleLocOrErr.takeError();
709 auto ToRAngleLocOrErr =
import(FromRAngleLoc);
710 if (!ToRAngleLocOrErr)
711 return ToRAngleLocOrErr.takeError();
717 return Error::success();
721Error ASTNodeImporter::ImportTemplateArgumentListInfo<TemplateArgumentListInfo>(
732 return ImportTemplateArgumentListInfo(
733 From.LAngleLoc, From.RAngleLoc, From.arguments(),
Result);
745 if (Error Err = importInto(std::get<0>(
Result), FTSInfo->getTemplate()))
746 return std::move(Err);
751 return std::move(Err);
761 return std::move(Err);
764 if (!ToRequiresClause)
765 return ToRequiresClause.takeError();
768 if (!ToTemplateLocOrErr)
769 return ToTemplateLocOrErr.takeError();
771 if (!ToLAngleLocOrErr)
772 return ToLAngleLocOrErr.takeError();
774 if (!ToRAngleLocOrErr)
775 return ToRAngleLocOrErr.takeError();
796 return ToTypeOrErr.takeError();
804 return ToTypeOrErr.takeError();
811 return ToOrErr.takeError();
814 return ToTypeOrErr.takeError();
815 return TemplateArgument(dyn_cast<ValueDecl>((*ToOrErr)->getCanonicalDecl()),
822 return ToTypeOrErr.takeError();
830 return ToTypeOrErr.takeError();
833 return ToValueOrErr.takeError();
840 if (!ToTemplateOrErr)
841 return ToTemplateOrErr.takeError();
849 if (!ToTemplateOrErr)
850 return ToTemplateOrErr.takeError();
860 return ToExpr.takeError();
866 return std::move(Err);
873 llvm_unreachable(
"Invalid template argument kind");
881 return ArgOrErr.takeError();
890 return E.takeError();
896 return TSIOrErr.takeError();
898 auto ToTemplateQualifierLocOrErr =
900 if (!ToTemplateQualifierLocOrErr)
901 return ToTemplateQualifierLocOrErr.takeError();
903 if (!ToTemplateNameLocOrErr)
904 return ToTemplateNameLocOrErr.takeError();
905 auto ToTemplateEllipsisLocOrErr =
907 if (!ToTemplateEllipsisLocOrErr)
908 return ToTemplateEllipsisLocOrErr.takeError();
911 *ToTemplateNameLocOrErr, *ToTemplateEllipsisLocOrErr);
921 size_t NumDecls = DG.
end() - DG.
begin();
923 ToDecls.reserve(NumDecls);
924 for (
Decl *FromD : DG) {
925 if (
auto ToDOrErr =
import(FromD))
926 ToDecls.push_back(*ToDOrErr);
928 return ToDOrErr.takeError();
943 return ToDotLocOrErr.takeError();
946 if (!ToFieldLocOrErr)
947 return ToFieldLocOrErr.takeError();
950 ToFieldName, *ToDotLocOrErr, *ToFieldLocOrErr);
954 if (!ToLBracketLocOrErr)
955 return ToLBracketLocOrErr.takeError();
958 if (!ToRBracketLocOrErr)
959 return ToRBracketLocOrErr.takeError();
964 *ToRBracketLocOrErr);
967 if (!ToEllipsisLocOrErr)
968 return ToEllipsisLocOrErr.takeError();
973 *ToRBracketLocOrErr);
978 Error Err = Error::success();
981 auto ToConceptNameLoc =
987 return std::move(Err);
992 return std::move(Err);
1010 return VarOrErr.takeError();
1015 return LocationOrErr.takeError();
1020 return std::move(Err);
1027template <
typename T>
1029 if (Found->getLinkageInternal() != From->getLinkageInternal())
1032 if (From->hasExternalFormalLinkage())
1033 return Found->hasExternalFormalLinkage();
1036 if (From->isInAnonymousNamespace())
1037 return Found->isInAnonymousNamespace();
1039 return !Found->isInAnonymousNamespace() &&
1040 !Found->hasExternalFormalLinkage();
1060using namespace clang;
1069 ExpectedType UnderlyingTypeOrErr =
import(
T->getValueType());
1070 if (!UnderlyingTypeOrErr)
1071 return UnderlyingTypeOrErr.takeError();
1077 switch (
T->getKind()) {
1078#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1079 case BuiltinType::Id: \
1080 return Importer.getToContext().SingletonId;
1081#include "clang/Basic/OpenCLImageTypes.def"
1082#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1083 case BuiltinType::Id: \
1084 return Importer.getToContext().Id##Ty;
1085#include "clang/Basic/OpenCLExtensionTypes.def"
1086#define SVE_TYPE(Name, Id, SingletonId) \
1087 case BuiltinType::Id: \
1088 return Importer.getToContext().SingletonId;
1089#include "clang/Basic/AArch64SVEACLETypes.def"
1090#define PPC_VECTOR_TYPE(Name, Id, Size) \
1091 case BuiltinType::Id: \
1092 return Importer.getToContext().Id##Ty;
1093#include "clang/Basic/PPCTypes.def"
1094#define RVV_TYPE(Name, Id, SingletonId) \
1095 case BuiltinType::Id: \
1096 return Importer.getToContext().SingletonId;
1097#include "clang/Basic/RISCVVTypes.def"
1098#define WASM_TYPE(Name, Id, SingletonId) \
1099 case BuiltinType::Id: \
1100 return Importer.getToContext().SingletonId;
1101#include "clang/Basic/WebAssemblyReferenceTypes.def"
1102#define SHARED_SINGLETON_TYPE(Expansion)
1103#define BUILTIN_TYPE(Id, SingletonId) \
1104 case BuiltinType::Id: return Importer.getToContext().SingletonId;
1105#include "clang/AST/BuiltinTypes.def"
1113 case BuiltinType::Char_U:
1122 case BuiltinType::Char_S:
1131 case BuiltinType::WChar_S:
1132 case BuiltinType::WChar_U:
1138 llvm_unreachable(
"Invalid BuiltinType Kind!");
1142 ExpectedType ToOriginalTypeOrErr =
import(
T->getOriginalType());
1143 if (!ToOriginalTypeOrErr)
1144 return ToOriginalTypeOrErr.takeError();
1150 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1151 if (!ToElementTypeOrErr)
1152 return ToElementTypeOrErr.takeError();
1159 if (!ToPointeeTypeOrErr)
1160 return ToPointeeTypeOrErr.takeError();
1168 if (!ToPointeeTypeOrErr)
1169 return ToPointeeTypeOrErr.takeError();
1177 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1178 if (!ToPointeeTypeOrErr)
1179 return ToPointeeTypeOrErr.takeError();
1187 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1188 if (!ToPointeeTypeOrErr)
1189 return ToPointeeTypeOrErr.takeError();
1198 if (!ToPointeeTypeOrErr)
1199 return ToPointeeTypeOrErr.takeError();
1202 if (!ClassTypeOrErr)
1203 return ClassTypeOrErr.takeError();
1211 Error Err = Error::success();
1215 return std::move(Err);
1218 ToElementType,
T->getSize(), ToSizeExpr,
T->getSizeModifier(),
1219 T->getIndexTypeCVRQualifiers());
1225 if (!ToArrayTypeOrErr)
1226 return ToArrayTypeOrErr.takeError();
1233 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1234 if (!ToElementTypeOrErr)
1235 return ToElementTypeOrErr.takeError();
1238 T->getSizeModifier(),
1239 T->getIndexTypeCVRQualifiers());
1244 Error Err = Error::success();
1249 return std::move(Err);
1251 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1252 T->getIndexTypeCVRQualifiers(), ToBracketsRange);
1255ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(
1257 Error Err = Error::success();
1262 return std::move(Err);
1267 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1268 T->getIndexTypeCVRQualifiers(), ToBracketsRange);
1271ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType(
1273 Error Err = Error::success();
1278 return std::move(Err);
1280 ToElementType, ToSizeExpr, ToAttrLoc);
1284 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1285 if (!ToElementTypeOrErr)
1286 return ToElementTypeOrErr.takeError();
1289 T->getNumElements(),
1290 T->getVectorKind());
1294 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1295 if (!ToElementTypeOrErr)
1296 return ToElementTypeOrErr.takeError();
1299 T->getNumElements());
1307 if (!ToReturnTypeOrErr)
1308 return ToReturnTypeOrErr.takeError();
1317 if (!ToReturnTypeOrErr)
1318 return ToReturnTypeOrErr.takeError();
1325 return TyOrErr.takeError();
1326 ArgTypes.push_back(*TyOrErr);
1334 return TyOrErr.takeError();
1335 ExceptionTypes.push_back(*TyOrErr);
1339 Error Err = Error::success();
1356 return std::move(Err);
1359 *ToReturnTypeOrErr, ArgTypes, ToEPI);
1364 Error Err = Error::success();
1366 auto ToPrevD =
importChecked(Err,
T->getDecl()->getPreviousDecl());
1368 return std::move(Err);
1371 ToD, cast_or_null<TypeDecl>(ToPrevD));
1376 if (!ToInnerTypeOrErr)
1377 return ToInnerTypeOrErr.takeError();
1387 return Pattern.takeError();
1390 return Index.takeError();
1397 return ToDeclOrErr.takeError();
1404 if (!ToUnderlyingTypeOrErr)
1405 return ToUnderlyingTypeOrErr.takeError();
1413 return ToExprOrErr.takeError();
1418 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnmodifiedType());
1419 if (!ToUnderlyingTypeOrErr)
1420 return ToUnderlyingTypeOrErr.takeError();
1428 return FoundOrErr.takeError();
1430 if (!UnderlyingOrErr)
1431 return UnderlyingOrErr.takeError();
1440 return ToExprOrErr.takeError();
1442 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1443 if (!ToUnderlyingTypeOrErr)
1444 return ToUnderlyingTypeOrErr.takeError();
1447 *ToExprOrErr, *ToUnderlyingTypeOrErr);
1453 if (!ToBaseTypeOrErr)
1454 return ToBaseTypeOrErr.takeError();
1456 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1457 if (!ToUnderlyingTypeOrErr)
1458 return ToUnderlyingTypeOrErr.takeError();
1461 *ToBaseTypeOrErr, *ToUnderlyingTypeOrErr,
T->getUTTKind());
1466 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1467 if (!ToDeducedTypeOrErr)
1468 return ToDeducedTypeOrErr.takeError();
1470 ExpectedDecl ToTypeConstraintConcept =
import(
T->getTypeConstraintConcept());
1471 if (!ToTypeConstraintConcept)
1472 return ToTypeConstraintConcept.takeError();
1477 return std::move(Err);
1480 *ToDeducedTypeOrErr,
T->getKeyword(),
false,
1481 false, cast_or_null<ConceptDecl>(*ToTypeConstraintConcept),
1485ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
1489 if (!ToTemplateNameOrErr)
1490 return ToTemplateNameOrErr.takeError();
1491 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1492 if (!ToDeducedTypeOrErr)
1493 return ToDeducedTypeOrErr.takeError();
1499ExpectedType ASTNodeImporter::VisitInjectedClassNameType(
1503 return ToDeclOrErr.takeError();
1507 const Type *Ty = (*ToDeclOrErr)->getTypeForDecl();
1508 assert(Ty && isa<InjectedClassNameType>(Ty));
1515 return ToDeclOrErr.takeError();
1523 return ToDeclOrErr.takeError();
1529 ExpectedType ToModifiedTypeOrErr =
import(
T->getModifiedType());
1530 if (!ToModifiedTypeOrErr)
1531 return ToModifiedTypeOrErr.takeError();
1532 ExpectedType ToEquivalentTypeOrErr =
import(
T->getEquivalentType());
1533 if (!ToEquivalentTypeOrErr)
1534 return ToEquivalentTypeOrErr.takeError();
1537 *ToModifiedTypeOrErr, *ToEquivalentTypeOrErr);
1543 if (!ToWrappedTypeOrErr)
1544 return ToWrappedTypeOrErr.takeError();
1546 Error Err = Error::success();
1550 for (
auto TI :
T->dependent_decls()) {
1553 return ToDeclOrErr.takeError();
1554 CoupledDecls.emplace_back(*ToDeclOrErr, TI.isDeref());
1558 *ToWrappedTypeOrErr, CountExpr,
T->isCountInBytes(),
T->isOrNull(),
1559 ArrayRef(CoupledDecls.data(), CoupledDecls.size()));
1562ExpectedType ASTNodeImporter::VisitTemplateTypeParmType(
1566 return ToDeclOrErr.takeError();
1569 T->getDepth(),
T->getIndex(),
T->isParameterPack(), *ToDeclOrErr);
1572ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmType(
1576 return ReplacedOrErr.takeError();
1578 ExpectedType ToReplacementTypeOrErr =
import(
T->getReplacementType());
1579 if (!ToReplacementTypeOrErr)
1580 return ToReplacementTypeOrErr.takeError();
1583 *ToReplacementTypeOrErr, *ReplacedOrErr,
T->getIndex(),
1587ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmPackType(
1591 return ReplacedOrErr.takeError();
1594 if (!ToArgumentPack)
1595 return ToArgumentPack.takeError();
1598 *ReplacedOrErr,
T->getIndex(),
T->getFinal(), *ToArgumentPack);
1601ExpectedType ASTNodeImporter::VisitTemplateSpecializationType(
1603 auto ToTemplateOrErr =
import(
T->getTemplateName());
1604 if (!ToTemplateOrErr)
1605 return ToTemplateOrErr.takeError();
1610 return std::move(Err);
1617 ToCanonType = *TyOrErr;
1619 return TyOrErr.takeError();
1628 auto ToQualifierOrErr =
import(
T->getQualifier());
1629 if (!ToQualifierOrErr)
1630 return ToQualifierOrErr.takeError();
1633 if (!ToNamedTypeOrErr)
1634 return ToNamedTypeOrErr.takeError();
1637 if (!ToOwnedTagDeclOrErr)
1638 return ToOwnedTagDeclOrErr.takeError();
1643 *ToOwnedTagDeclOrErr);
1649 if (!ToPatternOrErr)
1650 return ToPatternOrErr.takeError();
1653 T->getNumExpansions(),
1657ExpectedType ASTNodeImporter::VisitDependentTemplateSpecializationType(
1659 auto ToQualifierOrErr =
import(
T->getQualifier());
1660 if (!ToQualifierOrErr)
1661 return ToQualifierOrErr.takeError();
1666 ToPack.reserve(
T->template_arguments().size());
1668 return std::move(Err);
1671 T->getKeyword(), *ToQualifierOrErr, ToName, ToPack);
1676 auto ToQualifierOrErr =
import(
T->getQualifier());
1677 if (!ToQualifierOrErr)
1678 return ToQualifierOrErr.takeError();
1687 return TyOrErr.takeError();
1699 return ToDeclOrErr.takeError();
1706 if (!ToBaseTypeOrErr)
1707 return ToBaseTypeOrErr.takeError();
1710 for (
auto TypeArg :
T->getTypeArgsAsWritten()) {
1712 TypeArgs.push_back(*TyOrErr);
1714 return TyOrErr.takeError();
1718 for (
auto *
P :
T->quals()) {
1720 Protocols.push_back(*ProtocolOrErr);
1722 return ProtocolOrErr.takeError();
1728 T->isKindOfTypeAsWritten());
1734 if (!ToPointeeTypeOrErr)
1735 return ToPointeeTypeOrErr.takeError();
1742 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1743 if (!ToUnderlyingTypeOrErr)
1744 return ToUnderlyingTypeOrErr.takeError();
1752 Error Err = Error::success();
1753 QualType ToOriginalType = importChecked(Err,
T->getOriginalType());
1754 QualType ToAdjustedType = importChecked(Err,
T->getAdjustedType());
1756 return std::move(Err);
1758 return Importer.getToContext().getAdjustedType(ToOriginalType,
1763 return Importer.getToContext().getBitIntType(
T->isUnsigned(),
1767ExpectedType clang::ASTNodeImporter::VisitBTFTagAttributedType(
1769 Error Err = Error::success();
1770 const BTFTypeTagAttr *ToBTFAttr = importChecked(Err,
T->getAttr());
1771 QualType ToWrappedType = importChecked(Err,
T->getWrappedType());
1773 return std::move(Err);
1775 return Importer.getToContext().getBTFTagAttributedType(ToBTFAttr,
1779ExpectedType clang::ASTNodeImporter::VisitConstantMatrixType(
1781 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1782 if (!ToElementTypeOrErr)
1783 return ToElementTypeOrErr.takeError();
1785 return Importer.getToContext().getConstantMatrixType(
1786 *ToElementTypeOrErr,
T->getNumRows(),
T->getNumColumns());
1789ExpectedType clang::ASTNodeImporter::VisitDependentAddressSpaceType(
1791 Error Err = Error::success();
1793 Expr *ToAddrSpaceExpr = importChecked(Err,
T->getAddrSpaceExpr());
1796 return std::move(Err);
1798 return Importer.getToContext().getDependentAddressSpaceType(
1799 ToPointeeType, ToAddrSpaceExpr, ToAttrLoc);
1802ExpectedType clang::ASTNodeImporter::VisitDependentBitIntType(
1804 ExpectedExpr ToNumBitsExprOrErr =
import(
T->getNumBitsExpr());
1805 if (!ToNumBitsExprOrErr)
1806 return ToNumBitsExprOrErr.takeError();
1807 return Importer.getToContext().getDependentBitIntType(
T->isUnsigned(),
1808 *ToNumBitsExprOrErr);
1811ExpectedType clang::ASTNodeImporter::VisitDependentSizedMatrixType(
1813 Error Err = Error::success();
1814 QualType ToElementType = importChecked(Err,
T->getElementType());
1815 Expr *ToRowExpr = importChecked(Err,
T->getRowExpr());
1816 Expr *ToColumnExpr = importChecked(Err,
T->getColumnExpr());
1819 return std::move(Err);
1821 return Importer.getToContext().getDependentSizedMatrixType(
1822 ToElementType, ToRowExpr, ToColumnExpr, ToAttrLoc);
1825ExpectedType clang::ASTNodeImporter::VisitDependentVectorType(
1827 Error Err = Error::success();
1828 QualType ToElementType = importChecked(Err,
T->getElementType());
1829 Expr *ToSizeExpr = importChecked(Err,
T->getSizeExpr());
1832 return std::move(Err);
1834 return Importer.getToContext().getDependentVectorType(
1835 ToElementType, ToSizeExpr, ToAttrLoc,
T->getVectorKind());
1838ExpectedType clang::ASTNodeImporter::VisitObjCTypeParamType(
1842 return ToDeclOrErr.takeError();
1847 if (!ToProtocolOrErr)
1848 return ToProtocolOrErr.takeError();
1849 ToProtocols.push_back(*ToProtocolOrErr);
1852 return Importer.getToContext().getObjCTypeParamType(*ToDeclOrErr,
1857 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1858 if (!ToElementTypeOrErr)
1859 return ToElementTypeOrErr.takeError();
1862 if (
T->isReadOnly())
1882 if (isa<RecordDecl>(D) && (FunDecl = dyn_cast<FunctionDecl>(OrigDC)) &&
1884 auto getLeafPointeeType = [](
const Type *
T) {
1892 getLeafPointeeType(
P->getType().getCanonicalType().getTypePtr());
1893 auto *RT = dyn_cast<RecordType>(LeafT);
1894 if (RT && RT->getDecl() == D) {
1907 if (Error Err = importInto(Name, D->
getDeclName()))
1919 return Error::success();
1926 if (Error Err = importInto(Name, D->
getDeclName()))
1938 return Error::success();
1943 return Error::success();
1946 if (Error Err = importInto(ToD, FromD))
1949 if (
RecordDecl *FromRecord = dyn_cast<RecordDecl>(FromD)) {
1950 if (
RecordDecl *ToRecord = cast<RecordDecl>(ToD)) {
1951 if (FromRecord->getDefinition() && FromRecord->isCompleteDefinition() &&
1952 !ToRecord->getDefinition()) {
1957 return Error::success();
1960 if (
EnumDecl *FromEnum = dyn_cast<EnumDecl>(FromD)) {
1961 if (
EnumDecl *ToEnum = cast<EnumDecl>(ToD)) {
1962 if (FromEnum->getDefinition() && !ToEnum->getDefinition()) {
1967 return Error::success();
1970 return Error::success();
1985 return Error::success();
1991 return ToRangeOrErr.takeError();
1992 return Error::success();
1998 return LocOrErr.takeError();
1999 return Error::success();
2007 return ToTInfoOrErr.takeError();
2008 return Error::success();
2011 llvm_unreachable(
"Unknown name kind.");
2018 return ToDCOrErr.takeError();
2032 auto MightNeedReordering = [](
const Decl *D) {
2033 return isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D) || isa<FriendDecl>(D);
2037 Error ChildErrors = Error::success();
2038 for (
auto *From : FromDC->
decls()) {
2039 if (!MightNeedReordering(From))
2048 if (!ImportedOrErr) {
2050 ImportedOrErr.takeError());
2053 FieldDecl *FieldFrom = dyn_cast_or_null<FieldDecl>(From);
2054 Decl *ImportedDecl = *ImportedOrErr;
2055 FieldDecl *FieldTo = dyn_cast_or_null<FieldDecl>(ImportedDecl);
2056 if (FieldFrom && FieldTo) {
2088 consumeError(std::move(ChildErrors));
2089 return ToDCOrErr.takeError();
2092 if (
const auto *FromRD = dyn_cast<RecordDecl>(FromDC)) {
2096 for (
auto *D : FromRD->decls()) {
2097 if (!MightNeedReordering(D))
2100 assert(D &&
"DC contains a null decl");
2103 assert(ToDC == ToD->getLexicalDeclContext() && ToDC->
containsDecl(ToD));
2115 for (
auto *From : FromDC->
decls()) {
2116 if (MightNeedReordering(From))
2122 ImportedOrErr.takeError());
2142 if (!FromRecordDecl || !ToRecordDecl) {
2146 if (RecordFrom && RecordTo) {
2147 FromRecordDecl = RecordFrom->
getDecl();
2148 ToRecordDecl = RecordTo->getDecl();
2152 if (FromRecordDecl && ToRecordDecl) {
2158 return Error::success();
2165 return ToDCOrErr.takeError();
2171 if (!ToLexicalDCOrErr)
2172 return ToLexicalDCOrErr.takeError();
2173 ToLexicalDC = *ToLexicalDCOrErr;
2177 return Error::success();
2183 "Import implicit methods to or from non-definition");
2186 if (FromM->isImplicit()) {
2189 return ToMOrErr.takeError();
2192 return Error::success();
2201 return ToTypedefOrErr.takeError();
2203 return Error::success();
2208 auto DefinitionCompleter = [To]() {
2227 auto *FromCXXRD = cast<CXXRecordDecl>(From);
2229 ToCaptures.reserve(FromCXXRD->capture_size());
2230 for (
const auto &FromCapture : FromCXXRD->captures()) {
2231 if (
auto ToCaptureOrErr =
import(FromCapture))
2232 ToCaptures.push_back(*ToCaptureOrErr);
2234 return ToCaptureOrErr.takeError();
2236 cast<CXXRecordDecl>(To)->setCaptures(Importer.
getToContext(),
2243 DefinitionCompleter();
2247 return Error::success();
2262 auto DefinitionCompleterScopeExit =
2263 llvm::make_scope_exit(DefinitionCompleter);
2269 auto *ToCXX = dyn_cast<CXXRecordDecl>(To);
2270 auto *FromCXX = dyn_cast<CXXRecordDecl>(From);
2271 if (ToCXX && FromCXX && ToCXX->dataPtr() && FromCXX->dataPtr()) {
2273 struct CXXRecordDecl::DefinitionData &ToData = ToCXX->data();
2274 struct CXXRecordDecl::DefinitionData &FromData = FromCXX->data();
2276 #define FIELD(Name, Width, Merge) \
2277 ToData.Name = FromData.Name;
2278 #include "clang/AST/CXXRecordDeclDefinitionBits.def"
2281 ToCXX->setArgPassingRestrictions(FromCXX->getArgPassingRestrictions());
2284 for (
const auto &Base1 : FromCXX->bases()) {
2287 return TyOrErr.takeError();
2290 if (Base1.isPackExpansion()) {
2291 if (
ExpectedSLoc LocOrErr =
import(Base1.getEllipsisLoc()))
2292 EllipsisLoc = *LocOrErr;
2294 return LocOrErr.takeError();
2302 auto RangeOrErr =
import(Base1.getSourceRange());
2304 return RangeOrErr.takeError();
2306 auto TSIOrErr =
import(Base1.getTypeSourceInfo());
2308 return TSIOrErr.takeError();
2314 Base1.isBaseOfClass(),
2315 Base1.getAccessSpecifierAsWritten(),
2320 ToCXX->setBases(Bases.data(), Bases.size());
2328 return Error::success();
2333 return Error::success();
2337 return Error::success();
2341 return ToInitOrErr.takeError();
2352 return Error::success();
2360 return Error::success();
2371 return ToTypeOrErr.takeError();
2374 if (!ToPromotionTypeOrErr)
2375 return ToPromotionTypeOrErr.takeError();
2386 return Error::success();
2392 for (
const auto &Arg : FromArgs) {
2393 if (
auto ToOrErr =
import(Arg))
2394 ToArgs.push_back(*ToOrErr);
2396 return ToOrErr.takeError();
2399 return Error::success();
2405 return import(From);
2408template <
typename InContainerTy>
2411 for (
const auto &FromLoc : Container) {
2412 if (
auto ToLocOrErr =
import(FromLoc))
2415 return ToLocOrErr.takeError();
2417 return Error::success();
2427 bool IgnoreTemplateParmDepth) {
2438 false, Complain,
false,
2439 IgnoreTemplateParmDepth);
2459 return std::move(Err);
2464 return LocOrErr.takeError();
2467 if (GetImportedOrCreateDecl(ToD, D, Importer.
getToContext(), DC, *LocOrErr))
2490 return std::move(Err);
2496 Name.getAsIdentifierInfo()))
2499 Error Err = Error::success();
2504 return std::move(Err);
2508 addDeclToContexts(D, ToD);
2516 return LocOrErr.takeError();
2519 return ColonLocOrErr.takeError();
2524 return DCOrErr.takeError();
2529 DC, *LocOrErr, *ColonLocOrErr))
2543 return DCOrErr.takeError();
2547 Error Err = Error::success();
2553 return std::move(Err);
2556 if (GetImportedOrCreateDecl(
2557 ToD, D, Importer.
getToContext(), DC, ToLocation, ToAssertExpr, ToMessage,
2573 return std::move(Err);
2582 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2588 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2589 for (
auto *FoundDecl : FoundDecls) {
2593 if (
auto *FoundNS = dyn_cast<NamespaceDecl>(FoundDecl)) {
2594 MergeWithNamespace = FoundNS;
2595 ConflictingDecls.clear();
2599 ConflictingDecls.push_back(FoundDecl);
2602 if (!ConflictingDecls.empty()) {
2605 ConflictingDecls.size());
2607 Name = NameOrErr.get();
2609 return NameOrErr.takeError();
2615 return BeginLocOrErr.takeError();
2617 if (!RBraceLocOrErr)
2618 return RBraceLocOrErr.takeError();
2623 if (GetImportedOrCreateDecl(ToNamespace, D, Importer.
getToContext(), DC,
2625 Name.getAsIdentifierInfo(),
2635 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2636 TU->setAnonymousNamespace(ToNamespace);
2638 cast<NamespaceDecl>(DC)->setAnonymousNamespace(ToNamespace);
2644 return std::move(Err);
2656 return std::move(Err);
2662 Error Err = Error::success();
2669 return std::move(Err);
2674 if (GetImportedOrCreateDecl(
2675 ToD, D, Importer.
getToContext(), DC, ToNamespaceLoc, ToAliasLoc,
2676 ToIdentifier, ToQualifierLoc, ToTargetNameLoc, ToNamespace))
2694 return std::move(Err);
2713 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2714 for (
auto *FoundDecl : FoundDecls) {
2717 if (
auto *FoundTypedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
2722 QualType FoundUT = FoundTypedef->getUnderlyingType();
2736 if (FromR && FoundR &&
2747 ConflictingDecls.push_back(FoundDecl);
2752 if (!ConflictingDecls.empty()) {
2754 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
2756 Name = NameOrErr.get();
2758 return NameOrErr.takeError();
2762 Error Err = Error::success();
2767 return std::move(Err);
2774 if (GetImportedOrCreateDecl<TypeAliasDecl>(
2776 Name.getAsIdentifierInfo(), ToTypeSourceInfo))
2778 }
else if (GetImportedOrCreateDecl<TypedefDecl>(
2780 Name.getAsIdentifierInfo(), ToTypeSourceInfo))
2785 return std::move(Err);
2789 Importer.AddToLookupTable(ToTypedef);
2794 TypeAliasDecl *FromAlias = IsAlias ? cast<TypeAliasDecl>(D) :
nullptr;
2817 return std::move(Err);
2827 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2828 for (
auto *FoundDecl : FoundDecls) {
2831 if (
auto *FoundAlias = dyn_cast<TypeAliasTemplateDecl>(FoundDecl)) {
2834 ConflictingDecls.push_back(FoundDecl);
2838 if (!ConflictingDecls.empty()) {
2840 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
2842 Name = NameOrErr.get();
2844 return NameOrErr.takeError();
2848 Error Err = Error::success();
2852 return std::move(Err);
2855 if (GetImportedOrCreateDecl(ToAlias, D, Importer.
getToContext(), DC,
Loc,
2856 Name, ToTemplateParameters, ToTemplatedDecl))
2859 ToTemplatedDecl->setDescribedAliasTemplate(ToAlias);
2865 updateLookupTableForTemplateParameters(*ToTemplateParameters);
2876 return std::move(Err);
2886 return BeginLocOrErr.takeError();
2887 if (GetImportedOrCreateDecl(ToLabel, D, Importer.
getToContext(), DC,
Loc,
2888 Name.getAsIdentifierInfo(), *BeginLocOrErr))
2892 if (GetImportedOrCreateDecl(ToLabel, D, Importer.
getToContext(), DC,
Loc,
2893 Name.getAsIdentifierInfo()))
2900 return ToStmtOrErr.takeError();
2902 ToLabel->
setStmt(*ToStmtOrErr);
2915 return std::move(Err);
2923 if (Error Err = importInto(
2925 return std::move(Err);
2935 Importer.findDeclsInToCtx(DC, SearchName);
2936 for (
auto *FoundDecl : FoundDecls) {
2940 if (
auto *Typedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
2941 if (
const auto *Tag = Typedef->getUnderlyingType()->getAs<
TagType>())
2942 FoundDecl = Tag->getDecl();
2945 if (
auto *FoundEnum = dyn_cast<EnumDecl>(FoundDecl)) {
2955 ConflictingDecls.push_back(FoundDecl);
2959 if (!ConflictingDecls.empty()) {
2961 SearchName, DC, IDNS, ConflictingDecls.data(),
2962 ConflictingDecls.size());
2964 Name = NameOrErr.get();
2966 return NameOrErr.takeError();
2970 Error Err = Error::success();
2976 return std::move(Err);
2980 if (GetImportedOrCreateDecl(
2982 Loc, Name.getAsIdentifierInfo(), PrevDecl, D->
isScoped(),
2991 addDeclToContexts(D, D2);
2997 D2->setInstantiationOfMemberEnum(*ToInstOrErr, SK);
2999 return ToInstOrErr.takeError();
3000 if (
ExpectedSLoc POIOrErr =
import(MemberInfo->getPointOfInstantiation()))
3003 return POIOrErr.takeError();
3009 return std::move(Err);
3015 bool IsFriendTemplate =
false;
3016 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3018 DCXX->getDescribedClassTemplate() &&
3019 DCXX->getDescribedClassTemplate()->getFriendObjectKind() !=
3029 return std::move(Err);
3037 if (Error Err = importInto(
3039 return std::move(Err);
3046 bool DependentFriend = IsFriendTemplate && IsDependentContext;
3053 Importer.findDeclsInToCtx(DC, SearchName);
3054 if (!FoundDecls.empty()) {
3061 for (
auto *FoundDecl : FoundDecls) {
3065 Decl *Found = FoundDecl;
3066 if (
auto *Typedef = dyn_cast<TypedefNameDecl>(Found)) {
3067 if (
const auto *Tag = Typedef->getUnderlyingType()->getAs<
TagType>())
3068 Found = Tag->getDecl();
3071 if (
auto *FoundRecord = dyn_cast<RecordDecl>(Found)) {
3094 if (
const auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3095 auto *FoundCXX = dyn_cast<CXXRecordDecl>(FoundDef);
3096 assert(FoundCXX &&
"Record type mismatch");
3102 return std::move(Err);
3108 ConflictingDecls.push_back(FoundDecl);
3112 if (!ConflictingDecls.empty() && SearchName) {
3114 SearchName, DC, IDNS, ConflictingDecls.data(),
3115 ConflictingDecls.size());
3117 Name = NameOrErr.get();
3119 return NameOrErr.takeError();
3125 return BeginLocOrErr.takeError();
3130 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3131 if (DCXX->isLambda()) {
3132 auto TInfoOrErr =
import(DCXX->getLambdaTypeInfo());
3134 return TInfoOrErr.takeError();
3135 if (GetImportedOrCreateSpecialDecl(
3137 DC, *TInfoOrErr,
Loc, DCXX->getLambdaDependencyKind(),
3138 DCXX->isGenericLambda(), DCXX->getLambdaCaptureDefault()))
3143 return CDeclOrErr.takeError();
3146 }
else if (DCXX->isInjectedClassName()) {
3149 const bool DelayTypeCreation =
true;
3150 if (GetImportedOrCreateDecl(
3152 *BeginLocOrErr,
Loc, Name.getAsIdentifierInfo(),
3153 cast_or_null<CXXRecordDecl>(PrevDecl), DelayTypeCreation))
3156 D2CXX, dyn_cast<CXXRecordDecl>(DC));
3158 if (GetImportedOrCreateDecl(D2CXX, D, Importer.
getToContext(),
3160 Name.getAsIdentifierInfo(),
3161 cast_or_null<CXXRecordDecl>(PrevDecl)))
3168 addDeclToContexts(D, D2);
3171 DCXX->getDescribedClassTemplate()) {
3173 if (Error Err = importInto(ToDescribed, FromDescribed))
3174 return std::move(Err);
3176 if (!DCXX->isInjectedClassName() && !IsFriendTemplate) {
3183 auto *
Record = dyn_cast<CXXRecordDecl>(Found);
3196 const Type *FrontTy =
3197 cast<CXXRecordDecl>(Redecls.front())->getTypeForDecl();
3200 InjSpec = InjTy->getInjectedSpecializationType();
3203 for (
auto *R : Redecls) {
3204 auto *RI = cast<CXXRecordDecl>(R);
3205 if (R != Redecls.front() ||
3206 !isa<InjectedClassNameType>(RI->getTypeForDecl()))
3207 RI->setTypeForDecl(
nullptr);
3222 DCXX->getMemberSpecializationInfo()) {
3224 MemberInfo->getTemplateSpecializationKind();
3230 return ToInstOrErr.takeError();
3233 import(MemberInfo->getPointOfInstantiation()))
3237 return POIOrErr.takeError();
3241 if (GetImportedOrCreateDecl(D2, D, Importer.
getToContext(),
3243 Name.getAsIdentifierInfo(), PrevDecl))
3246 addDeclToContexts(D, D2);
3252 return BraceRangeOrErr.takeError();
3256 return QualifierLocOrErr.takeError();
3263 return std::move(Err);
3275 return std::move(Err);
3284 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3285 for (
auto *FoundDecl : FoundDecls) {
3289 if (
auto *FoundEnumConstant = dyn_cast<EnumConstantDecl>(FoundDecl)) {
3291 return Importer.
MapImported(D, FoundEnumConstant);
3292 ConflictingDecls.push_back(FoundDecl);
3296 if (!ConflictingDecls.empty()) {
3298 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3300 Name = NameOrErr.get();
3302 return NameOrErr.takeError();
3308 return TypeOrErr.takeError();
3312 return InitOrErr.takeError();
3315 if (GetImportedOrCreateDecl(
3317 Name.getAsIdentifierInfo(), *TypeOrErr, *InitOrErr, D->
getInitVal()))
3318 return ToEnumerator;
3323 return ToEnumerator;
3326template <
typename DeclTy>
3329 unsigned int Num = FromD->getNumTemplateParameterLists();
3331 return Error::success();
3333 for (
unsigned int I = 0; I < Num; ++I)
3335 import(FromD->getTemplateParameterList(I)))
3336 ToTPLists[I] = *ToTPListOrErr;
3338 return ToTPListOrErr.takeError();
3339 ToD->setTemplateParameterListsInfo(Importer.ToContext, ToTPLists);
3340 return Error::success();
3348 return Error::success();
3354 return Error::success();
3360 ToFD->setInstantiationOfMemberFunction(*InstFDOrErr, TSK);
3362 return InstFDOrErr.takeError();
3368 return POIOrErr.takeError();
3370 return Error::success();
3374 auto FunctionAndArgsOrErr =
3376 if (!FunctionAndArgsOrErr)
3377 return FunctionAndArgsOrErr.takeError();
3380 Importer.
getToContext(), std::get<1>(*FunctionAndArgsOrErr));
3384 const auto *FromTAArgsAsWritten = FTSInfo->TemplateArgumentsAsWritten;
3385 if (FromTAArgsAsWritten)
3387 *FromTAArgsAsWritten, ToTAInfo))
3390 ExpectedSLoc POIOrErr =
import(FTSInfo->getPointOfInstantiation());
3392 return POIOrErr.takeError();
3398 ToFD->setFunctionTemplateSpecialization(
3399 std::get<0>(*FunctionAndArgsOrErr), ToTAList,
nullptr,
3400 TSK, FromTAArgsAsWritten ? &ToTAInfo :
nullptr, *POIOrErr);
3401 return Error::success();
3409 Candidates.
addDecl(*ToFTDOrErr);
3411 return ToFTDOrErr.takeError();
3416 const auto *FromTAArgsAsWritten = FromInfo->TemplateArgumentsAsWritten;
3417 if (FromTAArgsAsWritten)
3424 FromTAArgsAsWritten ? &ToTAInfo :
nullptr);
3425 return Error::success();
3428 llvm_unreachable(
"All cases should be covered!");
3433 auto FunctionAndArgsOrErr =
3435 if (!FunctionAndArgsOrErr)
3436 return FunctionAndArgsOrErr.takeError();
3440 std::tie(Template, ToTemplArgs) = *FunctionAndArgsOrErr;
3441 void *InsertPos =
nullptr;
3452 return ToBodyOrErr.takeError();
3454 return Error::success();
3460 const DeclContext *DCi = dyn_cast<DeclContext>(D);
3463 assert(DCi &&
"Declaration should have a context");
3477 ToProcess.push_back(S);
3478 while (!ToProcess.empty()) {
3479 const Stmt *CurrentS = ToProcess.pop_back_val();
3481 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(CurrentS)) {
3482 if (
const Decl *D = DeclRef->getDecl())
3485 }
else if (
const auto *E =
3486 dyn_cast_or_null<SubstNonTypeTemplateParmExpr>(CurrentS)) {
3487 if (
const Decl *D = E->getAssociatedDecl())
3520class IsTypeDeclaredInsideVisitor
3521 :
public TypeVisitor<IsTypeDeclaredInsideVisitor, std::optional<bool>> {
3523 IsTypeDeclaredInsideVisitor(
const FunctionDecl *ParentDC)
3524 : ParentDC(ParentDC) {}
3530 if (std::optional<bool> Res = Visit(
T.getTypePtr()))
3533 T.getSingleStepDesugaredType(ParentDC->getParentASTContext());
3535 if (std::optional<bool> Res = Visit(DsT.
getTypePtr()))
3538 DsT =
T.getSingleStepDesugaredType(ParentDC->getParentASTContext());
3543 std::optional<bool> VisitTagType(
const TagType *
T) {
3544 if (
auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(
T->getDecl()))
3545 for (
const auto &Arg : Spec->getTemplateArgs().asArray())
3546 if (checkTemplateArgument(Arg))
3551 std::optional<bool> VisitPointerType(
const PointerType *
T) {
3556 return CheckType(
T->getPointeeTypeAsWritten());
3559 std::optional<bool> VisitTypedefType(
const TypedefType *
T) {
3565 std::optional<bool> VisitUsingType(
const UsingType *
T) {
3566 if (
T->getFoundDecl() &&
3575 for (
const auto &Arg :
T->template_arguments())
3576 if (checkTemplateArgument(Arg))
3594 return CheckType(
T->getElementType());
3599 "Variable array should not occur in deduced return type of a function");
3603 llvm_unreachable(
"Incomplete array should not occur in deduced return type "
3608 llvm_unreachable(
"Dependent array should not occur in deduced return type "
3635 if (checkTemplateArgument(PackArg))
3647 llvm_unreachable(
"Unknown TemplateArgument::ArgKind enum");
3657 assert(FromFPT &&
"Must be called on FunctionProtoType");
3659 auto IsCXX11LambdaWithouTrailingReturn = [&]() {
3660 if (Importer.FromContext.
getLangOpts().CPlusPlus14)
3663 if (FromFPT->hasTrailingReturn())
3666 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D))
3667 return cast<CXXRecordDecl>(MD->getDeclContext())->isLambda();
3672 QualType RetT = FromFPT->getReturnType();
3673 if (isa<AutoType>(RetT.
getTypePtr()) || IsCXX11LambdaWithouTrailingReturn()) {
3675 IsTypeDeclaredInsideVisitor Visitor(Def ? Def : D);
3676 return Visitor.CheckType(RetT);
3693 auto RedeclIt = Redecls.begin();
3696 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
3699 return ToRedeclOrErr.takeError();
3701 assert(*RedeclIt == D);
3709 return std::move(Err);
3724 if (!FoundFunctionOrErr)
3725 return FoundFunctionOrErr.takeError();
3726 if (
FunctionDecl *FoundFunction = *FoundFunctionOrErr) {
3727 if (
Decl *Def = FindAndMapDefinition(D, FoundFunction))
3729 FoundByLookup = FoundFunction;
3737 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3738 for (
auto *FoundDecl : FoundDecls) {
3742 if (
auto *FoundFunction = dyn_cast<FunctionDecl>(FoundDecl)) {
3747 if (
Decl *Def = FindAndMapDefinition(D, FoundFunction))
3749 FoundByLookup = FoundFunction;
3760 Importer.
ToDiag(
Loc, diag::warn_odr_function_type_inconsistent)
3761 << Name << D->
getType() << FoundFunction->getType();
3762 Importer.
ToDiag(FoundFunction->getLocation(), diag::note_odr_value_here)
3763 << FoundFunction->getType();
3764 ConflictingDecls.push_back(FoundDecl);
3768 if (!ConflictingDecls.empty()) {
3770 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3772 Name = NameOrErr.get();
3774 return NameOrErr.takeError();
3784 if (FoundByLookup) {
3785 if (isa<CXXMethodDecl>(FoundByLookup)) {
3794 "Templated function mapped to non-templated?");
3810 return std::move(Err);
3821 bool UsedDifferentProtoType =
false;
3823 QualType FromReturnTy = FromFPT->getReturnType();
3831 UsedDifferentProtoType =
true;
3842 FromEPI = DefaultEPI;
3843 UsedDifferentProtoType =
true;
3846 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
3851 Error Err = Error::success();
3858 auto TrailingRequiresClause =
3861 return std::move(Err);
3867 Parameters.push_back(*ToPOrErr);
3869 return ToPOrErr.takeError();
3874 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
3876 importExplicitSpecifier(Err, FromConstructor->getExplicitSpecifier());
3878 return std::move(Err);
3880 if (FromConstructor->isInheritingConstructor()) {
3882 import(FromConstructor->getInheritedConstructor());
3883 if (!ImportedInheritedCtor)
3884 return ImportedInheritedCtor.takeError();
3885 ToInheritedConstructor = *ImportedInheritedCtor;
3887 if (GetImportedOrCreateDecl<CXXConstructorDecl>(
3888 ToFunction, D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3889 ToInnerLocStart, NameInfo,
T, TInfo, ESpec, D->
UsesFPIntrin(),
3891 ToInheritedConstructor, TrailingRequiresClause))
3895 Error Err = Error::success();
3897 Err,
const_cast<FunctionDecl *
>(FromDtor->getOperatorDelete()));
3898 auto ToThisArg =
importChecked(Err, FromDtor->getOperatorDeleteThisArg());
3900 return std::move(Err);
3902 if (GetImportedOrCreateDecl<CXXDestructorDecl>(
3903 ToFunction, D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3906 TrailingRequiresClause))
3913 dyn_cast<CXXConversionDecl>(D)) {
3915 importExplicitSpecifier(Err, FromConversion->getExplicitSpecifier());
3917 return std::move(Err);
3918 if (GetImportedOrCreateDecl<CXXConversionDecl>(
3919 ToFunction, D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3924 }
else if (
auto *Method = dyn_cast<CXXMethodDecl>(D)) {
3925 if (GetImportedOrCreateDecl<CXXMethodDecl>(
3926 ToFunction, D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3927 ToInnerLocStart, NameInfo,
T, TInfo, Method->getStorageClass(),
3928 Method->UsesFPIntrin(), Method->isInlineSpecified(),
3931 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(D)) {
3933 importExplicitSpecifier(Err, Guide->getExplicitSpecifier());
3937 return std::move(Err);
3938 if (GetImportedOrCreateDecl<CXXDeductionGuideDecl>(
3939 ToFunction, D, Importer.
getToContext(), DC, ToInnerLocStart, ESpec,
3940 NameInfo,
T, TInfo, ToEndLoc, Ctor))
3942 cast<CXXDeductionGuideDecl>(ToFunction)
3943 ->setDeductionCandidateKind(Guide->getDeductionCandidateKind());
3945 if (GetImportedOrCreateDecl(
3946 ToFunction, D, Importer.
getToContext(), DC, ToInnerLocStart,
3954 if (FoundByLookup) {
3967 auto Imported =
import(Msg);
3969 return Imported.takeError();
3993 for (
auto *Param : Parameters) {
3994 Param->setOwningFunction(ToFunction);
3999 ToFunction->setParams(Parameters);
4006 for (
unsigned I = 0, N = Parameters.size(); I != N; ++I)
4007 ProtoLoc.setParam(I, Parameters[I]);
4013 auto ToFTOrErr =
import(FromFT);
4015 return ToFTOrErr.takeError();
4019 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
4020 if (
unsigned NumInitializers = FromConstructor->getNumCtorInitializers()) {
4024 FromConstructor->inits(), CtorInitializers))
4025 return std::move(Err);
4028 std::copy(CtorInitializers.begin(), CtorInitializers.end(), Memory);
4029 auto *ToCtor = cast<CXXConstructorDecl>(ToFunction);
4030 ToCtor->setCtorInitializers(Memory);
4031 ToCtor->setNumCtorInitializers(NumInitializers);
4037 return std::move(Err);
4039 if (
auto *FromCXXMethod = dyn_cast<CXXMethodDecl>(D))
4042 return std::move(Err);
4048 return std::move(Err);
4052 if (UsedDifferentProtoType) {
4054 ToFunction->
setType(*TyOrErr);
4056 return TyOrErr.takeError();
4060 return TSIOrErr.takeError();
4065 addDeclToContexts(D, ToFunction);
4068 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4071 return ToRedeclOrErr.takeError();
4105 return std::move(Err);
4110 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4111 for (
auto *FoundDecl : FoundDecls) {
4112 if (
FieldDecl *FoundField = dyn_cast<FieldDecl>(FoundDecl)) {
4120 FoundField->getType())) {
4129 if (
ExpectedExpr ToInitializerOrErr =
import(FromInitializer)) {
4132 assert(FoundField->hasInClassInitializer() &&
4133 "Field should have an in-class initializer if it has an "
4134 "expression for it.");
4135 if (!FoundField->getInClassInitializer())
4136 FoundField->setInClassInitializer(*ToInitializerOrErr);
4138 return ToInitializerOrErr.takeError();
4145 Importer.
ToDiag(
Loc, diag::warn_odr_field_type_inconsistent)
4146 << Name << D->
getType() << FoundField->getType();
4147 Importer.
ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4148 << FoundField->getType();
4154 Error Err = Error::success();
4160 return std::move(Err);
4161 const Type *ToCapturedVLAType =
nullptr;
4164 return std::move(Err);
4167 if (GetImportedOrCreateDecl(ToField, D, Importer.
getToContext(), DC,
4168 ToInnerLocStart,
Loc, Name.getAsIdentifierInfo(),
4169 ToType, ToTInfo, ToBitWidth, D->
isMutable(),
4176 Err = Importer.ImportAttrs(ToField, D);
4178 return std::move(Err);
4182 if (ToCapturedVLAType)
4189 return std::move(Err);
4190 if (ToInitializer) {
4192 if (AlreadyImported)
4193 assert(ToInitializer == AlreadyImported &&
4194 "Duplicate import of in-class initializer.");
4209 return std::move(Err);
4214 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4215 for (
unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
4216 if (
auto *FoundField = dyn_cast<IndirectFieldDecl>(FoundDecls[I])) {
4224 FoundField->getType(),
4231 if (!Name && I < N-1)
4235 Importer.
ToDiag(
Loc, diag::warn_odr_field_type_inconsistent)
4236 << Name << D->
getType() << FoundField->getType();
4237 Importer.
ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4238 << FoundField->getType();
4245 auto TypeOrErr =
import(D->
getType());
4247 return TypeOrErr.takeError();
4253 for (
auto *PI : D->
chain())
4255 NamedChain[i++] = *ToD;
4257 return ToD.takeError();
4261 if (GetImportedOrCreateDecl(ToIndirectField, D, Importer.
getToContext(), DC,
4262 Loc, Name.getAsIdentifierInfo(), *TypeOrErr, CH))
4264 return ToIndirectField;
4269 return ToIndirectField;
4299 unsigned int FriendCount = 0;
4300 std::optional<unsigned int> FriendPosition;
4303 for (
FriendDecl *FoundFriend : RD->friends()) {
4304 if (FoundFriend == FD) {
4305 FriendPosition = FriendCount;
4312 assert(FriendPosition &&
"Friend decl not found in own parent.");
4314 return {FriendCount, *FriendPosition};
4321 return std::move(Err);
4326 const auto *RD = cast<CXXRecordDecl>(DC);
4328 for (
FriendDecl *ImportedFriend : RD->friends())
4330 ImportedEquivalentFriends.push_back(ImportedFriend);
4335 assert(ImportedEquivalentFriends.size() <= CountAndPosition.
TotalCount &&
4336 "Class with non-matching friends is imported, ODR check wrong?");
4337 if (ImportedEquivalentFriends.size() == CountAndPosition.
TotalCount)
4339 D, ImportedEquivalentFriends[CountAndPosition.
IndexOfDecl]);
4346 if (Error Err = importInto(ToFriendD, FriendD))
4347 return std::move(Err);
4358 return TSIOrErr.takeError();
4363 for (
unsigned I = 0; I < D->NumTPLists; I++) {
4364 if (
auto ListOrErr =
import(FromTPLists[I]))
4365 ToTPLists[I] = *ListOrErr;
4367 return ListOrErr.takeError();
4372 return LocationOrErr.takeError();
4374 if (!FriendLocOrErr)
4375 return FriendLocOrErr.takeError();
4378 if (GetImportedOrCreateDecl(FrD, D, Importer.
getToContext(), DC,
4379 *LocationOrErr, ToFU,
4380 *FriendLocOrErr, ToTPLists))
4396 return std::move(Err);
4401 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4402 for (
auto *FoundDecl : FoundDecls) {
4403 if (
ObjCIvarDecl *FoundIvar = dyn_cast<ObjCIvarDecl>(FoundDecl)) {
4405 FoundIvar->getType())) {
4410 Importer.
ToDiag(
Loc, diag::warn_odr_ivar_type_inconsistent)
4411 << Name << D->
getType() << FoundIvar->getType();
4412 Importer.
ToDiag(FoundIvar->getLocation(), diag::note_odr_value_here)
4413 << FoundIvar->getType();
4419 Error Err = Error::success();
4425 return std::move(Err);
4428 if (GetImportedOrCreateDecl(
4429 ToIvar, D, Importer.
getToContext(), cast<ObjCContainerDecl>(DC),
4430 ToInnerLocStart,
Loc, Name.getAsIdentifierInfo(),
4431 ToType, ToTypeSourceInfo,
4443 auto RedeclIt = Redecls.begin();
4446 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
4449 return RedeclOrErr.takeError();
4451 assert(*RedeclIt == D);
4459 return std::move(Err);
4465 VarDecl *FoundByLookup =
nullptr;
4469 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4470 for (
auto *FoundDecl : FoundDecls) {
4474 if (
auto *FoundVar = dyn_cast<VarDecl>(FoundDecl)) {
4478 FoundVar->getType())) {
4490 const VarDecl *FoundDInit =
nullptr;
4491 if (D->
getInit() && FoundVar->getAnyInitializer(FoundDInit))
4495 FoundByLookup = FoundVar;
4503 if (FoundArray && TArray) {
4504 if (isa<IncompleteArrayType>(FoundArray) &&
4505 isa<ConstantArrayType>(TArray)) {
4507 if (
auto TyOrErr =
import(D->
getType()))
4508 FoundVar->setType(*TyOrErr);
4510 return TyOrErr.takeError();
4512 FoundByLookup = FoundVar;
4514 }
else if (isa<IncompleteArrayType>(TArray) &&
4515 isa<ConstantArrayType>(FoundArray)) {
4516 FoundByLookup = FoundVar;
4521 Importer.
ToDiag(
Loc, diag::warn_odr_variable_type_inconsistent)
4522 << Name << D->
getType() << FoundVar->getType();
4523 Importer.
ToDiag(FoundVar->getLocation(), diag::note_odr_value_here)
4524 << FoundVar->getType();
4525 ConflictingDecls.push_back(FoundDecl);
4529 if (!ConflictingDecls.empty()) {
4531 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
4533 Name = NameOrErr.get();
4535 return NameOrErr.takeError();
4539 Error Err = Error::success();
4545 return std::move(Err);
4548 if (
auto *FromDecomp = dyn_cast<DecompositionDecl>(D)) {
4552 return std::move(Err);
4554 if (GetImportedOrCreateDecl(
4555 ToDecomp, FromDecomp, Importer.
getToContext(), DC, ToInnerLocStart,
4561 if (GetImportedOrCreateDecl(ToVar, D, Importer.
getToContext(), DC,
4562 ToInnerLocStart,
Loc,
4563 Name.getAsIdentifierInfo(), ToType,
4577 if (FoundByLookup) {
4586 return ToVTOrErr.takeError();
4593 return ToInstOrErr.takeError();
4594 if (
ExpectedSLoc POIOrErr =
import(MSI->getPointOfInstantiation()))
4597 return POIOrErr.takeError();
4601 return std::move(Err);
4606 addDeclToContexts(D, ToVar);
4609 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4612 return RedeclOrErr.takeError();
4623 Error Err = Error::success();
4628 return std::move(Err);
4632 if (GetImportedOrCreateDecl(ToParm, D, Importer.
getToContext(), DC,
4633 ToLocation, ToDeclName.getAsIdentifierInfo(),
4650 return ToDefArgOrErr.takeError();
4654 if (
auto ToDefArgOrErr =
import(FromParam->
getDefaultArg()))
4657 return ToDefArgOrErr.takeError();
4660 return Error::success();
4665 Error Err = Error::success();
4670 return std::move(Err);
4679 Error Err = Error::success();
4686 return std::move(Err);
4689 if (GetImportedOrCreateDecl(ToParm, D, Importer.
getToContext(), DC,
4690 ToInnerLocStart, ToLocation,
4691 ToDeclName.getAsIdentifierInfo(), ToType,
4700 return std::move(Err);
4720 return std::move(Err);
4724 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4725 for (
auto *FoundDecl : FoundDecls) {
4726 if (
auto *FoundMethod = dyn_cast<ObjCMethodDecl>(FoundDecl)) {
4732 FoundMethod->getReturnType())) {
4733 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_result_type_inconsistent)
4735 << FoundMethod->getReturnType();
4736 Importer.
ToDiag(FoundMethod->getLocation(),
4737 diag::note_odr_objc_method_here)
4744 if (D->
param_size() != FoundMethod->param_size()) {
4745 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_num_params_inconsistent)
4747 << D->
param_size() << FoundMethod->param_size();
4748 Importer.
ToDiag(FoundMethod->getLocation(),
4749 diag::note_odr_objc_method_here)
4757 PEnd = D->
param_end(), FoundP = FoundMethod->param_begin();
4758 P != PEnd; ++
P, ++FoundP) {
4760 (*FoundP)->getType())) {
4761 Importer.
FromDiag((*P)->getLocation(),
4762 diag::warn_odr_objc_method_param_type_inconsistent)
4764 << (*P)->getType() << (*FoundP)->getType();
4765 Importer.
ToDiag((*FoundP)->getLocation(), diag::note_odr_value_here)
4766 << (*FoundP)->getType();
4774 if (D->
isVariadic() != FoundMethod->isVariadic()) {
4775 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_variadic_inconsistent)
4777 Importer.
ToDiag(FoundMethod->getLocation(),
4778 diag::note_odr_objc_method_here)
4789 Error Err = Error::success();
4792 auto ToReturnTypeSourceInfo =
4795 return std::move(Err);
4798 if (GetImportedOrCreateDecl(
4800 Name.getObjCSelector(), ToReturnType, ToReturnTypeSourceInfo, DC,
4813 ToParams.push_back(*ToPOrErr);
4815 return ToPOrErr.takeError();
4819 for (
auto *ToParam : ToParams) {
4820 ToParam->setOwningFunction(ToMethod);
4828 return std::move(Err);
4852 return std::move(Err);
4856 Error Err = Error::success();
4862 return std::move(Err);
4865 if (GetImportedOrCreateDecl(
4868 ToLocation, Name.getAsIdentifierInfo(),
4869 ToColonLoc, ToTypeSourceInfo))
4875 return std::move(Err);
4876 Result->setTypeForDecl(ToTypeForDecl);
4877 Result->setLexicalDeclContext(LexicalDC);
4888 return std::move(Err);
4894 return std::move(Err);
4902 Error Err = Error::success();
4908 return std::move(Err);
4910 if (GetImportedOrCreateDecl(ToCategory, D, Importer.
getToContext(), DC,
4913 Name.getAsIdentifierInfo(), ToInterface,
4926 return PListOrErr.takeError();
4935 FromProto != FromProtoEnd;
4936 ++FromProto, ++FromProtoLoc) {
4938 Protocols.push_back(*ToProtoOrErr);
4940 return ToProtoOrErr.takeError();
4942 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
4943 ProtocolLocs.push_back(*ToProtoLocOrErr);
4945 return ToProtoLocOrErr.takeError();
4958 return std::move(Err);
4966 return ToImplOrErr.takeError();
4978 return Error::success();
4991 FromProto != FromProtoEnd;
4992 ++FromProto, ++FromProtoLoc) {
4994 Protocols.push_back(*ToProtoOrErr);
4996 return ToProtoOrErr.takeError();
4998 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
4999 ProtocolLocs.push_back(*ToProtoLocOrErr);
5001 return ToProtoLocOrErr.takeError();
5014 return Error::success();
5024 return Importer.
MapImported(D, *ImportedDefOrErr);
5026 return ImportedDefOrErr.takeError();
5035 return std::move(Err);
5040 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5041 for (
auto *FoundDecl : FoundDecls) {
5045 if ((MergeWithProtocol = dyn_cast<ObjCProtocolDecl>(FoundDecl)))
5052 if (!ToAtBeginLocOrErr)
5053 return ToAtBeginLocOrErr.takeError();
5055 if (GetImportedOrCreateDecl(ToProto, D, Importer.
getToContext(), DC,
5056 Name.getAsIdentifierInfo(),
Loc,
5068 return std::move(Err);
5076 return std::move(Err);
5079 if (!ExternLocOrErr)
5080 return ExternLocOrErr.takeError();
5084 return LangLocOrErr.takeError();
5089 if (GetImportedOrCreateDecl(ToLinkageSpec, D, Importer.
getToContext(), DC,
5090 *ExternLocOrErr, *LangLocOrErr,
5092 return ToLinkageSpec;
5096 if (!RBraceLocOrErr)
5097 return RBraceLocOrErr.takeError();
5104 return ToLinkageSpec;
5115 return ToShadowOrErr.takeError();
5126 return std::move(Err);
5130 Error Err = Error::success();
5135 return std::move(Err);
5139 return std::move(Err);
5142 if (GetImportedOrCreateDecl(ToUsing, D, Importer.
getToContext(), DC,
5143 ToUsingLoc, ToQualifierLoc, NameInfo,
5154 ToUsing, *ToPatternOrErr);
5156 return ToPatternOrErr.takeError();
5168 return std::move(Err);
5172 Error Err = Error::success();
5178 return std::move(Err);
5181 if (GetImportedOrCreateDecl(ToUsingEnum, D, Importer.
getToContext(), DC,
5182 ToUsingLoc, ToEnumLoc, ToNameLoc, ToEnumType))
5194 return ToPatternOrErr.takeError();
5206 return std::move(Err);
5211 if (!ToIntroducerOrErr)
5212 return ToIntroducerOrErr.takeError();
5216 return ToTargetOrErr.takeError();
5219 if (
auto *FromConstructorUsingShadow =
5220 dyn_cast<ConstructorUsingShadowDecl>(D)) {
5221 Error Err = Error::success();
5223 Err, FromConstructorUsingShadow->getNominatedBaseClassShadowDecl());
5225 return std::move(Err);
5231 if (GetImportedOrCreateDecl<ConstructorUsingShadowDecl>(
5233 cast<UsingDecl>(*ToIntroducerOrErr),
5234 Nominated ? Nominated : *ToTargetOrErr,
5235 FromConstructorUsingShadow->constructsVirtualBase()))
5238 if (GetImportedOrCreateDecl(ToShadow, D, Importer.
getToContext(), DC,
Loc,
5239 Name, *ToIntroducerOrErr, *ToTargetOrErr))
5250 ToShadow, *ToPatternOrErr);
5254 return ToPatternOrErr.takeError();
5268 return std::move(Err);
5273 if (!ToComAncestorOrErr)
5274 return ToComAncestorOrErr.takeError();
5276 Error Err = Error::success();
5279 auto ToNamespaceKeyLocation =
5284 return std::move(Err);
5287 if (GetImportedOrCreateDecl(ToUsingDir, D, Importer.
getToContext(), DC,
5289 ToNamespaceKeyLocation,
5292 ToNominatedNamespace, *ToComAncestorOrErr))
5307 return std::move(Err);
5311 auto ToInstantiatedFromUsingOrErr =
5313 if (!ToInstantiatedFromUsingOrErr)
5314 return ToInstantiatedFromUsingOrErr.takeError();
5317 return std::move(Err);
5320 if (GetImportedOrCreateDecl(ToUsingPack, D, Importer.
getToContext(), DC,
5321 cast<NamedDecl>(*ToInstantiatedFromUsingOrErr),
5325 addDeclToContexts(D, ToUsingPack);
5337 return std::move(Err);
5341 Error Err = Error::success();
5347 return std::move(Err);
5351 return std::move(Err);
5354 if (GetImportedOrCreateDecl(ToUsingValue, D, Importer.
getToContext(), DC,
5355 ToUsingLoc, ToQualifierLoc, NameInfo,
5357 return ToUsingValue;
5363 return ToUsingValue;
5373 return std::move(Err);
5377 Error Err = Error::success();
5383 return std::move(Err);
5386 if (GetImportedOrCreateDecl(ToUsing, D, Importer.
getToContext(), DC,
5387 ToUsingLoc, ToTypenameLoc,
5388 ToQualifierLoc,
Loc, Name, ToEllipsisLoc))
5399 Decl* ToD =
nullptr;
5408 assert(ToD &&
"BuiltinTemplateDecl of unsupported kind!");
5419 if (
auto FromSuperOrErr =
import(FromSuper))
5420 FromSuper = *FromSuperOrErr;
5422 return FromSuperOrErr.takeError();
5426 if ((
bool)FromSuper != (
bool)ToSuper ||
5429 diag::warn_odr_objc_superclass_inconsistent)
5436 diag::note_odr_objc_missing_superclass);
5439 diag::note_odr_objc_superclass)
5443 diag::note_odr_objc_missing_superclass);
5449 return Error::success();
5460 return SuperTInfoOrErr.takeError();
5471 FromProto != FromProtoEnd;
5472 ++FromProto, ++FromProtoLoc) {
5474 Protocols.push_back(*ToProtoOrErr);
5476 return ToProtoOrErr.takeError();
5478 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5479 ProtocolLocs.push_back(*ToProtoLocOrErr);
5481 return ToProtoLocOrErr.takeError();
5492 auto ToCatOrErr =
import(Cat);
5494 return ToCatOrErr.takeError();
5503 return ToImplOrErr.takeError();
5510 return Error::success();
5519 for (
auto *fromTypeParam : *list) {
5520 if (
auto toTypeParamOrErr =
import(fromTypeParam))
5521 toTypeParams.push_back(*toTypeParamOrErr);
5523 return toTypeParamOrErr.takeError();
5527 if (!LAngleLocOrErr)
5528 return LAngleLocOrErr.takeError();
5531 if (!RAngleLocOrErr)
5532 return RAngleLocOrErr.takeError();
5547 return Importer.
MapImported(D, *ImportedDefOrErr);
5549 return ImportedDefOrErr.takeError();
5558 return std::move(Err);
5564 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5565 for (
auto *FoundDecl : FoundDecls) {
5569 if ((MergeWithIface = dyn_cast<ObjCInterfaceDecl>(FoundDecl)))
5577 if (!AtBeginLocOrErr)
5578 return AtBeginLocOrErr.takeError();
5580 if (GetImportedOrCreateDecl(
5582 *AtBeginLocOrErr, Name.getAsIdentifierInfo(),
5592 if (
auto ToPListOrErr =
5596 return ToPListOrErr.takeError();
5600 return std::move(Err);
5609 return std::move(Err);
5615 return std::move(Err);
5617 Error Err = Error::success();
5622 return std::move(Err);
5624 if (GetImportedOrCreateDecl(
5627 ToLocation, ToAtStartLoc, ToCategoryNameLoc))
5632 Category->setImplementation(ToImpl);
5637 return std::move(Err);
5647 return std::move(Err);
5652 return std::move(Err);
5660 return std::move(Err);
5662 Error Err = Error::success();
5669 return std::move(Err);
5671 if (GetImportedOrCreateDecl(Impl, D, Importer.
getToContext(),
5695 diag::warn_odr_objc_superclass_inconsistent)
5701 diag::note_odr_objc_superclass)
5705 diag::note_odr_objc_missing_superclass);
5708 diag::note_odr_objc_superclass)
5712 diag::note_odr_objc_missing_superclass);
5720 return std::move(Err);
5732 return std::move(Err);
5737 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5738 for (
auto *FoundDecl : FoundDecls) {
5739 if (
auto *FoundProp = dyn_cast<ObjCPropertyDecl>(FoundDecl)) {
5747 FoundProp->getType())) {
5748 Importer.
ToDiag(
Loc, diag::warn_odr_objc_property_type_inconsistent)
5749 << Name << D->
getType() << FoundProp->getType();
5750 Importer.
ToDiag(FoundProp->getLocation(), diag::note_odr_value_here)
5751 << FoundProp->getType();
5764 Error Err = Error::success();
5770 return std::move(Err);
5774 if (GetImportedOrCreateDecl(
5776 Name.getAsIdentifierInfo(), ToAtLoc,
5777 ToLParenLoc, ToType,
5789 return std::move(Err);
5809 return std::move(Err);
5813 return std::move(Err);
5815 auto *InImpl = cast<ObjCImplDecl>(LexicalDC);
5820 return std::move(Err);
5823 = InImpl->FindPropertyImplDecl(
Property->getIdentifier(),
5827 Error Err = Error::success();
5830 auto ToPropertyIvarDeclLoc =
5833 return std::move(Err);
5835 if (GetImportedOrCreateDecl(ToImpl, D, Importer.
getToContext(), DC,
5839 ToPropertyIvarDeclLoc))
5849 diag::warn_odr_objc_property_impl_kind_inconsistent)
5854 diag::note_odr_objc_property_impl_kind)
5865 diag::warn_odr_objc_synthesize_ivar_inconsistent)
5870 diag::note_odr_objc_synthesize_ivar_here)
5891 return BeginLocOrErr.takeError();
5895 return LocationOrErr.takeError();
5898 if (GetImportedOrCreateDecl(
5901 *BeginLocOrErr, *LocationOrErr,
5910 Error Err = Error::success();
5911 auto ToConceptRef =
importChecked(Err, TC->getConceptReference());
5912 auto ToIDC =
importChecked(Err, TC->getImmediatelyDeclaredConstraint());
5914 return std::move(Err);
5922 if (!ToDefaultArgOrErr)
5923 return ToDefaultArgOrErr.takeError();
5933 Error Err = Error::success();
5940 return std::move(Err);
5943 if (GetImportedOrCreateDecl(ToD, D, Importer.
getToContext(),
5945 ToInnerLocStart, ToLocation, D->
getDepth(),
5947 ToDeclName.getAsIdentifierInfo(), ToType,
5953 if (!ToDefaultArgOrErr)
5954 return ToDefaultArgOrErr.takeError();
5966 return NameOrErr.takeError();
5971 return LocationOrErr.takeError();
5975 if (!TemplateParamsOrErr)
5976 return TemplateParamsOrErr.takeError();
5979 if (GetImportedOrCreateDecl(
5984 *TemplateParamsOrErr))
5990 if (!ToDefaultArgOrErr)
5991 return ToDefaultArgOrErr.takeError();
6001 assert(D->getTemplatedDecl() &&
"Should be called on templates only");
6002 auto *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();
6003 if (!ToTemplatedDef)
6005 auto *TemplateWithDef = ToTemplatedDef->getDescribedTemplate();
6006 return cast_or_null<T>(TemplateWithDef);
6017 return std::move(Err);
6031 bool DependentFriend = IsDependentFriend(D);
6038 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6039 for (
auto *FoundDecl : FoundDecls) {
6044 Decl *Found = FoundDecl;
6045 auto *FoundTemplate = dyn_cast<ClassTemplateDecl>(Found);
6046 if (FoundTemplate) {
6051 bool IgnoreTemplateParmDepth =
6055 IgnoreTemplateParmDepth)) {
6056 if (DependentFriend || IsDependentFriend(FoundTemplate))
6064 FoundByLookup = FoundTemplate;
6069 ConflictingDecls.push_back(FoundDecl);
6073 if (!ConflictingDecls.empty()) {
6076 ConflictingDecls.size());
6078 Name = NameOrErr.get();
6080 return NameOrErr.takeError();
6087 if (!TemplateParamsOrErr)
6088 return TemplateParamsOrErr.takeError();
6092 if (Error Err = importInto(ToTemplated, FromTemplated))
6093 return std::move(Err);
6097 if (GetImportedOrCreateDecl(D2, D, Importer.
getToContext(), DC,
Loc, Name,
6098 *TemplateParamsOrErr, ToTemplated))
6106 addDeclToContexts(D, D2);
6107 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6109 if (FoundByLookup) {
6123 "Found decl must have its templated decl set");
6126 if (ToTemplated != PrevTemplated)
6140 return std::move(Err);
6145 return std::move(Err);
6151 return std::move(Err);
6154 void *InsertPos =
nullptr;
6157 dyn_cast<ClassTemplatePartialSpecializationDecl>(D);
6165 return ToTPListOrErr.takeError();
6166 ToTPList = *ToTPListOrErr;
6180 for (
auto *FromField : D->
fields()) {
6181 auto ToOrErr =
import(FromField);
6183 return ToOrErr.takeError();
6189 auto ToOrErr =
import(FromM);
6191 return ToOrErr.takeError();
6199 return PrevDefinition;
6210 return BeginLocOrErr.takeError();
6213 return IdLocOrErr.takeError();
6219 return std::move(Err);
6226 if (Error Err = importInto(
6228 return std::move(Err);
6231 if (GetImportedOrCreateDecl<ClassTemplatePartialSpecializationDecl>(
6233 *IdLocOrErr, ToTPList, ClassTemplate,
6236 cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl)))
6241 auto *PartSpec2 = cast<ClassTemplatePartialSpecializationDecl>(D2);
6248 PartSpec2->setInstantiatedFromMember(*ToInstOrErr);
6250 return ToInstOrErr.takeError();
6252 updateLookupTableForTemplateParameters(*ToTPList);
6254 if (GetImportedOrCreateDecl(
6256 *BeginLocOrErr, *IdLocOrErr, ClassTemplate, TemplateArgs,
6280 return BraceRangeOrErr.takeError();
6283 return std::move(Err);
6289 return LocOrErr.takeError();
6297 return LocOrErr.takeError();
6302 return LocOrErr.takeError();
6308 return POIOrErr.takeError();
6315 if (
auto CTDorErr =
import(CTD))
6318 auto *CTPSD = cast<ClassTemplatePartialSpecializationDecl *>(
P);
6319 auto CTPSDOrErr =
import(CTPSD);
6321 return CTPSDOrErr.takeError();
6324 for (
unsigned I = 0; I < DArgs.
size(); ++I) {
6326 if (
auto ArgOrErr =
import(DArg))
6327 D2ArgsVec[I] = *ArgOrErr;
6329 return ArgOrErr.takeError();
6339 return std::move(Err);
6351 return std::move(Err);
6357 "Variable templates cannot be declared at function scope");
6360 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6362 for (
auto *FoundDecl : FoundDecls) {
6366 if (
VarTemplateDecl *FoundTemplate = dyn_cast<VarTemplateDecl>(FoundDecl)) {
6376 assert(FoundTemplate->getDeclContext()->isRecord() &&
6377 "Member variable template imported as non-member, "
6378 "inconsistent imported AST?");
6387 FoundByLookup = FoundTemplate;
6390 ConflictingDecls.push_back(FoundDecl);
6394 if (!ConflictingDecls.empty()) {
6397 ConflictingDecls.size());
6399 Name = NameOrErr.get();
6401 return NameOrErr.takeError();
6410 return TypeOrErr.takeError();
6414 if (Error Err = importInto(ToTemplated, DTemplated))
6415 return std::move(Err);
6419 if (!TemplateParamsOrErr)
6420 return TemplateParamsOrErr.takeError();
6423 if (GetImportedOrCreateDecl(ToVarTD, D, Importer.
getToContext(), DC,
Loc,
6424 Name, *TemplateParamsOrErr, ToTemplated))
6433 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6435 if (FoundByLookup) {
6439 auto *PrevTemplated =
6441 if (ToTemplated != PrevTemplated)
6456 auto RedeclIt = Redecls.begin();
6459 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
6462 return RedeclOrErr.takeError();
6464 assert(*RedeclIt == D);
6468 return std::move(Err);
6473 return std::move(Err);
6478 return BeginLocOrErr.takeError();
6482 return IdLocOrErr.takeError();
6488 return std::move(Err);
6491 void *InsertPos =
nullptr;
6494 if (FoundSpecialization) {
6502 "Member variable template specialization imported as non-member, "
6503 "inconsistent imported AST?");
6507 return Importer.
MapImported(D, FoundSpecialization);
6524 return std::move(Err);
6529 if (
auto *FromPartial = dyn_cast<PartVarSpecDecl>(D)) {
6530 auto ToTPListOrErr =
import(FromPartial->getTemplateParameters());
6532 return ToTPListOrErr.takeError();
6534 PartVarSpecDecl *ToPartial;
6535 if (GetImportedOrCreateDecl(ToPartial, D, Importer.
getToContext(), DC,
6536 *BeginLocOrErr, *IdLocOrErr, *ToTPListOrErr,
6542 import(FromPartial->getInstantiatedFromMember()))
6545 return ToInstOrErr.takeError();
6547 if (FromPartial->isMemberSpecialization())
6548 ToPartial->setMemberSpecialization();
6556 if (GetImportedOrCreateDecl(D2, D, Importer.
getToContext(), DC,
6557 *BeginLocOrErr, *IdLocOrErr, VarTemplate,
6564 if (Error Err = importInto(
T, D->
getType()))
6565 return std::move(Err);
6570 return TInfoOrErr.takeError();
6577 return POIOrErr.takeError();
6588 return LocOrErr.takeError();
6596 return std::move(Err);
6598 if (FoundSpecialization)
6603 addDeclToContexts(D, D2);
6606 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
6609 return RedeclOrErr.takeError();
6623 return std::move(Err);
6635 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6636 for (
auto *FoundDecl : FoundDecls) {
6640 if (
auto *FoundTemplate = dyn_cast<FunctionTemplateDecl>(FoundDecl)) {
6649 FoundByLookup = FoundTemplate;
6659 return ParamsOrErr.takeError();
6664 return std::move(Err);
6681 OldParamDC.reserve(Params->
size());
6682 llvm::transform(*Params, std::back_inserter(OldParamDC),
6686 if (GetImportedOrCreateDecl(ToFunc, D, Importer.
getToContext(), DC,
Loc, Name,
6687 Params, TemplatedFD))
6693 ToFunc->setLexicalDeclContext(LexicalDC);
6694 addDeclToContexts(D, ToFunc);
6697 if (
LT && !OldParamDC.empty()) {
6698 for (
unsigned int I = 0; I < OldParamDC.size(); ++I)
6702 if (FoundByLookup) {
6707 "Found decl must have its templated decl set");
6708 auto *PrevTemplated =
6710 if (TemplatedFD != PrevTemplated)
6713 ToFunc->setPreviousDecl(Recent);
6724 Importer.
FromDiag(S->getBeginLoc(), diag::err_unsupported_ast_node)
6725 << S->getStmtClassName();
6734 for (
unsigned I = 0, E = S->getNumOutputs(); I != E; I++) {
6738 Names.push_back(ToII);
6741 for (
unsigned I = 0, E = S->getNumInputs(); I != E; I++) {
6745 Names.push_back(ToII);
6749 for (
unsigned I = 0, E = S->getNumClobbers(); I != E; I++) {
6750 if (
auto ClobberOrErr =
import(S->getClobberStringLiteral(I)))
6751 Clobbers.push_back(*ClobberOrErr);
6753 return ClobberOrErr.takeError();
6758 for (
unsigned I = 0, E = S->getNumOutputs(); I != E; I++) {
6759 if (
auto OutputOrErr =
import(S->getOutputConstraintLiteral(I)))
6760 Constraints.push_back(*OutputOrErr);
6762 return OutputOrErr.takeError();
6765 for (
unsigned I = 0, E = S->getNumInputs(); I != E; I++) {
6766 if (
auto InputOrErr =
import(S->getInputConstraintLiteral(I)))
6767 Constraints.push_back(*InputOrErr);
6769 return InputOrErr.takeError();
6775 return std::move(Err);
6779 return std::move(Err);
6782 S->labels(), Exprs.begin() + S->getNumOutputs() + S->getNumInputs()))
6783 return std::move(Err);
6787 return AsmLocOrErr.takeError();
6788 auto AsmStrOrErr =
import(S->getAsmString());
6790 return AsmStrOrErr.takeError();
6791 ExpectedSLoc RParenLocOrErr =
import(S->getRParenLoc());
6792 if (!RParenLocOrErr)
6793 return RParenLocOrErr.takeError();
6806 S->getNumClobbers(),
6814 Error Err = Error::success();
6819 return std::move(Err);
6825 if (!ToSemiLocOrErr)
6826 return ToSemiLocOrErr.takeError();
6828 *ToSemiLocOrErr, S->hasLeadingEmptyMacro());
6835 return std::move(Err);
6837 ExpectedSLoc ToLBracLocOrErr =
import(S->getLBracLoc());
6838 if (!ToLBracLocOrErr)
6839 return ToLBracLocOrErr.takeError();
6841 ExpectedSLoc ToRBracLocOrErr =
import(S->getRBracLoc());
6842 if (!ToRBracLocOrErr)
6843 return ToRBracLocOrErr.takeError();
6848 *ToLBracLocOrErr, *ToRBracLocOrErr);
6853 Error Err = Error::success();
6858 auto ToEllipsisLoc =
importChecked(Err, S->getEllipsisLoc());
6861 return std::move(Err);
6864 ToCaseLoc, ToEllipsisLoc, ToColonLoc);
6865 ToStmt->setSubStmt(ToSubStmt);
6872 Error Err = Error::success();
6877 return std::move(Err);
6880 ToDefaultLoc, ToColonLoc, ToSubStmt);
6885 Error Err = Error::success();
6890 return std::move(Err);
6893 ToIdentLoc, ToLabelDecl, ToSubStmt);
6898 if (!ToAttrLocOrErr)
6899 return ToAttrLocOrErr.takeError();
6903 return std::move(Err);
6905 if (!ToSubStmtOrErr)
6906 return ToSubStmtOrErr.takeError();
6909 Importer.
getToContext(), *ToAttrLocOrErr, ToAttrs, *ToSubStmtOrErr);
6914 Error Err = Error::success();
6917 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
6925 return std::move(Err);
6928 ToInit, ToConditionVariable, ToCond, ToLParenLoc,
6929 ToRParenLoc, ToThen, ToElseLoc, ToElse);
6934 Error Err = Error::success();
6936 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
6943 return std::move(Err);
6947 ToCond, ToLParenLoc, ToRParenLoc);
6948 ToStmt->setBody(ToBody);
6949 ToStmt->setSwitchLoc(ToSwitchLoc);
6953 for (
SwitchCase *SC = S->getSwitchCaseList(); SC !=
nullptr;
6954 SC = SC->getNextSwitchCase()) {
6957 return ToSCOrErr.takeError();
6958 if (LastChainedSwitchCase)
6961 ToStmt->setSwitchCaseList(*ToSCOrErr);
6962 LastChainedSwitchCase = *ToSCOrErr;
6970 Error Err = Error::success();
6971 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
6978 return std::move(Err);
6981 ToBody, ToWhileLoc, ToLParenLoc, ToRParenLoc);
6986 Error Err = Error::success();
6993 return std::move(Err);
6996 ToBody, ToCond, ToDoLoc, ToWhileLoc, ToRParenLoc);
7001 Error Err = Error::success();
7004 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
7011 return std::move(Err);
7015 ToInit, ToCond, ToConditionVariable, ToInc, ToBody, ToForLoc, ToLParenLoc,
7021 Error Err = Error::success();
7026 return std::move(Err);
7029 ToLabel, ToGotoLoc, ToLabelLoc);
7034 Error Err = Error::success();
7039 return std::move(Err);
7042 ToGotoLoc, ToStarLoc, ToTarget);
7046 ExpectedSLoc ToContinueLocOrErr =
import(S->getContinueLoc());
7047 if (!ToContinueLocOrErr)
7048 return ToContinueLocOrErr.takeError();
7053 auto ToBreakLocOrErr =
import(S->getBreakLoc());
7054 if (!ToBreakLocOrErr)
7055 return ToBreakLocOrErr.takeError();
7061 Error Err = Error::success();
7064 auto ToNRVOCandidate =
importChecked(Err, S->getNRVOCandidate());
7066 return std::move(Err);
7074 Error Err = Error::success();
7076 auto ToExceptionDecl =
importChecked(Err, S->getExceptionDecl());
7077 auto ToHandlerBlock =
importChecked(Err, S->getHandlerBlock());
7079 return std::move(Err);
7082 ToCatchLoc, ToExceptionDecl, ToHandlerBlock);
7088 return ToTryLocOrErr.takeError();
7090 ExpectedStmt ToTryBlockOrErr =
import(S->getTryBlock());
7091 if (!ToTryBlockOrErr)
7092 return ToTryBlockOrErr.takeError();
7095 for (
unsigned HI = 0, HE = S->getNumHandlers(); HI != HE; ++HI) {
7097 if (
auto ToHandlerOrErr =
import(FromHandler))
7098 ToHandlers[HI] = *ToHandlerOrErr;
7100 return ToHandlerOrErr.takeError();
7104 cast<CompoundStmt>(*ToTryBlockOrErr), ToHandlers);
7109 Error Err = Error::success();
7116 auto ToLoopVarStmt =
importChecked(Err, S->getLoopVarStmt());
7123 return std::move(Err);
7126 ToInit, ToRangeStmt, ToBeginStmt, ToEndStmt, ToCond, ToInc, ToLoopVarStmt,
7127 ToBody, ToForLoc, ToCoawaitLoc, ToColonLoc, ToRParenLoc);
7132 Error Err = Error::success();
7139 return std::move(Err);
7150 Error Err = Error::success();
7153 auto ToCatchParamDecl =
importChecked(Err, S->getCatchParamDecl());
7156 return std::move(Err);
7159 ToAtCatchLoc, ToRParenLoc, ToCatchParamDecl, ToCatchBody);
7163 ExpectedSLoc ToAtFinallyLocOrErr =
import(S->getAtFinallyLoc());
7164 if (!ToAtFinallyLocOrErr)
7165 return ToAtFinallyLocOrErr.takeError();
7166 ExpectedStmt ToAtFinallyStmtOrErr =
import(S->getFinallyBody());
7167 if (!ToAtFinallyStmtOrErr)
7168 return ToAtFinallyStmtOrErr.takeError();
7170 *ToAtFinallyStmtOrErr);
7175 Error Err = Error::success();
7178 auto ToFinallyStmt =
importChecked(Err, S->getFinallyStmt());
7180 return std::move(Err);
7183 for (
unsigned CI = 0, CE = S->getNumCatchStmts(); CI != CE; ++CI) {
7185 if (
ExpectedStmt ToCatchStmtOrErr =
import(FromCatchStmt))
7186 ToCatchStmts[CI] = *ToCatchStmtOrErr;
7188 return ToCatchStmtOrErr.takeError();
7192 ToAtTryLoc, ToTryBody,
7193 ToCatchStmts.begin(), ToCatchStmts.size(),
7200 Error Err = Error::success();
7201 auto ToAtSynchronizedLoc =
importChecked(Err, S->getAtSynchronizedLoc());
7205 return std::move(Err);
7208 ToAtSynchronizedLoc, ToSynchExpr, ToSynchBody);
7212 ExpectedSLoc ToThrowLocOrErr =
import(S->getThrowLoc());
7213 if (!ToThrowLocOrErr)
7214 return ToThrowLocOrErr.takeError();
7215 ExpectedExpr ToThrowExprOrErr =
import(S->getThrowExpr());
7216 if (!ToThrowExprOrErr)
7217 return ToThrowExprOrErr.takeError();
7219 *ToThrowLocOrErr, *ToThrowExprOrErr);
7226 return ToAtLocOrErr.takeError();
7228 if (!ToSubStmtOrErr)
7229 return ToSubStmtOrErr.takeError();
7244 Error Err = Error::success();
7249 return std::move(Err);
7251 if (!ParentContextOrErr)
7252 return ParentContextOrErr.takeError();
7256 RParenLoc, *ParentContextOrErr);
7261 Error Err = Error::success();
7268 return std::move(Err);
7271 ToBuiltinLoc, ToSubExpr, ToWrittenTypeInfo, ToRParenLoc, ToType,
7277 Error Err = Error::success();
7285 return std::move(Err);
7295 ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType, VK, OK,
7296 ToRParenLoc, CondIsTrue);
7300 Error Err = Error::success();
7307 return std::move(Err);
7315 Error Err = Error::success();
7323 ToSubExprs.resize(NumSubExprs);
7326 return std::move(Err);
7329 Importer.
getToContext(), ToSubExprs, ToType, ToBeginLoc, ToRParenLoc);
7335 return TypeOrErr.takeError();
7339 return BeginLocOrErr.takeError();
7346 Error Err = Error::success();
7348 Expr *ToControllingExpr =
nullptr;
7354 assert((ToControllingExpr || ToControllingType) &&
7355 "Either the controlling expr or type must be nonnull");
7359 return std::move(Err);
7364 return std::move(Err);
7369 return std::move(Err);
7373 if (ToControllingExpr) {
7375 ToCtx, ToGenericLoc, ToControllingExpr,
llvm::ArrayRef(ToAssocTypes),
7380 ToCtx, ToGenericLoc, ToControllingType,
llvm::ArrayRef(ToAssocTypes),
7385 if (ToControllingExpr) {
7387 ToCtx, ToGenericLoc, ToControllingExpr,
llvm::ArrayRef(ToAssocTypes),
7392 ToCtx, ToGenericLoc, ToControllingType,
llvm::ArrayRef(ToAssocTypes),
7399 Error Err = Error::success();
7404 return std::move(Err);
7413 Error Err = Error::success();
7420 return std::move(Err);
7426 return FoundDOrErr.takeError();
7427 ToFoundD = *FoundDOrErr;
7436 return std::move(Err);
7437 ToResInfo = &ToTAInfo;
7441 Importer.
getToContext(), ToQualifierLoc, ToTemplateKeywordLoc, ToDecl,
7445 ToE->setHadMultipleCandidates(
true);
7453 return TypeOrErr.takeError();
7461 return ToInitOrErr.takeError();
7464 if (!ToEqualOrColonLocOrErr)
7465 return ToEqualOrColonLocOrErr.takeError();
7471 ToIndexExprs[I - 1] = *ToArgOrErr;
7473 return ToArgOrErr.takeError();
7478 return std::move(Err);
7482 ToIndexExprs, *ToEqualOrColonLocOrErr,
7490 return ToTypeOrErr.takeError();
7493 if (!ToLocationOrErr)
7494 return ToLocationOrErr.takeError();
7497 *ToTypeOrErr, *ToLocationOrErr);
7503 return ToTypeOrErr.takeError();
7506 if (!ToLocationOrErr)
7507 return ToLocationOrErr.takeError();
7517 return ToTypeOrErr.takeError();
7520 if (!ToLocationOrErr)
7521 return ToLocationOrErr.takeError();
7525 *ToTypeOrErr, *ToLocationOrErr);
7529 auto ToTypeOrErr =
import(E->
getType());
7531 return ToTypeOrErr.takeError();
7534 if (!ToSubExprOrErr)
7535 return ToSubExprOrErr.takeError();
7538 *ToSubExprOrErr, *ToTypeOrErr);
7542 auto ToTypeOrErr =
import(E->
getType());
7544 return ToTypeOrErr.takeError();
7547 if (!ToLocationOrErr)
7548 return ToLocationOrErr.takeError();
7558 return ToTypeOrErr.takeError();
7561 if (!ToLocationOrErr)
7562 return ToLocationOrErr.takeError();
7571 return ToTypeOrErr.takeError();
7576 return std::move(Err);
7580 *ToTypeOrErr, ToLocations.data(), ToLocations.size());
7585 Error Err = Error::success();
7591 return std::move(Err);
7594 ToLParenLoc, ToTypeSourceInfo, ToType, E->
getValueKind(),
7600 Error Err = Error::success();
7605 return std::move(Err);
7611 return std::move(Err);
7615 ToBuiltinLoc, ToExprs, ToType, E->
getOp(), ToRParenLoc);
7619 Error Err = Error::success();
7625 return std::move(Err);
7628 ToAmpAmpLoc, ToLabelLoc, ToLabel, ToType);
7631 Error Err = Error::success();
7635 return std::move(Err);
7640 Error Err = Error::success();
7645 return std::move(Err);
7648 ParenExpr(ToLParen, ToRParen, ToSubExpr);
7654 return std::move(Err);
7657 if (!ToLParenLocOrErr)
7658 return ToLParenLocOrErr.takeError();
7661 if (!ToRParenLocOrErr)
7662 return ToRParenLocOrErr.takeError();
7665 ToExprs, *ToRParenLocOrErr);
7669 Error Err = Error::success();
7675 return std::move(Err);
7678 StmtExpr(ToSubStmt, ToType, ToLParenLoc, ToRParenLoc,
7683 Error Err = Error::success();
7688 return std::move(Err);
7692 UO->setType(ToType);
7693 UO->setSubExpr(ToSubExpr);
7695 UO->setOperatorLoc(ToOperatorLoc);
7706 Error Err = Error::success();
7711 return std::move(Err);
7716 if (!ToArgumentTypeInfoOrErr)
7717 return ToArgumentTypeInfoOrErr.takeError();
7720 E->
getKind(), *ToArgumentTypeInfoOrErr, ToType, ToOperatorLoc,
7725 if (!ToArgumentExprOrErr)
7726 return ToArgumentExprOrErr.takeError();
7729 E->
getKind(), *ToArgumentExprOrErr, ToType, ToOperatorLoc, ToRParenLoc);
7733 Error Err = Error::success();
7739 return std::move(Err);
7748 Error Err = Error::success();
7756 return std::move(Err);
7759 ToCond, ToQuestionLoc, ToLHS, ToColonLoc, ToRHS, ToType,
7765 Error Err = Error::success();
7775 return std::move(Err);
7778 ToCommon, ToOpaqueValue, ToCond, ToTrueExpr, ToFalseExpr,
7785 Error Err = Error::success();
7788 return std::move(Err);
7795 Error Err = Error::success();
7797 auto ToQueriedTypeSourceInfo =
7803 return std::move(Err);
7807 ToDimensionExpression, ToEndLoc, ToType);
7811 Error Err = Error::success();
7817 return std::move(Err);
7825 Error Err = Error::success();
7830 return std::move(Err);
7837 Error Err = Error::success();
7843 return std::move(Err);
7852 Error Err = Error::success();
7857 auto ToComputationResultType =
7861 return std::move(Err);
7867 ToComputationLHSType, ToComputationResultType);
7874 if (
auto SpecOrErr =
import(*I))
7875 Path.push_back(*SpecOrErr);
7877 return SpecOrErr.takeError();
7885 return ToTypeOrErr.takeError();
7888 if (!ToSubExprOrErr)
7889 return ToSubExprOrErr.takeError();
7892 if (!ToBasePathOrErr)
7893 return ToBasePathOrErr.takeError();
7901 Error Err = Error::success();
7906 return std::move(Err);
7909 if (!ToBasePathOrErr)
7910 return ToBasePathOrErr.takeError();
7914 case Stmt::CStyleCastExprClass: {
7915 auto *CCE = cast<CStyleCastExpr>(E);
7916 ExpectedSLoc ToLParenLocOrErr =
import(CCE->getLParenLoc());
7917 if (!ToLParenLocOrErr)
7918 return ToLParenLocOrErr.takeError();
7919 ExpectedSLoc ToRParenLocOrErr =
import(CCE->getRParenLoc());
7920 if (!ToRParenLocOrErr)
7921 return ToRParenLocOrErr.takeError();
7924 ToSubExpr, ToBasePath, CCE->getFPFeatures(), ToTypeInfoAsWritten,
7925 *ToLParenLocOrErr, *ToRParenLocOrErr);
7928 case Stmt::CXXFunctionalCastExprClass: {
7929 auto *FCE = cast<CXXFunctionalCastExpr>(E);
7930 ExpectedSLoc ToLParenLocOrErr =
import(FCE->getLParenLoc());
7931 if (!ToLParenLocOrErr)
7932 return ToLParenLocOrErr.takeError();
7933 ExpectedSLoc ToRParenLocOrErr =
import(FCE->getRParenLoc());
7934 if (!ToRParenLocOrErr)
7935 return ToRParenLocOrErr.takeError();
7938 E->
getCastKind(), ToSubExpr, ToBasePath, FCE->getFPFeatures(),
7939 *ToLParenLocOrErr, *ToRParenLocOrErr);
7942 case Stmt::ObjCBridgedCastExprClass: {
7943 auto *OCE = cast<ObjCBridgedCastExpr>(E);
7944 ExpectedSLoc ToLParenLocOrErr =
import(OCE->getLParenLoc());
7945 if (!ToLParenLocOrErr)
7946 return ToLParenLocOrErr.takeError();
7947 ExpectedSLoc ToBridgeKeywordLocOrErr =
import(OCE->getBridgeKeywordLoc());
7948 if (!ToBridgeKeywordLocOrErr)
7949 return ToBridgeKeywordLocOrErr.takeError();
7951 *ToLParenLocOrErr, OCE->getBridgeKind(), E->
getCastKind(),
7952 *ToBridgeKeywordLocOrErr, ToTypeInfoAsWritten, ToSubExpr);
7954 case Stmt::BuiltinBitCastExprClass: {
7955 auto *BBC = cast<BuiltinBitCastExpr>(E);
7956 ExpectedSLoc ToKWLocOrErr =
import(BBC->getBeginLoc());
7958 return ToKWLocOrErr.takeError();
7959 ExpectedSLoc ToRParenLocOrErr =
import(BBC->getEndLoc());
7960 if (!ToRParenLocOrErr)
7961 return ToRParenLocOrErr.takeError();
7964 ToTypeInfoAsWritten, *ToKWLocOrErr, *ToRParenLocOrErr);
7967 llvm_unreachable(
"Cast expression of unsupported type!");
7980 Error Err = Error::success();
7984 return std::move(Err);
7993 auto ToBSOrErr =
import(FromNode.
getBase());
7995 return ToBSOrErr.takeError();
8000 auto ToFieldOrErr =
import(FromNode.
getField());
8002 return ToFieldOrErr.takeError();
8003 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, *ToFieldOrErr, ToEndLoc));
8008 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, ToII, ToEndLoc));
8017 if (!ToIndexExprOrErr)
8018 return ToIndexExprOrErr.takeError();
8019 ToExprs[I] = *ToIndexExprOrErr;
8022 Error Err = Error::success();
8028 return std::move(Err);
8031 Importer.
getToContext(), ToType, ToOperatorLoc, ToTypeSourceInfo, ToNodes,
8032 ToExprs, ToRParenLoc);
8036 Error Err = Error::success();
8042 return std::move(Err);
8051 ToType, ToOperand, ToCanThrow, ToBeginLoc, ToEndLoc);
8055 Error Err = Error::success();
8060 return std::move(Err);
8068 if (!ToUsedLocOrErr)
8069 return ToUsedLocOrErr.takeError();
8071 auto ToParamOrErr =
import(E->
getParam());
8073 return ToParamOrErr.takeError();
8076 if (!UsedContextOrErr)
8077 return UsedContextOrErr.takeError();
8087 std::optional<ParmVarDecl *> FromParam =
8089 assert(FromParam &&
"ParmVarDecl was not imported?");
8092 return std::move(Err);
8094 Expr *RewrittenInit =
nullptr;
8098 return ExprOrErr.takeError();
8099 RewrittenInit = ExprOrErr.get();
8102 *ToParamOrErr, RewrittenInit,
8108 Error Err = Error::success();
8113 return std::move(Err);
8116 ToType, ToTypeSourceInfo, ToRParenLoc);
8122 if (!ToSubExprOrErr)
8123 return ToSubExprOrErr.takeError();
8127 return ToDtorOrErr.takeError();
8137 Error Err = Error::success();
8143 return std::move(Err);
8147 return std::move(Err);
8150 Importer.
getToContext(), ToConstructor, ToType, ToTypeSourceInfo, ToArgs,
8160 return std::move(Err);
8162 Error Err = Error::success();
8166 return std::move(Err);
8170 if (GetImportedOrCreateDecl(To, D, Temporary, ExtendingDecl,
8181 Error Err = Error::success();
8185 auto ToMaterializedDecl =
8188 return std::move(Err);
8190 if (!ToTemporaryExpr)
8191 ToTemporaryExpr = cast<Expr>(ToMaterializedDecl->getTemporaryExpr());
8195 ToMaterializedDecl);
8201 Error Err = Error::success();
8206 return std::move(Err);
8213 Error Err = Error::success();
8219 return std::move(Err);
8221 std::optional<unsigned> Length;
8228 ToPartialArguments))
8229 return std::move(Err);
8233 Importer.
getToContext(), ToOperatorLoc, ToPack, ToPackLoc, ToRParenLoc,
8234 Length, ToPartialArguments);
8239 Error Err = Error::success();
8246 auto ToAllocatedTypeSourceInfo =
8251 return std::move(Err);
8256 return std::move(Err);
8262 ToInitializer, ToType, ToAllocatedTypeSourceInfo, ToSourceRange,
8267 Error Err = Error::success();
8273 return std::move(Err);
8282 Error Err = Error::success();
8288 return std::move(Err);
8292 return std::move(Err);
8295 Importer.
getToContext(), ToType, ToLocation, ToConstructor,
8299 ToParenOrBraceRange);
8306 if (!ToSubExprOrErr)
8307 return ToSubExprOrErr.takeError();
8311 return std::move(Err);
8319 Error Err = Error::success();
8324 return std::move(Err);
8328 return std::move(Err);
8338 return ToTypeOrErr.takeError();
8341 if (!ToLocationOrErr)
8342 return ToLocationOrErr.takeError();
8351 return ToTypeOrErr.takeError();
8354 if (!ToLocationOrErr)
8355 return ToLocationOrErr.takeError();
8358 *ToTypeOrErr, *ToLocationOrErr);
8362 Error Err = Error::success();
8373 return std::move(Err);
8385 return std::move(Err);
8386 ResInfo = &ToTAInfo;
8390 ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8391 ToMemberDecl, ToFoundDecl, ToMemberNameInfo,
8398 Error Err = Error::success();
8406 return std::move(Err);
8412 if (!ToDestroyedTypeLocOrErr)
8413 return ToDestroyedTypeLocOrErr.takeError();
8419 return ToTIOrErr.takeError();
8424 ToQualifierLoc, ToScopeTypeInfo, ToColonColonLoc, ToTildeLoc, Storage);
8429 Error Err = Error::success();
8434 auto ToFirstQualifierFoundInScope =
8437 return std::move(Err);
8439 Expr *ToBase =
nullptr;
8442 ToBase = *ToBaseOrErr;
8444 return ToBaseOrErr.takeError();
8453 return std::move(Err);
8454 ResInfo = &ToTAInfo;
8459 return std::move(Err);
8465 return std::move(Err);
8469 ToQualifierLoc, ToTemplateKeywordLoc, ToFirstQualifierFoundInScope,
8470 ToMemberNameInfo, ResInfo);
8475 Error Err = Error::success();
8483 return std::move(Err);
8487 return std::move(Err);
8494 return std::move(Err);
8495 ResInfo = &ToTAInfo;
8499 Importer.
getToContext(), ToQualifierLoc, ToTemplateKeywordLoc,
8500 ToNameInfo, ResInfo);
8505 Error Err = Error::success();
8511 return std::move(Err);
8516 return std::move(Err);
8519 Importer.
getToContext(), ToType, ToTypeSourceInfo, ToLParenLoc,
8526 if (!ToNamingClassOrErr)
8527 return ToNamingClassOrErr.takeError();
8530 if (!ToQualifierLocOrErr)
8531 return ToQualifierLocOrErr.takeError();
8533 Error Err = Error::success();
8537 return std::move(Err);
8542 return std::move(Err);
8545 for (
auto *D : E->
decls())
8546 if (
auto ToDOrErr =
import(D))
8547 ToDecls.
addDecl(cast<NamedDecl>(*ToDOrErr));
8549 return ToDOrErr.takeError();
8556 return std::move(Err);
8559 if (!ToTemplateKeywordLocOrErr)
8560 return ToTemplateKeywordLocOrErr.takeError();
8562 const bool KnownDependent =
8564 ExprDependence::TypeValue;
8566 Importer.
getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8567 *ToTemplateKeywordLocOrErr, ToNameInfo, E->
requiresADL(), &ToTAInfo,
8568 ToDecls.
begin(), ToDecls.
end(), KnownDependent);
8572 Importer.
getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8579 Error Err = Error::success();
8587 return std::move(Err);
8592 return std::move(Err);
8596 if (
auto ToDOrErr =
import(D))
8597 ToDecls.
addDecl(cast<NamedDecl>(*ToDOrErr));
8599 return ToDOrErr.takeError();
8607 return std::move(Err);
8608 ResInfo = &ToTAInfo;
8611 Expr *ToBase =
nullptr;
8614 ToBase = *ToBaseOrErr;
8616 return ToBaseOrErr.takeError();
8621 E->
isArrow(), ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8622 ToNameInfo, ResInfo, ToDecls.
begin(), ToDecls.
end());
8626 Error Err = Error::success();
8631 return std::move(Err);
8636 return std::move(Err);
8638 if (
const auto *OCE = dyn_cast<CXXOperatorCallExpr>(E)) {
8640 Importer.
getToContext(), OCE->getOperator(), ToCallee, ToArgs, ToType,
8641 OCE->getValueKind(), ToRParenLoc, OCE->getFPFeatures(),
8642 OCE->getADLCallKind());
8652 auto ToClassOrErr =
import(FromClass);
8654 return ToClassOrErr.takeError();
8659 return ToCallOpOrErr.takeError();
8663 return std::move(Err);
8665 Error Err = Error::success();
8670 return std::move(Err);
8681 Error Err = Error::success();
8686 return std::move(Err);
8690 return std::move(Err);
8694 ToCtx, ToLBraceLoc, ToExprs, ToRBraceLoc);
8701 return ToFillerOrErr.takeError();
8705 if (
auto ToFDOrErr =
import(FromFD))
8708 return ToFDOrErr.takeError();
8712 if (
auto ToSyntFormOrErr =
import(SyntForm))
8715 return ToSyntFormOrErr.takeError();
8729 return ToTypeOrErr.takeError();
8732 if (!ToSubExprOrErr)
8733 return ToSubExprOrErr.takeError();
8736 *ToTypeOrErr, *ToSubExprOrErr);
8741 Error Err = Error::success();
8746 return std::move(Err);
8754 Error Err = Error::success();
8759 return std::move(Err);
8762 ToType, ToCommonExpr, ToSubExpr);
8768 return ToTypeOrErr.takeError();
8774 if (!ToBeginLocOrErr)
8775 return ToBeginLocOrErr.takeError();
8777 auto ToFieldOrErr =
import(E->
getField());
8779 return ToFieldOrErr.takeError();
8782 if (!UsedContextOrErr)
8783 return UsedContextOrErr.takeError();
8787 "Field should have in-class initializer if there is a default init "
8788 "expression that uses it.");
8793 auto ToInClassInitializerOrErr =
8795 if (!ToInClassInitializerOrErr)
8796 return ToInClassInitializerOrErr.takeError();
8800 Expr *RewrittenInit =
nullptr;
8804 return ExprOrErr.takeError();
8805 RewrittenInit = ExprOrErr.get();
8809 ToField, *UsedContextOrErr, RewrittenInit);
8813 Error Err = Error::success();
8821 return std::move(Err);
8826 if (!ToBasePathOrErr)
8827 return ToBasePathOrErr.takeError();
8829 if (
auto CCE = dyn_cast<CXXStaticCastExpr>(E)) {
8831 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8832 ToTypeInfoAsWritten, CCE->getFPFeatures(), ToOperatorLoc, ToRParenLoc,
8834 }
else if (isa<CXXDynamicCastExpr>(E)) {
8836 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8837 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8838 }
else if (isa<CXXReinterpretCastExpr>(E)) {
8840 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8841 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8842 }
else if (isa<CXXConstCastExpr>(E)) {
8844 Importer.
getToContext(), ToType, VK, ToSubExpr, ToTypeInfoAsWritten,
8845 ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8847 llvm_unreachable(
"Unknown cast type");
8848 return make_error<ASTImportError>();
8854 Error Err = Error::success();
8860 return std::move(Err);
8863 ToType, E->
getValueKind(), ToExprLoc, ToReplacement, ToAssociatedDecl,
8868 Error Err = Error::success();
8873 return std::move(Err);
8877 return std::move(Err);
8891 return ToTypeOrErr.takeError();
8894 if (!ToSourceRangeOrErr)
8895 return ToSourceRangeOrErr.takeError();
8900 *ToTypeOrErr, *ToTSIOrErr, *ToSourceRangeOrErr);
8902 return ToTSIOrErr.takeError();
8906 if (!ToExprOperandOrErr)
8907 return ToExprOperandOrErr.takeError();
8910 *ToTypeOrErr, *ToExprOperandOrErr, *ToSourceRangeOrErr);
8914 Error Err = Error::success();
8925 return std::move(Err);
8934 Error ImportErrors = Error::success();
8936 if (
auto ImportedOrErr =
import(FromOverriddenMethod))
8938 (*ImportedOrErr)->getCanonicalDecl()));
8941 joinErrors(std::move(ImportErrors), ImportedOrErr.takeError());
8943 return ImportErrors;
8949 std::shared_ptr<ASTImporterSharedState> SharedState)
8950 : SharedState(SharedState), ToContext(ToContext), FromContext(FromContext),
8951 ToFileManager(ToFileManager), FromFileManager(FromFileManager),
8956 this->SharedState = std::make_shared<ASTImporterSharedState>();
8966 assert(F && (isa<FieldDecl>(*F) || isa<IndirectFieldDecl>(*F)) &&
8967 "Try to get field index for non-field.");
8971 return std::nullopt;
8974 for (
const auto *D : Owner->decls()) {
8978 if (isa<FieldDecl>(*D) || isa<IndirectFieldDecl>(*D))
8982 llvm_unreachable(
"Field was not found in its parent context.");
8984 return std::nullopt;
8997 if (SharedState->getLookupTable()) {
8999 SharedState->getLookupTable()->lookup(ReDC, Name);
9003 FoundDeclsTy
Result(NoloadLookupResult.
begin(), NoloadLookupResult.
end());
9020void ASTImporter::AddToLookupTable(
Decl *ToD) {
9021 SharedState->addDeclToLookup(ToD);
9027 return Importer.
Visit(FromD);
9051 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
9052 ImportedTypes.find(FromT);
9053 if (Pos != ImportedTypes.end())
9060 return ToTOrErr.takeError();
9063 ImportedTypes[FromT] = ToTOrErr->getTypePtr();
9065 return ToTOrErr->getTypePtr();
9074 return ToTyOrErr.takeError();
9087 return TOrErr.takeError();
9090 return BeginLocOrErr.takeError();
9099template <
typename T>
struct AttrArgImporter {
9100 AttrArgImporter(
const AttrArgImporter<T> &) =
delete;
9101 AttrArgImporter(AttrArgImporter<T> &&) =
default;
9102 AttrArgImporter<T> &operator=(
const AttrArgImporter<T> &) =
delete;
9103 AttrArgImporter<T> &operator=(AttrArgImporter<T> &&) =
default;
9106 : To(I.importChecked(Err, From)) {}
9108 const T &value() {
return To; }
9119template <
typename T>
struct AttrArgArrayImporter {
9120 AttrArgArrayImporter(
const AttrArgArrayImporter<T> &) =
delete;
9121 AttrArgArrayImporter(AttrArgArrayImporter<T> &&) =
default;
9122 AttrArgArrayImporter<T> &operator=(
const AttrArgArrayImporter<T> &) =
delete;
9123 AttrArgArrayImporter<T> &operator=(AttrArgArrayImporter<T> &&) =
default;
9126 const llvm::iterator_range<T *> &From,
9127 unsigned ArraySize) {
9130 To.reserve(ArraySize);
9134 T *value() {
return To.data(); }
9141 Error Err{Error::success()};
9142 Attr *ToAttr =
nullptr;
9147 AttrImporter(
ASTImporter &I) : Importer(I), NImporter(I) {}
9150 template <
typename T>
T *castAttrAs() {
return cast<T>(ToAttr); }
9151 template <
typename T>
const T *castAttrAs()
const {
return cast<T>(ToAttr); }
9156 template <
class T> AttrArgImporter<T> importArg(
const T &From) {
9157 return AttrArgImporter<T>(NImporter, Err, From);
9163 template <
typename T>
9164 AttrArgArrayImporter<T> importArrayArg(
const llvm::iterator_range<T *> &From,
9165 unsigned ArraySize) {
9166 return AttrArgArrayImporter<T>(NImporter, Err, From, ArraySize);
9177 template <
typename T,
typename... Arg>
9178 void importAttr(
const T *FromAttr, Arg &&...ImportedArg) {
9179 static_assert(std::is_base_of<Attr, T>::value,
9180 "T should be subclass of Attr.");
9181 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9185 Importer.
Import(FromAttr->getScopeName());
9195 FromAttr->getParsedKind(), FromAttr->getForm());
9199 std::forward<Arg>(ImportedArg)..., ToI);
9203 if (
auto *ToInheritableAttr = dyn_cast<InheritableAttr>(ToAttr))
9204 ToInheritableAttr->setInherited(FromAttr->isInherited());
9210 void cloneAttr(
const Attr *FromAttr) {
9211 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9225 return std::move(Err);
9226 assert(ToAttr &&
"Attribute should be created.");
9233 AttrImporter AI(*
this);
9236 switch (FromAttr->
getKind()) {
9237 case attr::Aligned: {
9238 auto *From = cast<AlignedAttr>(FromAttr);
9239 if (From->isAlignmentExpr())
9240 AI.importAttr(From,
true, AI.importArg(From->getAlignmentExpr()).value());
9242 AI.importAttr(From,
false,
9243 AI.importArg(From->getAlignmentType()).value());
9247 case attr::AlignValue: {
9248 auto *From = cast<AlignValueAttr>(FromAttr);
9249 AI.importAttr(From, AI.importArg(From->getAlignment()).value());
9253 case attr::Format: {
9254 const auto *From = cast<FormatAttr>(FromAttr);
9255 AI.importAttr(From,
Import(From->getType()), From->getFormatIdx(),
9256 From->getFirstArg());
9260 case attr::EnableIf: {
9261 const auto *From = cast<EnableIfAttr>(FromAttr);
9262 AI.importAttr(From, AI.importArg(From->getCond()).value(),
9263 From->getMessage());
9267 case attr::AssertCapability: {
9268 const auto *From = cast<AssertCapabilityAttr>(FromAttr);
9270 AI.importArrayArg(From->args(), From->args_size()).value(),
9274 case attr::AcquireCapability: {
9275 const auto *From = cast<AcquireCapabilityAttr>(FromAttr);
9277 AI.importArrayArg(From->args(), From->args_size()).value(),
9281 case attr::TryAcquireCapability: {
9282 const auto *From = cast<TryAcquireCapabilityAttr>(FromAttr);
9283 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9284 AI.importArrayArg(From->args(), From->args_size()).value(),
9288 case attr::ReleaseCapability: {
9289 const auto *From = cast<ReleaseCapabilityAttr>(FromAttr);
9291 AI.importArrayArg(From->args(), From->args_size()).value(),
9295 case attr::RequiresCapability: {
9296 const auto *From = cast<RequiresCapabilityAttr>(FromAttr);
9298 AI.importArrayArg(From->args(), From->args_size()).value(),
9302 case attr::GuardedBy: {
9303 const auto *From = cast<GuardedByAttr>(FromAttr);
9304 AI.importAttr(From, AI.importArg(From->getArg()).value());
9307 case attr::PtGuardedBy: {
9308 const auto *From = cast<PtGuardedByAttr>(FromAttr);
9309 AI.importAttr(From, AI.importArg(From->getArg()).value());
9312 case attr::AcquiredAfter: {
9313 const auto *From = cast<AcquiredAfterAttr>(FromAttr);
9315 AI.importArrayArg(From->args(), From->args_size()).value(),
9319 case attr::AcquiredBefore: {
9320 const auto *From = cast<AcquiredBeforeAttr>(FromAttr);
9322 AI.importArrayArg(From->args(), From->args_size()).value(),
9326 case attr::AssertExclusiveLock: {
9327 const auto *From = cast<AssertExclusiveLockAttr>(FromAttr);
9329 AI.importArrayArg(From->args(), From->args_size()).value(),
9333 case attr::AssertSharedLock: {
9334 const auto *From = cast<AssertSharedLockAttr>(FromAttr);
9336 AI.importArrayArg(From->args(), From->args_size()).value(),
9340 case attr::ExclusiveTrylockFunction: {
9341 const auto *From = cast<ExclusiveTrylockFunctionAttr>(FromAttr);
9342 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9343 AI.importArrayArg(From->args(), From->args_size()).value(),
9347 case attr::SharedTrylockFunction: {
9348 const auto *From = cast<SharedTrylockFunctionAttr>(FromAttr);
9349 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9350 AI.importArrayArg(From->args(), From->args_size()).value(),
9354 case attr::LockReturned: {
9355 const auto *From = cast<LockReturnedAttr>(FromAttr);
9356 AI.importAttr(From, AI.importArg(From->getArg()).value());
9359 case attr::LocksExcluded: {
9360 const auto *From = cast<LocksExcludedAttr>(FromAttr);
9362 AI.importArrayArg(From->args(), From->args_size()).value(),
9370 AI.cloneAttr(FromAttr);
9375 return std::move(AI).getResult();
9379 return ImportedDecls.lookup(FromD);
9383 auto FromDPos = ImportedFromDecls.find(ToD);
9384 if (FromDPos == ImportedFromDecls.end())
9386 return FromDPos->second->getTranslationUnitDecl();
9389Error ASTImporter::ImportAttrs(
Decl *ToD,
Decl *FromD) {
9391 return Error::success();
9393 auto ToAttrOrErr =
Import(FromAttr);
9397 return ToAttrOrErr.takeError();
9399 return Error::success();
9407 ImportPath.
push(FromD);
9408 auto ImportPathBuilder =
9409 llvm::make_scope_exit([
this]() { ImportPath.
pop(); });
9414 return make_error<ASTImportError>(*Error);
9420 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9422 return make_error<ASTImportError>(*Error);
9439 auto Pos = ImportedDecls.find(FromD);
9440 if (Pos != ImportedDecls.end()) {
9443 auto *ToD = Pos->second;
9444 ImportedDecls.erase(Pos);
9456 auto PosF = ImportedFromDecls.find(ToD);
9457 if (PosF != ImportedFromDecls.end()) {
9462 SharedState->removeDeclFromLookup(ToD);
9463 ImportedFromDecls.erase(PosF);
9475 handleAllErrors(ToDOrErr.takeError(),
9479 if (Pos != ImportedDecls.end())
9480 SharedState->setImportDeclError(Pos->second, ErrOut);
9484 for (
const auto &Path : SavedImportPaths[FromD]) {
9487 Decl *PrevFromDi = FromD;
9488 for (
Decl *FromDi : Path) {
9490 if (FromDi == FromD)
9497 PrevFromDi = FromDi;
9501 auto Ii = ImportedDecls.find(FromDi);
9502 if (Ii != ImportedDecls.end())
9503 SharedState->setImportDeclError(Ii->second, ErrOut);
9508 SavedImportPaths.erase(FromD);
9511 return make_error<ASTImportError>(ErrOut);
9523 return make_error<ASTImportError>(*Err);
9529 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9531 return make_error<ASTImportError>(*Error);
9534 assert(ImportedDecls.count(FromD) != 0 &&
"Missing call to MapImported?");
9535 if (
auto Error = ImportAttrs(ToD, FromD))
9536 return std::move(Error);
9542 SavedImportPaths.erase(FromD);
9557 return ToDCOrErr.takeError();
9558 auto *ToDC = cast<DeclContext>(*ToDCOrErr);
9562 if (
auto *ToRecord = dyn_cast<RecordDecl>(ToDC)) {
9563 auto *FromRecord = cast<RecordDecl>(FromDC);
9564 if (ToRecord->isCompleteDefinition())
9572 if (FromRecord->getASTContext().getExternalSource() &&
9573 !FromRecord->isCompleteDefinition())
9574 FromRecord->getASTContext().getExternalSource()->CompleteType(FromRecord);
9576 if (FromRecord->isCompleteDefinition())
9579 return std::move(Err);
9580 }
else if (
auto *ToEnum = dyn_cast<EnumDecl>(ToDC)) {
9581 auto *FromEnum = cast<EnumDecl>(FromDC);
9582 if (ToEnum->isCompleteDefinition()) {
9584 }
else if (FromEnum->isCompleteDefinition()) {
9587 return std::move(Err);
9591 }
else if (
auto *ToClass = dyn_cast<ObjCInterfaceDecl>(ToDC)) {
9592 auto *FromClass = cast<ObjCInterfaceDecl>(FromDC);
9593 if (ToClass->getDefinition()) {
9598 return std::move(Err);
9602 }
else if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(ToDC)) {
9603 auto *FromProto = cast<ObjCProtocolDecl>(FromDC);
9604 if (ToProto->getDefinition()) {
9609 return std::move(Err);
9620 return cast_or_null<Expr>(*ToSOrErr);
9622 return ToSOrErr.takeError();
9630 llvm::DenseMap<Stmt *, Stmt *>::iterator Pos = ImportedStmts.find(FromS);
9631 if (Pos != ImportedStmts.end())
9640 if (
auto *ToE = dyn_cast<Expr>(*ToSOrErr)) {
9641 auto *FromE = cast<Expr>(FromS);
9644 ToE->setValueKind(FromE->getValueKind());
9645 ToE->setObjectKind(FromE->getObjectKind());
9646 ToE->setDependence(FromE->getDependence());
9650 ImportedStmts[FromS] = *ToSOrErr;
9661 return std::move(Err);
9665 assert(FromNNS->
getAsIdentifier() &&
"NNS should contain identifier.");
9672 cast<NamespaceDecl>(*NSOrErr));
9674 return NSOrErr.takeError();
9679 cast<NamespaceAliasDecl>(*NSADOrErr));
9681 return NSADOrErr.takeError();
9689 cast<CXXRecordDecl>(*RDOrErr));
9691 return RDOrErr.takeError();
9701 return TyOrErr.takeError();
9705 llvm_unreachable(
"Invalid nested name specifier kind");
9717 NestedNames.push_back(NNS);
9723 while (!NestedNames.empty()) {
9724 NNS = NestedNames.pop_back_val();
9727 return std::move(Err);
9734 return std::move(Err);
9738 return std::move(Err);
9754 ToLocalBeginLoc, ToLocalEndLoc);
9761 return std::move(Err);
9781 if (!ToSourceRangeOrErr)
9782 return ToSourceRangeOrErr.takeError();
9785 ToSourceRangeOrErr->getBegin(),
9786 ToSourceRangeOrErr->getEnd());
9798 return TemplateName(cast<TemplateDecl>((*ToTemplateOrErr)->getCanonicalDecl()));
9800 return ToTemplateOrErr.takeError();
9805 for (
auto *I : *FromStorage) {
9806 if (
auto ToOrErr =
Import(I))
9807 ToTemplates.
addDecl(cast<NamedDecl>(*ToOrErr));
9809 return ToOrErr.takeError();
9819 return DeclNameOrErr.takeError();
9826 if (!QualifierOrErr)
9827 return QualifierOrErr.takeError();
9830 return TNOrErr.takeError();
9838 if (!QualifierOrErr)
9839 return QualifierOrErr.takeError();
9854 if (!ReplacementOrErr)
9855 return ReplacementOrErr.takeError();
9858 if (!AssociatedDeclOrErr)
9859 return AssociatedDeclOrErr.takeError();
9862 *ReplacementOrErr, *AssociatedDeclOrErr, Subst->
getIndex(),
9873 return ArgPackOrErr.takeError();
9876 if (!AssociatedDeclOrErr)
9877 return AssociatedDeclOrErr.takeError();
9880 *ArgPackOrErr, *AssociatedDeclOrErr, SubstPack->
getIndex(),
9886 return UsingOrError.takeError();
9887 return TemplateName(cast<UsingShadowDecl>(*UsingOrError));
9891 llvm_unreachable(
"Invalid template name kind");
9904 return ToFileIDOrErr.takeError();
9912 return std::move(Err);
9914 return std::move(Err);
9920 llvm::DenseMap<FileID, FileID>::iterator Pos = ImportedFileIDs.find(FromID);
9921 if (Pos != ImportedFileIDs.end())
9934 return ToSpLoc.takeError();
9937 return ToExLocS.takeError();
9947 return ToExLocE.takeError();
9953 if (!IsBuiltin && !
Cache->BufferOverridden) {
9957 return ToIncludeLoc.takeError();
9968 if (
Cache->OrigEntry &&
Cache->OrigEntry->getDir()) {
9979 ToID = ToSM.
createFileID(*Entry, ToIncludeLocOrFakeLoc,
9986 std::optional<llvm::MemoryBufferRef> FromBuf =
9992 std::unique_ptr<llvm::MemoryBuffer> ToBuf =
9993 llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(),
9994 FromBuf->getBufferIdentifier());
10000 assert(ToID.
isValid() &&
"Unexpected invalid fileID was created.");
10002 ImportedFileIDs[FromID] = ToID;
10009 return ToExprOrErr.takeError();
10012 if (!LParenLocOrErr)
10013 return LParenLocOrErr.takeError();
10016 if (!RParenLocOrErr)
10017 return RParenLocOrErr.takeError();
10022 return ToTInfoOrErr.takeError();
10027 return std::move(Err);
10030 ToContext, *ToTInfoOrErr, From->
isBaseVirtual(), *LParenLocOrErr,
10031 *ToExprOrErr, *RParenLocOrErr, EllipsisLoc);
10035 return ToFieldOrErr.takeError();
10038 if (!MemberLocOrErr)
10039 return MemberLocOrErr.takeError();
10042 ToContext, cast_or_null<FieldDecl>(*ToFieldOrErr), *MemberLocOrErr,
10043 *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10046 if (!ToIFieldOrErr)
10047 return ToIFieldOrErr.takeError();
10050 if (!MemberLocOrErr)
10051 return MemberLocOrErr.takeError();
10054 ToContext, cast_or_null<IndirectFieldDecl>(*ToIFieldOrErr),
10055 *MemberLocOrErr, *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10059 return ToTInfoOrErr.takeError();
10061 return new (ToContext)
10063 *ToExprOrErr, *RParenLocOrErr);
10066 return make_error<ASTImportError>();
10072 auto Pos = ImportedCXXBaseSpecifiers.find(BaseSpec);
10073 if (Pos != ImportedCXXBaseSpecifiers.end())
10074 return Pos->second;
10077 if (!ToSourceRange)
10078 return ToSourceRange.takeError();
10081 return ToTSI.takeError();
10083 if (!ToEllipsisLoc)
10084 return ToEllipsisLoc.takeError();
10088 ImportedCXXBaseSpecifiers[BaseSpec] =
Imported;
10100 return ToOrErr.takeError();
10101 Decl *To = *ToOrErr;
10103 auto *FromDC = cast<DeclContext>(From);
10106 if (
auto *ToRecord = dyn_cast<RecordDecl>(To)) {
10107 if (!ToRecord->getDefinition()) {
10109 cast<RecordDecl>(FromDC), ToRecord,
10114 if (
auto *ToEnum = dyn_cast<EnumDecl>(To)) {
10115 if (!ToEnum->getDefinition()) {
10121 if (
auto *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
10122 if (!ToIFace->getDefinition()) {
10124 cast<ObjCInterfaceDecl>(FromDC), ToIFace,
10129 if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
10130 if (!ToProto->getDefinition()) {
10132 cast<ObjCProtocolDecl>(FromDC), ToProto,
10154 return ToSelOrErr.takeError();
10161 return ToTyOrErr.takeError();
10169 return ToTyOrErr.takeError();
10175 cast<TemplateDecl>(*ToTemplateOrErr));
10177 return ToTemplateOrErr.takeError();
10185 return ToTyOrErr.takeError();
10201 llvm_unreachable(
"Invalid DeclarationName Kind!");
10222 for (
unsigned I = 1, N = FromSel.
getNumArgs(); I < N; ++I)
10230 llvm::Error Err = llvm::Error::success();
10231 auto ImportLoop = [&](
const APValue *From,
APValue *To,
unsigned Size) {
10232 for (
unsigned Idx = 0; Idx < Size; Idx++) {
10237 switch (FromValue.
getKind()) {
10251 ImportLoop(((
const APValue::Vec *)(
const char *)&FromValue.Data)->Elts,
10258 ImportLoop(((
const APValue::Arr *)(
const char *)&FromValue.Data)->Elts,
10259 ((
const APValue::Arr *)(
const char *)&
Result.Data)->Elts,
10266 ((
const APValue::StructData *)(
const char *)&FromValue.Data)->Elts,
10267 ((
const APValue::StructData *)(
const char *)&
Result.Data)->Elts,
10275 return std::move(Err);
10276 Result.setUnion(cast<FieldDecl>(ImpFDecl), ImpValue);
10280 Result.MakeAddrLabelDiff();
10284 return std::move(Err);
10285 Result.setAddrLabelDiff(cast<AddrLabelExpr>(ImpLHS),
10286 cast<AddrLabelExpr>(ImpRHS));
10290 const Decl *ImpMemPtrDecl =
10293 return std::move(Err);
10295 Result.setMemberPointerUninit(
10296 cast<const ValueDecl>(ImpMemPtrDecl),
10300 Result.getMemberPointerPath();
10305 return std::move(Err);
10315 "in C++20 dynamic allocation are transient so they shouldn't "
10316 "appear in the AST");
10318 if (
const auto *E =
10320 FromElemTy = E->getType();
10323 return std::move(Err);
10333 return std::move(Err);
10345 return std::move(Err);
10359 for (
unsigned LoopIdx = 0; LoopIdx < PathLength; LoopIdx++) {
10362 FromPath[LoopIdx].getAsBaseOrMember().getPointer();
10365 return std::move(Err);
10366 if (
auto *RD = dyn_cast<CXXRecordDecl>(
FromDecl))
10369 FromElemTy = cast<ValueDecl>(
FromDecl)->getType();
10371 ImpDecl, FromPath[LoopIdx].getAsBaseOrMember().getInt()));
10376 FromPath[LoopIdx].getAsArrayIndex());
10384 return std::move(Err);
10392 unsigned NumDecls) {
10402 if (LastDiagFromFrom)
10405 LastDiagFromFrom =
false;
10410 if (!LastDiagFromFrom)
10413 LastDiagFromFrom =
true;
10418 if (
auto *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
10419 if (!ID->getDefinition())
10420 ID->startDefinition();
10422 else if (
auto *PD = dyn_cast<ObjCProtocolDecl>(D)) {
10423 if (!PD->getDefinition())
10424 PD->startDefinition();
10426 else if (
auto *TD = dyn_cast<TagDecl>(D)) {
10427 if (!TD->getDefinition() && !TD->isBeingDefined()) {
10428 TD->startDefinition();
10429 TD->setCompleteDefinition(
true);
10433 assert(0 &&
"CompleteDecl called on a Decl that can't be completed");
10438 llvm::DenseMap<Decl *, Decl *>::iterator Pos = ImportedDecls.find(From);
10439 assert((Pos == ImportedDecls.end() || Pos->second == To) &&
10440 "Try to import an already imported Decl");
10441 if (Pos != ImportedDecls.end())
10442 return Pos->second;
10443 ImportedDecls[From] = To;
10446 ImportedFromDecls[To] = From;
10451 AddToLookupTable(To);
10455std::optional<ASTImportError>
10457 auto Pos = ImportDeclErrors.find(FromD);
10458 if (Pos != ImportDeclErrors.end())
10459 return Pos->second;
10461 return std::nullopt;
10465 auto InsertRes = ImportDeclErrors.insert({From, Error});
10469 assert(InsertRes.second || InsertRes.first->second.Error == Error.Error);
10474 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
10476 if (Pos != ImportedTypes.end()) {
10481 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 ImportTemplateParameterLists(const DeclTy *FromD, DeclTy *ToD)
Error ImportDeclContext(DeclContext *FromDC, bool ForceImport=false)
ExpectedStmt VisitContinueStmt(ContinueStmt *S)
ExpectedStmt VisitCXXMemberCallExpr(CXXMemberCallExpr *E)
ExpectedDecl VisitVarDecl(VarDecl *D)
ExpectedStmt VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E)
ExpectedDecl VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D)
Error ImportImplicitMethods(const CXXRecordDecl *From, CXXRecordDecl *To)
ExpectedStmt VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E)
ExpectedStmt VisitImaginaryLiteral(ImaginaryLiteral *E)
ExpectedDecl VisitLinkageSpecDecl(LinkageSpecDecl *D)
ExpectedDecl VisitCXXDestructorDecl(CXXDestructorDecl *D)
ExpectedStmt VisitCXXNamedCastExpr(CXXNamedCastExpr *E)
ExpectedStmt VisitOffsetOfExpr(OffsetOfExpr *OE)
ExpectedStmt VisitExprWithCleanups(ExprWithCleanups *E)
ExpectedDecl VisitIndirectFieldDecl(IndirectFieldDecl *D)
ExpectedStmt VisitCXXFoldExpr(CXXFoldExpr *E)
ExpectedDecl VisitTypeAliasDecl(TypeAliasDecl *D)
Expected< InheritedConstructor > ImportInheritedConstructor(const InheritedConstructor &From)
ExpectedStmt VisitCXXNewExpr(CXXNewExpr *E)
Error ImportDeclParts(NamedDecl *D, DeclarationName &Name, NamedDecl *&ToD, SourceLocation &Loc)
Error ImportDefinition(RecordDecl *From, RecordDecl *To, ImportDefinitionKind Kind=IDK_Default)
ExpectedStmt VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S)
ExpectedStmt VisitConstantExpr(ConstantExpr *E)
ExpectedStmt VisitCompoundLiteralExpr(CompoundLiteralExpr *E)
ExpectedStmt VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E)
ExpectedDecl VisitDecl(Decl *D)
bool hasSameVisibilityContextAndLinkage(T *Found, T *From)
ExpectedStmt VisitParenExpr(ParenExpr *E)
ExpectedStmt VisitObjCForCollectionStmt(ObjCForCollectionStmt *S)
ExpectedStmt VisitSourceLocExpr(SourceLocExpr *E)
ExpectedStmt VisitInitListExpr(InitListExpr *E)
Expected< FunctionTemplateAndArgsTy > ImportFunctionTemplateWithTemplateArgsFromSpecialization(FunctionDecl *FromFD)
ExpectedStmt VisitReturnStmt(ReturnStmt *S)
ExpectedStmt VisitAtomicExpr(AtomicExpr *E)
ExpectedStmt VisitConditionalOperator(ConditionalOperator *E)
ExpectedStmt VisitChooseExpr(ChooseExpr *E)
ExpectedStmt VisitCompoundStmt(CompoundStmt *S)
Expected< TemplateArgument > ImportTemplateArgument(const TemplateArgument &From)
ExpectedStmt VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E)
ExpectedStmt VisitCaseStmt(CaseStmt *S)
ExpectedStmt VisitCXXRewrittenBinaryOperator(CXXRewrittenBinaryOperator *E)
ExpectedStmt VisitDesignatedInitExpr(DesignatedInitExpr *E)
ExpectedDecl VisitObjCTypeParamDecl(ObjCTypeParamDecl *D)
ExpectedStmt VisitCompoundAssignOperator(CompoundAssignOperator *E)
ExpectedStmt VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E)
ExpectedStmt VisitLambdaExpr(LambdaExpr *LE)
ExpectedStmt VisitBinaryOperator(BinaryOperator *E)
ExpectedStmt VisitCallExpr(CallExpr *E)
ExpectedStmt VisitDeclStmt(DeclStmt *S)
ExpectedStmt VisitCXXDeleteExpr(CXXDeleteExpr *E)
ExpectedStmt VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E)
Error ImportArrayChecked(IIter Ibegin, IIter Iend, OIter Obegin)
ExpectedDecl VisitClassTemplateDecl(ClassTemplateDecl *D)
ExpectedDecl VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D)
Expected< CXXCastPath > ImportCastPath(CastExpr *E)
Expected< APValue > ImportAPValue(const APValue &FromValue)
ExpectedDecl VisitFunctionTemplateDecl(FunctionTemplateDecl *D)
ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E)
ExpectedDecl VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
ExpectedStmt VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E)
ExpectedDecl VisitLifetimeExtendedTemporaryDecl(LifetimeExtendedTemporaryDecl *D)
ExpectedDecl VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias)
ExpectedDecl VisitCXXConstructorDecl(CXXConstructorDecl *D)
ExpectedDecl VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D)
ExpectedDecl VisitObjCIvarDecl(ObjCIvarDecl *D)
Expected< ObjCTypeParamList * > ImportObjCTypeParamList(ObjCTypeParamList *list)
ExpectedDecl VisitUsingPackDecl(UsingPackDecl *D)
ExpectedStmt VisitWhileStmt(WhileStmt *S)
ExpectedDecl VisitEnumConstantDecl(EnumConstantDecl *D)
ExpectedStmt VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E)
ExpectedStmt VisitCXXForRangeStmt(CXXForRangeStmt *S)
ExpectedDecl VisitFriendDecl(FriendDecl *D)
Error ImportContainerChecked(const InContainerTy &InContainer, OutContainerTy &OutContainer)
ExpectedStmt VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E)
ExpectedStmt VisitExpressionTraitExpr(ExpressionTraitExpr *E)
bool IsStructuralMatch(Decl *From, Decl *To, bool Complain=true, bool IgnoreTemplateParmDepth=false)
ExpectedStmt VisitFixedPointLiteral(FixedPointLiteral *E)
ExpectedStmt VisitForStmt(ForStmt *S)
ExpectedStmt VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E)
ExpectedDecl VisitEnumDecl(EnumDecl *D)
ExpectedDecl VisitObjCCategoryDecl(ObjCCategoryDecl *D)
ExpectedStmt VisitAddrLabelExpr(AddrLabelExpr *E)
ExpectedStmt VisitBinaryConditionalOperator(BinaryConditionalOperator *E)
ExpectedStmt VisitSwitchStmt(SwitchStmt *S)
ExpectedType VisitType(const Type *T)
ExpectedDecl VisitVarTemplateDecl(VarTemplateDecl *D)
ExpectedDecl ImportUsingShadowDecls(BaseUsingDecl *D, BaseUsingDecl *ToSI)
ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E)
ExpectedStmt VisitOpaqueValueExpr(OpaqueValueExpr *E)
ExpectedDecl VisitNamespaceAliasDecl(NamespaceAliasDecl *D)
ExpectedStmt VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E)
ExpectedDecl VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
ExpectedStmt VisitPackExpansionExpr(PackExpansionExpr *E)
ExpectedStmt VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E)
ExpectedDecl VisitObjCMethodDecl(ObjCMethodDecl *D)
Error ImportTemplateArguments(ArrayRef< TemplateArgument > FromArgs, SmallVectorImpl< TemplateArgument > &ToArgs)
ExpectedDecl VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D)
ExpectedStmt VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E)
ExpectedDecl VisitImplicitParamDecl(ImplicitParamDecl *D)
ExpectedDecl VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D)
ExpectedStmt VisitExplicitCastExpr(ExplicitCastExpr *E)
ExpectedStmt VisitArrayInitIndexExpr(ArrayInitIndexExpr *E)
Error ImportTemplateArgumentListInfo(const InContainerTy &Container, TemplateArgumentListInfo &ToTAInfo)
ExpectedStmt VisitDoStmt(DoStmt *S)
ExpectedStmt VisitNullStmt(NullStmt *S)
ExpectedStmt VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E)
ExpectedDecl VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D)
Error ImportOverriddenMethods(CXXMethodDecl *ToMethod, CXXMethodDecl *FromMethod)
ExpectedStmt VisitStringLiteral(StringLiteral *E)
Error ImportDeclarationNameLoc(const DeclarationNameInfo &From, DeclarationNameInfo &To)
ExpectedStmt VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E)
bool hasReturnTypeDeclaredInside(FunctionDecl *D)
This function checks if the given function has a return type that contains a reference (in any way) t...
ASTNodeImporter(ASTImporter &Importer)
std::tuple< FunctionTemplateDecl *, TemplateArgsTy > FunctionTemplateAndArgsTy
ExpectedDecl VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D)
ExpectedStmt VisitMemberExpr(MemberExpr *E)
ExpectedStmt VisitCXXThisExpr(CXXThisExpr *E)
Error ImportInitializer(VarDecl *From, VarDecl *To)
ImportDefinitionKind
What we should import from the definition.
@ IDK_Everything
Import everything.
@ IDK_Default
Import the default subset of the definition, which might be nothing (if minimal import is set) or mig...
@ IDK_Basic
Import only the bare bones needed to establish a valid DeclContext.
ExpectedDecl VisitTypedefDecl(TypedefDecl *D)
ExpectedDecl VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
ExpectedStmt VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E)
ExpectedDecl VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D)
ExpectedStmt VisitFloatingLiteral(FloatingLiteral *E)
ExpectedStmt VisitIfStmt(IfStmt *S)
ExpectedStmt VisitLabelStmt(LabelStmt *S)
ExpectedStmt VisitCXXTypeidExpr(CXXTypeidExpr *E)
ExpectedStmt VisitConvertVectorExpr(ConvertVectorExpr *E)
ExpectedDecl VisitUsingEnumDecl(UsingEnumDecl *D)
ExpectedStmt VisitGotoStmt(GotoStmt *S)
ExpectedStmt VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *E)
ExpectedStmt VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S)
ExpectedStmt VisitGCCAsmStmt(GCCAsmStmt *S)
ExpectedDecl VisitNamespaceDecl(NamespaceDecl *D)
ExpectedStmt VisitCXXTryStmt(CXXTryStmt *S)
ExpectedDecl VisitImportDecl(ImportDecl *D)
Error ImportFunctionDeclBody(FunctionDecl *FromFD, FunctionDecl *ToFD)
ExpectedStmt VisitArraySubscriptExpr(ArraySubscriptExpr *E)
ExpectedStmt VisitIntegerLiteral(IntegerLiteral *E)
ExpectedDecl VisitEmptyDecl(EmptyDecl *D)
ExpectedStmt VisitCXXNoexceptExpr(CXXNoexceptExpr *E)
ExpectedStmt VisitExpr(Expr *E)
Error ImportDefaultArgOfParmVarDecl(const ParmVarDecl *FromParam, ParmVarDecl *ToParam)
ExpectedStmt VisitArrayInitLoopExpr(ArrayInitLoopExpr *E)
ExpectedStmt VisitCXXCatchStmt(CXXCatchStmt *S)
ExpectedStmt VisitAttributedStmt(AttributedStmt *S)
ExpectedStmt VisitIndirectGotoStmt(IndirectGotoStmt *S)
ExpectedStmt VisitParenListExpr(ParenListExpr *E)
Expected< FunctionDecl * > FindFunctionTemplateSpecialization(FunctionDecl *FromFD)
ExpectedDecl VisitCXXConversionDecl(CXXConversionDecl *D)
ExpectedStmt VisitObjCAtCatchStmt(ObjCAtCatchStmt *S)
Error ImportTemplateInformation(FunctionDecl *FromFD, FunctionDecl *ToFD)
ExpectedStmt VisitStmtExpr(StmtExpr *E)
ExpectedStmt VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E)
bool shouldForceImportDeclContext(ImportDefinitionKind IDK)
ExpectedDecl VisitBindingDecl(BindingDecl *D)
ExpectedStmt VisitBreakStmt(BreakStmt *S)
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.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a class template specialization, which refers to a class template with a given set of temp...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void setPointOfInstantiation(SourceLocation Loc)
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setExternKeywordLoc(SourceLocation Loc)
Sets the location of the extern keyword.
void setSpecializationKind(TemplateSpecializationKind TSK)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
SourceLocation getExternKeywordLoc() const
Gets the location of the extern keyword, if present.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this class template specialization is an instantiation of a template (rather than an explicit spec...
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this class template specialization is actually an instantiation of the given class template...
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
Complex values, per C99 6.2.5p11.
CompoundAssignOperator - For compound assignments (e.g.
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.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
SourceLocation getBeginLoc() const LLVM_READONLY
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
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()
void setInstantiatedFromMember(VarTemplatePartialSpecializationDecl *PartialSpec)
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
void setSpecializationKind(TemplateSpecializationKind TSK)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
void setPointOfInstantiation(SourceLocation Loc)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
VarTemplateSpecializationDecl * getMostRecentDecl()
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