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/ErrorHandling.h"
63#include "llvm/Support/MemoryBuffer.h"
74 using llvm::make_error;
89 return "NameConflict";
91 return "UnsupportedConstruct";
93 return "Unknown error";
95 llvm_unreachable(
"Invalid error code.");
96 return "Invalid error code.";
102 llvm_unreachable(
"Function not implemented.");
113 Redecls.push_back(R);
116 std::reverse(Redecls.begin(), Redecls.end());
121 if (
auto *FD = dyn_cast<FunctionDecl>(D))
123 if (
auto *VD = dyn_cast<VarDecl>(D))
125 if (
auto *TD = dyn_cast<TagDecl>(D))
127 llvm_unreachable(
"Bad declaration kind");
148 bool const IgnoreChildErrors;
152 : FromDC(FromDC), IgnoreChildErrors(!
isa<
TagDecl>(FromDC)) {}
162 if (ChildErr && !IgnoreChildErrors)
163 ResultErr = joinErrors(std::move(ResultErr), std::move(ChildErr));
165 consumeError(std::move(ChildErr));
171 if (!IgnoreChildErrors || !FromDC)
173 return FromDC->containsDecl(FromChildD);
179 public StmtVisitor<ASTNodeImporter, ExpectedStmt> {
183 template <
typename ImportT>
184 [[nodiscard]]
Error importInto(ImportT &To,
const ImportT &From) {
185 return Importer.importInto(To, From);
189 template <
typename ImportT>
190 [[nodiscard]]
Error importInto(ImportT *&To, ImportT *From) {
191 auto ToOrErr = Importer.Import(From);
193 To = cast_or_null<ImportT>(*ToOrErr);
194 return ToOrErr.takeError();
199 template <
typename T>
203 auto ToOrErr = Importer.Import(From);
205 return ToOrErr.takeError();
206 return cast_or_null<T>(*ToOrErr);
209 template <
typename T>
210 auto import(
const T *From) {
211 return import(
const_cast<T *
>(From));
215 template <
typename T>
217 return Importer.Import(From);
221 template <
typename T>
225 return import(*From);
232 template <
typename ToDeclT>
struct CallOverloadedCreateFun {
233 template <
typename... Args>
decltype(
auto)
operator()(Args &&... args) {
234 return ToDeclT::Create(std::forward<Args>(args)...);
244 template <
typename ToDeclT,
typename FromDeclT,
typename... Args>
245 [[nodiscard]]
bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
250 CallOverloadedCreateFun<ToDeclT> OC;
251 return GetImportedOrCreateSpecialDecl(ToD, OC, FromD,
252 std::forward<Args>(args)...);
259 template <
typename NewDeclT,
typename ToDeclT,
typename FromDeclT,
261 [[nodiscard]]
bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
263 CallOverloadedCreateFun<NewDeclT> OC;
264 return GetImportedOrCreateSpecialDecl(ToD, OC, FromD,
265 std::forward<Args>(args)...);
269 template <
typename ToDeclT,
typename CreateFunT,
typename FromDeclT,
272 GetImportedOrCreateSpecialDecl(ToDeclT *&ToD, CreateFunT CreateFun,
273 FromDeclT *FromD, Args &&...args) {
274 if (Importer.getImportDeclErrorIfAny(FromD)) {
278 ToD = cast_or_null<ToDeclT>(Importer.GetAlreadyImportedOrNull(FromD));
281 ToD = CreateFun(std::forward<Args>(args)...);
283 Importer.RegisterImportedDecl(FromD, ToD);
284 Importer.SharedState->markAsNewDecl(ToD);
285 InitializeImportedDecl(FromD, ToD);
289 void InitializeImportedDecl(
Decl *FromD,
Decl *ToD) {
293 if (FromD->isImplicit())
307 void addDeclToContexts(
Decl *FromD,
Decl *ToD) {
308 if (Importer.isMinimalImport()) {
312 if (!FromD->getDescribedTemplate() &&
319 DeclContext *FromLexicalDC = FromD->getLexicalDeclContext();
323 bool Visible =
false;
336 if (
auto *FromNamed = dyn_cast<NamedDecl>(FromD)) {
339 FromDC->
lookup(FromNamed->getDeclName());
340 if (llvm::is_contained(FromLookup, FromNamed))
353 LT->update(TP, OldDC);
357 updateLookupTableForTemplateParameters(
358 Params, Importer.getToContext().getTranslationUnitDecl());
361 template <
typename TemplateParmDeclT>
362 Error importTemplateParameterDefaultArgument(
const TemplateParmDeclT *D,
363 TemplateParmDeclT *ToD) {
364 if (D->hasDefaultArgument()) {
365 if (D->defaultArgumentWasInherited()) {
367 import(D->getDefaultArgStorage().getInheritedFrom());
368 if (!ToInheritedFromOrErr)
369 return ToInheritedFromOrErr.takeError();
370 TemplateParmDeclT *ToInheritedFrom = *ToInheritedFromOrErr;
371 if (!ToInheritedFrom->hasDefaultArgument()) {
375 import(D->getDefaultArgStorage()
377 ->getDefaultArgument());
378 if (!ToInheritedDefaultArgOrErr)
379 return ToInheritedDefaultArgOrErr.takeError();
380 ToInheritedFrom->setDefaultArgument(Importer.getToContext(),
381 *ToInheritedDefaultArgOrErr);
383 ToD->setInheritedDefaultArgument(ToD->getASTContext(),
387 import(D->getDefaultArgument());
388 if (!ToDefaultArgOrErr)
389 return ToDefaultArgOrErr.takeError();
392 if (!ToD->hasDefaultArgument())
393 ToD->setDefaultArgument(Importer.getToContext(),
397 return Error::success();
409#define TYPE(Class, Base) \
410 ExpectedType Visit##Class##Type(const Class##Type *T);
411#include "clang/AST/TypeNodes.inc"
448 (IDK ==
IDK_Default && !Importer.isMinimalImport());
469 template <
typename InContainerTy>
473 template<
typename InContainerTy>
480 std::tuple<FunctionTemplateDecl *, TemplateArgsTy>;
485 template <
typename DeclTy>
509 template <
typename T>
513 bool IgnoreTemplateParmDepth =
false);
721 Err = MaybeVal.takeError();
727 template<
typename IIter,
typename OIter>
729 using ItemT = std::remove_reference_t<
decltype(*Obegin)>;
730 for (; Ibegin != Iend; ++Ibegin, ++Obegin) {
733 return ToOrErr.takeError();
736 return Error::success();
743 template<
typename InContainerTy,
typename OutContainerTy>
745 const InContainerTy &InContainer, OutContainerTy &OutContainer) {
747 InContainer.begin(), InContainer.end(), OutContainer.begin());
750 template<
typename InContainerTy,
typename OIter>
767template <
typename InContainerTy>
771 auto ToLAngleLocOrErr =
import(FromLAngleLoc);
772 if (!ToLAngleLocOrErr)
773 return ToLAngleLocOrErr.takeError();
774 auto ToRAngleLocOrErr =
import(FromRAngleLoc);
775 if (!ToRAngleLocOrErr)
776 return ToRAngleLocOrErr.takeError();
781 Result = std::move(ToTAInfo);
782 return Error::success();
798 From.LAngleLoc, From.RAngleLoc, From.arguments(),
Result);
810 if (
Error Err = importInto(std::get<0>(
Result), FTSInfo->getTemplate()))
811 return std::move(Err);
816 return std::move(Err);
826 return std::move(Err);
829 if (!ToRequiresClause)
830 return ToRequiresClause.takeError();
833 if (!ToTemplateLocOrErr)
834 return ToTemplateLocOrErr.takeError();
836 if (!ToLAngleLocOrErr)
837 return ToLAngleLocOrErr.takeError();
839 if (!ToRAngleLocOrErr)
840 return ToRAngleLocOrErr.takeError();
843 Importer.getToContext(),
861 return ToTypeOrErr.takeError();
869 return ToTypeOrErr.takeError();
876 return ToOrErr.takeError();
879 return ToTypeOrErr.takeError();
880 return TemplateArgument(dyn_cast<ValueDecl>((*ToOrErr)->getCanonicalDecl()),
887 return ToTypeOrErr.takeError();
895 return ToTypeOrErr.takeError();
898 return ToValueOrErr.takeError();
905 if (!ToTemplateOrErr)
906 return ToTemplateOrErr.takeError();
914 if (!ToTemplateOrErr)
915 return ToTemplateOrErr.takeError();
926 return ToExpr.takeError();
932 return std::move(Err);
938 llvm_unreachable(
"Invalid template argument kind");
946 return ArgOrErr.takeError();
955 return E.takeError();
961 return TSIOrErr.takeError();
964 if (!ToTemplateKWLocOrErr)
965 return ToTemplateKWLocOrErr.takeError();
967 if (!ToTemplateQualifierLocOrErr)
968 return ToTemplateQualifierLocOrErr.takeError();
970 if (!ToTemplateNameLocOrErr)
971 return ToTemplateNameLocOrErr.takeError();
972 auto ToTemplateEllipsisLocOrErr =
974 if (!ToTemplateEllipsisLocOrErr)
975 return ToTemplateEllipsisLocOrErr.takeError();
977 Importer.getToContext(), *ToTemplateKWLocOrErr,
978 *ToTemplateQualifierLocOrErr, *ToTemplateNameLocOrErr,
979 *ToTemplateEllipsisLocOrErr);
989 size_t NumDecls = DG.
end() - DG.
begin();
991 ToDecls.reserve(NumDecls);
992 for (
Decl *FromD : DG) {
993 if (
auto ToDOrErr =
import(FromD))
994 ToDecls.push_back(*ToDOrErr);
996 return ToDOrErr.takeError();
1011 return ToDotLocOrErr.takeError();
1014 if (!ToFieldLocOrErr)
1015 return ToFieldLocOrErr.takeError();
1018 ToFieldName, *ToDotLocOrErr, *ToFieldLocOrErr);
1022 if (!ToLBracketLocOrErr)
1023 return ToLBracketLocOrErr.takeError();
1026 if (!ToRBracketLocOrErr)
1027 return ToRBracketLocOrErr.takeError();
1031 *ToLBracketLocOrErr,
1032 *ToRBracketLocOrErr);
1035 if (!ToEllipsisLocOrErr)
1036 return ToEllipsisLocOrErr.takeError();
1040 D.
getArrayIndex(), *ToLBracketLocOrErr, *ToEllipsisLocOrErr,
1041 *ToRBracketLocOrErr);
1046 Error Err = Error::success();
1049 auto ToConceptNameLoc =
1055 return std::move(Err);
1058 if (ASTTemplateArgs)
1060 return std::move(Err);
1062 Importer.getToContext(), ToNNS, ToTemplateKWLoc,
1066 Importer.getToContext(), ToTAInfo)
1072 char *ToStore =
new (Importer.getToContext())
char[FromStr.size()];
1073 std::copy(FromStr.begin(), FromStr.end(), ToStore);
1074 return StringRef(ToStore, FromStr.size());
1086 return ToSecondExpr.takeError();
1087 ToSat.
Details.emplace_back(ToSecondExpr.get());
1091 return ToCROrErr.takeError();
1092 ToSat.
Details.emplace_back(ToCROrErr.get());
1099 return ToPairFirst.takeError();
1101 ToSat.
Details.emplace_back(
new (Importer.getToContext())
1103 ToPairFirst.get(), ToPairSecond});
1107 return Error::success();
1112ASTNodeImporter::import(
1117 return ToLoc.takeError();
1119 return new (Importer.getToContext())
1131 return DiagOrErr.takeError();
1132 return new (Importer.getToContext()) TypeRequirement(*DiagOrErr);
1136 return ToType.takeError();
1137 return new (Importer.getToContext()) TypeRequirement(*ToType);
1145 bool IsRKSimple = From->
getKind() == Requirement::RK_Simple;
1148 std::optional<ExprRequirement::ReturnTypeRequirement> Req;
1154 const ExprRequirement::ReturnTypeRequirement &FromTypeRequirement =
1157 if (FromTypeRequirement.isTypeConstraint()) {
1158 const bool IsDependent = FromTypeRequirement.isDependent();
1160 import(FromTypeRequirement.getTypeConstraintTemplateParameterList());
1162 return ParamsOrErr.takeError();
1163 if (Status >= ExprRequirement::SS_ConstraintsNotSatisfied) {
1164 auto SubstConstraintExprOrErr =
1166 if (!SubstConstraintExprOrErr)
1167 return SubstConstraintExprOrErr.takeError();
1168 SubstitutedConstraintExpr = SubstConstraintExprOrErr.get();
1170 Req.emplace(ParamsOrErr.get(), IsDependent);
1171 }
else if (FromTypeRequirement.isSubstitutionFailure()) {
1172 auto DiagOrErr =
import(FromTypeRequirement.getSubstitutionDiagnostic());
1174 return DiagOrErr.takeError();
1175 Req.emplace(DiagOrErr.get());
1182 if (!NoexceptLocOrErr)
1183 return NoexceptLocOrErr.takeError();
1185 if (Status == ExprRequirement::SS_ExprSubstitutionFailure) {
1188 return DiagOrErr.takeError();
1189 return new (Importer.getToContext()) ExprRequirement(
1190 *DiagOrErr, IsRKSimple, *NoexceptLocOrErr, std::move(*Req));
1194 return ExprOrErr.takeError();
1196 *ExprOrErr, IsRKSimple, *NoexceptLocOrErr, std::move(*Req), Status,
1197 SubstitutedConstraintExpr);
1212 return new (Importer.getToContext())
1213 NestedRequirement(ToEntity, ToSatisfaction);
1217 return ToExpr.takeError();
1218 if (ToExpr.get()->isInstantiationDependent()) {
1219 return new (Importer.getToContext()) NestedRequirement(ToExpr.get());
1224 return std::move(Err);
1225 return new (Importer.getToContext()) NestedRequirement(
1226 Importer.getToContext(), ToExpr.get(), Satisfaction);
1234 switch (FromRequire->
getKind()) {
1244 llvm_unreachable(
"Unhandled requirement kind");
1254 return VarOrErr.takeError();
1259 return LocationOrErr.takeError();
1264 return std::move(Err);
1271template <
typename T>
1273 if (
Found->getLinkageInternal() != From->getLinkageInternal())
1276 if (From->hasExternalFormalLinkage())
1277 return Found->hasExternalFormalLinkage();
1278 if (Importer.GetFromTU(
Found) != From->getTranslationUnitDecl())
1280 if (From->isInAnonymousNamespace())
1281 return Found->isInAnonymousNamespace();
1283 return !
Found->isInAnonymousNamespace() &&
1284 !
Found->hasExternalFormalLinkage();
1304using namespace clang;
1310 FunctionDeclsWithImportInProgress.insert(D);
1313 return llvm::scope_exit([
this, LambdaD]() {
1315 FunctionDeclsWithImportInProgress.erase(LambdaD);
1322 return FunctionDeclsWithImportInProgress.find(D) !=
1323 FunctionDeclsWithImportInProgress.end();
1327 Importer.FromDiag(
SourceLocation(), diag::err_unsupported_ast_node)
1328 <<
T->getTypeClassName();
1333 ExpectedType UnderlyingTypeOrErr =
import(
T->getValueType());
1334 if (!UnderlyingTypeOrErr)
1335 return UnderlyingTypeOrErr.takeError();
1337 return Importer.getToContext().getAtomicType(*UnderlyingTypeOrErr);
1341 switch (
T->getKind()) {
1342#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1343 case BuiltinType::Id: \
1344 return Importer.getToContext().SingletonId;
1345#include "clang/Basic/OpenCLImageTypes.def"
1346#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1347 case BuiltinType::Id: \
1348 return Importer.getToContext().Id##Ty;
1349#include "clang/Basic/OpenCLExtensionTypes.def"
1350#define SVE_TYPE(Name, Id, SingletonId) \
1351 case BuiltinType::Id: \
1352 return Importer.getToContext().SingletonId;
1353#include "clang/Basic/AArch64ACLETypes.def"
1354#define PPC_VECTOR_TYPE(Name, Id, Size) \
1355 case BuiltinType::Id: \
1356 return Importer.getToContext().Id##Ty;
1357#include "clang/Basic/PPCTypes.def"
1358#define RVV_TYPE(Name, Id, SingletonId) \
1359 case BuiltinType::Id: \
1360 return Importer.getToContext().SingletonId;
1361#include "clang/Basic/RISCVVTypes.def"
1362#define WASM_TYPE(Name, Id, SingletonId) \
1363 case BuiltinType::Id: \
1364 return Importer.getToContext().SingletonId;
1365#include "clang/Basic/WebAssemblyReferenceTypes.def"
1366#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1367 case BuiltinType::Id: \
1368 return Importer.getToContext().SingletonId;
1369#include "clang/Basic/AMDGPUTypes.def"
1370#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1371 case BuiltinType::Id: \
1372 return Importer.getToContext().SingletonId;
1373#include "clang/Basic/HLSLIntangibleTypes.def"
1374#define SHARED_SINGLETON_TYPE(Expansion)
1375#define BUILTIN_TYPE(Id, SingletonId) \
1376 case BuiltinType::Id: return Importer.getToContext().SingletonId;
1377#include "clang/AST/BuiltinTypes.def"
1385 case BuiltinType::Char_U:
1389 if (Importer.getToContext().getLangOpts().CharIsSigned)
1390 return Importer.getToContext().UnsignedCharTy;
1392 return Importer.getToContext().CharTy;
1394 case BuiltinType::Char_S:
1398 if (!Importer.getToContext().getLangOpts().CharIsSigned)
1399 return Importer.getToContext().SignedCharTy;
1401 return Importer.getToContext().CharTy;
1403 case BuiltinType::WChar_S:
1404 case BuiltinType::WChar_U:
1407 return Importer.getToContext().WCharTy;
1410 llvm_unreachable(
"Invalid BuiltinType Kind!");
1413ExpectedType ASTNodeImporter::VisitDecayedType(
const DecayedType *
T) {
1414 ExpectedType ToOriginalTypeOrErr =
import(
T->getOriginalType());
1415 if (!ToOriginalTypeOrErr)
1416 return ToOriginalTypeOrErr.takeError();
1418 return Importer.getToContext().getDecayedType(*ToOriginalTypeOrErr);
1421ExpectedType ASTNodeImporter::VisitComplexType(
const ComplexType *
T) {
1422 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1423 if (!ToElementTypeOrErr)
1424 return ToElementTypeOrErr.takeError();
1426 return Importer.getToContext().getComplexType(*ToElementTypeOrErr);
1429ExpectedType ASTNodeImporter::VisitPointerType(
const PointerType *
T) {
1431 if (!ToPointeeTypeOrErr)
1432 return ToPointeeTypeOrErr.takeError();
1434 return Importer.getToContext().getPointerType(*ToPointeeTypeOrErr);
1437ExpectedType ASTNodeImporter::VisitBlockPointerType(
const BlockPointerType *
T) {
1440 if (!ToPointeeTypeOrErr)
1441 return ToPointeeTypeOrErr.takeError();
1443 return Importer.getToContext().getBlockPointerType(*ToPointeeTypeOrErr);
1447ASTNodeImporter::VisitLValueReferenceType(
const LValueReferenceType *
T) {
1449 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1450 if (!ToPointeeTypeOrErr)
1451 return ToPointeeTypeOrErr.takeError();
1453 return Importer.getToContext().getLValueReferenceType(*ToPointeeTypeOrErr);
1457ASTNodeImporter::VisitRValueReferenceType(
const RValueReferenceType *
T) {
1459 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1460 if (!ToPointeeTypeOrErr)
1461 return ToPointeeTypeOrErr.takeError();
1463 return Importer.getToContext().getRValueReferenceType(*ToPointeeTypeOrErr);
1467ASTNodeImporter::VisitMemberPointerType(
const MemberPointerType *
T) {
1470 if (!ToPointeeTypeOrErr)
1471 return ToPointeeTypeOrErr.takeError();
1473 auto QualifierOrErr =
import(
T->getQualifier());
1474 if (!QualifierOrErr)
1475 return QualifierOrErr.takeError();
1477 auto ClsOrErr =
import(
T->getMostRecentCXXRecordDecl());
1479 return ClsOrErr.takeError();
1481 return Importer.getToContext().getMemberPointerType(
1482 *ToPointeeTypeOrErr, *QualifierOrErr, *ClsOrErr);
1486ASTNodeImporter::VisitConstantArrayType(
const ConstantArrayType *
T) {
1487 Error Err = Error::success();
1488 auto ToElementType = importChecked(Err,
T->getElementType());
1489 auto ToSizeExpr = importChecked(Err,
T->getSizeExpr());
1491 return std::move(Err);
1493 return Importer.getToContext().getConstantArrayType(
1494 ToElementType,
T->getSize(), ToSizeExpr,
T->getSizeModifier(),
1495 T->getIndexTypeCVRQualifiers());
1499ASTNodeImporter::VisitArrayParameterType(
const ArrayParameterType *
T) {
1501 if (!ToArrayTypeOrErr)
1502 return ToArrayTypeOrErr.takeError();
1504 return Importer.getToContext().getArrayParameterType(*ToArrayTypeOrErr);
1508ASTNodeImporter::VisitIncompleteArrayType(
const IncompleteArrayType *
T) {
1509 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1510 if (!ToElementTypeOrErr)
1511 return ToElementTypeOrErr.takeError();
1513 return Importer.getToContext().getIncompleteArrayType(*ToElementTypeOrErr,
1514 T->getSizeModifier(),
1515 T->getIndexTypeCVRQualifiers());
1519ASTNodeImporter::VisitVariableArrayType(
const VariableArrayType *
T) {
1520 Error Err = Error::success();
1521 QualType ToElementType = importChecked(Err,
T->getElementType());
1522 Expr *ToSizeExpr = importChecked(Err,
T->getSizeExpr());
1524 return std::move(Err);
1525 return Importer.getToContext().getVariableArrayType(
1526 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1527 T->getIndexTypeCVRQualifiers());
1530ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(
1531 const DependentSizedArrayType *
T) {
1532 Error Err = Error::success();
1533 QualType ToElementType = importChecked(Err,
T->getElementType());
1534 Expr *ToSizeExpr = importChecked(Err,
T->getSizeExpr());
1536 return std::move(Err);
1540 return Importer.getToContext().getDependentSizedArrayType(
1541 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1542 T->getIndexTypeCVRQualifiers());
1545ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType(
1546 const DependentSizedExtVectorType *
T) {
1547 Error Err = Error::success();
1548 QualType ToElementType = importChecked(Err,
T->getElementType());
1549 Expr *ToSizeExpr = importChecked(Err,
T->getSizeExpr());
1550 SourceLocation ToAttrLoc = importChecked(Err,
T->getAttributeLoc());
1552 return std::move(Err);
1553 return Importer.getToContext().getDependentSizedExtVectorType(
1554 ToElementType, ToSizeExpr, ToAttrLoc);
1557ExpectedType ASTNodeImporter::VisitVectorType(
const VectorType *
T) {
1558 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1559 if (!ToElementTypeOrErr)
1560 return ToElementTypeOrErr.takeError();
1562 return Importer.getToContext().getVectorType(*ToElementTypeOrErr,
1563 T->getNumElements(),
1564 T->getVectorKind());
1567ExpectedType ASTNodeImporter::VisitExtVectorType(
const ExtVectorType *
T) {
1568 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1569 if (!ToElementTypeOrErr)
1570 return ToElementTypeOrErr.takeError();
1572 return Importer.getToContext().getExtVectorType(*ToElementTypeOrErr,
1573 T->getNumElements());
1577ASTNodeImporter::VisitFunctionNoProtoType(
const FunctionNoProtoType *
T) {
1581 if (!ToReturnTypeOrErr)
1582 return ToReturnTypeOrErr.takeError();
1584 return Importer.getToContext().getFunctionNoProtoType(*ToReturnTypeOrErr,
1589ASTNodeImporter::VisitFunctionProtoType(
const FunctionProtoType *
T) {
1591 if (!ToReturnTypeOrErr)
1592 return ToReturnTypeOrErr.takeError();
1595 SmallVector<QualType, 4> ArgTypes;
1599 return TyOrErr.takeError();
1600 ArgTypes.push_back(*TyOrErr);
1604 SmallVector<QualType, 4> ExceptionTypes;
1608 return TyOrErr.takeError();
1609 ExceptionTypes.push_back(*TyOrErr);
1613 Error Err = Error::success();
1614 FunctionProtoType::ExtProtoInfo ToEPI;
1630 return std::move(Err);
1632 return Importer.getToContext().getFunctionType(
1633 *ToReturnTypeOrErr, ArgTypes, ToEPI);
1637 const UnresolvedUsingType *
T) {
1638 Error Err = Error::success();
1639 auto ToQualifier = importChecked(Err,
T->getQualifier());
1640 auto *ToD = importChecked(Err,
T->getDecl());
1642 return std::move(Err);
1645 return Importer.getToContext().getCanonicalUnresolvedUsingType(ToD);
1646 return Importer.getToContext().getUnresolvedUsingType(
T->getKeyword(),
1650ExpectedType ASTNodeImporter::VisitParenType(
const ParenType *
T) {
1652 if (!ToInnerTypeOrErr)
1653 return ToInnerTypeOrErr.takeError();
1655 return Importer.getToContext().getParenType(*ToInnerTypeOrErr);
1659ASTNodeImporter::VisitPackIndexingType(clang::PackIndexingType
const *
T) {
1663 return Pattern.takeError();
1666 return Index.takeError();
1667 return Importer.getToContext().getPackIndexingType(*Pattern, *Index);
1670ExpectedType ASTNodeImporter::VisitTypedefType(
const TypedefType *
T) {
1671 Expected<TypedefNameDecl *> ToDeclOrErr =
import(
T->getDecl());
1673 return ToDeclOrErr.takeError();
1675 auto ToQualifierOrErr =
import(
T->getQualifier());
1676 if (!ToQualifierOrErr)
1677 return ToQualifierOrErr.takeError();
1680 T->typeMatchesDecl() ? QualType() : import(
T->desugar());
1681 if (!ToUnderlyingTypeOrErr)
1682 return ToUnderlyingTypeOrErr.takeError();
1684 return Importer.getToContext().getTypedefType(
1685 T->getKeyword(), *ToQualifierOrErr, *ToDeclOrErr, *ToUnderlyingTypeOrErr);
1688ExpectedType ASTNodeImporter::VisitTypeOfExprType(
const TypeOfExprType *
T) {
1691 return ToExprOrErr.takeError();
1692 return Importer.getToContext().getTypeOfExprType(*ToExprOrErr,
T->getKind());
1695ExpectedType ASTNodeImporter::VisitTypeOfType(
const TypeOfType *
T) {
1696 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnmodifiedType());
1697 if (!ToUnderlyingTypeOrErr)
1698 return ToUnderlyingTypeOrErr.takeError();
1699 return Importer.getToContext().getTypeOfType(*ToUnderlyingTypeOrErr,
1703ExpectedType ASTNodeImporter::VisitUsingType(
const UsingType *
T) {
1704 Error Err = Error::success();
1705 auto ToQualifier = importChecked(Err,
T->getQualifier());
1706 auto *ToD = importChecked(Err,
T->getDecl());
1707 QualType ToT = importChecked(Err,
T->
desugar());
1709 return std::move(Err);
1710 return Importer.getToContext().getUsingType(
T->getKeyword(), ToQualifier, ToD,
1714ExpectedType ASTNodeImporter::VisitDecltypeType(
const DecltypeType *
T) {
1718 return ToExprOrErr.takeError();
1720 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1721 if (!ToUnderlyingTypeOrErr)
1722 return ToUnderlyingTypeOrErr.takeError();
1724 return Importer.getToContext().getDecltypeType(
1725 *ToExprOrErr, *ToUnderlyingTypeOrErr);
1729ASTNodeImporter::VisitUnaryTransformType(
const UnaryTransformType *
T) {
1731 if (!ToBaseTypeOrErr)
1732 return ToBaseTypeOrErr.takeError();
1734 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1735 if (!ToUnderlyingTypeOrErr)
1736 return ToUnderlyingTypeOrErr.takeError();
1738 return Importer.getToContext().getUnaryTransformType(
1739 *ToBaseTypeOrErr, *ToUnderlyingTypeOrErr,
T->getUTTKind());
1742ExpectedType ASTNodeImporter::VisitAutoType(
const AutoType *
T) {
1744 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1745 if (!ToDeducedTypeOrErr)
1746 return ToDeducedTypeOrErr.takeError();
1748 Expected<TemplateDecl *> ToTypeConstraint =
1749 import(
T->getTypeConstraintConcept());
1750 if (!ToTypeConstraint)
1751 return ToTypeConstraint.takeError();
1753 SmallVector<TemplateArgument, 2> ToTemplateArgs;
1756 return std::move(Err);
1758 return Importer.getToContext().getAutoType(
1759 T->getDeducedKind(), *ToDeducedTypeOrErr,
T->getKeyword(),
1760 *ToTypeConstraint, ToTemplateArgs);
1763ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
1764 const DeducedTemplateSpecializationType *
T) {
1766 Expected<TemplateName> ToTemplateNameOrErr =
import(
T->getTemplateName());
1767 if (!ToTemplateNameOrErr)
1768 return ToTemplateNameOrErr.takeError();
1769 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1770 if (!ToDeducedTypeOrErr)
1771 return ToDeducedTypeOrErr.takeError();
1773 return Importer.getToContext().getDeducedTemplateSpecializationType(
1774 T->getDeducedKind(), *ToDeducedTypeOrErr,
T->getKeyword(),
1775 *ToTemplateNameOrErr);
1778ExpectedType ASTNodeImporter::VisitTagType(
const TagType *
T) {
1779 TagDecl *DeclForType =
T->getDecl();
1780 Expected<TagDecl *> ToDeclOrErr =
import(DeclForType);
1782 return ToDeclOrErr.takeError();
1788 Expected<TagDecl *> ToDefDeclOrErr =
import(DeclForType->
getDefinition());
1789 if (!ToDefDeclOrErr)
1790 return ToDefDeclOrErr.takeError();
1793 return Importer.getToContext().getCanonicalTagType(*ToDeclOrErr);
1795 auto ToQualifierOrErr =
import(
T->getQualifier());
1796 if (!ToQualifierOrErr)
1797 return ToQualifierOrErr.takeError();
1799 return Importer.getToContext().getTagType(
T->getKeyword(), *ToQualifierOrErr,
1800 *ToDeclOrErr,
T->isTagOwned());
1803ExpectedType ASTNodeImporter::VisitEnumType(
const EnumType *
T) {
1804 return VisitTagType(
T);
1807ExpectedType ASTNodeImporter::VisitRecordType(
const RecordType *
T) {
1808 return VisitTagType(
T);
1812ASTNodeImporter::VisitInjectedClassNameType(
const InjectedClassNameType *
T) {
1813 return VisitTagType(
T);
1816ExpectedType ASTNodeImporter::VisitAttributedType(
const AttributedType *
T) {
1817 ExpectedType ToModifiedTypeOrErr =
import(
T->getModifiedType());
1818 if (!ToModifiedTypeOrErr)
1819 return ToModifiedTypeOrErr.takeError();
1820 ExpectedType ToEquivalentTypeOrErr =
import(
T->getEquivalentType());
1821 if (!ToEquivalentTypeOrErr)
1822 return ToEquivalentTypeOrErr.takeError();
1824 return Importer.getToContext().getAttributedType(
1825 T->getAttrKind(), *ToModifiedTypeOrErr, *ToEquivalentTypeOrErr,
1830ASTNodeImporter::VisitCountAttributedType(
const CountAttributedType *
T) {
1832 if (!ToWrappedTypeOrErr)
1833 return ToWrappedTypeOrErr.takeError();
1835 Error Err = Error::success();
1836 Expr *CountExpr = importChecked(Err,
T->getCountExpr());
1838 SmallVector<TypeCoupledDeclRefInfo, 1> CoupledDecls;
1839 for (
const TypeCoupledDeclRefInfo &TI :
T->dependent_decls()) {
1840 Expected<ValueDecl *> ToDeclOrErr =
import(TI.getDecl());
1842 return ToDeclOrErr.takeError();
1843 CoupledDecls.emplace_back(*ToDeclOrErr, TI.isDeref());
1846 return Importer.getToContext().getCountAttributedType(
1847 *ToWrappedTypeOrErr, CountExpr,
T->isCountInBytes(),
T->isOrNull(),
1848 ArrayRef(CoupledDecls));
1852ASTNodeImporter::VisitLateParsedAttrType(
const LateParsedAttrType *
T) {
1853 llvm_unreachable(
"should be replaced with a concrete type before AST import");
1856ExpectedType ASTNodeImporter::VisitTemplateTypeParmType(
1857 const TemplateTypeParmType *
T) {
1858 Expected<TemplateTypeParmDecl *> ToDeclOrErr =
import(
T->getDecl());
1860 return ToDeclOrErr.takeError();
1862 return Importer.getToContext().getTemplateTypeParmType(
1863 T->getDepth(),
T->getIndex(),
T->isParameterPack(), *ToDeclOrErr);
1866ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmType(
1867 const SubstTemplateTypeParmType *
T) {
1868 Expected<Decl *> ReplacedOrErr =
import(
T->getAssociatedDecl());
1870 return ReplacedOrErr.takeError();
1872 ExpectedType ToReplacementTypeOrErr =
import(
T->getReplacementType());
1873 if (!ToReplacementTypeOrErr)
1874 return ToReplacementTypeOrErr.takeError();
1876 return Importer.getToContext().getSubstTemplateTypeParmType(
1877 *ToReplacementTypeOrErr, *ReplacedOrErr,
T->getIndex(),
T->getPackIndex(),
1881ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmPackType(
1882 const SubstTemplateTypeParmPackType *
T) {
1883 Expected<Decl *> ReplacedOrErr =
import(
T->getAssociatedDecl());
1885 return ReplacedOrErr.takeError();
1887 Expected<TemplateArgument> ToArgumentPack =
import(
T->getArgumentPack());
1888 if (!ToArgumentPack)
1889 return ToArgumentPack.takeError();
1891 return Importer.getToContext().getSubstTemplateTypeParmPackType(
1892 *ReplacedOrErr,
T->getIndex(),
T->getFinal(), *ToArgumentPack);
1895ExpectedType ASTNodeImporter::VisitSubstBuiltinTemplatePackType(
1896 const SubstBuiltinTemplatePackType *
T) {
1897 Expected<TemplateArgument> ToArgumentPack =
import(
T->getArgumentPack());
1898 if (!ToArgumentPack)
1899 return ToArgumentPack.takeError();
1900 return Importer.getToContext().getSubstBuiltinTemplatePack(*ToArgumentPack);
1903ExpectedType ASTNodeImporter::VisitTemplateSpecializationType(
1904 const TemplateSpecializationType *
T) {
1905 auto ToTemplateOrErr =
import(
T->getTemplateName());
1906 if (!ToTemplateOrErr)
1907 return ToTemplateOrErr.takeError();
1909 SmallVector<TemplateArgument, 2> ToTemplateArgs;
1912 return std::move(Err);
1916 if (!ToUnderlyingOrErr)
1917 return ToUnderlyingOrErr.takeError();
1918 return Importer.getToContext().getTemplateSpecializationType(
1919 T->getKeyword(), *ToTemplateOrErr, ToTemplateArgs, {},
1920 *ToUnderlyingOrErr);
1924ASTNodeImporter::VisitPackExpansionType(
const PackExpansionType *
T) {
1926 if (!ToPatternOrErr)
1927 return ToPatternOrErr.takeError();
1929 return Importer.getToContext().getPackExpansionType(*ToPatternOrErr,
1930 T->getNumExpansions(),
1935ASTNodeImporter::VisitDependentNameType(
const DependentNameType *
T) {
1936 auto ToQualifierOrErr =
import(
T->getQualifier());
1937 if (!ToQualifierOrErr)
1938 return ToQualifierOrErr.takeError();
1940 IdentifierInfo *Name = Importer.Import(
T->getIdentifier());
1941 return Importer.getToContext().getDependentNameType(
T->getKeyword(),
1942 *ToQualifierOrErr, Name);
1946ASTNodeImporter::VisitObjCInterfaceType(
const ObjCInterfaceType *
T) {
1947 Expected<ObjCInterfaceDecl *> ToDeclOrErr =
import(
T->getDecl());
1949 return ToDeclOrErr.takeError();
1951 return Importer.getToContext().getObjCInterfaceType(*ToDeclOrErr);
1954ExpectedType ASTNodeImporter::VisitObjCObjectType(
const ObjCObjectType *
T) {
1956 if (!ToBaseTypeOrErr)
1957 return ToBaseTypeOrErr.takeError();
1959 SmallVector<QualType, 4> TypeArgs;
1960 for (
auto TypeArg :
T->getTypeArgsAsWritten()) {
1962 TypeArgs.push_back(*TyOrErr);
1964 return TyOrErr.takeError();
1967 SmallVector<ObjCProtocolDecl *, 4> Protocols;
1968 for (
auto *P :
T->quals()) {
1969 if (Expected<ObjCProtocolDecl *> ProtocolOrErr =
import(P))
1970 Protocols.push_back(*ProtocolOrErr);
1972 return ProtocolOrErr.takeError();
1976 return Importer.getToContext().getObjCObjectType(*ToBaseTypeOrErr, TypeArgs,
1978 T->isKindOfTypeAsWritten());
1982ASTNodeImporter::VisitObjCObjectPointerType(
const ObjCObjectPointerType *
T) {
1984 if (!ToPointeeTypeOrErr)
1985 return ToPointeeTypeOrErr.takeError();
1987 return Importer.getToContext().getObjCObjectPointerType(*ToPointeeTypeOrErr);
1991ASTNodeImporter::VisitMacroQualifiedType(
const MacroQualifiedType *
T) {
1992 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1993 if (!ToUnderlyingTypeOrErr)
1994 return ToUnderlyingTypeOrErr.takeError();
1996 IdentifierInfo *ToIdentifier = Importer.Import(
T->getMacroIdentifier());
1997 return Importer.getToContext().getMacroQualifiedType(*ToUnderlyingTypeOrErr,
2001ExpectedType clang::ASTNodeImporter::VisitAdjustedType(
const AdjustedType *
T) {
2002 Error Err = Error::success();
2003 QualType ToOriginalType = importChecked(Err,
T->getOriginalType());
2004 QualType ToAdjustedType = importChecked(Err,
T->getAdjustedType());
2006 return std::move(Err);
2008 return Importer.getToContext().getAdjustedType(ToOriginalType,
2012ExpectedType clang::ASTNodeImporter::VisitBitIntType(
const BitIntType *
T) {
2013 return Importer.getToContext().getBitIntType(
T->isUnsigned(),
2017ExpectedType clang::ASTNodeImporter::VisitBTFTagAttributedType(
2018 const clang::BTFTagAttributedType *
T) {
2019 Error Err = Error::success();
2020 const BTFTypeTagAttr *ToBTFAttr = importChecked(Err,
T->getAttr());
2021 QualType ToWrappedType = importChecked(Err,
T->getWrappedType());
2023 return std::move(Err);
2025 return Importer.getToContext().getBTFTagAttributedType(ToBTFAttr,
2029ExpectedType clang::ASTNodeImporter::VisitOverflowBehaviorType(
2030 const clang::OverflowBehaviorType *
T) {
2031 Error Err = Error::success();
2032 OverflowBehaviorType::OverflowBehaviorKind ToKind =
T->getBehaviorKind();
2035 return std::move(Err);
2037 return Importer.getToContext().getOverflowBehaviorType(ToKind,
2041ExpectedType clang::ASTNodeImporter::VisitHLSLAttributedResourceType(
2042 const clang::HLSLAttributedResourceType *
T) {
2043 Error Err = Error::success();
2044 const HLSLAttributedResourceType::Attributes &ToAttrs =
T->getAttrs();
2045 QualType ToWrappedType = importChecked(Err,
T->getWrappedType());
2046 QualType ToContainedType = importChecked(Err,
T->getContainedType());
2048 return std::move(Err);
2050 return Importer.getToContext().getHLSLAttributedResourceType(
2051 ToWrappedType, ToContainedType, ToAttrs);
2054ExpectedType clang::ASTNodeImporter::VisitHLSLInlineSpirvType(
2055 const clang::HLSLInlineSpirvType *
T) {
2056 Error Err = Error::success();
2060 uint32_t ToAlignment =
T->getAlignment();
2062 llvm::SmallVector<SpirvOperand> ToOperands;
2064 for (
auto &Operand :
T->getOperands()) {
2065 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
2068 case SpirvOperandKind::ConstantId:
2069 ToOperands.push_back(SpirvOperand::createConstant(
2070 importChecked(Err,
Operand.getResultType()),
Operand.getValue()));
2072 case SpirvOperandKind::Literal:
2073 ToOperands.push_back(SpirvOperand::createLiteral(
Operand.getValue()));
2075 case SpirvOperandKind::TypeId:
2076 ToOperands.push_back(SpirvOperand::createType(
2077 importChecked(Err,
Operand.getResultType())));
2080 llvm_unreachable(
"Invalid SpirvOperand kind");
2084 return std::move(Err);
2087 return Importer.getToContext().getHLSLInlineSpirvType(
2088 ToOpcode, ToSize, ToAlignment, ToOperands);
2091ExpectedType clang::ASTNodeImporter::VisitConstantMatrixType(
2092 const clang::ConstantMatrixType *
T) {
2093 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
2094 if (!ToElementTypeOrErr)
2095 return ToElementTypeOrErr.takeError();
2097 return Importer.getToContext().getConstantMatrixType(
2098 *ToElementTypeOrErr,
T->getNumRows(),
T->getNumColumns());
2101ExpectedType clang::ASTNodeImporter::VisitDependentAddressSpaceType(
2102 const clang::DependentAddressSpaceType *
T) {
2103 Error Err = Error::success();
2105 Expr *ToAddrSpaceExpr = importChecked(Err,
T->getAddrSpaceExpr());
2106 SourceLocation ToAttrLoc = importChecked(Err,
T->getAttributeLoc());
2108 return std::move(Err);
2110 return Importer.getToContext().getDependentAddressSpaceType(
2111 ToPointeeType, ToAddrSpaceExpr, ToAttrLoc);
2114ExpectedType clang::ASTNodeImporter::VisitDependentBitIntType(
2115 const clang::DependentBitIntType *
T) {
2116 ExpectedExpr ToNumBitsExprOrErr =
import(
T->getNumBitsExpr());
2117 if (!ToNumBitsExprOrErr)
2118 return ToNumBitsExprOrErr.takeError();
2119 return Importer.getToContext().getDependentBitIntType(
T->isUnsigned(),
2120 *ToNumBitsExprOrErr);
2123ExpectedType clang::ASTNodeImporter::VisitPredefinedSugarType(
2124 const clang::PredefinedSugarType *
T) {
2125 return Importer.getToContext().getPredefinedSugarType(
T->getKind());
2128ExpectedType clang::ASTNodeImporter::VisitDependentSizedMatrixType(
2129 const clang::DependentSizedMatrixType *
T) {
2130 Error Err = Error::success();
2131 QualType ToElementType = importChecked(Err,
T->getElementType());
2132 Expr *ToRowExpr = importChecked(Err,
T->getRowExpr());
2133 Expr *ToColumnExpr = importChecked(Err,
T->getColumnExpr());
2134 SourceLocation ToAttrLoc = importChecked(Err,
T->getAttributeLoc());
2136 return std::move(Err);
2138 return Importer.getToContext().getDependentSizedMatrixType(
2139 ToElementType, ToRowExpr, ToColumnExpr, ToAttrLoc);
2142ExpectedType clang::ASTNodeImporter::VisitDependentVectorType(
2143 const clang::DependentVectorType *
T) {
2144 Error Err = Error::success();
2145 QualType ToElementType = importChecked(Err,
T->getElementType());
2146 Expr *ToSizeExpr = importChecked(Err,
T->getSizeExpr());
2147 SourceLocation ToAttrLoc = importChecked(Err,
T->getAttributeLoc());
2149 return std::move(Err);
2151 return Importer.getToContext().getDependentVectorType(
2152 ToElementType, ToSizeExpr, ToAttrLoc,
T->getVectorKind());
2155ExpectedType clang::ASTNodeImporter::VisitObjCTypeParamType(
2156 const clang::ObjCTypeParamType *
T) {
2157 Expected<ObjCTypeParamDecl *> ToDeclOrErr =
import(
T->getDecl());
2159 return ToDeclOrErr.takeError();
2161 SmallVector<ObjCProtocolDecl *, 4> ToProtocols;
2162 for (ObjCProtocolDecl *FromProtocol :
T->getProtocols()) {
2163 Expected<ObjCProtocolDecl *> ToProtocolOrErr =
import(FromProtocol);
2164 if (!ToProtocolOrErr)
2165 return ToProtocolOrErr.takeError();
2166 ToProtocols.push_back(*ToProtocolOrErr);
2169 return Importer.getToContext().getObjCTypeParamType(*ToDeclOrErr,
2173ExpectedType clang::ASTNodeImporter::VisitPipeType(
const clang::PipeType *
T) {
2174 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
2175 if (!ToElementTypeOrErr)
2176 return ToElementTypeOrErr.takeError();
2178 ASTContext &ToCtx = Importer.getToContext();
2179 if (
T->isReadOnly())
2199 if (
isa<RecordDecl>(D) && (FunDecl = dyn_cast<FunctionDecl>(OrigDC)) &&
2201 auto getLeafPointeeType = [](
const Type *
T) {
2202 while (
T->isPointerType() ||
T->isArrayType()) {
2203 T =
T->getPointeeOrArrayElementType();
2209 getLeafPointeeType(
P->getType().getCanonicalType().getTypePtr());
2210 auto *RT = dyn_cast<RecordType>(LeafT);
2211 if (RT && RT->getDecl() == D) {
2212 Importer.FromDiag(D->
getLocation(), diag::err_unsupported_ast_node)
2231 ToD = cast_or_null<NamedDecl>(Importer.GetAlreadyImportedOrNull(D));
2236 return Error::success();
2250 ToD = cast_or_null<NamedDecl>(Importer.GetAlreadyImportedOrNull(D));
2255 return Error::success();
2260 return Error::success();
2266 if (
RecordDecl *FromRecord = dyn_cast<RecordDecl>(FromD)) {
2268 if (FromRecord->getDefinition() && FromRecord->isCompleteDefinition() &&
2269 !ToRecord->getDefinition()) {
2274 return Error::success();
2277 if (
EnumDecl *FromEnum = dyn_cast<EnumDecl>(FromD)) {
2279 if (FromEnum->getDefinition() && !ToEnum->getDefinition()) {
2284 return Error::success();
2287 return Error::success();
2302 return Error::success();
2308 return ToRangeOrErr.takeError();
2309 return Error::success();
2315 return LocOrErr.takeError();
2316 return Error::success();
2324 return ToTInfoOrErr.takeError();
2325 return Error::success();
2328 llvm_unreachable(
"Unknown name kind.");
2333 if (Importer.isMinimalImport() && !ForceImport) {
2334 auto ToDCOrErr = Importer.ImportContext(FromDC);
2335 return ToDCOrErr.takeError();
2349 auto MightNeedReordering = [](
const Decl *D) {
2354 Error ChildErrors = Error::success();
2355 for (
auto *From : FromDC->
decls()) {
2356 if (!MightNeedReordering(From))
2365 if (!ImportedOrErr) {
2367 ImportedOrErr.takeError());
2370 FieldDecl *FieldFrom = dyn_cast_or_null<FieldDecl>(From);
2371 Decl *ImportedDecl = *ImportedOrErr;
2372 FieldDecl *FieldTo = dyn_cast_or_null<FieldDecl>(ImportedDecl);
2373 if (FieldFrom && FieldTo) {
2403 auto ToDCOrErr = Importer.ImportContext(FromDC);
2405 consumeError(std::move(ChildErrors));
2406 return ToDCOrErr.takeError();
2409 if (
const auto *FromRD = dyn_cast<RecordDecl>(FromDC)) {
2413 for (
auto *D : FromRD->decls()) {
2414 if (!MightNeedReordering(D))
2417 assert(D &&
"DC contains a null decl");
2418 if (
Decl *ToD = Importer.GetAlreadyImportedOrNull(D)) {
2420 assert(ToDC == ToD->getLexicalDeclContext() && ToDC->
containsDecl(ToD));
2432 for (
auto *From : FromDC->
decls()) {
2433 if (MightNeedReordering(From))
2439 ImportedOrErr.takeError());
2459 if (!FromRecordDecl || !ToRecordDecl) {
2460 const RecordType *RecordFrom = FromType->
getAs<RecordType>();
2461 const RecordType *RecordTo = ToType->
getAs<RecordType>();
2463 if (RecordFrom && RecordTo) {
2464 FromRecordDecl = RecordFrom->getDecl();
2465 ToRecordDecl = RecordTo->getDecl();
2469 if (FromRecordDecl && ToRecordDecl) {
2475 return Error::success();
2480 auto ToDCOrErr = Importer.ImportContext(FromD->
getDeclContext());
2482 return ToDCOrErr.takeError();
2486 auto ToLexicalDCOrErr = Importer.ImportContext(
2488 if (!ToLexicalDCOrErr)
2489 return ToLexicalDCOrErr.takeError();
2490 ToLexicalDC = *ToLexicalDCOrErr;
2494 return Error::success();
2500 "Import implicit methods to or from non-definition");
2503 if (FromM->isImplicit()) {
2506 return ToMOrErr.takeError();
2509 return Error::success();
2518 return ToTypedefOrErr.takeError();
2520 return Error::success();
2525 auto DefinitionCompleter = [To]() {
2546 ToCaptures.reserve(FromCXXRD->capture_size());
2547 for (
const auto &FromCapture : FromCXXRD->captures()) {
2548 if (
auto ToCaptureOrErr =
import(FromCapture))
2549 ToCaptures.push_back(*ToCaptureOrErr);
2551 return ToCaptureOrErr.takeError();
2560 DefinitionCompleter();
2564 return Error::success();
2574 if (!Importer.isMinimalImport())
2579 llvm::scope_exit DefinitionCompleterScopeExit(DefinitionCompleter);
2585 auto *ToCXX = dyn_cast<CXXRecordDecl>(To);
2586 auto *FromCXX = dyn_cast<CXXRecordDecl>(From);
2587 if (ToCXX && FromCXX && ToCXX->dataPtr() && FromCXX->dataPtr()) {
2589 struct CXXRecordDecl::DefinitionData &ToData = ToCXX->data();
2590 struct CXXRecordDecl::DefinitionData &FromData = FromCXX->data();
2592 #define FIELD(Name, Width, Merge) \
2593 ToData.Name = FromData.Name;
2594 #include "clang/AST/CXXRecordDeclDefinitionBits.def"
2597 ToCXX->setArgPassingRestrictions(FromCXX->getArgPassingRestrictions());
2600 for (
const auto &Base1 : FromCXX->bases()) {
2603 return TyOrErr.takeError();
2606 if (Base1.isPackExpansion()) {
2607 if (
ExpectedSLoc LocOrErr =
import(Base1.getEllipsisLoc()))
2608 EllipsisLoc = *LocOrErr;
2610 return LocOrErr.takeError();
2618 auto RangeOrErr =
import(Base1.getSourceRange());
2620 return RangeOrErr.takeError();
2622 auto TSIOrErr =
import(Base1.getTypeSourceInfo());
2624 return TSIOrErr.takeError();
2630 Base1.isBaseOfClass(),
2631 Base1.getAccessSpecifierAsWritten(),
2636 ToCXX->setBases(Bases.data(), Bases.size());
2644 return Error::success();
2649 return Error::success();
2653 return Error::success();
2657 return ToInitOrErr.takeError();
2668 return Error::success();
2676 return Error::success();
2685 import(
QualType(Importer.getFromContext().getCanonicalTagType(From)));
2687 return ToTypeOrErr.takeError();
2690 if (!ToPromotionTypeOrErr)
2691 return ToPromotionTypeOrErr.takeError();
2702 return Error::success();
2708 for (
const auto &Arg : FromArgs) {
2709 if (
auto ToOrErr =
import(Arg))
2710 ToArgs.push_back(*ToOrErr);
2712 return ToOrErr.takeError();
2715 return Error::success();
2721 return import(From);
2724template <
typename InContainerTy>
2727 for (
const auto &FromLoc : Container) {
2728 if (
auto ToLocOrErr =
import(FromLoc))
2731 return ToLocOrErr.takeError();
2733 return Error::success();
2743 bool IgnoreTemplateParmDepth) {
2746 Decl *ToOrigin = Importer.GetOriginalDecl(To);
2752 Importer.getToContext().getLangOpts(), Importer.getFromContext(),
2753 Importer.getToContext(), Importer.getNonEquivalentDecls(),
2755 false, Complain,
false,
2756 IgnoreTemplateParmDepth);
2761 Importer.FromDiag(D->
getLocation(), diag::err_unsupported_ast_node)
2767 Importer.FromDiag(D->
getLocation(), diag::err_unsupported_ast_node)
2776 return std::move(Err);
2781 return LocOrErr.takeError();
2784 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, *LocOrErr))
2796 Importer.MapImported(D, ToD);
2802 Error Err = Error::success();
2807 return std::move(Err);
2811 return DCOrErr.takeError();
2815 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, ToAsmString,
2816 ToAsmLoc, ToRParenLoc))
2831 return std::move(Err);
2836 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, Loc,
2840 Error Err = Error::success();
2845 return std::move(Err);
2849 addDeclToContexts(D, ToD);
2857 return LocOrErr.takeError();
2860 return ColonLocOrErr.takeError();
2865 return DCOrErr.takeError();
2869 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), D->
getAccess(),
2870 DC, *LocOrErr, *ColonLocOrErr))
2884 return DCOrErr.takeError();
2888 Error Err = Error::success();
2894 return std::move(Err);
2897 if (GetImportedOrCreateDecl(
2898 ToD, D, Importer.getToContext(), DC, ToLocation, ToAssertExpr, ToMessage,
2911 return DCOrErr.takeError();
2915 Error Err = Error::success();
2921 return std::move(Err);
2924 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, ToLocation,
2942 return std::move(Err);
2951 if (
auto *TU = dyn_cast<TranslationUnitDecl>(EnclosingDC))
2954 MergeWithNamespace =
2958 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2959 for (
auto *FoundDecl : FoundDecls) {
2963 if (
auto *FoundNS = dyn_cast<NamespaceDecl>(FoundDecl)) {
2964 MergeWithNamespace = FoundNS;
2965 ConflictingDecls.clear();
2969 ConflictingDecls.push_back(FoundDecl);
2972 if (!ConflictingDecls.empty()) {
2975 ConflictingDecls.size());
2977 Name = NameOrErr.get();
2979 return NameOrErr.takeError();
2985 return BeginLocOrErr.takeError();
2987 if (!RBraceLocOrErr)
2988 return RBraceLocOrErr.takeError();
2993 if (GetImportedOrCreateDecl(ToNamespace, D, Importer.getToContext(), DC,
2994 D->
isInline(), *BeginLocOrErr, Loc,
3005 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
3006 TU->setAnonymousNamespace(ToNamespace);
3011 Importer.MapImported(D, ToNamespace);
3014 return std::move(Err);
3026 return std::move(Err);
3032 Error Err = Error::success();
3039 return std::move(Err);
3044 if (GetImportedOrCreateDecl(
3045 ToD, D, Importer.getToContext(), DC, ToNamespaceLoc, ToAliasLoc,
3046 ToIdentifier, ToQualifierLoc, ToTargetNameLoc, ToNamespace))
3064 return std::move(Err);
3071 cast_or_null<DeclContext>(Importer.GetAlreadyImportedOrNull(
3083 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3084 for (
auto *FoundDecl : FoundDecls) {
3085 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3087 if (
auto *FoundTypedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
3092 QualType FoundUT = FoundTypedef->getUnderlyingType();
3093 if (Importer.IsStructurallyEquivalent(FromUT, FoundUT)) {
3106 if (FromR && FoundR &&
3113 return Importer.MapImported(D, FoundTypedef);
3117 ConflictingDecls.push_back(FoundDecl);
3122 if (!ConflictingDecls.empty()) {
3124 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3126 Name = NameOrErr.get();
3128 return NameOrErr.takeError();
3132 Error Err = Error::success();
3137 return std::move(Err);
3144 if (GetImportedOrCreateDecl<TypeAliasDecl>(
3145 ToTypedef, D, Importer.getToContext(), DC, ToBeginLoc, Loc,
3148 }
else if (GetImportedOrCreateDecl<TypedefDecl>(
3149 ToTypedef, D, Importer.getToContext(), DC, ToBeginLoc, Loc,
3155 return std::move(Err);
3159 Importer.AddToLookupTable(ToTypedef);
3187 return std::move(Err);
3197 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3198 for (
auto *FoundDecl : FoundDecls) {
3199 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3201 if (
auto *FoundAlias = dyn_cast<TypeAliasTemplateDecl>(FoundDecl)) {
3203 return Importer.MapImported(D, FoundAlias);
3204 ConflictingDecls.push_back(FoundDecl);
3208 if (!ConflictingDecls.empty()) {
3210 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3212 Name = NameOrErr.get();
3214 return NameOrErr.takeError();
3218 Error Err = Error::success();
3222 return std::move(Err);
3225 if (GetImportedOrCreateDecl(ToAlias, D, Importer.getToContext(), DC, Loc,
3226 Name, ToTemplateParameters, ToTemplatedDecl))
3229 ToTemplatedDecl->setDescribedAliasTemplate(ToAlias);
3234 if (DC != Importer.getToContext().getTranslationUnitDecl())
3235 updateLookupTableForTemplateParameters(*ToTemplateParameters);
3246 return std::move(Err);
3256 return BeginLocOrErr.takeError();
3257 if (GetImportedOrCreateDecl(ToLabel, D, Importer.getToContext(), DC, Loc,
3262 if (GetImportedOrCreateDecl(ToLabel, D, Importer.getToContext(), DC, Loc,
3270 return ToStmtOrErr.takeError();
3272 ToLabel->
setStmt(*ToStmtOrErr);
3285 return std::move(Err);
3295 return std::move(Err);
3297 }
else if (Importer.getToContext().getLangOpts().CPlusPlus)
3305 Importer.findDeclsInToCtx(DC, SearchName);
3306 for (
auto *FoundDecl : FoundDecls) {
3307 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3310 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
3311 if (
const auto *Tag =
Typedef->getUnderlyingType()->getAs<TagType>())
3312 FoundDecl = Tag->getDecl();
3315 if (
auto *FoundEnum = dyn_cast<EnumDecl>(FoundDecl)) {
3321 return Importer.MapImported(D, FoundDef);
3325 ConflictingDecls.push_back(FoundDecl);
3334 if (SearchName && !ConflictingDecls.empty()) {
3336 SearchName, DC, IDNS, ConflictingDecls.data(),
3337 ConflictingDecls.size());
3339 Name = NameOrErr.get();
3341 return NameOrErr.takeError();
3345 Error Err = Error::success();
3351 return std::move(Err);
3355 if (GetImportedOrCreateDecl(
3356 D2, D, Importer.getToContext(), DC, ToBeginLoc,
3366 addDeclToContexts(D, D2);
3372 D2->setInstantiationOfMemberEnum(*ToInstOrErr, SK);
3374 return ToInstOrErr.takeError();
3375 if (
ExpectedSLoc POIOrErr =
import(MemberInfo->getPointOfInstantiation()))
3378 return POIOrErr.takeError();
3384 return std::move(Err);
3390 bool IsFriendTemplate =
false;
3391 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3393 DCXX->getDescribedClassTemplate() &&
3394 DCXX->getDescribedClassTemplate()->getFriendObjectKind() !=
3404 return std::move(Err);
3414 return std::move(Err);
3416 }
else if (Importer.getToContext().getLangOpts().CPlusPlus)
3421 bool DependentFriend = IsFriendTemplate && IsDependentContext;
3428 Importer.findDeclsInToCtx(DC, SearchName);
3429 if (!FoundDecls.empty()) {
3436 for (
auto *FoundDecl : FoundDecls) {
3437 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3441 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Found)) {
3442 if (
const auto *Tag =
Typedef->getUnderlyingType()->getAs<TagType>())
3443 Found = Tag->getDecl();
3446 if (
auto *FoundRecord = dyn_cast<RecordDecl>(
Found)) {
3468 Importer.MapImported(D, FoundDef);
3469 if (
const auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3470 auto *FoundCXX = dyn_cast<CXXRecordDecl>(FoundDef);
3471 assert(FoundCXX &&
"Record type mismatch");
3473 if (!Importer.isMinimalImport())
3477 return std::move(Err);
3484 ConflictingDecls.push_back(FoundDecl);
3488 if (!ConflictingDecls.empty() && SearchName) {
3490 SearchName, DC, IDNS, ConflictingDecls.data(),
3491 ConflictingDecls.size());
3493 Name = NameOrErr.get();
3495 return NameOrErr.takeError();
3501 return BeginLocOrErr.takeError();
3506 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3507 if (DCXX->isLambda()) {
3508 auto TInfoOrErr =
import(DCXX->getLambdaTypeInfo());
3510 return TInfoOrErr.takeError();
3511 if (GetImportedOrCreateSpecialDecl(
3513 DC, *TInfoOrErr, Loc, DCXX->getLambdaDependencyKind(),
3514 DCXX->isGenericLambda(), DCXX->getLambdaCaptureDefault()))
3516 Decl *ContextDecl = DCXX->getLambdaContextDecl();
3519 return CDeclOrErr.takeError();
3520 if (ContextDecl !=
nullptr) {
3525 if (GetImportedOrCreateDecl(D2CXX, D, Importer.getToContext(),
3528 cast_or_null<CXXRecordDecl>(PrevDecl)))
3535 addDeclToContexts(D, D2);
3538 DCXX->getDescribedClassTemplate()) {
3541 return std::move(Err);
3544 DCXX->getMemberSpecializationInfo()) {
3546 MemberInfo->getTemplateSpecializationKind();
3552 return ToInstOrErr.takeError();
3555 import(MemberInfo->getPointOfInstantiation()))
3559 return POIOrErr.takeError();
3563 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(),
3568 addDeclToContexts(D, D2);
3574 return BraceRangeOrErr.takeError();
3578 return QualifierLocOrErr.takeError();
3585 return std::move(Err);
3597 return std::move(Err);
3606 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3607 for (
auto *FoundDecl : FoundDecls) {
3608 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3611 if (
auto *FoundEnumConstant = dyn_cast<EnumConstantDecl>(FoundDecl)) {
3613 return Importer.MapImported(D, FoundEnumConstant);
3614 ConflictingDecls.push_back(FoundDecl);
3618 if (!ConflictingDecls.empty()) {
3620 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3622 Name = NameOrErr.get();
3624 return NameOrErr.takeError();
3630 return TypeOrErr.takeError();
3634 return InitOrErr.takeError();
3637 if (GetImportedOrCreateDecl(
3638 ToEnumerator, D, Importer.getToContext(),
cast<EnumDecl>(DC), Loc,
3640 return ToEnumerator;
3645 return ToEnumerator;
3648template <
typename DeclTy>
3652 FromD->getTemplateParameterLists();
3653 if (FromTPLs.empty())
3654 return Error::success();
3656 for (
unsigned int I = 0; I < FromTPLs.size(); ++I)
3658 ToTPLists[I] = *ToTPListOrErr;
3660 return ToTPListOrErr.takeError();
3661 ToD->setTemplateParameterListsInfo(Importer.ToContext, ToTPLists);
3662 return Error::success();
3670 return Error::success();
3676 return Error::success();
3682 ToFD->setInstantiationOfMemberFunction(*InstFDOrErr, TSK);
3684 return InstFDOrErr.takeError();
3690 return POIOrErr.takeError();
3692 return Error::success();
3696 auto FunctionAndArgsOrErr =
3698 if (!FunctionAndArgsOrErr)
3699 return FunctionAndArgsOrErr.takeError();
3702 Importer.getToContext(), std::get<1>(*FunctionAndArgsOrErr));
3706 const auto *FromTAArgsAsWritten = FTSInfo->TemplateArgumentsAsWritten;
3707 if (FromTAArgsAsWritten)
3709 *FromTAArgsAsWritten, ToTAInfo))
3712 ExpectedSLoc POIOrErr =
import(FTSInfo->getPointOfInstantiation());
3714 return POIOrErr.takeError();
3720 ToFD->setFunctionTemplateSpecialization(
3721 std::get<0>(*FunctionAndArgsOrErr), ToTAList,
nullptr,
3722 TSK, FromTAArgsAsWritten ? &ToTAInfo :
nullptr, *POIOrErr);
3723 return Error::success();
3731 Candidates.
addDecl(*ToFTDOrErr);
3733 return ToFTDOrErr.takeError();
3738 const auto *FromTAArgsAsWritten = FromInfo->TemplateArgumentsAsWritten;
3739 if (FromTAArgsAsWritten)
3745 Importer.getToContext(), Candidates,
3746 FromTAArgsAsWritten ? &ToTAInfo :
nullptr);
3747 return Error::success();
3750 llvm_unreachable(
"All cases should be covered!");
3755 auto FunctionAndArgsOrErr =
3757 if (!FunctionAndArgsOrErr)
3758 return FunctionAndArgsOrErr.takeError();
3762 std::tie(
Template, ToTemplArgs) = *FunctionAndArgsOrErr;
3763 void *InsertPos =
nullptr;
3764 auto *FoundSpec =
Template->findSpecialization(ToTemplArgs, InsertPos);
3774 return ToBodyOrErr.takeError();
3776 return Error::success();
3782 const DeclContext *DCi = dyn_cast<DeclContext>(D);
3785 assert(DCi &&
"Declaration should have a context");
3799 ToProcess.push_back(S);
3800 while (!ToProcess.empty()) {
3801 const Stmt *CurrentS = ToProcess.pop_back_val();
3803 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(CurrentS)) {
3804 if (
const Decl *D = DeclRef->getDecl())
3807 }
else if (
const auto *E =
3808 dyn_cast_or_null<SubstNonTypeTemplateParmExpr>(CurrentS)) {
3809 if (
const Decl *D = E->getAssociatedDecl())
3842class IsTypeDeclaredInsideVisitor
3843 :
public TypeVisitor<IsTypeDeclaredInsideVisitor, std::optional<bool>> {
3845 IsTypeDeclaredInsideVisitor(
const FunctionDecl *ParentDC)
3846 : ParentDC(ParentDC) {}
3848 bool CheckType(QualType
T) {
3852 if (std::optional<bool> Res = Visit(
T.getTypePtr()))
3855 T.getSingleStepDesugaredType(ParentDC->getParentASTContext());
3857 if (std::optional<bool> Res = Visit(DsT.
getTypePtr()))
3860 DsT =
T.getSingleStepDesugaredType(ParentDC->getParentASTContext());
3865 std::optional<bool> VisitTagType(
const TagType *
T) {
3866 if (
auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(
T->getDecl()))
3867 for (
const auto &Arg : Spec->getTemplateArgs().asArray())
3868 if (checkTemplateArgument(Arg))
3873 std::optional<bool> VisitPointerType(
const PointerType *
T) {
3877 std::optional<bool> VisitReferenceType(
const ReferenceType *
T) {
3878 return CheckType(
T->getPointeeTypeAsWritten());
3881 std::optional<bool> VisitTypedefType(
const TypedefType *
T) {
3885 std::optional<bool> VisitUsingType(
const UsingType *
T) {
3890 VisitTemplateSpecializationType(
const TemplateSpecializationType *
T) {
3891 for (
const auto &Arg :
T->template_arguments())
3892 if (checkTemplateArgument(Arg))
3898 std::optional<bool> VisitUnaryTransformType(
const UnaryTransformType *
T) {
3899 return CheckType(
T->getBaseType());
3903 VisitSubstTemplateTypeParmType(
const SubstTemplateTypeParmType *
T) {
3910 std::optional<bool> VisitConstantArrayType(
const ConstantArrayType *
T) {
3914 return CheckType(
T->getElementType());
3917 std::optional<bool> VisitVariableArrayType(
const VariableArrayType *
T) {
3919 "Variable array should not occur in deduced return type of a function");
3922 std::optional<bool> VisitIncompleteArrayType(
const IncompleteArrayType *
T) {
3923 llvm_unreachable(
"Incomplete array should not occur in deduced return type "
3927 std::optional<bool> VisitDependentArrayType(
const IncompleteArrayType *
T) {
3928 llvm_unreachable(
"Dependent array should not occur in deduced return type "
3933 const DeclContext *
const ParentDC;
3935 bool checkTemplateArgument(
const TemplateArgument &Arg) {
3955 if (checkTemplateArgument(PackArg))
3967 llvm_unreachable(
"Unknown TemplateArgument::ArgKind enum");
3977 assert(FromFPT &&
"Must be called on FunctionProtoType");
3979 auto IsCXX11Lambda = [&]() {
3980 if (Importer.FromContext.getLangOpts().CPlusPlus14)
3986 QualType RetT = FromFPT->getReturnType();
3989 IsTypeDeclaredInsideVisitor Visitor(Def ? Def : D);
3990 return Visitor.CheckType(RetT);
4000 ExplicitExpr = importChecked(Err, ESpec.
getExpr());
4007 auto RedeclIt = Redecls.begin();
4010 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
4013 return ToRedeclOrErr.takeError();
4015 assert(*RedeclIt == D);
4023 return std::move(Err);
4038 if (!FoundFunctionOrErr)
4039 return FoundFunctionOrErr.takeError();
4040 if (
FunctionDecl *FoundFunction = *FoundFunctionOrErr) {
4041 if (
Decl *Def = FindAndMapDefinition(D, FoundFunction))
4043 FoundByLookup = FoundFunction;
4051 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4052 for (
auto *FoundDecl : FoundDecls) {
4053 if (!FoundDecl->isInIdentifierNamespace(IDNS))
4056 if (
auto *FoundFunction = dyn_cast<FunctionDecl>(FoundDecl)) {
4061 if (
Decl *Def = FindAndMapDefinition(D, FoundFunction))
4063 FoundByLookup = FoundFunction;
4070 if (Importer.getToContext().getLangOpts().CPlusPlus)
4074 Importer.ToDiag(Loc, diag::warn_odr_function_type_inconsistent)
4075 << Name << D->
getType() << FoundFunction->getType();
4076 Importer.ToDiag(FoundFunction->getLocation(), diag::note_odr_value_here)
4077 << FoundFunction->getType();
4078 ConflictingDecls.push_back(FoundDecl);
4082 if (!ConflictingDecls.empty()) {
4084 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
4086 Name = NameOrErr.get();
4088 return NameOrErr.takeError();
4098 if (FoundByLookup) {
4108 "Templated function mapped to non-templated?");
4109 Importer.MapImported(DescribedD,
4112 return Importer.MapImported(D, FoundByLookup);
4124 return std::move(Err);
4135 bool UsedDifferentProtoType =
false;
4137 QualType FromReturnTy = FromFPT->getReturnType();
4146 Importer.FindFunctionDeclImportCycle.isCycle(D)) {
4147 FromReturnTy = Importer.getFromContext().VoidTy;
4148 UsedDifferentProtoType =
true;
4159 FromEPI = DefaultEPI;
4160 UsedDifferentProtoType =
true;
4162 FromTy = Importer.getFromContext().getFunctionType(
4163 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
4164 FromTSI = Importer.getFromContext().getTrivialTypeSourceInfo(
4168 Error Err = Error::success();
4169 auto ScopedReturnTypeDeclCycleDetector =
4170 Importer.FindFunctionDeclImportCycle.makeScopedCycleDetection(D);
4181 return std::move(Err);
4187 Parameters.push_back(*ToPOrErr);
4189 return ToPOrErr.takeError();
4194 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
4196 importExplicitSpecifier(Err, FromConstructor->getExplicitSpecifier());
4198 return std::move(Err);
4200 if (FromConstructor->isInheritingConstructor()) {
4202 import(FromConstructor->getInheritedConstructor());
4203 if (!ImportedInheritedCtor)
4204 return ImportedInheritedCtor.takeError();
4205 ToInheritedConstructor = *ImportedInheritedCtor;
4207 if (GetImportedOrCreateDecl<CXXConstructorDecl>(
4209 ToInnerLocStart, NameInfo,
T, TInfo, ESpec, D->
UsesFPIntrin(),
4211 ToInheritedConstructor, TrailingRequiresClause))
4215 Error Err = Error::success();
4217 Err,
const_cast<FunctionDecl *
>(FromDtor->getOperatorDelete()));
4218 auto ToThisArg =
importChecked(Err, FromDtor->getOperatorDeleteThisArg());
4220 return std::move(Err);
4222 if (GetImportedOrCreateDecl<CXXDestructorDecl>(
4226 TrailingRequiresClause))
4233 dyn_cast<CXXConversionDecl>(D)) {
4235 importExplicitSpecifier(Err, FromConversion->getExplicitSpecifier());
4237 return std::move(Err);
4238 if (GetImportedOrCreateDecl<CXXConversionDecl>(
4244 }
else if (
auto *
Method = dyn_cast<CXXMethodDecl>(D)) {
4245 if (GetImportedOrCreateDecl<CXXMethodDecl>(
4247 ToInnerLocStart, NameInfo,
T, TInfo,
Method->getStorageClass(),
4251 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(D)) {
4253 importExplicitSpecifier(Err, Guide->getExplicitSpecifier());
4259 return std::move(Err);
4260 if (GetImportedOrCreateDecl<CXXDeductionGuideDecl>(
4261 ToFunction, D, Importer.getToContext(), DC, ToInnerLocStart, ESpec,
4262 NameInfo,
T, TInfo, ToEndLoc, Ctor,
4263 Guide->getDeductionCandidateKind(), TrailingRequiresClause,
4267 if (GetImportedOrCreateDecl(
4268 ToFunction, D, Importer.getToContext(), DC, ToInnerLocStart,
4276 if (FoundByLookup) {
4326 Importer.getToContext(), Lookups, Info->getFPFeatures(), Msg));
4330 for (
auto *Param : Parameters) {
4331 Param->setOwningFunction(ToFunction);
4334 LT->update(Param, Importer.getToContext().getTranslationUnitDecl());
4336 ToFunction->setParams(Parameters);
4343 for (
unsigned I = 0, N = Parameters.size(); I != N; ++I)
4344 ProtoLoc.setParam(I, Parameters[I]);
4350 auto ToFTOrErr =
import(FromFT);
4352 return ToFTOrErr.takeError();
4356 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
4357 if (
unsigned NumInitializers = FromConstructor->getNumCtorInitializers()) {
4361 FromConstructor->inits(), CtorInitializers))
4362 return std::move(Err);
4365 llvm::copy(CtorInitializers, Memory);
4367 ToCtor->setCtorInitializers(Memory);
4368 ToCtor->setNumCtorInitializers(NumInitializers);
4374 return std::move(Err);
4376 if (
auto *FromCXXMethod = dyn_cast<CXXMethodDecl>(D))
4379 return std::move(Err);
4385 return std::move(Err);
4389 if (UsedDifferentProtoType) {
4391 ToFunction->
setType(*TyOrErr);
4393 return TyOrErr.takeError();
4397 return TSIOrErr.takeError();
4402 addDeclToContexts(D, ToFunction);
4405 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4408 return ToRedeclOrErr.takeError();
4442 return std::move(Err);
4447 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4448 for (
auto *FoundDecl : FoundDecls) {
4449 if (
FieldDecl *FoundField = dyn_cast<FieldDecl>(FoundDecl)) {
4456 if (Importer.IsStructurallyEquivalent(D->
getType(),
4457 FoundField->getType())) {
4458 Importer.MapImported(D, FoundField);
4466 if (
ExpectedExpr ToInitializerOrErr =
import(FromInitializer)) {
4469 assert(FoundField->hasInClassInitializer() &&
4470 "Field should have an in-class initializer if it has an "
4471 "expression for it.");
4472 if (!FoundField->getInClassInitializer())
4473 FoundField->setInClassInitializer(*ToInitializerOrErr);
4475 return ToInitializerOrErr.takeError();
4482 Importer.ToDiag(Loc, diag::warn_odr_field_type_inconsistent)
4483 << Name << D->
getType() << FoundField->getType();
4484 Importer.ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4485 << FoundField->getType();
4491 Error Err = Error::success();
4497 return std::move(Err);
4498 const Type *ToCapturedVLAType =
nullptr;
4499 if (
Error Err = Importer.importInto(
4501 return std::move(Err);
4504 if (GetImportedOrCreateDecl(ToField, D, Importer.getToContext(), DC,
4506 ToType, ToTInfo, ToBitWidth, D->
isMutable(),
4513 if (ToCapturedVLAType)
4520 return std::move(Err);
4521 if (ToInitializer) {
4523 if (AlreadyImported)
4524 assert(ToInitializer == AlreadyImported &&
4525 "Duplicate import of in-class initializer.");
4540 return std::move(Err);
4545 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4546 for (
unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
4547 if (
auto *FoundField = dyn_cast<IndirectFieldDecl>(FoundDecls[I])) {
4554 if (Importer.IsStructurallyEquivalent(D->
getType(),
4555 FoundField->getType(),
4557 Importer.MapImported(D, FoundField);
4562 if (!Name && I < N-1)
4566 Importer.ToDiag(Loc, diag::warn_odr_field_type_inconsistent)
4567 << Name << D->
getType() << FoundField->getType();
4568 Importer.ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4569 << FoundField->getType();
4576 auto TypeOrErr =
import(D->
getType());
4578 return TypeOrErr.takeError();
4584 for (
auto *PI : D->
chain())
4586 NamedChain[i++] = *ToD;
4588 return ToD.takeError();
4592 if (GetImportedOrCreateDecl(ToIndirectField, D, Importer.getToContext(), DC,
4595 return ToIndirectField;
4600 return ToIndirectField;
4631 unsigned int FriendCount = 0;
4635 for (
FriendDecl *FoundFriend : RD->friends()) {
4636 if (FoundFriend == FD) {
4637 FriendPosition = FriendCount;
4644 assert(FriendPosition &&
"Friend decl not found in own parent.");
4646 return {FriendCount, *FriendPosition};
4653 return std::move(Err);
4660 for (
FriendDecl *ImportedFriend : RD->friends())
4662 ImportedEquivalentFriends.push_back(ImportedFriend);
4667 assert(ImportedEquivalentFriends.size() <= CountAndPosition.
TotalCount &&
4668 "Class with non-matching friends is imported, ODR check wrong?");
4669 if (ImportedEquivalentFriends.size() == CountAndPosition.
TotalCount)
4670 return Importer.MapImported(
4671 D, ImportedEquivalentFriends[CountAndPosition.
IndexOfDecl]);
4679 return std::move(Err);
4690 return TSIOrErr.takeError();
4694 auto **FromTPLists = D->getTrailingObjects();
4695 for (
unsigned I = 0; I < D->NumTPLists; I++) {
4696 if (
auto ListOrErr =
import(FromTPLists[I]))
4697 ToTPLists[I] = *ListOrErr;
4699 return ListOrErr.takeError();
4704 return LocationOrErr.takeError();
4706 if (!FriendLocOrErr)
4707 return FriendLocOrErr.takeError();
4709 if (!EllipsisLocOrErr)
4710 return EllipsisLocOrErr.takeError();
4713 if (GetImportedOrCreateDecl(FrD, D, Importer.getToContext(), DC,
4714 *LocationOrErr, ToFU, *FriendLocOrErr,
4715 *EllipsisLocOrErr, ToTPLists))
4731 return std::move(Err);
4736 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4737 for (
auto *FoundDecl : FoundDecls) {
4738 if (
ObjCIvarDecl *FoundIvar = dyn_cast<ObjCIvarDecl>(FoundDecl)) {
4739 if (Importer.IsStructurallyEquivalent(D->
getType(),
4740 FoundIvar->getType())) {
4741 Importer.MapImported(D, FoundIvar);
4745 Importer.ToDiag(Loc, diag::warn_odr_ivar_type_inconsistent)
4746 << Name << D->
getType() << FoundIvar->getType();
4747 Importer.ToDiag(FoundIvar->getLocation(), diag::note_odr_value_here)
4748 << FoundIvar->getType();
4754 Error Err = Error::success();
4760 return std::move(Err);
4763 if (GetImportedOrCreateDecl(
4766 ToType, ToTypeSourceInfo,
4778 auto RedeclIt = Redecls.begin();
4781 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
4784 return RedeclOrErr.takeError();
4786 assert(*RedeclIt == D);
4794 return std::move(Err);
4800 VarDecl *FoundByLookup =
nullptr;
4804 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4805 for (
auto *FoundDecl : FoundDecls) {
4806 if (!FoundDecl->isInIdentifierNamespace(IDNS))
4809 if (
auto *FoundVar = dyn_cast<VarDecl>(FoundDecl)) {
4812 if (Importer.IsStructurallyEquivalent(D->
getType(),
4813 FoundVar->getType())) {
4821 return Importer.MapImported(D, FoundDef);
4825 const VarDecl *FoundDInit =
nullptr;
4826 if (D->
getInit() && FoundVar->getAnyInitializer(FoundDInit))
4828 return Importer.MapImported(D,
const_cast<VarDecl*
>(FoundDInit));
4830 FoundByLookup = FoundVar;
4835 = Importer.getToContext().getAsArrayType(FoundVar->getType());
4837 = Importer.getToContext().getAsArrayType(D->
getType());
4838 if (FoundArray && TArray) {
4842 if (
auto TyOrErr =
import(D->
getType()))
4843 FoundVar->setType(*TyOrErr);
4845 return TyOrErr.takeError();
4847 FoundByLookup = FoundVar;
4851 FoundByLookup = FoundVar;
4856 Importer.ToDiag(Loc, diag::warn_odr_variable_type_inconsistent)
4857 << Name << D->
getType() << FoundVar->getType();
4858 Importer.ToDiag(FoundVar->getLocation(), diag::note_odr_value_here)
4859 << FoundVar->getType();
4860 ConflictingDecls.push_back(FoundDecl);
4864 if (!ConflictingDecls.empty()) {
4866 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
4868 Name = NameOrErr.get();
4870 return NameOrErr.takeError();
4874 Error Err = Error::success();
4880 return std::move(Err);
4883 if (
auto *FromDecomp = dyn_cast<DecompositionDecl>(D)) {
4887 return std::move(Err);
4889 if (GetImportedOrCreateDecl(
4890 ToDecomp, FromDecomp, Importer.getToContext(), DC, ToInnerLocStart,
4891 Loc, FromDecomp->getRSquareLoc(), ToType, ToTypeSourceInfo,
4897 if (GetImportedOrCreateDecl(ToVar, D, Importer.getToContext(), DC,
4898 ToInnerLocStart, Loc,
4913 if (FoundByLookup) {
4922 return ToVTOrErr.takeError();
4929 return ToInstOrErr.takeError();
4930 if (
ExpectedSLoc POIOrErr =
import(MSI->getPointOfInstantiation()))
4933 return POIOrErr.takeError();
4937 return std::move(Err);
4942 addDeclToContexts(D, ToVar);
4945 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4948 return RedeclOrErr.takeError();
4957 DeclContext *DC = Importer.getToContext().getTranslationUnitDecl();
4959 Error Err = Error::success();
4964 return std::move(Err);
4968 if (GetImportedOrCreateDecl(ToParm, D, Importer.getToContext(), DC,
4969 ToLocation, ToDeclName.getAsIdentifierInfo(),
4981 return LocOrErr.takeError();
4990 return ToDefArgOrErr.takeError();
4994 if (
auto ToDefArgOrErr =
import(FromParam->
getDefaultArg()))
4997 return ToDefArgOrErr.takeError();
5000 return Error::success();
5005 Error Err = Error::success();
5010 return std::move(Err);
5017 DeclContext *DC = Importer.getToContext().getTranslationUnitDecl();
5019 Error Err = Error::success();
5026 return std::move(Err);
5029 if (GetImportedOrCreateDecl(ToParm, D, Importer.getToContext(), DC,
5030 ToInnerLocStart, ToLocation,
5031 ToDeclName.getAsIdentifierInfo(), ToType,
5040 return std::move(Err);
5060 return std::move(Err);
5064 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5065 for (
auto *FoundDecl : FoundDecls) {
5066 if (
auto *FoundMethod = dyn_cast<ObjCMethodDecl>(FoundDecl)) {
5072 FoundMethod->getReturnType())) {
5073 Importer.ToDiag(Loc, diag::warn_odr_objc_method_result_type_inconsistent)
5075 << FoundMethod->getReturnType();
5076 Importer.ToDiag(FoundMethod->getLocation(),
5077 diag::note_odr_objc_method_here)
5084 if (D->
param_size() != FoundMethod->param_size()) {
5085 Importer.ToDiag(Loc, diag::warn_odr_objc_method_num_params_inconsistent)
5087 << D->
param_size() << FoundMethod->param_size();
5088 Importer.ToDiag(FoundMethod->getLocation(),
5089 diag::note_odr_objc_method_here)
5097 PEnd = D->
param_end(), FoundP = FoundMethod->param_begin();
5098 P != PEnd; ++
P, ++FoundP) {
5099 if (!Importer.IsStructurallyEquivalent((*P)->getType(),
5100 (*FoundP)->getType())) {
5101 Importer.FromDiag((*P)->getLocation(),
5102 diag::warn_odr_objc_method_param_type_inconsistent)
5104 << (*P)->getType() << (*FoundP)->getType();
5105 Importer.ToDiag((*FoundP)->getLocation(), diag::note_odr_value_here)
5106 << (*FoundP)->getType();
5114 if (D->
isVariadic() != FoundMethod->isVariadic()) {
5115 Importer.ToDiag(Loc, diag::warn_odr_objc_method_variadic_inconsistent)
5117 Importer.ToDiag(FoundMethod->getLocation(),
5118 diag::note_odr_objc_method_here)
5125 return Importer.MapImported(D, FoundMethod);
5129 Error Err = Error::success();
5132 auto ToReturnTypeSourceInfo =
5135 return std::move(Err);
5138 if (GetImportedOrCreateDecl(
5139 ToMethod, D, Importer.getToContext(), Loc, ToEndLoc,
5153 ToParams.push_back(*ToPOrErr);
5155 return ToPOrErr.takeError();
5159 for (
auto *ToParam : ToParams) {
5160 ToParam->setOwningFunction(ToMethod);
5168 return std::move(Err);
5170 ToMethod->
setMethodParams(Importer.getToContext(), ToParams, ToSelLocs);
5192 return std::move(Err);
5196 Error Err = Error::success();
5202 return std::move(Err);
5205 if (GetImportedOrCreateDecl(
5209 ToColonLoc, ToTypeSourceInfo))
5215 return std::move(Err);
5216 Result->setTypeForDecl(ToTypeForDecl);
5217 Result->setLexicalDeclContext(LexicalDC);
5228 return std::move(Err);
5234 return std::move(Err);
5242 Error Err = Error::success();
5248 return std::move(Err);
5250 if (GetImportedOrCreateDecl(ToCategory, D, Importer.getToContext(), DC,
5266 return PListOrErr.takeError();
5275 FromProto != FromProtoEnd;
5276 ++FromProto, ++FromProtoLoc) {
5278 Protocols.push_back(*ToProtoOrErr);
5280 return ToProtoOrErr.takeError();
5282 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5283 ProtocolLocs.push_back(*ToProtoLocOrErr);
5285 return ToProtoLocOrErr.takeError();
5290 ProtocolLocs.data(), Importer.getToContext());
5293 Importer.MapImported(D, ToCategory);
5298 return std::move(Err);
5306 return ToImplOrErr.takeError();
5318 return Error::success();
5331 FromProto != FromProtoEnd;
5332 ++FromProto, ++FromProtoLoc) {
5334 Protocols.push_back(*ToProtoOrErr);
5336 return ToProtoOrErr.takeError();
5338 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5339 ProtocolLocs.push_back(*ToProtoLocOrErr);
5341 return ToProtoLocOrErr.takeError();
5347 ProtocolLocs.data(), Importer.getToContext());
5354 return Error::success();
5364 return Importer.MapImported(D, *ImportedDefOrErr);
5366 return ImportedDefOrErr.takeError();
5375 return std::move(Err);
5380 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5381 for (
auto *FoundDecl : FoundDecls) {
5385 if ((MergeWithProtocol = dyn_cast<ObjCProtocolDecl>(FoundDecl)))
5392 if (!ToAtBeginLocOrErr)
5393 return ToAtBeginLocOrErr.takeError();
5395 if (GetImportedOrCreateDecl(ToProto, D, Importer.getToContext(), DC,
5404 Importer.MapImported(D, ToProto);
5408 return std::move(Err);
5416 return std::move(Err);
5419 if (!ExternLocOrErr)
5420 return ExternLocOrErr.takeError();
5424 return LangLocOrErr.takeError();
5429 if (GetImportedOrCreateDecl(ToLinkageSpec, D, Importer.getToContext(), DC,
5430 *ExternLocOrErr, *LangLocOrErr,
5432 return ToLinkageSpec;
5436 if (!RBraceLocOrErr)
5437 return RBraceLocOrErr.takeError();
5444 return ToLinkageSpec;
5455 return ToShadowOrErr.takeError();
5466 return std::move(Err);
5470 Error Err = Error::success();
5475 return std::move(Err);
5479 return std::move(Err);
5482 if (GetImportedOrCreateDecl(ToUsing, D, Importer.getToContext(), DC,
5483 ToUsingLoc, ToQualifierLoc, NameInfo,
5491 Importer.getFromContext().getInstantiatedFromUsingDecl(D)) {
5493 Importer.getToContext().setInstantiatedFromUsingDecl(
5494 ToUsing, *ToPatternOrErr);
5496 return ToPatternOrErr.takeError();
5508 return std::move(Err);
5512 Error Err = Error::success();
5518 return std::move(Err);
5521 if (GetImportedOrCreateDecl(ToUsingEnum, D, Importer.getToContext(), DC,
5522 ToUsingLoc, ToEnumLoc, ToNameLoc, ToEnumType))
5529 Importer.getFromContext().getInstantiatedFromUsingEnumDecl(D)) {
5531 Importer.getToContext().setInstantiatedFromUsingEnumDecl(ToUsingEnum,
5534 return ToPatternOrErr.takeError();
5546 return std::move(Err);
5551 if (!ToIntroducerOrErr)
5552 return ToIntroducerOrErr.takeError();
5556 return ToTargetOrErr.takeError();
5559 if (
auto *FromConstructorUsingShadow =
5560 dyn_cast<ConstructorUsingShadowDecl>(D)) {
5561 Error Err = Error::success();
5563 Err, FromConstructorUsingShadow->getNominatedBaseClassShadowDecl());
5565 return std::move(Err);
5571 if (GetImportedOrCreateDecl<ConstructorUsingShadowDecl>(
5572 ToShadow, D, Importer.getToContext(), DC, Loc,
5574 Nominated ? Nominated : *ToTargetOrErr,
5575 FromConstructorUsingShadow->constructsVirtualBase()))
5578 if (GetImportedOrCreateDecl(ToShadow, D, Importer.getToContext(), DC, Loc,
5579 Name, *ToIntroducerOrErr, *ToTargetOrErr))
5587 Importer.getFromContext().getInstantiatedFromUsingShadowDecl(D)) {
5589 Importer.getToContext().setInstantiatedFromUsingShadowDecl(
5590 ToShadow, *ToPatternOrErr);
5594 return ToPatternOrErr.takeError();
5608 return std::move(Err);
5613 if (!ToComAncestorOrErr)
5614 return ToComAncestorOrErr.takeError();
5616 Error Err = Error::success();
5619 auto ToNamespaceKeyLocation =
5624 return std::move(Err);
5627 if (GetImportedOrCreateDecl(ToUsingDir, D, Importer.getToContext(), DC,
5629 ToNamespaceKeyLocation,
5632 ToNominatedNamespace, *ToComAncestorOrErr))
5647 return std::move(Err);
5651 auto ToInstantiatedFromUsingOrErr =
5653 if (!ToInstantiatedFromUsingOrErr)
5654 return ToInstantiatedFromUsingOrErr.takeError();
5657 return std::move(Err);
5660 if (GetImportedOrCreateDecl(ToUsingPack, D, Importer.getToContext(), DC,
5665 addDeclToContexts(D, ToUsingPack);
5677 return std::move(Err);
5681 Error Err = Error::success();
5687 return std::move(Err);
5691 return std::move(Err);
5694 if (GetImportedOrCreateDecl(ToUsingValue, D, Importer.getToContext(), DC,
5695 ToUsingLoc, ToQualifierLoc, NameInfo,
5697 return ToUsingValue;
5703 return ToUsingValue;
5713 return std::move(Err);
5717 Error Err = Error::success();
5723 return std::move(Err);
5726 if (GetImportedOrCreateDecl(ToUsing, D, Importer.getToContext(), DC,
5727 ToUsingLoc, ToTypenameLoc,
5728 ToQualifierLoc, Loc, Name, ToEllipsisLoc))
5739 Decl* ToD =
nullptr;
5741#define BuiltinTemplate(BTName) \
5742 case BuiltinTemplateKind::BTK##BTName: \
5743 ToD = Importer.getToContext().get##BTName##Decl(); \
5745#include "clang/Basic/BuiltinTemplates.inc"
5747 assert(ToD &&
"BuiltinTemplateDecl of unsupported kind!");
5748 Importer.MapImported(D, ToD);
5758 if (
auto FromSuperOrErr =
import(FromSuper))
5759 FromSuper = *FromSuperOrErr;
5761 return FromSuperOrErr.takeError();
5765 if ((
bool)FromSuper != (
bool)ToSuper ||
5768 diag::warn_odr_objc_superclass_inconsistent)
5775 diag::note_odr_objc_missing_superclass);
5778 diag::note_odr_objc_superclass)
5782 diag::note_odr_objc_missing_superclass);
5788 return Error::success();
5799 return SuperTInfoOrErr.takeError();
5810 FromProto != FromProtoEnd;
5811 ++FromProto, ++FromProtoLoc) {
5813 Protocols.push_back(*ToProtoOrErr);
5815 return ToProtoOrErr.takeError();
5817 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5818 ProtocolLocs.push_back(*ToProtoLocOrErr);
5820 return ToProtoLocOrErr.takeError();
5826 ProtocolLocs.data(), Importer.getToContext());
5831 auto ToCatOrErr =
import(Cat);
5833 return ToCatOrErr.takeError();
5842 return ToImplOrErr.takeError();
5849 return Error::success();
5858 for (
auto *fromTypeParam : *list) {
5859 if (
auto toTypeParamOrErr =
import(fromTypeParam))
5860 toTypeParams.push_back(*toTypeParamOrErr);
5862 return toTypeParamOrErr.takeError();
5866 if (!LAngleLocOrErr)
5867 return LAngleLocOrErr.takeError();
5870 if (!RAngleLocOrErr)
5871 return RAngleLocOrErr.takeError();
5886 return Importer.MapImported(D, *ImportedDefOrErr);
5888 return ImportedDefOrErr.takeError();
5897 return std::move(Err);
5903 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5904 for (
auto *FoundDecl : FoundDecls) {
5908 if ((MergeWithIface = dyn_cast<ObjCInterfaceDecl>(FoundDecl)))
5916 if (!AtBeginLocOrErr)
5917 return AtBeginLocOrErr.takeError();
5919 if (GetImportedOrCreateDecl(
5920 ToIface, D, Importer.getToContext(), DC,
5928 Importer.MapImported(D, ToIface);
5931 if (
auto ToPListOrErr =
5935 return ToPListOrErr.takeError();
5939 return std::move(Err);
5948 return std::move(Err);
5954 return std::move(Err);
5956 Error Err = Error::success();
5961 return std::move(Err);
5963 if (GetImportedOrCreateDecl(
5964 ToImpl, D, Importer.getToContext(), DC,
5965 Importer.Import(D->
getIdentifier()), Category->getClassInterface(),
5966 ToLocation, ToAtStartLoc, ToCategoryNameLoc))
5971 Category->setImplementation(ToImpl);
5974 Importer.MapImported(D, ToImpl);
5976 return std::move(Err);
5986 return std::move(Err);
5991 return std::move(Err);
5999 return std::move(Err);
6001 Error Err = Error::success();
6008 return std::move(Err);
6010 if (GetImportedOrCreateDecl(Impl, D, Importer.getToContext(),
6019 Impl->setLexicalDeclContext(LexicalDC);
6033 Importer.ToDiag(Impl->getLocation(),
6034 diag::warn_odr_objc_superclass_inconsistent)
6038 if (Impl->getSuperClass())
6039 Importer.ToDiag(Impl->getLocation(),
6040 diag::note_odr_objc_superclass)
6041 << Impl->getSuperClass()->getDeclName();
6043 Importer.ToDiag(Impl->getLocation(),
6044 diag::note_odr_objc_missing_superclass);
6047 diag::note_odr_objc_superclass)
6051 diag::note_odr_objc_missing_superclass);
6059 return std::move(Err);
6071 return std::move(Err);
6076 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6077 for (
auto *FoundDecl : FoundDecls) {
6078 if (
auto *FoundProp = dyn_cast<ObjCPropertyDecl>(FoundDecl)) {
6085 if (!Importer.IsStructurallyEquivalent(D->
getType(),
6086 FoundProp->getType())) {
6087 Importer.ToDiag(Loc, diag::warn_odr_objc_property_type_inconsistent)
6088 << Name << D->
getType() << FoundProp->getType();
6089 Importer.ToDiag(FoundProp->getLocation(), diag::note_odr_value_here)
6090 << FoundProp->getType();
6098 Importer.MapImported(D, FoundProp);
6103 Error Err = Error::success();
6109 return std::move(Err);
6113 if (GetImportedOrCreateDecl(
6114 ToProperty, D, Importer.getToContext(), DC, Loc,
6116 ToLParenLoc, ToType,
6128 return std::move(Err);
6148 return std::move(Err);
6152 return std::move(Err);
6159 return std::move(Err);
6162 = InImpl->FindPropertyImplDecl(
Property->getIdentifier(),
6166 Error Err = Error::success();
6169 auto ToPropertyIvarDeclLoc =
6172 return std::move(Err);
6174 if (GetImportedOrCreateDecl(ToImpl, D, Importer.getToContext(), DC,
6178 ToPropertyIvarDeclLoc))
6188 diag::warn_odr_objc_property_impl_kind_inconsistent)
6193 diag::note_odr_objc_property_impl_kind)
6204 diag::warn_odr_objc_synthesize_ivar_inconsistent)
6209 diag::note_odr_objc_synthesize_ivar_here)
6216 Importer.MapImported(D, ToImpl);
6224 Error Err = Error::success();
6228 return std::move(Err);
6232 return Importer.ToContext.getTemplateParamObjectDecl(
T,
V);
6234 (void)GetImportedOrCreateSpecialDecl(ToD,
Create, D, ToType, ToValue);
6246 return BeginLocOrErr.takeError();
6250 return LocationOrErr.takeError();
6253 if (GetImportedOrCreateDecl(
6254 ToD, D, Importer.getToContext(),
6256 *BeginLocOrErr, *LocationOrErr,
6265 Error Err = Error::success();
6266 auto ToConceptRef =
importChecked(Err, TC->getConceptReference());
6267 auto ToIDC =
importChecked(Err, TC->getImmediatelyDeclaredConstraint());
6269 return std::move(Err);
6274 if (
Error Err = importTemplateParameterDefaultArgument(D, ToD))
6283 Error Err = Error::success();
6290 return std::move(Err);
6293 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(),
6295 ToInnerLocStart, ToLocation, D->
getDepth(),
6297 ToDeclName.getAsIdentifierInfo(), ToType,
6301 Err = importTemplateParameterDefaultArgument(D, ToD);
6310 bool IsCanonical =
false;
6311 if (
auto *CanonD = Importer.getFromContext()
6312 .findCanonicalTemplateTemplateParmDeclInternal(D);
6319 return NameOrErr.takeError();
6324 return LocationOrErr.takeError();
6328 if (!TemplateParamsOrErr)
6329 return TemplateParamsOrErr.takeError();
6332 if (GetImportedOrCreateDecl(
6333 ToD, D, Importer.getToContext(),
6340 if (
Error Err = importTemplateParameterDefaultArgument(D, ToD))
6344 return Importer.getToContext()
6345 .insertCanonicalTemplateTemplateParmDeclInternal(ToD);
6353 assert(D->getTemplatedDecl() &&
"Should be called on templates only");
6354 auto *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();
6355 if (!ToTemplatedDef)
6357 auto *TemplateWithDef = ToTemplatedDef->getDescribedTemplate();
6358 return cast_or_null<T>(TemplateWithDef);
6369 return std::move(Err);
6381 TD->getLexicalDeclContext()->isDependentContext();
6383 bool DependentFriend = IsDependentFriend(D);
6390 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6391 for (
auto *FoundDecl : FoundDecls) {
6396 auto *FoundTemplate = dyn_cast<ClassTemplateDecl>(FoundDecl);
6397 if (FoundTemplate) {
6402 bool IgnoreTemplateParmDepth =
6406 IgnoreTemplateParmDepth)) {
6407 if (DependentFriend || IsDependentFriend(FoundTemplate))
6413 return Importer.MapImported(D, TemplateWithDef);
6415 FoundByLookup = FoundTemplate;
6433 ConflictingDecls.push_back(FoundDecl);
6437 if (!ConflictingDecls.empty()) {
6440 ConflictingDecls.size());
6442 Name = NameOrErr.get();
6444 return NameOrErr.takeError();
6451 if (!TemplateParamsOrErr)
6452 return TemplateParamsOrErr.takeError();
6457 return std::move(Err);
6461 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), DC, Loc, Name,
6462 *TemplateParamsOrErr, ToTemplated))
6470 addDeclToContexts(D, D2);
6471 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6473 if (FoundByLookup) {
6487 "Found decl must have its templated decl set");
6490 if (ToTemplated != PrevTemplated)
6504 return std::move(Err);
6509 return std::move(Err);
6515 return std::move(Err);
6518 void *InsertPos =
nullptr;
6521 dyn_cast<ClassTemplatePartialSpecializationDecl>(D);
6529 return ToTPListOrErr.takeError();
6530 ToTPList = *ToTPListOrErr;
6541 Importer.MapImported(D, PrevDefinition);
6544 for (
auto *FromField : D->
fields()) {
6545 auto ToOrErr =
import(FromField);
6547 return ToOrErr.takeError();
6553 auto ToOrErr =
import(FromM);
6555 return ToOrErr.takeError();
6563 return PrevDefinition;
6574 return BeginLocOrErr.takeError();
6577 return IdLocOrErr.takeError();
6583 return std::move(Err);
6589 if (GetImportedOrCreateDecl<ClassTemplatePartialSpecializationDecl>(
6590 D2, D, Importer.getToContext(), D->
getTagKind(), DC, *BeginLocOrErr,
6591 *IdLocOrErr, ToTPList, ClassTemplate,
ArrayRef(TemplateArgs),
6593 cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl)))
6605 PartSpec2->setInstantiatedFromMember(*ToInstOrErr);
6607 return ToInstOrErr.takeError();
6609 updateLookupTableForTemplateParameters(*ToTPList);
6611 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), D->
getTagKind(),
6612 DC, *BeginLocOrErr, *IdLocOrErr, ClassTemplate,
6637 return BraceRangeOrErr.takeError();
6640 return std::move(Err);
6646 return LocOrErr.takeError();
6654 return LocOrErr.takeError();
6659 return LocOrErr.takeError();
6665 return POIOrErr.takeError();
6671 if (
auto *CTD = dyn_cast<ClassTemplateDecl *>(
P)) {
6672 if (
auto CTDorErr =
import(CTD))
6676 auto CTPSDOrErr =
import(CTPSD);
6678 return CTPSDOrErr.takeError();
6681 for (
unsigned I = 0; I < DArgs.
size(); ++I) {
6683 if (
auto ArgOrErr =
import(DArg))
6684 D2ArgsVec[I] = *ArgOrErr;
6686 return ArgOrErr.takeError();
6696 return std::move(Err);
6708 return std::move(Err);
6714 "Variable templates cannot be declared at function scope");
6717 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6719 for (
auto *FoundDecl : FoundDecls) {
6723 if (
VarTemplateDecl *FoundTemplate = dyn_cast<VarTemplateDecl>(FoundDecl)) {
6733 assert(FoundTemplate->getDeclContext()->isRecord() &&
6734 "Member variable template imported as non-member, "
6735 "inconsistent imported AST?");
6737 return Importer.MapImported(D, FoundDef);
6739 return Importer.MapImported(D, FoundTemplate);
6742 return Importer.MapImported(D, FoundDef);
6744 FoundByLookup = FoundTemplate;
6747 ConflictingDecls.push_back(FoundDecl);
6751 if (!ConflictingDecls.empty()) {
6754 ConflictingDecls.size());
6756 Name = NameOrErr.get();
6758 return NameOrErr.takeError();
6767 return TypeOrErr.takeError();
6772 return std::move(Err);
6776 if (!TemplateParamsOrErr)
6777 return TemplateParamsOrErr.takeError();
6780 if (GetImportedOrCreateDecl(ToVarTD, D, Importer.getToContext(), DC, Loc,
6781 Name, *TemplateParamsOrErr, ToTemplated))
6789 if (DC != Importer.getToContext().getTranslationUnitDecl())
6790 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6792 if (FoundByLookup) {
6796 auto *PrevTemplated =
6798 if (ToTemplated != PrevTemplated)
6813 auto RedeclIt = Redecls.begin();
6816 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
6819 return RedeclOrErr.takeError();
6821 assert(*RedeclIt == D);
6825 return std::move(Err);
6830 return std::move(Err);
6835 return BeginLocOrErr.takeError();
6839 return IdLocOrErr.takeError();
6845 return std::move(Err);
6848 void *InsertPos =
nullptr;
6850 VarTemplate->findSpecialization(TemplateArgs, InsertPos);
6851 if (FoundSpecialization) {
6859 "Member variable template specialization imported as non-member, "
6860 "inconsistent imported AST?");
6862 return Importer.MapImported(D, FoundDef);
6864 return Importer.MapImported(D, FoundSpecialization);
6869 return Importer.MapImported(D, FoundDef);
6881 return std::move(Err);
6886 if (
auto *FromPartial = dyn_cast<PartVarSpecDecl>(D)) {
6887 auto ToTPListOrErr =
import(FromPartial->getTemplateParameters());
6889 return ToTPListOrErr.takeError();
6891 PartVarSpecDecl *ToPartial;
6892 if (GetImportedOrCreateDecl(ToPartial, D, Importer.getToContext(), DC,
6893 *BeginLocOrErr, *IdLocOrErr, *ToTPListOrErr,
6899 import(FromPartial->getInstantiatedFromMember()))
6900 ToPartial->setInstantiatedFromMember(*ToInstOrErr);
6902 return ToInstOrErr.takeError();
6904 if (FromPartial->isMemberSpecialization())
6905 ToPartial->setMemberSpecialization();
6913 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), DC,
6922 if (!
VarTemplate->findSpecialization(TemplateArgs, InsertPos))
6927 return std::move(Err);
6932 return TInfoOrErr.takeError();
6939 return POIOrErr.takeError();
6950 return LocOrErr.takeError();
6958 return std::move(Err);
6960 if (FoundSpecialization)
6963 addDeclToContexts(D, D2);
6966 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
6969 return RedeclOrErr.takeError();
6983 return std::move(Err);
6995 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6996 for (
auto *FoundDecl : FoundDecls) {
6997 if (!FoundDecl->isInIdentifierNamespace(IDNS))
7000 if (
auto *FoundTemplate = dyn_cast<FunctionTemplateDecl>(FoundDecl)) {
7007 return Importer.MapImported(D, TemplateWithDef);
7009 FoundByLookup = FoundTemplate;
7019 return ParamsOrErr.takeError();
7024 return std::move(Err);
7041 OldParamDC.reserve(Params->
size());
7042 llvm::transform(*Params, std::back_inserter(OldParamDC),
7046 if (GetImportedOrCreateDecl(ToFunc, D, Importer.getToContext(), DC, Loc, Name,
7047 Params, TemplatedFD))
7061 ToFunc->setLexicalDeclContext(LexicalDC);
7062 addDeclToContexts(D, ToFunc);
7065 if (LT && !OldParamDC.empty()) {
7066 for (
unsigned int I = 0; I < OldParamDC.size(); ++I)
7067 LT->updateForced(Params->
getParam(I), OldParamDC[I]);
7070 if (FoundByLookup) {
7075 "Found decl must have its templated decl set");
7076 auto *PrevTemplated =
7078 if (TemplatedFD != PrevTemplated)
7095 return std::move(Err);
7098 if (GetImportedOrCreateDecl(To, D, Importer.getToContext(), DC, LocationOrErr,
7099 NameDeclOrErr, ToTemplateParameters,
7113 return std::move(Err);
7116 if (GetImportedOrCreateDecl(To, D, Importer.getToContext(), DC, RequiresLoc))
7129 return std::move(Err);
7133 return std::move(Err);
7136 if (GetImportedOrCreateDecl(To, D, Importer.getToContext(), DC, ToSL, ToArgs))
7148 Importer.FromDiag(S->
getBeginLoc(), diag::err_unsupported_ast_node)
7155 if (Importer.returnWithErrorInTest())
7162 Names.push_back(ToII);
7165 for (
unsigned I = 0, E = S->
getNumInputs(); I != E; I++) {
7169 Names.push_back(ToII);
7175 Clobbers.push_back(*ClobberOrErr);
7177 return ClobberOrErr.takeError();
7184 Constraints.push_back(*OutputOrErr);
7186 return OutputOrErr.takeError();
7189 for (
unsigned I = 0, E = S->
getNumInputs(); I != E; I++) {
7191 Constraints.push_back(*InputOrErr);
7193 return InputOrErr.takeError();
7199 return std::move(Err);
7203 return std::move(Err);
7207 return std::move(Err);
7211 return AsmLocOrErr.takeError();
7214 return AsmStrOrErr.takeError();
7216 if (!RParenLocOrErr)
7217 return RParenLocOrErr.takeError();
7219 return new (Importer.getToContext())
GCCAsmStmt(
7220 Importer.getToContext(),
7238 Error Err = Error::success();
7243 return std::move(Err);
7244 return new (Importer.getToContext())
DeclStmt(ToDG, ToBeginLoc, ToEndLoc);
7249 if (!ToSemiLocOrErr)
7250 return ToSemiLocOrErr.takeError();
7251 return new (Importer.getToContext())
NullStmt(
7259 return std::move(Err);
7262 if (!ToLBracLocOrErr)
7263 return ToLBracLocOrErr.takeError();
7266 if (!ToRBracLocOrErr)
7267 return ToRBracLocOrErr.takeError();
7272 *ToLBracLocOrErr, *ToRBracLocOrErr);
7277 Error Err = Error::success();
7285 return std::move(Err);
7288 ToCaseLoc, ToEllipsisLoc, ToColonLoc);
7289 ToStmt->setSubStmt(ToSubStmt);
7296 Error Err = Error::success();
7301 return std::move(Err);
7304 ToDefaultLoc, ToColonLoc, ToSubStmt);
7309 Error Err = Error::success();
7314 return std::move(Err);
7316 return new (Importer.getToContext())
LabelStmt(
7317 ToIdentLoc, ToLabelDecl, ToSubStmt);
7322 if (!ToAttrLocOrErr)
7323 return ToAttrLocOrErr.takeError();
7327 return std::move(Err);
7329 if (!ToSubStmtOrErr)
7330 return ToSubStmtOrErr.takeError();
7333 Importer.getToContext(), *ToAttrLocOrErr, ToAttrs, *ToSubStmtOrErr);
7338 Error Err = Error::success();
7349 return std::move(Err);
7352 ToInit, ToConditionVariable, ToCond, ToLParenLoc,
7353 ToRParenLoc, ToThen, ToElseLoc, ToElse);
7358 Error Err = Error::success();
7367 return std::move(Err);
7371 ToCond, ToLParenLoc, ToRParenLoc);
7372 ToStmt->setBody(ToBody);
7373 ToStmt->setSwitchLoc(ToSwitchLoc);
7381 return ToSCOrErr.takeError();
7382 if (LastChainedSwitchCase)
7385 ToStmt->setSwitchCaseList(*ToSCOrErr);
7386 LastChainedSwitchCase = *ToSCOrErr;
7394 Error Err = Error::success();
7402 return std::move(Err);
7405 ToBody, ToWhileLoc, ToLParenLoc, ToRParenLoc);
7410 Error Err = Error::success();
7417 return std::move(Err);
7419 return new (Importer.getToContext())
DoStmt(
7420 ToBody, ToCond, ToDoLoc, ToWhileLoc, ToRParenLoc);
7425 Error Err = Error::success();
7435 return std::move(Err);
7437 return new (Importer.getToContext())
ForStmt(
7438 Importer.getToContext(),
7439 ToInit, ToCond, ToConditionVariable, ToInc, ToBody, ToForLoc, ToLParenLoc,
7445 Error Err = Error::success();
7450 return std::move(Err);
7452 return new (Importer.getToContext())
GotoStmt(
7453 ToLabel, ToGotoLoc, ToLabelLoc);
7458 Error Err = Error::success();
7463 return std::move(Err);
7466 ToGotoLoc, ToStarLoc, ToTarget);
7469template <
typename StmtClass>
7472 Error Err = Error::success();
7473 auto ToLoc = NodeImporter.
importChecked(Err, S->getKwLoc());
7474 auto ToLabelLoc = S->hasLabelTarget()
7477 auto ToDecl = S->hasLabelTarget()
7481 return std::move(Err);
7482 return new (Importer.
getToContext()) StmtClass(ToLoc, ToLabelLoc, ToDecl);
7495 Error Err = Error::success();
7500 return std::move(Err);
7508 Error Err = Error::success();
7513 return std::move(Err);
7516 ToCatchLoc, ToExceptionDecl, ToHandlerBlock);
7522 return ToTryLocOrErr.takeError();
7525 if (!ToTryBlockOrErr)
7526 return ToTryBlockOrErr.takeError();
7529 for (
unsigned HI = 0, HE = S->
getNumHandlers(); HI != HE; ++HI) {
7531 if (
auto ToHandlerOrErr =
import(FromHandler))
7532 ToHandlers[HI] = *ToHandlerOrErr;
7534 return ToHandlerOrErr.takeError();
7543 Error Err = Error::success();
7557 return std::move(Err);
7560 ToInit, ToRangeStmt, ToBeginStmt, ToEndStmt, ToCond, ToInc, ToLoopVarStmt,
7561 ToBody, ToForLoc, ToCoawaitLoc, ToColonLoc, ToRParenLoc);
7566 Error Err = Error::success();
7574 return std::move(Err);
7579 Importer.getToContext(), ToESD, ToInit, ToExpansionVar, ToLParenLoc,
7580 ToColonLoc, ToRParenLoc);
7587 return std::move(Err);
7590 Importer.getToContext(), ToESD, ToInit, ToExpansionVar, ToRange,
7591 ToBegin, ToIter, ToLParenLoc, ToColonLoc, ToRParenLoc);
7595 auto ToDecompositionDeclStmt =
7598 return std::move(Err);
7601 Importer.getToContext(), ToESD, ToInit, ToExpansionVar,
7602 ToDecompositionDeclStmt, ToLParenLoc, ToColonLoc, ToRParenLoc);
7606 auto ToExpansionInitializer =
7609 return std::move(Err);
7611 Importer.getToContext(), ToESD, ToInit, ToExpansionVar,
7612 ToExpansionInitializer, ToLParenLoc, ToColonLoc, ToRParenLoc);
7616 llvm_unreachable(
"invalid pattern kind");
7621 Error Err = Error::success();
7631 return std::move(Err);
7634 Importer.getToContext(), ToParent, ToInstantiations, ToSharedStmts,
7640 Error Err = Error::success();
7647 return std::move(Err);
7658 Error Err = Error::success();
7664 return std::move(Err);
7667 ToAtCatchLoc, ToRParenLoc, ToCatchParamDecl, ToCatchBody);
7672 if (!ToAtFinallyLocOrErr)
7673 return ToAtFinallyLocOrErr.takeError();
7675 if (!ToAtFinallyStmtOrErr)
7676 return ToAtFinallyStmtOrErr.takeError();
7678 *ToAtFinallyStmtOrErr);
7683 Error Err = Error::success();
7688 return std::move(Err);
7693 if (
ExpectedStmt ToCatchStmtOrErr =
import(FromCatchStmt))
7694 ToCatchStmts[CI] = *ToCatchStmtOrErr;
7696 return ToCatchStmtOrErr.takeError();
7700 ToAtTryLoc, ToTryBody,
7701 ToCatchStmts.begin(), ToCatchStmts.size(),
7708 Error Err = Error::success();
7713 return std::move(Err);
7716 ToAtSynchronizedLoc, ToSynchExpr, ToSynchBody);
7721 if (!ToThrowLocOrErr)
7722 return ToThrowLocOrErr.takeError();
7724 if (!ToThrowExprOrErr)
7725 return ToThrowExprOrErr.takeError();
7727 *ToThrowLocOrErr, *ToThrowExprOrErr);
7734 return ToAtLocOrErr.takeError();
7736 if (!ToSubStmtOrErr)
7737 return ToSubStmtOrErr.takeError();
7746 Importer.FromDiag(E->
getBeginLoc(), diag::err_unsupported_ast_node)
7752 Error Err = Error::success();
7757 return std::move(Err);
7759 if (!ParentContextOrErr)
7760 return ParentContextOrErr.takeError();
7762 return new (Importer.getToContext())
7764 RParenLoc, *ParentContextOrErr);
7769 Error Err = Error::success();
7776 return std::move(Err);
7778 return new (Importer.getToContext())
7779 VAArgExpr(ToBuiltinLoc, ToSubExpr, ToWrittenTypeInfo, ToRParenLoc, ToType,
7785 Error Err = Error::success();
7793 return std::move(Err);
7802 return new (Importer.getToContext())
7803 ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType,
VK, OK,
7804 ToRParenLoc, CondIsTrue);
7808 Error Err = Error::success();
7815 return std::move(Err);
7818 Importer.getToContext(), ToSrcExpr, ToTSI, ToType, E->
getValueKind(),
7824 Error Err = Error::success();
7832 ToSubExprs.resize(NumSubExprs);
7835 return std::move(Err);
7838 Importer.getToContext(), ToSubExprs, ToType, ToBeginLoc, ToRParenLoc);
7844 return TypeOrErr.takeError();
7848 return BeginLocOrErr.takeError();
7850 return new (Importer.getToContext())
GNUNullExpr(*TypeOrErr, *BeginLocOrErr);
7855 Error Err = Error::success();
7857 Expr *ToControllingExpr =
nullptr;
7863 assert((ToControllingExpr || ToControllingType) &&
7864 "Either the controlling expr or type must be nonnull");
7868 return std::move(Err);
7873 return std::move(Err);
7878 return std::move(Err);
7880 const ASTContext &ToCtx = Importer.getToContext();
7882 if (ToControllingExpr) {
7884 ToCtx, ToGenericLoc, ToControllingExpr,
ArrayRef(ToAssocTypes),
7885 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7889 ToCtx, ToGenericLoc, ToControllingType,
ArrayRef(ToAssocTypes),
7890 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7894 if (ToControllingExpr) {
7896 ToCtx, ToGenericLoc, ToControllingExpr,
ArrayRef(ToAssocTypes),
7897 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7901 ToCtx, ToGenericLoc, ToControllingType,
ArrayRef(ToAssocTypes),
7902 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7908 Error Err = Error::success();
7913 return std::move(Err);
7922 Error Err = Error::success();
7929 return std::move(Err);
7935 return FoundDOrErr.takeError();
7936 ToFoundD = *FoundDOrErr;
7945 return std::move(Err);
7946 ToResInfo = &ToTAInfo;
7950 Importer.getToContext(), ToQualifierLoc, ToTemplateKeywordLoc, ToDecl,
7954 ToE->setHadMultipleCandidates(
true);
7962 return TypeOrErr.takeError();
7970 return ToInitOrErr.takeError();
7973 if (!ToEqualOrColonLocOrErr)
7974 return ToEqualOrColonLocOrErr.takeError();
7980 ToIndexExprs[I - 1] = *ToArgOrErr;
7982 return ToArgOrErr.takeError();
7987 return std::move(Err);
7990 Importer.getToContext(), ToDesignators,
7991 ToIndexExprs, *ToEqualOrColonLocOrErr,
7999 return ToTypeOrErr.takeError();
8002 if (!ToLocationOrErr)
8003 return ToLocationOrErr.takeError();
8006 *ToTypeOrErr, *ToLocationOrErr);
8012 return ToTypeOrErr.takeError();
8015 if (!ToLocationOrErr)
8016 return ToLocationOrErr.takeError();
8019 Importer.getToContext(), E->
getValue(), *ToTypeOrErr, *ToLocationOrErr);
8026 return ToTypeOrErr.takeError();
8029 if (!ToLocationOrErr)
8030 return ToLocationOrErr.takeError();
8034 *ToTypeOrErr, *ToLocationOrErr);
8038 auto ToTypeOrErr =
import(E->
getType());
8040 return ToTypeOrErr.takeError();
8043 if (!ToSubExprOrErr)
8044 return ToSubExprOrErr.takeError();
8047 *ToSubExprOrErr, *ToTypeOrErr);
8051 auto ToTypeOrErr =
import(E->
getType());
8053 return ToTypeOrErr.takeError();
8056 if (!ToLocationOrErr)
8057 return ToLocationOrErr.takeError();
8060 Importer.getToContext(), E->
getValue(), *ToTypeOrErr, *ToLocationOrErr,
8061 Importer.getToContext().getFixedPointScale(*ToTypeOrErr));
8067 return ToTypeOrErr.takeError();
8070 if (!ToLocationOrErr)
8071 return ToLocationOrErr.takeError();
8080 return ToTypeOrErr.takeError();
8085 return std::move(Err);
8094 Error Err = Error::success();
8100 return std::move(Err);
8103 ToLParenLoc, ToTypeSourceInfo, ToType, E->
getValueKind(),
8109 Error Err = Error::success();
8114 return std::move(Err);
8120 return std::move(Err);
8122 return new (Importer.getToContext())
AtomicExpr(
8124 ToBuiltinLoc, ToExprs, ToType, E->
getOp(), ToRParenLoc);
8128 Error Err = Error::success();
8134 return std::move(Err);
8137 ToAmpAmpLoc, ToLabelLoc, ToLabel, ToType);
8140 Error Err = Error::success();
8144 return std::move(Err);
8149 Error Err = Error::success();
8154 return std::move(Err);
8156 return new (Importer.getToContext())
8157 ParenExpr(ToLParen, ToRParen, ToSubExpr);
8163 return std::move(Err);
8166 if (!ToLParenLocOrErr)
8167 return ToLParenLocOrErr.takeError();
8170 if (!ToRParenLocOrErr)
8171 return ToRParenLocOrErr.takeError();
8174 ToExprs, *ToRParenLocOrErr);
8178 Error Err = Error::success();
8184 return std::move(Err);
8186 return new (Importer.getToContext())
8187 StmtExpr(ToSubStmt, ToType, ToLParenLoc, ToRParenLoc,
8192 Error Err = Error::success();
8197 return std::move(Err);
8201 UO->setType(ToType);
8202 UO->setSubExpr(ToSubExpr);
8204 UO->setOperatorLoc(ToOperatorLoc);
8215 Error Err = Error::success();
8220 return std::move(Err);
8225 if (!ToArgumentTypeInfoOrErr)
8226 return ToArgumentTypeInfoOrErr.takeError();
8229 E->
getKind(), *ToArgumentTypeInfoOrErr, ToType, ToOperatorLoc,
8234 if (!ToArgumentExprOrErr)
8235 return ToArgumentExprOrErr.takeError();
8238 E->
getKind(), *ToArgumentExprOrErr, ToType, ToOperatorLoc, ToRParenLoc);
8242 Error Err = Error::success();
8248 return std::move(Err);
8251 Importer.getToContext(), ToLHS, ToRHS, E->
getOpcode(), ToType,
8257 Error Err = Error::success();
8265 return std::move(Err);
8268 ToCond, ToQuestionLoc, ToLHS, ToColonLoc, ToRHS, ToType,
8274 Error Err = Error::success();
8284 return std::move(Err);
8287 ToCommon, ToOpaqueValue, ToCond, ToTrueExpr, ToFalseExpr,
8294 Error Err = Error::success();
8297 return std::move(Err);
8299 return new (Importer.getToContext())
8304 Error Err = Error::success();
8306 auto ToQueriedTypeSourceInfo =
8312 return std::move(Err);
8316 ToDimensionExpression, ToEndLoc, ToType);
8320 Error Err = Error::success();
8326 return std::move(Err);
8334 Error Err = Error::success();
8339 return std::move(Err);
8346 Error Err = Error::success();
8352 return std::move(Err);
8361 Error Err = Error::success();
8366 auto ToComputationResultType =
8370 return std::move(Err);
8373 Importer.getToContext(), ToLHS, ToRHS, E->
getOpcode(), ToType,
8376 ToComputationLHSType, ToComputationResultType);
8383 if (
auto SpecOrErr =
import(*I))
8384 Path.push_back(*SpecOrErr);
8386 return SpecOrErr.takeError();
8394 return ToTypeOrErr.takeError();
8397 if (!ToSubExprOrErr)
8398 return ToSubExprOrErr.takeError();
8401 if (!ToBasePathOrErr)
8402 return ToBasePathOrErr.takeError();
8405 Importer.getToContext(), *ToTypeOrErr, E->
getCastKind(), *ToSubExprOrErr,
8410 Error Err = Error::success();
8415 return std::move(Err);
8418 if (!ToBasePathOrErr)
8419 return ToBasePathOrErr.takeError();
8423 case Stmt::CStyleCastExprClass: {
8425 ExpectedSLoc ToLParenLocOrErr =
import(CCE->getLParenLoc());
8426 if (!ToLParenLocOrErr)
8427 return ToLParenLocOrErr.takeError();
8428 ExpectedSLoc ToRParenLocOrErr =
import(CCE->getRParenLoc());
8429 if (!ToRParenLocOrErr)
8430 return ToRParenLocOrErr.takeError();
8433 ToSubExpr, ToBasePath, CCE->getFPFeatures(), ToTypeInfoAsWritten,
8434 *ToLParenLocOrErr, *ToRParenLocOrErr);
8437 case Stmt::CXXFunctionalCastExprClass: {
8439 ExpectedSLoc ToLParenLocOrErr =
import(FCE->getLParenLoc());
8440 if (!ToLParenLocOrErr)
8441 return ToLParenLocOrErr.takeError();
8442 ExpectedSLoc ToRParenLocOrErr =
import(FCE->getRParenLoc());
8443 if (!ToRParenLocOrErr)
8444 return ToRParenLocOrErr.takeError();
8446 Importer.getToContext(), ToType, E->
getValueKind(), ToTypeInfoAsWritten,
8447 E->
getCastKind(), ToSubExpr, ToBasePath, FCE->getFPFeatures(),
8448 *ToLParenLocOrErr, *ToRParenLocOrErr);
8451 case Stmt::ObjCBridgedCastExprClass: {
8453 ExpectedSLoc ToLParenLocOrErr =
import(OCE->getLParenLoc());
8454 if (!ToLParenLocOrErr)
8455 return ToLParenLocOrErr.takeError();
8456 ExpectedSLoc ToBridgeKeywordLocOrErr =
import(OCE->getBridgeKeywordLoc());
8457 if (!ToBridgeKeywordLocOrErr)
8458 return ToBridgeKeywordLocOrErr.takeError();
8460 *ToLParenLocOrErr, OCE->getBridgeKind(), E->
getCastKind(),
8461 *ToBridgeKeywordLocOrErr, ToTypeInfoAsWritten, ToSubExpr);
8463 case Stmt::BuiltinBitCastExprClass: {
8465 ExpectedSLoc ToKWLocOrErr =
import(BBC->getBeginLoc());
8467 return ToKWLocOrErr.takeError();
8468 ExpectedSLoc ToRParenLocOrErr =
import(BBC->getEndLoc());
8469 if (!ToRParenLocOrErr)
8470 return ToRParenLocOrErr.takeError();
8473 ToTypeInfoAsWritten, *ToKWLocOrErr, *ToRParenLocOrErr);
8476 llvm_unreachable(
"Cast expression of unsupported type!");
8489 Error Err = Error::success();
8493 return std::move(Err);
8502 auto ToBSOrErr =
import(FromNode.
getBase());
8504 return ToBSOrErr.takeError();
8509 auto ToFieldOrErr =
import(FromNode.
getField());
8511 return ToFieldOrErr.takeError();
8512 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, *ToFieldOrErr, ToEndLoc));
8517 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, ToII, ToEndLoc));
8526 if (!ToIndexExprOrErr)
8527 return ToIndexExprOrErr.takeError();
8528 ToExprs[I] = *ToIndexExprOrErr;
8531 Error Err = Error::success();
8537 return std::move(Err);
8540 Importer.getToContext(), ToType, ToOperatorLoc, ToTypeSourceInfo, ToNodes,
8541 ToExprs, ToRParenLoc);
8545 Error Err = Error::success();
8551 return std::move(Err);
8560 ToType, ToOperand, ToCanThrow, ToBeginLoc, ToEndLoc);
8564 Error Err = Error::success();
8569 return std::move(Err);
8577 if (!ToUsedLocOrErr)
8578 return ToUsedLocOrErr.takeError();
8580 auto ToParamOrErr =
import(E->
getParam());
8582 return ToParamOrErr.takeError();
8584 auto UsedContextOrErr = Importer.ImportContext(E->
getUsedContext());
8585 if (!UsedContextOrErr)
8586 return UsedContextOrErr.takeError();
8596 std::optional<ParmVarDecl *> FromParam =
8597 Importer.getImportedFromDecl(ToParam);
8598 assert(FromParam &&
"ParmVarDecl was not imported?");
8601 return std::move(Err);
8603 Expr *RewrittenInit =
nullptr;
8607 return ExprOrErr.takeError();
8608 RewrittenInit = ExprOrErr.get();
8611 *ToParamOrErr, RewrittenInit,
8617 Error Err = Error::success();
8622 return std::move(Err);
8625 ToType, ToTypeSourceInfo, ToRParenLoc);
8631 if (!ToSubExprOrErr)
8632 return ToSubExprOrErr.takeError();
8634 auto ToDtorOrErr =
import(E->
getTemporary()->getDestructor());
8636 return ToDtorOrErr.takeError();
8646 Error Err = Error::success();
8652 return std::move(Err);
8656 return std::move(Err);
8659 Importer.getToContext(), ToConstructor, ToType, ToTypeSourceInfo, ToArgs,
8669 return std::move(Err);
8671 Error Err = Error::success();
8675 return std::move(Err);
8679 if (GetImportedOrCreateDecl(To, D, Temporary, ExtendingDecl,
8690 Error Err = Error::success();
8694 auto ToMaterializedDecl =
8697 return std::move(Err);
8699 if (!ToTemporaryExpr)
8700 ToTemporaryExpr =
cast<Expr>(ToMaterializedDecl->getTemporaryExpr());
8704 ToMaterializedDecl);
8710 Error Err = Error::success();
8714 return std::move(Err);
8716 return new (Importer.getToContext())
8721 Error Err = Error::success();
8727 return std::move(Err);
8736 ToPartialArguments))
8737 return std::move(Err);
8741 Importer.getToContext(), ToOperatorLoc, ToPack, ToPackLoc, ToRParenLoc,
8742 Length, ToPartialArguments);
8747 Error Err = Error::success();
8754 auto ToAllocatedTypeSourceInfo =
8759 return std::move(Err);
8764 return std::move(Err);
8767 Importer.getToContext(), E->
isGlobalNew(), ToOperatorNew,
8771 ToAllocatedTypeSourceInfo, ToSourceRange, ToDirectInitRange);
8775 Error Err = Error::success();
8781 return std::move(Err);
8790 Error Err = Error::success();
8796 return std::move(Err);
8800 return std::move(Err);
8803 Importer.getToContext(), ToType, ToLocation, ToConstructor,
8807 ToParenOrBraceRange);
8814 if (!ToSubExprOrErr)
8815 return ToSubExprOrErr.takeError();
8819 return std::move(Err);
8827 Error Err = Error::success();
8832 return std::move(Err);
8836 return std::move(Err);
8846 return ToTypeOrErr.takeError();
8849 if (!ToLocationOrErr)
8850 return ToLocationOrErr.takeError();
8859 return ToTypeOrErr.takeError();
8862 if (!ToLocationOrErr)
8863 return ToLocationOrErr.takeError();
8866 *ToTypeOrErr, *ToLocationOrErr);
8870 Error Err = Error::success();
8881 return std::move(Err);
8893 return std::move(Err);
8894 ResInfo = &ToTAInfo;
8898 ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8899 ToMemberDecl, ToFoundDecl, ToMemberNameInfo,
8906 Error Err = Error::success();
8914 return std::move(Err);
8920 if (!ToDestroyedTypeLocOrErr)
8921 return ToDestroyedTypeLocOrErr.takeError();
8927 return ToTIOrErr.takeError();
8931 Importer.getToContext(), ToBase, E->
isArrow(), ToOperatorLoc,
8932 ToQualifierLoc, ToScopeTypeInfo, ToColonColonLoc, ToTildeLoc, Storage);
8937 Error Err = Error::success();
8942 auto ToFirstQualifierFoundInScope =
8945 return std::move(Err);
8947 Expr *ToBase =
nullptr;
8950 ToBase = *ToBaseOrErr;
8952 return ToBaseOrErr.takeError();
8961 return std::move(Err);
8962 ResInfo = &ToTAInfo;
8967 return std::move(Err);
8973 return std::move(Err);
8976 Importer.getToContext(), ToBase, ToType, E->
isArrow(), ToOperatorLoc,
8977 ToQualifierLoc, ToTemplateKeywordLoc, ToFirstQualifierFoundInScope,
8978 ToMemberNameInfo, ResInfo);
8983 Error Err = Error::success();
8991 return std::move(Err);
8995 return std::move(Err);
9002 return std::move(Err);
9003 ResInfo = &ToTAInfo;
9007 Importer.getToContext(), ToQualifierLoc, ToTemplateKeywordLoc,
9008 ToNameInfo, ResInfo);
9013 Error Err = Error::success();
9019 return std::move(Err);
9024 return std::move(Err);
9027 Importer.getToContext(), ToType, ToTypeSourceInfo, ToLParenLoc,
9034 if (!ToNamingClassOrErr)
9035 return ToNamingClassOrErr.takeError();
9038 if (!ToQualifierLocOrErr)
9039 return ToQualifierLocOrErr.takeError();
9041 Error Err = Error::success();
9045 return std::move(Err);
9050 return std::move(Err);
9053 for (
auto *D : E->
decls())
9054 if (
auto ToDOrErr =
import(D))
9057 return ToDOrErr.takeError();
9064 return std::move(Err);
9067 if (!ToTemplateKeywordLocOrErr)
9068 return ToTemplateKeywordLocOrErr.takeError();
9070 const bool KnownDependent =
9072 ExprDependence::TypeValue;
9074 Importer.getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
9075 *ToTemplateKeywordLocOrErr, ToNameInfo, E->
requiresADL(), &ToTAInfo,
9076 ToDecls.
begin(), ToDecls.
end(), KnownDependent,
9081 Importer.getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
9089 Error Err = Error::success();
9097 return std::move(Err);
9102 return std::move(Err);
9106 if (
auto ToDOrErr =
import(D))
9109 return ToDOrErr.takeError();
9117 return std::move(Err);
9118 ResInfo = &ToTAInfo;
9121 Expr *ToBase =
nullptr;
9124 ToBase = *ToBaseOrErr;
9126 return ToBaseOrErr.takeError();
9131 E->
isArrow(), ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
9132 ToNameInfo, ResInfo, ToDecls.
begin(), ToDecls.
end());
9136 Error Err = Error::success();
9141 return std::move(Err);
9146 return std::move(Err);
9148 if (
const auto *OCE = dyn_cast<CXXOperatorCallExpr>(E)) {
9150 Importer.getToContext(), OCE->getOperator(), ToCallee, ToArgs, ToType,
9151 OCE->getValueKind(), ToRParenLoc, OCE->getFPFeatures(),
9152 OCE->getADLCallKind());
9162 auto ToClassOrErr =
import(FromClass);
9164 return ToClassOrErr.takeError();
9169 return ToCallOpOrErr.takeError();
9173 return std::move(Err);
9175 Error Err = Error::success();
9180 return std::move(Err);
9191 Error Err = Error::success();
9196 return std::move(Err);
9200 return std::move(Err);
9211 return ToFillerOrErr.takeError();
9215 if (
auto ToFDOrErr =
import(FromFD))
9218 return ToFDOrErr.takeError();
9222 if (
auto ToSyntFormOrErr =
import(SyntForm))
9225 return ToSyntFormOrErr.takeError();
9239 return ToTypeOrErr.takeError();
9242 if (!ToSubExprOrErr)
9243 return ToSubExprOrErr.takeError();
9246 *ToTypeOrErr, *ToSubExprOrErr);
9251 Error Err = Error::success();
9256 return std::move(Err);
9264 Error Err = Error::success();
9269 return std::move(Err);
9272 ToType, ToCommonExpr, ToSubExpr);
9278 return ToTypeOrErr.takeError();
9284 if (!ToBeginLocOrErr)
9285 return ToBeginLocOrErr.takeError();
9287 auto ToFieldOrErr =
import(E->
getField());
9289 return ToFieldOrErr.takeError();
9291 auto UsedContextOrErr = Importer.ImportContext(E->
getUsedContext());
9292 if (!UsedContextOrErr)
9293 return UsedContextOrErr.takeError();
9297 "Field should have in-class initializer if there is a default init "
9298 "expression that uses it.");
9303 auto ToInClassInitializerOrErr =
9304 import(E->
getField()->getInClassInitializer());
9305 if (!ToInClassInitializerOrErr)
9306 return ToInClassInitializerOrErr.takeError();
9310 Expr *RewrittenInit =
nullptr;
9314 return ExprOrErr.takeError();
9315 RewrittenInit = ExprOrErr.get();
9319 ToField, *UsedContextOrErr, RewrittenInit);
9323 Error Err = Error::success();
9331 return std::move(Err);
9336 if (!ToBasePathOrErr)
9337 return ToBasePathOrErr.takeError();
9339 if (
auto CCE = dyn_cast<CXXStaticCastExpr>(E)) {
9341 Importer.getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9342 ToTypeInfoAsWritten, CCE->getFPFeatures(), ToOperatorLoc, ToRParenLoc,
9346 Importer.getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9347 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9350 Importer.getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9351 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9354 Importer.getToContext(), ToType,
VK, ToSubExpr, ToTypeInfoAsWritten,
9355 ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9357 llvm_unreachable(
"Unknown cast type");
9358 return make_error<ASTImportError>();
9364 Error Err = Error::success();
9371 return std::move(Err);
9374 ToType, E->
getValueKind(), ToNameLoc, ToReplacement, ToAssociatedDecl,
9379 Error Err = Error::success();
9384 return std::move(Err);
9388 return std::move(Err);
9395 E->
getTrait(), ToArgs, ToEndLoc, ToValue);
9405 return ToTypeOrErr.takeError();
9408 if (!ToSourceRangeOrErr)
9409 return ToSourceRangeOrErr.takeError();
9414 *ToTypeOrErr, *ToTSIOrErr, *ToSourceRangeOrErr);
9416 return ToTSIOrErr.takeError();
9420 if (!ToExprOperandOrErr)
9421 return ToExprOperandOrErr.takeError();
9424 *ToTypeOrErr, *ToExprOperandOrErr, *ToSourceRangeOrErr);
9428 Error Err = Error::success();
9439 return std::move(Err);
9441 return new (Importer.getToContext())
9447 Error Err = Error::success();
9455 return std::move(Err);
9459 return std::move(Err);
9464 return std::move(Err);
9466 LParenLoc, LocalParameters, RParenLoc,
9467 Requirements, RBraceLoc);
9472 Error Err = Error::success();
9476 return std::move(Err);
9479 Importer.getToContext(),
CL,
9484 return std::move(Err);
9486 Importer.getToContext(),
CL,
9492 Error Err = Error::success();
9498 return std::move(Err);
9501 ToType, E->
getValueKind(), ToPackLoc, ToArgPack, ToAssociatedDecl,
9508 return std::move(Err);
9511 return ToSyntOrErr.takeError();
9518 Error Err = Error::success();
9524 return std::move(Err);
9528 return std::move(Err);
9531 ToInitLoc, ToBeginLoc, ToEndLoc);
9536 Error Err = Error::success();
9540 return std::move(Err);
9542 return new (Importer.getToContext())
9548 Error ImportErrors = Error::success();
9550 if (
auto ImportedOrErr =
import(FromOverriddenMethod))
9552 (*ImportedOrErr)->getCanonicalDecl()));
9555 joinErrors(std::move(ImportErrors), ImportedOrErr.takeError());
9557 return ImportErrors;
9563 std::shared_ptr<ASTImporterSharedState> SharedState)
9564 : SharedState(SharedState), ToContext(ToContext), FromContext(FromContext),
9565 ToFileManager(ToFileManager), FromFileManager(FromFileManager),
9570 this->SharedState = std::make_shared<ASTImporterSharedState>();
9573 ImportedDecls[FromContext.getTranslationUnitDecl()] =
9574 ToContext.getTranslationUnitDecl();
9581 "Try to get field index for non-field.");
9585 return std::nullopt;
9588 for (
const auto *D : Owner->decls()) {
9596 llvm_unreachable(
"Field was not found in its parent context.");
9598 return std::nullopt;
9601ASTImporter::FoundDeclsTy
9611 if (SharedState->getLookupTable()) {
9619 dyn_cast<NamespaceDecl>(ReDC));
9620 for (
auto *D : NSChain) {
9622 SharedState->getLookupTable()->lookup(dyn_cast<NamespaceDecl>(D),
9629 SharedState->getLookupTable()->lookup(ReDC, Name);
9630 return FoundDeclsTy(LookupResult.begin(), LookupResult.end());
9634 FoundDeclsTy
Result(NoloadLookupResult.
begin(), NoloadLookupResult.
end());
9651void ASTImporter::AddToLookupTable(
Decl *ToD) {
9652 SharedState->addDeclToLookup(ToD);
9658 return Importer.
Visit(FromD);
9682 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
9683 ImportedTypes.find(FromT);
9684 if (Pos != ImportedTypes.end())
9691 return ToTOrErr.takeError();
9694 ImportedTypes[FromT] = ToTOrErr->getTypePtr();
9696 return ToTOrErr->getTypePtr();
9705 return ToTyOrErr.takeError();
9718 return TOrErr.takeError();
9721 return BeginLocOrErr.takeError();
9723 return ToContext.getTrivialTypeSourceInfo(*TOrErr, *BeginLocOrErr);
9730template <
typename T>
struct AttrArgImporter {
9731 AttrArgImporter(
const AttrArgImporter<T> &) =
delete;
9732 AttrArgImporter(AttrArgImporter<T> &&) =
default;
9733 AttrArgImporter<T> &operator=(
const AttrArgImporter<T> &) =
delete;
9734 AttrArgImporter<T> &operator=(AttrArgImporter<T> &&) =
default;
9737 : To(I.importChecked(Err, From)) {}
9739 const T &value() {
return To; }
9750template <
typename T>
struct AttrArgArrayImporter {
9751 AttrArgArrayImporter(
const AttrArgArrayImporter<T> &) =
delete;
9752 AttrArgArrayImporter(AttrArgArrayImporter<T> &&) =
default;
9753 AttrArgArrayImporter<T> &operator=(
const AttrArgArrayImporter<T> &) =
delete;
9754 AttrArgArrayImporter<T> &operator=(AttrArgArrayImporter<T> &&) =
default;
9756 AttrArgArrayImporter(ASTNodeImporter &I,
Error &Err,
9757 const llvm::iterator_range<T *> &From,
9758 unsigned ArraySize) {
9761 To.reserve(ArraySize);
9765 T *value() {
return To.data(); }
9768 llvm::SmallVector<T, 2> To;
9772 Error Err{Error::success()};
9773 Attr *ToAttr =
nullptr;
9774 ASTImporter &Importer;
9775 ASTNodeImporter NImporter;
9778 AttrImporter(ASTImporter &I) : Importer(I), NImporter(I) {}
9783 template <
class T> AttrArgImporter<T> importArg(
const T &From) {
9784 return AttrArgImporter<T>(NImporter, Err, From);
9790 template <
typename T>
9791 AttrArgArrayImporter<T> importArrayArg(
const llvm::iterator_range<T *> &From,
9792 unsigned ArraySize) {
9793 return AttrArgArrayImporter<T>(NImporter, Err, From, ArraySize);
9804 template <
typename T,
typename... Arg>
9805 void importAttr(
const T *FromAttr, Arg &&...ImportedArg) {
9806 static_assert(std::is_base_of<Attr, T>::value,
9807 "T should be subclass of Attr.");
9808 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9810 const IdentifierInfo *ToAttrName = Importer.
Import(FromAttr->getAttrName());
9811 const IdentifierInfo *ToScopeName =
9812 Importer.
Import(FromAttr->getScopeName());
9813 SourceRange ToAttrRange =
9815 SourceLocation ToScopeLoc =
9821 AttributeCommonInfo ToI(
9822 ToAttrName, AttributeScopeInfo(ToScopeName, ToScopeLoc), ToAttrRange,
9823 FromAttr->getParsedKind(), FromAttr->getForm());
9827 std::forward<Arg>(ImportedArg)..., ToI);
9831 if (
auto *ToInheritableAttr = dyn_cast<InheritableAttr>(ToAttr))
9832 ToInheritableAttr->setInherited(FromAttr->isInherited());
9838 void cloneAttr(
const Attr *FromAttr) {
9839 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9851 llvm::Expected<Attr *> getResult() && {
9853 return std::move(Err);
9854 assert(ToAttr &&
"Attribute should be created.");
9861 AttrImporter AI(*
this);
9864 switch (FromAttr->
getKind()) {
9865 case attr::Aligned: {
9867 if (From->isAlignmentExpr())
9868 AI.importAttr(From,
true, AI.importArg(From->getAlignmentExpr()).value());
9870 AI.importAttr(From,
false,
9871 AI.importArg(From->getAlignmentType()).value());
9875 case attr::AlignValue: {
9877 AI.importAttr(From, AI.importArg(From->getAlignment()).value());
9881 case attr::Format: {
9883 AI.importAttr(From,
Import(From->getType()), From->getFormatIdx(),
9884 From->getFirstArg());
9888 case attr::EnableIf: {
9890 AI.importAttr(From, AI.importArg(From->getCond()).value(),
9891 From->getMessage());
9895 case attr::AssertCapability: {
9898 AI.importArrayArg(From->args(), From->args_size()).value(),
9902 case attr::AcquireCapability: {
9905 AI.importArrayArg(From->args(), From->args_size()).value(),
9909 case attr::TryAcquireCapability: {
9911 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9912 AI.importArrayArg(From->args(), From->args_size()).value(),
9916 case attr::ReleaseCapability: {
9919 AI.importArrayArg(From->args(), From->args_size()).value(),
9923 case attr::RequiresCapability: {
9926 AI.importArrayArg(From->args(), From->args_size()).value(),
9930 case attr::GuardedBy: {
9933 AI.importArrayArg(From->args(), From->args_size()).value(),
9937 case attr::PtGuardedBy: {
9940 AI.importArrayArg(From->args(), From->args_size()).value(),
9944 case attr::AcquiredAfter: {
9947 AI.importArrayArg(From->args(), From->args_size()).value(),
9951 case attr::AcquiredBefore: {
9954 AI.importArrayArg(From->args(), From->args_size()).value(),
9958 case attr::LockReturned: {
9960 AI.importAttr(From, AI.importArg(From->getArg()).value());
9963 case attr::LocksExcluded: {
9966 AI.importArrayArg(From->args(), From->args_size()).value(),
9974 AI.cloneAttr(FromAttr);
9979 return std::move(AI).getResult();
9983 return ImportedDecls.lookup(FromD);
9987 auto FromDPos = ImportedFromDecls.find(ToD);
9988 if (FromDPos == ImportedFromDecls.end())
9998 ImportPath.push(FromD);
9999 llvm::scope_exit ImportPathBuilder([
this]() { ImportPath.pop(); });
10004 return make_error<ASTImportError>(*
Error);
10010 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
10012 return make_error<ASTImportError>(*
Error);
10019 if (ImportPath.hasCycleAtBack())
10020 SavedImportPaths[FromD].push_back(ImportPath.copyCycleAtBack());
10029 auto Pos = ImportedDecls.find(FromD);
10030 bool ToDWasCreated = Pos != ImportedDecls.end();
10034 Decl *CreatedToD = ToDWasCreated ? Pos->second :
nullptr;
10035 if (ToDWasCreated) {
10038 auto *ToD = CreatedToD;
10039 ImportedDecls.erase(Pos);
10051 auto PosF = ImportedFromDecls.find(ToD);
10052 if (PosF != ImportedFromDecls.end()) {
10057 SharedState->removeDeclFromLookup(ToD);
10058 ImportedFromDecls.erase(PosF);
10070 handleAllErrors(ToDOrErr.takeError(),
10075 SharedState->setImportDeclError(CreatedToD, ErrOut);
10079 for (
const auto &Path : SavedImportPaths[FromD]) {
10082 Decl *PrevFromDi = FromD;
10083 for (
Decl *FromDi : Path) {
10085 if (FromDi == FromD)
10092 PrevFromDi = FromDi;
10096 auto Ii = ImportedDecls.find(FromDi);
10097 if (Ii != ImportedDecls.end())
10098 SharedState->setImportDeclError(Ii->second, ErrOut);
10103 SavedImportPaths.erase(FromD);
10106 return make_error<ASTImportError>(ErrOut);
10118 return make_error<ASTImportError>(*Err);
10124 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
10126 return make_error<ASTImportError>(*
Error);
10129 assert(ImportedDecls.count(FromD) != 0 &&
"Missing call to MapImported?");
10133 auto ToAttrOrErr =
Import(FromAttr);
10137 return ToAttrOrErr.takeError();
10144 SavedImportPaths.erase(FromD);
10159 return ToDCOrErr.takeError();
10164 if (
auto *ToRecord = dyn_cast<RecordDecl>(ToDC)) {
10166 if (ToRecord->isCompleteDefinition())
10174 if (FromRecord->getASTContext().getExternalSource() &&
10175 !FromRecord->isCompleteDefinition())
10176 FromRecord->getASTContext().getExternalSource()->CompleteType(FromRecord);
10178 if (FromRecord->isCompleteDefinition())
10181 return std::move(Err);
10182 }
else if (
auto *ToEnum = dyn_cast<EnumDecl>(ToDC)) {
10184 if (ToEnum->isCompleteDefinition()) {
10186 }
else if (FromEnum->isCompleteDefinition()) {
10189 return std::move(Err);
10193 }
else if (
auto *ToClass = dyn_cast<ObjCInterfaceDecl>(ToDC)) {
10195 if (ToClass->getDefinition()) {
10200 return std::move(Err);
10204 }
else if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(ToDC)) {
10206 if (ToProto->getDefinition()) {
10211 return std::move(Err);
10222 return cast_or_null<Expr>(*ToSOrErr);
10224 return ToSOrErr.takeError();
10232 llvm::DenseMap<Stmt *, Stmt *>::iterator Pos = ImportedStmts.find(FromS);
10233 if (Pos != ImportedStmts.end())
10234 return Pos->second;
10242 if (
auto *ToE = dyn_cast<Expr>(*ToSOrErr)) {
10246 ToE->setValueKind(FromE->getValueKind());
10247 ToE->setObjectKind(FromE->getObjectKind());
10248 ToE->setDependence(FromE->getDependence());
10252 ImportedStmts[FromS] = *ToSOrErr;
10263 auto NSOrErr =
Import(Namespace);
10265 return NSOrErr.takeError();
10266 auto PrefixOrErr =
Import(Prefix);
10268 return PrefixOrErr.takeError();
10276 return RDOrErr.takeError();
10281 return TyOrErr.takeError();
10284 llvm_unreachable(
"Invalid nested name specifier kind");
10296 NestedNames.push_back(NNS);
10302 while (!NestedNames.empty()) {
10303 NNS = NestedNames.pop_back_val();
10306 return std::move(Err);
10313 return std::move(Err);
10317 return std::move(Err);
10323 ToLocalBeginLoc, ToLocalEndLoc);
10329 return std::move(Err);
10342 if (!ToSourceRangeOrErr)
10343 return ToSourceRangeOrErr.takeError();
10346 ToSourceRangeOrErr->getBegin(),
10347 ToSourceRangeOrErr->getEnd());
10351 llvm_unreachable(
"unexpected null nested name specifier");
10364 return ToTemplateOrErr.takeError();
10369 for (
auto *I : *FromStorage) {
10370 if (
auto ToOrErr =
Import(I))
10373 return ToOrErr.takeError();
10375 return ToContext.getOverloadedTemplateName(ToTemplates.
begin(),
10376 ToTemplates.
end());
10382 if (!DeclNameOrErr)
10383 return DeclNameOrErr.takeError();
10384 return ToContext.getAssumedTemplateName(*DeclNameOrErr);
10390 if (!QualifierOrErr)
10391 return QualifierOrErr.takeError();
10394 return TNOrErr.takeError();
10395 return ToContext.getQualifiedTemplateName(
10402 if (!QualifierOrErr)
10403 return QualifierOrErr.takeError();
10404 return ToContext.getDependentTemplateName(
10412 if (!ReplacementOrErr)
10413 return ReplacementOrErr.takeError();
10416 if (!AssociatedDeclOrErr)
10417 return AssociatedDeclOrErr.takeError();
10419 return ToContext.getSubstTemplateTemplateParm(
10420 *ReplacementOrErr, *AssociatedDeclOrErr, Subst->
getIndex(),
10428 auto ArgPackOrErr =
10431 return ArgPackOrErr.takeError();
10434 if (!AssociatedDeclOrErr)
10435 return AssociatedDeclOrErr.takeError();
10437 return ToContext.getSubstTemplateTemplateParmPack(
10438 *ArgPackOrErr, *AssociatedDeclOrErr, SubstPack->
getIndex(),
10444 return UsingOrError.takeError();
10448 llvm_unreachable(
"Unexpected DeducedTemplate");
10451 llvm_unreachable(
"Invalid template name kind");
10463 if (!ToFileIDOrErr)
10464 return ToFileIDOrErr.takeError();
10472 return std::move(Err);
10474 return std::move(Err);
10480 llvm::DenseMap<FileID, FileID>::iterator Pos = ImportedFileIDs.find(FromID);
10481 if (Pos != ImportedFileIDs.end())
10482 return Pos->second;
10494 return ToSpLoc.takeError();
10497 return ToExLocS.takeError();
10507 return ToExLocE.takeError();
10513 if (!IsBuiltin && !
Cache->BufferOverridden) {
10517 return ToIncludeLoc.takeError();
10528 if (
Cache->OrigEntry &&
Cache->OrigEntry->getDir()) {
10534 ToFileManager.getOptionalFileRef(
Cache->OrigEntry->getName());
10539 ToID = ToSM.
createFileID(*Entry, ToIncludeLocOrFakeLoc,
10546 std::optional<llvm::MemoryBufferRef> FromBuf =
10547 Cache->getBufferOrNone(FromContext.getDiagnostics(),
10552 std::unique_ptr<llvm::MemoryBuffer> ToBuf =
10553 llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(),
10554 FromBuf->getBufferIdentifier());
10560 assert(ToID.
isValid() &&
"Unexpected invalid fileID was created.");
10562 ImportedFileIDs[FromID] = ToID;
10569 return ToExprOrErr.takeError();
10572 if (!LParenLocOrErr)
10573 return LParenLocOrErr.takeError();
10576 if (!RParenLocOrErr)
10577 return RParenLocOrErr.takeError();
10582 return ToTInfoOrErr.takeError();
10587 return std::move(Err);
10590 ToContext, *ToTInfoOrErr, From->
isBaseVirtual(), *LParenLocOrErr,
10591 *ToExprOrErr, *RParenLocOrErr, EllipsisLoc);
10595 return ToFieldOrErr.takeError();
10598 if (!MemberLocOrErr)
10599 return MemberLocOrErr.takeError();
10602 ToContext, cast_or_null<FieldDecl>(*ToFieldOrErr), *MemberLocOrErr,
10603 *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10606 if (!ToIFieldOrErr)
10607 return ToIFieldOrErr.takeError();
10610 if (!MemberLocOrErr)
10611 return MemberLocOrErr.takeError();
10614 ToContext, cast_or_null<IndirectFieldDecl>(*ToIFieldOrErr),
10615 *MemberLocOrErr, *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10619 return ToTInfoOrErr.takeError();
10621 return new (ToContext)
10623 *ToExprOrErr, *RParenLocOrErr);
10626 return make_error<ASTImportError>();
10632 auto Pos = ImportedCXXBaseSpecifiers.find(BaseSpec);
10633 if (Pos != ImportedCXXBaseSpecifiers.end())
10634 return Pos->second;
10637 if (!ToSourceRange)
10638 return ToSourceRange.takeError();
10641 return ToTSI.takeError();
10643 if (!ToEllipsisLoc)
10644 return ToEllipsisLoc.takeError();
10648 ImportedCXXBaseSpecifiers[BaseSpec] =
Imported;
10660 return ToOrErr.takeError();
10661 Decl *To = *ToOrErr;
10666 if (
auto *ToRecord = dyn_cast<RecordDecl>(To)) {
10667 if (!ToRecord->getDefinition()) {
10674 if (
auto *ToEnum = dyn_cast<EnumDecl>(To)) {
10675 if (!ToEnum->getDefinition()) {
10681 if (
auto *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
10682 if (!ToIFace->getDefinition()) {
10689 if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
10690 if (!ToProto->getDefinition()) {
10714 return ToSelOrErr.takeError();
10718 return ToContext.DeclarationNames.getCXXConstructorName(
10719 ToContext.getCanonicalType(*ToTyOrErr));
10721 return ToTyOrErr.takeError();
10726 return ToContext.DeclarationNames.getCXXDestructorName(
10727 ToContext.getCanonicalType(*ToTyOrErr));
10729 return ToTyOrErr.takeError();
10734 return ToContext.DeclarationNames.getCXXDeductionGuideName(
10737 return ToTemplateOrErr.takeError();
10742 return ToContext.DeclarationNames.getCXXConversionFunctionName(
10743 ToContext.getCanonicalType(*ToTyOrErr));
10745 return ToTyOrErr.takeError();
10749 return ToContext.DeclarationNames.getCXXOperatorName(
10753 return ToContext.DeclarationNames.getCXXLiteralOperatorName(
10761 llvm_unreachable(
"Invalid DeclarationName Kind!");
10789 for (
unsigned I = 1, N = FromSel.
getNumArgs(); I < N; ++I)
10791 return ToContext.Selectors.getSelector(FromSel.
getNumArgs(), Idents.data());
10797 llvm::Error Err = llvm::Error::success();
10798 auto ImportLoop = [&](
const APValue *From,
APValue *To,
unsigned Size) {
10799 for (
unsigned Idx = 0; Idx < Size; Idx++) {
10804 switch (FromValue.
getKind()) {
10818 ImportLoop(((
const APValue::Vec *)(
const char *)&FromValue.Data)->Elts,
10824 llvm_unreachable(
"Matrix APValue import not yet supported");
10828 ImportLoop(((
const APValue::Arr *)(
const char *)&FromValue.Data)->Elts,
10829 ((
const APValue::Arr *)(
const char *)&
Result.Data)->Elts,
10837 ((
const APValue::StructData *)(
const char *)&FromValue.Data)->Elts,
10838 ((
const APValue::StructData *)(
const char *)&
Result.Data)->Elts,
10847 return std::move(Err);
10852 Result.MakeAddrLabelDiff();
10856 return std::move(Err);
10862 const Decl *ImpMemPtrDecl =
10865 return std::move(Err);
10867 Result.setMemberPointerUninit(
10876 return std::move(Err);
10886 "in C++20 dynamic allocation are transient so they shouldn't "
10887 "appear in the AST");
10889 if (
const auto *E =
10891 FromElemTy = E->getType();
10894 return std::move(Err);
10904 return std::move(Err);
10916 return std::move(Err);
10929 for (
unsigned LoopIdx = 0; LoopIdx < PathLength; LoopIdx++) {
10931 const Decl *FromDecl =
10932 FromPath[LoopIdx].getAsBaseOrMember().getPointer();
10935 return std::move(Err);
10936 if (
auto *RD = dyn_cast<CXXRecordDecl>(FromDecl))
10937 FromElemTy = Importer.FromContext.getCanonicalTagType(RD);
10941 ImpDecl, FromPath[LoopIdx].getAsBaseOrMember().getInt()));
10944 Importer.FromContext.getAsArrayType(FromElemTy)->getElementType();
10946 FromPath[LoopIdx].getAsArrayIndex());
10954 return std::move(Err);
10962 unsigned NumDecls) {
10972 if (LastDiagFromFrom)
10973 ToContext.getDiagnostics().notePriorDiagnosticFrom(
10974 FromContext.getDiagnostics());
10975 LastDiagFromFrom =
false;
10976 return ToContext.getDiagnostics().Report(Loc, DiagID);
10980 if (!LastDiagFromFrom)
10981 FromContext.getDiagnostics().notePriorDiagnosticFrom(
10982 ToContext.getDiagnostics());
10983 LastDiagFromFrom =
true;
10984 return FromContext.getDiagnostics().Report(Loc, DiagID);
10988 if (
auto *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
10989 if (!ID->getDefinition())
10990 ID->startDefinition();
10992 else if (
auto *PD = dyn_cast<ObjCProtocolDecl>(D)) {
10993 if (!PD->getDefinition())
10994 PD->startDefinition();
10996 else if (
auto *TD = dyn_cast<TagDecl>(D)) {
10997 if (!TD->getDefinition() && !TD->isBeingDefined()) {
10998 TD->startDefinition();
10999 TD->setCompleteDefinition(
true);
11003 assert(0 &&
"CompleteDecl called on a Decl that can't be completed");
11008 auto [Pos, Inserted] = ImportedDecls.try_emplace(From, To);
11009 assert((Inserted || Pos->second == To) &&
11010 "Try to import an already imported Decl");
11012 return Pos->second;
11015 ImportedFromDecls[To] = From;
11020 AddToLookupTable(To);
11024std::optional<ASTImportError>
11026 auto Pos = ImportDeclErrors.find(FromD);
11027 if (Pos != ImportDeclErrors.end())
11028 return Pos->second;
11030 return std::nullopt;
11034 auto InsertRes = ImportDeclErrors.insert({From,
Error});
11038 assert(InsertRes.second || InsertRes.first->second.Error ==
Error.Error);
11043 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
11045 if (Pos != ImportedTypes.end()) {
11047 if (ToContext.hasSameType(*ToFromOrErr, To))
11050 llvm::consumeError(ToFromOrErr.takeError());
11055 getToContext().getLangOpts(), FromContext, ToContext, NonEquivalentDecls,
Defines the clang::ASTContext interface.
static FriendCountAndPosition getFriendCountAndPosition(ASTImporter &Importer, FriendDecl *FD)
static bool IsEquivalentFriend(ASTImporter &Importer, FriendDecl *FD1, FriendDecl *FD2)
static ExpectedStmt ImportLoopControlStmt(ASTNodeImporter &NodeImporter, ASTImporter &Importer, StmtClass *S)
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)
This file provides some common utility functions for processing Lambda related AST Constructs.
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.
Result
Implement __builtin_bit_cast and related operations.
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.
llvm::APInt getValue() const
unsigned getVersion() const
QualType getTypeInfoType() const
static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo)
unsigned getCallIndex() const
A non-discriminated union of a base, field, or array index.
static LValuePathEntry ArrayIndex(uint64_t Index)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
const LValueBase getLValueBase() const
ArrayRef< LValuePathEntry > getLValuePath() const
const FieldDecl * getUnionField() const
unsigned getStructNumFields() const
llvm::PointerIntPair< const Decl *, 1, bool > BaseOrMemberType
A FieldDecl or CXXRecordDecl, along with a flag indicating whether we mean a virtual or non-virtual b...
ValueKind getKind() const
bool isLValueOnePastTheEnd() const
bool isMemberPointerToDerivedMember() const
unsigned getArrayInitializedElts() const
unsigned getStructNumBases() const
unsigned getStructNumVirtualBases() const
bool hasLValuePath() const
const ValueDecl * getMemberPointerDecl() const
APValue & getUnionValue()
const AddrLabelExpr * getAddrLabelDiffRHS() const
CharUnits & getLValueOffset()
unsigned getVectorLength() const
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
unsigned getArraySize() const
@ Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
@ None
There is no such object (it's outside its lifetime).
bool isNullPointer() const
const AddrLabelExpr * getAddrLabelDiffLHS() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
const LangOptions & getLangOpts() const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
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).
auto makeScopedCycleDetection(const FunctionDecl *D)
bool isCycle(const FunctionDecl *D) const
Imports selected nodes from one AST context into another context, merging AST nodes where appropriate...
ASTContext & getToContext() const
Retrieve the context that AST nodes are being imported into.
DiagnosticBuilder ToDiag(SourceLocation Loc, unsigned DiagID)
Report a diagnostic in the "to" context.
Decl * MapImported(Decl *From, Decl *To)
Store and assign the imported declaration to its counterpart.
static UnsignedOrNone getFieldIndex(Decl *F)
Determine the index of a field in its parent record.
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.
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
llvm::Error ImportTemplateArguments(ArrayRef< TemplateArgument > FromArgs, SmallVectorImpl< TemplateArgument > &ToArgs)
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.
llvm::DenseSet< std::tuple< Decl *, Decl *, int > > NonEquivalentDeclSet
bool IsStructurallyEquivalent(QualType From, QualType To, bool Complain=true)
Determine whether the given types are structurally equivalent.
virtual Expected< Decl * > ImportImpl(Decl *From)
Can be overwritten by subclasses to implement their own import logic.
bool isMinimalImport() const
Whether the importer will perform a minimal import, creating to-be-completed forward declarations whe...
ASTImporter(ASTContext &ToContext, FileManager &ToFileManager, ASTContext &FromContext, FileManager &FromFileManager, bool MinimalImport, std::shared_ptr< ASTImporterSharedState > SharedState=nullptr)
llvm::Expected< ExprWithCleanups::CleanupObject > Import(ExprWithCleanups::CleanupObject From)
Import cleanup objects owned by ExprWithCleanup.
virtual void CompleteDecl(Decl *D)
Called for ObjCInterfaceDecl, ObjCProtocolDecl, and TagDecl.
Decl * GetAlreadyImportedOrNull(const Decl *FromD) const
Return the copy of the given declaration in the "to" context if it has already been imported from the...
void setImportDeclError(Decl *From, ASTImportError Error)
Mark (newly) imported declaration with error.
ExpectedDecl VisitObjCImplementationDecl(ObjCImplementationDecl *D)
ExpectedStmt VisitGenericSelectionExpr(GenericSelectionExpr *E)
ExpectedStmt VisitTypeTraitExpr(TypeTraitExpr *E)
ExpectedDecl VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
ExpectedDecl VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
ExpectedStmt VisitDeclRefExpr(DeclRefExpr *E)
ExpectedDecl VisitAccessSpecDecl(AccessSpecDecl *D)
ExpectedDecl VisitFunctionDecl(FunctionDecl *D)
ExpectedDecl VisitParmVarDecl(ParmVarDecl *D)
ExpectedStmt VisitImplicitValueInitExpr(ImplicitValueInitExpr *E)
ExpectedStmt VisitImplicitCastExpr(ImplicitCastExpr *E)
ExpectedDecl VisitCXXMethodDecl(CXXMethodDecl *D)
ExpectedDecl VisitUsingDecl(UsingDecl *D)
ExpectedDecl VisitObjCProtocolDecl(ObjCProtocolDecl *D)
ExpectedStmt VisitStmt(Stmt *S)
ExpectedDecl VisitTranslationUnitDecl(TranslationUnitDecl *D)
ExpectedDecl VisitFieldDecl(FieldDecl *D)
Error ImportFieldDeclDefinition(const FieldDecl *From, const FieldDecl *To)
Error ImportDefinitionIfNeeded(Decl *FromD, Decl *ToD=nullptr)
ExpectedStmt VisitCharacterLiteral(CharacterLiteral *E)
ExpectedStmt VisitCXXConstructExpr(CXXConstructExpr *E)
ExpectedStmt VisitObjCAtThrowStmt(ObjCAtThrowStmt *S)
ExpectedStmt VisitCXXExpansionSelectExpr(CXXExpansionSelectExpr *E)
ExpectedDecl VisitStaticAssertDecl(StaticAssertDecl *D)
ExpectedStmt VisitShuffleVectorExpr(ShuffleVectorExpr *E)
ExpectedDecl VisitObjCPropertyDecl(ObjCPropertyDecl *D)
ExpectedDecl VisitRecordDecl(RecordDecl *D)
ExpectedStmt VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E)
ExpectedStmt VisitCXXExpansionStmtPattern(CXXExpansionStmtPattern *S)
ExpectedDecl VisitUsingShadowDecl(UsingShadowDecl *D)
Error ImportArrayChecked(const InContainerTy &InContainer, OIter Obegin)
ExpectedStmt VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S)
StringRef ImportASTStringRef(StringRef FromStr)
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)
ExpectedDecl VisitRequiresExprBodyDecl(RequiresExprBodyDecl *E)
ExpectedStmt VisitObjCAtTryStmt(ObjCAtTryStmt *S)
ExpectedStmt VisitUnaryOperator(UnaryOperator *E)
Error ImportTemplateParameterLists(const DeclTy *FromD, DeclTy *ToD)
Error ImportDeclContext(DeclContext *FromDC, bool ForceImport=false)
ExpectedStmt VisitRequiresExpr(RequiresExpr *E)
ExpectedDecl VisitImplicitConceptSpecializationDecl(ImplicitConceptSpecializationDecl *D)
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 VisitPseudoObjectExpr(PseudoObjectExpr *E)
ExpectedStmt VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E)
ExpectedStmt VisitImaginaryLiteral(ImaginaryLiteral *E)
ExpectedDecl VisitConceptDecl(ConceptDecl *D)
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)
ExpectedDecl VisitCXXExpansionStmtDecl(CXXExpansionStmtDecl *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)
SmallVector< TemplateArgument, 8 > TemplateArgsTy
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)
ExpectedStmt VisitSubstNonTypeTemplateParmPackExpr(SubstNonTypeTemplateParmPackExpr *E)
ExpectedDecl VisitObjCTypeParamDecl(ObjCTypeParamDecl *D)
ExpectedDecl VisitFileScopeAsmDecl(FileScopeAsmDecl *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)
Expected< concepts::Requirement * > ImportNestedRequirement(concepts::NestedRequirement *From)
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)
ExpectedStmt VisitCXXExpansionStmtInstantiation(CXXExpansionStmtInstantiation *S)
ExpectedStmt VisitCXXParenListInitExpr(CXXParenListInitExpr *E)
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)
ExpectedDecl VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D)
ExpectedStmt VisitMemberExpr(MemberExpr *E)
ExpectedStmt VisitConceptSpecializationExpr(ConceptSpecializationExpr *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)
Expected< concepts::Requirement * > ImportExprRequirement(concepts::ExprRequirement *From)
ExpectedStmt VisitFloatingLiteral(FloatingLiteral *E)
ExpectedStmt VisitIfStmt(IfStmt *S)
ExpectedStmt VisitLabelStmt(LabelStmt *S)
ExpectedStmt VisitCXXTypeidExpr(CXXTypeidExpr *E)
ExpectedStmt VisitConvertVectorExpr(ConvertVectorExpr *E)
ExpectedDecl VisitUsingEnumDecl(UsingEnumDecl *D)
ExpectedStmt VisitGotoStmt(GotoStmt *S)
ExpectedStmt VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *E)
ExpectedStmt VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S)
ExpectedStmt VisitGCCAsmStmt(GCCAsmStmt *S)
ExpectedDecl VisitNamespaceDecl(NamespaceDecl *D)
ExpectedStmt VisitCXXTryStmt(CXXTryStmt *S)
Error ImportConstraintSatisfaction(const ASTConstraintSatisfaction &FromSat, ConstraintSatisfaction &ToSat)
ExpectedDecl VisitImportDecl(ImportDecl *D)
Error ImportFunctionDeclBody(FunctionDecl *FromFD, FunctionDecl *ToFD)
ExpectedStmt VisitArraySubscriptExpr(ArraySubscriptExpr *E)
Expected< concepts::Requirement * > ImportTypeRequirement(concepts::TypeRequirement *From)
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)
std::tuple< FunctionTemplateDecl *, TemplateArgsTy > FunctionTemplateAndArgsTy
ExpectedStmt VisitBreakStmt(BreakStmt *S)
DesignatedInitExpr::Designator Designator
ExpectedDecl VisitTemplateParamObjectDecl(TemplateParamObjectDecl *D)
SourceLocation getColonLoc() const
SourceLocation getQuestionLoc() const
Represents an access specifier followed by colon ':'.
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
AddrLabelExpr - The GNU address of label extension, representing &&label.
SourceLocation getAmpAmpLoc() const
SourceLocation getLabelLoc() const
LabelDecl * getLabel() const
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Represents a loop initializing the elements of an array.
OpaqueValueExpr * getCommonExpr() const
Get the common subexpression shared by all initializations (the source array).
Expr * getSubExpr() const
Get the initializer to use for each array element.
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
SourceLocation getRBracketLoc() const
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
uint64_t getValue() const
SourceLocation getEndLoc() const LLVM_READONLY
ArrayTypeTrait getTrait() const
Expr * getDimensionExpression() const
TypeSourceInfo * getQueriedTypeSourceInfo() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents an array type, per C99 6.7.5.2 - Array Declarators.
SourceLocation getAsmLoc() const
unsigned getNumClobbers() const
unsigned getNumOutputs() const
unsigned getNumInputs() const
A structure for storing the information associated with a name that has been assumed to be a template...
DeclarationName getDeclName() const
Get the name of the template.
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
SourceLocation getRParenLoc() const
static unsigned getNumSubExprs(AtomicOp Op)
Determine the number of arguments the specified atomic builtin should have.
SourceLocation getBuiltinLoc() const
Attr - This represents one attribute.
attr::Kind getKind() const
void setPackExpansion(bool PE)
Attr * clone(ASTContext &C) const
SourceRange getRange() const
void setRange(SourceRange R)
void setAttrName(const IdentifierInfo *AttrNameII)
const IdentifierInfo * getAttrName() const
Represents an attribute applied to a statement.
SourceLocation getAttrLoc() const
ArrayRef< const Attr * > getAttrs() const
static AttributedStmt * Create(const ASTContext &C, SourceLocation Loc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Represents a C++ declaration that introduces decls from somewhere else.
void addShadowDecl(UsingShadowDecl *S)
shadow_range shadows() const
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condition evaluates to false; ...
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value.
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression which will be evaluated if the condition evaluates to true; th...
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
A builtin binary operation expression such as "x + y" or "x <= y".
SourceLocation getOperatorLoc() const
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
FPOptionsOverride getFPFeatures() const
A binding in a decomposition declaration.
ValueDecl * getDecomposedDecl() const
Get the decomposition declaration that this binding represents a decomposition of.
Expr * getBinding() const
Get the expression to which this declaration is bound.
void setBinding(QualType DeclaredType, Expr *Binding)
Set the binding for this BindingDecl, along with its declared type (which should be a possibly-cv-qua...
void setDecomposedDecl(ValueDecl *Decomposed)
Set the decomposed variable for this BindingDecl.
BreakStmt - This represents a break.
Represents a C++2a __builtin_bit_cast(T, v) expression.
Represents the builtin template declaration which is used to implement __make_integer_seq and other b...
BuiltinTemplateKind getBuiltinTemplateKind() const
This class is used for builtin types like 'int'.
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, FPOptionsOverride FPO, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
Represents a base class of a C++ class.
AccessSpecifier getAccessSpecifierAsWritten() const
Retrieves the access specifier as written in the source code (which may mean that no access specifier...
SourceLocation getEllipsisLoc() const
For a pack expansion, determine the location of the ellipsis.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
TypeSourceInfo * getTypeSourceInfo() const
Retrieves the type and source location of the base class.
bool isBaseOfClass() const
Determine whether this base class is a base of a class declared with the 'class' keyword (vs.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
Represents binding an expression to a temporary.
CXXTemporary * getTemporary()
static CXXBindTemporaryExpr * Create(const ASTContext &C, CXXTemporary *Temp, Expr *SubExpr)
const Expr * getSubExpr() const
A boolean literal, per ([C++ lex.bool] Boolean literals).
static CXXBoolLiteralExpr * Create(const ASTContext &C, bool Val, QualType Ty, SourceLocation Loc)
SourceLocation getLocation() const
CXXCatchStmt - This represents a C++ catch block.
SourceLocation getCatchLoc() const
Stmt * getHandlerBlock() const
VarDecl * getExceptionDecl() const
static CXXConstCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Represents a call to a C++ constructor.
SourceRange getParenOrBraceRange() const
void setIsImmediateEscalating(bool Set)
bool isElidable() const
Whether this construction is elidable.
bool hadMultipleCandidates() const
Whether the referred constructor was resolved from an overloaded set having size greater than 1.
static CXXConstructExpr * Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr * > Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, CXXConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Create a C++ construction expression.
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
bool isImmediateEscalating() const
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called.
SourceLocation getLocation() const
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
CXXConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Represents a C++ constructor within a class.
Represents a C++ conversion function within a class.
Represents a C++ base or member initializer.
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
Expr * getInit() const
Get the initializer.
SourceLocation getRParenLoc() const
SourceLocation getEllipsisLoc() const
SourceLocation getLParenLoc() const
bool isPackExpansion() const
Determine whether this initializer is a pack expansion.
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
bool isMemberInitializer() const
Determine whether this initializer is initializing a non-static data member.
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
bool isIndirectMemberInitializer() const
SourceLocation getMemberLocation() const
IndirectFieldDecl * getIndirectMember() const
bool isBaseVirtual() const
Returns whether the base is virtual or not.
Represents a C++ deduction guide declaration.
SourceDeductionGuideKind getSourceDeductionGuideKind() const
A default argument (C++ [dcl.fct.default]).
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
const ParmVarDecl * getParam() const
Expr * getRewrittenExpr()
const DeclContext * getUsedContext() const
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
bool hasRewrittenInit() const
A use of a default initializer in a constructor or in aggregate initialization.
static CXXDefaultInitExpr * Create(const ASTContext &Ctx, SourceLocation Loc, FieldDecl *Field, DeclContext *UsedContext, Expr *RewrittenInitExpr)
Field is the non-static data member whose default initializer is used by this expression.
const DeclContext * getUsedContext() const
const Expr * getRewrittenExpr() const
Retrieve the initializing expression with evaluated immediate calls, if any.
bool hasRewrittenInit() const
FieldDecl * getField()
Get the field whose initializer will be used.
SourceLocation getBeginLoc() const
Represents a delete expression for memory deallocation and destructor calls, e.g.
FunctionDecl * getOperatorDelete() const
SourceLocation getBeginLoc() const
bool isGlobalDelete() const
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
bool isArrayFormAsWritten() const
Represents a C++ member access expression where the actual member referenced could not be resolved be...
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
SourceLocation getOperatorLoc() const
Retrieve the location of the '->' or '.' operator.
static CXXDependentScopeMemberExpr * Create(const ASTContext &Ctx, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
SourceLocation getMemberLoc() const
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the member name, with source location information.
bool isImplicitAccess() const
True if this is an implicit access, i.e.
ArrayRef< TemplateArgumentLoc > template_arguments() const
Represents a C++ destructor within a class.
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg)
static CXXDynamicCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Helper that selects an expression from an InitListExpr depending on the current expansion index.
InitListExpr * getRangeExpr()
Represents a C++26 expansion statement declaration.
CXXExpansionStmtPattern * getExpansionPattern()
CXXExpansionStmtInstantiation * getInstantiations()
void setInstantiations(CXXExpansionStmtInstantiation *S)
NonTypeTemplateParmDecl * getIndexTemplateParm()
void setExpansionPattern(CXXExpansionStmtPattern *S)
Represents the code generated for an expanded expansion statement.
ArrayRef< Stmt * > getInstantiations() const
bool shouldApplyLifetimeExtensionToPreamble() const
CXXExpansionStmtDecl * getParent()
ArrayRef< Stmt * > getPreambleStmts() const
static CXXExpansionStmtInstantiation * Create(ASTContext &C, CXXExpansionStmtDecl *Parent, ArrayRef< Stmt * > Instantiations, ArrayRef< Stmt * > PreambleStmts, bool ShouldApplyLifetimeExtensionToPreamble)
CXXExpansionStmtPattern - Represents an unexpanded C++ expansion statement.
ExpansionStmtKind getKind() const
static CXXExpansionStmtPattern * CreateIterating(ASTContext &Context, CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVar, DeclStmt *Range, DeclStmt *Begin, DeclStmt *Iter, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc)
Create an iterating expansion statement pattern.
const DeclStmt * getIterVarStmt() const
DeclStmt * getExpansionVarStmt()
static CXXExpansionStmtPattern * CreateDependent(ASTContext &Context, CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVar, Expr *ExpansionInitializer, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc)
Create a dependent expansion statement pattern.
SourceLocation getRParenLoc() const
static CXXExpansionStmtPattern * CreateDestructuring(ASTContext &Context, CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVar, Stmt *DecompositionDeclStmt, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc)
Create a destructuring expansion statement pattern.
Stmt * getDecompositionDeclStmt()
const DeclStmt * getBeginVarStmt() const
SourceLocation getColonLoc() const
Expr * getExpansionInitializer()
const DeclStmt * getRangeVarStmt() const
CXXExpansionStmtDecl * getDecl()
static CXXExpansionStmtPattern * CreateEnumerating(ASTContext &Context, CXXExpansionStmtDecl *ESD, Stmt *Init, DeclStmt *ExpansionVar, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation RParenLoc)
Create an enumerating expansion statement pattern.
SourceLocation getLParenLoc() const
Represents a folding of a pack over an operator.
UnresolvedLookupExpr * getCallee() const
SourceLocation getLParenLoc() const
SourceLocation getEllipsisLoc() const
UnsignedOrNone getNumExpansions() const
SourceLocation getRParenLoc() const
BinaryOperatorKind getOperator() const
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
DeclStmt * getBeginStmt()
DeclStmt * getLoopVarStmt()
SourceLocation getForLoc() const
DeclStmt * getRangeStmt()
SourceLocation getRParenLoc() const
SourceLocation getColonLoc() const
SourceLocation getCoawaitLoc() const
static CXXFunctionalCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, TypeSourceInfo *Written, CastKind Kind, Expr *Op, const CXXCastPath *Path, FPOptionsOverride FPO, SourceLocation LPLoc, SourceLocation RPLoc)
Represents a call to an inherited base class constructor from an inheriting constructor.
bool constructsVBase() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will call.
SourceLocation getLocation() const LLVM_READONLY
bool inheritedFromVBase() const
Determine whether the inherited constructor is inherited from a virtual base of the object we constru...
Represents a call to a member function that may be written either with member call syntax (e....
static CXXMemberCallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RP, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0)
Represents a static or instance method of a struct/union/class.
void addOverriddenMethod(const CXXMethodDecl *MD)
overridden_method_range overridden_methods() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Abstract class common to all of the C++ "named"/"keyword" casts.
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
SourceRange getAngleBrackets() const LLVM_READONLY
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
static CXXNewExpr * Create(const ASTContext &Ctx, bool IsGlobalNew, FunctionDecl *OperatorNew, FunctionDecl *OperatorDelete, const ImplicitAllocationParameters &IAP, 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.
SourceRange getDirectInitRange() const
llvm::iterator_range< arg_iterator > placement_arguments()
std::optional< Expr * > getArraySize()
This might return std::nullopt even if isArray() returns true, since there might not be an array size...
CXXNewInitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
ImplicitAllocationParameters implicitAllocationParameters() const
Provides the full set of information about expected implicit parameters in this call.
FunctionDecl * getOperatorDelete() const
unsigned getNumPlacementArgs() const
TypeSourceInfo * getAllocatedTypeSourceInfo() const
SourceRange getSourceRange() const
SourceRange getTypeIdParens() const
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
FunctionDecl * getOperatorNew() const
Expr * getInitializer()
The initializer of this new-expression.
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
SourceLocation getEndLoc() const
Expr * getOperand() const
SourceLocation getBeginLoc() const
The null pointer literal (C++11 [lex.nullptr])
SourceLocation getLocation() const
static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptionsOverride FPFeatures, ADLCallKind UsesADL=NotADL, bool IsReversed=false)
Represents a list-initialization with parenthesis.
static CXXParenListInitExpr * Create(ASTContext &C, ArrayRef< Expr * > Args, QualType T, unsigned NumUserSpecifiedExprs, SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getInitLoc() const LLVM_READONLY
MutableArrayRef< Expr * > getInitExprs()
SourceLocation getBeginLoc() const LLVM_READONLY
MutableArrayRef< Expr * > getUserSpecifiedInitExprs()
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
TypeSourceInfo * getDestroyedTypeInfo() const
Retrieve the source location information for the type being destroyed.
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise,...
TypeSourceInfo * getScopeTypeInfo() const
Retrieve the scope type in a qualified pseudo-destructor expression.
SourceLocation getTildeLoc() const
Retrieve the location of the '~'.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieves the nested-name-specifier that qualifies the type name, with source-location information.
SourceLocation getDestroyedTypeLoc() const
Retrieve the starting location of the type being destroyed.
SourceLocation getColonColonLoc() const
Retrieve the location of the '::' in a qualified pseudo-destructor expression.
SourceLocation getOperatorLoc() const
Retrieve the location of the '.' or '->' operator.
const IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
Represents a C++ struct/union/class.
CXXRecordDecl * getMostRecentDecl()
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
method_range methods() const
CXXRecordDecl * getDefinition() const
static CXXRecordDecl * CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, unsigned DependencyKind, bool IsGeneric, LambdaCaptureDefault CaptureDefault)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
void setLambdaContextDecl(Decl *ContextDecl)
Set the context declaration for a lambda class.
void setDescribedClassTemplate(ClassTemplateDecl *Template)
void setLambdaNumbering(LambdaNumbering Numbering)
Set the mangling numbers for a lambda class.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
CXXRecordDecl * getPreviousDecl()
static CXXReinterpretCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
A rewritten comparison expression that was originally written using operator syntax.
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
bool isReversed() const
Determine whether this expression was rewritten in reverse form.
An expression "T()" which creates an rvalue of a non-class type T.
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.
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.
SourceLocation getTryLoc() const
CXXCatchStmt * getHandler(unsigned i)
unsigned getNumHandlers() const
static CXXTryStmt * Create(const ASTContext &C, SourceLocation tryLoc, CompoundStmt *tryBlock, ArrayRef< Stmt * > handlers)
CompoundStmt * getTryBlock()
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
bool isTypeOperand() const
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Expr * getExprOperand() const
SourceRange getSourceRange() const LLVM_READONLY
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
bool isListInitialization() const
Determine whether this expression models list-initialization.
static CXXUnresolvedConstructExpr * Create(const ASTContext &Context, QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool IsListInit)
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
unsigned getNumArgs() const
Retrieve the number of arguments.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
ADLCallKind getADLCallKind() const
FPOptionsOverride getFPFeatures() const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
SourceLocation getRParenLoc() const
CaseStmt - Represent a case statement.
SourceLocation getEllipsisLoc() const
Get the location of the ... in a case statement of the form LHS ... RHS.
static CaseStmt * Create(const ASTContext &Ctx, Expr *lhs, Expr *rhs, SourceLocation caseLoc, SourceLocation ellipsisLoc, SourceLocation colonLoc)
Build a case statement.
SourceLocation getCaseLoc() const
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.
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...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a class template specialization, which refers to a class template with a given set of temp...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void setPointOfInstantiation(SourceLocation Loc)
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setExternKeywordLoc(SourceLocation Loc)
Sets the location of the extern keyword.
void setSpecializationKind(TemplateSpecializationKind TSK)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
SourceLocation getExternKeywordLoc() const
Gets the location of the extern keyword, if present.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this class template specialization is an instantiation of a template (rather than an explicit spec...
bool hasStrictPackMatch() const
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.
CompoundAssignOperator - For compound assignments (e.g.
QualType getComputationLHSType() const
static CompoundAssignOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures, QualType CompLHSType=QualType(), QualType CompResultType=QualType())
QualType getComputationResultType() const
CompoundLiteralExpr - [C99 6.5.2.5].
SourceLocation getLParenLoc() const
const Expr * getInitializer() const
TypeSourceInfo * getTypeSourceInfo() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
SourceLocation getLBracLoc() const
bool hasStoredFPFeatures() const
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)
SourceLocation getRBracLoc() const
Declaration of a C++20 concept.
Expr * getConstraintExpr() const
A reference to a concept and its template args, as it appears in the code.
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
NamedDecl * getFoundDecl() const
const DeclarationNameInfo & getConceptNameInfo() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
TemplateDecl * getNamedConcept() const
SourceLocation getTemplateKWLoc() const
Represents the specialization of a concept - evaluates to a prvalue of type bool.
static ConceptSpecializationExpr * Create(const ASTContext &C, ConceptReference *ConceptRef, ImplicitConceptSpecializationDecl *SpecDecl, const ConstraintSatisfaction *Satisfaction)
ConceptReference * getConceptReference() const
const ImplicitConceptSpecializationDecl * getSpecializationDecl() const
const ASTConstraintSatisfaction & getSatisfaction() const
Get elaborated satisfaction info about the template arguments' satisfaction of the named concept.
ConditionalOperator - The ?
Expr * getCond() const
getCond - Return the expression representing the condition for the ?
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)
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
llvm::SmallVector< UnsatisfiedConstraintRecord, 4 > Details
The substituted constraint expr, if the template arguments could be substituted into them,...
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...
FPOptionsOverride getStoredFPFeaturesOrDefault() const
Get the store FPOptionsOverride or default if not stored.
SourceLocation getRParenLoc() const
getRParenLoc - Return the location of final right parenthesis.
static ConvertVectorExpr * Create(const ASTContext &C, Expr *SrcExpr, TypeSourceInfo *TI, QualType DstType, ExprValueKind VK, ExprObjectKind OK, SourceLocation BuiltinLoc, SourceLocation RParenLoc, FPOptionsOverride FPFeatures)
SourceLocation getBuiltinLoc() const
getBuiltinLoc - Return the location of the __builtin_convertvector token.
TypeSourceInfo * getTypeSourceInfo() const
getTypeSourceInfo - Return the destination type.
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
AccessSpecifier getAccess() const
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
DeclContextLookupResult lookup_result
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDeclInternal(Decl *D)
Add the declaration D into this context, but suppress searches for external declarations with the sam...
bool containsDeclAndLoad(Decl *D) const
Checks whether a declaration is in this context.
void removeDecl(Decl *D)
Removes a declaration from this context.
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
void localUncachedLookup(DeclarationName Name, SmallVectorImpl< NamedDecl * > &Results)
A simplistic name lookup mechanism that performs name lookup into this declaration context without co...
static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls)
A reference to a declared variable, function, enum, etc.
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name,...
ArrayRef< TemplateArgumentLoc > template_arguments() const
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
bool hadMultipleCandidates() const
Returns true if this expression refers to a function that was resolved from an overloaded set having ...
SourceLocation getLocation() const
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
bool isImmediateEscalating() const
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
SourceLocation getEndLoc() const
const DeclGroupRef getDeclGroup() const
SourceLocation getBeginLoc() const LLVM_READONLY
A simple visitor class that helps create declaration visitors.
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEndLoc() const LLVM_READONLY
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
@ FOK_None
Not a friend object.
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration.
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
const char * getDeclKindName() const
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
@ IDNS_NonMemberOperator
This declaration is a C++ operator declared in a non-class context.
@ IDNS_TagFriend
This declaration is a friend class.
@ IDNS_Ordinary
Ordinary names.
@ IDNS_ObjCProtocol
Objective C @protocol.
@ IDNS_Namespace
Namespaces, declared with 'namespace foo {}'.
@ IDNS_OrdinaryFriend
This declaration is a friend function.
@ IDNS_Tag
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
void setImplicit(bool I=true)
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
bool isInAnonymousNamespace() const
SourceLocation getBeginLoc() const LLVM_READONLY
TranslationUnitDecl * getTranslationUnitDecl()
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
void setLexicalDeclContext(DeclContext *DC)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
const IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it.
static DeclarationName getUsingDirectiveName()
Returns the name for all C++ using-directives.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
@ CXXConversionFunctionName
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
NameKind getNameKind() const
Determine what kind of name this is.
bool isEmpty() const
Evaluates true when this declaration name is empty.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
SourceLocation getBeginLoc() const LLVM_READONLY
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
void setTypeSourceInfo(TypeSourceInfo *TI)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
TypeSourceInfo * getTypeSourceInfo() const
A decomposition declaration.
SourceLocation getDefaultLoc() const
A qualified reference to a name whose declaration cannot yet be resolved.
static DependentScopeDeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
ArrayRef< TemplateArgumentLoc > template_arguments() const
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
IdentifierOrOverloadedOperator getName() const
NestedNameSpecifier getQualifier() const
Return the nested name specifier that qualifies this name.
bool hasTemplateKeyword() const
Was this template name was preceeded by the template keyword?
Represents a single C99 designator.
unsigned getArrayIndex() const
bool isFieldDesignator() const
static Designator CreateArrayRangeDesignator(unsigned Index, SourceLocation LBracketLoc, SourceLocation EllipsisLoc, SourceLocation RBracketLoc)
Creates a GNU array-range designator.
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
bool isArrayRangeDesignator() const
static Designator CreateArrayDesignator(unsigned Index, SourceLocation LBracketLoc, SourceLocation RBracketLoc)
Creates an array designator.
bool isArrayDesignator() const
SourceLocation getFieldLoc() const
SourceLocation getRBracketLoc() const
const IdentifierInfo * getFieldName() const
SourceLocation getEllipsisLoc() const
SourceLocation getDotLoc() const
SourceLocation getLBracketLoc() const
Represents a C99 designated initializer expression.
Expr * getSubExpr(unsigned Idx) const
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
MutableArrayRef< Designator > designators()
Expr * getInit() const
Retrieve the initializer value.
unsigned size() const
Returns the number of designators in this initializer.
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the '=' that precedes the initializer value itself, if present.
unsigned getNumSubExprs() const
Retrieve the total number of subexpressions in this designated initializer expression,...
static DesignatedInitExpr * Create(const ASTContext &C, ArrayRef< Designator > Designators, ArrayRef< Expr * > IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
A little helper class used to produce diagnostics.
DoStmt - This represents a 'do/while' stmt.
SourceLocation getWhileLoc() const
SourceLocation getDoLoc() const
SourceLocation getRParenLoc() const
Symbolic representation of a dynamic allocation.
Represents an empty-declaration.
An instance of this object exists for each enum constant that is defined.
llvm::APSInt getInitVal() const
const Expr * getInitExpr() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this enumeration is an instantiation of a member enumeration of a class template specialization,...
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
void setIntegerType(QualType T)
Set the underlying integer type.
EnumDecl * getMostRecentDecl()
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
void completeDefinition(QualType NewType, QualType PromotionType, unsigned NumPositiveBits, unsigned NumNegativeBits)
When created, the EnumDecl corresponds to a forward-declared enum.
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
EnumDecl * getDefinition() const
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum.
QualType getPromotionType() const
Return the integer type that enumerators should promote to.
ExplicitCastExpr - An explicit cast written in the source code.
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
Store information needed for an explicit specifier.
ExplicitSpecKind getKind() const
const Expr * getExpr() const
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
bool cleanupsHaveSideEffects() const
ArrayRef< CleanupObject > getObjects() const
unsigned getNumObjects() const
llvm::PointerUnion< BlockDecl *, CompoundLiteralExpr * > CleanupObject
The type of objects that are kept in the cleanup.
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
This represents one expression.
bool isValueDependent() const
Determines whether the value of this expression depends on.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates).
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
ExprDependence getDependence() const
An expression trait intrinsic.
SourceLocation getBeginLoc() const LLVM_READONLY
Expr * getQueriedExpression() const
ExpressionTrait getTrait() const
SourceLocation getEndLoc() const LLVM_READONLY
virtual void CompleteType(TagDecl *Tag)
Gives the external AST source an opportunity to complete an incomplete type.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
bool isMutable() const
Determines whether this field is mutable (C++ only).
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
void setInClassInitializer(Expr *NewInit)
Set the C++11 in-class initializer for this member.
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
const VariableArrayType * getCapturedVLAType() const
Get the captured variable length array type.
void setCapturedVLAType(const VariableArrayType *VLAType)
Set the captured variable length array type for this field.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Implements support for file system lookup, file system caching, and directory search management.
SourceLocation getAsmLoc() const
const Expr * getAsmStringExpr() const
SourceLocation getRParenLoc() const
SourceLocation getLocation() const
Retrieve the location of the literal.
llvm::APInt getValue() const
Returns an internal integer representation 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.
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
SourceLocation getRParenLoc() const
SourceLocation getForLoc() const
SourceLocation getLParenLoc() const
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
SourceLocation getEllipsisLoc() const
Retrieves the location of the '...', if present.
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
const Expr * getSubExpr() const
static DefaultedOrDeletedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups, FPOptionsOverride FPFeatures, 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
DefaultedOrDeletedFunctionInfo * getDefaultedOrDeletedInfo() 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 isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
bool UsesFPIntrin() const
Determine whether the function was declared in source context that requires constrained FP intrinsics...
SourceLocation getDefaultLoc() const
ArrayRef< ParmVarDecl * > parameters() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
bool hasWrittenPrototype() const
Whether this function has a written prototype.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
void setDefaultLoc(SourceLocation NewLoc)
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
@ TK_MemberSpecialization
@ TK_DependentNonTemplate
@ TK_FunctionTemplateSpecialization
@ TK_DependentFunctionTemplateSpecialization
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool FriendConstraintRefersToEnclosingTemplate() const
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
void setInstantiatedFromDecl(FunctionDecl *FD)
Specify that this function declaration was instantiated from a FunctionDecl FD.
bool isDeletedAsWritten() const
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo *TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization.
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
FunctionDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
void setIsDestroyingOperatorDelete(bool IsDestroyingDelete)
FunctionDecl * getDefinition()
Get the definition for this declaration.
bool isTypeAwareOperatorNewOrDelete() const
Determine whether this is a type aware operator new or delete.
void setIsTypeAwareOperatorNewOrDelete(bool IsTypeAwareOperator=true)
void setRangeEnd(SourceLocation E)
bool isDefaulted() const
Whether this function is defaulted.
FunctionDecl * getInstantiatedFromDecl() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
void setDefaulted(bool D=true)
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
void setDeletedAsWritten(bool D=true, StringLiteral *Message=nullptr)
void setExplicitlyDefaulted(bool ED=true)
State that this function is explicitly defaulted.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
DeclarationNameInfo getNameInfo() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Represents a prototype with parameter type info, e.g.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > exceptions() const
ArrayRef< QualType > param_types() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary pattern.
FunctionTemplateDecl * getMostRecentDecl()
ExtInfo getExtInfo() const
QualType getReturnType() const
This represents a GCC inline-assembly statement extension.
unsigned getNumLabels() const
SourceLocation getRParenLoc() const
IdentifierInfo * getInputIdentifier(unsigned i) const
const Expr * getOutputConstraintExpr(unsigned i) const
const Expr * getInputConstraintExpr(unsigned i) const
IdentifierInfo * getOutputIdentifier(unsigned i) const
const Expr * getAsmStringExpr() const
Expr * getClobberExpr(unsigned i)
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a C11 generic selection.
TypeSourceInfo * getControllingType()
Return the controlling type of this generic selection expression.
ArrayRef< Expr * > getAssocExprs() const
bool isExprPredicate() const
Whether this generic selection uses an expression as its controlling argument.
SourceLocation getGenericLoc() const
SourceLocation getRParenLoc() const
unsigned getResultIndex() const
The zero-based index of the result expression's generic association in the generic selection's associ...
SourceLocation getDefaultLoc() const
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression accepting an expression predicate.
bool isResultDependent() const
Whether this generic selection is result-dependent.
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
ArrayRef< TypeSourceInfo * > getAssocTypeSourceInfos() const
GotoStmt - This represents a direct goto.
SourceLocation getLabelLoc() const
SourceLocation getGotoLoc() const
LabelDecl * getLabel() const
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.
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.
SourceLocation getIfLoc() const
IfStatementKind getStatementKind() const
SourceLocation getElseLoc() const
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
VarDecl * getConditionVariable()
Retrieve the variable declared in this "if" statement, if any.
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)
ArrayRef< TemplateArgument > getTemplateArguments() const
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 field injected from an anonymous union/struct into the parent scope.
unsigned getChainingSize() const
ArrayRef< NamedDecl * > chain() const
IndirectGotoStmt - This represents an indirect goto.
SourceLocation getGotoLoc() const
SourceLocation getStarLoc() const
Description of a constructor that was inherited from a base class.
CXXConstructorDecl * getConstructor() const
ConstructorUsingShadowDecl * getShadowDecl() const
Describes an C or C++ initializer list.
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
void setSyntacticForm(InitListExpr *Init)
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
unsigned getNumInits() const
SourceLocation getLBraceLoc() const
void setArrayFiller(Expr *filler)
InitListExpr * getSyntacticForm() const
bool hadArrayRangeDesignator() const
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
SourceLocation getRBraceLoc() const
void setInitializedFieldInUnion(FieldDecl *FD)
ArrayRef< Expr * > inits() const
void sawArrayRangeDesignator(bool ARD=true)
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.
Represents the declaration of a label.
LabelStmt * getStmt() const
void setStmt(LabelStmt *T)
LabelStmt - Represents a label, which has a substatement.
LabelDecl * getDecl() const
SourceLocation getIdentLoc() const
Describes the capture of a variable or of this, or of a C++1y init-capture.
bool capturesVariable() const
Determine whether this capture handles a variable.
bool isPackExpansion() const
Determine whether this capture is a pack expansion, which captures a function parameter pack.
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis for a capture that is a pack expansion.
LambdaCaptureKind getCaptureKind() const
Determine the kind of capture.
ValueDecl * getCapturedVar() const
Retrieve the declaration of the local variable being captured.
bool isImplicit() const
Determine whether this was an implicit capture (not written between the square brackets introducing t...
SourceLocation getLocation() const
Retrieve the source location of the capture.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
static LambdaExpr * Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc, bool ExplicitParams, bool ExplicitResultType, ArrayRef< Expr * > CaptureInits, SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack)
Construct a new lambda expression.
SourceLocation getEndLoc() const LLVM_READONLY
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
SourceRange getIntroducerRange() const
Retrieve the source range covering the lambda introducer, which contains the explicit capture list su...
unsigned capture_size() const
Determine the number of captures in this lambda.
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
SourceLocation getCaptureDefaultLoc() const
Retrieve the location of this lambda's capture-default, if any.
llvm::iterator_range< capture_init_iterator > capture_inits()
Retrieve the initialization expressions for this lambda's captures.
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Implicit declaration of a temporary that was materialized by a MaterializeTemporaryExpr and lifetime-...
unsigned getManglingNumber() const
Expr * getTemporaryExpr()
Retrieve the expression to which the temporary materialization conversion was applied.
ValueDecl * getExtendingDecl()
Represents a linkage specification.
void setRBraceLoc(SourceLocation L)
LinkageSpecLanguageIDs getLanguage() const
Return the language specified by this linkage specification.
SourceLocation getExternLoc() const
SourceLocation getRBraceLoc() const
bool hasBraces() const
Determines whether this linkage specification had braces in its syntactic form.
Represents the results of name lookup.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
bool isBoundToLvalueReference() const
Determine whether this materialized temporary is bound to an lvalue reference; otherwise,...
LifetimeExtendedTemporaryDecl * getLifetimeExtendedTemporaryDecl()
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ArrayRef< TemplateArgumentLoc > template_arguments() const
SourceLocation getOperatorLoc() const
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
NestedNameSpecifierLoc getQualifierLoc() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name,...
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
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.
Provides information a specialization of a member of a class template, which may be a member function...
SourceLocation getPointOfInstantiation() const
Retrieve the first point of instantiation of this member.
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
This represents a decl that may have a name.
Linkage getLinkageInternal() const
Determine what kind of linkage this entity has.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Represents a C++ namespace alias.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
SourceLocation getAliasLoc() const
Returns the location of the alias name, i.e.
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Represent a C++ namespace.
SourceLocation getRBraceLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isInline() const
Returns true if this is an inline namespace declaration.
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace that inhabits this namespace, if any.
bool isNested() const
Returns true if this is a nested namespace declaration.
void setRBraceLoc(SourceLocation L)
Class that aids in the construction of nested-name-specifiers along with source-location information ...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
A C++ nested-name-specifier augmented with source location information.
NamespaceAndPrefixLoc getAsNamespaceAndPrefix() const
NestedNameSpecifier getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end 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.
TypeLoc castAsTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
CXXRecordDecl * getAsMicrosoftSuper() const
NamespaceAndPrefix getAsNamespaceAndPrefix() const
const Type * getAsType() const
Kind
The kind of specifier that completes this nested name specifier.
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
unsigned getDepth() const
Get the nesting depth of the template parameter.
NullStmt - This is the null statement ";": C99 6.8.3p3.
bool hasLeadingEmptyMacro() const
SourceLocation getSemiLoc() const
Represents Objective-C's @catch statement.
const VarDecl * getCatchParamDecl() const
const Stmt * getCatchBody() const
SourceLocation getAtCatchLoc() const
SourceLocation getRParenLoc() const
Represents Objective-C's @finally statement.
const Stmt * getFinallyBody() const
SourceLocation getAtFinallyLoc() const
Represents Objective-C's @synchronized statement.
const Expr * getSynchExpr() const
const CompoundStmt * getSynchBody() const
SourceLocation getAtSynchronizedLoc() const
Represents Objective-C's @throw statement.
const Expr * getThrowExpr() const
SourceLocation getThrowLoc() const LLVM_READONLY
Represents Objective-C's @try ... @catch ... @finally statement.
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
static ObjCAtTryStmt * Create(const ASTContext &Context, SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt)
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
const Stmt * getTryBody() const
Retrieve the @try body.
SourceLocation getAtTryLoc() const
Retrieve the location of the @ in the @try.
Represents Objective-C's @autoreleasepool Statement.
SourceLocation getAtLoc() const
const Stmt * getSubStmt() const
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers,...
ObjCCategoryDecl - Represents a category declaration.
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this category.
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
ObjCCategoryImplDecl * getImplementation() const
ObjCInterfaceDecl * getClassInterface()
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
protocol_iterator protocol_end() const
ObjCProtocolList::loc_iterator protocol_loc_iterator
SourceLocation getIvarLBraceLoc() const
SourceLocation getIvarRBraceLoc() const
protocol_loc_iterator protocol_loc_begin() const
protocol_iterator protocol_begin() const
void setImplementation(ObjCCategoryImplDecl *ImplD)
ObjCProtocolList::iterator protocol_iterator
SourceLocation getCategoryNameLoc() const
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
SourceLocation getCategoryNameLoc() const
ObjCCategoryDecl * getCategoryDecl() const
SourceLocation getAtStartLoc() const
Represents Objective-C's collection statement.
SourceLocation getForLoc() const
SourceLocation getRParenLoc() const
const ObjCInterfaceDecl * getClassInterface() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
SourceLocation getIvarRBraceLoc() const
SourceLocation getSuperClassLoc() const
const ObjCInterfaceDecl * getSuperClass() const
SourceLocation getIvarLBraceLoc() const
Represents an ObjC class declaration.
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
bool isImplicitInterfaceDecl() const
isImplicitInterfaceDecl - check that this is an implicitly declared ObjCInterfaceDecl node.
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class.
ObjCCategoryDecl * FindCategoryDeclaration(const IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
protocol_loc_iterator protocol_loc_begin() const
void setImplementation(ObjCImplementationDecl *ImplD)
known_categories_range known_categories() const
void setSuperClass(TypeSourceInfo *superClass)
protocol_iterator protocol_end() const
SourceLocation getSuperClassLoc() const
Retrieve the starting location of the superclass.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this class.
ObjCProtocolList::iterator protocol_iterator
ObjCImplementationDecl * getImplementation() const
protocol_iterator protocol_begin() const
ObjCProtocolList::loc_iterator protocol_loc_iterator
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
ObjCInterfaceDecl * getSuperClass() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
TypeSourceInfo * getSuperClassTInfo() const
ObjCIvarDecl - Represents an ObjC instance variable.
AccessControl getAccessControl() const
bool getSynthesize() const
ObjCMethodDecl - Represents an instance or class method declaration.
ImplicitParamDecl * getSelfDecl() const
ArrayRef< ParmVarDecl * > parameters() const
unsigned param_size() const
bool isPropertyAccessor() const
param_const_iterator param_end() const
param_const_iterator param_begin() const
SourceLocation getEndLoc() const LLVM_READONLY
TypeSourceInfo * getReturnTypeSourceInfo() const
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs={})
Sets the method's parameters and selector source locations.
bool isSynthesizedAccessorStub() const
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type.
bool isInstanceMethod() const
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implicit parameters.
QualType getReturnType() const
ParmVarDecl *const * param_iterator
ObjCImplementationControl getImplementationControl() const
ObjCInterfaceDecl * getClassInterface()
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
Represents one property declaration in an Objective-C interface.
void setSetterName(Selector Sel, SourceLocation Loc=SourceLocation())
SourceLocation getGetterNameLoc() const
ObjCMethodDecl * getGetterMethodDecl() const
bool isInstanceProperty() const
ObjCMethodDecl * getSetterMethodDecl() const
SourceLocation getSetterNameLoc() const
SourceLocation getAtLoc() const
void setPropertyAttributes(ObjCPropertyAttribute::Kind PRVal)
ObjCIvarDecl * getPropertyIvarDecl() const
Selector getSetterName() const
TypeSourceInfo * getTypeSourceInfo() const
void setPropertyAttributesAsWritten(ObjCPropertyAttribute::Kind PRVal)
Selector getGetterName() const
void setPropertyIvarDecl(ObjCIvarDecl *Ivar)
SourceLocation getLParenLoc() const
void setSetterMethodDecl(ObjCMethodDecl *gDecl)
ObjCPropertyAttribute::Kind getPropertyAttributesAsWritten() const
ObjCPropertyAttribute::Kind getPropertyAttributes() const
void setGetterName(Selector Sel, SourceLocation Loc=SourceLocation())
PropertyControl getPropertyImplementation() const
void setGetterMethodDecl(ObjCMethodDecl *gDecl)
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
ObjCIvarDecl * getPropertyIvarDecl() const
SourceLocation getPropertyIvarDeclLoc() const
Kind getPropertyImplementation() const
ObjCPropertyDecl * getPropertyDecl() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents an Objective-C protocol declaration.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
void startDefinition()
Starts the definition of this Objective-C protocol.
ObjCProtocolList::iterator protocol_iterator
protocol_iterator protocol_begin() const
ObjCProtocolList::loc_iterator protocol_loc_iterator
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.
const Type * getTypeForDecl() const
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
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
Expr * getIndexExpr(unsigned Idx)
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
const OffsetOfNode & getComponent(unsigned Idx) const
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr * > exprs, SourceLocation RParenLoc)
TypeSourceInfo * getTypeSourceInfo() const
unsigned getNumExpressions() const
SourceLocation getRParenLoc() const
Return the location of the right parentheses.
unsigned getNumComponents() const
Helper class for OffsetOfExpr.
const IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
FieldDecl * getField() const
For a field offsetof node, returns the field.
@ Array
An index into an array.
@ Identifier
A field in a dependent type, known only by its name.
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
SourceLocation getBeginLoc() const LLVM_READONLY
Kind getKind() const
Determine what kind of offsetof node this is.
SourceLocation getEndLoc() const LLVM_READONLY
CXXBaseSpecifier * getBase() const
For a base class node, returns the base specifier.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
SourceLocation getLocation() const
Retrieve the location of this expression.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
SourceLocation getNameLoc() const
Gets the location of the name.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
llvm::iterator_range< decls_iterator > decls() const
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
DeclarationName getName() const
Gets the name looked up.
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
ArrayRef< TemplateArgumentLoc > template_arguments() const
A structure for storing the information associated with an overloaded template name.
Represents a C++11 pack expansion that produces a sequence of expressions.
Expr * getPattern()
Retrieve the pattern of the pack expansion.
UnsignedOrNone 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.
ParenExpr - This represents a parenthesized expression, e.g.
SourceLocation getLParen() const
Get the location of the left parentheses '('.
const Expr * getSubExpr() const
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
ArrayRef< Expr * > exprs() const
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
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)
[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.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
unsigned getResultExprIndex() const
Return the index of the result-bearing expression into the semantics expressions, or PseudoObjectExpr...
static PseudoObjectExpr * Create(const ASTContext &Context, Expr *syntactic, ArrayRef< Expr * > semantic, unsigned resultIndex)
ArrayRef< Expr * > semantics()
unsigned getNumSemanticExprs() const
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
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.
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Represents a template name as written in source code.
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.
Represents a struct/union/class.
bool isLambda() const
Determine whether this record is a class describing a lambda function object.
void setAnonymousStructOrUnion(bool Anon)
field_range fields() const
RecordDecl * getMostRecentDecl()
virtual void completeDefinition()
Note that the definition of this type is now complete.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Provides common interface for the Decls that can be redeclared.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Represents the body of a requires-expression.
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
SourceLocation getRBraceLoc() const
SourceLocation getRequiresKWLoc() const
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
RequiresExprBodyDecl * getBody() const
ArrayRef< concepts::Requirement * > getRequirements() const
ArrayRef< ParmVarDecl * > getLocalParameters() const
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
SourceLocation getReturnLoc() const
const VarDecl * getNRVOCandidate() const
Retrieve the variable that might be used for the named return value optimization.
static ReturnStmt * Create(const ASTContext &Ctx, SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)
Create a return statement.
Smart pointer class that efficiently represents Objective-C method names.
const IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
bool isNull() const
Determine whether this is the empty selector.
unsigned getNumArgs() const
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Expr ** getSubExprs()
Retrieve the array of expressions.
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
SourceLocation getRParenLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents an expression that computes the length of a parameter pack.
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof... expression, such as is produced f...
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
NamedDecl * getPack() const
Retrieve the parameter pack.
unsigned getPackLength() const
Retrieve the length of the parameter pack.
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
SourceLocation getBeginLoc() const
const DeclContext * getParentContext() const
If the SourceLocExpr has been resolved return the subexpression representing the resolved value.
SourceLocation getEndLoc() const
SourceLocIdentKind getIdentKind() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
FileIDAndOffset getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
bool isWrittenInBuiltinFile(SourceLocation Loc) const
Returns whether Loc is located in a <built-in> file.
FileID createFileID(FileEntryRef SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0)
Create a new FileID that represents the specified file being #included from the specified IncludePosi...
SourceLocation getComposedLoc(FileID FID, unsigned Offset) const
Form a SourceLocation from a FileID and Offset pair.
FileManager & getFileManager() const
FileID getMainFileID() const
Returns the FileID of the main source file.
unsigned getFileIDSize(FileID FID) const
The size of the SLocEntry that FID represents.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
SourceLocation createExpansionLoc(SourceLocation SpellingLoc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned Length, bool ExpansionIsTokenRange=true, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0)
Creates an expansion SLocEntry for a macro use.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
SourceLocation createMacroArgExpansionLoc(SourceLocation SpellingLoc, SourceLocation ExpansionLoc, unsigned Length)
Creates an expansion SLocEntry for the substitution of an argument into a function-like macro's body.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
One instance of this struct is kept for every file loaded or used.
Each ExpansionInfo encodes the expansion location - where the token was ultimately expanded,...
SourceLocation getExpansionLocStart() const
bool isExpansionTokenRange() const
SourceLocation getSpellingLoc() const
bool isMacroArgExpansion() const
SourceLocation getExpansionLocEnd() const
const ContentCache & getContentCache() const
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
SourceLocation getIncludeLoc() const
This is a discriminated union of FileInfo and ExpansionInfo.
const FileInfo & getFile() const
const ExpansionInfo & getExpansion() const
Represents a C++11 static_assert declaration.
SourceLocation getRParenLoc() const
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
CompoundStmt * getSubStmt()
unsigned getTemplateDepth() const
SourceLocation getRParenLoc() const
SourceLocation getLParenLoc() const
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Stmt - This represents one statement.
child_iterator child_begin()
StmtClass getStmtClass() const
child_iterator child_end()
const char * getStmtClassName() const
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
tokloc_iterator tokloc_begin() const
tokloc_iterator tokloc_end() const
StringLiteralKind getKind() const
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind, bool Pascal, QualType Ty, ArrayRef< SourceLocation > Locs)
This is the "fully general" constructor that allows representation of strings formed from one or more...
StringRef getBytes() const
Allow access to clients that need the byte representation, such as ASTWriterStmt::VisitStringLiteral(...
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...
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
UnsignedOrNone getPackIndex() const
QualType getParameterType() const
Determine the substituted type of the template parameter.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
SourceLocation getNameLoc() const
Expr * getReplacement() const
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
SourceLocation getParameterPackLocation() const
Retrieve the location of the parameter pack name.
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.
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
UnsignedOrNone getPackIndex() const
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
void setNextSwitchCase(SwitchCase *SC)
SourceLocation getColonLoc() const
const SwitchCase * getNextSwitchCase() const
SwitchStmt - This represents a 'switch' stmt.
SourceLocation getSwitchLoc() const
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
static SwitchStmt * Create(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a switch statement.
VarDecl * getConditionVariable()
Retrieve the variable declared in this "switch" statement, if any.
SwitchCase * getSwitchCaseList()
Represents the declaration of a struct/union/class/enum.
SourceRange getBraceRange() const
bool isBeingDefined() const
Return true if this decl is currently being defined.
TagDecl * getDefinition() const
Returns the TagDecl that actually defines this struct/union/class/enum.
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
TypedefNameDecl * getTypedefNameForAnonDecl() const
void startDefinition()
Starts the definition of this tag declaration.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
TagKind getTagKind() const
void setBraceRange(SourceRange R)
void setCompleteDefinition(bool V=true)
True if this decl has its body fully specified.
A convenient class for passing around template argument information.
SourceLocation getRAngleLoc() const
void addArgument(const TemplateArgumentLoc &Loc)
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
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
QualType getParamTypeForDecl() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
UnsignedOrNone getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce,...
QualType getAsType() const
Retrieve the type for a type template argument.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
QualType getIntegralType() const
Retrieve the type of the integral value.
bool getIsDefaulted() const
If returns 'true', this TemplateArgument corresponds to a default template parameter.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isCanonicalExpr() const
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ OverloadedTemplate
A set of overloaded template declarations.
@ Template
A single template declaration.
@ DependentTemplate
A dependent template name that has not been resolved to a template (or set of templates).
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
@ DeducedTemplate
A template name that refers to another TemplateName with deduced default arguments.
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
@ AssumedTemplate
An unqualified-id that has been assumed to name a function template that will be found by ADL.
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
A template parameter object.
const APValue & getValue() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
SourceLocation getTemplateLoc() const
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
bool wasDeclaredWithTypename() const
Whether this template template parameter was declared with the 'typename' keyword.
TemplateNameKind templateParameterKind() const
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
unsigned getDepth() const
Get the nesting depth of the template parameter.
Declaration of a template type parameter.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
unsigned getIndex() const
Retrieve the index of the template parameter.
void setTypeConstraint(ConceptReference *CR, Expr *ImmediatelyDeclaredConstraint, UnsignedOrNone ArgPackSubstIndex)
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
bool isParameterPack() const
Returns whether this is a parameter pack.
unsigned getDepth() const
Retrieve the depth of the template parameter.
The top declaration context.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Declaration of an alias template.
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...
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.
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.
bool getBoolValue() const
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
static TypeTraitExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, TypeTrait Kind, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc, bool Value)
Create a new type trait expression.
SourceLocation getEndLoc() const LLVM_READONLY
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
TypeTrait getTrait() const
Determine which type trait this expression uses.
SourceLocation getBeginLoc() const LLVM_READONLY
const APValue & getAPValue() const
bool isStoredAsBoolean() const
ExpectedType Visit(const Type *T)
The base class of the type hierarchy.
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
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
Represents the declaration of a typedef-name via the 'typedef' type specifier.
Base class for declarations which introduce a typedef-name.
TypeSourceInfo * getTypeSourceInfo() const
QualType getUnderlyingType() const
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
SourceLocation getRParenLoc() const
SourceLocation getOperatorLoc() const
bool isArgumentType() const
TypeSourceInfo * getArgumentTypeInfo() const
UnaryExprOrTypeTrait getKind() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Expr * getSubExpr() const
bool hasStoredFPFeatures() const
Is FPFeatures in Trailing Storage?
FPOptionsOverride getStoredFPFeatures() const
Get FPFeatures from trailing storage.
static UnaryOperator * CreateEmpty(const ASTContext &C, bool hasFPFeatures)
bool canOverflow() const
Returns true if the unary operator can cause an overflow.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Represents a C++ member access expression for which lookup produced a set of overloaded functions.
bool isArrow() const
Determine whether this member expression used the '->' operator; otherwise, it used the '.
SourceLocation getOperatorLoc() const
Retrieve the location of the '->' or '.' operator.
bool hasUnresolvedUsing() const
Determine whether the lookup results contain an unresolved using declaration.
Expr * getBase()
Retrieve the base object of this member expressions, e.g., the x in x.m.
static UnresolvedMemberExpr * Create(const ASTContext &Context, bool HasUnresolvedUsing, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
bool isImplicitAccess() const
True if this is an implicit access, i.e., one in which the member being accessed was not written in t...
void addDecl(NamedDecl *D)
A set of unresolved declarations.
Represents a dependent using declaration which was marked with typename.
SourceLocation getTypenameLoc() const
Returns the source location of the 'typename' keyword.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Represents a dependent using declaration which was not marked with typename.
SourceLocation getUsingLoc() const
Returns the source location of the 'using' keyword.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
DeclarationNameInfo getNameInfo() const
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Represents a C++ using-declaration.
bool hasTypename() const
Return true if the using declaration has 'typename'.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
DeclarationNameInfo getNameInfo() const
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Represents C++ using-directive.
SourceLocation getUsingLoc() const
Return the location of the using keyword.
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
SourceLocation getIdentLocation() const
Returns the location of this using declaration's identifier.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Represents a C++ using-enum-declaration.
SourceLocation getEnumLoc() const
The source location of the 'enum' keyword.
TypeSourceInfo * getEnumType() const
SourceLocation getUsingLoc() const
The source location of the 'using' keyword.
Represents a pack of using declarations that a single using-declarator pack-expanded into.
NamedDecl * getInstantiatedFromUsingDecl() const
Get the using declaration from which this was instantiated.
ArrayRef< NamedDecl * > expansions() const
Get the set of using declarations that this pack expanded into.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
Represents a call to the builtin function __builtin_va_arg.
TypeSourceInfo * getWrittenTypeInfo() const
SourceLocation getBuiltinLoc() const
SourceLocation getRParenLoc() const
VarArgKind getVarargABI() 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.
VarDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
bool isInlineSpecified() const
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
EvaluatedStmt * getEvaluatedStmt() const
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form,...
void setInlineSpecified()
VarDecl * getInstantiatedFromStaticDataMember() const
If this variable is an instantiated static data member of a class template specialization,...
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
void setTSCSpec(ThreadStorageClassSpecifier TSC)
bool isInline() const
Whether this variable is (C++1z) inline.
ThreadStorageClassSpecifier getTSCSpec() const
const Expr * getInit() const
void setConstexpr(bool IC)
void setDescribedVarTemplate(VarTemplateDecl *Template)
StorageClass getStorageClass() const
Returns the storage class as written in the source.
void setImplicitlyInline()
VarDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this variable is an instantiation of a static data member of a class template specialization,...
Declaration of a variable template.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary variable pattern.
VarTemplateDecl * getMostRecentDecl()
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
void setSpecializationKind(TemplateSpecializationKind TSK)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
void setPointOfInstantiation(SourceLocation Loc)
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
VarTemplateSpecializationDecl * getMostRecentDecl()
WhileStmt - This represents a 'while' stmt.
SourceLocation getWhileLoc() const
SourceLocation getRParenLoc() const
VarDecl * getConditionVariable()
Retrieve the variable declared in this "while" statement, if any.
SourceLocation getLParenLoc() const
static WhileStmt * Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body, SourceLocation WL, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a while statement.
A requires-expression requirement which queries the validity and properties of an expression ('simple...
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
ConceptSpecializationExpr * getReturnTypeRequirementSubstitutedConstraintExpr() const
const ReturnTypeRequirement & getReturnTypeRequirement() const
SatisfactionStatus getSatisfactionStatus() const
SourceLocation getNoexceptLoc() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
bool hasInvalidConstraint() const
Expr * getConstraintExpr() const
StringRef getInvalidConstraintEntity()
A static requirement that can be used in a requires-expression to check properties of types and expre...
RequirementKind getKind() const
A requires-expression requirement which queries the existence of a type name or type template special...
bool isSubstitutionFailure() const
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
TypeSourceInfo * getType() const
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isa(CodeGen::Address addr)
llvm::Expected< SourceLocation > ExpectedSLoc
StructuralEquivalenceKind
Whether to perform a normal or minimal equivalence check.
llvm::Expected< const Type * > ExpectedTypePtr
CanThrowResult
Possible results from evaluation of a noexcept expression.
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
std::pair< FileID, unsigned > FileIDAndOffset
llvm::Expected< DeclarationName > ExpectedName
llvm::Expected< Decl * > ExpectedDecl
@ Property
The type of a property.
@ Result
The result type of a method or function.
OptionalUnsigned< unsigned > UnsignedOrNone
const FunctionProtoType * T
llvm::Expected< QualType > ExpectedType
@ Template
We are parsing a template declaration.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
@ VarTemplate
The name was classified as a variable template name.
std::pair< SourceLocation, StringRef > ConstraintSubstitutionDiagnostic
Unsatisfied constraint expressions if the template arguments could be substituted into them,...
CastKind
CastKind - The kind of operation required for a conversion.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
llvm::SmallVector< Decl *, 2 > getCanonicalForwardRedeclChain(Decl *D)
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
llvm::Expected< Expr * > ExpectedExpr
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...
U cast(CodeGen::Address addr)
bool isLambdaMethod(const DeclContext *DC)
llvm::Expected< Stmt * > ExpectedStmt
static void updateFlags(const Decl *From, Decl *To)
__packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 __packed_splat2 __packed_splat4 __packed_splat2 __packed_splat8 __packed_splat4 uint32_t
Used as return type of getFriendCountAndPosition.
unsigned int IndexOfDecl
Index of the specific FriendDecl.
unsigned int TotalCount
Number of similar looking friends.
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
const UnsatisfiedConstraintRecord * end() const
static ASTConstraintSatisfaction * Rebuild(const ASTContext &C, const ASTConstraintSatisfaction &Satisfaction)
const UnsatisfiedConstraintRecord * begin() const
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)
const Expr * ConstraintExpr
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
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),...
unsigned HasConstantInitialization
Whether this variable is known to have constant initialization.
unsigned HasConstantDestruction
Whether this variable is known to have constant destruction.
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
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
NestedNameSpecifierLoc Prefix
const NamespaceBaseDecl * Namespace
bool IsEquivalent(Decl *D1, Decl *D2)
Determine whether the two declarations are structurally equivalent.
Location information for a TemplateArgument.
SourceLocation getTemplateEllipsisLoc() const
SourceLocation getTemplateKwLoc() const
TypeSourceInfo * getAsTypeSourceInfo() const
SourceLocation getTemplateNameLoc() const
StringRef SubstitutedEntity