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);
191 template <
typename ImportT>
192 [[nodiscard]]
Error importInto(ImportT *&To, ImportT *From) {
193 auto ToOrErr = Importer.Import(From);
195 To = cast_or_null<ImportT>(*ToOrErr);
196 return ToOrErr.takeError();
201 template <
typename T>
205 auto ToOrErr = Importer.Import(From);
207 return ToOrErr.takeError();
208 return cast_or_null<T>(*ToOrErr);
211 template <
typename T>
212 auto import(
const T *From) {
213 return import(
const_cast<T *
>(From));
217 template <
typename T>
219 return Importer.Import(From);
223 template <
typename T>
227 return import(*From);
234 template <
typename ToDeclT>
struct CallOverloadedCreateFun {
235 template <
typename... Args>
decltype(
auto)
operator()(Args &&... args) {
236 return ToDeclT::Create(std::forward<Args>(args)...);
246 template <
typename ToDeclT,
typename FromDeclT,
typename... Args>
247 [[nodiscard]]
bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
252 CallOverloadedCreateFun<ToDeclT> OC;
253 return GetImportedOrCreateSpecialDecl(ToD, OC, FromD,
254 std::forward<Args>(args)...);
261 template <
typename NewDeclT,
typename ToDeclT,
typename FromDeclT,
263 [[nodiscard]]
bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
265 CallOverloadedCreateFun<NewDeclT> OC;
266 return GetImportedOrCreateSpecialDecl(ToD, OC, FromD,
267 std::forward<Args>(args)...);
271 template <
typename ToDeclT,
typename CreateFunT,
typename FromDeclT,
274 GetImportedOrCreateSpecialDecl(ToDeclT *&ToD, CreateFunT CreateFun,
275 FromDeclT *FromD, Args &&...args) {
276 if (Importer.getImportDeclErrorIfAny(FromD)) {
280 ToD = cast_or_null<ToDeclT>(Importer.GetAlreadyImportedOrNull(FromD));
283 ToD = CreateFun(std::forward<Args>(args)...);
285 Importer.RegisterImportedDecl(FromD, ToD);
286 Importer.SharedState->markAsNewDecl(ToD);
287 InitializeImportedDecl(FromD, ToD);
291 void InitializeImportedDecl(
Decl *FromD,
Decl *ToD) {
295 if (FromD->isImplicit())
303 if (D->doesThisDeclarationHaveABody() &&
309 void addDeclToContexts(
Decl *FromD,
Decl *ToD) {
310 if (Importer.isMinimalImport()) {
314 if (!FromD->getDescribedTemplate() &&
321 DeclContext *FromLexicalDC = FromD->getLexicalDeclContext();
325 bool Visible =
false;
338 if (
auto *FromNamed = dyn_cast<NamedDecl>(FromD)) {
341 FromDC->
lookup(FromNamed->getDeclName());
342 if (llvm::is_contained(FromLookup, FromNamed))
355 LT->update(TP, OldDC);
359 updateLookupTableForTemplateParameters(
360 Params, Importer.getToContext().getTranslationUnitDecl());
363 template <
typename TemplateParmDeclT>
364 Error importTemplateParameterDefaultArgument(
const TemplateParmDeclT *D,
365 TemplateParmDeclT *ToD) {
366 if (D->hasDefaultArgument()) {
367 if (D->defaultArgumentWasInherited()) {
369 import(D->getDefaultArgStorage().getInheritedFrom());
370 if (!ToInheritedFromOrErr)
371 return ToInheritedFromOrErr.takeError();
372 TemplateParmDeclT *ToInheritedFrom = *ToInheritedFromOrErr;
373 if (!ToInheritedFrom->hasDefaultArgument()) {
377 import(D->getDefaultArgStorage()
379 ->getDefaultArgument());
380 if (!ToInheritedDefaultArgOrErr)
381 return ToInheritedDefaultArgOrErr.takeError();
382 ToInheritedFrom->setDefaultArgument(Importer.getToContext(),
383 *ToInheritedDefaultArgOrErr);
385 ToD->setInheritedDefaultArgument(ToD->getASTContext(),
389 import(D->getDefaultArgument());
390 if (!ToDefaultArgOrErr)
391 return ToDefaultArgOrErr.takeError();
394 if (!ToD->hasDefaultArgument())
395 ToD->setDefaultArgument(Importer.getToContext(),
399 return Error::success();
411#define TYPE(Class, Base) \
412 ExpectedType Visit##Class##Type(const Class##Type *T);
413#include "clang/AST/TypeNodes.inc"
450 (IDK ==
IDK_Default && !Importer.isMinimalImport());
471 template <
typename InContainerTy>
475 template<
typename InContainerTy>
482 std::tuple<FunctionTemplateDecl *, TemplateArgsTy>;
487 template <
typename DeclTy>
511 template <
typename T>
515 bool IgnoreTemplateParmDepth =
false);
726 Err = MaybeVal.takeError();
732 template<
typename IIter,
typename OIter>
734 using ItemT = std::remove_reference_t<
decltype(*Obegin)>;
735 for (; Ibegin != Iend; ++Ibegin, ++Obegin) {
738 return ToOrErr.takeError();
741 return Error::success();
748 template<
typename InContainerTy,
typename OutContainerTy>
750 const InContainerTy &InContainer, OutContainerTy &OutContainer) {
752 InContainer.begin(), InContainer.end(), OutContainer.begin());
755 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());
1083 if (
const Expr *E = dyn_cast<const Expr *>(*
Record)) {
1086 return ToSecondExpr.takeError();
1087 ToSat.
Details.emplace_back(ToSecondExpr.get());
1088 }
else if (
auto CR = dyn_cast<const ConceptReference *>(*
Record)) {
1091 return ToCROrErr.takeError();
1092 ToSat.
Details.emplace_back(ToCROrErr.get());
1094 auto Pair = dyn_cast<const ConstraintSubstitutionDiagnostic *>(*
Record);
1098 return ToPairFirst.takeError();
1100 ToSat.
Details.emplace_back(
new (Importer.getToContext())
1102 ToPairFirst.get(), ToPairSecond});
1106 return Error::success();
1111ASTNodeImporter::import(
1116 return ToLoc.takeError();
1118 return new (Importer.getToContext())
1130 return DiagOrErr.takeError();
1131 return new (Importer.getToContext()) TypeRequirement(*DiagOrErr);
1135 return ToType.takeError();
1136 return new (Importer.getToContext()) TypeRequirement(*ToType);
1144 bool IsRKSimple = From->
getKind() == Requirement::RK_Simple;
1147 std::optional<ExprRequirement::ReturnTypeRequirement> Req;
1153 const ExprRequirement::ReturnTypeRequirement &FromTypeRequirement =
1156 if (FromTypeRequirement.isTypeConstraint()) {
1157 const bool IsDependent = FromTypeRequirement.isDependent();
1159 import(FromTypeRequirement.getTypeConstraintTemplateParameterList());
1161 return ParamsOrErr.takeError();
1162 if (Status >= ExprRequirement::SS_ConstraintsNotSatisfied) {
1163 auto SubstConstraintExprOrErr =
1165 if (!SubstConstraintExprOrErr)
1166 return SubstConstraintExprOrErr.takeError();
1167 SubstitutedConstraintExpr = SubstConstraintExprOrErr.get();
1169 Req.emplace(ParamsOrErr.get(), IsDependent);
1170 }
else if (FromTypeRequirement.isSubstitutionFailure()) {
1171 auto DiagOrErr =
import(FromTypeRequirement.getSubstitutionDiagnostic());
1173 return DiagOrErr.takeError();
1174 Req.emplace(DiagOrErr.get());
1181 if (!NoexceptLocOrErr)
1182 return NoexceptLocOrErr.takeError();
1184 if (Status == ExprRequirement::SS_ExprSubstitutionFailure) {
1187 return DiagOrErr.takeError();
1188 return new (Importer.getToContext()) ExprRequirement(
1189 *DiagOrErr, IsRKSimple, *NoexceptLocOrErr, std::move(*Req));
1193 return ExprOrErr.takeError();
1195 *ExprOrErr, IsRKSimple, *NoexceptLocOrErr, std::move(*Req), Status,
1196 SubstitutedConstraintExpr);
1211 return new (Importer.getToContext())
1212 NestedRequirement(ToEntity, ToSatisfaction);
1216 return ToExpr.takeError();
1217 if (ToExpr.get()->isInstantiationDependent()) {
1218 return new (Importer.getToContext()) NestedRequirement(ToExpr.get());
1223 return std::move(Err);
1224 return new (Importer.getToContext()) NestedRequirement(
1225 Importer.getToContext(), ToExpr.get(), Satisfaction);
1233 switch (FromRequire->
getKind()) {
1243 llvm_unreachable(
"Unhandled requirement kind");
1253 return VarOrErr.takeError();
1258 return LocationOrErr.takeError();
1263 return std::move(Err);
1270template <
typename T>
1272 if (
Found->getLinkageInternal() != From->getLinkageInternal())
1275 if (From->hasExternalFormalLinkage())
1276 return Found->hasExternalFormalLinkage();
1277 if (Importer.GetFromTU(
Found) != From->getTranslationUnitDecl())
1279 if (From->isInAnonymousNamespace())
1280 return Found->isInAnonymousNamespace();
1282 return !
Found->isInAnonymousNamespace() &&
1283 !
Found->hasExternalFormalLinkage();
1303using namespace clang;
1309 FunctionDeclsWithImportInProgress.insert(D);
1312 return llvm::scope_exit([
this, LambdaD]() {
1314 FunctionDeclsWithImportInProgress.erase(LambdaD);
1321 return FunctionDeclsWithImportInProgress.find(D) !=
1322 FunctionDeclsWithImportInProgress.end();
1326 Importer.FromDiag(
SourceLocation(), diag::err_unsupported_ast_node)
1327 <<
T->getTypeClassName();
1332 ExpectedType UnderlyingTypeOrErr =
import(
T->getValueType());
1333 if (!UnderlyingTypeOrErr)
1334 return UnderlyingTypeOrErr.takeError();
1336 return Importer.getToContext().getAtomicType(*UnderlyingTypeOrErr);
1340 switch (
T->getKind()) {
1341#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1342 case BuiltinType::Id: \
1343 return Importer.getToContext().SingletonId;
1344#include "clang/Basic/OpenCLImageTypes.def"
1345#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1346 case BuiltinType::Id: \
1347 return Importer.getToContext().Id##Ty;
1348#include "clang/Basic/OpenCLExtensionTypes.def"
1349#define SVE_TYPE(Name, Id, SingletonId) \
1350 case BuiltinType::Id: \
1351 return Importer.getToContext().SingletonId;
1352#include "clang/Basic/AArch64ACLETypes.def"
1353#define PPC_VECTOR_TYPE(Name, Id, Size) \
1354 case BuiltinType::Id: \
1355 return Importer.getToContext().Id##Ty;
1356#include "clang/Basic/PPCTypes.def"
1357#define RVV_TYPE(Name, Id, SingletonId) \
1358 case BuiltinType::Id: \
1359 return Importer.getToContext().SingletonId;
1360#include "clang/Basic/RISCVVTypes.def"
1361#define WASM_TYPE(Name, Id, SingletonId) \
1362 case BuiltinType::Id: \
1363 return Importer.getToContext().SingletonId;
1364#include "clang/Basic/WebAssemblyReferenceTypes.def"
1365#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1366 case BuiltinType::Id: \
1367 return Importer.getToContext().SingletonId;
1368#include "clang/Basic/AMDGPUTypes.def"
1369#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1370 case BuiltinType::Id: \
1371 return Importer.getToContext().SingletonId;
1372#include "clang/Basic/HLSLIntangibleTypes.def"
1373#define HLSL_PACKED_TYPE(Name, Id, SingletonId) \
1374 case BuiltinType::Id: \
1375 return Importer.getToContext().SingletonId;
1376#include "clang/Basic/HLSLPackedTypes.def"
1377#define SPIRV_TYPE(Name, Id, SingletonId) \
1378 case BuiltinType::Id: \
1379 return Importer.getToContext().SingletonId;
1380#include "clang/Basic/SPIRVTypes.def"
1381#define SHARED_SINGLETON_TYPE(Expansion)
1382#define BUILTIN_TYPE(Id, SingletonId) \
1383 case BuiltinType::Id: return Importer.getToContext().SingletonId;
1384#include "clang/AST/BuiltinTypes.def"
1392 case BuiltinType::Char_U:
1396 if (Importer.getToContext().getLangOpts().CharIsSigned)
1397 return Importer.getToContext().UnsignedCharTy;
1399 return Importer.getToContext().CharTy;
1401 case BuiltinType::Char_S:
1405 if (!Importer.getToContext().getLangOpts().CharIsSigned)
1406 return Importer.getToContext().SignedCharTy;
1408 return Importer.getToContext().CharTy;
1410 case BuiltinType::WChar_S:
1411 case BuiltinType::WChar_U:
1414 return Importer.getToContext().WCharTy;
1417 llvm_unreachable(
"Invalid BuiltinType Kind!");
1420ExpectedType ASTNodeImporter::VisitDecayedType(
const DecayedType *
T) {
1421 ExpectedType ToOriginalTypeOrErr =
import(
T->getOriginalType());
1422 if (!ToOriginalTypeOrErr)
1423 return ToOriginalTypeOrErr.takeError();
1425 return Importer.getToContext().getDecayedType(*ToOriginalTypeOrErr);
1428ExpectedType ASTNodeImporter::VisitComplexType(
const ComplexType *
T) {
1429 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1430 if (!ToElementTypeOrErr)
1431 return ToElementTypeOrErr.takeError();
1433 return Importer.getToContext().getComplexType(*ToElementTypeOrErr);
1436ExpectedType ASTNodeImporter::VisitPointerType(
const PointerType *
T) {
1438 if (!ToPointeeTypeOrErr)
1439 return ToPointeeTypeOrErr.takeError();
1441 return Importer.getToContext().getPointerType(*ToPointeeTypeOrErr);
1444ExpectedType ASTNodeImporter::VisitBlockPointerType(
const BlockPointerType *
T) {
1447 if (!ToPointeeTypeOrErr)
1448 return ToPointeeTypeOrErr.takeError();
1450 return Importer.getToContext().getBlockPointerType(*ToPointeeTypeOrErr);
1454ASTNodeImporter::VisitLValueReferenceType(
const LValueReferenceType *
T) {
1456 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1457 if (!ToPointeeTypeOrErr)
1458 return ToPointeeTypeOrErr.takeError();
1460 return Importer.getToContext().getLValueReferenceType(*ToPointeeTypeOrErr);
1464ASTNodeImporter::VisitRValueReferenceType(
const RValueReferenceType *
T) {
1466 ExpectedType ToPointeeTypeOrErr =
import(
T->getPointeeTypeAsWritten());
1467 if (!ToPointeeTypeOrErr)
1468 return ToPointeeTypeOrErr.takeError();
1470 return Importer.getToContext().getRValueReferenceType(*ToPointeeTypeOrErr);
1474ASTNodeImporter::VisitMemberPointerType(
const MemberPointerType *
T) {
1477 if (!ToPointeeTypeOrErr)
1478 return ToPointeeTypeOrErr.takeError();
1480 auto QualifierOrErr =
import(
T->getQualifier());
1481 if (!QualifierOrErr)
1482 return QualifierOrErr.takeError();
1484 auto ClsOrErr =
import(
T->getMostRecentCXXRecordDecl());
1486 return ClsOrErr.takeError();
1488 return Importer.getToContext().getMemberPointerType(
1489 *ToPointeeTypeOrErr, *QualifierOrErr, *ClsOrErr);
1493ASTNodeImporter::VisitConstantArrayType(
const ConstantArrayType *
T) {
1494 Error Err = Error::success();
1495 auto ToElementType = importChecked(Err,
T->getElementType());
1496 auto ToSizeExpr = importChecked(Err,
T->getSizeExpr());
1498 return std::move(Err);
1500 return Importer.getToContext().getConstantArrayType(
1501 ToElementType,
T->getSize(), ToSizeExpr,
T->getSizeModifier(),
1502 T->getIndexTypeCVRQualifiers());
1506ASTNodeImporter::VisitArrayParameterType(
const ArrayParameterType *
T) {
1508 if (!ToArrayTypeOrErr)
1509 return ToArrayTypeOrErr.takeError();
1511 return Importer.getToContext().getArrayParameterType(*ToArrayTypeOrErr);
1515ASTNodeImporter::VisitIncompleteArrayType(
const IncompleteArrayType *
T) {
1516 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1517 if (!ToElementTypeOrErr)
1518 return ToElementTypeOrErr.takeError();
1520 return Importer.getToContext().getIncompleteArrayType(*ToElementTypeOrErr,
1521 T->getSizeModifier(),
1522 T->getIndexTypeCVRQualifiers());
1526ASTNodeImporter::VisitVariableArrayType(
const VariableArrayType *
T) {
1527 Error Err = Error::success();
1528 QualType ToElementType = importChecked(Err,
T->getElementType());
1529 Expr *ToSizeExpr = importChecked(Err,
T->getSizeExpr());
1531 return std::move(Err);
1532 return Importer.getToContext().getVariableArrayType(
1533 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1534 T->getIndexTypeCVRQualifiers());
1537ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(
1538 const DependentSizedArrayType *
T) {
1539 Error Err = Error::success();
1540 QualType ToElementType = importChecked(Err,
T->getElementType());
1541 Expr *ToSizeExpr = importChecked(Err,
T->getSizeExpr());
1543 return std::move(Err);
1547 return Importer.getToContext().getDependentSizedArrayType(
1548 ToElementType, ToSizeExpr,
T->getSizeModifier(),
1549 T->getIndexTypeCVRQualifiers());
1552ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType(
1553 const DependentSizedExtVectorType *
T) {
1554 Error Err = Error::success();
1555 QualType ToElementType = importChecked(Err,
T->getElementType());
1556 Expr *ToSizeExpr = importChecked(Err,
T->getSizeExpr());
1557 SourceLocation ToAttrLoc = importChecked(Err,
T->getAttributeLoc());
1559 return std::move(Err);
1560 return Importer.getToContext().getDependentSizedExtVectorType(
1561 ToElementType, ToSizeExpr, ToAttrLoc);
1564ExpectedType ASTNodeImporter::VisitVectorType(
const VectorType *
T) {
1565 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1566 if (!ToElementTypeOrErr)
1567 return ToElementTypeOrErr.takeError();
1569 return Importer.getToContext().getVectorType(*ToElementTypeOrErr,
1570 T->getNumElements(),
1571 T->getVectorKind());
1574ExpectedType ASTNodeImporter::VisitExtVectorType(
const ExtVectorType *
T) {
1575 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
1576 if (!ToElementTypeOrErr)
1577 return ToElementTypeOrErr.takeError();
1579 return Importer.getToContext().getExtVectorType(*ToElementTypeOrErr,
1580 T->getNumElements());
1584ASTNodeImporter::VisitFunctionNoProtoType(
const FunctionNoProtoType *
T) {
1588 if (!ToReturnTypeOrErr)
1589 return ToReturnTypeOrErr.takeError();
1591 return Importer.getToContext().getFunctionNoProtoType(*ToReturnTypeOrErr,
1596ASTNodeImporter::VisitFunctionProtoType(
const FunctionProtoType *
T) {
1598 if (!ToReturnTypeOrErr)
1599 return ToReturnTypeOrErr.takeError();
1602 SmallVector<QualType, 4> ArgTypes;
1606 return TyOrErr.takeError();
1607 ArgTypes.push_back(*TyOrErr);
1611 SmallVector<QualType, 4> ExceptionTypes;
1615 return TyOrErr.takeError();
1616 ExceptionTypes.push_back(*TyOrErr);
1620 Error Err = Error::success();
1621 FunctionProtoType::ExtProtoInfo ToEPI;
1637 return std::move(Err);
1639 return Importer.getToContext().getFunctionType(
1640 *ToReturnTypeOrErr, ArgTypes, ToEPI);
1644 const UnresolvedUsingType *
T) {
1645 auto ToQualifierOrErr =
import(
T->getQualifier());
1646 if (!ToQualifierOrErr)
1647 return ToQualifierOrErr.takeError();
1648 auto ToDeclOrErr =
import(
T->getDecl());
1650 return ToDeclOrErr.takeError();
1653 return Importer.getToContext().getCanonicalUnresolvedUsingType(
1655 return Importer.getToContext().getUnresolvedUsingType(
1656 T->getKeyword(), *ToQualifierOrErr, *ToDeclOrErr);
1659ExpectedType ASTNodeImporter::VisitParenType(
const ParenType *
T) {
1661 if (!ToInnerTypeOrErr)
1662 return ToInnerTypeOrErr.takeError();
1664 return Importer.getToContext().getParenType(*ToInnerTypeOrErr);
1668ASTNodeImporter::VisitPackIndexingType(clang::PackIndexingType
const *
T) {
1672 return Pattern.takeError();
1675 return Index.takeError();
1676 return Importer.getToContext().getPackIndexingType(*Pattern, *Index);
1679ExpectedType ASTNodeImporter::VisitTypedefType(
const TypedefType *
T) {
1680 Expected<TypedefNameDecl *> ToDeclOrErr =
import(
T->getDecl());
1682 return ToDeclOrErr.takeError();
1684 auto ToQualifierOrErr =
import(
T->getQualifier());
1685 if (!ToQualifierOrErr)
1686 return ToQualifierOrErr.takeError();
1689 T->typeMatchesDecl() ? QualType() : import(
T->desugar());
1690 if (!ToUnderlyingTypeOrErr)
1691 return ToUnderlyingTypeOrErr.takeError();
1693 return Importer.getToContext().getTypedefType(
1694 T->getKeyword(), *ToQualifierOrErr, *ToDeclOrErr, *ToUnderlyingTypeOrErr);
1697ExpectedType ASTNodeImporter::VisitTypeOfExprType(
const TypeOfExprType *
T) {
1700 return ToExprOrErr.takeError();
1701 return Importer.getToContext().getTypeOfExprType(*ToExprOrErr,
T->getKind());
1704ExpectedType ASTNodeImporter::VisitTypeOfType(
const TypeOfType *
T) {
1705 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnmodifiedType());
1706 if (!ToUnderlyingTypeOrErr)
1707 return ToUnderlyingTypeOrErr.takeError();
1708 return Importer.getToContext().getTypeOfType(*ToUnderlyingTypeOrErr,
1712ExpectedType ASTNodeImporter::VisitUsingType(
const UsingType *
T) {
1713 auto ToQualifierOrErr =
import(
T->getQualifier());
1714 if (!ToQualifierOrErr)
1715 return ToQualifierOrErr.takeError();
1716 auto ToDeclOrErr =
import(
T->getDecl());
1718 return ToDeclOrErr.takeError();
1722 return ToTypeOrErr.takeError();
1723 return Importer.getToContext().getUsingType(
1724 T->getKeyword(), *ToQualifierOrErr, *ToDeclOrErr, *ToTypeOrErr);
1727ExpectedType ASTNodeImporter::VisitDecltypeType(
const DecltypeType *
T) {
1731 return ToExprOrErr.takeError();
1733 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1734 if (!ToUnderlyingTypeOrErr)
1735 return ToUnderlyingTypeOrErr.takeError();
1737 return Importer.getToContext().getDecltypeType(
1738 *ToExprOrErr, *ToUnderlyingTypeOrErr);
1742ASTNodeImporter::VisitUnaryTransformType(
const UnaryTransformType *
T) {
1744 if (!ToBaseTypeOrErr)
1745 return ToBaseTypeOrErr.takeError();
1747 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
1748 if (!ToUnderlyingTypeOrErr)
1749 return ToUnderlyingTypeOrErr.takeError();
1751 return Importer.getToContext().getUnaryTransformType(
1752 *ToBaseTypeOrErr, *ToUnderlyingTypeOrErr,
T->getUTTKind());
1755ExpectedType ASTNodeImporter::VisitAutoType(
const AutoType *
T) {
1757 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1758 if (!ToDeducedTypeOrErr)
1759 return ToDeducedTypeOrErr.takeError();
1762 if (
TemplateName FromTypeConstraint =
T->getTypeConstraintConcept();
1763 !FromTypeConstraint.isNull()) {
1764 Expected<TemplateName> ToTypeConstraintOrErr =
import(FromTypeConstraint);
1765 if (!ToTypeConstraintOrErr)
1766 return ToTypeConstraintOrErr.takeError();
1767 ToTypeConstraint = *ToTypeConstraintOrErr;
1770 SmallVector<TemplateArgument, 2> ToTemplateArgs;
1773 return std::move(Err);
1775 return Importer.getToContext().getAutoType(
1776 T->getDeducedKind(), *ToDeducedTypeOrErr,
T->getKeyword(),
1777 ToTypeConstraint, ToTemplateArgs);
1780ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
1781 const DeducedTemplateSpecializationType *
T) {
1783 Expected<TemplateName> ToTemplateNameOrErr =
import(
T->getTemplateName());
1784 if (!ToTemplateNameOrErr)
1785 return ToTemplateNameOrErr.takeError();
1786 ExpectedType ToDeducedTypeOrErr =
import(
T->getDeducedType());
1787 if (!ToDeducedTypeOrErr)
1788 return ToDeducedTypeOrErr.takeError();
1790 return Importer.getToContext().getDeducedTemplateSpecializationType(
1791 T->getDeducedKind(), *ToDeducedTypeOrErr,
T->getKeyword(),
1792 *ToTemplateNameOrErr);
1795ExpectedType ASTNodeImporter::VisitTagType(
const TagType *
T) {
1796 TagDecl *DeclForType =
T->getDecl();
1797 Expected<TagDecl *> ToDeclOrErr =
import(DeclForType);
1799 return ToDeclOrErr.takeError();
1805 Expected<TagDecl *> ToDefDeclOrErr =
import(DeclForType->
getDefinition());
1806 if (!ToDefDeclOrErr)
1807 return ToDefDeclOrErr.takeError();
1810 return Importer.getToContext().getCanonicalTagType(*ToDeclOrErr);
1812 auto ToQualifierOrErr =
import(
T->getQualifier());
1813 if (!ToQualifierOrErr)
1814 return ToQualifierOrErr.takeError();
1816 return Importer.getToContext().getTagType(
T->getKeyword(), *ToQualifierOrErr,
1817 *ToDeclOrErr,
T->isTagOwned());
1820ExpectedType ASTNodeImporter::VisitEnumType(
const EnumType *
T) {
1821 return VisitTagType(
T);
1824ExpectedType ASTNodeImporter::VisitRecordType(
const RecordType *
T) {
1825 return VisitTagType(
T);
1829ASTNodeImporter::VisitInjectedClassNameType(
const InjectedClassNameType *
T) {
1830 return VisitTagType(
T);
1833ExpectedType ASTNodeImporter::VisitAttributedType(
const AttributedType *
T) {
1834 ExpectedType ToModifiedTypeOrErr =
import(
T->getModifiedType());
1835 if (!ToModifiedTypeOrErr)
1836 return ToModifiedTypeOrErr.takeError();
1837 ExpectedType ToEquivalentTypeOrErr =
import(
T->getEquivalentType());
1838 if (!ToEquivalentTypeOrErr)
1839 return ToEquivalentTypeOrErr.takeError();
1841 return Importer.getToContext().getAttributedType(
1842 T->getAttrKind(), *ToModifiedTypeOrErr, *ToEquivalentTypeOrErr,
1847ASTNodeImporter::VisitCountAttributedType(
const CountAttributedType *
T) {
1849 if (!ToWrappedTypeOrErr)
1850 return ToWrappedTypeOrErr.takeError();
1852 Error Err = Error::success();
1853 Expr *CountExpr = importChecked(Err,
T->getCountExpr());
1855 SmallVector<TypeCoupledDeclRefInfo, 1> CoupledDecls;
1856 for (
const TypeCoupledDeclRefInfo &TI :
T->dependent_decls()) {
1857 Expected<ValueDecl *> ToDeclOrErr =
import(TI.getDecl());
1859 return ToDeclOrErr.takeError();
1860 CoupledDecls.emplace_back(*ToDeclOrErr, TI.isDeref());
1863 return Importer.getToContext().getCountAttributedType(
1864 *ToWrappedTypeOrErr, CountExpr,
T->isCountInBytes(),
T->isOrNull(),
1865 ArrayRef(CoupledDecls));
1869ASTNodeImporter::VisitLateParsedAttrType(
const LateParsedAttrType *
T) {
1870 llvm_unreachable(
"should be replaced with a concrete type before AST import");
1873ExpectedType ASTNodeImporter::VisitTemplateTypeParmType(
1874 const TemplateTypeParmType *
T) {
1875 Expected<TemplateTypeParmDecl *> ToDeclOrErr =
import(
T->getDecl());
1877 return ToDeclOrErr.takeError();
1879 return Importer.getToContext().getTemplateTypeParmType(
1880 T->getDepth(),
T->getIndex(),
T->isParameterPack(), *ToDeclOrErr);
1883ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmType(
1884 const SubstTemplateTypeParmType *
T) {
1885 Expected<Decl *> ReplacedOrErr =
import(
T->getAssociatedDecl());
1887 return ReplacedOrErr.takeError();
1889 ExpectedType ToReplacementTypeOrErr =
import(
T->getReplacementType());
1890 if (!ToReplacementTypeOrErr)
1891 return ToReplacementTypeOrErr.takeError();
1893 return Importer.getToContext().getSubstTemplateTypeParmType(
1894 *ToReplacementTypeOrErr, *ReplacedOrErr,
T->getIndex(),
T->getPackIndex(),
1898ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmPackType(
1899 const SubstTemplateTypeParmPackType *
T) {
1900 Expected<Decl *> ReplacedOrErr =
import(
T->getAssociatedDecl());
1902 return ReplacedOrErr.takeError();
1904 Expected<TemplateArgument> ToArgumentPack =
import(
T->getArgumentPack());
1905 if (!ToArgumentPack)
1906 return ToArgumentPack.takeError();
1908 return Importer.getToContext().getSubstTemplateTypeParmPackType(
1909 *ReplacedOrErr,
T->getIndex(),
T->getFinal(), *ToArgumentPack);
1912ExpectedType ASTNodeImporter::VisitSubstBuiltinTemplatePackType(
1913 const SubstBuiltinTemplatePackType *
T) {
1914 Expected<TemplateArgument> ToArgumentPack =
import(
T->getArgumentPack());
1915 if (!ToArgumentPack)
1916 return ToArgumentPack.takeError();
1917 return Importer.getToContext().getSubstBuiltinTemplatePack(*ToArgumentPack);
1920ExpectedType ASTNodeImporter::VisitTemplateSpecializationType(
1921 const TemplateSpecializationType *
T) {
1922 auto ToTemplateOrErr =
import(
T->getTemplateName());
1923 if (!ToTemplateOrErr)
1924 return ToTemplateOrErr.takeError();
1926 SmallVector<TemplateArgument, 2> ToTemplateArgs;
1929 return std::move(Err);
1933 if (!ToUnderlyingOrErr)
1934 return ToUnderlyingOrErr.takeError();
1935 return Importer.getToContext().getTemplateSpecializationType(
1936 T->getKeyword(), *ToTemplateOrErr, ToTemplateArgs, {},
1937 *ToUnderlyingOrErr);
1941ASTNodeImporter::VisitPackExpansionType(
const PackExpansionType *
T) {
1943 if (!ToPatternOrErr)
1944 return ToPatternOrErr.takeError();
1946 return Importer.getToContext().getPackExpansionType(*ToPatternOrErr,
1947 T->getNumExpansions(),
1952ASTNodeImporter::VisitDependentNameType(
const DependentNameType *
T) {
1953 auto ToQualifierOrErr =
import(
T->getQualifier());
1954 if (!ToQualifierOrErr)
1955 return ToQualifierOrErr.takeError();
1957 IdentifierInfo *Name = Importer.Import(
T->getIdentifier());
1958 return Importer.getToContext().getDependentNameType(
T->getKeyword(),
1959 *ToQualifierOrErr, Name);
1963ASTNodeImporter::VisitObjCInterfaceType(
const ObjCInterfaceType *
T) {
1964 Expected<ObjCInterfaceDecl *> ToDeclOrErr =
import(
T->getDecl());
1966 return ToDeclOrErr.takeError();
1968 return Importer.getToContext().getObjCInterfaceType(*ToDeclOrErr);
1971ExpectedType ASTNodeImporter::VisitObjCObjectType(
const ObjCObjectType *
T) {
1973 if (!ToBaseTypeOrErr)
1974 return ToBaseTypeOrErr.takeError();
1976 SmallVector<QualType, 4> TypeArgs;
1977 for (
auto TypeArg :
T->getTypeArgsAsWritten()) {
1979 TypeArgs.push_back(*TyOrErr);
1981 return TyOrErr.takeError();
1984 SmallVector<ObjCProtocolDecl *, 4> Protocols;
1985 for (
auto *P :
T->quals()) {
1986 if (Expected<ObjCProtocolDecl *> ProtocolOrErr =
import(P))
1987 Protocols.push_back(*ProtocolOrErr);
1989 return ProtocolOrErr.takeError();
1993 return Importer.getToContext().getObjCObjectType(*ToBaseTypeOrErr, TypeArgs,
1995 T->isKindOfTypeAsWritten());
1999ASTNodeImporter::VisitObjCObjectPointerType(
const ObjCObjectPointerType *
T) {
2001 if (!ToPointeeTypeOrErr)
2002 return ToPointeeTypeOrErr.takeError();
2004 return Importer.getToContext().getObjCObjectPointerType(*ToPointeeTypeOrErr);
2008ASTNodeImporter::VisitMacroQualifiedType(
const MacroQualifiedType *
T) {
2009 ExpectedType ToUnderlyingTypeOrErr =
import(
T->getUnderlyingType());
2010 if (!ToUnderlyingTypeOrErr)
2011 return ToUnderlyingTypeOrErr.takeError();
2013 IdentifierInfo *ToIdentifier = Importer.Import(
T->getMacroIdentifier());
2014 return Importer.getToContext().getMacroQualifiedType(*ToUnderlyingTypeOrErr,
2018ExpectedType clang::ASTNodeImporter::VisitAdjustedType(
const AdjustedType *
T) {
2019 Error Err = Error::success();
2020 QualType ToOriginalType = importChecked(Err,
T->getOriginalType());
2021 QualType ToAdjustedType = importChecked(Err,
T->getAdjustedType());
2023 return std::move(Err);
2025 return Importer.getToContext().getAdjustedType(ToOriginalType,
2029ExpectedType clang::ASTNodeImporter::VisitBitIntType(
const BitIntType *
T) {
2030 return Importer.getToContext().getBitIntType(
T->isUnsigned(),
2034ExpectedType clang::ASTNodeImporter::VisitBTFTagAttributedType(
2035 const clang::BTFTagAttributedType *
T) {
2036 Error Err = Error::success();
2037 const BTFTypeTagAttr *ToBTFAttr = importChecked(Err,
T->getAttr());
2038 QualType ToWrappedType = importChecked(Err,
T->getWrappedType());
2040 return std::move(Err);
2042 return Importer.getToContext().getBTFTagAttributedType(ToBTFAttr,
2046ExpectedType clang::ASTNodeImporter::VisitOverflowBehaviorType(
2047 const clang::OverflowBehaviorType *
T) {
2048 Error Err = Error::success();
2049 OverflowBehaviorType::OverflowBehaviorKind ToKind =
T->getBehaviorKind();
2052 return std::move(Err);
2054 return Importer.getToContext().getOverflowBehaviorType(ToKind,
2058ExpectedType clang::ASTNodeImporter::VisitHLSLAttributedResourceType(
2059 const clang::HLSLAttributedResourceType *
T) {
2060 Error Err = Error::success();
2061 HLSLAttributedResourceType::Attributes ToAttrs =
T->getAttrs();
2062 QualType ToWrappedType = importChecked(Err,
T->getWrappedType());
2063 QualType ToContainedType = importChecked(Err,
T->getContainedType());
2064 ToAttrs.SampleCountExpr = importChecked(Err,
T->getSampleCountExpr());
2066 return std::move(Err);
2068 return Importer.getToContext().getHLSLAttributedResourceType(
2069 ToWrappedType, ToContainedType, ToAttrs);
2072ExpectedType clang::ASTNodeImporter::VisitHLSLInlineSpirvType(
2073 const clang::HLSLInlineSpirvType *
T) {
2074 Error Err = Error::success();
2078 uint32_t ToAlignment =
T->getAlignment();
2080 llvm::SmallVector<SpirvOperand> ToOperands;
2082 for (
auto &Operand :
T->getOperands()) {
2083 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
2086 case SpirvOperandKind::ConstantId:
2087 ToOperands.push_back(SpirvOperand::createConstant(
2088 importChecked(Err,
Operand.getResultType()),
Operand.getValue()));
2090 case SpirvOperandKind::Literal:
2091 ToOperands.push_back(SpirvOperand::createLiteral(
Operand.getValue()));
2093 case SpirvOperandKind::TypeId:
2094 ToOperands.push_back(SpirvOperand::createType(
2095 importChecked(Err,
Operand.getResultType())));
2098 llvm_unreachable(
"Invalid SpirvOperand kind");
2102 return std::move(Err);
2105 return Importer.getToContext().getHLSLInlineSpirvType(
2106 ToOpcode, ToSize, ToAlignment, ToOperands);
2109ExpectedType clang::ASTNodeImporter::VisitConstantMatrixType(
2110 const clang::ConstantMatrixType *
T) {
2111 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
2112 if (!ToElementTypeOrErr)
2113 return ToElementTypeOrErr.takeError();
2115 return Importer.getToContext().getConstantMatrixType(
2116 *ToElementTypeOrErr,
T->getNumRows(),
T->getNumColumns(),
T->getLayout());
2119ExpectedType clang::ASTNodeImporter::VisitDependentAddressSpaceType(
2120 const clang::DependentAddressSpaceType *
T) {
2121 Error Err = Error::success();
2123 Expr *ToAddrSpaceExpr = importChecked(Err,
T->getAddrSpaceExpr());
2124 SourceLocation ToAttrLoc = importChecked(Err,
T->getAttributeLoc());
2126 return std::move(Err);
2128 return Importer.getToContext().getDependentAddressSpaceType(
2129 ToPointeeType, ToAddrSpaceExpr, ToAttrLoc);
2132ExpectedType clang::ASTNodeImporter::VisitDependentBitIntType(
2133 const clang::DependentBitIntType *
T) {
2134 ExpectedExpr ToNumBitsExprOrErr =
import(
T->getNumBitsExpr());
2135 if (!ToNumBitsExprOrErr)
2136 return ToNumBitsExprOrErr.takeError();
2137 return Importer.getToContext().getDependentBitIntType(
T->isUnsigned(),
2138 *ToNumBitsExprOrErr);
2141ExpectedType clang::ASTNodeImporter::VisitPredefinedSugarType(
2142 const clang::PredefinedSugarType *
T) {
2143 return Importer.getToContext().getPredefinedSugarType(
T->getKind());
2146ExpectedType clang::ASTNodeImporter::VisitDependentSizedMatrixType(
2147 const clang::DependentSizedMatrixType *
T) {
2148 Error Err = Error::success();
2149 QualType ToElementType = importChecked(Err,
T->getElementType());
2150 Expr *ToRowExpr = importChecked(Err,
T->getRowExpr());
2151 Expr *ToColumnExpr = importChecked(Err,
T->getColumnExpr());
2152 SourceLocation ToAttrLoc = importChecked(Err,
T->getAttributeLoc());
2154 return std::move(Err);
2156 return Importer.getToContext().getDependentSizedMatrixType(
2157 ToElementType, ToRowExpr, ToColumnExpr, ToAttrLoc);
2160ExpectedType clang::ASTNodeImporter::VisitDependentVectorType(
2161 const clang::DependentVectorType *
T) {
2162 Error Err = Error::success();
2163 QualType ToElementType = importChecked(Err,
T->getElementType());
2164 Expr *ToSizeExpr = importChecked(Err,
T->getSizeExpr());
2165 SourceLocation ToAttrLoc = importChecked(Err,
T->getAttributeLoc());
2167 return std::move(Err);
2169 return Importer.getToContext().getDependentVectorType(
2170 ToElementType, ToSizeExpr, ToAttrLoc,
T->getVectorKind());
2173ExpectedType clang::ASTNodeImporter::VisitObjCTypeParamType(
2174 const clang::ObjCTypeParamType *
T) {
2175 Expected<ObjCTypeParamDecl *> ToDeclOrErr =
import(
T->getDecl());
2177 return ToDeclOrErr.takeError();
2179 SmallVector<ObjCProtocolDecl *, 4> ToProtocols;
2180 for (ObjCProtocolDecl *FromProtocol :
T->getProtocols()) {
2181 Expected<ObjCProtocolDecl *> ToProtocolOrErr =
import(FromProtocol);
2182 if (!ToProtocolOrErr)
2183 return ToProtocolOrErr.takeError();
2184 ToProtocols.push_back(*ToProtocolOrErr);
2187 return Importer.getToContext().getObjCTypeParamType(*ToDeclOrErr,
2191ExpectedType clang::ASTNodeImporter::VisitPipeType(
const clang::PipeType *
T) {
2192 ExpectedType ToElementTypeOrErr =
import(
T->getElementType());
2193 if (!ToElementTypeOrErr)
2194 return ToElementTypeOrErr.takeError();
2196 ASTContext &ToCtx = Importer.getToContext();
2197 if (
T->isReadOnly())
2217 if (
isa<RecordDecl>(D) && (FunDecl = dyn_cast<FunctionDecl>(OrigDC)) &&
2219 auto getLeafPointeeType = [](
const Type *
T) {
2220 while (
T->isPointerType() ||
T->isArrayType()) {
2221 T =
T->getPointeeOrArrayElementType();
2227 getLeafPointeeType(
P->getType().getCanonicalType().getTypePtr());
2228 auto *RT = dyn_cast<RecordType>(LeafT);
2229 if (RT && RT->getDecl() == D) {
2230 Importer.FromDiag(D->
getLocation(), diag::err_unsupported_ast_node)
2249 ToD = cast_or_null<NamedDecl>(Importer.GetAlreadyImportedOrNull(D));
2254 return Error::success();
2268 ToD = cast_or_null<NamedDecl>(Importer.GetAlreadyImportedOrNull(D));
2273 return Error::success();
2278 return Error::success();
2284 if (
RecordDecl *FromRecord = dyn_cast<RecordDecl>(FromD)) {
2286 if (FromRecord->getDefinition() && FromRecord->isCompleteDefinition() &&
2287 !ToRecord->getDefinition()) {
2292 return Error::success();
2295 if (
EnumDecl *FromEnum = dyn_cast<EnumDecl>(FromD)) {
2297 if (FromEnum->getDefinition() && !ToEnum->getDefinition()) {
2302 return Error::success();
2305 return Error::success();
2320 return Error::success();
2326 return ToRangeOrErr.takeError();
2327 return Error::success();
2333 return LocOrErr.takeError();
2334 return Error::success();
2342 return ToTInfoOrErr.takeError();
2343 return Error::success();
2346 llvm_unreachable(
"Unknown name kind.");
2351 if (Importer.isMinimalImport() && !ForceImport) {
2352 auto ToDCOrErr = Importer.ImportContext(FromDC);
2353 return ToDCOrErr.takeError();
2367 auto MightNeedReordering = [](
const Decl *D) {
2372 Error ChildErrors = Error::success();
2373 for (
auto *From : FromDC->
decls()) {
2374 if (!MightNeedReordering(From))
2383 if (!ImportedOrErr) {
2385 ImportedOrErr.takeError());
2388 FieldDecl *FieldFrom = dyn_cast_or_null<FieldDecl>(From);
2389 Decl *ImportedDecl = *ImportedOrErr;
2390 FieldDecl *FieldTo = dyn_cast_or_null<FieldDecl>(ImportedDecl);
2391 if (FieldFrom && FieldTo) {
2421 auto ToDCOrErr = Importer.ImportContext(FromDC);
2423 consumeError(std::move(ChildErrors));
2424 return ToDCOrErr.takeError();
2427 if (
const auto *FromRD = dyn_cast<RecordDecl>(FromDC)) {
2431 for (
auto *D : FromRD->decls()) {
2432 if (!MightNeedReordering(D))
2435 assert(D &&
"DC contains a null decl");
2436 if (
Decl *ToD = Importer.GetAlreadyImportedOrNull(D)) {
2438 assert(ToDC == ToD->getLexicalDeclContext() && ToDC->
containsDecl(ToD));
2450 for (
auto *From : FromDC->
decls()) {
2451 if (MightNeedReordering(From))
2457 ImportedOrErr.takeError());
2477 if (!FromRecordDecl || !ToRecordDecl) {
2478 const RecordType *RecordFrom = FromType->
getAs<RecordType>();
2479 const RecordType *RecordTo = ToType->
getAs<RecordType>();
2481 if (RecordFrom && RecordTo) {
2482 FromRecordDecl = RecordFrom->getDecl();
2483 ToRecordDecl = RecordTo->getDecl();
2487 if (FromRecordDecl && ToRecordDecl) {
2493 return Error::success();
2498 auto ToDCOrErr = Importer.ImportContext(FromD->
getDeclContext());
2500 return ToDCOrErr.takeError();
2504 auto ToLexicalDCOrErr = Importer.ImportContext(
2506 if (!ToLexicalDCOrErr)
2507 return ToLexicalDCOrErr.takeError();
2508 ToLexicalDC = *ToLexicalDCOrErr;
2512 return Error::success();
2518 "Import implicit methods to or from non-definition");
2521 if (FromM->isImplicit()) {
2524 return ToMOrErr.takeError();
2527 return Error::success();
2536 return ToTypedefOrErr.takeError();
2538 return Error::success();
2543 auto DefinitionCompleter = [To]() {
2564 ToCaptures.reserve(FromCXXRD->capture_size());
2565 for (
const auto &FromCapture : FromCXXRD->captures()) {
2566 if (
auto ToCaptureOrErr =
import(FromCapture))
2567 ToCaptures.push_back(*ToCaptureOrErr);
2569 return ToCaptureOrErr.takeError();
2578 DefinitionCompleter();
2582 return Error::success();
2592 if (!Importer.isMinimalImport())
2597 llvm::scope_exit DefinitionCompleterScopeExit(DefinitionCompleter);
2603 auto *ToCXX = dyn_cast<CXXRecordDecl>(To);
2604 auto *FromCXX = dyn_cast<CXXRecordDecl>(From);
2605 if (ToCXX && FromCXX && ToCXX->dataPtr() && FromCXX->dataPtr()) {
2607 struct CXXRecordDecl::DefinitionData &ToData = ToCXX->data();
2608 struct CXXRecordDecl::DefinitionData &FromData = FromCXX->data();
2610 #define FIELD(Name, Width, Merge) \
2611 ToData.Name = FromData.Name;
2612 #include "clang/AST/CXXRecordDeclDefinitionBits.def"
2615 ToCXX->setArgPassingRestrictions(FromCXX->getArgPassingRestrictions());
2618 for (
const auto &Base1 : FromCXX->bases()) {
2621 return TyOrErr.takeError();
2624 if (Base1.isPackExpansion()) {
2625 if (
ExpectedSLoc LocOrErr =
import(Base1.getEllipsisLoc()))
2626 EllipsisLoc = *LocOrErr;
2628 return LocOrErr.takeError();
2636 auto RangeOrErr =
import(Base1.getSourceRange());
2638 return RangeOrErr.takeError();
2640 auto TSIOrErr =
import(Base1.getTypeSourceInfo());
2642 return TSIOrErr.takeError();
2648 Base1.isBaseOfClass(),
2649 Base1.getAccessSpecifierAsWritten(),
2654 ToCXX->setBases(Bases.data(), Bases.size());
2662 return Error::success();
2667 return Error::success();
2671 return Error::success();
2675 return ToInitOrErr.takeError();
2686 return Error::success();
2694 return Error::success();
2703 import(
QualType(Importer.getFromContext().getCanonicalTagType(From)));
2705 return ToTypeOrErr.takeError();
2708 if (!ToPromotionTypeOrErr)
2709 return ToPromotionTypeOrErr.takeError();
2720 return Error::success();
2726 for (
const auto &Arg : FromArgs) {
2727 if (
auto ToOrErr =
import(Arg))
2728 ToArgs.push_back(*ToOrErr);
2730 return ToOrErr.takeError();
2733 return Error::success();
2739 return import(From);
2742template <
typename InContainerTy>
2745 for (
const auto &FromLoc : Container) {
2746 if (
auto ToLocOrErr =
import(FromLoc))
2749 return ToLocOrErr.takeError();
2751 return Error::success();
2761 bool IgnoreTemplateParmDepth) {
2764 Decl *ToOrigin = Importer.GetOriginalDecl(To);
2770 Importer.getToContext().getLangOpts(), Importer.getFromContext(),
2771 Importer.getToContext(), Importer.getNonEquivalentDecls(),
2773 false, Complain,
false,
2774 IgnoreTemplateParmDepth);
2779 Importer.FromDiag(D->
getLocation(), diag::err_unsupported_ast_node)
2785 Importer.FromDiag(D->
getLocation(), diag::err_unsupported_ast_node)
2794 return std::move(Err);
2799 return LocOrErr.takeError();
2802 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, *LocOrErr))
2814 Importer.MapImported(D, ToD);
2820 Error Err = Error::success();
2825 return std::move(Err);
2829 return DCOrErr.takeError();
2833 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, ToAsmString,
2834 ToAsmLoc, ToRParenLoc))
2849 return std::move(Err);
2854 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, Loc,
2858 Error Err = Error::success();
2864 return std::move(Err);
2868 addDeclToContexts(D, ToD);
2876 return LocOrErr.takeError();
2879 return ColonLocOrErr.takeError();
2884 return DCOrErr.takeError();
2888 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), D->
getAccess(),
2889 DC, *LocOrErr, *ColonLocOrErr))
2903 return DCOrErr.takeError();
2907 Error Err = Error::success();
2913 return std::move(Err);
2916 if (GetImportedOrCreateDecl(
2917 ToD, D, Importer.getToContext(), DC, ToLocation, ToAssertExpr, ToMessage,
2930 return DCOrErr.takeError();
2934 Error Err = Error::success();
2940 return std::move(Err);
2943 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, ToLocation,
2961 return std::move(Err);
2970 if (
auto *TU = dyn_cast<TranslationUnitDecl>(EnclosingDC))
2973 MergeWithNamespace =
2977 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2978 for (
auto *FoundDecl : FoundDecls) {
2982 if (
auto *FoundNS = dyn_cast<NamespaceDecl>(FoundDecl)) {
2983 MergeWithNamespace = FoundNS;
2984 ConflictingDecls.clear();
2988 ConflictingDecls.push_back(FoundDecl);
2991 if (!ConflictingDecls.empty()) {
2994 ConflictingDecls.size());
2996 Name = NameOrErr.get();
2998 return NameOrErr.takeError();
3004 return BeginLocOrErr.takeError();
3006 if (!RBraceLocOrErr)
3007 return RBraceLocOrErr.takeError();
3012 if (GetImportedOrCreateDecl(ToNamespace, D, Importer.getToContext(), DC,
3013 D->
isInline(), *BeginLocOrErr, Loc,
3024 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
3025 TU->setAnonymousNamespace(ToNamespace);
3030 Importer.MapImported(D, ToNamespace);
3033 return std::move(Err);
3045 return std::move(Err);
3051 Error Err = Error::success();
3058 return std::move(Err);
3063 if (GetImportedOrCreateDecl(
3064 ToD, D, Importer.getToContext(), DC, ToNamespaceLoc, ToAliasLoc,
3065 ToIdentifier, ToQualifierLoc, ToTargetNameLoc, ToNamespace))
3083 return std::move(Err);
3090 cast_or_null<DeclContext>(Importer.GetAlreadyImportedOrNull(
3102 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3103 for (
auto *FoundDecl : FoundDecls) {
3104 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3106 if (
auto *FoundTypedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
3111 QualType FoundUT = FoundTypedef->getUnderlyingType();
3112 if (Importer.IsStructurallyEquivalent(FromUT, FoundUT)) {
3125 if (FromR && FoundR &&
3132 return Importer.MapImported(D, FoundTypedef);
3136 ConflictingDecls.push_back(FoundDecl);
3141 if (!ConflictingDecls.empty()) {
3143 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3145 Name = NameOrErr.get();
3147 return NameOrErr.takeError();
3151 Error Err = Error::success();
3156 return std::move(Err);
3163 if (GetImportedOrCreateDecl<TypeAliasDecl>(
3164 ToTypedef, D, Importer.getToContext(), DC, ToBeginLoc, Loc,
3167 }
else if (GetImportedOrCreateDecl<TypedefDecl>(
3168 ToTypedef, D, Importer.getToContext(), DC, ToBeginLoc, Loc,
3174 return std::move(Err);
3178 Importer.AddToLookupTable(ToTypedef);
3206 return std::move(Err);
3216 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3217 for (
auto *FoundDecl : FoundDecls) {
3218 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3220 if (
auto *FoundAlias = dyn_cast<TypeAliasTemplateDecl>(FoundDecl)) {
3222 return Importer.MapImported(D, FoundAlias);
3223 ConflictingDecls.push_back(FoundDecl);
3227 if (!ConflictingDecls.empty()) {
3229 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3231 Name = NameOrErr.get();
3233 return NameOrErr.takeError();
3237 Error Err = Error::success();
3241 return std::move(Err);
3244 if (GetImportedOrCreateDecl(ToAlias, D, Importer.getToContext(), DC, Loc,
3245 Name, ToTemplateParameters, ToTemplatedDecl))
3248 ToTemplatedDecl->setDescribedAliasTemplate(ToAlias);
3253 if (DC != Importer.getToContext().getTranslationUnitDecl())
3254 updateLookupTableForTemplateParameters(*ToTemplateParameters);
3265 return std::move(Err);
3275 return BeginLocOrErr.takeError();
3276 if (GetImportedOrCreateDecl(ToLabel, D, Importer.getToContext(), DC, Loc,
3281 if (GetImportedOrCreateDecl(ToLabel, D, Importer.getToContext(), DC, Loc,
3289 return ToStmtOrErr.takeError();
3291 ToLabel->
setStmt(*ToStmtOrErr);
3304 return std::move(Err);
3314 return std::move(Err);
3316 }
else if (Importer.getToContext().getLangOpts().CPlusPlus)
3324 Importer.findDeclsInToCtx(DC, SearchName);
3325 for (
auto *FoundDecl : FoundDecls) {
3326 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3329 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
3330 if (
const auto *Tag =
Typedef->getUnderlyingType()->getAs<TagType>())
3331 FoundDecl = Tag->getDecl();
3334 if (
auto *FoundEnum = dyn_cast<EnumDecl>(FoundDecl)) {
3340 return Importer.MapImported(D, FoundDef);
3344 ConflictingDecls.push_back(FoundDecl);
3353 if (SearchName && !ConflictingDecls.empty()) {
3355 SearchName, DC, IDNS, ConflictingDecls.data(),
3356 ConflictingDecls.size());
3358 Name = NameOrErr.get();
3360 return NameOrErr.takeError();
3364 Error Err = Error::success();
3370 return std::move(Err);
3374 if (GetImportedOrCreateDecl(
3375 D2, D, Importer.getToContext(), DC, ToBeginLoc,
3385 addDeclToContexts(D, D2);
3391 D2->setInstantiationOfMemberEnum(*ToInstOrErr, SK);
3393 return ToInstOrErr.takeError();
3394 if (
ExpectedSLoc POIOrErr =
import(MemberInfo->getPointOfInstantiation()))
3397 return POIOrErr.takeError();
3403 return std::move(Err);
3409 bool IsFriendTemplate =
false;
3410 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3412 DCXX->getDescribedClassTemplate() &&
3413 DCXX->getDescribedClassTemplate()->getFriendObjectKind() !=
3423 return std::move(Err);
3433 return std::move(Err);
3435 }
else if (Importer.getToContext().getLangOpts().CPlusPlus)
3440 bool DependentFriend = IsFriendTemplate && IsDependentContext;
3447 Importer.findDeclsInToCtx(DC, SearchName);
3448 if (!FoundDecls.empty()) {
3455 for (
auto *FoundDecl : FoundDecls) {
3456 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3460 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Found)) {
3461 if (
const auto *Tag =
Typedef->getUnderlyingType()->getAs<TagType>())
3462 Found = Tag->getDecl();
3465 if (
auto *FoundRecord = dyn_cast<RecordDecl>(
Found)) {
3487 Importer.MapImported(D, FoundDef);
3488 if (
const auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3489 auto *FoundCXX = dyn_cast<CXXRecordDecl>(FoundDef);
3490 assert(FoundCXX &&
"Record type mismatch");
3492 if (!Importer.isMinimalImport())
3496 return std::move(Err);
3503 ConflictingDecls.push_back(FoundDecl);
3507 if (!ConflictingDecls.empty() && SearchName) {
3509 SearchName, DC, IDNS, ConflictingDecls.data(),
3510 ConflictingDecls.size());
3512 Name = NameOrErr.get();
3514 return NameOrErr.takeError();
3520 return BeginLocOrErr.takeError();
3525 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3526 if (DCXX->isLambda()) {
3527 auto TInfoOrErr =
import(DCXX->getLambdaTypeInfo());
3529 return TInfoOrErr.takeError();
3530 if (GetImportedOrCreateSpecialDecl(
3532 DC, *TInfoOrErr, Loc, DCXX->getLambdaDependencyKind(),
3533 DCXX->isGenericLambda(), DCXX->getLambdaCaptureDefault()))
3535 Decl *ContextDecl = DCXX->getLambdaContextDecl();
3538 return CDeclOrErr.takeError();
3539 if (ContextDecl !=
nullptr) {
3544 if (GetImportedOrCreateDecl(D2CXX, D, Importer.getToContext(),
3547 cast_or_null<CXXRecordDecl>(PrevDecl)))
3554 addDeclToContexts(D, D2);
3557 DCXX->getDescribedClassTemplate()) {
3560 return std::move(Err);
3563 DCXX->getMemberSpecializationInfo()) {
3565 MemberInfo->getTemplateSpecializationKind();
3571 return ToInstOrErr.takeError();
3574 import(MemberInfo->getPointOfInstantiation()))
3578 return POIOrErr.takeError();
3582 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(),
3587 addDeclToContexts(D, D2);
3593 return BraceRangeOrErr.takeError();
3597 return QualifierLocOrErr.takeError();
3604 return std::move(Err);
3616 return std::move(Err);
3625 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3626 for (
auto *FoundDecl : FoundDecls) {
3627 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3630 if (
auto *FoundEnumConstant = dyn_cast<EnumConstantDecl>(FoundDecl)) {
3632 return Importer.MapImported(D, FoundEnumConstant);
3633 ConflictingDecls.push_back(FoundDecl);
3637 if (!ConflictingDecls.empty()) {
3639 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3641 Name = NameOrErr.get();
3643 return NameOrErr.takeError();
3649 return TypeOrErr.takeError();
3653 return InitOrErr.takeError();
3656 if (GetImportedOrCreateDecl(
3657 ToEnumerator, D, Importer.getToContext(),
cast<EnumDecl>(DC), Loc,
3659 return ToEnumerator;
3664 return ToEnumerator;
3667template <
typename DeclTy>
3671 FromD->getTemplateParameterLists();
3672 if (FromTPLs.empty())
3673 return Error::success();
3675 for (
unsigned int I = 0; I < FromTPLs.size(); ++I)
3677 ToTPLists[I] = *ToTPListOrErr;
3679 return ToTPListOrErr.takeError();
3680 ToD->setTemplateParameterListsInfo(Importer.ToContext, ToTPLists);
3681 return Error::success();
3689 return Error::success();
3695 return Error::success();
3701 ToFD->setInstantiationOfMemberFunction(*InstFDOrErr, TSK);
3703 return InstFDOrErr.takeError();
3709 return POIOrErr.takeError();
3711 return Error::success();
3715 auto FunctionAndArgsOrErr =
3717 if (!FunctionAndArgsOrErr)
3718 return FunctionAndArgsOrErr.takeError();
3721 Importer.getToContext(), std::get<1>(*FunctionAndArgsOrErr));
3725 const auto *FromTAArgsAsWritten = FTSInfo->TemplateArgumentsAsWritten;
3726 if (FromTAArgsAsWritten)
3728 *FromTAArgsAsWritten, ToTAInfo))
3731 ExpectedSLoc POIOrErr =
import(FTSInfo->getPointOfInstantiation());
3733 return POIOrErr.takeError();
3739 ToFD->setFunctionTemplateSpecialization(
3740 std::get<0>(*FunctionAndArgsOrErr), ToTAList, {}, TSK,
3741 FromTAArgsAsWritten ? &ToTAInfo :
nullptr, *POIOrErr);
3742 return Error::success();
3750 Candidates.
addDecl(*ToFTDOrErr);
3752 return ToFTDOrErr.takeError();
3757 const auto *FromTAArgsAsWritten = FromInfo->TemplateArgumentsAsWritten;
3758 if (FromTAArgsAsWritten)
3764 Importer.getToContext(), Candidates,
3765 FromTAArgsAsWritten ? &ToTAInfo :
nullptr);
3766 return Error::success();
3769 llvm_unreachable(
"All cases should be covered!");
3774 auto FunctionAndArgsOrErr =
3776 if (!FunctionAndArgsOrErr)
3777 return FunctionAndArgsOrErr.takeError();
3781 std::tie(
Template, ToTemplArgs) = *FunctionAndArgsOrErr;
3782 llvm::FoldingSetInsertToken InsertToken;
3783 auto *FoundSpec =
Template->findSpecialization(ToTemplArgs, InsertToken);
3793 return ToBodyOrErr.takeError();
3795 return Error::success();
3802 ExplicitExpr = importChecked(Err, ESpec.
getExpr());
3809 auto RedeclIt = Redecls.begin();
3812 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
3815 return ToRedeclOrErr.takeError();
3817 assert(*RedeclIt == D);
3825 return std::move(Err);
3840 if (!FoundFunctionOrErr)
3841 return FoundFunctionOrErr.takeError();
3842 if (
FunctionDecl *FoundFunction = *FoundFunctionOrErr) {
3843 if (
Decl *Def = FindAndMapDefinition(D, FoundFunction))
3845 FoundByLookup = FoundFunction;
3853 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3854 for (
auto *FoundDecl : FoundDecls) {
3855 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3858 if (
auto *FoundFunction = dyn_cast<FunctionDecl>(FoundDecl)) {
3863 if (
Decl *Def = FindAndMapDefinition(D, FoundFunction))
3865 FoundByLookup = FoundFunction;
3872 if (Importer.getToContext().getLangOpts().CPlusPlus)
3876 Importer.ToDiag(Loc, diag::warn_odr_function_type_inconsistent)
3877 << Name << D->
getType() << FoundFunction->getType();
3878 Importer.ToDiag(FoundFunction->getLocation(), diag::note_odr_value_here)
3879 << FoundFunction->getType();
3880 ConflictingDecls.push_back(FoundDecl);
3884 if (!ConflictingDecls.empty()) {
3886 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3888 Name = NameOrErr.get();
3890 return NameOrErr.takeError();
3900 if (FoundByLookup) {
3910 "Templated function mapped to non-templated?");
3911 Importer.MapImported(DescribedD,
3914 return Importer.MapImported(D, FoundByLookup);
3926 return std::move(Err);
3937 bool UsedDifferentProtoType =
false;
3939 QualType FromReturnTy = FromFPT->getReturnType();
3947 if (Importer.FindFunctionDeclImportCycle.isCycle(D)) {
3948 FromReturnTy = Importer.getFromContext().VoidTy;
3949 UsedDifferentProtoType =
true;
3960 FromEPI = DefaultEPI;
3961 UsedDifferentProtoType =
true;
3963 FromTy = Importer.getFromContext().getFunctionType(
3964 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
3965 FromTSI = Importer.getFromContext().getTrivialTypeSourceInfo(
3969 Error Err = Error::success();
3970 auto ScopedReturnTypeDeclCycleDetector =
3971 Importer.FindFunctionDeclImportCycle.makeScopedCycleDetection(D);
3982 return std::move(Err);
3988 Parameters.push_back(*ToPOrErr);
3990 return ToPOrErr.takeError();
3995 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
3997 importExplicitSpecifier(Err, FromConstructor->getExplicitSpecifier());
3999 return std::move(Err);
4001 if (FromConstructor->isInheritingConstructor()) {
4003 import(FromConstructor->getInheritedConstructor());
4004 if (!ImportedInheritedCtor)
4005 return ImportedInheritedCtor.takeError();
4006 ToInheritedConstructor = *ImportedInheritedCtor;
4008 if (GetImportedOrCreateDecl<CXXConstructorDecl>(
4010 ToInnerLocStart, NameInfo,
T, TInfo, ESpec, D->
UsesFPIntrin(),
4012 ToInheritedConstructor, TrailingRequiresClause))
4016 Error Err = Error::success();
4018 Err,
const_cast<FunctionDecl *
>(FromDtor->getOperatorDelete()));
4019 auto ToThisArg =
importChecked(Err, FromDtor->getOperatorDeleteThisArg());
4021 return std::move(Err);
4023 if (GetImportedOrCreateDecl<CXXDestructorDecl>(
4027 TrailingRequiresClause))
4034 dyn_cast<CXXConversionDecl>(D)) {
4036 importExplicitSpecifier(Err, FromConversion->getExplicitSpecifier());
4038 return std::move(Err);
4039 if (GetImportedOrCreateDecl<CXXConversionDecl>(
4045 }
else if (
auto *
Method = dyn_cast<CXXMethodDecl>(D)) {
4046 if (GetImportedOrCreateDecl<CXXMethodDecl>(
4048 ToInnerLocStart, NameInfo,
T, TInfo,
Method->getStorageClass(),
4052 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(D)) {
4054 importExplicitSpecifier(Err, Guide->getExplicitSpecifier());
4060 return std::move(Err);
4061 if (GetImportedOrCreateDecl<CXXDeductionGuideDecl>(
4062 ToFunction, D, Importer.getToContext(), DC, ToInnerLocStart, ESpec,
4063 NameInfo,
T, TInfo, ToEndLoc, Ctor,
4064 Guide->getDeductionCandidateKind(), TrailingRequiresClause,
4068 if (GetImportedOrCreateDecl(
4069 ToFunction, D, Importer.getToContext(), DC, ToInnerLocStart,
4077 if (FoundByLookup) {
4127 Importer.getToContext(), Lookups, Info->getFPFeatures(), Msg));
4131 for (
auto *Param : Parameters) {
4132 Param->setOwningFunction(ToFunction);
4135 LT->update(Param, Importer.getToContext().getTranslationUnitDecl());
4137 ToFunction->setParams(Parameters);
4144 for (
unsigned I = 0, N = Parameters.size(); I != N; ++I)
4145 ProtoLoc.setParam(I, Parameters[I]);
4151 auto ToFTOrErr =
import(FromFT);
4153 return ToFTOrErr.takeError();
4157 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
4158 if (
unsigned NumInitializers = FromConstructor->getNumCtorInitializers()) {
4162 FromConstructor->inits(), CtorInitializers))
4163 return std::move(Err);
4166 llvm::copy(CtorInitializers, Memory);
4168 ToCtor->setCtorInitializers(Memory);
4169 ToCtor->setNumCtorInitializers(NumInitializers);
4175 return std::move(Err);
4177 if (
auto *FromCXXMethod = dyn_cast<CXXMethodDecl>(D))
4180 return std::move(Err);
4186 return std::move(Err);
4190 if (UsedDifferentProtoType) {
4192 ToFunction->
setType(*TyOrErr);
4194 return TyOrErr.takeError();
4198 return TSIOrErr.takeError();
4203 addDeclToContexts(D, ToFunction);
4206 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4209 return ToRedeclOrErr.takeError();
4243 return std::move(Err);
4248 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4249 for (
auto *FoundDecl : FoundDecls) {
4250 if (
FieldDecl *FoundField = dyn_cast<FieldDecl>(FoundDecl)) {
4257 if (Importer.IsStructurallyEquivalent(D->
getType(),
4258 FoundField->getType())) {
4259 Importer.MapImported(D, FoundField);
4267 if (
ExpectedExpr ToInitializerOrErr =
import(FromInitializer)) {
4270 assert(FoundField->hasInClassInitializer() &&
4271 "Field should have an in-class initializer if it has an "
4272 "expression for it.");
4273 if (!FoundField->getInClassInitializer())
4274 FoundField->setInClassInitializer(*ToInitializerOrErr);
4276 return ToInitializerOrErr.takeError();
4283 Importer.ToDiag(Loc, diag::warn_odr_field_type_inconsistent)
4284 << Name << D->
getType() << FoundField->getType();
4285 Importer.ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4286 << FoundField->getType();
4292 Error Err = Error::success();
4298 return std::move(Err);
4299 const Type *ToCapturedVLAType =
nullptr;
4300 if (
Error Err = Importer.importInto(
4302 return std::move(Err);
4305 if (GetImportedOrCreateDecl(ToField, D, Importer.getToContext(), DC,
4307 ToType, ToTInfo, ToBitWidth, D->
isMutable(),
4314 if (ToCapturedVLAType)
4321 return std::move(Err);
4322 if (ToInitializer) {
4324 if (AlreadyImported)
4325 assert(ToInitializer == AlreadyImported &&
4326 "Duplicate import of in-class initializer.");
4341 return std::move(Err);
4346 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4347 for (
unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
4348 if (
auto *FoundField = dyn_cast<IndirectFieldDecl>(FoundDecls[I])) {
4355 if (Importer.IsStructurallyEquivalent(D->
getType(),
4356 FoundField->getType(),
4358 Importer.MapImported(D, FoundField);
4363 if (!Name && I < N-1)
4367 Importer.ToDiag(Loc, diag::warn_odr_field_type_inconsistent)
4368 << Name << D->
getType() << FoundField->getType();
4369 Importer.ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4370 << FoundField->getType();
4377 auto TypeOrErr =
import(D->
getType());
4379 return TypeOrErr.takeError();
4385 for (
auto *PI : D->
chain())
4387 NamedChain[i++] = *ToD;
4389 return ToD.takeError();
4393 if (GetImportedOrCreateDecl(ToIndirectField, D, Importer.getToContext(), DC,
4396 return ToIndirectField;
4401 return ToIndirectField;
4428 unsigned int FriendCount = 0;
4432 for (
FriendDecl *FoundFriend : RD->friends()) {
4433 if (FoundFriend == FD) {
4434 FriendPosition = FriendCount;
4441 assert(FriendPosition &&
"Friend decl not found in own parent.");
4442 return {FriendCount, *FriendPosition};
4445Expected<FriendDecl::FriendUnion>
4446ASTNodeImporter::importFriendUnion(FriendDecl *D) {
4448 NamedDecl *ToFriendD;
4450 return std::move(Err);
4463 return TSIOrErr.takeError();
4470 return std::move(Err);
4477 for (
FriendDecl *ImportedFriend : RD->friends())
4479 ImportedEquivalentFriends.push_back(ImportedFriend);
4484 assert(ImportedEquivalentFriends.size() <= CountAndPosition.
TotalCount &&
4485 "Class with non-matching friends is imported, ODR check wrong?");
4486 if (ImportedEquivalentFriends.size() == CountAndPosition.
TotalCount)
4487 return Importer.MapImported(
4488 D, ImportedEquivalentFriends[CountAndPosition.
IndexOfDecl]);
4492 auto ToFUOrErr = importFriendUnion(D);
4494 return ToFUOrErr.takeError();
4499 return LocationOrErr.takeError();
4501 if (!FriendLocOrErr)
4502 return FriendLocOrErr.takeError();
4504 if (!EllipsisLocOrErr)
4505 return EllipsisLocOrErr.takeError();
4508 if (GetImportedOrCreateDecl(FrD, D, Importer.getToContext(), DC,
4509 *LocationOrErr, ToFU, *FriendLocOrErr,
4522 return std::move(Err);
4526 for (
FriendDecl *ImportedFriend : RD->friends()) {
4527 auto *ImportedFriendTemplate = dyn_cast<FriendTemplateDecl>(ImportedFriend);
4528 if (ImportedFriendTemplate &&
4530 ImportedEquivalentFriends.push_back(ImportedFriendTemplate);
4535 assert(ImportedEquivalentFriends.size() <= CountAndPosition.
TotalCount &&
4536 "Class with non-matching friends is imported, ODR check wrong?");
4538 if (ImportedEquivalentFriends.size() == CountAndPosition.
TotalCount)
4539 return Importer.MapImported(
4540 D, ImportedEquivalentFriends[CountAndPosition.
IndexOfDecl]);
4545 auto ToFUOrErr = importFriendUnion(D);
4547 return ToFUOrErr.takeError();
4553 if (!FromTemplate.
isNull()) {
4555 return std::move(Err);
4561 return std::move(Err);
4565 return LocationOrErr.takeError();
4568 if (!FriendLocOrErr)
4569 return FriendLocOrErr.takeError();
4572 if (!EllipsisLocOrErr)
4573 return EllipsisLocOrErr.takeError();
4576 if (GetImportedOrCreateDecl(FTD, D, Importer.getToContext(), DC,
4577 *LocationOrErr, ToFU, *FriendLocOrErr, ToTPLs,
4578 *EllipsisLocOrErr, ToTemplate))
4594 return std::move(Err);
4599 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4600 for (
auto *FoundDecl : FoundDecls) {
4601 if (
ObjCIvarDecl *FoundIvar = dyn_cast<ObjCIvarDecl>(FoundDecl)) {
4602 if (Importer.IsStructurallyEquivalent(D->
getType(),
4603 FoundIvar->getType())) {
4604 Importer.MapImported(D, FoundIvar);
4608 Importer.ToDiag(Loc, diag::warn_odr_ivar_type_inconsistent)
4609 << Name << D->
getType() << FoundIvar->getType();
4610 Importer.ToDiag(FoundIvar->getLocation(), diag::note_odr_value_here)
4611 << FoundIvar->getType();
4617 Error Err = Error::success();
4623 return std::move(Err);
4626 if (GetImportedOrCreateDecl(
4629 ToType, ToTypeSourceInfo,
4641 auto RedeclIt = Redecls.begin();
4644 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
4647 return RedeclOrErr.takeError();
4649 assert(*RedeclIt == D);
4657 return std::move(Err);
4663 VarDecl *FoundByLookup =
nullptr;
4667 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4668 for (
auto *FoundDecl : FoundDecls) {
4669 if (!FoundDecl->isInIdentifierNamespace(IDNS))
4672 if (
auto *FoundVar = dyn_cast<VarDecl>(FoundDecl)) {
4675 if (Importer.IsStructurallyEquivalent(D->
getType(),
4676 FoundVar->getType())) {
4684 return Importer.MapImported(D, FoundDef);
4688 const VarDecl *FoundDInit =
nullptr;
4689 if (D->
getInit() && FoundVar->getAnyInitializer(FoundDInit))
4691 return Importer.MapImported(D,
const_cast<VarDecl*
>(FoundDInit));
4693 FoundByLookup = FoundVar;
4698 = Importer.getToContext().getAsArrayType(FoundVar->getType());
4700 = Importer.getToContext().getAsArrayType(D->
getType());
4701 if (FoundArray && TArray) {
4705 if (
auto TyOrErr =
import(D->
getType()))
4706 FoundVar->setType(*TyOrErr);
4708 return TyOrErr.takeError();
4710 FoundByLookup = FoundVar;
4714 FoundByLookup = FoundVar;
4719 Importer.ToDiag(Loc, diag::warn_odr_variable_type_inconsistent)
4720 << Name << D->
getType() << FoundVar->getType();
4721 Importer.ToDiag(FoundVar->getLocation(), diag::note_odr_value_here)
4722 << FoundVar->getType();
4723 ConflictingDecls.push_back(FoundDecl);
4727 if (!ConflictingDecls.empty()) {
4729 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
4731 Name = NameOrErr.get();
4733 return NameOrErr.takeError();
4737 Error Err = Error::success();
4743 return std::move(Err);
4746 if (
auto *FromDecomp = dyn_cast<DecompositionDecl>(D)) {
4750 return std::move(Err);
4752 if (GetImportedOrCreateDecl(
4753 ToDecomp, FromDecomp, Importer.getToContext(), DC, ToInnerLocStart,
4754 Loc, FromDecomp->getRSquareLoc(), ToType, ToTypeSourceInfo,
4760 if (GetImportedOrCreateDecl(ToVar, D, Importer.getToContext(), DC,
4761 ToInnerLocStart, Loc,
4776 if (FoundByLookup) {
4785 return ToVTOrErr.takeError();
4792 return ToInstOrErr.takeError();
4793 if (
ExpectedSLoc POIOrErr =
import(MSI->getPointOfInstantiation()))
4796 return POIOrErr.takeError();
4800 return std::move(Err);
4805 addDeclToContexts(D, ToVar);
4808 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4811 return RedeclOrErr.takeError();
4820 DeclContext *DC = Importer.getToContext().getTranslationUnitDecl();
4822 Error Err = Error::success();
4827 return std::move(Err);
4831 if (GetImportedOrCreateDecl(ToParm, D, Importer.getToContext(), DC,
4832 ToLocation, ToDeclName.getAsIdentifierInfo(),
4844 return LocOrErr.takeError();
4853 return ToDefArgOrErr.takeError();
4857 if (
auto ToDefArgOrErr =
import(FromParam->
getDefaultArg()))
4860 return ToDefArgOrErr.takeError();
4863 return Error::success();
4868 Error Err = Error::success();
4873 return std::move(Err);
4880 DeclContext *DC = Importer.getToContext().getTranslationUnitDecl();
4882 Error Err = Error::success();
4889 return std::move(Err);
4892 if (GetImportedOrCreateDecl(ToParm, D, Importer.getToContext(), DC,
4893 ToInnerLocStart, ToLocation,
4894 ToDeclName.getAsIdentifierInfo(), ToType,
4903 return std::move(Err);
4923 return std::move(Err);
4927 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4928 for (
auto *FoundDecl : FoundDecls) {
4929 if (
auto *FoundMethod = dyn_cast<ObjCMethodDecl>(FoundDecl)) {
4935 FoundMethod->getReturnType())) {
4936 Importer.ToDiag(Loc, diag::warn_odr_objc_method_result_type_inconsistent)
4938 << FoundMethod->getReturnType();
4939 Importer.ToDiag(FoundMethod->getLocation(),
4940 diag::note_odr_objc_method_here)
4947 if (D->
param_size() != FoundMethod->param_size()) {
4948 Importer.ToDiag(Loc, diag::warn_odr_objc_method_num_params_inconsistent)
4950 << D->
param_size() << FoundMethod->param_size();
4951 Importer.ToDiag(FoundMethod->getLocation(),
4952 diag::note_odr_objc_method_here)
4960 PEnd = D->
param_end(), FoundP = FoundMethod->param_begin();
4961 P != PEnd; ++
P, ++FoundP) {
4962 if (!Importer.IsStructurallyEquivalent((*P)->getType(),
4963 (*FoundP)->getType())) {
4964 Importer.FromDiag((*P)->getLocation(),
4965 diag::warn_odr_objc_method_param_type_inconsistent)
4967 << (*P)->getType() << (*FoundP)->getType();
4968 Importer.ToDiag((*FoundP)->getLocation(), diag::note_odr_value_here)
4969 << (*FoundP)->getType();
4977 if (D->
isVariadic() != FoundMethod->isVariadic()) {
4978 Importer.ToDiag(Loc, diag::warn_odr_objc_method_variadic_inconsistent)
4980 Importer.ToDiag(FoundMethod->getLocation(),
4981 diag::note_odr_objc_method_here)
4988 return Importer.MapImported(D, FoundMethod);
4992 Error Err = Error::success();
4995 auto ToReturnTypeSourceInfo =
4998 return std::move(Err);
5001 if (GetImportedOrCreateDecl(
5002 ToMethod, D, Importer.getToContext(), Loc, ToEndLoc,
5016 ToParams.push_back(*ToPOrErr);
5018 return ToPOrErr.takeError();
5022 for (
auto *ToParam : ToParams) {
5023 ToParam->setOwningFunction(ToMethod);
5031 return std::move(Err);
5033 ToMethod->
setMethodParams(Importer.getToContext(), ToParams, ToSelLocs);
5055 return std::move(Err);
5059 Error Err = Error::success();
5065 return std::move(Err);
5068 if (GetImportedOrCreateDecl(
5072 ToColonLoc, ToTypeSourceInfo))
5078 return std::move(Err);
5079 Result->setTypeForDecl(ToTypeForDecl);
5080 Result->setLexicalDeclContext(LexicalDC);
5091 return std::move(Err);
5097 return std::move(Err);
5105 Error Err = Error::success();
5111 return std::move(Err);
5113 if (GetImportedOrCreateDecl(ToCategory, D, Importer.getToContext(), DC,
5129 return PListOrErr.takeError();
5138 FromProto != FromProtoEnd;
5139 ++FromProto, ++FromProtoLoc) {
5141 Protocols.push_back(*ToProtoOrErr);
5143 return ToProtoOrErr.takeError();
5145 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5146 ProtocolLocs.push_back(*ToProtoLocOrErr);
5148 return ToProtoLocOrErr.takeError();
5153 ProtocolLocs.data(), Importer.getToContext());
5156 Importer.MapImported(D, ToCategory);
5161 return std::move(Err);
5169 return ToImplOrErr.takeError();
5181 return Error::success();
5194 FromProto != FromProtoEnd;
5195 ++FromProto, ++FromProtoLoc) {
5197 Protocols.push_back(*ToProtoOrErr);
5199 return ToProtoOrErr.takeError();
5201 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5202 ProtocolLocs.push_back(*ToProtoLocOrErr);
5204 return ToProtoLocOrErr.takeError();
5210 ProtocolLocs.data(), Importer.getToContext());
5217 return Error::success();
5227 return Importer.MapImported(D, *ImportedDefOrErr);
5229 return ImportedDefOrErr.takeError();
5238 return std::move(Err);
5243 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5244 for (
auto *FoundDecl : FoundDecls) {
5248 if ((MergeWithProtocol = dyn_cast<ObjCProtocolDecl>(FoundDecl)))
5255 if (!ToAtBeginLocOrErr)
5256 return ToAtBeginLocOrErr.takeError();
5258 if (GetImportedOrCreateDecl(ToProto, D, Importer.getToContext(), DC,
5267 Importer.MapImported(D, ToProto);
5271 return std::move(Err);
5279 return std::move(Err);
5282 if (!ExternLocOrErr)
5283 return ExternLocOrErr.takeError();
5287 return LangLocOrErr.takeError();
5292 if (GetImportedOrCreateDecl(ToLinkageSpec, D, Importer.getToContext(), DC,
5293 *ExternLocOrErr, *LangLocOrErr,
5295 return ToLinkageSpec;
5299 if (!RBraceLocOrErr)
5300 return RBraceLocOrErr.takeError();
5307 return ToLinkageSpec;
5318 return ToShadowOrErr.takeError();
5329 return std::move(Err);
5333 Error Err = Error::success();
5338 return std::move(Err);
5342 return std::move(Err);
5345 if (GetImportedOrCreateDecl(ToUsing, D, Importer.getToContext(), DC,
5346 ToUsingLoc, ToQualifierLoc, NameInfo,
5354 Importer.getFromContext().getInstantiatedFromUsingDecl(D)) {
5356 Importer.getToContext().setInstantiatedFromUsingDecl(
5357 ToUsing, *ToPatternOrErr);
5359 return ToPatternOrErr.takeError();
5371 return std::move(Err);
5375 Error Err = Error::success();
5381 return std::move(Err);
5384 if (GetImportedOrCreateDecl(ToUsingEnum, D, Importer.getToContext(), DC,
5385 ToUsingLoc, ToEnumLoc, ToNameLoc, ToEnumType))
5392 Importer.getFromContext().getInstantiatedFromUsingEnumDecl(D)) {
5394 Importer.getToContext().setInstantiatedFromUsingEnumDecl(ToUsingEnum,
5397 return ToPatternOrErr.takeError();
5409 return std::move(Err);
5414 if (!ToIntroducerOrErr)
5415 return ToIntroducerOrErr.takeError();
5419 return ToTargetOrErr.takeError();
5422 if (
auto *FromConstructorUsingShadow =
5423 dyn_cast<ConstructorUsingShadowDecl>(D)) {
5424 Error Err = Error::success();
5426 Err, FromConstructorUsingShadow->getNominatedBaseClassShadowDecl());
5428 return std::move(Err);
5434 if (GetImportedOrCreateDecl<ConstructorUsingShadowDecl>(
5435 ToShadow, D, Importer.getToContext(), DC, Loc,
5437 Nominated ? Nominated : *ToTargetOrErr,
5438 FromConstructorUsingShadow->constructsVirtualBase()))
5441 if (GetImportedOrCreateDecl(ToShadow, D, Importer.getToContext(), DC, Loc,
5442 Name, *ToIntroducerOrErr, *ToTargetOrErr))
5450 Importer.getFromContext().getInstantiatedFromUsingShadowDecl(D)) {
5452 Importer.getToContext().setInstantiatedFromUsingShadowDecl(
5453 ToShadow, *ToPatternOrErr);
5457 return ToPatternOrErr.takeError();
5471 return std::move(Err);
5476 if (!ToComAncestorOrErr)
5477 return ToComAncestorOrErr.takeError();
5479 Error Err = Error::success();
5482 auto ToNamespaceKeyLocation =
5487 return std::move(Err);
5490 if (GetImportedOrCreateDecl(ToUsingDir, D, Importer.getToContext(), DC,
5492 ToNamespaceKeyLocation,
5495 ToNominatedNamespace, *ToComAncestorOrErr))
5510 return std::move(Err);
5514 auto ToInstantiatedFromUsingOrErr =
5516 if (!ToInstantiatedFromUsingOrErr)
5517 return ToInstantiatedFromUsingOrErr.takeError();
5520 return std::move(Err);
5523 if (GetImportedOrCreateDecl(ToUsingPack, D, Importer.getToContext(), DC,
5528 addDeclToContexts(D, ToUsingPack);
5540 return std::move(Err);
5544 Error Err = Error::success();
5550 return std::move(Err);
5554 return std::move(Err);
5557 if (GetImportedOrCreateDecl(ToUsingValue, D, Importer.getToContext(), DC,
5558 ToUsingLoc, ToQualifierLoc, NameInfo,
5560 return ToUsingValue;
5566 return ToUsingValue;
5576 return std::move(Err);
5580 Error Err = Error::success();
5586 return std::move(Err);
5589 if (GetImportedOrCreateDecl(ToUsing, D, Importer.getToContext(), DC,
5590 ToUsingLoc, ToTypenameLoc,
5591 ToQualifierLoc, Loc, Name, ToEllipsisLoc))
5602 Decl* ToD =
nullptr;
5604#define BuiltinTemplate(BTName) \
5605 case BuiltinTemplateKind::BTK##BTName: \
5606 ToD = Importer.getToContext().get##BTName##Decl(); \
5608#include "clang/Basic/BuiltinTemplates.inc"
5610 assert(ToD &&
"BuiltinTemplateDecl of unsupported kind!");
5611 Importer.MapImported(D, ToD);
5621 if (
auto FromSuperOrErr =
import(FromSuper))
5622 FromSuper = *FromSuperOrErr;
5624 return FromSuperOrErr.takeError();
5628 if ((
bool)FromSuper != (
bool)ToSuper ||
5631 diag::warn_odr_objc_superclass_inconsistent)
5638 diag::note_odr_objc_missing_superclass);
5641 diag::note_odr_objc_superclass)
5645 diag::note_odr_objc_missing_superclass);
5651 return Error::success();
5662 return SuperTInfoOrErr.takeError();
5673 FromProto != FromProtoEnd;
5674 ++FromProto, ++FromProtoLoc) {
5676 Protocols.push_back(*ToProtoOrErr);
5678 return ToProtoOrErr.takeError();
5680 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5681 ProtocolLocs.push_back(*ToProtoLocOrErr);
5683 return ToProtoLocOrErr.takeError();
5689 ProtocolLocs.data(), Importer.getToContext());
5694 auto ToCatOrErr =
import(Cat);
5696 return ToCatOrErr.takeError();
5705 return ToImplOrErr.takeError();
5712 return Error::success();
5721 for (
auto *fromTypeParam : *list) {
5722 if (
auto toTypeParamOrErr =
import(fromTypeParam))
5723 toTypeParams.push_back(*toTypeParamOrErr);
5725 return toTypeParamOrErr.takeError();
5729 if (!LAngleLocOrErr)
5730 return LAngleLocOrErr.takeError();
5733 if (!RAngleLocOrErr)
5734 return RAngleLocOrErr.takeError();
5749 return Importer.MapImported(D, *ImportedDefOrErr);
5751 return ImportedDefOrErr.takeError();
5760 return std::move(Err);
5766 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5767 for (
auto *FoundDecl : FoundDecls) {
5771 if ((MergeWithIface = dyn_cast<ObjCInterfaceDecl>(FoundDecl)))
5779 if (!AtBeginLocOrErr)
5780 return AtBeginLocOrErr.takeError();
5782 if (GetImportedOrCreateDecl(
5783 ToIface, D, Importer.getToContext(), DC,
5791 Importer.MapImported(D, ToIface);
5794 if (
auto ToPListOrErr =
5798 return ToPListOrErr.takeError();
5802 return std::move(Err);
5811 return std::move(Err);
5817 return std::move(Err);
5819 Error Err = Error::success();
5824 return std::move(Err);
5826 if (GetImportedOrCreateDecl(
5827 ToImpl, D, Importer.getToContext(), DC,
5828 Importer.Import(D->
getIdentifier()), Category->getClassInterface(),
5829 ToLocation, ToAtStartLoc, ToCategoryNameLoc))
5834 Category->setImplementation(ToImpl);
5837 Importer.MapImported(D, ToImpl);
5839 return std::move(Err);
5849 return std::move(Err);
5854 return std::move(Err);
5862 return std::move(Err);
5864 Error Err = Error::success();
5871 return std::move(Err);
5873 if (GetImportedOrCreateDecl(Impl, D, Importer.getToContext(),
5882 Impl->setLexicalDeclContext(LexicalDC);
5896 Importer.ToDiag(Impl->getLocation(),
5897 diag::warn_odr_objc_superclass_inconsistent)
5901 if (Impl->getSuperClass())
5902 Importer.ToDiag(Impl->getLocation(),
5903 diag::note_odr_objc_superclass)
5904 << Impl->getSuperClass()->getDeclName();
5906 Importer.ToDiag(Impl->getLocation(),
5907 diag::note_odr_objc_missing_superclass);
5910 diag::note_odr_objc_superclass)
5914 diag::note_odr_objc_missing_superclass);
5922 return std::move(Err);
5934 return std::move(Err);
5939 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5940 for (
auto *FoundDecl : FoundDecls) {
5941 if (
auto *FoundProp = dyn_cast<ObjCPropertyDecl>(FoundDecl)) {
5948 if (!Importer.IsStructurallyEquivalent(D->
getType(),
5949 FoundProp->getType())) {
5950 Importer.ToDiag(Loc, diag::warn_odr_objc_property_type_inconsistent)
5951 << Name << D->
getType() << FoundProp->getType();
5952 Importer.ToDiag(FoundProp->getLocation(), diag::note_odr_value_here)
5953 << FoundProp->getType();
5961 Importer.MapImported(D, FoundProp);
5966 Error Err = Error::success();
5972 return std::move(Err);
5976 if (GetImportedOrCreateDecl(
5977 ToProperty, D, Importer.getToContext(), DC, Loc,
5979 ToLParenLoc, ToType,
5991 return std::move(Err);
6011 return std::move(Err);
6015 return std::move(Err);
6022 return std::move(Err);
6025 = InImpl->FindPropertyImplDecl(
Property->getIdentifier(),
6029 Error Err = Error::success();
6032 auto ToPropertyIvarDeclLoc =
6035 return std::move(Err);
6037 if (GetImportedOrCreateDecl(ToImpl, D, Importer.getToContext(), DC,
6041 ToPropertyIvarDeclLoc))
6051 diag::warn_odr_objc_property_impl_kind_inconsistent)
6056 diag::note_odr_objc_property_impl_kind)
6067 diag::warn_odr_objc_synthesize_ivar_inconsistent)
6072 diag::note_odr_objc_synthesize_ivar_here)
6079 Importer.MapImported(D, ToImpl);
6087 Error Err = Error::success();
6091 return std::move(Err);
6095 return Importer.ToContext.getTemplateParamObjectDecl(
T,
V);
6097 (void)GetImportedOrCreateSpecialDecl(ToD,
Create, D, ToType, ToValue);
6109 return BeginLocOrErr.takeError();
6113 return LocationOrErr.takeError();
6116 if (GetImportedOrCreateDecl(
6117 ToD, D, Importer.getToContext(),
6119 *BeginLocOrErr, *LocationOrErr,
6128 Error Err = Error::success();
6129 auto ToConceptRef =
importChecked(Err, TC->getConceptReference());
6130 auto ToIDC =
importChecked(Err, TC->getImmediatelyDeclaredConstraint());
6132 return std::move(Err);
6137 if (
Error Err = importTemplateParameterDefaultArgument(D, ToD))
6146 Error Err = Error::success();
6153 return std::move(Err);
6156 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(),
6158 ToInnerLocStart, ToLocation, D->
getDepth(),
6160 ToDeclName.getAsIdentifierInfo(), ToType,
6164 Err = importTemplateParameterDefaultArgument(D, ToD);
6173 bool IsCanonical =
false;
6174 if (
auto *CanonD = Importer.getFromContext()
6175 .findCanonicalTemplateTemplateParmDeclInternal(D);
6182 return NameOrErr.takeError();
6187 return LocationOrErr.takeError();
6191 if (!TemplateParamsOrErr)
6192 return TemplateParamsOrErr.takeError();
6195 if (GetImportedOrCreateDecl(
6196 ToD, D, Importer.getToContext(),
6203 if (
Error Err = importTemplateParameterDefaultArgument(D, ToD))
6207 return Importer.getToContext()
6208 .insertCanonicalTemplateTemplateParmDeclInternal(ToD);
6216 assert(D->getTemplatedDecl() &&
"Should be called on templates only");
6217 auto *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();
6218 if (!ToTemplatedDef)
6221 return cast_or_null<T>(TemplateWithDef);
6232 return std::move(Err);
6244 TD->getLexicalDeclContext()->isDependentContext();
6246 bool DependentFriend = IsDependentFriend(D);
6253 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6254 for (
auto *FoundDecl : FoundDecls) {
6259 auto *FoundTemplate = dyn_cast<ClassTemplateDecl>(FoundDecl);
6260 if (FoundTemplate) {
6265 bool IgnoreTemplateParmDepth =
6269 IgnoreTemplateParmDepth)) {
6270 if (DependentFriend || IsDependentFriend(FoundTemplate))
6276 return Importer.MapImported(D, TemplateWithDef);
6278 FoundByLookup = FoundTemplate;
6296 ConflictingDecls.push_back(FoundDecl);
6300 if (!ConflictingDecls.empty()) {
6303 ConflictingDecls.size());
6305 Name = NameOrErr.get();
6307 return NameOrErr.takeError();
6314 if (!TemplateParamsOrErr)
6315 return TemplateParamsOrErr.takeError();
6320 return std::move(Err);
6324 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), DC, Loc, Name,
6325 *TemplateParamsOrErr, ToTemplated))
6333 addDeclToContexts(D, D2);
6334 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6336 if (FoundByLookup) {
6350 "Found decl must have its templated decl set");
6353 if (ToTemplated != PrevTemplated)
6367 return std::move(Err);
6372 return std::move(Err);
6378 return std::move(Err);
6381 llvm::FoldingSetInsertToken InsertToken;
6384 dyn_cast<ClassTemplatePartialSpecializationDecl>(D);
6392 return ToTPListOrErr.takeError();
6393 ToTPList = *ToTPListOrErr;
6395 TemplateArgs, *ToTPListOrErr, InsertToken);
6403 Importer.MapImported(D, PrevDefinition);
6406 for (
auto *FromField : D->
fields()) {
6407 auto ToOrErr =
import(FromField);
6409 return ToOrErr.takeError();
6415 auto ToOrErr =
import(FromM);
6417 return ToOrErr.takeError();
6425 return PrevDefinition;
6436 return BeginLocOrErr.takeError();
6439 return IdLocOrErr.takeError();
6445 return std::move(Err);
6451 if (GetImportedOrCreateDecl<ClassTemplatePartialSpecializationDecl>(
6452 D2, D, Importer.getToContext(), D->
getTagKind(), DC, *BeginLocOrErr,
6453 *IdLocOrErr, ToTPList, ClassTemplate,
ArrayRef(TemplateArgs),
6455 cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl)))
6467 PartSpec2->setInstantiatedFromMember(*ToInstOrErr);
6469 return ToInstOrErr.takeError();
6471 updateLookupTableForTemplateParameters(*ToTPList);
6473 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), D->
getTagKind(),
6474 DC, *BeginLocOrErr, *IdLocOrErr, ClassTemplate,
6499 return BraceRangeOrErr.takeError();
6502 return std::move(Err);
6508 return LocOrErr.takeError();
6516 return LocOrErr.takeError();
6521 return LocOrErr.takeError();
6527 return POIOrErr.takeError();
6533 if (
auto *CTD = dyn_cast<ClassTemplateDecl *>(
P)) {
6534 if (
auto CTDorErr =
import(CTD))
6538 auto CTPSDOrErr =
import(CTPSD);
6540 return CTPSDOrErr.takeError();
6543 for (
unsigned I = 0; I < DArgs.
size(); ++I) {
6545 if (
auto ArgOrErr =
import(DArg))
6546 D2ArgsVec[I] = *ArgOrErr;
6548 return ArgOrErr.takeError();
6558 return std::move(Err);
6570 return std::move(Err);
6576 "Variable templates cannot be declared at function scope");
6579 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6581 for (
auto *FoundDecl : FoundDecls) {
6585 if (
VarTemplateDecl *FoundTemplate = dyn_cast<VarTemplateDecl>(FoundDecl)) {
6595 assert(FoundTemplate->getDeclContext()->isRecord() &&
6596 "Member variable template imported as non-member, "
6597 "inconsistent imported AST?");
6599 return Importer.MapImported(D, FoundDef);
6601 return Importer.MapImported(D, FoundTemplate);
6604 return Importer.MapImported(D, FoundDef);
6606 FoundByLookup = FoundTemplate;
6609 ConflictingDecls.push_back(FoundDecl);
6613 if (!ConflictingDecls.empty()) {
6616 ConflictingDecls.size());
6618 Name = NameOrErr.get();
6620 return NameOrErr.takeError();
6629 return TypeOrErr.takeError();
6634 return std::move(Err);
6638 if (!TemplateParamsOrErr)
6639 return TemplateParamsOrErr.takeError();
6642 if (GetImportedOrCreateDecl(ToVarTD, D, Importer.getToContext(), DC, Loc,
6643 Name, *TemplateParamsOrErr, ToTemplated))
6651 if (DC != Importer.getToContext().getTranslationUnitDecl())
6652 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6654 if (FoundByLookup) {
6658 auto *PrevTemplated =
6660 if (ToTemplated != PrevTemplated)
6675 auto RedeclIt = Redecls.begin();
6678 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
6681 return RedeclOrErr.takeError();
6683 assert(*RedeclIt == D);
6687 return std::move(Err);
6692 return std::move(Err);
6697 return BeginLocOrErr.takeError();
6701 return IdLocOrErr.takeError();
6707 return std::move(Err);
6710 llvm::FoldingSetInsertToken InsertToken;
6712 VarTemplate->findSpecialization(TemplateArgs, InsertToken);
6713 if (FoundSpecialization) {
6721 "Member variable template specialization imported as non-member, "
6722 "inconsistent imported AST?");
6724 return Importer.MapImported(D, FoundDef);
6726 return Importer.MapImported(D, FoundSpecialization);
6731 return Importer.MapImported(D, FoundDef);
6743 return std::move(Err);
6748 if (
auto *FromPartial = dyn_cast<PartVarSpecDecl>(D)) {
6749 auto ToTPListOrErr =
import(FromPartial->getTemplateParameters());
6751 return ToTPListOrErr.takeError();
6753 PartVarSpecDecl *ToPartial;
6754 if (GetImportedOrCreateDecl(ToPartial, D, Importer.getToContext(), DC,
6755 *BeginLocOrErr, *IdLocOrErr, *ToTPListOrErr,
6761 import(FromPartial->getInstantiatedFromMember()))
6762 ToPartial->setInstantiatedFromMember(*ToInstOrErr);
6764 return ToInstOrErr.takeError();
6766 if (FromPartial->isMemberSpecialization())
6767 ToPartial->setMemberSpecialization();
6775 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), DC,
6784 if (!
VarTemplate->findSpecialization(TemplateArgs, InsertToken))
6789 return std::move(Err);
6794 return TInfoOrErr.takeError();
6801 return POIOrErr.takeError();
6812 return LocOrErr.takeError();
6820 return std::move(Err);
6822 if (FoundSpecialization)
6825 addDeclToContexts(D, D2);
6828 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
6831 return RedeclOrErr.takeError();
6845 return std::move(Err);
6857 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6858 for (
auto *FoundDecl : FoundDecls) {
6859 if (!FoundDecl->isInIdentifierNamespace(IDNS))
6862 if (
auto *FoundTemplate = dyn_cast<FunctionTemplateDecl>(FoundDecl)) {
6869 return Importer.MapImported(D, TemplateWithDef);
6871 FoundByLookup = FoundTemplate;
6881 return ParamsOrErr.takeError();
6886 return std::move(Err);
6903 OldParamDC.reserve(Params->
size());
6904 llvm::transform(*Params, std::back_inserter(OldParamDC),
6908 if (GetImportedOrCreateDecl(ToFunc, D, Importer.getToContext(), DC, Loc, Name,
6909 Params, TemplatedFD))
6923 ToFunc->setLexicalDeclContext(LexicalDC);
6924 addDeclToContexts(D, ToFunc);
6927 if (LT && !OldParamDC.empty()) {
6928 for (
unsigned int I = 0; I < OldParamDC.size(); ++I)
6929 LT->updateForced(Params->
getParam(I), OldParamDC[I]);
6932 if (FoundByLookup) {
6937 "Found decl must have its templated decl set");
6938 auto *PrevTemplated =
6940 if (TemplatedFD != PrevTemplated)
6957 return std::move(Err);
6960 if (GetImportedOrCreateDecl(To, D, Importer.getToContext(), DC, LocationOrErr,
6961 NameDeclOrErr, ToTemplateParameters,
6975 return std::move(Err);
6978 if (GetImportedOrCreateDecl(To, D, Importer.getToContext(), DC, RequiresLoc))
6991 return std::move(Err);
6995 return std::move(Err);
6998 if (GetImportedOrCreateDecl(To, D, Importer.getToContext(), DC, ToSL, ToArgs))
7010 Importer.FromDiag(S->
getBeginLoc(), diag::err_unsupported_ast_node)
7017 if (Importer.returnWithErrorInTest())
7024 Names.push_back(ToII);
7027 for (
unsigned I = 0, E = S->
getNumInputs(); I != E; I++) {
7031 Names.push_back(ToII);
7037 Clobbers.push_back(*ClobberOrErr);
7039 return ClobberOrErr.takeError();
7046 Constraints.push_back(*OutputOrErr);
7048 return OutputOrErr.takeError();
7051 for (
unsigned I = 0, E = S->
getNumInputs(); I != E; I++) {
7053 Constraints.push_back(*InputOrErr);
7055 return InputOrErr.takeError();
7061 return std::move(Err);
7065 return std::move(Err);
7069 return std::move(Err);
7073 return AsmLocOrErr.takeError();
7076 return AsmStrOrErr.takeError();
7078 if (!RParenLocOrErr)
7079 return RParenLocOrErr.takeError();
7081 return new (Importer.getToContext())
GCCAsmStmt(
7082 Importer.getToContext(),
7100 Error Err = Error::success();
7105 return std::move(Err);
7106 return new (Importer.getToContext())
DeclStmt(ToDG, ToBeginLoc, ToEndLoc);
7111 if (!ToSemiLocOrErr)
7112 return ToSemiLocOrErr.takeError();
7113 return new (Importer.getToContext())
NullStmt(
7121 return std::move(Err);
7124 if (!ToLBracLocOrErr)
7125 return ToLBracLocOrErr.takeError();
7128 if (!ToRBracLocOrErr)
7129 return ToRBracLocOrErr.takeError();
7134 *ToLBracLocOrErr, *ToRBracLocOrErr);
7139 Error Err = Error::success();
7147 return std::move(Err);
7150 ToCaseLoc, ToEllipsisLoc, ToColonLoc);
7151 ToStmt->setSubStmt(ToSubStmt);
7158 Error Err = Error::success();
7163 return std::move(Err);
7166 ToDefaultLoc, ToColonLoc, ToSubStmt);
7171 Error Err = Error::success();
7176 return std::move(Err);
7178 return new (Importer.getToContext())
LabelStmt(
7179 ToIdentLoc, ToLabelDecl, ToSubStmt);
7184 if (!ToAttrLocOrErr)
7185 return ToAttrLocOrErr.takeError();
7189 return std::move(Err);
7191 if (!ToSubStmtOrErr)
7192 return ToSubStmtOrErr.takeError();
7195 Importer.getToContext(), *ToAttrLocOrErr, ToAttrs, *ToSubStmtOrErr);
7200 Error Err = Error::success();
7211 return std::move(Err);
7214 ToInit, ToConditionVariable, ToCond, ToLParenLoc,
7215 ToRParenLoc, ToThen, ToElseLoc, ToElse);
7220 Error Err = Error::success();
7229 return std::move(Err);
7233 ToCond, ToLParenLoc, ToRParenLoc);
7234 ToStmt->setBody(ToBody);
7235 ToStmt->setSwitchLoc(ToSwitchLoc);
7243 return ToSCOrErr.takeError();
7244 if (LastChainedSwitchCase)
7247 ToStmt->setSwitchCaseList(*ToSCOrErr);
7248 LastChainedSwitchCase = *ToSCOrErr;
7256 Error Err = Error::success();
7264 return std::move(Err);
7267 ToBody, ToWhileLoc, ToLParenLoc, ToRParenLoc);
7272 Error Err = Error::success();
7279 return std::move(Err);
7281 return new (Importer.getToContext())
DoStmt(
7282 ToBody, ToCond, ToDoLoc, ToWhileLoc, ToRParenLoc);
7287 Error Err = Error::success();
7297 return std::move(Err);
7299 return new (Importer.getToContext())
ForStmt(
7300 Importer.getToContext(),
7301 ToInit, ToCond, ToConditionVariable, ToInc, ToBody, ToForLoc, ToLParenLoc,
7307 Error Err = Error::success();
7312 return std::move(Err);
7314 return new (Importer.getToContext())
GotoStmt(
7315 ToLabel, ToGotoLoc, ToLabelLoc);
7320 Error Err = Error::success();
7325 return std::move(Err);
7328 ToGotoLoc, ToStarLoc, ToTarget);
7331template <
typename StmtClass>
7334 Error Err = Error::success();
7335 auto ToLoc = NodeImporter.
importChecked(Err, S->getKwLoc());
7336 auto ToLabelLoc = S->hasLabelTarget()
7339 auto ToDecl = S->hasLabelTarget()
7343 return std::move(Err);
7344 return new (Importer.
getToContext()) StmtClass(ToLoc, ToLabelLoc, ToDecl);
7357 Error Err = Error::success();
7362 return std::move(Err);
7370 Error Err = Error::success();
7375 return std::move(Err);
7378 ToCatchLoc, ToExceptionDecl, ToHandlerBlock);
7384 return ToTryLocOrErr.takeError();
7387 if (!ToTryBlockOrErr)
7388 return ToTryBlockOrErr.takeError();
7391 for (
unsigned HI = 0, HE = S->
getNumHandlers(); HI != HE; ++HI) {
7393 if (
auto ToHandlerOrErr =
import(FromHandler))
7394 ToHandlers[HI] = *ToHandlerOrErr;
7396 return ToHandlerOrErr.takeError();
7405 Error Err = Error::success();
7419 return std::move(Err);
7422 ToInit, ToRangeStmt, ToBeginStmt, ToEndStmt, ToCond, ToInc, ToLoopVarStmt,
7423 ToBody, ToForLoc, ToCoawaitLoc, ToColonLoc, ToRParenLoc);
7428 Error Err = Error::success();
7436 return std::move(Err);
7441 Importer.getToContext(), ToESD, ToInit, ToExpansionVar, ToLParenLoc,
7442 ToColonLoc, ToRParenLoc);
7449 return std::move(Err);
7452 Importer.getToContext(), ToESD, ToInit, ToExpansionVar, ToRange,
7453 ToBegin, ToIter, ToLParenLoc, ToColonLoc, ToRParenLoc);
7457 auto ToDecompositionDeclStmt =
7460 return std::move(Err);
7463 Importer.getToContext(), ToESD, ToInit, ToExpansionVar,
7464 ToDecompositionDeclStmt, ToLParenLoc, ToColonLoc, ToRParenLoc);
7468 auto ToExpansionInitializer =
7471 return std::move(Err);
7473 Importer.getToContext(), ToESD, ToInit, ToExpansionVar,
7474 ToExpansionInitializer, ToLParenLoc, ToColonLoc, ToRParenLoc);
7478 llvm_unreachable(
"invalid pattern kind");
7483 Error Err = Error::success();
7493 return std::move(Err);
7496 Importer.getToContext(), ToParent, ToInstantiations, ToSharedStmts,
7502 Error Err = Error::success();
7509 return std::move(Err);
7520 Error Err = Error::success();
7526 return std::move(Err);
7529 ToAtCatchLoc, ToRParenLoc, ToCatchParamDecl, ToCatchBody);
7534 if (!ToAtFinallyLocOrErr)
7535 return ToAtFinallyLocOrErr.takeError();
7537 if (!ToAtFinallyStmtOrErr)
7538 return ToAtFinallyStmtOrErr.takeError();
7540 *ToAtFinallyStmtOrErr);
7545 Error Err = Error::success();
7550 return std::move(Err);
7555 if (
ExpectedStmt ToCatchStmtOrErr =
import(FromCatchStmt))
7556 ToCatchStmts[CI] = *ToCatchStmtOrErr;
7558 return ToCatchStmtOrErr.takeError();
7562 ToAtTryLoc, ToTryBody,
7563 ToCatchStmts.begin(), ToCatchStmts.size(),
7570 Error Err = Error::success();
7575 return std::move(Err);
7578 ToAtSynchronizedLoc, ToSynchExpr, ToSynchBody);
7583 if (!ToThrowLocOrErr)
7584 return ToThrowLocOrErr.takeError();
7586 if (!ToThrowExprOrErr)
7587 return ToThrowExprOrErr.takeError();
7589 *ToThrowLocOrErr, *ToThrowExprOrErr);
7596 return ToAtLocOrErr.takeError();
7598 if (!ToSubStmtOrErr)
7599 return ToSubStmtOrErr.takeError();
7608 Importer.FromDiag(E->
getBeginLoc(), diag::err_unsupported_ast_node)
7614 Error Err = Error::success();
7619 return std::move(Err);
7621 if (!ParentContextOrErr)
7622 return ParentContextOrErr.takeError();
7624 return new (Importer.getToContext())
7626 RParenLoc, *ParentContextOrErr);
7631 Error Err = Error::success();
7638 return std::move(Err);
7640 return new (Importer.getToContext())
7641 VAArgExpr(ToBuiltinLoc, ToSubExpr, ToWrittenTypeInfo, ToRParenLoc, ToType,
7647 Error Err = Error::success();
7655 return std::move(Err);
7664 return new (Importer.getToContext())
7665 ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType,
VK, OK,
7666 ToRParenLoc, CondIsTrue);
7670 Error Err = Error::success();
7677 return std::move(Err);
7680 Importer.getToContext(), ToSrcExpr, ToTSI, ToType, E->
getValueKind(),
7686 Error Err = Error::success();
7694 ToSubExprs.resize(NumSubExprs);
7697 return std::move(Err);
7700 Importer.getToContext(), ToSubExprs, ToType, ToBeginLoc, ToRParenLoc);
7706 return TypeOrErr.takeError();
7710 return BeginLocOrErr.takeError();
7712 return new (Importer.getToContext())
GNUNullExpr(*TypeOrErr, *BeginLocOrErr);
7717 Error Err = Error::success();
7719 Expr *ToControllingExpr =
nullptr;
7725 assert((ToControllingExpr || ToControllingType) &&
7726 "Either the controlling expr or type must be nonnull");
7730 return std::move(Err);
7735 return std::move(Err);
7740 return std::move(Err);
7742 const ASTContext &ToCtx = Importer.getToContext();
7744 if (ToControllingExpr) {
7746 ToCtx, ToGenericLoc, ToControllingExpr,
ArrayRef(ToAssocTypes),
7747 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7751 ToCtx, ToGenericLoc, ToControllingType,
ArrayRef(ToAssocTypes),
7752 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7756 if (ToControllingExpr) {
7758 ToCtx, ToGenericLoc, ToControllingExpr,
ArrayRef(ToAssocTypes),
7759 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7763 ToCtx, ToGenericLoc, ToControllingType,
ArrayRef(ToAssocTypes),
7764 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7770 Error Err = Error::success();
7775 return std::move(Err);
7784 Error Err = Error::success();
7791 return std::move(Err);
7797 return FoundDOrErr.takeError();
7798 ToFoundD = *FoundDOrErr;
7807 return std::move(Err);
7808 ToResInfo = &ToTAInfo;
7812 Importer.getToContext(), ToQualifierLoc, ToTemplateKeywordLoc, ToDecl,
7816 ToE->setHadMultipleCandidates(
true);
7824 return TypeOrErr.takeError();
7832 return ToInitOrErr.takeError();
7835 if (!ToEqualOrColonLocOrErr)
7836 return ToEqualOrColonLocOrErr.takeError();
7842 ToIndexExprs[I - 1] = *ToArgOrErr;
7844 return ToArgOrErr.takeError();
7849 return std::move(Err);
7852 Importer.getToContext(), ToDesignators,
7853 ToIndexExprs, *ToEqualOrColonLocOrErr,
7861 return ToTypeOrErr.takeError();
7864 if (!ToLocationOrErr)
7865 return ToLocationOrErr.takeError();
7868 *ToTypeOrErr, *ToLocationOrErr);
7874 return ToTypeOrErr.takeError();
7877 if (!ToLocationOrErr)
7878 return ToLocationOrErr.takeError();
7881 Importer.getToContext(), E->
getValue(), *ToTypeOrErr, *ToLocationOrErr);
7888 return ToTypeOrErr.takeError();
7891 if (!ToLocationOrErr)
7892 return ToLocationOrErr.takeError();
7896 *ToTypeOrErr, *ToLocationOrErr);
7900 auto ToTypeOrErr =
import(E->
getType());
7902 return ToTypeOrErr.takeError();
7905 if (!ToSubExprOrErr)
7906 return ToSubExprOrErr.takeError();
7909 *ToSubExprOrErr, *ToTypeOrErr);
7913 auto ToTypeOrErr =
import(E->
getType());
7915 return ToTypeOrErr.takeError();
7918 if (!ToLocationOrErr)
7919 return ToLocationOrErr.takeError();
7922 Importer.getToContext(), E->
getValue(), *ToTypeOrErr, *ToLocationOrErr,
7923 Importer.getToContext().getFixedPointScale(*ToTypeOrErr));
7929 return ToTypeOrErr.takeError();
7932 if (!ToLocationOrErr)
7933 return ToLocationOrErr.takeError();
7942 return ToTypeOrErr.takeError();
7947 return std::move(Err);
7956 Error Err = Error::success();
7962 return std::move(Err);
7965 ToLParenLoc, ToTypeSourceInfo, ToType, E->
getValueKind(),
7971 Error Err = Error::success();
7976 return std::move(Err);
7982 return std::move(Err);
7984 return new (Importer.getToContext())
AtomicExpr(
7986 ToBuiltinLoc, ToExprs, ToType, E->
getOp(), ToRParenLoc);
7990 Error Err = Error::success();
7996 return std::move(Err);
7999 ToAmpAmpLoc, ToLabelLoc, ToLabel, ToType);
8002 Error Err = Error::success();
8006 return std::move(Err);
8011 Error Err = Error::success();
8016 return std::move(Err);
8018 return new (Importer.getToContext())
8019 ParenExpr(ToLParen, ToRParen, ToSubExpr);
8025 return std::move(Err);
8028 if (!ToLParenLocOrErr)
8029 return ToLParenLocOrErr.takeError();
8032 if (!ToRParenLocOrErr)
8033 return ToRParenLocOrErr.takeError();
8036 ToExprs, *ToRParenLocOrErr);
8040 Error Err = Error::success();
8046 return std::move(Err);
8048 return new (Importer.getToContext())
8049 StmtExpr(ToSubStmt, ToType, ToLParenLoc, ToRParenLoc,
8054 Error Err = Error::success();
8059 return std::move(Err);
8063 UO->setType(ToType);
8064 UO->setSubExpr(ToSubExpr);
8066 UO->setOperatorLoc(ToOperatorLoc);
8077 Error Err = Error::success();
8082 return std::move(Err);
8087 if (!ToArgumentTypeInfoOrErr)
8088 return ToArgumentTypeInfoOrErr.takeError();
8091 E->
getKind(), *ToArgumentTypeInfoOrErr, ToType, ToOperatorLoc,
8096 if (!ToArgumentExprOrErr)
8097 return ToArgumentExprOrErr.takeError();
8100 E->
getKind(), *ToArgumentExprOrErr, ToType, ToOperatorLoc, ToRParenLoc);
8104 Error Err = Error::success();
8110 return std::move(Err);
8113 Importer.getToContext(), ToLHS, ToRHS, E->
getOpcode(), ToType,
8119 Error Err = Error::success();
8127 return std::move(Err);
8130 ToCond, ToQuestionLoc, ToLHS, ToColonLoc, ToRHS, ToType,
8136 Error Err = Error::success();
8146 return std::move(Err);
8149 ToCommon, ToOpaqueValue, ToCond, ToTrueExpr, ToFalseExpr,
8156 Error Err = Error::success();
8159 return std::move(Err);
8161 return new (Importer.getToContext())
8166 Error Err = Error::success();
8168 auto ToQueriedTypeSourceInfo =
8174 return std::move(Err);
8178 ToDimensionExpression, ToEndLoc, ToType);
8182 Error Err = Error::success();
8188 return std::move(Err);
8196 Error Err = Error::success();
8201 return std::move(Err);
8208 Error Err = Error::success();
8214 return std::move(Err);
8223 Error Err = Error::success();
8228 auto ToComputationResultType =
8232 return std::move(Err);
8235 Importer.getToContext(), ToLHS, ToRHS, E->
getOpcode(), ToType,
8238 ToComputationLHSType, ToComputationResultType);
8245 if (
auto SpecOrErr =
import(*I))
8246 Path.push_back(*SpecOrErr);
8248 return SpecOrErr.takeError();
8256 return ToTypeOrErr.takeError();
8259 if (!ToSubExprOrErr)
8260 return ToSubExprOrErr.takeError();
8263 if (!ToBasePathOrErr)
8264 return ToBasePathOrErr.takeError();
8267 Importer.getToContext(), *ToTypeOrErr, E->
getCastKind(), *ToSubExprOrErr,
8272 Error Err = Error::success();
8277 return std::move(Err);
8280 if (!ToBasePathOrErr)
8281 return ToBasePathOrErr.takeError();
8285 case Stmt::CStyleCastExprClass: {
8287 ExpectedSLoc ToLParenLocOrErr =
import(CCE->getLParenLoc());
8288 if (!ToLParenLocOrErr)
8289 return ToLParenLocOrErr.takeError();
8290 ExpectedSLoc ToRParenLocOrErr =
import(CCE->getRParenLoc());
8291 if (!ToRParenLocOrErr)
8292 return ToRParenLocOrErr.takeError();
8295 ToSubExpr, ToBasePath, CCE->getFPFeatures(), ToTypeInfoAsWritten,
8296 *ToLParenLocOrErr, *ToRParenLocOrErr);
8299 case Stmt::CXXFunctionalCastExprClass: {
8301 ExpectedSLoc ToLParenLocOrErr =
import(FCE->getLParenLoc());
8302 if (!ToLParenLocOrErr)
8303 return ToLParenLocOrErr.takeError();
8304 ExpectedSLoc ToRParenLocOrErr =
import(FCE->getRParenLoc());
8305 if (!ToRParenLocOrErr)
8306 return ToRParenLocOrErr.takeError();
8308 Importer.getToContext(), ToType, E->
getValueKind(), ToTypeInfoAsWritten,
8309 E->
getCastKind(), ToSubExpr, ToBasePath, FCE->getFPFeatures(),
8310 *ToLParenLocOrErr, *ToRParenLocOrErr);
8313 case Stmt::ObjCBridgedCastExprClass: {
8315 ExpectedSLoc ToLParenLocOrErr =
import(OCE->getLParenLoc());
8316 if (!ToLParenLocOrErr)
8317 return ToLParenLocOrErr.takeError();
8318 ExpectedSLoc ToBridgeKeywordLocOrErr =
import(OCE->getBridgeKeywordLoc());
8319 if (!ToBridgeKeywordLocOrErr)
8320 return ToBridgeKeywordLocOrErr.takeError();
8322 *ToLParenLocOrErr, OCE->getBridgeKind(), E->
getCastKind(),
8323 *ToBridgeKeywordLocOrErr, ToTypeInfoAsWritten, ToSubExpr);
8325 case Stmt::BuiltinBitCastExprClass: {
8327 ExpectedSLoc ToKWLocOrErr =
import(BBC->getBeginLoc());
8329 return ToKWLocOrErr.takeError();
8330 ExpectedSLoc ToRParenLocOrErr =
import(BBC->getEndLoc());
8331 if (!ToRParenLocOrErr)
8332 return ToRParenLocOrErr.takeError();
8335 ToTypeInfoAsWritten, *ToKWLocOrErr, *ToRParenLocOrErr);
8338 llvm_unreachable(
"Cast expression of unsupported type!");
8351 Error Err = Error::success();
8355 return std::move(Err);
8364 auto ToBSOrErr =
import(FromNode.
getBase());
8366 return ToBSOrErr.takeError();
8371 auto ToFieldOrErr =
import(FromNode.
getField());
8373 return ToFieldOrErr.takeError();
8374 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, *ToFieldOrErr, ToEndLoc));
8379 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, ToII, ToEndLoc));
8388 if (!ToIndexExprOrErr)
8389 return ToIndexExprOrErr.takeError();
8390 ToExprs[I] = *ToIndexExprOrErr;
8393 Error Err = Error::success();
8399 return std::move(Err);
8402 Importer.getToContext(), ToType, ToOperatorLoc, ToTypeSourceInfo, ToNodes,
8403 ToExprs, ToRParenLoc);
8407 Error Err = Error::success();
8413 return std::move(Err);
8422 ToType, ToOperand, ToCanThrow, ToBeginLoc, ToEndLoc);
8426 Error Err = Error::success();
8431 return std::move(Err);
8439 if (!ToUsedLocOrErr)
8440 return ToUsedLocOrErr.takeError();
8442 auto ToParamOrErr =
import(E->
getParam());
8444 return ToParamOrErr.takeError();
8446 auto UsedContextOrErr = Importer.ImportContext(E->
getUsedContext());
8447 if (!UsedContextOrErr)
8448 return UsedContextOrErr.takeError();
8458 std::optional<ParmVarDecl *> FromParam =
8459 Importer.getImportedFromDecl(ToParam);
8460 assert(FromParam &&
"ParmVarDecl was not imported?");
8463 return std::move(Err);
8465 Expr *RewrittenInit =
nullptr;
8469 return ExprOrErr.takeError();
8470 RewrittenInit = ExprOrErr.get();
8473 *ToParamOrErr, RewrittenInit,
8479 Error Err = Error::success();
8484 return std::move(Err);
8487 ToType, ToTypeSourceInfo, ToRParenLoc);
8493 if (!ToSubExprOrErr)
8494 return ToSubExprOrErr.takeError();
8496 auto ToDtorOrErr =
import(E->
getTemporary()->getDestructor());
8498 return ToDtorOrErr.takeError();
8508 Error Err = Error::success();
8514 return std::move(Err);
8518 return std::move(Err);
8521 Importer.getToContext(), ToConstructor, ToType, ToTypeSourceInfo, ToArgs,
8531 return std::move(Err);
8533 Error Err = Error::success();
8537 return std::move(Err);
8541 if (GetImportedOrCreateDecl(To, D, Temporary, ExtendingDecl,
8552 Error Err = Error::success();
8556 auto ToMaterializedDecl =
8559 return std::move(Err);
8561 if (!ToTemporaryExpr)
8562 ToTemporaryExpr =
cast<Expr>(ToMaterializedDecl->getTemporaryExpr());
8566 ToMaterializedDecl);
8572 Error Err = Error::success();
8576 return std::move(Err);
8578 return new (Importer.getToContext())
8583 Error Err = Error::success();
8589 return std::move(Err);
8598 ToPartialArguments))
8599 return std::move(Err);
8603 Importer.getToContext(), ToOperatorLoc, ToPack, ToPackLoc, ToRParenLoc,
8604 Length, ToPartialArguments);
8609 Error Err = Error::success();
8616 auto ToAllocatedTypeSourceInfo =
8621 return std::move(Err);
8626 return std::move(Err);
8629 Importer.getToContext(), E->
isGlobalNew(), ToOperatorNew,
8633 ToAllocatedTypeSourceInfo, ToSourceRange, ToDirectInitRange);
8637 Error Err = Error::success();
8643 return std::move(Err);
8652 Error Err = Error::success();
8658 return std::move(Err);
8662 return std::move(Err);
8665 Importer.getToContext(), ToType, ToLocation, ToConstructor,
8669 ToParenOrBraceRange);
8676 if (!ToSubExprOrErr)
8677 return ToSubExprOrErr.takeError();
8681 return std::move(Err);
8689 Error Err = Error::success();
8694 return std::move(Err);
8698 return std::move(Err);
8708 return ToTypeOrErr.takeError();
8711 if (!ToLocationOrErr)
8712 return ToLocationOrErr.takeError();
8721 return ToTypeOrErr.takeError();
8724 if (!ToLocationOrErr)
8725 return ToLocationOrErr.takeError();
8728 *ToTypeOrErr, *ToLocationOrErr);
8732 Error Err = Error::success();
8736 return std::move(Err);
8742 Error Err = Error::success();
8753 return std::move(Err);
8765 return std::move(Err);
8766 ResInfo = &ToTAInfo;
8770 ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8771 ToMemberDecl, ToFoundDecl, ToMemberNameInfo,
8778 Error Err = Error::success();
8786 return std::move(Err);
8792 if (!ToDestroyedTypeLocOrErr)
8793 return ToDestroyedTypeLocOrErr.takeError();
8799 return ToTIOrErr.takeError();
8803 Importer.getToContext(), ToBase, E->
isArrow(), ToOperatorLoc,
8804 ToQualifierLoc, ToScopeTypeInfo, ToColonColonLoc, ToTildeLoc, Storage);
8809 Error Err = Error::success();
8814 auto ToFirstQualifierFoundInScope =
8817 return std::move(Err);
8819 Expr *ToBase =
nullptr;
8822 ToBase = *ToBaseOrErr;
8824 return ToBaseOrErr.takeError();
8833 return std::move(Err);
8834 ResInfo = &ToTAInfo;
8839 return std::move(Err);
8845 return std::move(Err);
8848 Importer.getToContext(), ToBase, ToType, E->
isArrow(), ToOperatorLoc,
8849 ToQualifierLoc, ToTemplateKeywordLoc, ToFirstQualifierFoundInScope,
8850 ToMemberNameInfo, ResInfo);
8855 Error Err = Error::success();
8860 return std::move(Err);
8864 return std::move(Err);
8870 return std::move(Err);
8878 Error Err = Error::success();
8886 return std::move(Err);
8890 return std::move(Err);
8897 return std::move(Err);
8898 ResInfo = &ToTAInfo;
8902 Importer.getToContext(), ToQualifierLoc, ToTemplateKeywordLoc,
8903 ToNameInfo, ResInfo);
8908 Error Err = Error::success();
8914 return std::move(Err);
8919 return std::move(Err);
8922 Importer.getToContext(), ToType, ToTypeSourceInfo, ToLParenLoc,
8929 if (!ToNamingClassOrErr)
8930 return ToNamingClassOrErr.takeError();
8933 if (!ToQualifierLocOrErr)
8934 return ToQualifierLocOrErr.takeError();
8936 Error Err = Error::success();
8940 return std::move(Err);
8945 return std::move(Err);
8948 for (
auto *D : E->
decls())
8949 if (
auto ToDOrErr =
import(D))
8952 return ToDOrErr.takeError();
8959 return std::move(Err);
8962 if (!ToTemplateKeywordLocOrErr)
8963 return ToTemplateKeywordLocOrErr.takeError();
8965 const bool KnownDependent =
8967 ExprDependence::TypeValue;
8969 Importer.getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8970 *ToTemplateKeywordLocOrErr, ToNameInfo, E->
requiresADL(), &ToTAInfo,
8971 ToDecls.
begin(), ToDecls.
end(), KnownDependent,
8976 Importer.getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8984 Error Err = Error::success();
8992 return std::move(Err);
8997 return std::move(Err);
9001 if (
auto ToDOrErr =
import(D))
9004 return ToDOrErr.takeError();
9012 return std::move(Err);
9013 ResInfo = &ToTAInfo;
9016 Expr *ToBase =
nullptr;
9019 ToBase = *ToBaseOrErr;
9021 return ToBaseOrErr.takeError();
9026 E->
isArrow(), ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
9027 ToNameInfo, ResInfo, ToDecls.
begin(), ToDecls.
end());
9031 Error Err = Error::success();
9036 return std::move(Err);
9041 return std::move(Err);
9043 if (
const auto *OCE = dyn_cast<CXXOperatorCallExpr>(E)) {
9045 Importer.getToContext(), OCE->getOperator(), ToCallee, ToArgs, ToType,
9046 OCE->getValueKind(), ToRParenLoc, OCE->getFPFeatures(),
9047 OCE->getADLCallKind());
9057 auto ToClassOrErr =
import(FromClass);
9059 return ToClassOrErr.takeError();
9064 return ToCallOpOrErr.takeError();
9068 return std::move(Err);
9070 Error Err = Error::success();
9075 return std::move(Err);
9086 Error Err = Error::success();
9091 return std::move(Err);
9095 return std::move(Err);
9106 return ToFillerOrErr.takeError();
9110 if (
auto ToFDOrErr =
import(FromFD))
9113 return ToFDOrErr.takeError();
9117 if (
auto ToSyntFormOrErr =
import(SyntForm))
9120 return ToSyntFormOrErr.takeError();
9134 return ToTypeOrErr.takeError();
9137 if (!ToSubExprOrErr)
9138 return ToSubExprOrErr.takeError();
9141 *ToTypeOrErr, *ToSubExprOrErr);
9146 Error Err = Error::success();
9151 return std::move(Err);
9159 Error Err = Error::success();
9164 return std::move(Err);
9167 ToType, ToCommonExpr, ToSubExpr);
9173 return ToTypeOrErr.takeError();
9179 if (!ToBeginLocOrErr)
9180 return ToBeginLocOrErr.takeError();
9182 auto ToFieldOrErr =
import(E->
getField());
9184 return ToFieldOrErr.takeError();
9186 auto UsedContextOrErr = Importer.ImportContext(E->
getUsedContext());
9187 if (!UsedContextOrErr)
9188 return UsedContextOrErr.takeError();
9192 "Field should have in-class initializer if there is a default init "
9193 "expression that uses it.");
9198 auto ToInClassInitializerOrErr =
9199 import(E->
getField()->getInClassInitializer());
9200 if (!ToInClassInitializerOrErr)
9201 return ToInClassInitializerOrErr.takeError();
9205 Expr *RewrittenInit =
nullptr;
9209 return ExprOrErr.takeError();
9210 RewrittenInit = ExprOrErr.get();
9214 ToField, *UsedContextOrErr, RewrittenInit);
9218 Error Err = Error::success();
9226 return std::move(Err);
9231 if (!ToBasePathOrErr)
9232 return ToBasePathOrErr.takeError();
9234 if (
auto CCE = dyn_cast<CXXStaticCastExpr>(E)) {
9236 Importer.getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9237 ToTypeInfoAsWritten, CCE->getFPFeatures(), ToOperatorLoc, ToRParenLoc,
9241 Importer.getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9242 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9245 Importer.getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9246 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9249 Importer.getToContext(), ToType,
VK, ToSubExpr, ToTypeInfoAsWritten,
9250 ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9252 llvm_unreachable(
"Unknown cast type");
9253 return make_error<ASTImportError>();
9259 Error Err = Error::success();
9266 return std::move(Err);
9269 ToType, E->
getValueKind(), ToNameLoc, ToReplacement, ToAssociatedDecl,
9274 Error Err = Error::success();
9279 return std::move(Err);
9283 return std::move(Err);
9290 E->
getTrait(), ToArgs, ToEndLoc, ToValue);
9300 return ToTypeOrErr.takeError();
9303 if (!ToSourceRangeOrErr)
9304 return ToSourceRangeOrErr.takeError();
9309 *ToTypeOrErr, *ToTSIOrErr, *ToSourceRangeOrErr);
9311 return ToTSIOrErr.takeError();
9315 if (!ToExprOperandOrErr)
9316 return ToExprOperandOrErr.takeError();
9319 *ToTypeOrErr, *ToExprOperandOrErr, *ToSourceRangeOrErr);
9323 Error Err = Error::success();
9334 return std::move(Err);
9336 return new (Importer.getToContext())
9342 Error Err = Error::success();
9350 return std::move(Err);
9354 return std::move(Err);
9359 return std::move(Err);
9361 LParenLoc, LocalParameters, RParenLoc,
9362 Requirements, RBraceLoc);
9367 Error Err = Error::success();
9371 return std::move(Err);
9374 Importer.getToContext(),
CL,
9379 return std::move(Err);
9381 Importer.getToContext(),
CL,
9387 Error Err = Error::success();
9393 return std::move(Err);
9396 ToType, E->
getValueKind(), ToPackLoc, ToArgPack, ToAssociatedDecl,
9403 return std::move(Err);
9406 return ToSyntOrErr.takeError();
9413 Error Err = Error::success();
9419 return std::move(Err);
9423 return std::move(Err);
9426 ToInitLoc, ToBeginLoc, ToEndLoc);
9431 Error Err = Error::success();
9435 return std::move(Err);
9437 return new (Importer.getToContext())
9443 Error ImportErrors = Error::success();
9445 if (
auto ImportedOrErr =
import(FromOverriddenMethod))
9447 (*ImportedOrErr)->getCanonicalDecl()));
9450 joinErrors(std::move(ImportErrors), ImportedOrErr.takeError());
9452 return ImportErrors;
9458 std::shared_ptr<ASTImporterSharedState> SharedState)
9459 : SharedState(SharedState), ToContext(ToContext), FromContext(FromContext),
9460 ToFileManager(ToFileManager), FromFileManager(FromFileManager),
9465 this->SharedState = std::make_shared<ASTImporterSharedState>();
9468 ImportedDecls[FromContext.getTranslationUnitDecl()] =
9469 ToContext.getTranslationUnitDecl();
9476 "Try to get field index for non-field.");
9480 return std::nullopt;
9483 for (
const auto *D : Owner->decls()) {
9491 llvm_unreachable(
"Field was not found in its parent context.");
9493 return std::nullopt;
9496ASTImporter::FoundDeclsTy
9506 if (SharedState->getLookupTable()) {
9514 dyn_cast<NamespaceDecl>(ReDC));
9515 for (
auto *D : NSChain) {
9517 SharedState->getLookupTable()->lookup(dyn_cast<NamespaceDecl>(D),
9524 SharedState->getLookupTable()->lookup(ReDC, Name);
9525 return FoundDeclsTy(LookupResult.begin(), LookupResult.end());
9529 FoundDeclsTy
Result(NoloadLookupResult.
begin(), NoloadLookupResult.
end());
9546void ASTImporter::AddToLookupTable(
Decl *ToD) {
9547 SharedState->addDeclToLookup(ToD);
9553 return Importer.
Visit(FromD);
9562 if (
auto *CLE = dyn_cast<CompoundLiteralExpr *>(From)) {
9577 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
9578 ImportedTypes.find(FromT);
9579 if (Pos != ImportedTypes.end())
9586 return ToTOrErr.takeError();
9589 ImportedTypes[FromT] = ToTOrErr->getTypePtr();
9591 return ToTOrErr->getTypePtr();
9600 return ToTyOrErr.takeError();
9613 return TOrErr.takeError();
9616 return BeginLocOrErr.takeError();
9618 return ToContext.getTrivialTypeSourceInfo(*TOrErr, *BeginLocOrErr);
9625template <
typename T>
struct AttrArgImporter {
9626 AttrArgImporter(
const AttrArgImporter<T> &) =
delete;
9627 AttrArgImporter(AttrArgImporter<T> &&) =
default;
9628 AttrArgImporter<T> &operator=(
const AttrArgImporter<T> &) =
delete;
9629 AttrArgImporter<T> &operator=(AttrArgImporter<T> &&) =
default;
9632 : To(I.importChecked(Err, From)) {}
9634 const T &value() {
return To; }
9645template <
typename T>
struct AttrArgArrayImporter {
9646 AttrArgArrayImporter(
const AttrArgArrayImporter<T> &) =
delete;
9647 AttrArgArrayImporter(AttrArgArrayImporter<T> &&) =
default;
9648 AttrArgArrayImporter<T> &operator=(
const AttrArgArrayImporter<T> &) =
delete;
9649 AttrArgArrayImporter<T> &operator=(AttrArgArrayImporter<T> &&) =
default;
9651 AttrArgArrayImporter(ASTNodeImporter &I,
Error &Err,
9652 const llvm::iterator_range<T *> &From,
9653 unsigned ArraySize) {
9656 To.reserve(ArraySize);
9660 T *value() {
return To.data(); }
9663 llvm::SmallVector<T, 2> To;
9667 Error Err{Error::success()};
9668 Attr *ToAttr =
nullptr;
9669 ASTImporter &Importer;
9670 ASTNodeImporter NImporter;
9673 AttrImporter(ASTImporter &I) : Importer(I), NImporter(I) {}
9678 template <
class T> AttrArgImporter<T> importArg(
const T &From) {
9679 return AttrArgImporter<T>(NImporter, Err, From);
9685 template <
typename T>
9686 AttrArgArrayImporter<T> importArrayArg(
const llvm::iterator_range<T *> &From,
9687 unsigned ArraySize) {
9688 return AttrArgArrayImporter<T>(NImporter, Err, From, ArraySize);
9699 template <
typename T,
typename... Arg>
9700 void importAttr(
const T *FromAttr, Arg &&...ImportedArg) {
9701 static_assert(std::is_base_of<Attr, T>::value,
9702 "T should be subclass of Attr.");
9703 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9705 const IdentifierInfo *ToAttrName = Importer.
Import(FromAttr->getAttrName());
9706 const IdentifierInfo *ToScopeName =
9707 Importer.
Import(FromAttr->getScopeName());
9708 SourceRange ToAttrRange =
9710 SourceLocation ToScopeLoc =
9716 AttributeCommonInfo ToI(
9717 ToAttrName, AttributeScopeInfo(ToScopeName, ToScopeLoc), ToAttrRange,
9718 FromAttr->getParsedKind(), FromAttr->getForm());
9722 std::forward<Arg>(ImportedArg)..., ToI);
9726 if (
auto *ToInheritableAttr = dyn_cast<InheritableAttr>(ToAttr))
9727 ToInheritableAttr->setInherited(FromAttr->isInherited());
9733 void cloneAttr(
const Attr *FromAttr) {
9734 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9746 llvm::Expected<Attr *> getResult() && {
9748 return std::move(Err);
9749 assert(ToAttr &&
"Attribute should be created.");
9756 AttrImporter AI(*
this);
9759 switch (FromAttr->
getKind()) {
9760 case attr::Aligned: {
9762 if (From->isAlignmentExpr())
9763 AI.importAttr(From,
true, AI.importArg(From->getAlignmentExpr()).value());
9765 AI.importAttr(From,
false,
9766 AI.importArg(From->getAlignmentType()).value());
9770 case attr::AlignValue: {
9772 AI.importAttr(From, AI.importArg(From->getAlignment()).value());
9776 case attr::Format: {
9778 AI.importAttr(From,
Import(From->getType()), From->getFormatIdx(),
9779 From->getFirstArg());
9783 case attr::EnableIf: {
9785 AI.importAttr(From, AI.importArg(From->getCond()).value(),
9786 From->getMessage());
9790 case attr::AssertCapability: {
9793 AI.importArrayArg(From->args(), From->args_size()).value(),
9797 case attr::AcquireCapability: {
9800 AI.importArrayArg(From->args(), From->args_size()).value(),
9804 case attr::TryAcquireCapability: {
9806 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9807 AI.importArrayArg(From->args(), From->args_size()).value(),
9811 case attr::ReleaseCapability: {
9814 AI.importArrayArg(From->args(), From->args_size()).value(),
9818 case attr::RequiresCapability: {
9821 AI.importArrayArg(From->args(), From->args_size()).value(),
9825 case attr::GuardedBy: {
9828 AI.importArrayArg(From->args(), From->args_size()).value(),
9832 case attr::PtGuardedBy: {
9835 AI.importArrayArg(From->args(), From->args_size()).value(),
9839 case attr::AcquiredAfter: {
9842 AI.importArrayArg(From->args(), From->args_size()).value(),
9846 case attr::AcquiredBefore: {
9849 AI.importArrayArg(From->args(), From->args_size()).value(),
9853 case attr::LockReturned: {
9855 AI.importAttr(From, AI.importArg(From->getArg()).value());
9858 case attr::LocksExcluded: {
9861 AI.importArrayArg(From->args(), From->args_size()).value(),
9869 AI.cloneAttr(FromAttr);
9874 return std::move(AI).getResult();
9878 return ImportedDecls.lookup(FromD);
9882 auto FromDPos = ImportedFromDecls.find(ToD);
9883 if (FromDPos == ImportedFromDecls.end())
9893 ImportPath.push(FromD);
9894 llvm::scope_exit ImportPathBuilder([
this]() { ImportPath.pop(); });
9899 return make_error<ASTImportError>(*
Error);
9905 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9907 return make_error<ASTImportError>(*
Error);
9914 if (ImportPath.hasCycleAtBack())
9915 SavedImportPaths[FromD].push_back(ImportPath.copyCycleAtBack());
9924 auto Pos = ImportedDecls.find(FromD);
9925 bool ToDWasCreated = Pos != ImportedDecls.end();
9929 Decl *CreatedToD = ToDWasCreated ? Pos->second :
nullptr;
9930 if (ToDWasCreated) {
9933 auto *ToD = CreatedToD;
9934 ImportedDecls.erase(Pos);
9939 if (
const auto *FromTD = dyn_cast<TagDecl>(FromD)) {
9940 if (
const Type *FromTy =
9942 ImportedTypes.erase(FromTy);
9956 auto PosF = ImportedFromDecls.find(ToD);
9957 if (PosF != ImportedFromDecls.end()) {
9962 SharedState->removeDeclFromLookup(ToD);
9963 ImportedFromDecls.erase(PosF);
9975 handleAllErrors(ToDOrErr.takeError(),
9980 SharedState->setImportDeclError(CreatedToD, ErrOut);
9984 for (
const auto &Path : SavedImportPaths[FromD]) {
9987 Decl *PrevFromDi = FromD;
9988 for (
Decl *FromDi : Path) {
9990 if (FromDi == FromD)
9997 PrevFromDi = FromDi;
10000 if (
const auto *FromTDi = dyn_cast<TagDecl>(FromDi)) {
10001 if (
const Type *FromTyi =
10003 ImportedTypes.erase(FromTyi);
10009 auto Ii = ImportedDecls.find(FromDi);
10010 if (Ii != ImportedDecls.end())
10011 SharedState->setImportDeclError(Ii->second, ErrOut);
10016 SavedImportPaths.erase(FromD);
10019 return make_error<ASTImportError>(ErrOut);
10031 return make_error<ASTImportError>(*Err);
10037 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
10039 return make_error<ASTImportError>(*
Error);
10042 assert(ImportedDecls.count(FromD) != 0 &&
"Missing call to MapImported?");
10046 auto ToAttrOrErr =
Import(FromAttr);
10050 return ToAttrOrErr.takeError();
10057 SavedImportPaths.erase(FromD);
10072 return ToDCOrErr.takeError();
10077 if (
auto *ToRecord = dyn_cast<RecordDecl>(ToDC)) {
10079 if (ToRecord->isCompleteDefinition())
10087 if (FromRecord->getASTContext().getExternalSource() &&
10088 !FromRecord->isCompleteDefinition())
10089 FromRecord->getASTContext().getExternalSource()->CompleteType(FromRecord);
10091 if (FromRecord->isCompleteDefinition())
10094 return std::move(Err);
10095 }
else if (
auto *ToEnum = dyn_cast<EnumDecl>(ToDC)) {
10097 if (ToEnum->isCompleteDefinition()) {
10099 }
else if (FromEnum->isCompleteDefinition()) {
10102 return std::move(Err);
10106 }
else if (
auto *ToClass = dyn_cast<ObjCInterfaceDecl>(ToDC)) {
10108 if (ToClass->getDefinition()) {
10113 return std::move(Err);
10117 }
else if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(ToDC)) {
10119 if (ToProto->getDefinition()) {
10124 return std::move(Err);
10135 return cast_or_null<Expr>(*ToSOrErr);
10137 return ToSOrErr.takeError();
10145 llvm::DenseMap<Stmt *, Stmt *>::iterator Pos = ImportedStmts.find(FromS);
10146 if (Pos != ImportedStmts.end())
10147 return Pos->second;
10155 if (
auto *ToE = dyn_cast<Expr>(*ToSOrErr)) {
10159 ToE->setValueKind(FromE->getValueKind());
10160 ToE->setObjectKind(FromE->getObjectKind());
10161 ToE->setDependence(FromE->getDependence());
10165 ImportedStmts[FromS] = *ToSOrErr;
10176 auto NSOrErr =
Import(Namespace);
10178 return NSOrErr.takeError();
10179 auto PrefixOrErr =
Import(Prefix);
10181 return PrefixOrErr.takeError();
10189 return RDOrErr.takeError();
10194 return TyOrErr.takeError();
10197 llvm_unreachable(
"Invalid nested name specifier kind");
10209 NestedNames.push_back(NNS);
10215 while (!NestedNames.empty()) {
10216 NNS = NestedNames.pop_back_val();
10219 return std::move(Err);
10226 return std::move(Err);
10230 return std::move(Err);
10236 ToLocalBeginLoc, ToLocalEndLoc);
10242 return std::move(Err);
10255 if (!ToSourceRangeOrErr)
10256 return ToSourceRangeOrErr.takeError();
10259 ToSourceRangeOrErr->getBegin(),
10260 ToSourceRangeOrErr->getEnd());
10264 llvm_unreachable(
"unexpected null nested name specifier");
10277 return ToTemplateOrErr.takeError();
10282 for (
auto *I : *FromStorage) {
10283 if (
auto ToOrErr =
Import(I))
10286 return ToOrErr.takeError();
10288 return ToContext.getOverloadedTemplateName(ToTemplates.
begin(),
10289 ToTemplates.
end());
10295 if (!DeclNameOrErr)
10296 return DeclNameOrErr.takeError();
10297 return ToContext.getAssumedTemplateName(*DeclNameOrErr);
10303 if (!QualifierOrErr)
10304 return QualifierOrErr.takeError();
10307 return TNOrErr.takeError();
10308 return ToContext.getQualifiedTemplateName(
10315 if (!QualifierOrErr)
10316 return QualifierOrErr.takeError();
10317 return ToContext.getDependentTemplateName(
10325 if (!ReplacementOrErr)
10326 return ReplacementOrErr.takeError();
10329 if (!AssociatedDeclOrErr)
10330 return AssociatedDeclOrErr.takeError();
10332 return ToContext.getSubstTemplateTemplateParm(
10333 *ReplacementOrErr, *AssociatedDeclOrErr, Subst->
getIndex(),
10341 auto ArgPackOrErr =
10344 return ArgPackOrErr.takeError();
10347 if (!AssociatedDeclOrErr)
10348 return AssociatedDeclOrErr.takeError();
10350 return ToContext.getSubstTemplateTemplateParmPack(
10351 *ArgPackOrErr, *AssociatedDeclOrErr, SubstPack->
getIndex(),
10358 return PatternOrErr.takeError();
10361 if (!IndexExprOrErr)
10362 return IndexExprOrErr.takeError();
10366 auto ExpansionOrErr =
Import(
T);
10367 if (!ExpansionOrErr)
10368 return ExpansionOrErr.takeError();
10369 Expansions.push_back(*ExpansionOrErr);
10372 return ToContext.getPackIndexingTemplateName(
10378 return UsingOrError.takeError();
10382 llvm_unreachable(
"Unexpected DeducedTemplate");
10385 llvm_unreachable(
"Invalid template name kind");
10397 if (!ToFileIDOrErr)
10398 return ToFileIDOrErr.takeError();
10406 return std::move(Err);
10408 return std::move(Err);
10414 llvm::DenseMap<FileID, FileID>::iterator Pos = ImportedFileIDs.find(FromID);
10415 if (Pos != ImportedFileIDs.end())
10416 return Pos->second;
10428 return ToSpLoc.takeError();
10431 return ToExLocS.takeError();
10441 return ToExLocE.takeError();
10447 if (!IsBuiltin && !
Cache->BufferOverridden) {
10451 return ToIncludeLoc.takeError();
10462 if (
Cache->OrigEntry &&
Cache->OrigEntry->getDir()) {
10468 ToFileManager.getOptionalFileRef(
Cache->OrigEntry->getName());
10473 ToID = ToSM.
createFileID(*Entry, ToIncludeLocOrFakeLoc,
10480 std::optional<llvm::MemoryBufferRef> FromBuf =
10481 Cache->getBufferOrNone(FromContext.getDiagnostics(),
10486 std::unique_ptr<llvm::MemoryBuffer> ToBuf =
10487 llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(),
10488 FromBuf->getBufferIdentifier());
10494 assert(ToID.
isValid() &&
"Unexpected invalid fileID was created.");
10496 ImportedFileIDs[FromID] = ToID;
10503 return ToExprOrErr.takeError();
10506 if (!LParenLocOrErr)
10507 return LParenLocOrErr.takeError();
10510 if (!RParenLocOrErr)
10511 return RParenLocOrErr.takeError();
10516 return ToTInfoOrErr.takeError();
10521 return std::move(Err);
10524 ToContext, *ToTInfoOrErr, From->
isBaseVirtual(), *LParenLocOrErr,
10525 *ToExprOrErr, *RParenLocOrErr, EllipsisLoc);
10529 return ToFieldOrErr.takeError();
10532 if (!MemberLocOrErr)
10533 return MemberLocOrErr.takeError();
10536 ToContext, cast_or_null<FieldDecl>(*ToFieldOrErr), *MemberLocOrErr,
10537 *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10540 if (!ToIFieldOrErr)
10541 return ToIFieldOrErr.takeError();
10544 if (!MemberLocOrErr)
10545 return MemberLocOrErr.takeError();
10548 ToContext, cast_or_null<IndirectFieldDecl>(*ToIFieldOrErr),
10549 *MemberLocOrErr, *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10553 return ToTInfoOrErr.takeError();
10555 return new (ToContext)
10557 *ToExprOrErr, *RParenLocOrErr);
10560 return make_error<ASTImportError>();
10566 auto Pos = ImportedCXXBaseSpecifiers.find(BaseSpec);
10567 if (Pos != ImportedCXXBaseSpecifiers.end())
10568 return Pos->second;
10571 if (!ToSourceRange)
10572 return ToSourceRange.takeError();
10575 return ToTSI.takeError();
10577 if (!ToEllipsisLoc)
10578 return ToEllipsisLoc.takeError();
10582 ImportedCXXBaseSpecifiers[BaseSpec] =
Imported;
10594 return ToOrErr.takeError();
10595 Decl *To = *ToOrErr;
10600 if (
auto *ToRecord = dyn_cast<RecordDecl>(To)) {
10601 if (!ToRecord->getDefinition()) {
10608 if (
auto *ToEnum = dyn_cast<EnumDecl>(To)) {
10609 if (!ToEnum->getDefinition()) {
10615 if (
auto *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
10616 if (!ToIFace->getDefinition()) {
10623 if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
10624 if (!ToProto->getDefinition()) {
10648 return ToSelOrErr.takeError();
10652 return ToContext.DeclarationNames.getCXXConstructorName(
10653 ToContext.getCanonicalType(*ToTyOrErr));
10655 return ToTyOrErr.takeError();
10660 return ToContext.DeclarationNames.getCXXDestructorName(
10661 ToContext.getCanonicalType(*ToTyOrErr));
10663 return ToTyOrErr.takeError();
10668 return ToContext.DeclarationNames.getCXXDeductionGuideName(
10671 return ToTemplateOrErr.takeError();
10676 return ToContext.DeclarationNames.getCXXConversionFunctionName(
10677 ToContext.getCanonicalType(*ToTyOrErr));
10679 return ToTyOrErr.takeError();
10683 return ToContext.DeclarationNames.getCXXOperatorName(
10687 return ToContext.DeclarationNames.getCXXLiteralOperatorName(
10695 llvm_unreachable(
"Invalid DeclarationName Kind!");
10723 for (
unsigned I = 1, N = FromSel.
getNumArgs(); I < N; ++I)
10725 return ToContext.Selectors.getSelector(FromSel.
getNumArgs(), Idents.data());
10731 llvm::Error Err = llvm::Error::success();
10732 auto ImportLoop = [&](
const APValue *From,
APValue *To,
unsigned Size) {
10733 for (
unsigned Idx = 0; Idx < Size; Idx++) {
10738 switch (FromValue.
getKind()) {
10752 ImportLoop(((
const APValue::Vec *)(
const char *)&FromValue.Data)->Elts,
10758 llvm_unreachable(
"Matrix APValue import not yet supported");
10762 ImportLoop(((
const APValue::Arr *)(
const char *)&FromValue.Data)->Elts,
10763 ((
const APValue::Arr *)(
const char *)&
Result.Data)->Elts,
10771 ((
const APValue::StructData *)(
const char *)&FromValue.Data)->Elts,
10772 ((
const APValue::StructData *)(
const char *)&
Result.Data)->Elts,
10781 return std::move(Err);
10786 Result.MakeAddrLabelDiff();
10790 return std::move(Err);
10796 const Decl *ImpMemPtrDecl =
10799 return std::move(Err);
10801 Result.setMemberPointerUninit(
10810 return std::move(Err);
10820 "in C++20 dynamic allocation are transient so they shouldn't "
10821 "appear in the AST");
10823 if (
const auto *E =
10825 FromElemTy = E->getType();
10828 return std::move(Err);
10838 return std::move(Err);
10850 return std::move(Err);
10863 for (
unsigned LoopIdx = 0; LoopIdx < PathLength; LoopIdx++) {
10865 const Decl *FromDecl =
10866 FromPath[LoopIdx].getAsBaseOrMember().getPointer();
10869 return std::move(Err);
10870 if (
auto *RD = dyn_cast<CXXRecordDecl>(FromDecl))
10871 FromElemTy = Importer.FromContext.getCanonicalTagType(RD);
10875 ImpDecl, FromPath[LoopIdx].getAsBaseOrMember().getInt()));
10878 Importer.FromContext.getAsArrayType(FromElemTy)->getElementType();
10880 FromPath[LoopIdx].getAsArrayIndex());
10899 return std::move(Err);
10908 return std::move(Err);
10916 unsigned NumDecls) {
10926 if (LastDiagFromFrom)
10927 ToContext.getDiagnostics().notePriorDiagnosticFrom(
10928 FromContext.getDiagnostics());
10929 LastDiagFromFrom =
false;
10930 return ToContext.getDiagnostics().Report(Loc, DiagID);
10934 if (!LastDiagFromFrom)
10935 FromContext.getDiagnostics().notePriorDiagnosticFrom(
10936 ToContext.getDiagnostics());
10937 LastDiagFromFrom =
true;
10938 return FromContext.getDiagnostics().Report(Loc, DiagID);
10942 if (
auto *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
10943 if (!ID->getDefinition())
10944 ID->startDefinition();
10946 else if (
auto *PD = dyn_cast<ObjCProtocolDecl>(D)) {
10947 if (!PD->getDefinition())
10948 PD->startDefinition();
10950 else if (
auto *TD = dyn_cast<TagDecl>(D)) {
10951 if (!TD->getDefinition() && !TD->isBeingDefined()) {
10952 TD->startDefinition();
10953 TD->setCompleteDefinition(
true);
10957 assert(0 &&
"CompleteDecl called on a Decl that can't be completed");
10962 auto [Pos, Inserted] = ImportedDecls.try_emplace(From, To);
10963 assert((Inserted || Pos->second == To) &&
10964 "Try to import an already imported Decl");
10966 return Pos->second;
10969 ImportedFromDecls[To] = From;
10974 AddToLookupTable(To);
10978std::optional<ASTImportError>
10980 auto Pos = ImportDeclErrors.find(FromD);
10981 if (Pos != ImportDeclErrors.end())
10982 return Pos->second;
10984 return std::nullopt;
10988 auto InsertRes = ImportDeclErrors.insert({From,
Error});
10992 assert(InsertRes.second || InsertRes.first->second.Error ==
Error.Error);
10997 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
10999 if (Pos != ImportedTypes.end()) {
11001 if (ToContext.hasSameType(*ToFromOrErr, To))
11004 llvm::consumeError(ToFromOrErr.takeError());
11009 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 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 void * getReflectionOpaqueOperand() 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
ReflectionKind getReflectionOperandKind() 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 & getFromContext() const
Retrieve the context that AST nodes are being imported from.
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 VisitCXXReflectExpr(CXXReflectExpr *E)
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)
ExpectedDecl VisitFriendTemplateDecl(FriendTemplateDecl *D)
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)
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 VisitDependentTemplateIdExpr(DependentTemplateIdExpr *E)
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.
void setDecomposedDecl(DecompositionDecl *Decomposed)
Set the decomposed variable for this BindingDecl.
Expr * getBinding() const
Get the expression to which this declaration is bound.
DecompositionDecl * getDecomposedDecl() const
Get the decomposition declaration that this binding represents a decomposition of.
void setBinding(QualType DeclaredType, Expr *Binding)
Set the binding for this BindingDecl, along with its declared type (which should be a possibly-cv-qua...
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()
Represents a C++26 reflect expression [expr.reflect].
SourceLocation getOperatorLoc() const
Returns location of the '^^'-operator.
const TypeSourceInfo * getTypeSourceInfo() const
static CXXReflectExpr * Create(ASTContext &C, SourceLocation OperatorLoc, const TypeSourceInfo *TSI)
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
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.
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, llvm::FoldingSetInsertToken &InsertToken)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
ClassTemplateDecl * getMostRecentDecl()
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, llvm::FoldingSetInsertToken &InsertToken)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary class pattern.
void AddSpecialization(ClassTemplateSpecializationDecl *D, llvm::FoldingSetInsertToken InsertToken)
Insert the specified specialization knowing that it is not already in.
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, llvm::FoldingSetInsertToken InsertToken)
Insert the specified partial specialization knowing that it is not already in.
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
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateName NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
TemplateName 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...
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
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
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.
A template-id naming a variable template or a concept through a template template parameter.
static DependentTemplateIdExpr * Create(const ASTContext &Context, const DeclarationNameInfo &NameInfo, TemplateName Name, const TemplateArgumentListInfo &TemplateArgs)
const DeclarationNameInfo & getNameInfo() const
ArrayRef< TemplateArgumentLoc > template_arguments() const
SourceLocation getRAngleLoc() const
DeclarationName getName() const
TemplateName getTemplateName() const
SourceLocation getNameLoc() const
SourceLocation getLAngleLoc() const
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
SourceLocation getEllipsisLoc() const
Retrieves the location of the '...', if present.
virtual 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...
Declaration of a friend template.
TemplateName getFriendTemplateName() const
FriendTemplateEntityKind getFriendKind() const
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
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)
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.
A structure for storing a pack-index-template-name ([temp.names]).
bool isFullySubstituted() const
TemplateName getPattern() const
Expr * getIndexExpr() const
ArrayRef< TemplateName > getExpansions() const
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.
StmtClass getStmtClass() const
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
Get the number of string literal tokens that were concatenated in translation phase #6 to form this s...
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.
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.
bool isNull() const
Determine whether this template name is NULL.
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.
@ PackIndexingTemplate
A pack-index-template-name.
@ 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.
PackIndexingTemplateStorage * getAsPackIndexingTemplate() const
Retrieve the pack-index-template-name storage, if any.
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
Top level wrappers for InstallAPI frontend operations.
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)
llvm::Expected< Stmt * > ExpectedStmt
static void updateFlags(const Decl *From, Decl *To)
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