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"
70 #include <type_traits>
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())
303 FoundFunction->
hasBody(Definition))
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>
702 template <
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();
721 Error 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);
750 std::get<1>(Result)))
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);
1027 template <
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();
1060 using 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 IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1083 case BuiltinType::Sampled##Id: \
1084 return Importer.getToContext().Sampled##SingletonId;
1085 #define IMAGE_WRITE_TYPE(Type, Id, Ext)
1086 #define IMAGE_READ_WRITE_TYPE(Type, Id, Ext)
1087 #include "clang/Basic/OpenCLImageTypes.def"
1088 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1089 case BuiltinType::Id: \
1090 return Importer.getToContext().Id##Ty;
1091 #include "clang/Basic/OpenCLExtensionTypes.def"
1092 #define SVE_TYPE(Name, Id, SingletonId) \
1093 case BuiltinType::Id: \
1094 return Importer.getToContext().SingletonId;
1095 #include "clang/Basic/AArch64SVEACLETypes.def"
1096 #define PPC_VECTOR_TYPE(Name, Id, Size) \
1097 case BuiltinType::Id: \
1098 return Importer.getToContext().Id##Ty;
1099 #include "clang/Basic/PPCTypes.def"
1100 #define RVV_TYPE(Name, Id, SingletonId) \
1101 case BuiltinType::Id: \
1102 return Importer.getToContext().SingletonId;
1103 #include "clang/Basic/RISCVVTypes.def"
1104 #define WASM_TYPE(Name, Id, SingletonId) \
1105 case BuiltinType::Id: \
1106 return Importer.getToContext().SingletonId;
1107 #include "clang/Basic/WebAssemblyReferenceTypes.def"
1108 #define SHARED_SINGLETON_TYPE(Expansion)
1109 #define BUILTIN_TYPE(Id, SingletonId) \
1110 case BuiltinType::Id: return Importer.getToContext().SingletonId;
1111 #include "clang/AST/BuiltinTypes.def"
1119 case BuiltinType::Char_U:
1128 case BuiltinType::Char_S:
1137 case BuiltinType::WChar_S:
1138 case BuiltinType::WChar_U:
1144 llvm_unreachable(
"Invalid BuiltinType Kind!");
1148 ExpectedType ToOriginalTypeOrErr =
import(
T->getOriginalType());
1149 if (!ToOriginalTypeOrErr)
1150 return ToOriginalTypeOrErr.takeError();
1156 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1157 if (!ToElementTypeOrErr)
1158 return ToElementTypeOrErr.takeError();
1165 if (!ToPointeeTypeOrErr)
1166 return ToPointeeTypeOrErr.takeError();
1174 if (!ToPointeeTypeOrErr)
1175 return ToPointeeTypeOrErr.takeError();
1183 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1184 if (!ToPointeeTypeOrErr)
1185 return ToPointeeTypeOrErr.takeError();
1193 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1194 if (!ToPointeeTypeOrErr)
1195 return ToPointeeTypeOrErr.takeError();
1204 if (!ToPointeeTypeOrErr)
1205 return ToPointeeTypeOrErr.takeError();
1208 if (!ClassTypeOrErr)
1209 return ClassTypeOrErr.takeError();
1217 Error Err = Error::success();
1221 return std::move(Err);
1224 ToElementType,
T->getSize(), ToSizeExpr,
T->getSizeModifier(),
1225 T->getIndexTypeCVRQualifiers());
1231 if (!ToArrayTypeOrErr)
1232 return ToArrayTypeOrErr.takeError();
1239 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1240 if (!ToElementTypeOrErr)
1241 return ToElementTypeOrErr.takeError();
1244 T->getSizeModifier(),
1245 T->getIndexTypeCVRQualifiers());
1250 Error Err = Error::success();
1255 return std::move(Err);
1257 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1258 T->getIndexTypeCVRQualifiers(), ToBracketsRange);
1261 ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(
1263 Error Err = Error::success();
1268 return std::move(Err);
1273 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1274 T->getIndexTypeCVRQualifiers(), ToBracketsRange);
1277 ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType(
1279 Error Err = Error::success();
1284 return std::move(Err);
1286 ToElementType, ToSizeExpr, ToAttrLoc);
1290 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1291 if (!ToElementTypeOrErr)
1292 return ToElementTypeOrErr.takeError();
1295 T->getNumElements(),
1296 T->getVectorKind());
1300 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1301 if (!ToElementTypeOrErr)
1302 return ToElementTypeOrErr.takeError();
1305 T->getNumElements());
1313 if (!ToReturnTypeOrErr)
1314 return ToReturnTypeOrErr.takeError();
1323 if (!ToReturnTypeOrErr)
1324 return ToReturnTypeOrErr.takeError();
1331 return TyOrErr.takeError();
1332 ArgTypes.push_back(*TyOrErr);
1340 return TyOrErr.takeError();
1341 ExceptionTypes.push_back(*TyOrErr);
1345 Error Err = Error::success();
1362 return std::move(Err);
1365 *ToReturnTypeOrErr, ArgTypes, ToEPI);
1368 ExpectedType ASTNodeImporter::VisitUnresolvedUsingType(
1370 Error Err = Error::success();
1372 auto ToPrevD =
importChecked(Err,
T->getDecl()->getPreviousDecl());
1374 return std::move(Err);
1377 ToD, cast_or_null<TypeDecl>(ToPrevD));
1382 if (!ToInnerTypeOrErr)
1383 return ToInnerTypeOrErr.takeError();
1393 return Pattern.takeError();
1396 return Index.takeError();
1403 return ToDeclOrErr.takeError();
1410 if (!ToUnderlyingTypeOrErr)
1411 return ToUnderlyingTypeOrErr.takeError();
1419 return ToExprOrErr.takeError();
1424 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnmodifiedType());
1425 if (!ToUnderlyingTypeOrErr)
1426 return ToUnderlyingTypeOrErr.takeError();
1434 return FoundOrErr.takeError();
1436 if (!UnderlyingOrErr)
1437 return UnderlyingOrErr.takeError();
1446 return ToExprOrErr.takeError();
1448 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1449 if (!ToUnderlyingTypeOrErr)
1450 return ToUnderlyingTypeOrErr.takeError();
1453 *ToExprOrErr, *ToUnderlyingTypeOrErr);
1459 if (!ToBaseTypeOrErr)
1460 return ToBaseTypeOrErr.takeError();
1462 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1463 if (!ToUnderlyingTypeOrErr)
1464 return ToUnderlyingTypeOrErr.takeError();
1467 *ToBaseTypeOrErr, *ToUnderlyingTypeOrErr,
T->getUTTKind());
1472 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1473 if (!ToDeducedTypeOrErr)
1474 return ToDeducedTypeOrErr.takeError();
1476 ExpectedDecl ToTypeConstraintConcept =
import(
T->getTypeConstraintConcept());
1477 if (!ToTypeConstraintConcept)
1478 return ToTypeConstraintConcept.takeError();
1483 return std::move(Err);
1486 *ToDeducedTypeOrErr,
T->getKeyword(),
false,
1487 false, cast_or_null<ConceptDecl>(*ToTypeConstraintConcept),
1491 ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
1495 if (!ToTemplateNameOrErr)
1496 return ToTemplateNameOrErr.takeError();
1497 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1498 if (!ToDeducedTypeOrErr)
1499 return ToDeducedTypeOrErr.takeError();
1505 ExpectedType ASTNodeImporter::VisitInjectedClassNameType(
1509 return ToDeclOrErr.takeError();
1513 const Type *Ty = (*ToDeclOrErr)->getTypeForDecl();
1514 assert(Ty && isa<InjectedClassNameType>(Ty));
1521 return ToDeclOrErr.takeError();
1529 return ToDeclOrErr.takeError();
1535 ExpectedType ToModifiedTypeOrErr =
import(
T->getModifiedType());
1536 if (!ToModifiedTypeOrErr)
1537 return ToModifiedTypeOrErr.takeError();
1538 ExpectedType ToEquivalentTypeOrErr =
import(
T->getEquivalentType());
1539 if (!ToEquivalentTypeOrErr)
1540 return ToEquivalentTypeOrErr.takeError();
1543 *ToModifiedTypeOrErr, *ToEquivalentTypeOrErr);
1549 if (!ToWrappedTypeOrErr)
1550 return ToWrappedTypeOrErr.takeError();
1552 Error Err = Error::success();
1556 for (
auto TI :
T->dependent_decls()) {
1559 return ToDeclOrErr.takeError();
1560 CoupledDecls.emplace_back(*ToDeclOrErr, TI.isDeref());
1564 *ToWrappedTypeOrErr, CountExpr,
T->isCountInBytes(),
T->isOrNull(),
1565 ArrayRef(CoupledDecls.data(), CoupledDecls.size()));
1568 ExpectedType ASTNodeImporter::VisitTemplateTypeParmType(
1572 return ToDeclOrErr.takeError();
1575 T->getDepth(),
T->getIndex(),
T->isParameterPack(), *ToDeclOrErr);
1578 ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmType(
1582 return ReplacedOrErr.takeError();
1584 ExpectedType ToReplacementTypeOrErr =
import(
T->getReplacementType());
1585 if (!ToReplacementTypeOrErr)
1586 return ToReplacementTypeOrErr.takeError();
1589 *ToReplacementTypeOrErr, *ReplacedOrErr,
T->getIndex(),
1593 ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmPackType(
1597 return ReplacedOrErr.takeError();
1600 if (!ToArgumentPack)
1601 return ToArgumentPack.takeError();
1604 *ReplacedOrErr,
T->getIndex(),
T->getFinal(), *ToArgumentPack);
1607 ExpectedType ASTNodeImporter::VisitTemplateSpecializationType(
1609 auto ToTemplateOrErr =
import(
T->getTemplateName());
1610 if (!ToTemplateOrErr)
1611 return ToTemplateOrErr.takeError();
1616 return std::move(Err);
1623 ToCanonType = *TyOrErr;
1625 return TyOrErr.takeError();
1634 auto ToQualifierOrErr =
import(
T->getQualifier());
1635 if (!ToQualifierOrErr)
1636 return ToQualifierOrErr.takeError();
1639 if (!ToNamedTypeOrErr)
1640 return ToNamedTypeOrErr.takeError();
1643 if (!ToOwnedTagDeclOrErr)
1644 return ToOwnedTagDeclOrErr.takeError();
1649 *ToOwnedTagDeclOrErr);
1655 if (!ToPatternOrErr)
1656 return ToPatternOrErr.takeError();
1659 T->getNumExpansions(),
1663 ExpectedType ASTNodeImporter::VisitDependentTemplateSpecializationType(
1665 auto ToQualifierOrErr =
import(
T->getQualifier());
1666 if (!ToQualifierOrErr)
1667 return ToQualifierOrErr.takeError();
1672 ToPack.reserve(
T->template_arguments().size());
1674 return std::move(Err);
1677 T->getKeyword(), *ToQualifierOrErr, ToName, ToPack);
1682 auto ToQualifierOrErr =
import(
T->getQualifier());
1683 if (!ToQualifierOrErr)
1684 return ToQualifierOrErr.takeError();
1693 return TyOrErr.takeError();
1705 return ToDeclOrErr.takeError();
1712 if (!ToBaseTypeOrErr)
1713 return ToBaseTypeOrErr.takeError();
1716 for (
auto TypeArg :
T->getTypeArgsAsWritten()) {
1718 TypeArgs.push_back(*TyOrErr);
1720 return TyOrErr.takeError();
1724 for (
auto *
P :
T->quals()) {
1726 Protocols.push_back(*ProtocolOrErr);
1728 return ProtocolOrErr.takeError();
1734 T->isKindOfTypeAsWritten());
1740 if (!ToPointeeTypeOrErr)
1741 return ToPointeeTypeOrErr.takeError();
1748 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1749 if (!ToUnderlyingTypeOrErr)
1750 return ToUnderlyingTypeOrErr.takeError();
1758 Error Err = Error::success();
1759 QualType ToOriginalType = importChecked(Err,
T->getOriginalType());
1760 QualType ToAdjustedType = importChecked(Err,
T->getAdjustedType());
1762 return std::move(Err);
1764 return Importer.getToContext().getAdjustedType(ToOriginalType,
1769 return Importer.getToContext().getBitIntType(
T->isUnsigned(),
1773 ExpectedType clang::ASTNodeImporter::VisitBTFTagAttributedType(
1775 Error Err = Error::success();
1776 const BTFTypeTagAttr *ToBTFAttr = importChecked(Err,
T->getAttr());
1777 QualType ToWrappedType = importChecked(Err,
T->getWrappedType());
1779 return std::move(Err);
1781 return Importer.getToContext().getBTFTagAttributedType(ToBTFAttr,
1785 ExpectedType clang::ASTNodeImporter::VisitConstantMatrixType(
1787 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1788 if (!ToElementTypeOrErr)
1789 return ToElementTypeOrErr.takeError();
1791 return Importer.getToContext().getConstantMatrixType(
1792 *ToElementTypeOrErr,
T->getNumRows(),
T->getNumColumns());
1795 ExpectedType clang::ASTNodeImporter::VisitDependentAddressSpaceType(
1797 Error Err = Error::success();
1799 Expr *ToAddrSpaceExpr = importChecked(Err,
T->getAddrSpaceExpr());
1802 return std::move(Err);
1804 return Importer.getToContext().getDependentAddressSpaceType(
1805 ToPointeeType, ToAddrSpaceExpr, ToAttrLoc);
1808 ExpectedType clang::ASTNodeImporter::VisitDependentBitIntType(
1810 ExpectedExpr ToNumBitsExprOrErr =
import(
T->getNumBitsExpr());
1811 if (!ToNumBitsExprOrErr)
1812 return ToNumBitsExprOrErr.takeError();
1813 return Importer.getToContext().getDependentBitIntType(
T->isUnsigned(),
1814 *ToNumBitsExprOrErr);
1817 ExpectedType clang::ASTNodeImporter::VisitDependentSizedMatrixType(
1819 Error Err = Error::success();
1820 QualType ToElementType = importChecked(Err,
T->getElementType());
1821 Expr *ToRowExpr = importChecked(Err,
T->getRowExpr());
1822 Expr *ToColumnExpr = importChecked(Err,
T->getColumnExpr());
1825 return std::move(Err);
1827 return Importer.getToContext().getDependentSizedMatrixType(
1828 ToElementType, ToRowExpr, ToColumnExpr, ToAttrLoc);
1831 ExpectedType clang::ASTNodeImporter::VisitDependentVectorType(
1833 Error Err = Error::success();
1834 QualType ToElementType = importChecked(Err,
T->getElementType());
1835 Expr *ToSizeExpr = importChecked(Err,
T->getSizeExpr());
1838 return std::move(Err);
1840 return Importer.getToContext().getDependentVectorType(
1841 ToElementType, ToSizeExpr, ToAttrLoc,
T->getVectorKind());
1844 ExpectedType clang::ASTNodeImporter::VisitObjCTypeParamType(
1848 return ToDeclOrErr.takeError();
1853 if (!ToProtocolOrErr)
1854 return ToProtocolOrErr.takeError();
1855 ToProtocols.push_back(*ToProtocolOrErr);
1858 return Importer.getToContext().getObjCTypeParamType(*ToDeclOrErr,
1863 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1864 if (!ToElementTypeOrErr)
1865 return ToElementTypeOrErr.takeError();
1868 if (
T->isReadOnly())
1888 if (isa<RecordDecl>(D) && (FunDecl = dyn_cast<FunctionDecl>(OrigDC)) &&
1890 auto getLeafPointeeType = [](
const Type *
T) {
1898 getLeafPointeeType(
P->getType().getCanonicalType().getTypePtr());
1899 auto *RT = dyn_cast<RecordType>(LeafT);
1900 if (RT && RT->getDecl() == D) {
1913 if (Error Err = importInto(Name, D->
getDeclName()))
1922 if (Error Err =
ASTNodeImporter(*this).ImportDefinitionIfNeeded(D, ToD))
1925 return Error::success();
1932 if (Error Err = importInto(Name, D->
getDeclName()))
1941 if (Error Err =
ASTNodeImporter(*this).ImportDefinitionIfNeeded(D, ToD))
1944 return Error::success();
1949 return Error::success();
1952 if (Error Err = importInto(ToD, FromD))
1955 if (
RecordDecl *FromRecord = dyn_cast<RecordDecl>(FromD)) {
1956 if (
RecordDecl *ToRecord = cast<RecordDecl>(ToD)) {
1957 if (FromRecord->getDefinition() && FromRecord->isCompleteDefinition() &&
1958 !ToRecord->getDefinition()) {
1963 return Error::success();
1966 if (
EnumDecl *FromEnum = dyn_cast<EnumDecl>(FromD)) {
1967 if (
EnumDecl *ToEnum = cast<EnumDecl>(ToD)) {
1968 if (FromEnum->getDefinition() && !ToEnum->getDefinition()) {
1973 return Error::success();
1976 return Error::success();
1991 return Error::success();
1997 return ToRangeOrErr.takeError();
1998 return Error::success();
2004 return LocOrErr.takeError();
2005 return Error::success();
2013 return ToTInfoOrErr.takeError();
2014 return Error::success();
2017 llvm_unreachable(
"Unknown name kind.");
2024 return ToDCOrErr.takeError();
2038 auto MightNeedReordering = [](
const Decl *D) {
2039 return isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D) || isa<FriendDecl>(D);
2043 Error ChildErrors = Error::success();
2044 for (
auto *From : FromDC->
decls()) {
2045 if (!MightNeedReordering(From))
2054 if (!ImportedOrErr) {
2056 ImportedOrErr.takeError());
2059 FieldDecl *FieldFrom = dyn_cast_or_null<FieldDecl>(From);
2060 Decl *ImportedDecl = *ImportedOrErr;
2061 FieldDecl *FieldTo = dyn_cast_or_null<FieldDecl>(ImportedDecl);
2062 if (FieldFrom && FieldTo) {
2094 consumeError(std::move(ChildErrors));
2095 return ToDCOrErr.takeError();
2098 if (
const auto *FromRD = dyn_cast<RecordDecl>(FromDC)) {
2102 for (
auto *D : FromRD->decls()) {
2103 if (!MightNeedReordering(D))
2106 assert(D &&
"DC contains a null decl");
2109 assert(ToDC == ToD->getLexicalDeclContext() && ToDC->
containsDecl(ToD));
2121 for (
auto *From : FromDC->
decls()) {
2122 if (MightNeedReordering(From))
2128 ImportedOrErr.takeError());
2148 if (!FromRecordDecl || !ToRecordDecl) {
2152 if (RecordFrom && RecordTo) {
2153 FromRecordDecl = RecordFrom->
getDecl();
2154 ToRecordDecl = RecordTo->getDecl();
2158 if (FromRecordDecl && ToRecordDecl) {
2164 return Error::success();
2171 return ToDCOrErr.takeError();
2177 if (!ToLexicalDCOrErr)
2178 return ToLexicalDCOrErr.takeError();
2179 ToLexicalDC = *ToLexicalDCOrErr;
2183 return Error::success();
2189 "Import implicit methods to or from non-definition");
2192 if (FromM->isImplicit()) {
2195 return ToMOrErr.takeError();
2198 return Error::success();
2207 return ToTypedefOrErr.takeError();
2209 return Error::success();
2214 auto DefinitionCompleter = [To]() {
2233 auto *FromCXXRD = cast<CXXRecordDecl>(From);
2235 ToCaptures.reserve(FromCXXRD->capture_size());
2236 for (
const auto &FromCapture : FromCXXRD->captures()) {
2237 if (
auto ToCaptureOrErr =
import(FromCapture))
2238 ToCaptures.push_back(*ToCaptureOrErr);
2240 return ToCaptureOrErr.takeError();
2242 cast<CXXRecordDecl>(To)->setCaptures(Importer.
getToContext(),
2249 DefinitionCompleter();
2253 return Error::success();
2268 auto DefinitionCompleterScopeExit =
2269 llvm::make_scope_exit(DefinitionCompleter);
2275 auto *ToCXX = dyn_cast<CXXRecordDecl>(To);
2276 auto *FromCXX = dyn_cast<CXXRecordDecl>(From);
2277 if (ToCXX && FromCXX && ToCXX->dataPtr() && FromCXX->dataPtr()) {
2279 struct CXXRecordDecl::DefinitionData &ToData = ToCXX->data();
2280 struct CXXRecordDecl::DefinitionData &FromData = FromCXX->data();
2282 #define FIELD(Name, Width, Merge) \
2283 ToData.Name = FromData.Name;
2284 #include "clang/AST/CXXRecordDeclDefinitionBits.def"
2287 ToCXX->setArgPassingRestrictions(FromCXX->getArgPassingRestrictions());
2290 for (
const auto &Base1 : FromCXX->bases()) {
2293 return TyOrErr.takeError();
2296 if (Base1.isPackExpansion()) {
2297 if (
ExpectedSLoc LocOrErr =
import(Base1.getEllipsisLoc()))
2298 EllipsisLoc = *LocOrErr;
2300 return LocOrErr.takeError();
2308 auto RangeOrErr =
import(Base1.getSourceRange());
2310 return RangeOrErr.takeError();
2312 auto TSIOrErr =
import(Base1.getTypeSourceInfo());
2314 return TSIOrErr.takeError();
2320 Base1.isBaseOfClass(),
2321 Base1.getAccessSpecifierAsWritten(),
2326 ToCXX->setBases(Bases.data(), Bases.size());
2334 return Error::success();
2339 return Error::success();
2343 return Error::success();
2347 return ToInitOrErr.takeError();
2358 return Error::success();
2366 return Error::success();
2377 return ToTypeOrErr.takeError();
2380 if (!ToPromotionTypeOrErr)
2381 return ToPromotionTypeOrErr.takeError();
2392 return Error::success();
2398 for (
const auto &Arg : FromArgs) {
2399 if (
auto ToOrErr =
import(Arg))
2400 ToArgs.push_back(*ToOrErr);
2402 return ToOrErr.takeError();
2405 return Error::success();
2411 return import(From);
2414 template <
typename InContainerTy>
2417 for (
const auto &FromLoc : Container) {
2418 if (
auto ToLocOrErr =
import(FromLoc))
2421 return ToLocOrErr.takeError();
2423 return Error::success();
2433 bool IgnoreTemplateParmDepth) {
2444 false, Complain,
false,
2445 IgnoreTemplateParmDepth);
2465 return std::move(Err);
2470 return LocOrErr.takeError();
2473 if (GetImportedOrCreateDecl(ToD, D, Importer.
getToContext(), DC, *LocOrErr))
2496 return std::move(Err);
2502 Name.getAsIdentifierInfo()))
2505 Error Err = Error::success();
2510 return std::move(Err);
2514 addDeclToContexts(D, ToD);
2522 return LocOrErr.takeError();
2525 return ColonLocOrErr.takeError();
2530 return DCOrErr.takeError();
2535 DC, *LocOrErr, *ColonLocOrErr))
2549 return DCOrErr.takeError();
2553 Error Err = Error::success();
2559 return std::move(Err);
2562 if (GetImportedOrCreateDecl(
2563 ToD, D, Importer.
getToContext(), DC, ToLocation, ToAssertExpr, ToMessage,
2579 return std::move(Err);
2588 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2594 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2595 for (
auto *FoundDecl : FoundDecls) {
2599 if (
auto *FoundNS = dyn_cast<NamespaceDecl>(FoundDecl)) {
2600 MergeWithNamespace = FoundNS;
2601 ConflictingDecls.clear();
2605 ConflictingDecls.push_back(FoundDecl);
2608 if (!ConflictingDecls.empty()) {
2611 ConflictingDecls.size());
2613 Name = NameOrErr.get();
2615 return NameOrErr.takeError();
2621 return BeginLocOrErr.takeError();
2623 if (!RBraceLocOrErr)
2624 return RBraceLocOrErr.takeError();
2629 if (GetImportedOrCreateDecl(ToNamespace, D, Importer.
getToContext(), DC,
2631 Name.getAsIdentifierInfo(),
2641 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2642 TU->setAnonymousNamespace(ToNamespace);
2644 cast<NamespaceDecl>(DC)->setAnonymousNamespace(ToNamespace);
2650 return std::move(Err);
2662 return std::move(Err);
2668 Error Err = Error::success();
2675 return std::move(Err);
2680 if (GetImportedOrCreateDecl(
2681 ToD, D, Importer.
getToContext(), DC, ToNamespaceLoc, ToAliasLoc,
2682 ToIdentifier, ToQualifierLoc, ToTargetNameLoc, ToNamespace))
2700 return std::move(Err);
2719 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2720 for (
auto *FoundDecl : FoundDecls) {
2723 if (
auto *FoundTypedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
2728 QualType FoundUT = FoundTypedef->getUnderlyingType();
2742 if (FromR && FoundR &&
2753 ConflictingDecls.push_back(FoundDecl);
2758 if (!ConflictingDecls.empty()) {
2760 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
2762 Name = NameOrErr.get();
2764 return NameOrErr.takeError();
2768 Error Err = Error::success();
2773 return std::move(Err);
2780 if (GetImportedOrCreateDecl<TypeAliasDecl>(
2782 Name.getAsIdentifierInfo(), ToTypeSourceInfo))
2784 }
else if (GetImportedOrCreateDecl<TypedefDecl>(
2786 Name.getAsIdentifierInfo(), ToTypeSourceInfo))
2791 return std::move(Err);
2795 Importer.AddToLookupTable(ToTypedef);
2800 TypeAliasDecl *FromAlias = IsAlias ? cast<TypeAliasDecl>(D) :
nullptr;
2823 return std::move(Err);
2833 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2834 for (
auto *FoundDecl : FoundDecls) {
2837 if (
auto *FoundAlias = dyn_cast<TypeAliasTemplateDecl>(FoundDecl)) {
2840 ConflictingDecls.push_back(FoundDecl);
2844 if (!ConflictingDecls.empty()) {
2846 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
2848 Name = NameOrErr.get();
2850 return NameOrErr.takeError();
2854 Error Err = Error::success();
2858 return std::move(Err);
2861 if (GetImportedOrCreateDecl(ToAlias, D, Importer.
getToContext(), DC,
Loc,
2862 Name, ToTemplateParameters, ToTemplatedDecl))
2865 ToTemplatedDecl->setDescribedAliasTemplate(ToAlias);
2871 updateLookupTableForTemplateParameters(*ToTemplateParameters);
2882 return std::move(Err);
2892 return BeginLocOrErr.takeError();
2893 if (GetImportedOrCreateDecl(ToLabel, D, Importer.
getToContext(), DC,
Loc,
2894 Name.getAsIdentifierInfo(), *BeginLocOrErr))
2898 if (GetImportedOrCreateDecl(ToLabel, D, Importer.
getToContext(), DC,
Loc,
2899 Name.getAsIdentifierInfo()))
2906 return ToStmtOrErr.takeError();
2908 ToLabel->
setStmt(*ToStmtOrErr);
2921 return std::move(Err);
2929 if (
Error Err = importInto(
2931 return std::move(Err);
2941 Importer.findDeclsInToCtx(DC, SearchName);
2942 for (
auto *FoundDecl : FoundDecls) {
2946 if (
auto *Typedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
2947 if (
const auto *Tag = Typedef->getUnderlyingType()->getAs<
TagType>())
2948 FoundDecl = Tag->getDecl();
2951 if (
auto *FoundEnum = dyn_cast<EnumDecl>(FoundDecl)) {
2961 ConflictingDecls.push_back(FoundDecl);
2965 if (!ConflictingDecls.empty()) {
2967 SearchName, DC, IDNS, ConflictingDecls.data(),
2968 ConflictingDecls.size());
2970 Name = NameOrErr.get();
2972 return NameOrErr.takeError();
2976 Error Err = Error::success();
2982 return std::move(Err);
2986 if (GetImportedOrCreateDecl(
2988 Loc, Name.getAsIdentifierInfo(), PrevDecl, D->
isScoped(),
2997 addDeclToContexts(D, D2);
3003 D2->setInstantiationOfMemberEnum(*ToInstOrErr, SK);
3005 return ToInstOrErr.takeError();
3006 if (
ExpectedSLoc POIOrErr =
import(MemberInfo->getPointOfInstantiation()))
3009 return POIOrErr.takeError();
3015 return std::move(Err);
3021 bool IsFriendTemplate =
false;
3022 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3024 DCXX->getDescribedClassTemplate() &&
3025 DCXX->getDescribedClassTemplate()->getFriendObjectKind() !=
3035 return std::move(Err);
3043 if (
Error Err = importInto(
3045 return std::move(Err);
3052 bool DependentFriend = IsFriendTemplate && IsDependentContext;
3059 Importer.findDeclsInToCtx(DC, SearchName);
3060 if (!FoundDecls.empty()) {
3067 for (
auto *FoundDecl : FoundDecls) {
3071 Decl *Found = FoundDecl;
3072 if (
auto *Typedef = dyn_cast<TypedefNameDecl>(Found)) {
3073 if (
const auto *Tag = Typedef->getUnderlyingType()->getAs<
TagType>())
3074 Found = Tag->getDecl();
3077 if (
auto *FoundRecord = dyn_cast<RecordDecl>(Found)) {
3100 if (
const auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3101 auto *FoundCXX = dyn_cast<CXXRecordDecl>(FoundDef);
3102 assert(FoundCXX &&
"Record type mismatch");
3108 return std::move(Err);
3114 ConflictingDecls.push_back(FoundDecl);
3118 if (!ConflictingDecls.empty() && SearchName) {
3120 SearchName, DC, IDNS, ConflictingDecls.data(),
3121 ConflictingDecls.size());
3123 Name = NameOrErr.get();
3125 return NameOrErr.takeError();
3131 return BeginLocOrErr.takeError();
3136 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3137 if (DCXX->isLambda()) {
3138 auto TInfoOrErr =
import(DCXX->getLambdaTypeInfo());
3140 return TInfoOrErr.takeError();
3141 if (GetImportedOrCreateSpecialDecl(
3143 DC, *TInfoOrErr,
Loc, DCXX->getLambdaDependencyKind(),
3144 DCXX->isGenericLambda(), DCXX->getLambdaCaptureDefault()))
3149 return CDeclOrErr.takeError();
3152 }
else if (DCXX->isInjectedClassName()) {
3155 const bool DelayTypeCreation =
true;
3156 if (GetImportedOrCreateDecl(
3158 *BeginLocOrErr,
Loc, Name.getAsIdentifierInfo(),
3159 cast_or_null<CXXRecordDecl>(PrevDecl), DelayTypeCreation))
3162 D2CXX, dyn_cast<CXXRecordDecl>(DC));
3164 if (GetImportedOrCreateDecl(D2CXX, D, Importer.
getToContext(),
3166 Name.getAsIdentifierInfo(),
3167 cast_or_null<CXXRecordDecl>(PrevDecl)))
3174 addDeclToContexts(D, D2);
3177 DCXX->getDescribedClassTemplate()) {
3179 if (
Error Err = importInto(ToDescribed, FromDescribed))
3180 return std::move(Err);
3182 if (!DCXX->isInjectedClassName() && !IsFriendTemplate) {
3189 auto *
Record = dyn_cast<CXXRecordDecl>(Found);
3202 const Type *FrontTy =
3203 cast<CXXRecordDecl>(Redecls.front())->getTypeForDecl();
3206 InjSpec = InjTy->getInjectedSpecializationType();
3209 for (
auto *R : Redecls) {
3210 auto *RI = cast<CXXRecordDecl>(R);
3211 if (R != Redecls.front() ||
3212 !isa<InjectedClassNameType>(RI->getTypeForDecl()))
3213 RI->setTypeForDecl(
nullptr);
3228 DCXX->getMemberSpecializationInfo()) {
3230 MemberInfo->getTemplateSpecializationKind();
3236 return ToInstOrErr.takeError();
3239 import(MemberInfo->getPointOfInstantiation()))
3243 return POIOrErr.takeError();
3247 if (GetImportedOrCreateDecl(D2, D, Importer.
getToContext(),
3249 Name.getAsIdentifierInfo(), PrevDecl))
3252 addDeclToContexts(D, D2);
3258 return BraceRangeOrErr.takeError();
3262 return QualifierLocOrErr.takeError();
3269 return std::move(Err);
3281 return std::move(Err);
3290 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3291 for (
auto *FoundDecl : FoundDecls) {
3295 if (
auto *FoundEnumConstant = dyn_cast<EnumConstantDecl>(FoundDecl)) {
3297 return Importer.
MapImported(D, FoundEnumConstant);
3298 ConflictingDecls.push_back(FoundDecl);
3302 if (!ConflictingDecls.empty()) {
3304 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3306 Name = NameOrErr.get();
3308 return NameOrErr.takeError();
3314 return TypeOrErr.takeError();
3318 return InitOrErr.takeError();
3321 if (GetImportedOrCreateDecl(
3323 Name.getAsIdentifierInfo(), *TypeOrErr, *InitOrErr, D->
getInitVal()))
3324 return ToEnumerator;
3329 return ToEnumerator;
3332 template <
typename DeclTy>
3335 unsigned int Num = FromD->getNumTemplateParameterLists();
3337 return Error::success();
3339 for (
unsigned int I = 0; I < Num; ++I)
3341 import(FromD->getTemplateParameterList(I)))
3342 ToTPLists[I] = *ToTPListOrErr;
3344 return ToTPListOrErr.takeError();
3345 ToD->setTemplateParameterListsInfo(Importer.ToContext, ToTPLists);
3346 return Error::success();
3354 return Error::success();
3360 return Error::success();
3366 ToFD->setInstantiationOfMemberFunction(*InstFDOrErr, TSK);
3368 return InstFDOrErr.takeError();
3374 return POIOrErr.takeError();
3376 return Error::success();
3380 auto FunctionAndArgsOrErr =
3382 if (!FunctionAndArgsOrErr)
3383 return FunctionAndArgsOrErr.takeError();
3386 Importer.
getToContext(), std::get<1>(*FunctionAndArgsOrErr));
3390 const auto *FromTAArgsAsWritten = FTSInfo->TemplateArgumentsAsWritten;
3391 if (FromTAArgsAsWritten)
3393 *FromTAArgsAsWritten, ToTAInfo))
3396 ExpectedSLoc POIOrErr =
import(FTSInfo->getPointOfInstantiation());
3398 return POIOrErr.takeError();
3404 ToFD->setFunctionTemplateSpecialization(
3405 std::get<0>(*FunctionAndArgsOrErr), ToTAList,
nullptr,
3406 TSK, FromTAArgsAsWritten ? &ToTAInfo :
nullptr, *POIOrErr);
3407 return Error::success();
3415 Candidates.
addDecl(*ToFTDOrErr);
3417 return ToFTDOrErr.takeError();
3422 const auto *FromTAArgsAsWritten = FromInfo->TemplateArgumentsAsWritten;
3423 if (FromTAArgsAsWritten)
3430 FromTAArgsAsWritten ? &ToTAInfo :
nullptr);
3431 return Error::success();
3434 llvm_unreachable(
"All cases should be covered!");
3439 auto FunctionAndArgsOrErr =
3441 if (!FunctionAndArgsOrErr)
3442 return FunctionAndArgsOrErr.takeError();
3446 std::tie(Template, ToTemplArgs) = *FunctionAndArgsOrErr;
3447 void *InsertPos =
nullptr;
3458 return ToBodyOrErr.takeError();
3460 return Error::success();
3466 const DeclContext *DCi = dyn_cast<DeclContext>(D);
3469 assert(DCi &&
"Declaration should have a context");
3483 ToProcess.push_back(S);
3484 while (!ToProcess.empty()) {
3485 const Stmt *CurrentS = ToProcess.pop_back_val();
3487 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(CurrentS)) {
3488 if (
const Decl *D = DeclRef->getDecl())
3491 }
else if (
const auto *E =
3492 dyn_cast_or_null<SubstNonTypeTemplateParmExpr>(CurrentS)) {
3493 if (
const Decl *D = E->getAssociatedDecl())
3526 class IsTypeDeclaredInsideVisitor
3527 :
public TypeVisitor<IsTypeDeclaredInsideVisitor, std::optional<bool>> {
3529 IsTypeDeclaredInsideVisitor(
const FunctionDecl *ParentDC)
3530 : ParentDC(ParentDC) {}
3536 if (std::optional<bool> Res = Visit(
T.getTypePtr()))
3539 T.getSingleStepDesugaredType(ParentDC->getParentASTContext());
3541 if (std::optional<bool> Res = Visit(DsT.
getTypePtr()))
3544 DsT =
T.getSingleStepDesugaredType(ParentDC->getParentASTContext());
3549 std::optional<bool> VisitTagType(
const TagType *
T) {
3550 if (
auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(
T->getDecl()))
3551 for (
const auto &Arg : Spec->getTemplateArgs().asArray())
3552 if (checkTemplateArgument(Arg))
3557 std::optional<bool> VisitPointerType(
const PointerType *
T) {
3562 return CheckType(
T->getPointeeTypeAsWritten());
3565 std::optional<bool> VisitTypedefType(
const TypedefType *
T) {
3571 std::optional<bool> VisitUsingType(
const UsingType *
T) {
3572 if (
T->getFoundDecl() &&
3581 for (
const auto &Arg :
T->template_arguments())
3582 if (checkTemplateArgument(Arg))
3600 return CheckType(
T->getElementType());
3605 "Variable array should not occur in deduced return type of a function");
3609 llvm_unreachable(
"Incomplete array should not occur in deduced return type "
3614 llvm_unreachable(
"Dependent array should not occur in deduced return type "
3641 if (checkTemplateArgument(PackArg))
3653 llvm_unreachable(
"Unknown TemplateArgument::ArgKind enum");
3663 assert(FromFPT &&
"Must be called on FunctionProtoType");
3665 auto IsCXX11LambdaWithouTrailingReturn = [&]() {
3666 if (Importer.FromContext.
getLangOpts().CPlusPlus14)
3669 if (FromFPT->hasTrailingReturn())
3672 if (
const auto *MD = dyn_cast<CXXMethodDecl>(D))
3673 return cast<CXXRecordDecl>(MD->getDeclContext())->isLambda();
3678 QualType RetT = FromFPT->getReturnType();
3679 if (isa<AutoType>(RetT.
getTypePtr()) || IsCXX11LambdaWithouTrailingReturn()) {
3681 IsTypeDeclaredInsideVisitor Visitor(Def ? Def : D);
3682 return Visitor.CheckType(RetT);
3699 auto RedeclIt = Redecls.begin();
3702 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
3705 return ToRedeclOrErr.takeError();
3707 assert(*RedeclIt == D);
3715 return std::move(Err);
3730 if (!FoundFunctionOrErr)
3731 return FoundFunctionOrErr.takeError();
3732 if (
FunctionDecl *FoundFunction = *FoundFunctionOrErr) {
3733 if (
Decl *Def = FindAndMapDefinition(D, FoundFunction))
3735 FoundByLookup = FoundFunction;
3743 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3744 for (
auto *FoundDecl : FoundDecls) {
3748 if (
auto *FoundFunction = dyn_cast<FunctionDecl>(FoundDecl)) {
3753 if (
Decl *Def = FindAndMapDefinition(D, FoundFunction))
3755 FoundByLookup = FoundFunction;
3766 Importer.
ToDiag(
Loc, diag::warn_odr_function_type_inconsistent)
3767 << Name << D->
getType() << FoundFunction->getType();
3768 Importer.
ToDiag(FoundFunction->getLocation(), diag::note_odr_value_here)
3769 << FoundFunction->getType();
3770 ConflictingDecls.push_back(FoundDecl);
3774 if (!ConflictingDecls.empty()) {
3776 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3778 Name = NameOrErr.get();
3780 return NameOrErr.takeError();
3790 if (FoundByLookup) {
3791 if (isa<CXXMethodDecl>(FoundByLookup)) {
3800 "Templated function mapped to non-templated?");
3816 return std::move(Err);
3827 bool UsedDifferentProtoType =
false;
3829 QualType FromReturnTy = FromFPT->getReturnType();
3837 UsedDifferentProtoType =
true;
3848 FromEPI = DefaultEPI;
3849 UsedDifferentProtoType =
true;
3852 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
3857 Error Err = Error::success();
3864 auto TrailingRequiresClause =
3867 return std::move(Err);
3873 Parameters.push_back(*ToPOrErr);
3875 return ToPOrErr.takeError();
3880 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
3882 importExplicitSpecifier(Err, FromConstructor->getExplicitSpecifier());
3884 return std::move(Err);
3886 if (FromConstructor->isInheritingConstructor()) {
3888 import(FromConstructor->getInheritedConstructor());
3889 if (!ImportedInheritedCtor)
3890 return ImportedInheritedCtor.takeError();
3891 ToInheritedConstructor = *ImportedInheritedCtor;
3893 if (GetImportedOrCreateDecl<CXXConstructorDecl>(
3894 ToFunction, D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3895 ToInnerLocStart, NameInfo,
T, TInfo, ESpec, D->
UsesFPIntrin(),
3897 ToInheritedConstructor, TrailingRequiresClause))
3901 Error Err = Error::success();
3903 Err,
const_cast<FunctionDecl *
>(FromDtor->getOperatorDelete()));
3904 auto ToThisArg =
importChecked(Err, FromDtor->getOperatorDeleteThisArg());
3906 return std::move(Err);
3908 if (GetImportedOrCreateDecl<CXXDestructorDecl>(
3909 ToFunction, D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3912 TrailingRequiresClause))
3919 dyn_cast<CXXConversionDecl>(D)) {
3921 importExplicitSpecifier(Err, FromConversion->getExplicitSpecifier());
3923 return std::move(Err);
3924 if (GetImportedOrCreateDecl<CXXConversionDecl>(
3925 ToFunction, D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3930 }
else if (
auto *Method = dyn_cast<CXXMethodDecl>(D)) {
3931 if (GetImportedOrCreateDecl<CXXMethodDecl>(
3932 ToFunction, D, Importer.
getToContext(), cast<CXXRecordDecl>(DC),
3933 ToInnerLocStart, NameInfo,
T, TInfo, Method->getStorageClass(),
3934 Method->UsesFPIntrin(), Method->isInlineSpecified(),
3937 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(D)) {
3939 importExplicitSpecifier(Err, Guide->getExplicitSpecifier());
3943 return std::move(Err);
3944 if (GetImportedOrCreateDecl<CXXDeductionGuideDecl>(
3945 ToFunction, D, Importer.
getToContext(), DC, ToInnerLocStart, ESpec,
3946 NameInfo,
T, TInfo, ToEndLoc, Ctor))
3948 cast<CXXDeductionGuideDecl>(ToFunction)
3949 ->setDeductionCandidateKind(Guide->getDeductionCandidateKind());
3951 if (GetImportedOrCreateDecl(
3952 ToFunction, D, Importer.
getToContext(), DC, ToInnerLocStart,
3960 if (FoundByLookup) {
3973 auto Imported =
import(Msg);
3975 return Imported.takeError();
3999 for (
auto *Param : Parameters) {
4000 Param->setOwningFunction(ToFunction);
4005 ToFunction->setParams(Parameters);
4012 for (
unsigned I = 0, N = Parameters.size(); I != N; ++I)
4013 ProtoLoc.setParam(I, Parameters[I]);
4019 auto ToFTOrErr =
import(FromFT);
4021 return ToFTOrErr.takeError();
4025 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
4026 if (
unsigned NumInitializers = FromConstructor->getNumCtorInitializers()) {
4030 FromConstructor->inits(), CtorInitializers))
4031 return std::move(Err);
4034 std::copy(CtorInitializers.begin(), CtorInitializers.end(), Memory);
4035 auto *ToCtor = cast<CXXConstructorDecl>(ToFunction);
4036 ToCtor->setCtorInitializers(Memory);
4037 ToCtor->setNumCtorInitializers(NumInitializers);
4043 return std::move(Err);
4045 if (
auto *FromCXXMethod = dyn_cast<CXXMethodDecl>(D))
4048 return std::move(Err);
4054 return std::move(Err);
4058 if (UsedDifferentProtoType) {
4060 ToFunction->
setType(*TyOrErr);
4062 return TyOrErr.takeError();
4066 return TSIOrErr.takeError();
4071 addDeclToContexts(D, ToFunction);
4074 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4077 return ToRedeclOrErr.takeError();
4111 return std::move(Err);
4116 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4117 for (
auto *FoundDecl : FoundDecls) {
4118 if (
FieldDecl *FoundField = dyn_cast<FieldDecl>(FoundDecl)) {
4126 FoundField->getType())) {
4135 if (
ExpectedExpr ToInitializerOrErr =
import(FromInitializer)) {
4138 assert(FoundField->hasInClassInitializer() &&
4139 "Field should have an in-class initializer if it has an "
4140 "expression for it.");
4141 if (!FoundField->getInClassInitializer())
4142 FoundField->setInClassInitializer(*ToInitializerOrErr);
4144 return ToInitializerOrErr.takeError();
4151 Importer.
ToDiag(
Loc, diag::warn_odr_field_type_inconsistent)
4152 << Name << D->
getType() << FoundField->getType();
4153 Importer.
ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4154 << FoundField->getType();
4160 Error Err = Error::success();
4166 return std::move(Err);
4167 const Type *ToCapturedVLAType =
nullptr;
4170 return std::move(Err);
4173 if (GetImportedOrCreateDecl(ToField, D, Importer.
getToContext(), DC,
4174 ToInnerLocStart,
Loc, Name.getAsIdentifierInfo(),
4175 ToType, ToTInfo, ToBitWidth, D->
isMutable(),
4182 Err = Importer.ImportAttrs(ToField, D);
4184 return std::move(Err);
4188 if (ToCapturedVLAType)
4195 return std::move(Err);
4196 if (ToInitializer) {
4198 if (AlreadyImported)
4199 assert(ToInitializer == AlreadyImported &&
4200 "Duplicate import of in-class initializer.");
4215 return std::move(Err);
4220 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4221 for (
unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
4222 if (
auto *FoundField = dyn_cast<IndirectFieldDecl>(FoundDecls[I])) {
4230 FoundField->getType(),
4237 if (!Name && I < N-1)
4241 Importer.
ToDiag(
Loc, diag::warn_odr_field_type_inconsistent)
4242 << Name << D->
getType() << FoundField->getType();
4243 Importer.
ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4244 << FoundField->getType();
4251 auto TypeOrErr =
import(D->
getType());
4253 return TypeOrErr.takeError();
4259 for (
auto *PI : D->
chain())
4261 NamedChain[i++] = *ToD;
4263 return ToD.takeError();
4267 if (GetImportedOrCreateDecl(ToIndirectField, D, Importer.
getToContext(), DC,
4268 Loc, Name.getAsIdentifierInfo(), *TypeOrErr, CH))
4270 return ToIndirectField;
4275 return ToIndirectField;
4305 unsigned int FriendCount = 0;
4306 std::optional<unsigned int> FriendPosition;
4309 for (
FriendDecl *FoundFriend : RD->friends()) {
4310 if (FoundFriend == FD) {
4311 FriendPosition = FriendCount;
4318 assert(FriendPosition &&
"Friend decl not found in own parent.");
4320 return {FriendCount, *FriendPosition};
4327 return std::move(Err);
4332 const auto *RD = cast<CXXRecordDecl>(DC);
4334 for (
FriendDecl *ImportedFriend : RD->friends())
4336 ImportedEquivalentFriends.push_back(ImportedFriend);
4341 assert(ImportedEquivalentFriends.size() <= CountAndPosition.
TotalCount &&
4342 "Class with non-matching friends is imported, ODR check wrong?");
4343 if (ImportedEquivalentFriends.size() == CountAndPosition.
TotalCount)
4345 D, ImportedEquivalentFriends[CountAndPosition.
IndexOfDecl]);
4352 if (Error Err = importInto(ToFriendD, FriendD))
4353 return std::move(Err);
4364 return TSIOrErr.takeError();
4369 for (
unsigned I = 0; I < D->NumTPLists; I++) {
4370 if (
auto ListOrErr =
import(FromTPLists[I]))
4371 ToTPLists[I] = *ListOrErr;
4373 return ListOrErr.takeError();
4378 return LocationOrErr.takeError();
4380 if (!FriendLocOrErr)
4381 return FriendLocOrErr.takeError();
4384 if (GetImportedOrCreateDecl(FrD, D, Importer.
getToContext(), DC,
4385 *LocationOrErr, ToFU,
4386 *FriendLocOrErr, ToTPLists))
4402 return std::move(Err);
4407 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4408 for (
auto *FoundDecl : FoundDecls) {
4409 if (
ObjCIvarDecl *FoundIvar = dyn_cast<ObjCIvarDecl>(FoundDecl)) {
4411 FoundIvar->getType())) {
4416 Importer.
ToDiag(
Loc, diag::warn_odr_ivar_type_inconsistent)
4417 << Name << D->
getType() << FoundIvar->getType();
4418 Importer.
ToDiag(FoundIvar->getLocation(), diag::note_odr_value_here)
4419 << FoundIvar->getType();
4425 Error Err = Error::success();
4431 return std::move(Err);
4434 if (GetImportedOrCreateDecl(
4435 ToIvar, D, Importer.
getToContext(), cast<ObjCContainerDecl>(DC),
4436 ToInnerLocStart,
Loc, Name.getAsIdentifierInfo(),
4437 ToType, ToTypeSourceInfo,
4449 auto RedeclIt = Redecls.begin();
4452 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
4455 return RedeclOrErr.takeError();
4457 assert(*RedeclIt == D);
4465 return std::move(Err);
4471 VarDecl *FoundByLookup =
nullptr;
4475 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4476 for (
auto *FoundDecl : FoundDecls) {
4480 if (
auto *FoundVar = dyn_cast<VarDecl>(FoundDecl)) {
4484 FoundVar->getType())) {
4496 const VarDecl *FoundDInit =
nullptr;
4497 if (D->
getInit() && FoundVar->getAnyInitializer(FoundDInit))
4501 FoundByLookup = FoundVar;
4509 if (FoundArray && TArray) {
4510 if (isa<IncompleteArrayType>(FoundArray) &&
4511 isa<ConstantArrayType>(TArray)) {
4513 if (
auto TyOrErr =
import(D->
getType()))
4514 FoundVar->setType(*TyOrErr);
4516 return TyOrErr.takeError();
4518 FoundByLookup = FoundVar;
4520 }
else if (isa<IncompleteArrayType>(TArray) &&
4521 isa<ConstantArrayType>(FoundArray)) {
4522 FoundByLookup = FoundVar;
4527 Importer.
ToDiag(
Loc, diag::warn_odr_variable_type_inconsistent)
4528 << Name << D->
getType() << FoundVar->getType();
4529 Importer.
ToDiag(FoundVar->getLocation(), diag::note_odr_value_here)
4530 << FoundVar->getType();
4531 ConflictingDecls.push_back(FoundDecl);
4535 if (!ConflictingDecls.empty()) {
4537 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
4539 Name = NameOrErr.get();
4541 return NameOrErr.takeError();
4545 Error Err = Error::success();
4551 return std::move(Err);
4554 if (
auto *FromDecomp = dyn_cast<DecompositionDecl>(D)) {
4558 return std::move(Err);
4560 if (GetImportedOrCreateDecl(
4561 ToDecomp, FromDecomp, Importer.
getToContext(), DC, ToInnerLocStart,
4567 if (GetImportedOrCreateDecl(ToVar, D, Importer.
getToContext(), DC,
4568 ToInnerLocStart,
Loc,
4569 Name.getAsIdentifierInfo(), ToType,
4583 if (FoundByLookup) {
4592 return ToVTOrErr.takeError();
4599 return ToInstOrErr.takeError();
4600 if (
ExpectedSLoc POIOrErr =
import(MSI->getPointOfInstantiation()))
4603 return POIOrErr.takeError();
4607 return std::move(Err);
4612 addDeclToContexts(D, ToVar);
4615 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4618 return RedeclOrErr.takeError();
4629 Error Err = Error::success();
4634 return std::move(Err);
4638 if (GetImportedOrCreateDecl(ToParm, D, Importer.
getToContext(), DC,
4639 ToLocation, ToDeclName.getAsIdentifierInfo(),
4656 return ToDefArgOrErr.takeError();
4660 if (
auto ToDefArgOrErr =
import(FromParam->
getDefaultArg()))
4663 return ToDefArgOrErr.takeError();
4666 return Error::success();
4671 Error Err = Error::success();
4676 return std::move(Err);
4685 Error Err = Error::success();
4692 return std::move(Err);
4695 if (GetImportedOrCreateDecl(ToParm, D, Importer.
getToContext(), DC,
4696 ToInnerLocStart, ToLocation,
4697 ToDeclName.getAsIdentifierInfo(), ToType,
4706 return std::move(Err);
4726 return std::move(Err);
4730 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4731 for (
auto *FoundDecl : FoundDecls) {
4732 if (
auto *FoundMethod = dyn_cast<ObjCMethodDecl>(FoundDecl)) {
4738 FoundMethod->getReturnType())) {
4739 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_result_type_inconsistent)
4741 << FoundMethod->getReturnType();
4742 Importer.
ToDiag(FoundMethod->getLocation(),
4743 diag::note_odr_objc_method_here)
4750 if (D->
param_size() != FoundMethod->param_size()) {
4751 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_num_params_inconsistent)
4753 << D->
param_size() << FoundMethod->param_size();
4754 Importer.
ToDiag(FoundMethod->getLocation(),
4755 diag::note_odr_objc_method_here)
4763 PEnd = D->
param_end(), FoundP = FoundMethod->param_begin();
4764 P != PEnd; ++
P, ++FoundP) {
4766 (*FoundP)->getType())) {
4767 Importer.
FromDiag((*P)->getLocation(),
4768 diag::warn_odr_objc_method_param_type_inconsistent)
4770 << (*P)->getType() << (*FoundP)->getType();
4771 Importer.
ToDiag((*FoundP)->getLocation(), diag::note_odr_value_here)
4772 << (*FoundP)->getType();
4780 if (D->
isVariadic() != FoundMethod->isVariadic()) {
4781 Importer.
ToDiag(
Loc, diag::warn_odr_objc_method_variadic_inconsistent)
4783 Importer.
ToDiag(FoundMethod->getLocation(),
4784 diag::note_odr_objc_method_here)
4795 Error Err = Error::success();
4798 auto ToReturnTypeSourceInfo =
4801 return std::move(Err);
4804 if (GetImportedOrCreateDecl(
4806 Name.getObjCSelector(), ToReturnType, ToReturnTypeSourceInfo, DC,
4819 ToParams.push_back(*ToPOrErr);
4821 return ToPOrErr.takeError();
4825 for (
auto *ToParam : ToParams) {
4826 ToParam->setOwningFunction(ToMethod);
4834 return std::move(Err);
4858 return std::move(Err);
4862 Error Err = Error::success();
4868 return std::move(Err);
4871 if (GetImportedOrCreateDecl(
4874 ToLocation, Name.getAsIdentifierInfo(),
4875 ToColonLoc, ToTypeSourceInfo))
4881 return std::move(Err);
4882 Result->setTypeForDecl(ToTypeForDecl);
4894 return std::move(Err);
4900 return std::move(Err);
4908 Error Err = Error::success();
4914 return std::move(Err);
4916 if (GetImportedOrCreateDecl(ToCategory, D, Importer.
getToContext(), DC,
4919 Name.getAsIdentifierInfo(), ToInterface,
4932 return PListOrErr.takeError();
4941 FromProto != FromProtoEnd;
4942 ++FromProto, ++FromProtoLoc) {
4944 Protocols.push_back(*ToProtoOrErr);
4946 return ToProtoOrErr.takeError();
4948 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
4949 ProtocolLocs.push_back(*ToProtoLocOrErr);
4951 return ToProtoLocOrErr.takeError();
4964 return std::move(Err);
4972 return ToImplOrErr.takeError();
4984 return Error::success();
4997 FromProto != FromProtoEnd;
4998 ++FromProto, ++FromProtoLoc) {
5000 Protocols.push_back(*ToProtoOrErr);
5002 return ToProtoOrErr.takeError();
5004 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5005 ProtocolLocs.push_back(*ToProtoLocOrErr);
5007 return ToProtoLocOrErr.takeError();
5020 return Error::success();
5028 if (Definition && Definition != D) {
5029 if (
ExpectedDecl ImportedDefOrErr =
import(Definition))
5030 return Importer.
MapImported(D, *ImportedDefOrErr);
5032 return ImportedDefOrErr.takeError();
5041 return std::move(Err);
5046 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5047 for (
auto *FoundDecl : FoundDecls) {
5051 if ((MergeWithProtocol = dyn_cast<ObjCProtocolDecl>(FoundDecl)))
5058 if (!ToAtBeginLocOrErr)
5059 return ToAtBeginLocOrErr.takeError();
5061 if (GetImportedOrCreateDecl(ToProto, D, Importer.
getToContext(), DC,
5062 Name.getAsIdentifierInfo(),
Loc,
5074 return std::move(Err);
5082 return std::move(Err);
5085 if (!ExternLocOrErr)
5086 return ExternLocOrErr.takeError();
5090 return LangLocOrErr.takeError();
5095 if (GetImportedOrCreateDecl(ToLinkageSpec, D, Importer.
getToContext(), DC,
5096 *ExternLocOrErr, *LangLocOrErr,
5098 return ToLinkageSpec;
5102 if (!RBraceLocOrErr)
5103 return RBraceLocOrErr.takeError();
5110 return ToLinkageSpec;
5121 return ToShadowOrErr.takeError();
5132 return std::move(Err);
5136 Error Err = Error::success();
5141 return std::move(Err);
5145 return std::move(Err);
5148 if (GetImportedOrCreateDecl(ToUsing, D, Importer.
getToContext(), DC,
5149 ToUsingLoc, ToQualifierLoc, NameInfo,
5160 ToUsing, *ToPatternOrErr);
5162 return ToPatternOrErr.takeError();
5174 return std::move(Err);
5178 Error Err = Error::success();
5184 return std::move(Err);
5187 if (GetImportedOrCreateDecl(ToUsingEnum, D, Importer.
getToContext(), DC,
5188 ToUsingLoc, ToEnumLoc, ToNameLoc, ToEnumType))
5200 return ToPatternOrErr.takeError();
5212 return std::move(Err);
5217 if (!ToIntroducerOrErr)
5218 return ToIntroducerOrErr.takeError();
5222 return ToTargetOrErr.takeError();
5225 if (
auto *FromConstructorUsingShadow =
5226 dyn_cast<ConstructorUsingShadowDecl>(D)) {
5227 Error Err = Error::success();
5229 Err, FromConstructorUsingShadow->getNominatedBaseClassShadowDecl());
5231 return std::move(Err);
5237 if (GetImportedOrCreateDecl<ConstructorUsingShadowDecl>(
5239 cast<UsingDecl>(*ToIntroducerOrErr),
5240 Nominated ? Nominated : *ToTargetOrErr,
5241 FromConstructorUsingShadow->constructsVirtualBase()))
5244 if (GetImportedOrCreateDecl(ToShadow, D, Importer.
getToContext(), DC,
Loc,
5245 Name, *ToIntroducerOrErr, *ToTargetOrErr))
5256 ToShadow, *ToPatternOrErr);
5260 return ToPatternOrErr.takeError();
5274 return std::move(Err);
5279 if (!ToComAncestorOrErr)
5280 return ToComAncestorOrErr.takeError();
5282 Error Err = Error::success();
5285 auto ToNamespaceKeyLocation =
5290 return std::move(Err);
5293 if (GetImportedOrCreateDecl(ToUsingDir, D, Importer.
getToContext(), DC,
5295 ToNamespaceKeyLocation,
5298 ToNominatedNamespace, *ToComAncestorOrErr))
5313 return std::move(Err);
5317 auto ToInstantiatedFromUsingOrErr =
5319 if (!ToInstantiatedFromUsingOrErr)
5320 return ToInstantiatedFromUsingOrErr.takeError();
5323 return std::move(Err);
5326 if (GetImportedOrCreateDecl(ToUsingPack, D, Importer.
getToContext(), DC,
5327 cast<NamedDecl>(*ToInstantiatedFromUsingOrErr),
5331 addDeclToContexts(D, ToUsingPack);
5343 return std::move(Err);
5347 Error Err = Error::success();
5353 return std::move(Err);
5357 return std::move(Err);
5360 if (GetImportedOrCreateDecl(ToUsingValue, D, Importer.
getToContext(), DC,
5361 ToUsingLoc, ToQualifierLoc, NameInfo,
5363 return ToUsingValue;
5369 return ToUsingValue;
5379 return std::move(Err);
5383 Error Err = Error::success();
5389 return std::move(Err);
5392 if (GetImportedOrCreateDecl(ToUsing, D, Importer.
getToContext(), DC,
5393 ToUsingLoc, ToTypenameLoc,
5394 ToQualifierLoc,
Loc, Name, ToEllipsisLoc))
5405 Decl* ToD =
nullptr;
5414 assert(ToD &&
"BuiltinTemplateDecl of unsupported kind!");
5425 if (
auto FromSuperOrErr =
import(FromSuper))
5426 FromSuper = *FromSuperOrErr;
5428 return FromSuperOrErr.takeError();
5432 if ((
bool)FromSuper != (
bool)ToSuper ||
5435 diag::warn_odr_objc_superclass_inconsistent)
5442 diag::note_odr_objc_missing_superclass);
5445 diag::note_odr_objc_superclass)
5449 diag::note_odr_objc_missing_superclass);
5455 return Error::success();
5466 return SuperTInfoOrErr.takeError();
5477 FromProto != FromProtoEnd;
5478 ++FromProto, ++FromProtoLoc) {
5480 Protocols.push_back(*ToProtoOrErr);
5482 return ToProtoOrErr.takeError();
5484 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5485 ProtocolLocs.push_back(*ToProtoLocOrErr);
5487 return ToProtoLocOrErr.takeError();
5498 auto ToCatOrErr =
import(Cat);
5500 return ToCatOrErr.takeError();
5509 return ToImplOrErr.takeError();
5516 return Error::success();
5525 for (
auto *fromTypeParam : *list) {
5526 if (
auto toTypeParamOrErr =
import(fromTypeParam))
5527 toTypeParams.push_back(*toTypeParamOrErr);
5529 return toTypeParamOrErr.takeError();
5533 if (!LAngleLocOrErr)
5534 return LAngleLocOrErr.takeError();
5537 if (!RAngleLocOrErr)
5538 return RAngleLocOrErr.takeError();
5551 if (Definition && Definition != D) {
5552 if (
ExpectedDecl ImportedDefOrErr =
import(Definition))
5553 return Importer.
MapImported(D, *ImportedDefOrErr);
5555 return ImportedDefOrErr.takeError();
5564 return std::move(Err);
5570 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5571 for (
auto *FoundDecl : FoundDecls) {
5575 if ((MergeWithIface = dyn_cast<ObjCInterfaceDecl>(FoundDecl)))
5583 if (!AtBeginLocOrErr)
5584 return AtBeginLocOrErr.takeError();
5586 if (GetImportedOrCreateDecl(
5588 *AtBeginLocOrErr, Name.getAsIdentifierInfo(),
5598 if (
auto ToPListOrErr =
5602 return ToPListOrErr.takeError();
5606 return std::move(Err);
5615 return std::move(Err);
5621 return std::move(Err);
5623 Error Err = Error::success();
5628 return std::move(Err);
5630 if (GetImportedOrCreateDecl(
5633 ToLocation, ToAtStartLoc, ToCategoryNameLoc))
5638 Category->setImplementation(ToImpl);
5643 return std::move(Err);
5653 return std::move(Err);
5658 return std::move(Err);
5666 return std::move(Err);
5668 Error Err = Error::success();
5675 return std::move(Err);
5677 if (GetImportedOrCreateDecl(Impl, D, Importer.
getToContext(),
5701 diag::warn_odr_objc_superclass_inconsistent)
5707 diag::note_odr_objc_superclass)
5711 diag::note_odr_objc_missing_superclass);
5714 diag::note_odr_objc_superclass)
5718 diag::note_odr_objc_missing_superclass);
5726 return std::move(Err);
5738 return std::move(Err);
5743 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5744 for (
auto *FoundDecl : FoundDecls) {
5745 if (
auto *FoundProp = dyn_cast<ObjCPropertyDecl>(FoundDecl)) {
5753 FoundProp->getType())) {
5754 Importer.
ToDiag(
Loc, diag::warn_odr_objc_property_type_inconsistent)
5755 << Name << D->
getType() << FoundProp->getType();
5756 Importer.
ToDiag(FoundProp->getLocation(), diag::note_odr_value_here)
5757 << FoundProp->getType();
5770 Error Err = Error::success();
5776 return std::move(Err);
5780 if (GetImportedOrCreateDecl(
5782 Name.getAsIdentifierInfo(), ToAtLoc,
5783 ToLParenLoc, ToType,
5795 return std::move(Err);
5815 return std::move(Err);
5819 return std::move(Err);
5821 auto *InImpl = cast<ObjCImplDecl>(LexicalDC);
5826 return std::move(Err);
5829 = InImpl->FindPropertyImplDecl(
Property->getIdentifier(),
5833 Error Err = Error::success();
5836 auto ToPropertyIvarDeclLoc =
5839 return std::move(Err);
5841 if (GetImportedOrCreateDecl(ToImpl, D, Importer.
getToContext(), DC,
5845 ToPropertyIvarDeclLoc))
5855 diag::warn_odr_objc_property_impl_kind_inconsistent)
5860 diag::note_odr_objc_property_impl_kind)
5871 diag::warn_odr_objc_synthesize_ivar_inconsistent)
5876 diag::note_odr_objc_synthesize_ivar_here)
5897 return BeginLocOrErr.takeError();
5901 return LocationOrErr.takeError();
5904 if (GetImportedOrCreateDecl(
5907 *BeginLocOrErr, *LocationOrErr,
5916 Error Err = Error::success();
5917 auto ToConceptRef =
importChecked(Err, TC->getConceptReference());
5918 auto ToIDC =
importChecked(Err, TC->getImmediatelyDeclaredConstraint());
5920 return std::move(Err);
5928 if (!ToDefaultArgOrErr)
5929 return ToDefaultArgOrErr.takeError();
5939 Error Err = Error::success();
5946 return std::move(Err);
5949 if (GetImportedOrCreateDecl(ToD, D, Importer.
getToContext(),
5951 ToInnerLocStart, ToLocation, D->
getDepth(),
5953 ToDeclName.getAsIdentifierInfo(), ToType,
5960 if (!ToDefaultArgOrErr)
5961 return ToDefaultArgOrErr.takeError();
5973 return NameOrErr.takeError();
5978 return LocationOrErr.takeError();
5982 if (!TemplateParamsOrErr)
5983 return TemplateParamsOrErr.takeError();
5986 if (GetImportedOrCreateDecl(
5991 *TemplateParamsOrErr))
5997 if (!ToDefaultArgOrErr)
5998 return ToDefaultArgOrErr.takeError();
6008 assert(D->getTemplatedDecl() &&
"Should be called on templates only");
6009 auto *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();
6010 if (!ToTemplatedDef)
6012 auto *TemplateWithDef = ToTemplatedDef->getDescribedTemplate();
6013 return cast_or_null<T>(TemplateWithDef);
6024 return std::move(Err);
6038 bool DependentFriend = IsDependentFriend(D);
6045 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6046 for (
auto *FoundDecl : FoundDecls) {
6051 Decl *Found = FoundDecl;
6052 auto *FoundTemplate = dyn_cast<ClassTemplateDecl>(Found);
6053 if (FoundTemplate) {
6058 bool IgnoreTemplateParmDepth =
6062 IgnoreTemplateParmDepth)) {
6063 if (DependentFriend || IsDependentFriend(FoundTemplate))
6071 FoundByLookup = FoundTemplate;
6076 ConflictingDecls.push_back(FoundDecl);
6080 if (!ConflictingDecls.empty()) {
6083 ConflictingDecls.size());
6085 Name = NameOrErr.get();
6087 return NameOrErr.takeError();
6094 if (!TemplateParamsOrErr)
6095 return TemplateParamsOrErr.takeError();
6099 if (Error Err = importInto(ToTemplated, FromTemplated))
6100 return std::move(Err);
6104 if (GetImportedOrCreateDecl(D2, D, Importer.
getToContext(), DC,
Loc, Name,
6105 *TemplateParamsOrErr, ToTemplated))
6113 addDeclToContexts(D, D2);
6114 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6116 if (FoundByLookup) {
6130 "Found decl must have its templated decl set");
6133 if (ToTemplated != PrevTemplated)
6147 return std::move(Err);
6152 return std::move(Err);
6158 return std::move(Err);
6161 void *InsertPos =
nullptr;
6164 dyn_cast<ClassTemplatePartialSpecializationDecl>(D);
6172 return ToTPListOrErr.takeError();
6173 ToTPList = *ToTPListOrErr;
6187 for (
auto *FromField : D->
fields()) {
6188 auto ToOrErr =
import(FromField);
6190 return ToOrErr.takeError();
6196 auto ToOrErr =
import(FromM);
6198 return ToOrErr.takeError();
6206 return PrevDefinition;
6217 return BeginLocOrErr.takeError();
6220 return IdLocOrErr.takeError();
6226 return std::move(Err);
6233 if (Error Err = importInto(
6235 return std::move(Err);
6238 if (GetImportedOrCreateDecl<ClassTemplatePartialSpecializationDecl>(
6240 *IdLocOrErr, ToTPList, ClassTemplate,
6243 cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl)))
6248 auto *PartSpec2 = cast<ClassTemplatePartialSpecializationDecl>(D2);
6255 PartSpec2->setInstantiatedFromMember(*ToInstOrErr);
6257 return ToInstOrErr.takeError();
6259 updateLookupTableForTemplateParameters(*ToTPList);
6261 if (GetImportedOrCreateDecl(
6263 *BeginLocOrErr, *IdLocOrErr, ClassTemplate, TemplateArgs,
6287 return BraceRangeOrErr.takeError();
6290 return std::move(Err);
6296 return LocOrErr.takeError();
6304 return LocOrErr.takeError();
6309 return LocOrErr.takeError();
6315 return POIOrErr.takeError();
6322 if (
auto CTDorErr =
import(CTD))
6325 auto *CTPSD = cast<ClassTemplatePartialSpecializationDecl *>(
P);
6326 auto CTPSDOrErr =
import(CTPSD);
6328 return CTPSDOrErr.takeError();
6331 for (
unsigned I = 0; I < DArgs.
size(); ++I) {
6333 if (
auto ArgOrErr =
import(DArg))
6334 D2ArgsVec[I] = *ArgOrErr;
6336 return ArgOrErr.takeError();
6346 return std::move(Err);
6358 return std::move(Err);
6364 "Variable templates cannot be declared at function scope");
6367 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6369 for (
auto *FoundDecl : FoundDecls) {
6373 if (
VarTemplateDecl *FoundTemplate = dyn_cast<VarTemplateDecl>(FoundDecl)) {
6383 assert(FoundTemplate->getDeclContext()->isRecord() &&
6384 "Member variable template imported as non-member, "
6385 "inconsistent imported AST?");
6394 FoundByLookup = FoundTemplate;
6397 ConflictingDecls.push_back(FoundDecl);
6401 if (!ConflictingDecls.empty()) {
6404 ConflictingDecls.size());
6406 Name = NameOrErr.get();
6408 return NameOrErr.takeError();
6417 return TypeOrErr.takeError();
6421 if (Error Err = importInto(ToTemplated, DTemplated))
6422 return std::move(Err);
6426 if (!TemplateParamsOrErr)
6427 return TemplateParamsOrErr.takeError();
6430 if (GetImportedOrCreateDecl(ToVarTD, D, Importer.
getToContext(), DC,
Loc,
6431 Name, *TemplateParamsOrErr, ToTemplated))
6440 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6442 if (FoundByLookup) {
6446 auto *PrevTemplated =
6448 if (ToTemplated != PrevTemplated)
6463 auto RedeclIt = Redecls.begin();
6466 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
6469 return RedeclOrErr.takeError();
6471 assert(*RedeclIt == D);
6475 return std::move(Err);
6480 return std::move(Err);
6485 return BeginLocOrErr.takeError();
6489 return IdLocOrErr.takeError();
6495 return std::move(Err);
6498 void *InsertPos =
nullptr;
6501 if (FoundSpecialization) {
6509 "Member variable template specialization imported as non-member, "
6510 "inconsistent imported AST?");
6514 return Importer.
MapImported(D, FoundSpecialization);
6531 return std::move(Err);
6536 if (
auto *FromPartial = dyn_cast<PartVarSpecDecl>(D)) {
6537 auto ToTPListOrErr =
import(FromPartial->getTemplateParameters());
6539 return ToTPListOrErr.takeError();
6541 PartVarSpecDecl *ToPartial;
6542 if (GetImportedOrCreateDecl(ToPartial, D, Importer.
getToContext(), DC,
6543 *BeginLocOrErr, *IdLocOrErr, *ToTPListOrErr,
6549 import(FromPartial->getInstantiatedFromMember()))
6552 return ToInstOrErr.takeError();
6554 if (FromPartial->isMemberSpecialization())
6555 ToPartial->setMemberSpecialization();
6563 if (GetImportedOrCreateDecl(D2, D, Importer.
getToContext(), DC,
6564 *BeginLocOrErr, *IdLocOrErr, VarTemplate,
6571 if (Error Err = importInto(
T, D->
getType()))
6572 return std::move(Err);
6577 return TInfoOrErr.takeError();
6584 return POIOrErr.takeError();
6595 return LocOrErr.takeError();
6603 return std::move(Err);
6605 if (FoundSpecialization)
6610 addDeclToContexts(D, D2);
6613 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
6616 return RedeclOrErr.takeError();
6630 return std::move(Err);
6642 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6643 for (
auto *FoundDecl : FoundDecls) {
6647 if (
auto *FoundTemplate = dyn_cast<FunctionTemplateDecl>(FoundDecl)) {
6656 FoundByLookup = FoundTemplate;
6666 return ParamsOrErr.takeError();
6671 return std::move(Err);
6688 OldParamDC.reserve(Params->
size());
6689 llvm::transform(*Params, std::back_inserter(OldParamDC),
6693 if (GetImportedOrCreateDecl(ToFunc, D, Importer.
getToContext(), DC,
Loc, Name,
6694 Params, TemplatedFD))
6700 ToFunc->setLexicalDeclContext(LexicalDC);
6701 addDeclToContexts(D, ToFunc);
6704 if (
LT && !OldParamDC.empty()) {
6705 for (
unsigned int I = 0; I < OldParamDC.size(); ++I)
6709 if (FoundByLookup) {
6714 "Found decl must have its templated decl set");
6715 auto *PrevTemplated =
6717 if (TemplatedFD != PrevTemplated)
6720 ToFunc->setPreviousDecl(Recent);
6731 Importer.
FromDiag(S->getBeginLoc(), diag::err_unsupported_ast_node)
6732 << S->getStmtClassName();
6741 for (
unsigned I = 0, E = S->getNumOutputs(); I != E; I++) {
6745 Names.push_back(ToII);
6748 for (
unsigned I = 0, E = S->getNumInputs(); I != E; I++) {
6752 Names.push_back(ToII);
6756 for (
unsigned I = 0, E = S->getNumClobbers(); I != E; I++) {
6757 if (
auto ClobberOrErr =
import(S->getClobberStringLiteral(I)))
6758 Clobbers.push_back(*ClobberOrErr);
6760 return ClobberOrErr.takeError();
6765 for (
unsigned I = 0, E = S->getNumOutputs(); I != E; I++) {
6766 if (
auto OutputOrErr =
import(S->getOutputConstraintLiteral(I)))
6767 Constraints.push_back(*OutputOrErr);
6769 return OutputOrErr.takeError();
6772 for (
unsigned I = 0, E = S->getNumInputs(); I != E; I++) {
6773 if (
auto InputOrErr =
import(S->getInputConstraintLiteral(I)))
6774 Constraints.push_back(*InputOrErr);
6776 return InputOrErr.takeError();
6782 return std::move(Err);
6786 return std::move(Err);
6789 S->labels(), Exprs.begin() + S->getNumOutputs() + S->getNumInputs()))
6790 return std::move(Err);
6794 return AsmLocOrErr.takeError();
6795 auto AsmStrOrErr =
import(S->getAsmString());
6797 return AsmStrOrErr.takeError();
6798 ExpectedSLoc RParenLocOrErr =
import(S->getRParenLoc());
6799 if (!RParenLocOrErr)
6800 return RParenLocOrErr.takeError();
6813 S->getNumClobbers(),
6821 Error Err = Error::success();
6826 return std::move(Err);
6832 if (!ToSemiLocOrErr)
6833 return ToSemiLocOrErr.takeError();
6835 *ToSemiLocOrErr, S->hasLeadingEmptyMacro());
6842 return std::move(Err);
6844 ExpectedSLoc ToLBracLocOrErr =
import(S->getLBracLoc());
6845 if (!ToLBracLocOrErr)
6846 return ToLBracLocOrErr.takeError();
6848 ExpectedSLoc ToRBracLocOrErr =
import(S->getRBracLoc());
6849 if (!ToRBracLocOrErr)
6850 return ToRBracLocOrErr.takeError();
6855 *ToLBracLocOrErr, *ToRBracLocOrErr);
6860 Error Err = Error::success();
6865 auto ToEllipsisLoc =
importChecked(Err, S->getEllipsisLoc());
6868 return std::move(Err);
6871 ToCaseLoc, ToEllipsisLoc, ToColonLoc);
6872 ToStmt->setSubStmt(ToSubStmt);
6879 Error Err = Error::success();
6884 return std::move(Err);
6887 ToDefaultLoc, ToColonLoc, ToSubStmt);
6892 Error Err = Error::success();
6897 return std::move(Err);
6900 ToIdentLoc, ToLabelDecl, ToSubStmt);
6905 if (!ToAttrLocOrErr)
6906 return ToAttrLocOrErr.takeError();
6910 return std::move(Err);
6912 if (!ToSubStmtOrErr)
6913 return ToSubStmtOrErr.takeError();
6916 Importer.
getToContext(), *ToAttrLocOrErr, ToAttrs, *ToSubStmtOrErr);
6921 Error Err = Error::success();
6924 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
6932 return std::move(Err);
6935 ToInit, ToConditionVariable, ToCond, ToLParenLoc,
6936 ToRParenLoc, ToThen, ToElseLoc, ToElse);
6941 Error Err = Error::success();
6943 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
6950 return std::move(Err);
6954 ToCond, ToLParenLoc, ToRParenLoc);
6955 ToStmt->setBody(ToBody);
6956 ToStmt->setSwitchLoc(ToSwitchLoc);
6960 for (
SwitchCase *SC = S->getSwitchCaseList(); SC !=
nullptr;
6961 SC = SC->getNextSwitchCase()) {
6964 return ToSCOrErr.takeError();
6965 if (LastChainedSwitchCase)
6968 ToStmt->setSwitchCaseList(*ToSCOrErr);
6969 LastChainedSwitchCase = *ToSCOrErr;
6977 Error Err = Error::success();
6978 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
6985 return std::move(Err);
6988 ToBody, ToWhileLoc, ToLParenLoc, ToRParenLoc);
6993 Error Err = Error::success();
7000 return std::move(Err);
7003 ToBody, ToCond, ToDoLoc, ToWhileLoc, ToRParenLoc);
7008 Error Err = Error::success();
7011 auto ToConditionVariable =
importChecked(Err, S->getConditionVariable());
7018 return std::move(Err);
7022 ToInit, ToCond, ToConditionVariable, ToInc, ToBody, ToForLoc, ToLParenLoc,
7028 Error Err = Error::success();
7033 return std::move(Err);
7036 ToLabel, ToGotoLoc, ToLabelLoc);
7041 Error Err = Error::success();
7046 return std::move(Err);
7049 ToGotoLoc, ToStarLoc, ToTarget);
7053 ExpectedSLoc ToContinueLocOrErr =
import(S->getContinueLoc());
7054 if (!ToContinueLocOrErr)
7055 return ToContinueLocOrErr.takeError();
7060 auto ToBreakLocOrErr =
import(S->getBreakLoc());
7061 if (!ToBreakLocOrErr)
7062 return ToBreakLocOrErr.takeError();
7068 Error Err = Error::success();
7071 auto ToNRVOCandidate =
importChecked(Err, S->getNRVOCandidate());
7073 return std::move(Err);
7081 Error Err = Error::success();
7083 auto ToExceptionDecl =
importChecked(Err, S->getExceptionDecl());
7084 auto ToHandlerBlock =
importChecked(Err, S->getHandlerBlock());
7086 return std::move(Err);
7089 ToCatchLoc, ToExceptionDecl, ToHandlerBlock);
7095 return ToTryLocOrErr.takeError();
7097 ExpectedStmt ToTryBlockOrErr =
import(S->getTryBlock());
7098 if (!ToTryBlockOrErr)
7099 return ToTryBlockOrErr.takeError();
7102 for (
unsigned HI = 0, HE = S->getNumHandlers(); HI != HE; ++HI) {
7104 if (
auto ToHandlerOrErr =
import(FromHandler))
7105 ToHandlers[HI] = *ToHandlerOrErr;
7107 return ToHandlerOrErr.takeError();
7111 cast<CompoundStmt>(*ToTryBlockOrErr), ToHandlers);
7116 Error Err = Error::success();
7123 auto ToLoopVarStmt =
importChecked(Err, S->getLoopVarStmt());
7130 return std::move(Err);
7133 ToInit, ToRangeStmt, ToBeginStmt, ToEndStmt, ToCond, ToInc, ToLoopVarStmt,
7134 ToBody, ToForLoc, ToCoawaitLoc, ToColonLoc, ToRParenLoc);
7139 Error Err = Error::success();
7146 return std::move(Err);
7157 Error Err = Error::success();
7160 auto ToCatchParamDecl =
importChecked(Err, S->getCatchParamDecl());
7163 return std::move(Err);
7166 ToAtCatchLoc, ToRParenLoc, ToCatchParamDecl, ToCatchBody);
7170 ExpectedSLoc ToAtFinallyLocOrErr =
import(S->getAtFinallyLoc());
7171 if (!ToAtFinallyLocOrErr)
7172 return ToAtFinallyLocOrErr.takeError();
7173 ExpectedStmt ToAtFinallyStmtOrErr =
import(S->getFinallyBody());
7174 if (!ToAtFinallyStmtOrErr)
7175 return ToAtFinallyStmtOrErr.takeError();
7177 *ToAtFinallyStmtOrErr);
7182 Error Err = Error::success();
7185 auto ToFinallyStmt =
importChecked(Err, S->getFinallyStmt());
7187 return std::move(Err);
7190 for (
unsigned CI = 0, CE = S->getNumCatchStmts(); CI != CE; ++CI) {
7192 if (
ExpectedStmt ToCatchStmtOrErr =
import(FromCatchStmt))
7193 ToCatchStmts[CI] = *ToCatchStmtOrErr;
7195 return ToCatchStmtOrErr.takeError();
7199 ToAtTryLoc, ToTryBody,
7200 ToCatchStmts.begin(), ToCatchStmts.size(),
7207 Error Err = Error::success();
7208 auto ToAtSynchronizedLoc =
importChecked(Err, S->getAtSynchronizedLoc());
7212 return std::move(Err);
7215 ToAtSynchronizedLoc, ToSynchExpr, ToSynchBody);
7219 ExpectedSLoc ToThrowLocOrErr =
import(S->getThrowLoc());
7220 if (!ToThrowLocOrErr)
7221 return ToThrowLocOrErr.takeError();
7222 ExpectedExpr ToThrowExprOrErr =
import(S->getThrowExpr());
7223 if (!ToThrowExprOrErr)
7224 return ToThrowExprOrErr.takeError();
7226 *ToThrowLocOrErr, *ToThrowExprOrErr);
7233 return ToAtLocOrErr.takeError();
7235 if (!ToSubStmtOrErr)
7236 return ToSubStmtOrErr.takeError();
7251 Error Err = Error::success();
7256 return std::move(Err);
7258 if (!ParentContextOrErr)
7259 return ParentContextOrErr.takeError();
7263 RParenLoc, *ParentContextOrErr);
7268 Error Err = Error::success();
7275 return std::move(Err);
7278 ToBuiltinLoc, ToSubExpr, ToWrittenTypeInfo, ToRParenLoc, ToType,
7284 Error Err = Error::success();
7292 return std::move(Err);
7302 ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType, VK, OK,
7303 ToRParenLoc, CondIsTrue);
7307 Error Err = Error::success();
7314 return std::move(Err);
7322 Error Err = Error::success();
7330 ToSubExprs.resize(NumSubExprs);
7333 return std::move(Err);
7336 Importer.
getToContext(), ToSubExprs, ToType, ToBeginLoc, ToRParenLoc);
7342 return TypeOrErr.takeError();
7346 return BeginLocOrErr.takeError();
7353 Error Err = Error::success();
7355 Expr *ToControllingExpr =
nullptr;
7361 assert((ToControllingExpr || ToControllingType) &&
7362 "Either the controlling expr or type must be nonnull");
7366 return std::move(Err);
7371 return std::move(Err);
7376 return std::move(Err);
7380 if (ToControllingExpr) {
7382 ToCtx, ToGenericLoc, ToControllingExpr,
llvm::ArrayRef(ToAssocTypes),
7387 ToCtx, ToGenericLoc, ToControllingType,
llvm::ArrayRef(ToAssocTypes),
7392 if (ToControllingExpr) {
7394 ToCtx, ToGenericLoc, ToControllingExpr,
llvm::ArrayRef(ToAssocTypes),
7399 ToCtx, ToGenericLoc, ToControllingType,
llvm::ArrayRef(ToAssocTypes),
7406 Error Err = Error::success();
7411 return std::move(Err);
7420 Error Err = Error::success();
7427 return std::move(Err);
7433 return FoundDOrErr.takeError();
7434 ToFoundD = *FoundDOrErr;
7443 return std::move(Err);
7444 ToResInfo = &ToTAInfo;
7448 Importer.
getToContext(), ToQualifierLoc, ToTemplateKeywordLoc, ToDecl,
7452 ToE->setHadMultipleCandidates(
true);
7460 return TypeOrErr.takeError();
7468 return ToInitOrErr.takeError();
7471 if (!ToEqualOrColonLocOrErr)
7472 return ToEqualOrColonLocOrErr.takeError();
7478 ToIndexExprs[I - 1] = *ToArgOrErr;
7480 return ToArgOrErr.takeError();
7485 return std::move(Err);
7489 ToIndexExprs, *ToEqualOrColonLocOrErr,
7497 return ToTypeOrErr.takeError();
7500 if (!ToLocationOrErr)
7501 return ToLocationOrErr.takeError();
7504 *ToTypeOrErr, *ToLocationOrErr);
7510 return ToTypeOrErr.takeError();
7513 if (!ToLocationOrErr)
7514 return ToLocationOrErr.takeError();
7524 return ToTypeOrErr.takeError();
7527 if (!ToLocationOrErr)
7528 return ToLocationOrErr.takeError();
7532 *ToTypeOrErr, *ToLocationOrErr);
7536 auto ToTypeOrErr =
import(E->
getType());
7538 return ToTypeOrErr.takeError();
7541 if (!ToSubExprOrErr)
7542 return ToSubExprOrErr.takeError();
7545 *ToSubExprOrErr, *ToTypeOrErr);
7549 auto ToTypeOrErr =
import(E->
getType());
7551 return ToTypeOrErr.takeError();
7554 if (!ToLocationOrErr)
7555 return ToLocationOrErr.takeError();
7565 return ToTypeOrErr.takeError();
7568 if (!ToLocationOrErr)
7569 return ToLocationOrErr.takeError();
7578 return ToTypeOrErr.takeError();
7583 return std::move(Err);
7587 *ToTypeOrErr, ToLocations.data(), ToLocations.size());
7592 Error Err = Error::success();
7598 return std::move(Err);
7601 ToLParenLoc, ToTypeSourceInfo, ToType, E->
getValueKind(),
7607 Error Err = Error::success();
7612 return std::move(Err);
7618 return std::move(Err);
7622 ToBuiltinLoc, ToExprs, ToType, E->
getOp(), ToRParenLoc);
7626 Error Err = Error::success();
7632 return std::move(Err);
7635 ToAmpAmpLoc, ToLabelLoc, ToLabel, ToType);
7638 Error Err = Error::success();
7642 return std::move(Err);
7647 Error Err = Error::success();
7652 return std::move(Err);
7655 ParenExpr(ToLParen, ToRParen, ToSubExpr);
7661 return std::move(Err);
7664 if (!ToLParenLocOrErr)
7665 return ToLParenLocOrErr.takeError();
7668 if (!ToRParenLocOrErr)
7669 return ToRParenLocOrErr.takeError();
7672 ToExprs, *ToRParenLocOrErr);
7676 Error Err = Error::success();
7682 return std::move(Err);
7685 StmtExpr(ToSubStmt, ToType, ToLParenLoc, ToRParenLoc,
7690 Error Err = Error::success();
7695 return std::move(Err);
7699 UO->setType(ToType);
7700 UO->setSubExpr(ToSubExpr);
7702 UO->setOperatorLoc(ToOperatorLoc);
7713 Error Err = Error::success();
7718 return std::move(Err);
7723 if (!ToArgumentTypeInfoOrErr)
7724 return ToArgumentTypeInfoOrErr.takeError();
7727 E->
getKind(), *ToArgumentTypeInfoOrErr, ToType, ToOperatorLoc,
7732 if (!ToArgumentExprOrErr)
7733 return ToArgumentExprOrErr.takeError();
7736 E->
getKind(), *ToArgumentExprOrErr, ToType, ToOperatorLoc, ToRParenLoc);
7740 Error Err = Error::success();
7746 return std::move(Err);
7755 Error Err = Error::success();
7763 return std::move(Err);
7766 ToCond, ToQuestionLoc, ToLHS, ToColonLoc, ToRHS, ToType,
7772 Error Err = Error::success();
7782 return std::move(Err);
7785 ToCommon, ToOpaqueValue, ToCond, ToTrueExpr, ToFalseExpr,
7792 Error Err = Error::success();
7795 return std::move(Err);
7802 Error Err = Error::success();
7804 auto ToQueriedTypeSourceInfo =
7810 return std::move(Err);
7814 ToDimensionExpression, ToEndLoc, ToType);
7818 Error Err = Error::success();
7824 return std::move(Err);
7832 Error Err = Error::success();
7837 return std::move(Err);
7844 Error Err = Error::success();
7850 return std::move(Err);
7859 Error Err = Error::success();
7864 auto ToComputationResultType =
7868 return std::move(Err);
7874 ToComputationLHSType, ToComputationResultType);
7881 if (
auto SpecOrErr =
import(*I))
7882 Path.push_back(*SpecOrErr);
7884 return SpecOrErr.takeError();
7892 return ToTypeOrErr.takeError();
7895 if (!ToSubExprOrErr)
7896 return ToSubExprOrErr.takeError();
7899 if (!ToBasePathOrErr)
7900 return ToBasePathOrErr.takeError();
7908 Error Err = Error::success();
7913 return std::move(Err);
7916 if (!ToBasePathOrErr)
7917 return ToBasePathOrErr.takeError();
7921 case Stmt::CStyleCastExprClass: {
7922 auto *CCE = cast<CStyleCastExpr>(E);
7923 ExpectedSLoc ToLParenLocOrErr =
import(CCE->getLParenLoc());
7924 if (!ToLParenLocOrErr)
7925 return ToLParenLocOrErr.takeError();
7926 ExpectedSLoc ToRParenLocOrErr =
import(CCE->getRParenLoc());
7927 if (!ToRParenLocOrErr)
7928 return ToRParenLocOrErr.takeError();
7931 ToSubExpr, ToBasePath, CCE->getFPFeatures(), ToTypeInfoAsWritten,
7932 *ToLParenLocOrErr, *ToRParenLocOrErr);
7935 case Stmt::CXXFunctionalCastExprClass: {
7936 auto *FCE = cast<CXXFunctionalCastExpr>(E);
7937 ExpectedSLoc ToLParenLocOrErr =
import(FCE->getLParenLoc());
7938 if (!ToLParenLocOrErr)
7939 return ToLParenLocOrErr.takeError();
7940 ExpectedSLoc ToRParenLocOrErr =
import(FCE->getRParenLoc());
7941 if (!ToRParenLocOrErr)
7942 return ToRParenLocOrErr.takeError();
7945 E->
getCastKind(), ToSubExpr, ToBasePath, FCE->getFPFeatures(),
7946 *ToLParenLocOrErr, *ToRParenLocOrErr);
7949 case Stmt::ObjCBridgedCastExprClass: {
7950 auto *OCE = cast<ObjCBridgedCastExpr>(E);
7951 ExpectedSLoc ToLParenLocOrErr =
import(OCE->getLParenLoc());
7952 if (!ToLParenLocOrErr)
7953 return ToLParenLocOrErr.takeError();
7954 ExpectedSLoc ToBridgeKeywordLocOrErr =
import(OCE->getBridgeKeywordLoc());
7955 if (!ToBridgeKeywordLocOrErr)
7956 return ToBridgeKeywordLocOrErr.takeError();
7958 *ToLParenLocOrErr, OCE->getBridgeKind(), E->
getCastKind(),
7959 *ToBridgeKeywordLocOrErr, ToTypeInfoAsWritten, ToSubExpr);
7961 case Stmt::BuiltinBitCastExprClass: {
7962 auto *BBC = cast<BuiltinBitCastExpr>(E);
7963 ExpectedSLoc ToKWLocOrErr =
import(BBC->getBeginLoc());
7965 return ToKWLocOrErr.takeError();
7966 ExpectedSLoc ToRParenLocOrErr =
import(BBC->getEndLoc());
7967 if (!ToRParenLocOrErr)
7968 return ToRParenLocOrErr.takeError();
7971 ToTypeInfoAsWritten, *ToKWLocOrErr, *ToRParenLocOrErr);
7974 llvm_unreachable(
"Cast expression of unsupported type!");
7987 Error Err = Error::success();
7991 return std::move(Err);
8000 auto ToBSOrErr =
import(FromNode.
getBase());
8002 return ToBSOrErr.takeError();
8007 auto ToFieldOrErr =
import(FromNode.
getField());
8009 return ToFieldOrErr.takeError();
8010 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, *ToFieldOrErr, ToEndLoc));
8015 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, ToII, ToEndLoc));
8024 if (!ToIndexExprOrErr)
8025 return ToIndexExprOrErr.takeError();
8026 ToExprs[I] = *ToIndexExprOrErr;
8029 Error Err = Error::success();
8035 return std::move(Err);
8038 Importer.
getToContext(), ToType, ToOperatorLoc, ToTypeSourceInfo, ToNodes,
8039 ToExprs, ToRParenLoc);
8043 Error Err = Error::success();
8049 return std::move(Err);
8058 ToType, ToOperand, ToCanThrow, ToBeginLoc, ToEndLoc);
8062 Error Err = Error::success();
8067 return std::move(Err);
8075 if (!ToUsedLocOrErr)
8076 return ToUsedLocOrErr.takeError();
8078 auto ToParamOrErr =
import(E->
getParam());
8080 return ToParamOrErr.takeError();
8083 if (!UsedContextOrErr)
8084 return UsedContextOrErr.takeError();
8094 std::optional<ParmVarDecl *> FromParam =
8096 assert(FromParam &&
"ParmVarDecl was not imported?");
8099 return std::move(Err);
8101 Expr *RewrittenInit =
nullptr;
8105 return ExprOrErr.takeError();
8106 RewrittenInit = ExprOrErr.get();
8109 *ToParamOrErr, RewrittenInit,
8115 Error Err = Error::success();
8120 return std::move(Err);
8123 ToType, ToTypeSourceInfo, ToRParenLoc);
8129 if (!ToSubExprOrErr)
8130 return ToSubExprOrErr.takeError();
8134 return ToDtorOrErr.takeError();
8144 Error Err = Error::success();
8150 return std::move(Err);
8154 return std::move(Err);
8157 Importer.
getToContext(), ToConstructor, ToType, ToTypeSourceInfo, ToArgs,
8167 return std::move(Err);
8169 Error Err = Error::success();
8173 return std::move(Err);
8177 if (GetImportedOrCreateDecl(To, D, Temporary, ExtendingDecl,
8188 Error Err = Error::success();
8192 auto ToMaterializedDecl =
8195 return std::move(Err);
8197 if (!ToTemporaryExpr)
8198 ToTemporaryExpr = cast<Expr>(ToMaterializedDecl->getTemporaryExpr());
8202 ToMaterializedDecl);
8208 Error Err = Error::success();
8213 return std::move(Err);
8220 Error Err = Error::success();
8226 return std::move(Err);
8228 std::optional<unsigned> Length;
8235 ToPartialArguments))
8236 return std::move(Err);
8240 Importer.
getToContext(), ToOperatorLoc, ToPack, ToPackLoc, ToRParenLoc,
8241 Length, ToPartialArguments);
8246 Error Err = Error::success();
8253 auto ToAllocatedTypeSourceInfo =
8258 return std::move(Err);
8263 return std::move(Err);
8269 ToInitializer, ToType, ToAllocatedTypeSourceInfo, ToSourceRange,
8274 Error Err = Error::success();
8280 return std::move(Err);
8289 Error Err = Error::success();
8295 return std::move(Err);
8299 return std::move(Err);
8302 Importer.
getToContext(), ToType, ToLocation, ToConstructor,
8306 ToParenOrBraceRange);
8313 if (!ToSubExprOrErr)
8314 return ToSubExprOrErr.takeError();
8318 return std::move(Err);
8326 Error Err = Error::success();
8331 return std::move(Err);
8335 return std::move(Err);
8345 return ToTypeOrErr.takeError();
8348 if (!ToLocationOrErr)
8349 return ToLocationOrErr.takeError();
8358 return ToTypeOrErr.takeError();
8361 if (!ToLocationOrErr)
8362 return ToLocationOrErr.takeError();
8365 *ToTypeOrErr, *ToLocationOrErr);
8369 Error Err = Error::success();
8380 return std::move(Err);
8392 return std::move(Err);
8393 ResInfo = &ToTAInfo;
8397 ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8398 ToMemberDecl, ToFoundDecl, ToMemberNameInfo,
8405 Error Err = Error::success();
8413 return std::move(Err);
8419 if (!ToDestroyedTypeLocOrErr)
8420 return ToDestroyedTypeLocOrErr.takeError();
8426 return ToTIOrErr.takeError();
8431 ToQualifierLoc, ToScopeTypeInfo, ToColonColonLoc, ToTildeLoc,
Storage);
8436 Error Err = Error::success();
8441 auto ToFirstQualifierFoundInScope =
8444 return std::move(Err);
8446 Expr *ToBase =
nullptr;
8449 ToBase = *ToBaseOrErr;
8451 return ToBaseOrErr.takeError();
8460 return std::move(Err);
8461 ResInfo = &ToTAInfo;
8466 return std::move(Err);
8472 return std::move(Err);
8476 ToQualifierLoc, ToTemplateKeywordLoc, ToFirstQualifierFoundInScope,
8477 ToMemberNameInfo, ResInfo);
8482 Error Err = Error::success();
8490 return std::move(Err);
8494 return std::move(Err);
8501 return std::move(Err);
8502 ResInfo = &ToTAInfo;
8506 Importer.
getToContext(), ToQualifierLoc, ToTemplateKeywordLoc,
8507 ToNameInfo, ResInfo);
8512 Error Err = Error::success();
8518 return std::move(Err);
8523 return std::move(Err);
8526 Importer.
getToContext(), ToType, ToTypeSourceInfo, ToLParenLoc,
8533 if (!ToNamingClassOrErr)
8534 return ToNamingClassOrErr.takeError();
8537 if (!ToQualifierLocOrErr)
8538 return ToQualifierLocOrErr.takeError();
8540 Error Err = Error::success();
8544 return std::move(Err);
8549 return std::move(Err);
8552 for (
auto *D : E->
decls())
8553 if (
auto ToDOrErr =
import(D))
8554 ToDecls.
addDecl(cast<NamedDecl>(*ToDOrErr));
8556 return ToDOrErr.takeError();
8563 return std::move(Err);
8566 if (!ToTemplateKeywordLocOrErr)
8567 return ToTemplateKeywordLocOrErr.takeError();
8569 const bool KnownDependent =
8571 ExprDependence::TypeValue;
8573 Importer.
getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8574 *ToTemplateKeywordLocOrErr, ToNameInfo, E->
requiresADL(), &ToTAInfo,
8575 ToDecls.
begin(), ToDecls.
end(), KnownDependent);
8579 Importer.
getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8586 Error Err = Error::success();
8594 return std::move(Err);
8599 return std::move(Err);
8603 if (
auto ToDOrErr =
import(D))
8604 ToDecls.
addDecl(cast<NamedDecl>(*ToDOrErr));
8606 return ToDOrErr.takeError();
8614 return std::move(Err);
8615 ResInfo = &ToTAInfo;
8618 Expr *ToBase =
nullptr;
8621 ToBase = *ToBaseOrErr;
8623 return ToBaseOrErr.takeError();
8628 E->
isArrow(), ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8629 ToNameInfo, ResInfo, ToDecls.
begin(), ToDecls.
end());
8633 Error Err = Error::success();
8638 return std::move(Err);
8643 return std::move(Err);
8645 if (
const auto *OCE = dyn_cast<CXXOperatorCallExpr>(E)) {
8647 Importer.
getToContext(), OCE->getOperator(), ToCallee, ToArgs, ToType,
8648 OCE->getValueKind(), ToRParenLoc, OCE->getFPFeatures(),
8649 OCE->getADLCallKind());
8659 auto ToClassOrErr =
import(FromClass);
8661 return ToClassOrErr.takeError();
8666 return ToCallOpOrErr.takeError();
8670 return std::move(Err);
8672 Error Err = Error::success();
8677 return std::move(Err);
8688 Error Err = Error::success();
8693 return std::move(Err);
8697 return std::move(Err);
8701 ToCtx, ToLBraceLoc, ToExprs, ToRBraceLoc);
8708 return ToFillerOrErr.takeError();
8712 if (
auto ToFDOrErr =
import(FromFD))
8715 return ToFDOrErr.takeError();
8719 if (
auto ToSyntFormOrErr =
import(SyntForm))
8722 return ToSyntFormOrErr.takeError();
8736 return ToTypeOrErr.takeError();
8739 if (!ToSubExprOrErr)
8740 return ToSubExprOrErr.takeError();
8743 *ToTypeOrErr, *ToSubExprOrErr);
8748 Error Err = Error::success();
8753 return std::move(Err);
8761 Error Err = Error::success();
8766 return std::move(Err);
8769 ToType, ToCommonExpr, ToSubExpr);
8775 return ToTypeOrErr.takeError();
8781 if (!ToBeginLocOrErr)
8782 return ToBeginLocOrErr.takeError();
8784 auto ToFieldOrErr =
import(E->
getField());
8786 return ToFieldOrErr.takeError();
8789 if (!UsedContextOrErr)
8790 return UsedContextOrErr.takeError();
8794 "Field should have in-class initializer if there is a default init "
8795 "expression that uses it.");
8800 auto ToInClassInitializerOrErr =
8802 if (!ToInClassInitializerOrErr)
8803 return ToInClassInitializerOrErr.takeError();
8807 Expr *RewrittenInit =
nullptr;
8811 return ExprOrErr.takeError();
8812 RewrittenInit = ExprOrErr.get();
8816 ToField, *UsedContextOrErr, RewrittenInit);
8820 Error Err = Error::success();
8828 return std::move(Err);
8833 if (!ToBasePathOrErr)
8834 return ToBasePathOrErr.takeError();
8836 if (
auto CCE = dyn_cast<CXXStaticCastExpr>(E)) {
8838 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8839 ToTypeInfoAsWritten, CCE->getFPFeatures(), ToOperatorLoc, ToRParenLoc,
8841 }
else if (isa<CXXDynamicCastExpr>(E)) {
8843 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8844 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8845 }
else if (isa<CXXReinterpretCastExpr>(E)) {
8847 Importer.
getToContext(), ToType, VK, CK, ToSubExpr, &(*ToBasePathOrErr),
8848 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8849 }
else if (isa<CXXConstCastExpr>(E)) {
8851 Importer.
getToContext(), ToType, VK, ToSubExpr, ToTypeInfoAsWritten,
8852 ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
8854 llvm_unreachable(
"Unknown cast type");
8855 return make_error<ASTImportError>();
8861 Error Err = Error::success();
8867 return std::move(Err);
8870 ToType, E->
getValueKind(), ToExprLoc, ToReplacement, ToAssociatedDecl,
8875 Error Err = Error::success();
8880 return std::move(Err);
8884 return std::move(Err);
8898 return ToTypeOrErr.takeError();
8901 if (!ToSourceRangeOrErr)
8902 return ToSourceRangeOrErr.takeError();
8907 *ToTypeOrErr, *ToTSIOrErr, *ToSourceRangeOrErr);
8909 return ToTSIOrErr.takeError();
8913 if (!ToExprOperandOrErr)
8914 return ToExprOperandOrErr.takeError();
8917 *ToTypeOrErr, *ToExprOperandOrErr, *ToSourceRangeOrErr);
8921 Error Err = Error::success();
8932 return std::move(Err);
8941 Error ImportErrors = Error::success();
8943 if (
auto ImportedOrErr =
import(FromOverriddenMethod))
8945 (*ImportedOrErr)->getCanonicalDecl()));
8948 joinErrors(std::move(ImportErrors), ImportedOrErr.takeError());
8950 return ImportErrors;
8956 std::shared_ptr<ASTImporterSharedState> SharedState)
8957 : SharedState(SharedState), ToContext(ToContext), FromContext(FromContext),
8958 ToFileManager(ToFileManager), FromFileManager(FromFileManager),
8963 this->SharedState = std::make_shared<ASTImporterSharedState>();
8973 assert(F && (isa<FieldDecl>(*F) || isa<IndirectFieldDecl>(*F)) &&
8974 "Try to get field index for non-field.");
8978 return std::nullopt;
8981 for (
const auto *D : Owner->decls()) {
8985 if (isa<FieldDecl>(*D) || isa<IndirectFieldDecl>(*D))
8989 llvm_unreachable(
"Field was not found in its parent context.");
8991 return std::nullopt;
9004 if (SharedState->getLookupTable()) {
9006 SharedState->getLookupTable()->lookup(ReDC, Name);
9010 FoundDeclsTy Result(NoloadLookupResult.
begin(), NoloadLookupResult.
end());
9027 void ASTImporter::AddToLookupTable(
Decl *ToD) {
9028 SharedState->addDeclToLookup(ToD);
9034 return Importer.
Visit(FromD);
9058 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
9059 ImportedTypes.find(FromT);
9060 if (Pos != ImportedTypes.end())
9067 return ToTOrErr.takeError();
9070 ImportedTypes[FromT] = ToTOrErr->getTypePtr();
9072 return ToTOrErr->getTypePtr();
9081 return ToTyOrErr.takeError();
9094 return TOrErr.takeError();
9097 return BeginLocOrErr.takeError();
9106 template <
typename T>
struct AttrArgImporter {
9107 AttrArgImporter(
const AttrArgImporter<T> &) =
delete;
9108 AttrArgImporter(AttrArgImporter<T> &&) =
default;
9109 AttrArgImporter<T> &operator=(
const AttrArgImporter<T> &) =
delete;
9110 AttrArgImporter<T> &operator=(AttrArgImporter<T> &&) =
default;
9113 : To(I.importChecked(Err, From)) {}
9115 const T &value() {
return To; }
9126 template <
typename T>
struct AttrArgArrayImporter {
9127 AttrArgArrayImporter(
const AttrArgArrayImporter<T> &) =
delete;
9128 AttrArgArrayImporter(AttrArgArrayImporter<T> &&) =
default;
9129 AttrArgArrayImporter<T> &operator=(
const AttrArgArrayImporter<T> &) =
delete;
9130 AttrArgArrayImporter<T> &operator=(AttrArgArrayImporter<T> &&) =
default;
9133 const llvm::iterator_range<T *> &From,
9134 unsigned ArraySize) {
9137 To.reserve(ArraySize);
9141 T *value() {
return To.data(); }
9147 class AttrImporter {
9148 Error Err{Error::success()};
9149 Attr *ToAttr =
nullptr;
9154 AttrImporter(
ASTImporter &I) : Importer(I), NImporter(I) {}
9157 template <
typename T>
T *castAttrAs() {
return cast<T>(ToAttr); }
9158 template <
typename T>
const T *castAttrAs()
const {
return cast<T>(ToAttr); }
9163 template <
class T> AttrArgImporter<T> importArg(
const T &From) {
9164 return AttrArgImporter<T>(NImporter, Err, From);
9170 template <
typename T>
9171 AttrArgArrayImporter<T> importArrayArg(
const llvm::iterator_range<T *> &From,
9172 unsigned ArraySize) {
9173 return AttrArgArrayImporter<T>(NImporter, Err, From, ArraySize);
9184 template <
typename T,
typename... Arg>
9185 void importAttr(
const T *FromAttr, Arg &&...ImportedArg) {
9186 static_assert(std::is_base_of<Attr, T>::value,
9187 "T should be subclass of Attr.");
9188 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9192 Importer.
Import(FromAttr->getScopeName());
9202 FromAttr->getParsedKind(), FromAttr->getForm());
9206 std::forward<Arg>(ImportedArg)..., ToI);
9210 if (
auto *ToInheritableAttr = dyn_cast<InheritableAttr>(ToAttr))
9211 ToInheritableAttr->setInherited(FromAttr->isInherited());
9217 void cloneAttr(
const Attr *FromAttr) {
9218 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9232 return std::move(Err);
9233 assert(ToAttr &&
"Attribute should be created.");
9240 AttrImporter AI(*
this);
9243 switch (FromAttr->
getKind()) {
9244 case attr::Aligned: {
9245 auto *From = cast<AlignedAttr>(FromAttr);
9246 if (From->isAlignmentExpr())
9247 AI.importAttr(From,
true, AI.importArg(From->getAlignmentExpr()).value());
9249 AI.importAttr(From,
false,
9250 AI.importArg(From->getAlignmentType()).value());
9254 case attr::AlignValue: {
9255 auto *From = cast<AlignValueAttr>(FromAttr);
9256 AI.importAttr(From, AI.importArg(From->getAlignment()).value());
9260 case attr::Format: {
9261 const auto *From = cast<FormatAttr>(FromAttr);
9262 AI.importAttr(From,
Import(From->getType()), From->getFormatIdx(),
9263 From->getFirstArg());
9267 case attr::EnableIf: {
9268 const auto *From = cast<EnableIfAttr>(FromAttr);
9269 AI.importAttr(From, AI.importArg(From->getCond()).value(),
9270 From->getMessage());
9274 case attr::AssertCapability: {
9275 const auto *From = cast<AssertCapabilityAttr>(FromAttr);
9277 AI.importArrayArg(From->args(), From->args_size()).value(),
9281 case attr::AcquireCapability: {
9282 const auto *From = cast<AcquireCapabilityAttr>(FromAttr);
9284 AI.importArrayArg(From->args(), From->args_size()).value(),
9288 case attr::TryAcquireCapability: {
9289 const auto *From = cast<TryAcquireCapabilityAttr>(FromAttr);
9290 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9291 AI.importArrayArg(From->args(), From->args_size()).value(),
9295 case attr::ReleaseCapability: {
9296 const auto *From = cast<ReleaseCapabilityAttr>(FromAttr);
9298 AI.importArrayArg(From->args(), From->args_size()).value(),
9302 case attr::RequiresCapability: {
9303 const auto *From = cast<RequiresCapabilityAttr>(FromAttr);
9305 AI.importArrayArg(From->args(), From->args_size()).value(),
9309 case attr::GuardedBy: {
9310 const auto *From = cast<GuardedByAttr>(FromAttr);
9311 AI.importAttr(From, AI.importArg(From->getArg()).value());
9314 case attr::PtGuardedBy: {
9315 const auto *From = cast<PtGuardedByAttr>(FromAttr);
9316 AI.importAttr(From, AI.importArg(From->getArg()).value());
9319 case attr::AcquiredAfter: {
9320 const auto *From = cast<AcquiredAfterAttr>(FromAttr);
9322 AI.importArrayArg(From->args(), From->args_size()).value(),
9326 case attr::AcquiredBefore: {
9327 const auto *From = cast<AcquiredBeforeAttr>(FromAttr);
9329 AI.importArrayArg(From->args(), From->args_size()).value(),
9333 case attr::AssertExclusiveLock: {
9334 const auto *From = cast<AssertExclusiveLockAttr>(FromAttr);
9336 AI.importArrayArg(From->args(), From->args_size()).value(),
9340 case attr::AssertSharedLock: {
9341 const auto *From = cast<AssertSharedLockAttr>(FromAttr);
9343 AI.importArrayArg(From->args(), From->args_size()).value(),
9347 case attr::ExclusiveTrylockFunction: {
9348 const auto *From = cast<ExclusiveTrylockFunctionAttr>(FromAttr);
9349 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9350 AI.importArrayArg(From->args(), From->args_size()).value(),
9354 case attr::SharedTrylockFunction: {
9355 const auto *From = cast<SharedTrylockFunctionAttr>(FromAttr);
9356 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9357 AI.importArrayArg(From->args(), From->args_size()).value(),
9361 case attr::LockReturned: {
9362 const auto *From = cast<LockReturnedAttr>(FromAttr);
9363 AI.importAttr(From, AI.importArg(From->getArg()).value());
9366 case attr::LocksExcluded: {
9367 const auto *From = cast<LocksExcludedAttr>(FromAttr);
9369 AI.importArrayArg(From->args(), From->args_size()).value(),
9377 AI.cloneAttr(FromAttr);
9382 return std::move(AI).getResult();
9386 return ImportedDecls.lookup(FromD);
9390 auto FromDPos = ImportedFromDecls.find(ToD);
9391 if (FromDPos == ImportedFromDecls.end())
9393 return FromDPos->second->getTranslationUnitDecl();
9396 Error ASTImporter::ImportAttrs(
Decl *ToD,
Decl *FromD) {
9398 return Error::success();
9400 auto ToAttrOrErr =
Import(FromAttr);
9404 return ToAttrOrErr.takeError();
9406 return Error::success();
9414 ImportPath.
push(FromD);
9415 auto ImportPathBuilder =
9416 llvm::make_scope_exit([
this]() { ImportPath.
pop(); });
9421 return make_error<ASTImportError>(*Error);
9427 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9429 return make_error<ASTImportError>(*Error);
9446 auto Pos = ImportedDecls.find(FromD);
9447 if (Pos != ImportedDecls.end()) {
9450 auto *ToD = Pos->second;
9451 ImportedDecls.erase(Pos);
9463 auto PosF = ImportedFromDecls.find(ToD);
9464 if (PosF != ImportedFromDecls.end()) {
9469 SharedState->removeDeclFromLookup(ToD);
9470 ImportedFromDecls.erase(PosF);
9482 handleAllErrors(ToDOrErr.takeError(),
9486 if (Pos != ImportedDecls.end())
9487 SharedState->setImportDeclError(Pos->second, ErrOut);
9491 for (
const auto &Path : SavedImportPaths[FromD]) {
9494 Decl *PrevFromDi = FromD;
9495 for (
Decl *FromDi : Path) {
9497 if (FromDi == FromD)
9504 PrevFromDi = FromDi;
9508 auto Ii = ImportedDecls.find(FromDi);
9509 if (Ii != ImportedDecls.end())
9510 SharedState->setImportDeclError(Ii->second, ErrOut);
9515 SavedImportPaths.erase(FromD);
9518 return make_error<ASTImportError>(ErrOut);
9530 return make_error<ASTImportError>(*Err);
9536 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9538 return make_error<ASTImportError>(*Error);
9541 assert(ImportedDecls.count(FromD) != 0 &&
"Missing call to MapImported?");
9542 if (
auto Error = ImportAttrs(ToD, FromD))
9543 return std::move(Error);
9549 SavedImportPaths.erase(FromD);
9564 return ToDCOrErr.takeError();
9565 auto *ToDC = cast<DeclContext>(*ToDCOrErr);
9569 if (
auto *ToRecord = dyn_cast<RecordDecl>(ToDC)) {
9570 auto *FromRecord = cast<RecordDecl>(FromDC);
9571 if (ToRecord->isCompleteDefinition())
9579 if (FromRecord->getASTContext().getExternalSource() &&
9580 !FromRecord->isCompleteDefinition())
9581 FromRecord->getASTContext().getExternalSource()->CompleteType(FromRecord);
9583 if (FromRecord->isCompleteDefinition())
9586 return std::move(Err);
9587 }
else if (
auto *ToEnum = dyn_cast<EnumDecl>(ToDC)) {
9588 auto *FromEnum = cast<EnumDecl>(FromDC);
9589 if (ToEnum->isCompleteDefinition()) {
9591 }
else if (FromEnum->isCompleteDefinition()) {
9594 return std::move(Err);
9598 }
else if (
auto *ToClass = dyn_cast<ObjCInterfaceDecl>(ToDC)) {
9599 auto *FromClass = cast<ObjCInterfaceDecl>(FromDC);
9600 if (ToClass->getDefinition()) {
9605 return std::move(Err);
9609 }
else if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(ToDC)) {
9610 auto *FromProto = cast<ObjCProtocolDecl>(FromDC);
9611 if (ToProto->getDefinition()) {
9616 return std::move(Err);
9627 return cast_or_null<Expr>(*ToSOrErr);
9629 return ToSOrErr.takeError();
9637 llvm::DenseMap<Stmt *, Stmt *>::iterator Pos = ImportedStmts.find(FromS);
9638 if (Pos != ImportedStmts.end())
9647 if (
auto *ToE = dyn_cast<Expr>(*ToSOrErr)) {
9648 auto *FromE = cast<Expr>(FromS);
9651 ToE->setValueKind(FromE->getValueKind());
9652 ToE->setObjectKind(FromE->getObjectKind());
9653 ToE->setDependence(FromE->getDependence());
9657 ImportedStmts[FromS] = *ToSOrErr;
9668 return std::move(Err);
9672 assert(FromNNS->
getAsIdentifier() &&
"NNS should contain identifier.");
9679 cast<NamespaceDecl>(*NSOrErr));
9681 return NSOrErr.takeError();
9686 cast<NamespaceAliasDecl>(*NSADOrErr));
9688 return NSADOrErr.takeError();
9696 cast<CXXRecordDecl>(*RDOrErr));
9698 return RDOrErr.takeError();
9708 return TyOrErr.takeError();
9712 llvm_unreachable(
"Invalid nested name specifier kind");
9724 NestedNames.push_back(NNS);
9730 while (!NestedNames.empty()) {
9731 NNS = NestedNames.pop_back_val();
9734 return std::move(Err);
9741 return std::move(Err);
9745 return std::move(Err);
9761 ToLocalBeginLoc, ToLocalEndLoc);
9768 return std::move(Err);
9788 if (!ToSourceRangeOrErr)
9789 return ToSourceRangeOrErr.takeError();
9792 ToSourceRangeOrErr->getBegin(),
9793 ToSourceRangeOrErr->getEnd());
9805 return TemplateName(cast<TemplateDecl>((*ToTemplateOrErr)->getCanonicalDecl()));
9807 return ToTemplateOrErr.takeError();
9812 for (
auto *I : *FromStorage) {
9813 if (
auto ToOrErr =
Import(I))
9814 ToTemplates.
addDecl(cast<NamedDecl>(*ToOrErr));
9816 return ToOrErr.takeError();
9826 return DeclNameOrErr.takeError();
9833 if (!QualifierOrErr)
9834 return QualifierOrErr.takeError();
9837 return TNOrErr.takeError();
9845 if (!QualifierOrErr)
9846 return QualifierOrErr.takeError();
9861 if (!ReplacementOrErr)
9862 return ReplacementOrErr.takeError();
9865 if (!AssociatedDeclOrErr)
9866 return AssociatedDeclOrErr.takeError();
9869 *ReplacementOrErr, *AssociatedDeclOrErr, Subst->
getIndex(),
9880 return ArgPackOrErr.takeError();
9883 if (!AssociatedDeclOrErr)
9884 return AssociatedDeclOrErr.takeError();
9887 *ArgPackOrErr, *AssociatedDeclOrErr, SubstPack->
getIndex(),
9893 return UsingOrError.takeError();
9894 return TemplateName(cast<UsingShadowDecl>(*UsingOrError));
9898 llvm_unreachable(
"Invalid template name kind");
9911 return ToFileIDOrErr.takeError();
9919 return std::move(Err);
9921 return std::move(Err);
9927 llvm::DenseMap<FileID, FileID>::iterator Pos = ImportedFileIDs.find(FromID);
9928 if (Pos != ImportedFileIDs.end())
9941 return ToSpLoc.takeError();
9944 return ToExLocS.takeError();
9954 return ToExLocE.takeError();
9960 if (!IsBuiltin && !
Cache->BufferOverridden) {
9964 return ToIncludeLoc.takeError();
9975 if (
Cache->OrigEntry &&
Cache->OrigEntry->getDir()) {
9986 ToID = ToSM.
createFileID(*Entry, ToIncludeLocOrFakeLoc,
9993 std::optional<llvm::MemoryBufferRef> FromBuf =
9999 std::unique_ptr<llvm::MemoryBuffer> ToBuf =
10000 llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(),
10001 FromBuf->getBufferIdentifier());
10007 assert(ToID.
isValid() &&
"Unexpected invalid fileID was created.");
10009 ImportedFileIDs[FromID] = ToID;
10016 return ToExprOrErr.takeError();
10019 if (!LParenLocOrErr)
10020 return LParenLocOrErr.takeError();
10023 if (!RParenLocOrErr)
10024 return RParenLocOrErr.takeError();
10029 return ToTInfoOrErr.takeError();
10034 return std::move(Err);
10037 ToContext, *ToTInfoOrErr, From->
isBaseVirtual(), *LParenLocOrErr,
10038 *ToExprOrErr, *RParenLocOrErr, EllipsisLoc);
10042 return ToFieldOrErr.takeError();
10045 if (!MemberLocOrErr)
10046 return MemberLocOrErr.takeError();
10049 ToContext, cast_or_null<FieldDecl>(*ToFieldOrErr), *MemberLocOrErr,
10050 *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10053 if (!ToIFieldOrErr)
10054 return ToIFieldOrErr.takeError();
10057 if (!MemberLocOrErr)
10058 return MemberLocOrErr.takeError();
10061 ToContext, cast_or_null<IndirectFieldDecl>(*ToIFieldOrErr),
10062 *MemberLocOrErr, *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10066 return ToTInfoOrErr.takeError();
10068 return new (ToContext)
10070 *ToExprOrErr, *RParenLocOrErr);
10073 return make_error<ASTImportError>();
10079 auto Pos = ImportedCXXBaseSpecifiers.find(BaseSpec);
10080 if (Pos != ImportedCXXBaseSpecifiers.end())
10081 return Pos->second;
10084 if (!ToSourceRange)
10085 return ToSourceRange.takeError();
10088 return ToTSI.takeError();
10090 if (!ToEllipsisLoc)
10091 return ToEllipsisLoc.takeError();
10095 ImportedCXXBaseSpecifiers[BaseSpec] =
Imported;
10107 return ToOrErr.takeError();
10108 Decl *To = *ToOrErr;
10110 auto *FromDC = cast<DeclContext>(From);
10113 if (
auto *ToRecord = dyn_cast<RecordDecl>(To)) {
10114 if (!ToRecord->getDefinition()) {
10116 cast<RecordDecl>(FromDC), ToRecord,
10121 if (
auto *ToEnum = dyn_cast<EnumDecl>(To)) {
10122 if (!ToEnum->getDefinition()) {
10128 if (
auto *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
10129 if (!ToIFace->getDefinition()) {
10131 cast<ObjCInterfaceDecl>(FromDC), ToIFace,
10136 if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
10137 if (!ToProto->getDefinition()) {
10139 cast<ObjCProtocolDecl>(FromDC), ToProto,
10161 return ToSelOrErr.takeError();
10168 return ToTyOrErr.takeError();
10176 return ToTyOrErr.takeError();
10182 cast<TemplateDecl>(*ToTemplateOrErr));
10184 return ToTemplateOrErr.takeError();
10192 return ToTyOrErr.takeError();
10208 llvm_unreachable(
"Invalid DeclarationName Kind!");
10229 for (
unsigned I = 1, N = FromSel.
getNumArgs(); I < N; ++I)
10237 llvm::Error Err = llvm::Error::success();
10238 auto ImportLoop = [&](
const APValue *From,
APValue *To,
unsigned Size) {
10239 for (
unsigned Idx = 0; Idx < Size; Idx++) {
10244 switch (FromValue.
getKind()) {
10252 Result = FromValue;
10255 Result.MakeVector();
10258 ImportLoop(((
const APValue::Vec *)(
const char *)&FromValue.Data)->Elts,
10265 ImportLoop(((
const APValue::Arr *)(
const char *)&FromValue.Data)->Elts,
10266 ((
const APValue::Arr *)(
const char *)&Result.Data)->Elts,
10273 ((
const APValue::StructData *)(
const char *)&FromValue.Data)->Elts,
10274 ((
const APValue::StructData *)(
const char *)&Result.Data)->Elts,
10278 Result.MakeUnion();
10282 return std::move(Err);
10283 Result.setUnion(cast<FieldDecl>(ImpFDecl), ImpValue);
10287 Result.MakeAddrLabelDiff();
10291 return std::move(Err);
10292 Result.setAddrLabelDiff(cast<AddrLabelExpr>(ImpLHS),
10293 cast<AddrLabelExpr>(ImpRHS));
10297 const Decl *ImpMemPtrDecl =
10300 return std::move(Err);
10302 Result.setMemberPointerUninit(
10303 cast<const ValueDecl>(ImpMemPtrDecl),
10307 Result.getMemberPointerPath();
10312 return std::move(Err);
10322 "in C++20 dynamic allocation are transient so they shouldn't "
10323 "appear in the AST");
10325 if (
const auto *E =
10327 FromElemTy = E->getType();
10330 return std::move(Err);
10340 return std::move(Err);
10352 return std::move(Err);
10359 Result.MakeLValue();
10366 for (
unsigned LoopIdx = 0; LoopIdx < PathLength; LoopIdx++) {
10369 FromPath[LoopIdx].getAsBaseOrMember().getPointer();
10372 return std::move(Err);
10373 if (
auto *RD = dyn_cast<CXXRecordDecl>(
FromDecl))
10376 FromElemTy = cast<ValueDecl>(
FromDecl)->getType();
10378 ImpDecl, FromPath[LoopIdx].getAsBaseOrMember().getInt()));
10383 FromPath[LoopIdx].getAsArrayIndex());
10391 return std::move(Err);
10399 unsigned NumDecls) {
10409 if (LastDiagFromFrom)
10412 LastDiagFromFrom =
false;
10417 if (!LastDiagFromFrom)
10420 LastDiagFromFrom =
true;
10425 if (
auto *
ID = dyn_cast<ObjCInterfaceDecl>(D)) {
10426 if (!
ID->getDefinition())
10427 ID->startDefinition();
10429 else if (
auto *PD = dyn_cast<ObjCProtocolDecl>(D)) {
10430 if (!PD->getDefinition())
10431 PD->startDefinition();
10433 else if (
auto *TD = dyn_cast<TagDecl>(D)) {
10434 if (!TD->getDefinition() && !TD->isBeingDefined()) {
10435 TD->startDefinition();
10436 TD->setCompleteDefinition(
true);
10440 assert(0 &&
"CompleteDecl called on a Decl that can't be completed");
10445 llvm::DenseMap<Decl *, Decl *>::iterator Pos = ImportedDecls.find(From);
10446 assert((Pos == ImportedDecls.end() || Pos->second == To) &&
10447 "Try to import an already imported Decl");
10448 if (Pos != ImportedDecls.end())
10449 return Pos->second;
10450 ImportedDecls[From] = To;
10453 ImportedFromDecls[To] = From;
10458 AddToLookupTable(To);
10462 std::optional<ASTImportError>
10464 auto Pos = ImportDeclErrors.find(FromD);
10465 if (Pos != ImportDeclErrors.end())
10466 return Pos->second;
10468 return std::nullopt;
10472 auto InsertRes = ImportDeclErrors.insert({From, Error});
10476 assert(InsertRes.second || InsertRes.first->second.Error == Error.Error);
10481 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
10483 if (Pos != ImportedTypes.end()) {
10488 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 AddrLabelExpr * getAddrLabelDiffLHS() const
APValue & getUnionValue()
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
CharUnits & getLValueOffset()
unsigned getVectorLength() const
const AddrLabelExpr * getAddrLabelDiffRHS() const
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
const FieldDecl * getUnionField() 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
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
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.
SourceManager & getSourceManager()
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.
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.
const LangOptions & getLangOpts() const
void setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst, UsingEnumDecl *Pattern)
Remember that the using enum decl Inst is an instantiation of the using enum decl Pattern of a class ...
UsingEnumDecl * getInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst)
If the given using-enum decl Inst is an instantiation of another using-enum decl, return it.
QualType 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.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
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
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.
TranslationUnitDecl * getTranslationUnitDecl() const
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...
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...
virtual Decl * GetOriginalDecl(Decl *To)
Called by StructuralEquivalenceContext.
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.
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 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.
ASTContext & getFromContext() const
Retrieve the context that AST nodes are being imported from.
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...
NonEquivalentDeclSet & getNonEquivalentDecls()
Return the set of declarations that we know are not equivalent.
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.
ASTContext & getToContext() const
Retrieve the context that AST nodes are being imported into.
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
LabelDecl * getLabel() const
SourceLocation getLabelLoc() 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.
Expr * getSubExpr() const
Get the initializer to use for each array element.
OpaqueValueExpr * getCommonExpr() const
Get the common subexpression shared by all initializations (the source array).
Represents a constant array type that does not decay to a pointer when used as a function parameter.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
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
TypeSourceInfo * getQueriedTypeSourceInfo() const
SourceLocation getEndLoc() const LLVM_READONLY
ArrayTypeTrait getTrait() const
Expr * getDimensionExpression() 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 * clone(ASTContext &C) const
attr::Kind getKind() const
void setPackExpansion(bool PE)
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 * getTrueExpr() const
getTrueExpr - Return the subexpression which will be evaluated if the condition evaluates to true; th...
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
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.
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.
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.
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.
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.
TypeSourceInfo * getTypeSourceInfo() const
Retrieves the type and source location of the base 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).
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.
const Expr * getSubExpr() const
static CXXBindTemporaryExpr * Create(const ASTContext &C, CXXTemporary *Temp, Expr *SubExpr)
CXXTemporary * getTemporary()
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
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...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Represents a C++ constructor within a class.
Represents a C++ conversion function within a class.
Represents a C++ base or member initializer.
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
IndirectFieldDecl * getIndirectMember() const
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
SourceLocation getRParenLoc() const
SourceLocation getEllipsisLoc() const
SourceLocation getLParenLoc() const
bool isPackExpansion() const
Determine whether this initializer is a pack expansion.
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.
Expr * getInit() const
Get the initializer.
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
bool isIndirectMemberInitializer() const
SourceLocation getMemberLocation() 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]).
const ParmVarDecl * getParam() const
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Expr * getRewrittenExpr()
const DeclContext * getUsedContext() const
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.
bool hasRewrittenInit() const
SourceLocation getBeginLoc() const
const Expr * getRewrittenExpr() const
Retrieve the initializing expression with evaluated immediate calls, if any.
const DeclContext * getUsedContext() const
FieldDecl * getField()
Get the field whose initializer will be used.
Represents a delete expression for memory deallocation and destructor calls, e.g.
SourceLocation getBeginLoc() const
FunctionDecl * getOperatorDelete() 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)
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
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.
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
ArrayRef< TemplateArgumentLoc > template_arguments() const
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.
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.
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
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
SourceLocation getLParenLoc() const
SourceLocation getEllipsisLoc() const
std::optional< unsigned > getNumExpansions() 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...
SourceLocation getLocation() const LLVM_READONLY
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will call.
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
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.
unsigned getNumPlacementArgs() const
Expr * getInitializer()
The initializer of this new-expression.
TypeSourceInfo * getAllocatedTypeSourceInfo() const
SourceRange getSourceRange() const
SourceRange getTypeIdParens() const
llvm::iterator_range< arg_iterator > placement_arguments()
FunctionDecl * getOperatorDelete() const
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
FunctionDecl * getOperatorNew() const
std::optional< Expr * > getArraySize()
This might return std::nullopt even if isArray() returns true, since there might not be an array size...
static CXXNewExpr * Create(const ASTContext &Ctx, bool IsGlobalNew, FunctionDecl *OperatorNew, FunctionDecl *OperatorDelete, bool ShouldPassAlignment, bool UsualArrayDeleteWantsSize, ArrayRef< Expr * > PlacementArgs, SourceRange TypeIdParens, std::optional< Expr * > ArraySize, CXXNewInitializationStyle InitializationStyle, Expr *Initializer, QualType Ty, TypeSourceInfo *AllocatedTypeInfo, SourceRange Range, SourceRange DirectInitRange)
Create a c++ new expression.
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Expr * getOperand() const
SourceLocation getEndLoc() 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]).
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise,...
SourceLocation getTildeLoc() const
Retrieve the location of the '~'.
TypeSourceInfo * getScopeTypeInfo() const
Retrieve the scope type in a qualified pseudo-destructor expression.
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.
const IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
SourceLocation getColonColonLoc() const
Retrieve the location of the '::' in a qualified pseudo-destructor expression.
SourceLocation getOperatorLoc() const
Retrieve the location of the '.' or '->' operator.
TypeSourceInfo * getDestroyedTypeInfo() const
Retrieve the source location information for the type being destroyed.
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
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.
CXXRecordDecl * getPreviousDecl()
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 * getDefinition() const
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.
bool isReversed() const
Determine whether this expression was rewritten in reverse form.
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
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...
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
bool isTypeOperand() const
SourceRange getSourceRange() const LLVM_READONLY
Expr * getExprOperand() const
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.
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this class template specialization is an instantiation of a template (rather than an explicit spec...
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
void setPointOfInstantiation(SourceLocation Loc)
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
void setExternKeywordLoc(SourceLocation Loc)
Sets the location of the extern keyword.
void setSpecializationKind(TemplateSpecializationKind TSK)
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.
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
TypeSourceInfo * getTypeSourceInfo() const
const Expr * getInitializer() 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 DeclarationNameInfo & getConceptNameInfo() const
NamedDecl * getFoundDecl() const
ConceptDecl * getNamedConcept() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
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.
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
SourceLocation getBuiltinLoc() const
getBuiltinLoc - Return the location of the __builtin_convertvector token.
TypeSourceInfo * getTypeSourceInfo() const
getTypeSourceInfo - Return the destination type.
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...
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
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.
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...
ArrayRef< TemplateArgumentLoc > template_arguments() const
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name,...
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
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.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given 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'.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
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.
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.
void setLexicalDeclContext(DeclContext *DC)
DeclContext * getDeclContext()
The name of a declaration.
const IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it.
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
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.
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
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)
TypeSourceInfo * getTypeSourceInfo() const
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
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)
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
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...
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.
ArrayRef< TemplateArgumentLoc > template_arguments() const
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.
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
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 * getInit() const
Retrieve the initializer value.
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 * getSubExpr(unsigned Idx) const
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.
const Expr * getInitExpr() const
llvm::APSInt getInitVal() const
EnumDecl * getMostRecentDecl()
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.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
EnumDecl * getDefinition() const
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...
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.
const Expr * getExpr() const
ExplicitSpecKind getKind() const
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
bool cleanupsHaveSideEffects() const
unsigned getNumObjects() const
ArrayRef< CleanupObject > getObjects() 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.
Expr * getQueriedExpression() const
SourceLocation getBeginLoc() const LLVM_READONLY
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.
const VariableArrayType * getCapturedVLAType() const
Get the captured variable length array type.
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.
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,...
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
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)
bool UsesFPIntrin() const
Determine whether the function was declared in source context that requires constrained FP intrinsics...
SourceLocation getDefaultLoc() 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.
StringLiteral * getDeletedMessage() const
Get the message that indicates why this function was deleted.
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.
void setRangeEnd(SourceLocation E)
bool isDefaulted() const
Whether this function is defaulted.
ArrayRef< ParmVarDecl * > parameters() const
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.
FunctionDecl * getDefinition()
Get the definition for this declaration.
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.
ArrayRef< QualType > param_types() const
ArrayRef< QualType > exceptions() const
ExtProtoInfo getExtProtoInfo() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
FunctionDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
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.
ArrayRef< Expr * > getAssocExprs() const
bool isExprPredicate() const
Whether this generic selection uses an expression as its controlling argument.
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
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
TypeSourceInfo * getControllingType()
Return the controlling type of this generic selection expression.
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.
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.
ArrayRef< NamedDecl * > chain() const
unsigned getChainingSize() const
IndirectGotoStmt - This represents an indirect goto.
Description of a constructor that was inherited from a base class.
ConstructorUsingShadowDecl * getShadowDecl() const
CXXConstructorDecl * getConstructor() const
Describes an C or C++ initializer list.
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
void setSyntacticForm(InitListExpr *Init)
unsigned getNumInits() const
SourceLocation getLBraceLoc() const
ArrayRef< Expr * > inits()
void setArrayFiller(Expr *filler)
bool hadArrayRangeDesignator() const
SourceLocation getRBraceLoc() const
void setInitializedFieldInUnion(FieldDecl *FD)
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
void sawArrayRangeDesignator(bool ARD=true)
InitListExpr * getSyntacticForm() const
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.
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.
ValueDecl * getCapturedVar() const
Retrieve the declaration of the local variable being captured.
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.
llvm::iterator_range< capture_init_iterator > capture_inits()
Retrieve the initialization expressions for this lambda's captures.
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.
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
ValueDecl * getExtendingDecl()
Expr * getTemporaryExpr()
Retrieve the expression to which the temporary materialization conversion was applied.
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.
LifetimeExtendedTemporaryDecl * getLifetimeExtendedTemporaryDecl()
bool isBoundToLvalueReference() const
Determine whether this materialized temporary is bound to an lvalue reference; otherwise,...
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
SourceLocation getOperatorLoc() const
ArrayRef< TemplateArgumentLoc > template_arguments() 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,...
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...
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
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.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
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
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
bool isInline() const
Returns true if this is an inline namespace declaration.
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.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier 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.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.
const Type * getAsType() const
Retrieve the type stored in 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.
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.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
unsigned getDepth() const
Get the nesting depth of the template parameter.
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter, and whether that default argument was inherited...
NullStmt - This is the null statement ";": C99 6.8.3p3.
Represents Objective-C's @catch statement.
Represents Objective-C's @finally statement.
Represents Objective-C's @synchronized statement.
Represents Objective-C's @throw statement.
Represents Objective-C's @try ... @catch ... @finally statement.
static ObjCAtTryStmt * Create(const ASTContext &Context, SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt)
Represents Objective-C's @autoreleasepool Statement.
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
ObjCCategoryDecl - Represents a category declaration.
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this category.
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
ObjCCategoryImplDecl * getImplementation() const
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
ObjCInterfaceDecl * getClassInterface()
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
const ObjCInterfaceDecl * getSuperClass() const
SourceLocation getSuperClassLoc() 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.
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
bool isImplicitInterfaceDecl() const
isImplicitInterfaceDecl - check that this is an implicitly declared ObjCInterfaceDecl node.
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.
TypeSourceInfo * getSuperClassTInfo() const
ObjCProtocolList::iterator protocol_iterator
ObjCImplementationDecl * getImplementation() const
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class.
protocol_iterator protocol_begin() const
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
ObjCInterfaceDecl * getSuperClass() 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.
unsigned param_size() const
bool isPropertyAccessor() const
param_const_iterator param_end() const
param_const_iterator param_begin() const
SourceLocation getEndLoc() const LLVM_READONLY
bool isSynthesizedAccessorStub() const
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type.
ImplicitParamDecl * getSelfDecl() const
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()
ArrayRef< ParmVarDecl * > parameters() const
TypeSourceInfo * getReturnTypeSourceInfo() const
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
bool isInstanceProperty() const
SourceLocation getSetterNameLoc() const
SourceLocation getAtLoc() const
void setPropertyAttributes(ObjCPropertyAttribute::Kind PRVal)
ObjCMethodDecl * getGetterMethodDecl() const
Selector getSetterName() const
ObjCIvarDecl * getPropertyIvarDecl() 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
TypeSourceInfo * getTypeSourceInfo() const
void setGetterName(Selector Sel, SourceLocation Loc=SourceLocation())
PropertyControl getPropertyImplementation() const
void setGetterMethodDecl(ObjCMethodDecl *gDecl)
ObjCMethodDecl * getSetterMethodDecl() const
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
SourceLocation getPropertyIvarDeclLoc() const
ObjCIvarDecl * getPropertyIvarDecl() const
ObjCPropertyDecl * getPropertyDecl() const
Kind getPropertyImplementation() 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.
void startDefinition()
Starts the definition of this Objective-C protocol.
ObjCProtocolList::iterator protocol_iterator
protocol_iterator protocol_begin() const
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
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,...
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr * > exprs, SourceLocation RParenLoc)
TypeSourceInfo * getTypeSourceInfo() const
const OffsetOfNode & getComponent(unsigned Idx) const
unsigned getNumExpressions() const
SourceLocation getRParenLoc() const
Return the location of the right parentheses.
Expr * getIndexExpr(unsigned Idx)
unsigned getNumComponents() const
Helper class for OffsetOfExpr.
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
FieldDecl * getField() const
For a field offsetof node, returns the field.
CXXBaseSpecifier * getBase() const
For a base class node, returns the base specifier.
@ 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
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.
llvm::iterator_range< decls_iterator > decls() const
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...
SourceLocation getNameLoc() const
Gets the location of the name.
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
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.
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.
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.
Expr * getPattern()
Retrieve the pattern of the 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 ')'.
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
ArrayRef< Expr * > exprs()
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.
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
TemplateName getUnderlyingTemplate() const
Return the underlying template name.
bool hasTemplateKeyword() const
Whether the template name was prefixed by the "template" keyword.
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
void setAnonymousStructOrUnion(bool Anon)
field_range fields() const
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
virtual void completeDefinition()
Note that the definition of this type is now complete.
RecordDecl * getMostRecentDecl()
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 * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first 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.
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof...
NamedDecl * getPack() const
Retrieve the parameter pack.
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, std::optional< unsigned > Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs=std::nullopt)
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
unsigned getPackLength() const
Retrieve the length of the parameter pack.
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
const DeclContext * getParentContext() const
If the SourceLocExpr has been resolved return the subexpression representing the resolved value.
SourceLocation getBeginLoc() const
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.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
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...
FileManager & getFileManager() const
SourceLocation getComposedLoc(FileID FID, unsigned Offset) const
Form a SourceLocation from a FileID and Offset pair.
FileID getMainFileID() const
Returns the FileID of the main source file.
unsigned getFileIDSize(FileID FID) const
The size of the SLocEntry that FID represents.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
SourceLocation createExpansionLoc(SourceLocation SpellingLoc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned Length, bool ExpansionIsTokenRange=true, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0)
Creates an expansion SLocEntry for a macro use.
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
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
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
SourceLocation getIncludeLoc() const
const ContentCache & getContentCache() const
This is a discriminated union of FileInfo and ExpansionInfo.
const ExpansionInfo & getExpansion() const
const FileInfo & getFile() 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
bool isReferenceParameter() 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.
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
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
std::optional< unsigned > getPackIndex() const
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...
void startDefinition()
Starts the definition of this tag declaration.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
TypedefNameDecl * getTypedefNameForAnonDecl() const
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.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
QualType getParamTypeForDecl() const
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.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
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.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
QualType getIntegralType() const
Retrieve the type of the integral value.
bool getIsDefaulted() const
If returns 'true', this TemplateArgument corresponds to a default template parameter.
@ 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.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
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.
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
NamedDecl * getParam(unsigned Idx)
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
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.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
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.
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
unsigned getIndex() const
Retrieve the index of the template parameter.
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
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)
void setDefaultArgument(const ASTContext &C, const TemplateArgumentLoc &DefArg)
Set the default argument for this template parameter.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
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.
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.
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
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
RetTy 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
TypeSourceInfo * getArgumentTypeInfo() const
bool isArgumentType() 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.
bool hasStoredFPFeatures() const
Is FPFeatures in Trailing Storage?
Expr * getSubExpr() const
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)
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the 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)
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.
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
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.
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
NamedDecl * getInstantiatedFromUsingDecl() const
Get the using declaration from which this was instantiated.
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.
SourceLocation getBuiltinLoc() const
SourceLocation getRParenLoc() const
bool isMicrosoftABI() const
Returns whether this is really a Win64 ABI va_arg expression.
TypeSourceInfo * getWrittenTypeInfo() const
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()
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to.
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.
const Expr * getInit() const
void setTSCSpec(ThreadStorageClassSpecifier TSC)
bool isInline() const
Whether this variable is (C++1z) inline.
ThreadStorageClassSpecifier getTSCSpec() const
void setConstexpr(bool IC)
void setDescribedVarTemplate(VarTemplateDecl *Template)
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void setImplicitlyInline()
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.
VarTemplateDecl * getMostRecentDecl()
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...
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.
VarTemplateSpecializationDecl * getMostRecentDecl()
void setSpecializationKind(TemplateSpecializationKind TSK)
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
void setPointOfInstantiation(SourceLocation Loc)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
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.
unsigned llvm::PointerUnion< const Decl *, const Expr * > DeclTy
bool LE(InterpState &S, CodePtr OpPC)
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.
@ 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