57#include "llvm/ADT/ArrayRef.h"
58#include "llvm/ADT/DenseMap.h"
59#include "llvm/ADT/STLExtras.h"
60#include "llvm/ADT/ScopeExit.h"
61#include "llvm/ADT/SmallVector.h"
62#include "llvm/Support/ErrorHandling.h"
63#include "llvm/Support/MemoryBuffer.h"
74 using llvm::make_error;
89 return "NameConflict";
91 return "UnsupportedConstruct";
93 return "Unknown error";
95 llvm_unreachable(
"Invalid error code.");
96 return "Invalid error code.";
102 llvm_unreachable(
"Function not implemented.");
113 Redecls.push_back(R);
116 std::reverse(Redecls.begin(), Redecls.end());
121 if (
auto *FD = dyn_cast<FunctionDecl>(D))
123 if (
auto *VD = dyn_cast<VarDecl>(D))
125 if (
auto *TD = dyn_cast<TagDecl>(D))
127 llvm_unreachable(
"Bad declaration kind");
148 bool const IgnoreChildErrors;
152 : FromDC(FromDC), IgnoreChildErrors(!
isa<
TagDecl>(FromDC)) {}
162 if (ChildErr && !IgnoreChildErrors)
163 ResultErr = joinErrors(std::move(ResultErr), std::move(ChildErr));
165 consumeError(std::move(ChildErr));
171 if (!IgnoreChildErrors || !FromDC)
173 return FromDC->containsDecl(FromChildD);
179 public StmtVisitor<ASTNodeImporter, ExpectedStmt> {
183 template <
typename ImportT>
184 [[nodiscard]]
Error importInto(ImportT &To,
const ImportT &From) {
185 return Importer.importInto(To, From);
189 template <
typename ImportT>
190 [[nodiscard]]
Error importInto(ImportT *&To, ImportT *From) {
191 auto ToOrErr = Importer.Import(From);
193 To = cast_or_null<ImportT>(*ToOrErr);
194 return ToOrErr.takeError();
199 template <
typename T>
203 auto ToOrErr = Importer.Import(From);
205 return ToOrErr.takeError();
206 return cast_or_null<T>(*ToOrErr);
209 template <
typename T>
210 auto import(
const T *From) {
211 return import(
const_cast<T *
>(From));
215 template <
typename T>
217 return Importer.Import(From);
221 template <
typename T>
225 return import(*From);
232 template <
typename ToDeclT>
struct CallOverloadedCreateFun {
233 template <
typename... Args>
decltype(
auto)
operator()(Args &&... args) {
234 return ToDeclT::Create(std::forward<Args>(args)...);
244 template <
typename ToDeclT,
typename FromDeclT,
typename... Args>
245 [[nodiscard]]
bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
250 CallOverloadedCreateFun<ToDeclT> OC;
251 return GetImportedOrCreateSpecialDecl(ToD, OC, FromD,
252 std::forward<Args>(args)...);
259 template <
typename NewDeclT,
typename ToDeclT,
typename FromDeclT,
261 [[nodiscard]]
bool GetImportedOrCreateDecl(ToDeclT *&ToD, FromDeclT *FromD,
263 CallOverloadedCreateFun<NewDeclT> OC;
264 return GetImportedOrCreateSpecialDecl(ToD, OC, FromD,
265 std::forward<Args>(args)...);
269 template <
typename ToDeclT,
typename CreateFunT,
typename FromDeclT,
272 GetImportedOrCreateSpecialDecl(ToDeclT *&ToD, CreateFunT CreateFun,
273 FromDeclT *FromD, Args &&...args) {
274 if (Importer.getImportDeclErrorIfAny(FromD)) {
278 ToD = cast_or_null<ToDeclT>(Importer.GetAlreadyImportedOrNull(FromD));
281 ToD = CreateFun(std::forward<Args>(args)...);
283 Importer.RegisterImportedDecl(FromD, ToD);
284 Importer.SharedState->markAsNewDecl(ToD);
285 InitializeImportedDecl(FromD, ToD);
289 void InitializeImportedDecl(
Decl *FromD,
Decl *ToD) {
293 if (FromD->isImplicit())
307 void addDeclToContexts(
Decl *FromD,
Decl *ToD) {
308 if (Importer.isMinimalImport()) {
312 if (!FromD->getDescribedTemplate() &&
319 DeclContext *FromLexicalDC = FromD->getLexicalDeclContext();
323 bool Visible =
false;
336 if (
auto *FromNamed = dyn_cast<NamedDecl>(FromD)) {
339 FromDC->
lookup(FromNamed->getDeclName());
340 if (llvm::is_contained(FromLookup, FromNamed))
353 LT->update(TP, OldDC);
357 updateLookupTableForTemplateParameters(
358 Params, Importer.getToContext().getTranslationUnitDecl());
361 template <
typename TemplateParmDeclT>
362 Error importTemplateParameterDefaultArgument(
const TemplateParmDeclT *D,
363 TemplateParmDeclT *ToD) {
364 if (D->hasDefaultArgument()) {
365 if (D->defaultArgumentWasInherited()) {
367 import(D->getDefaultArgStorage().getInheritedFrom());
368 if (!ToInheritedFromOrErr)
369 return ToInheritedFromOrErr.takeError();
370 TemplateParmDeclT *ToInheritedFrom = *ToInheritedFromOrErr;
371 if (!ToInheritedFrom->hasDefaultArgument()) {
375 import(D->getDefaultArgStorage()
377 ->getDefaultArgument());
378 if (!ToInheritedDefaultArgOrErr)
379 return ToInheritedDefaultArgOrErr.takeError();
380 ToInheritedFrom->setDefaultArgument(Importer.getToContext(),
381 *ToInheritedDefaultArgOrErr);
383 ToD->setInheritedDefaultArgument(ToD->getASTContext(),
387 import(D->getDefaultArgument());
388 if (!ToDefaultArgOrErr)
389 return ToDefaultArgOrErr.takeError();
392 if (!ToD->hasDefaultArgument())
393 ToD->setDefaultArgument(Importer.getToContext(),
397 return Error::success();
409#define TYPE(Class, Base) \
410 ExpectedType Visit##Class##Type(const Class##Type *T);
411#include "clang/AST/TypeNodes.inc"
448 (IDK ==
IDK_Default && !Importer.isMinimalImport());
469 template <
typename InContainerTy>
473 template<
typename InContainerTy>
480 std::tuple<FunctionTemplateDecl *, TemplateArgsTy>;
485 template <
typename DeclTy>
509 template <
typename T>
513 bool IgnoreTemplateParmDepth =
false);
715 Err = MaybeVal.takeError();
721 template<
typename IIter,
typename OIter>
723 using ItemT = std::remove_reference_t<
decltype(*Obegin)>;
724 for (; Ibegin != Iend; ++Ibegin, ++Obegin) {
727 return ToOrErr.takeError();
730 return Error::success();
737 template<
typename InContainerTy,
typename OutContainerTy>
739 const InContainerTy &InContainer, OutContainerTy &OutContainer) {
741 InContainer.begin(), InContainer.end(), OutContainer.begin());
744 template<
typename InContainerTy,
typename OIter>
761template <
typename InContainerTy>
765 auto ToLAngleLocOrErr =
import(FromLAngleLoc);
766 if (!ToLAngleLocOrErr)
767 return ToLAngleLocOrErr.takeError();
768 auto ToRAngleLocOrErr =
import(FromRAngleLoc);
769 if (!ToRAngleLocOrErr)
770 return ToRAngleLocOrErr.takeError();
775 Result = std::move(ToTAInfo);
776 return Error::success();
792 From.LAngleLoc, From.RAngleLoc, From.arguments(),
Result);
804 if (
Error Err = importInto(std::get<0>(
Result), FTSInfo->getTemplate()))
805 return std::move(Err);
810 return std::move(Err);
820 return std::move(Err);
823 if (!ToRequiresClause)
824 return ToRequiresClause.takeError();
827 if (!ToTemplateLocOrErr)
828 return ToTemplateLocOrErr.takeError();
830 if (!ToLAngleLocOrErr)
831 return ToLAngleLocOrErr.takeError();
833 if (!ToRAngleLocOrErr)
834 return ToRAngleLocOrErr.takeError();
837 Importer.getToContext(),
855 return ToTypeOrErr.takeError();
863 return ToTypeOrErr.takeError();
870 return ToOrErr.takeError();
873 return ToTypeOrErr.takeError();
874 return TemplateArgument(dyn_cast<ValueDecl>((*ToOrErr)->getCanonicalDecl()),
881 return ToTypeOrErr.takeError();
889 return ToTypeOrErr.takeError();
892 return ToValueOrErr.takeError();
899 if (!ToTemplateOrErr)
900 return ToTemplateOrErr.takeError();
908 if (!ToTemplateOrErr)
909 return ToTemplateOrErr.takeError();
920 return ToExpr.takeError();
926 return std::move(Err);
932 llvm_unreachable(
"Invalid template argument kind");
940 return ArgOrErr.takeError();
949 return E.takeError();
955 return TSIOrErr.takeError();
958 if (!ToTemplateKWLocOrErr)
959 return ToTemplateKWLocOrErr.takeError();
961 if (!ToTemplateQualifierLocOrErr)
962 return ToTemplateQualifierLocOrErr.takeError();
964 if (!ToTemplateNameLocOrErr)
965 return ToTemplateNameLocOrErr.takeError();
966 auto ToTemplateEllipsisLocOrErr =
968 if (!ToTemplateEllipsisLocOrErr)
969 return ToTemplateEllipsisLocOrErr.takeError();
971 Importer.getToContext(), *ToTemplateKWLocOrErr,
972 *ToTemplateQualifierLocOrErr, *ToTemplateNameLocOrErr,
973 *ToTemplateEllipsisLocOrErr);
983 size_t NumDecls = DG.
end() - DG.
begin();
985 ToDecls.reserve(NumDecls);
986 for (
Decl *FromD : DG) {
987 if (
auto ToDOrErr =
import(FromD))
988 ToDecls.push_back(*ToDOrErr);
990 return ToDOrErr.takeError();
1005 return ToDotLocOrErr.takeError();
1008 if (!ToFieldLocOrErr)
1009 return ToFieldLocOrErr.takeError();
1012 ToFieldName, *ToDotLocOrErr, *ToFieldLocOrErr);
1016 if (!ToLBracketLocOrErr)
1017 return ToLBracketLocOrErr.takeError();
1020 if (!ToRBracketLocOrErr)
1021 return ToRBracketLocOrErr.takeError();
1025 *ToLBracketLocOrErr,
1026 *ToRBracketLocOrErr);
1029 if (!ToEllipsisLocOrErr)
1030 return ToEllipsisLocOrErr.takeError();
1034 D.
getArrayIndex(), *ToLBracketLocOrErr, *ToEllipsisLocOrErr,
1035 *ToRBracketLocOrErr);
1040 Error Err = Error::success();
1043 auto ToConceptNameLoc =
1049 return std::move(Err);
1052 if (ASTTemplateArgs)
1054 return std::move(Err);
1056 Importer.getToContext(), ToNNS, ToTemplateKWLoc,
1060 Importer.getToContext(), ToTAInfo)
1066 char *ToStore =
new (Importer.getToContext())
char[FromStr.size()];
1067 std::copy(FromStr.begin(), FromStr.end(), ToStore);
1068 return StringRef(ToStore, FromStr.size());
1080 return ToSecondExpr.takeError();
1081 ToSat.
Details.emplace_back(ToSecondExpr.get());
1085 return ToCROrErr.takeError();
1086 ToSat.
Details.emplace_back(ToCROrErr.get());
1093 return ToPairFirst.takeError();
1095 ToSat.
Details.emplace_back(
new (Importer.getToContext())
1097 ToPairFirst.get(), ToPairSecond});
1101 return Error::success();
1106ASTNodeImporter::import(
1111 return ToLoc.takeError();
1113 return new (Importer.getToContext())
1125 return DiagOrErr.takeError();
1126 return new (Importer.getToContext()) TypeRequirement(*DiagOrErr);
1130 return ToType.takeError();
1131 return new (Importer.getToContext()) TypeRequirement(*ToType);
1139 bool IsRKSimple = From->
getKind() == Requirement::RK_Simple;
1142 std::optional<ExprRequirement::ReturnTypeRequirement> Req;
1148 const ExprRequirement::ReturnTypeRequirement &FromTypeRequirement =
1151 if (FromTypeRequirement.isTypeConstraint()) {
1152 const bool IsDependent = FromTypeRequirement.isDependent();
1154 import(FromTypeRequirement.getTypeConstraintTemplateParameterList());
1156 return ParamsOrErr.takeError();
1157 if (Status >= ExprRequirement::SS_ConstraintsNotSatisfied) {
1158 auto SubstConstraintExprOrErr =
1160 if (!SubstConstraintExprOrErr)
1161 return SubstConstraintExprOrErr.takeError();
1162 SubstitutedConstraintExpr = SubstConstraintExprOrErr.get();
1164 Req.emplace(ParamsOrErr.get(), IsDependent);
1165 }
else if (FromTypeRequirement.isSubstitutionFailure()) {
1166 auto DiagOrErr =
import(FromTypeRequirement.getSubstitutionDiagnostic());
1168 return DiagOrErr.takeError();
1169 Req.emplace(DiagOrErr.get());
1176 if (!NoexceptLocOrErr)
1177 return NoexceptLocOrErr.takeError();
1179 if (Status == ExprRequirement::SS_ExprSubstitutionFailure) {
1182 return DiagOrErr.takeError();
1183 return new (Importer.getToContext()) ExprRequirement(
1184 *DiagOrErr, IsRKSimple, *NoexceptLocOrErr, std::move(*Req));
1188 return ExprOrErr.takeError();
1190 *ExprOrErr, IsRKSimple, *NoexceptLocOrErr, std::move(*Req), Status,
1191 SubstitutedConstraintExpr);
1206 return new (Importer.getToContext())
1207 NestedRequirement(ToEntity, ToSatisfaction);
1211 return ToExpr.takeError();
1212 if (ToExpr.get()->isInstantiationDependent()) {
1213 return new (Importer.getToContext()) NestedRequirement(ToExpr.get());
1218 return std::move(Err);
1219 return new (Importer.getToContext()) NestedRequirement(
1220 Importer.getToContext(), ToExpr.get(), Satisfaction);
1228 switch (FromRequire->
getKind()) {
1238 llvm_unreachable(
"Unhandled requirement kind");
1248 return VarOrErr.takeError();
1253 return LocationOrErr.takeError();
1258 return std::move(Err);
1265template <
typename T>
1267 if (
Found->getLinkageInternal() != From->getLinkageInternal())
1270 if (From->hasExternalFormalLinkage())
1271 return Found->hasExternalFormalLinkage();
1272 if (Importer.GetFromTU(
Found) != From->getTranslationUnitDecl())
1274 if (From->isInAnonymousNamespace())
1275 return Found->isInAnonymousNamespace();
1277 return !
Found->isInAnonymousNamespace() &&
1278 !
Found->hasExternalFormalLinkage();
1298using namespace clang;
1304 FunctionDeclsWithImportInProgress.insert(D);
1307 return llvm::scope_exit([
this, LambdaD]() {
1309 FunctionDeclsWithImportInProgress.erase(LambdaD);
1316 return FunctionDeclsWithImportInProgress.find(D) !=
1317 FunctionDeclsWithImportInProgress.end();
1321 Importer.FromDiag(
SourceLocation(), diag::err_unsupported_ast_node)
1322 << T->getTypeClassName();
1327 ExpectedType UnderlyingTypeOrErr =
import(T->getValueType());
1328 if (!UnderlyingTypeOrErr)
1329 return UnderlyingTypeOrErr.takeError();
1331 return Importer.getToContext().getAtomicType(*UnderlyingTypeOrErr);
1335 switch (T->getKind()) {
1336#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
1337 case BuiltinType::Id: \
1338 return Importer.getToContext().SingletonId;
1339#include "clang/Basic/OpenCLImageTypes.def"
1340#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
1341 case BuiltinType::Id: \
1342 return Importer.getToContext().Id##Ty;
1343#include "clang/Basic/OpenCLExtensionTypes.def"
1344#define SVE_TYPE(Name, Id, SingletonId) \
1345 case BuiltinType::Id: \
1346 return Importer.getToContext().SingletonId;
1347#include "clang/Basic/AArch64ACLETypes.def"
1348#define PPC_VECTOR_TYPE(Name, Id, Size) \
1349 case BuiltinType::Id: \
1350 return Importer.getToContext().Id##Ty;
1351#include "clang/Basic/PPCTypes.def"
1352#define RVV_TYPE(Name, Id, SingletonId) \
1353 case BuiltinType::Id: \
1354 return Importer.getToContext().SingletonId;
1355#include "clang/Basic/RISCVVTypes.def"
1356#define WASM_TYPE(Name, Id, SingletonId) \
1357 case BuiltinType::Id: \
1358 return Importer.getToContext().SingletonId;
1359#include "clang/Basic/WebAssemblyReferenceTypes.def"
1360#define AMDGPU_TYPE(Name, Id, SingletonId, Width, Align) \
1361 case BuiltinType::Id: \
1362 return Importer.getToContext().SingletonId;
1363#include "clang/Basic/AMDGPUTypes.def"
1364#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
1365 case BuiltinType::Id: \
1366 return Importer.getToContext().SingletonId;
1367#include "clang/Basic/HLSLIntangibleTypes.def"
1368#define SHARED_SINGLETON_TYPE(Expansion)
1369#define BUILTIN_TYPE(Id, SingletonId) \
1370 case BuiltinType::Id: return Importer.getToContext().SingletonId;
1371#include "clang/AST/BuiltinTypes.def"
1379 case BuiltinType::Char_U:
1383 if (Importer.getToContext().getLangOpts().CharIsSigned)
1384 return Importer.getToContext().UnsignedCharTy;
1386 return Importer.getToContext().CharTy;
1388 case BuiltinType::Char_S:
1392 if (!Importer.getToContext().getLangOpts().CharIsSigned)
1393 return Importer.getToContext().SignedCharTy;
1395 return Importer.getToContext().CharTy;
1397 case BuiltinType::WChar_S:
1398 case BuiltinType::WChar_U:
1401 return Importer.getToContext().WCharTy;
1404 llvm_unreachable(
"Invalid BuiltinType Kind!");
1407ExpectedType ASTNodeImporter::VisitDecayedType(
const DecayedType *T) {
1409 if (!ToOriginalTypeOrErr)
1410 return ToOriginalTypeOrErr.takeError();
1412 return Importer.getToContext().getDecayedType(*ToOriginalTypeOrErr);
1415ExpectedType ASTNodeImporter::VisitComplexType(
const ComplexType *T) {
1417 if (!ToElementTypeOrErr)
1418 return ToElementTypeOrErr.takeError();
1420 return Importer.getToContext().getComplexType(*ToElementTypeOrErr);
1423ExpectedType ASTNodeImporter::VisitPointerType(
const PointerType *T) {
1425 if (!ToPointeeTypeOrErr)
1426 return ToPointeeTypeOrErr.takeError();
1428 return Importer.getToContext().getPointerType(*ToPointeeTypeOrErr);
1431ExpectedType ASTNodeImporter::VisitBlockPointerType(
const BlockPointerType *T) {
1434 if (!ToPointeeTypeOrErr)
1435 return ToPointeeTypeOrErr.takeError();
1437 return Importer.getToContext().getBlockPointerType(*ToPointeeTypeOrErr);
1441ASTNodeImporter::VisitLValueReferenceType(
const LValueReferenceType *T) {
1444 if (!ToPointeeTypeOrErr)
1445 return ToPointeeTypeOrErr.takeError();
1447 return Importer.getToContext().getLValueReferenceType(*ToPointeeTypeOrErr);
1451ASTNodeImporter::VisitRValueReferenceType(
const RValueReferenceType *T) {
1454 if (!ToPointeeTypeOrErr)
1455 return ToPointeeTypeOrErr.takeError();
1457 return Importer.getToContext().getRValueReferenceType(*ToPointeeTypeOrErr);
1461ASTNodeImporter::VisitMemberPointerType(
const MemberPointerType *T) {
1464 if (!ToPointeeTypeOrErr)
1465 return ToPointeeTypeOrErr.takeError();
1468 if (!QualifierOrErr)
1469 return QualifierOrErr.takeError();
1473 return ClsOrErr.takeError();
1475 return Importer.getToContext().getMemberPointerType(
1476 *ToPointeeTypeOrErr, *QualifierOrErr, *ClsOrErr);
1480ASTNodeImporter::VisitConstantArrayType(
const ConstantArrayType *T) {
1481 Error Err = Error::success();
1483 auto ToSizeExpr = importChecked(Err, T->
getSizeExpr());
1485 return std::move(Err);
1487 return Importer.getToContext().getConstantArrayType(
1493ASTNodeImporter::VisitArrayParameterType(
const ArrayParameterType *T) {
1494 ExpectedType ToArrayTypeOrErr = VisitConstantArrayType(T);
1495 if (!ToArrayTypeOrErr)
1496 return ToArrayTypeOrErr.takeError();
1498 return Importer.getToContext().getArrayParameterType(*ToArrayTypeOrErr);
1502ASTNodeImporter::VisitIncompleteArrayType(
const IncompleteArrayType *T) {
1504 if (!ToElementTypeOrErr)
1505 return ToElementTypeOrErr.takeError();
1507 return Importer.getToContext().getIncompleteArrayType(*ToElementTypeOrErr,
1513ASTNodeImporter::VisitVariableArrayType(
const VariableArrayType *T) {
1514 Error Err = Error::success();
1515 QualType ToElementType = importChecked(Err, T->
getElementType());
1516 Expr *ToSizeExpr = importChecked(Err, T->
getSizeExpr());
1518 return std::move(Err);
1519 return Importer.getToContext().getVariableArrayType(
1524ExpectedType ASTNodeImporter::VisitDependentSizedArrayType(
1525 const DependentSizedArrayType *T) {
1526 Error Err = Error::success();
1527 QualType ToElementType = importChecked(Err, T->
getElementType());
1528 Expr *ToSizeExpr = importChecked(Err, T->
getSizeExpr());
1530 return std::move(Err);
1534 return Importer.getToContext().getDependentSizedArrayType(
1539ExpectedType ASTNodeImporter::VisitDependentSizedExtVectorType(
1540 const DependentSizedExtVectorType *T) {
1541 Error Err = Error::success();
1542 QualType ToElementType = importChecked(Err, T->
getElementType());
1543 Expr *ToSizeExpr = importChecked(Err, T->
getSizeExpr());
1546 return std::move(Err);
1547 return Importer.getToContext().getDependentSizedExtVectorType(
1548 ToElementType, ToSizeExpr, ToAttrLoc);
1551ExpectedType ASTNodeImporter::VisitVectorType(
const VectorType *T) {
1553 if (!ToElementTypeOrErr)
1554 return ToElementTypeOrErr.takeError();
1556 return Importer.getToContext().getVectorType(*ToElementTypeOrErr,
1561ExpectedType ASTNodeImporter::VisitExtVectorType(
const ExtVectorType *T) {
1563 if (!ToElementTypeOrErr)
1564 return ToElementTypeOrErr.takeError();
1566 return Importer.getToContext().getExtVectorType(*ToElementTypeOrErr,
1571ASTNodeImporter::VisitFunctionNoProtoType(
const FunctionNoProtoType *T) {
1575 if (!ToReturnTypeOrErr)
1576 return ToReturnTypeOrErr.takeError();
1578 return Importer.getToContext().getFunctionNoProtoType(*ToReturnTypeOrErr,
1583ASTNodeImporter::VisitFunctionProtoType(
const FunctionProtoType *T) {
1585 if (!ToReturnTypeOrErr)
1586 return ToReturnTypeOrErr.takeError();
1589 SmallVector<QualType, 4> ArgTypes;
1593 return TyOrErr.takeError();
1594 ArgTypes.push_back(*TyOrErr);
1598 SmallVector<QualType, 4> ExceptionTypes;
1602 return TyOrErr.takeError();
1603 ExceptionTypes.push_back(*TyOrErr);
1607 Error Err = Error::success();
1608 FunctionProtoType::ExtProtoInfo ToEPI;
1624 return std::move(Err);
1626 return Importer.getToContext().getFunctionType(
1627 *ToReturnTypeOrErr, ArgTypes, ToEPI);
1631 const UnresolvedUsingType *T) {
1632 Error Err = Error::success();
1633 auto ToQualifier = importChecked(Err, T->
getQualifier());
1634 auto *ToD = importChecked(Err, T->
getDecl());
1636 return std::move(Err);
1639 return Importer.getToContext().getCanonicalUnresolvedUsingType(ToD);
1640 return Importer.getToContext().getUnresolvedUsingType(T->
getKeyword(),
1644ExpectedType ASTNodeImporter::VisitParenType(
const ParenType *T) {
1646 if (!ToInnerTypeOrErr)
1647 return ToInnerTypeOrErr.takeError();
1649 return Importer.getToContext().getParenType(*ToInnerTypeOrErr);
1653ASTNodeImporter::VisitPackIndexingType(clang::PackIndexingType
const *T) {
1657 return Pattern.takeError();
1660 return Index.takeError();
1661 return Importer.getToContext().getPackIndexingType(*Pattern, *Index);
1664ExpectedType ASTNodeImporter::VisitTypedefType(
const TypedefType *T) {
1665 Expected<TypedefNameDecl *> ToDeclOrErr =
import(T->
getDecl());
1667 return ToDeclOrErr.takeError();
1670 if (!ToQualifierOrErr)
1671 return ToQualifierOrErr.takeError();
1675 if (!ToUnderlyingTypeOrErr)
1676 return ToUnderlyingTypeOrErr.takeError();
1678 return Importer.getToContext().getTypedefType(
1679 T->
getKeyword(), *ToQualifierOrErr, *ToDeclOrErr, *ToUnderlyingTypeOrErr);
1682ExpectedType ASTNodeImporter::VisitTypeOfExprType(
const TypeOfExprType *T) {
1685 return ToExprOrErr.takeError();
1686 return Importer.getToContext().getTypeOfExprType(*ToExprOrErr, T->
getKind());
1689ExpectedType ASTNodeImporter::VisitTypeOfType(
const TypeOfType *T) {
1690 ExpectedType ToUnderlyingTypeOrErr =
import(T->getUnmodifiedType());
1691 if (!ToUnderlyingTypeOrErr)
1692 return ToUnderlyingTypeOrErr.takeError();
1693 return Importer.getToContext().getTypeOfType(*ToUnderlyingTypeOrErr,
1697ExpectedType ASTNodeImporter::VisitUsingType(
const UsingType *T) {
1698 Error Err = Error::success();
1699 auto ToQualifier = importChecked(Err, T->
getQualifier());
1700 auto *ToD = importChecked(Err, T->
getDecl());
1701 QualType ToT = importChecked(Err, T->
desugar());
1703 return std::move(Err);
1704 return Importer.getToContext().getUsingType(T->
getKeyword(), ToQualifier, ToD,
1708ExpectedType ASTNodeImporter::VisitDecltypeType(
const DecltypeType *T) {
1710 ExpectedExpr ToExprOrErr =
import(T->getUnderlyingExpr());
1712 return ToExprOrErr.takeError();
1714 ExpectedType ToUnderlyingTypeOrErr =
import(T->getUnderlyingType());
1715 if (!ToUnderlyingTypeOrErr)
1716 return ToUnderlyingTypeOrErr.takeError();
1718 return Importer.getToContext().getDecltypeType(
1719 *ToExprOrErr, *ToUnderlyingTypeOrErr);
1723ASTNodeImporter::VisitUnaryTransformType(
const UnaryTransformType *T) {
1724 ExpectedType ToBaseTypeOrErr =
import(T->getBaseType());
1725 if (!ToBaseTypeOrErr)
1726 return ToBaseTypeOrErr.takeError();
1728 ExpectedType ToUnderlyingTypeOrErr =
import(T->getUnderlyingType());
1729 if (!ToUnderlyingTypeOrErr)
1730 return ToUnderlyingTypeOrErr.takeError();
1732 return Importer.getToContext().getUnaryTransformType(
1733 *ToBaseTypeOrErr, *ToUnderlyingTypeOrErr, T->getUTTKind());
1736ExpectedType ASTNodeImporter::VisitAutoType(
const AutoType *T) {
1738 ExpectedType ToDeducedTypeOrErr =
import(T->getDeducedType());
1739 if (!ToDeducedTypeOrErr)
1740 return ToDeducedTypeOrErr.takeError();
1742 Expected<TemplateDecl *> ToTypeConstraint =
1743 import(T->getTypeConstraintConcept());
1744 if (!ToTypeConstraint)
1745 return ToTypeConstraint.takeError();
1747 SmallVector<TemplateArgument, 2> ToTemplateArgs;
1750 return std::move(Err);
1752 return Importer.getToContext().getAutoType(
1753 T->getDeducedKind(), *ToDeducedTypeOrErr, T->getKeyword(),
1754 *ToTypeConstraint, ToTemplateArgs);
1757ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
1758 const DeducedTemplateSpecializationType *T) {
1760 Expected<TemplateName> ToTemplateNameOrErr =
import(T->getTemplateName());
1761 if (!ToTemplateNameOrErr)
1762 return ToTemplateNameOrErr.takeError();
1763 ExpectedType ToDeducedTypeOrErr =
import(T->getDeducedType());
1764 if (!ToDeducedTypeOrErr)
1765 return ToDeducedTypeOrErr.takeError();
1767 return Importer.getToContext().getDeducedTemplateSpecializationType(
1768 T->getDeducedKind(), *ToDeducedTypeOrErr, T->getKeyword(),
1769 *ToTemplateNameOrErr);
1772ExpectedType ASTNodeImporter::VisitTagType(
const TagType *T) {
1773 TagDecl *DeclForType = T->getDecl();
1774 Expected<TagDecl *> ToDeclOrErr =
import(DeclForType);
1776 return ToDeclOrErr.takeError();
1782 Expected<TagDecl *> ToDefDeclOrErr =
import(DeclForType->
getDefinition());
1783 if (!ToDefDeclOrErr)
1784 return ToDefDeclOrErr.takeError();
1786 if (T->isCanonicalUnqualified())
1787 return Importer.getToContext().getCanonicalTagType(*ToDeclOrErr);
1789 auto ToQualifierOrErr =
import(T->getQualifier());
1790 if (!ToQualifierOrErr)
1791 return ToQualifierOrErr.takeError();
1793 return Importer.getToContext().getTagType(T->getKeyword(), *ToQualifierOrErr,
1794 *ToDeclOrErr, T->isTagOwned());
1797ExpectedType ASTNodeImporter::VisitEnumType(
const EnumType *T) {
1798 return VisitTagType(T);
1801ExpectedType ASTNodeImporter::VisitRecordType(
const RecordType *T) {
1802 return VisitTagType(T);
1806ASTNodeImporter::VisitInjectedClassNameType(
const InjectedClassNameType *T) {
1807 return VisitTagType(T);
1810ExpectedType ASTNodeImporter::VisitAttributedType(
const AttributedType *T) {
1811 ExpectedType ToModifiedTypeOrErr =
import(T->getModifiedType());
1812 if (!ToModifiedTypeOrErr)
1813 return ToModifiedTypeOrErr.takeError();
1814 ExpectedType ToEquivalentTypeOrErr =
import(T->getEquivalentType());
1815 if (!ToEquivalentTypeOrErr)
1816 return ToEquivalentTypeOrErr.takeError();
1818 return Importer.getToContext().getAttributedType(
1819 T->getAttrKind(), *ToModifiedTypeOrErr, *ToEquivalentTypeOrErr,
1824ASTNodeImporter::VisitCountAttributedType(
const CountAttributedType *T) {
1826 if (!ToWrappedTypeOrErr)
1827 return ToWrappedTypeOrErr.takeError();
1829 Error Err = Error::success();
1830 Expr *CountExpr = importChecked(Err, T->
getCountExpr());
1832 SmallVector<TypeCoupledDeclRefInfo, 1> CoupledDecls;
1834 Expected<ValueDecl *> ToDeclOrErr =
import(TI.getDecl());
1836 return ToDeclOrErr.takeError();
1837 CoupledDecls.emplace_back(*ToDeclOrErr, TI.isDeref());
1840 return Importer.getToContext().getCountAttributedType(
1842 ArrayRef(CoupledDecls));
1845ExpectedType ASTNodeImporter::VisitTemplateTypeParmType(
1846 const TemplateTypeParmType *T) {
1847 Expected<TemplateTypeParmDecl *> ToDeclOrErr =
import(T->getDecl());
1849 return ToDeclOrErr.takeError();
1851 return Importer.getToContext().getTemplateTypeParmType(
1852 T->getDepth(), T->getIndex(), T->isParameterPack(), *ToDeclOrErr);
1855ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmType(
1856 const SubstTemplateTypeParmType *T) {
1857 Expected<Decl *> ReplacedOrErr =
import(T->getAssociatedDecl());
1859 return ReplacedOrErr.takeError();
1861 ExpectedType ToReplacementTypeOrErr =
import(T->getReplacementType());
1862 if (!ToReplacementTypeOrErr)
1863 return ToReplacementTypeOrErr.takeError();
1865 return Importer.getToContext().getSubstTemplateTypeParmType(
1866 *ToReplacementTypeOrErr, *ReplacedOrErr, T->getIndex(), T->getPackIndex(),
1870ExpectedType ASTNodeImporter::VisitSubstTemplateTypeParmPackType(
1871 const SubstTemplateTypeParmPackType *T) {
1872 Expected<Decl *> ReplacedOrErr =
import(T->getAssociatedDecl());
1874 return ReplacedOrErr.takeError();
1876 Expected<TemplateArgument> ToArgumentPack =
import(T->getArgumentPack());
1877 if (!ToArgumentPack)
1878 return ToArgumentPack.takeError();
1880 return Importer.getToContext().getSubstTemplateTypeParmPackType(
1881 *ReplacedOrErr, T->getIndex(), T->getFinal(), *ToArgumentPack);
1884ExpectedType ASTNodeImporter::VisitSubstBuiltinTemplatePackType(
1885 const SubstBuiltinTemplatePackType *T) {
1886 Expected<TemplateArgument> ToArgumentPack =
import(T->getArgumentPack());
1887 if (!ToArgumentPack)
1888 return ToArgumentPack.takeError();
1889 return Importer.getToContext().getSubstBuiltinTemplatePack(*ToArgumentPack);
1892ExpectedType ASTNodeImporter::VisitTemplateSpecializationType(
1893 const TemplateSpecializationType *T) {
1894 auto ToTemplateOrErr =
import(T->getTemplateName());
1895 if (!ToTemplateOrErr)
1896 return ToTemplateOrErr.takeError();
1898 SmallVector<TemplateArgument, 2> ToTemplateArgs;
1901 return std::move(Err);
1904 T->isCanonicalUnqualified() ? QualType() : import(T->desugar());
1905 if (!ToUnderlyingOrErr)
1906 return ToUnderlyingOrErr.takeError();
1907 return Importer.getToContext().getTemplateSpecializationType(
1908 T->getKeyword(), *ToTemplateOrErr, ToTemplateArgs, {},
1909 *ToUnderlyingOrErr);
1913ASTNodeImporter::VisitPackExpansionType(
const PackExpansionType *T) {
1915 if (!ToPatternOrErr)
1916 return ToPatternOrErr.takeError();
1918 return Importer.getToContext().getPackExpansionType(*ToPatternOrErr,
1919 T->getNumExpansions(),
1924ASTNodeImporter::VisitDependentNameType(
const DependentNameType *T) {
1925 auto ToQualifierOrErr =
import(T->getQualifier());
1926 if (!ToQualifierOrErr)
1927 return ToQualifierOrErr.takeError();
1929 IdentifierInfo *Name = Importer.Import(T->getIdentifier());
1930 return Importer.getToContext().getDependentNameType(T->getKeyword(),
1931 *ToQualifierOrErr, Name);
1935ASTNodeImporter::VisitObjCInterfaceType(
const ObjCInterfaceType *T) {
1936 Expected<ObjCInterfaceDecl *> ToDeclOrErr =
import(T->
getDecl());
1938 return ToDeclOrErr.takeError();
1940 return Importer.getToContext().getObjCInterfaceType(*ToDeclOrErr);
1943ExpectedType ASTNodeImporter::VisitObjCObjectType(
const ObjCObjectType *T) {
1944 ExpectedType ToBaseTypeOrErr =
import(T->getBaseType());
1945 if (!ToBaseTypeOrErr)
1946 return ToBaseTypeOrErr.takeError();
1948 SmallVector<QualType, 4> TypeArgs;
1949 for (
auto TypeArg : T->getTypeArgsAsWritten()) {
1951 TypeArgs.push_back(*TyOrErr);
1953 return TyOrErr.takeError();
1956 SmallVector<ObjCProtocolDecl *, 4> Protocols;
1957 for (
auto *P : T->quals()) {
1958 if (Expected<ObjCProtocolDecl *> ProtocolOrErr =
import(P))
1959 Protocols.push_back(*ProtocolOrErr);
1961 return ProtocolOrErr.takeError();
1965 return Importer.getToContext().getObjCObjectType(*ToBaseTypeOrErr, TypeArgs,
1967 T->isKindOfTypeAsWritten());
1971ASTNodeImporter::VisitObjCObjectPointerType(
const ObjCObjectPointerType *T) {
1973 if (!ToPointeeTypeOrErr)
1974 return ToPointeeTypeOrErr.takeError();
1976 return Importer.getToContext().getObjCObjectPointerType(*ToPointeeTypeOrErr);
1980ASTNodeImporter::VisitMacroQualifiedType(
const MacroQualifiedType *T) {
1982 if (!ToUnderlyingTypeOrErr)
1983 return ToUnderlyingTypeOrErr.takeError();
1986 return Importer.getToContext().getMacroQualifiedType(*ToUnderlyingTypeOrErr,
1990ExpectedType clang::ASTNodeImporter::VisitAdjustedType(
const AdjustedType *T) {
1991 Error Err = Error::success();
1995 return std::move(Err);
1997 return Importer.getToContext().getAdjustedType(ToOriginalType,
2001ExpectedType clang::ASTNodeImporter::VisitBitIntType(
const BitIntType *T) {
2002 return Importer.getToContext().getBitIntType(T->
isUnsigned(),
2006ExpectedType clang::ASTNodeImporter::VisitBTFTagAttributedType(
2007 const clang::BTFTagAttributedType *T) {
2008 Error Err = Error::success();
2009 const BTFTypeTagAttr *ToBTFAttr = importChecked(Err, T->getAttr());
2010 QualType ToWrappedType = importChecked(Err, T->getWrappedType());
2012 return std::move(Err);
2014 return Importer.getToContext().getBTFTagAttributedType(ToBTFAttr,
2018ExpectedType clang::ASTNodeImporter::VisitOverflowBehaviorType(
2019 const clang::OverflowBehaviorType *T) {
2020 Error Err = Error::success();
2021 OverflowBehaviorType::OverflowBehaviorKind ToKind = T->getBehaviorKind();
2024 return std::move(Err);
2026 return Importer.getToContext().getOverflowBehaviorType(ToKind,
2030ExpectedType clang::ASTNodeImporter::VisitHLSLAttributedResourceType(
2031 const clang::HLSLAttributedResourceType *T) {
2032 Error Err = Error::success();
2033 const HLSLAttributedResourceType::Attributes &ToAttrs = T->getAttrs();
2034 QualType ToWrappedType = importChecked(Err, T->getWrappedType());
2035 QualType ToContainedType = importChecked(Err, T->getContainedType());
2037 return std::move(Err);
2039 return Importer.getToContext().getHLSLAttributedResourceType(
2040 ToWrappedType, ToContainedType, ToAttrs);
2043ExpectedType clang::ASTNodeImporter::VisitHLSLInlineSpirvType(
2044 const clang::HLSLInlineSpirvType *T) {
2045 Error Err = Error::success();
2047 uint32_t ToOpcode = T->getOpcode();
2049 uint32_t ToAlignment = T->getAlignment();
2051 llvm::SmallVector<SpirvOperand> ToOperands;
2053 for (
auto &Operand : T->getOperands()) {
2054 using SpirvOperandKind = SpirvOperand::SpirvOperandKind;
2057 case SpirvOperandKind::ConstantId:
2058 ToOperands.push_back(SpirvOperand::createConstant(
2059 importChecked(Err,
Operand.getResultType()),
Operand.getValue()));
2061 case SpirvOperandKind::Literal:
2062 ToOperands.push_back(SpirvOperand::createLiteral(
Operand.getValue()));
2064 case SpirvOperandKind::TypeId:
2065 ToOperands.push_back(SpirvOperand::createType(
2066 importChecked(Err,
Operand.getResultType())));
2069 llvm_unreachable(
"Invalid SpirvOperand kind");
2073 return std::move(Err);
2076 return Importer.getToContext().getHLSLInlineSpirvType(
2077 ToOpcode, ToSize, ToAlignment, ToOperands);
2080ExpectedType clang::ASTNodeImporter::VisitConstantMatrixType(
2081 const clang::ConstantMatrixType *T) {
2083 if (!ToElementTypeOrErr)
2084 return ToElementTypeOrErr.takeError();
2086 return Importer.getToContext().getConstantMatrixType(
2090ExpectedType clang::ASTNodeImporter::VisitDependentAddressSpaceType(
2091 const clang::DependentAddressSpaceType *T) {
2092 Error Err = Error::success();
2093 QualType ToPointeeType = importChecked(Err, T->
getPointeeType());
2097 return std::move(Err);
2099 return Importer.getToContext().getDependentAddressSpaceType(
2100 ToPointeeType, ToAddrSpaceExpr, ToAttrLoc);
2103ExpectedType clang::ASTNodeImporter::VisitDependentBitIntType(
2104 const clang::DependentBitIntType *T) {
2106 if (!ToNumBitsExprOrErr)
2107 return ToNumBitsExprOrErr.takeError();
2108 return Importer.getToContext().getDependentBitIntType(T->
isUnsigned(),
2109 *ToNumBitsExprOrErr);
2112ExpectedType clang::ASTNodeImporter::VisitPredefinedSugarType(
2113 const clang::PredefinedSugarType *T) {
2114 return Importer.getToContext().getPredefinedSugarType(T->
getKind());
2117ExpectedType clang::ASTNodeImporter::VisitDependentSizedMatrixType(
2118 const clang::DependentSizedMatrixType *T) {
2119 Error Err = Error::success();
2120 QualType ToElementType = importChecked(Err, T->
getElementType());
2121 Expr *ToRowExpr = importChecked(Err, T->
getRowExpr());
2122 Expr *ToColumnExpr = importChecked(Err, T->
getColumnExpr());
2125 return std::move(Err);
2127 return Importer.getToContext().getDependentSizedMatrixType(
2128 ToElementType, ToRowExpr, ToColumnExpr, ToAttrLoc);
2131ExpectedType clang::ASTNodeImporter::VisitDependentVectorType(
2132 const clang::DependentVectorType *T) {
2133 Error Err = Error::success();
2134 QualType ToElementType = importChecked(Err, T->
getElementType());
2135 Expr *ToSizeExpr = importChecked(Err, T->
getSizeExpr());
2138 return std::move(Err);
2140 return Importer.getToContext().getDependentVectorType(
2144ExpectedType clang::ASTNodeImporter::VisitObjCTypeParamType(
2145 const clang::ObjCTypeParamType *T) {
2146 Expected<ObjCTypeParamDecl *> ToDeclOrErr =
import(T->getDecl());
2148 return ToDeclOrErr.takeError();
2150 SmallVector<ObjCProtocolDecl *, 4> ToProtocols;
2151 for (ObjCProtocolDecl *FromProtocol : T->getProtocols()) {
2152 Expected<ObjCProtocolDecl *> ToProtocolOrErr =
import(FromProtocol);
2153 if (!ToProtocolOrErr)
2154 return ToProtocolOrErr.takeError();
2155 ToProtocols.push_back(*ToProtocolOrErr);
2158 return Importer.getToContext().getObjCTypeParamType(*ToDeclOrErr,
2162ExpectedType clang::ASTNodeImporter::VisitPipeType(
const clang::PipeType *T) {
2164 if (!ToElementTypeOrErr)
2165 return ToElementTypeOrErr.takeError();
2167 ASTContext &ToCtx = Importer.getToContext();
2188 if (
isa<RecordDecl>(D) && (FunDecl = dyn_cast<FunctionDecl>(OrigDC)) &&
2190 auto getLeafPointeeType = [](
const Type *T) {
2191 while (T->isPointerType() || T->isArrayType()) {
2192 T = T->getPointeeOrArrayElementType();
2198 getLeafPointeeType(
P->getType().getCanonicalType().getTypePtr());
2199 auto *RT = dyn_cast<RecordType>(LeafT);
2200 if (RT && RT->getDecl() == D) {
2201 Importer.FromDiag(D->
getLocation(), diag::err_unsupported_ast_node)
2220 ToD = cast_or_null<NamedDecl>(Importer.GetAlreadyImportedOrNull(D));
2225 return Error::success();
2239 ToD = cast_or_null<NamedDecl>(Importer.GetAlreadyImportedOrNull(D));
2244 return Error::success();
2249 return Error::success();
2255 if (
RecordDecl *FromRecord = dyn_cast<RecordDecl>(FromD)) {
2257 if (FromRecord->getDefinition() && FromRecord->isCompleteDefinition() &&
2258 !ToRecord->getDefinition()) {
2263 return Error::success();
2266 if (
EnumDecl *FromEnum = dyn_cast<EnumDecl>(FromD)) {
2268 if (FromEnum->getDefinition() && !ToEnum->getDefinition()) {
2273 return Error::success();
2276 return Error::success();
2291 return Error::success();
2297 return ToRangeOrErr.takeError();
2298 return Error::success();
2304 return LocOrErr.takeError();
2305 return Error::success();
2313 return ToTInfoOrErr.takeError();
2314 return Error::success();
2317 llvm_unreachable(
"Unknown name kind.");
2322 if (Importer.isMinimalImport() && !ForceImport) {
2323 auto ToDCOrErr = Importer.ImportContext(FromDC);
2324 return ToDCOrErr.takeError();
2338 auto MightNeedReordering = [](
const Decl *D) {
2343 Error ChildErrors = Error::success();
2344 for (
auto *From : FromDC->
decls()) {
2345 if (!MightNeedReordering(From))
2354 if (!ImportedOrErr) {
2356 ImportedOrErr.takeError());
2359 FieldDecl *FieldFrom = dyn_cast_or_null<FieldDecl>(From);
2360 Decl *ImportedDecl = *ImportedOrErr;
2361 FieldDecl *FieldTo = dyn_cast_or_null<FieldDecl>(ImportedDecl);
2362 if (FieldFrom && FieldTo) {
2392 auto ToDCOrErr = Importer.ImportContext(FromDC);
2394 consumeError(std::move(ChildErrors));
2395 return ToDCOrErr.takeError();
2398 if (
const auto *FromRD = dyn_cast<RecordDecl>(FromDC)) {
2402 for (
auto *D : FromRD->decls()) {
2403 if (!MightNeedReordering(D))
2406 assert(D &&
"DC contains a null decl");
2407 if (
Decl *ToD = Importer.GetAlreadyImportedOrNull(D)) {
2409 assert(ToDC == ToD->getLexicalDeclContext() && ToDC->
containsDecl(ToD));
2421 for (
auto *From : FromDC->
decls()) {
2422 if (MightNeedReordering(From))
2428 ImportedOrErr.takeError());
2448 if (!FromRecordDecl || !ToRecordDecl) {
2449 const RecordType *RecordFrom = FromType->
getAs<RecordType>();
2450 const RecordType *RecordTo = ToType->
getAs<RecordType>();
2452 if (RecordFrom && RecordTo) {
2453 FromRecordDecl = RecordFrom->getDecl();
2454 ToRecordDecl = RecordTo->getDecl();
2458 if (FromRecordDecl && ToRecordDecl) {
2464 return Error::success();
2469 auto ToDCOrErr = Importer.ImportContext(FromD->
getDeclContext());
2471 return ToDCOrErr.takeError();
2475 auto ToLexicalDCOrErr = Importer.ImportContext(
2477 if (!ToLexicalDCOrErr)
2478 return ToLexicalDCOrErr.takeError();
2479 ToLexicalDC = *ToLexicalDCOrErr;
2483 return Error::success();
2489 "Import implicit methods to or from non-definition");
2492 if (FromM->isImplicit()) {
2495 return ToMOrErr.takeError();
2498 return Error::success();
2507 return ToTypedefOrErr.takeError();
2509 return Error::success();
2514 auto DefinitionCompleter = [To]() {
2535 ToCaptures.reserve(FromCXXRD->capture_size());
2536 for (
const auto &FromCapture : FromCXXRD->captures()) {
2537 if (
auto ToCaptureOrErr =
import(FromCapture))
2538 ToCaptures.push_back(*ToCaptureOrErr);
2540 return ToCaptureOrErr.takeError();
2549 DefinitionCompleter();
2553 return Error::success();
2563 if (!Importer.isMinimalImport())
2568 llvm::scope_exit DefinitionCompleterScopeExit(DefinitionCompleter);
2574 auto *ToCXX = dyn_cast<CXXRecordDecl>(To);
2575 auto *FromCXX = dyn_cast<CXXRecordDecl>(From);
2576 if (ToCXX && FromCXX && ToCXX->dataPtr() && FromCXX->dataPtr()) {
2578 struct CXXRecordDecl::DefinitionData &ToData = ToCXX->data();
2579 struct CXXRecordDecl::DefinitionData &FromData = FromCXX->data();
2581 #define FIELD(Name, Width, Merge) \
2582 ToData.Name = FromData.Name;
2583 #include "clang/AST/CXXRecordDeclDefinitionBits.def"
2586 ToCXX->setArgPassingRestrictions(FromCXX->getArgPassingRestrictions());
2589 for (
const auto &Base1 : FromCXX->bases()) {
2592 return TyOrErr.takeError();
2595 if (Base1.isPackExpansion()) {
2596 if (
ExpectedSLoc LocOrErr =
import(Base1.getEllipsisLoc()))
2597 EllipsisLoc = *LocOrErr;
2599 return LocOrErr.takeError();
2607 auto RangeOrErr =
import(Base1.getSourceRange());
2609 return RangeOrErr.takeError();
2611 auto TSIOrErr =
import(Base1.getTypeSourceInfo());
2613 return TSIOrErr.takeError();
2619 Base1.isBaseOfClass(),
2620 Base1.getAccessSpecifierAsWritten(),
2625 ToCXX->setBases(Bases.data(), Bases.size());
2633 return Error::success();
2638 return Error::success();
2642 return Error::success();
2646 return ToInitOrErr.takeError();
2657 return Error::success();
2665 return Error::success();
2674 import(
QualType(Importer.getFromContext().getCanonicalTagType(From)));
2676 return ToTypeOrErr.takeError();
2679 if (!ToPromotionTypeOrErr)
2680 return ToPromotionTypeOrErr.takeError();
2691 return Error::success();
2697 for (
const auto &Arg : FromArgs) {
2698 if (
auto ToOrErr =
import(Arg))
2699 ToArgs.push_back(*ToOrErr);
2701 return ToOrErr.takeError();
2704 return Error::success();
2710 return import(From);
2713template <
typename InContainerTy>
2716 for (
const auto &FromLoc : Container) {
2717 if (
auto ToLocOrErr =
import(FromLoc))
2720 return ToLocOrErr.takeError();
2722 return Error::success();
2732 bool IgnoreTemplateParmDepth) {
2735 Decl *ToOrigin = Importer.GetOriginalDecl(To);
2741 Importer.getToContext().getLangOpts(), Importer.getFromContext(),
2742 Importer.getToContext(), Importer.getNonEquivalentDecls(),
2744 false, Complain,
false,
2745 IgnoreTemplateParmDepth);
2750 Importer.FromDiag(D->
getLocation(), diag::err_unsupported_ast_node)
2756 Importer.FromDiag(D->
getLocation(), diag::err_unsupported_ast_node)
2765 return std::move(Err);
2770 return LocOrErr.takeError();
2773 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, *LocOrErr))
2785 Importer.MapImported(D, ToD);
2796 return std::move(Err);
2801 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), DC, Loc,
2805 Error Err = Error::success();
2810 return std::move(Err);
2814 addDeclToContexts(D, ToD);
2822 return LocOrErr.takeError();
2825 return ColonLocOrErr.takeError();
2830 return DCOrErr.takeError();
2834 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(), D->
getAccess(),
2835 DC, *LocOrErr, *ColonLocOrErr))
2849 return DCOrErr.takeError();
2853 Error Err = Error::success();
2859 return std::move(Err);
2862 if (GetImportedOrCreateDecl(
2863 ToD, D, Importer.getToContext(), DC, ToLocation, ToAssertExpr, ToMessage,
2879 return std::move(Err);
2888 if (
auto *TU = dyn_cast<TranslationUnitDecl>(EnclosingDC))
2891 MergeWithNamespace =
2895 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
2896 for (
auto *FoundDecl : FoundDecls) {
2900 if (
auto *FoundNS = dyn_cast<NamespaceDecl>(FoundDecl)) {
2901 MergeWithNamespace = FoundNS;
2902 ConflictingDecls.clear();
2906 ConflictingDecls.push_back(FoundDecl);
2909 if (!ConflictingDecls.empty()) {
2912 ConflictingDecls.size());
2914 Name = NameOrErr.get();
2916 return NameOrErr.takeError();
2922 return BeginLocOrErr.takeError();
2924 if (!RBraceLocOrErr)
2925 return RBraceLocOrErr.takeError();
2930 if (GetImportedOrCreateDecl(ToNamespace, D, Importer.getToContext(), DC,
2931 D->
isInline(), *BeginLocOrErr, Loc,
2942 if (
auto *TU = dyn_cast<TranslationUnitDecl>(DC))
2943 TU->setAnonymousNamespace(ToNamespace);
2948 Importer.MapImported(D, ToNamespace);
2951 return std::move(Err);
2963 return std::move(Err);
2969 Error Err = Error::success();
2976 return std::move(Err);
2981 if (GetImportedOrCreateDecl(
2982 ToD, D, Importer.getToContext(), DC, ToNamespaceLoc, ToAliasLoc,
2983 ToIdentifier, ToQualifierLoc, ToTargetNameLoc, ToNamespace))
3001 return std::move(Err);
3008 cast_or_null<DeclContext>(Importer.GetAlreadyImportedOrNull(
3020 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3021 for (
auto *FoundDecl : FoundDecls) {
3022 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3024 if (
auto *FoundTypedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
3029 QualType FoundUT = FoundTypedef->getUnderlyingType();
3030 if (Importer.IsStructurallyEquivalent(FromUT, FoundUT)) {
3043 if (FromR && FoundR &&
3050 return Importer.MapImported(D, FoundTypedef);
3054 ConflictingDecls.push_back(FoundDecl);
3059 if (!ConflictingDecls.empty()) {
3061 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3063 Name = NameOrErr.get();
3065 return NameOrErr.takeError();
3069 Error Err = Error::success();
3074 return std::move(Err);
3081 if (GetImportedOrCreateDecl<TypeAliasDecl>(
3082 ToTypedef, D, Importer.getToContext(), DC, ToBeginLoc, Loc,
3085 }
else if (GetImportedOrCreateDecl<TypedefDecl>(
3086 ToTypedef, D, Importer.getToContext(), DC, ToBeginLoc, Loc,
3092 return std::move(Err);
3096 Importer.AddToLookupTable(ToTypedef);
3124 return std::move(Err);
3134 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3135 for (
auto *FoundDecl : FoundDecls) {
3136 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3138 if (
auto *FoundAlias = dyn_cast<TypeAliasTemplateDecl>(FoundDecl)) {
3140 return Importer.MapImported(D, FoundAlias);
3141 ConflictingDecls.push_back(FoundDecl);
3145 if (!ConflictingDecls.empty()) {
3147 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3149 Name = NameOrErr.get();
3151 return NameOrErr.takeError();
3155 Error Err = Error::success();
3159 return std::move(Err);
3162 if (GetImportedOrCreateDecl(ToAlias, D, Importer.getToContext(), DC, Loc,
3163 Name, ToTemplateParameters, ToTemplatedDecl))
3166 ToTemplatedDecl->setDescribedAliasTemplate(ToAlias);
3171 if (DC != Importer.getToContext().getTranslationUnitDecl())
3172 updateLookupTableForTemplateParameters(*ToTemplateParameters);
3183 return std::move(Err);
3193 return BeginLocOrErr.takeError();
3194 if (GetImportedOrCreateDecl(ToLabel, D, Importer.getToContext(), DC, Loc,
3199 if (GetImportedOrCreateDecl(ToLabel, D, Importer.getToContext(), DC, Loc,
3207 return ToStmtOrErr.takeError();
3209 ToLabel->
setStmt(*ToStmtOrErr);
3222 return std::move(Err);
3232 return std::move(Err);
3234 }
else if (Importer.getToContext().getLangOpts().CPlusPlus)
3242 Importer.findDeclsInToCtx(DC, SearchName);
3243 for (
auto *FoundDecl : FoundDecls) {
3244 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3247 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(FoundDecl)) {
3248 if (
const auto *Tag =
Typedef->getUnderlyingType()->getAs<TagType>())
3249 FoundDecl = Tag->getDecl();
3252 if (
auto *FoundEnum = dyn_cast<EnumDecl>(FoundDecl)) {
3258 return Importer.MapImported(D, FoundDef);
3262 ConflictingDecls.push_back(FoundDecl);
3271 if (SearchName && !ConflictingDecls.empty()) {
3273 SearchName, DC, IDNS, ConflictingDecls.data(),
3274 ConflictingDecls.size());
3276 Name = NameOrErr.get();
3278 return NameOrErr.takeError();
3282 Error Err = Error::success();
3288 return std::move(Err);
3292 if (GetImportedOrCreateDecl(
3293 D2, D, Importer.getToContext(), DC, ToBeginLoc,
3303 addDeclToContexts(D, D2);
3309 D2->setInstantiationOfMemberEnum(*ToInstOrErr, SK);
3311 return ToInstOrErr.takeError();
3312 if (
ExpectedSLoc POIOrErr =
import(MemberInfo->getPointOfInstantiation()))
3315 return POIOrErr.takeError();
3321 return std::move(Err);
3327 bool IsFriendTemplate =
false;
3328 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3330 DCXX->getDescribedClassTemplate() &&
3331 DCXX->getDescribedClassTemplate()->getFriendObjectKind() !=
3341 return std::move(Err);
3351 return std::move(Err);
3353 }
else if (Importer.getToContext().getLangOpts().CPlusPlus)
3358 bool DependentFriend = IsFriendTemplate && IsDependentContext;
3365 Importer.findDeclsInToCtx(DC, SearchName);
3366 if (!FoundDecls.empty()) {
3373 for (
auto *FoundDecl : FoundDecls) {
3374 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3378 if (
auto *
Typedef = dyn_cast<TypedefNameDecl>(
Found)) {
3379 if (
const auto *Tag =
Typedef->getUnderlyingType()->getAs<TagType>())
3380 Found = Tag->getDecl();
3383 if (
auto *FoundRecord = dyn_cast<RecordDecl>(
Found)) {
3405 Importer.MapImported(D, FoundDef);
3406 if (
const auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3407 auto *FoundCXX = dyn_cast<CXXRecordDecl>(FoundDef);
3408 assert(FoundCXX &&
"Record type mismatch");
3410 if (!Importer.isMinimalImport())
3414 return std::move(Err);
3421 ConflictingDecls.push_back(FoundDecl);
3425 if (!ConflictingDecls.empty() && SearchName) {
3427 SearchName, DC, IDNS, ConflictingDecls.data(),
3428 ConflictingDecls.size());
3430 Name = NameOrErr.get();
3432 return NameOrErr.takeError();
3438 return BeginLocOrErr.takeError();
3443 if (
auto *DCXX = dyn_cast<CXXRecordDecl>(D)) {
3444 if (DCXX->isLambda()) {
3445 auto TInfoOrErr =
import(DCXX->getLambdaTypeInfo());
3447 return TInfoOrErr.takeError();
3448 if (GetImportedOrCreateSpecialDecl(
3450 DC, *TInfoOrErr, Loc, DCXX->getLambdaDependencyKind(),
3451 DCXX->isGenericLambda(), DCXX->getLambdaCaptureDefault()))
3453 Decl *ContextDecl = DCXX->getLambdaContextDecl();
3456 return CDeclOrErr.takeError();
3457 if (ContextDecl !=
nullptr) {
3462 if (GetImportedOrCreateDecl(D2CXX, D, Importer.getToContext(),
3465 cast_or_null<CXXRecordDecl>(PrevDecl)))
3472 addDeclToContexts(D, D2);
3475 DCXX->getDescribedClassTemplate()) {
3478 return std::move(Err);
3481 DCXX->getMemberSpecializationInfo()) {
3483 MemberInfo->getTemplateSpecializationKind();
3489 return ToInstOrErr.takeError();
3492 import(MemberInfo->getPointOfInstantiation()))
3496 return POIOrErr.takeError();
3500 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(),
3505 addDeclToContexts(D, D2);
3511 return BraceRangeOrErr.takeError();
3515 return QualifierLocOrErr.takeError();
3522 return std::move(Err);
3534 return std::move(Err);
3543 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3544 for (
auto *FoundDecl : FoundDecls) {
3545 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3548 if (
auto *FoundEnumConstant = dyn_cast<EnumConstantDecl>(FoundDecl)) {
3550 return Importer.MapImported(D, FoundEnumConstant);
3551 ConflictingDecls.push_back(FoundDecl);
3555 if (!ConflictingDecls.empty()) {
3557 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
3559 Name = NameOrErr.get();
3561 return NameOrErr.takeError();
3567 return TypeOrErr.takeError();
3571 return InitOrErr.takeError();
3574 if (GetImportedOrCreateDecl(
3575 ToEnumerator, D, Importer.getToContext(),
cast<EnumDecl>(DC), Loc,
3577 return ToEnumerator;
3582 return ToEnumerator;
3585template <
typename DeclTy>
3589 FromD->getTemplateParameterLists();
3590 if (FromTPLs.empty())
3591 return Error::success();
3593 for (
unsigned int I = 0; I < FromTPLs.size(); ++I)
3595 ToTPLists[I] = *ToTPListOrErr;
3597 return ToTPListOrErr.takeError();
3598 ToD->setTemplateParameterListsInfo(Importer.ToContext, ToTPLists);
3599 return Error::success();
3607 return Error::success();
3613 return Error::success();
3619 ToFD->setInstantiationOfMemberFunction(*InstFDOrErr, TSK);
3621 return InstFDOrErr.takeError();
3627 return POIOrErr.takeError();
3629 return Error::success();
3633 auto FunctionAndArgsOrErr =
3635 if (!FunctionAndArgsOrErr)
3636 return FunctionAndArgsOrErr.takeError();
3639 Importer.getToContext(), std::get<1>(*FunctionAndArgsOrErr));
3643 const auto *FromTAArgsAsWritten = FTSInfo->TemplateArgumentsAsWritten;
3644 if (FromTAArgsAsWritten)
3646 *FromTAArgsAsWritten, ToTAInfo))
3649 ExpectedSLoc POIOrErr =
import(FTSInfo->getPointOfInstantiation());
3651 return POIOrErr.takeError();
3657 ToFD->setFunctionTemplateSpecialization(
3658 std::get<0>(*FunctionAndArgsOrErr), ToTAList,
nullptr,
3659 TSK, FromTAArgsAsWritten ? &ToTAInfo :
nullptr, *POIOrErr);
3660 return Error::success();
3668 Candidates.
addDecl(*ToFTDOrErr);
3670 return ToFTDOrErr.takeError();
3675 const auto *FromTAArgsAsWritten = FromInfo->TemplateArgumentsAsWritten;
3676 if (FromTAArgsAsWritten)
3682 Importer.getToContext(), Candidates,
3683 FromTAArgsAsWritten ? &ToTAInfo :
nullptr);
3684 return Error::success();
3687 llvm_unreachable(
"All cases should be covered!");
3692 auto FunctionAndArgsOrErr =
3694 if (!FunctionAndArgsOrErr)
3695 return FunctionAndArgsOrErr.takeError();
3699 std::tie(
Template, ToTemplArgs) = *FunctionAndArgsOrErr;
3700 void *InsertPos =
nullptr;
3701 auto *FoundSpec =
Template->findSpecialization(ToTemplArgs, InsertPos);
3711 return ToBodyOrErr.takeError();
3713 return Error::success();
3719 const DeclContext *DCi = dyn_cast<DeclContext>(D);
3722 assert(DCi &&
"Declaration should have a context");
3736 ToProcess.push_back(S);
3737 while (!ToProcess.empty()) {
3738 const Stmt *CurrentS = ToProcess.pop_back_val();
3740 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(CurrentS)) {
3741 if (
const Decl *D = DeclRef->getDecl())
3744 }
else if (
const auto *E =
3745 dyn_cast_or_null<SubstNonTypeTemplateParmExpr>(CurrentS)) {
3746 if (
const Decl *D = E->getAssociatedDecl())
3779class IsTypeDeclaredInsideVisitor
3780 :
public TypeVisitor<IsTypeDeclaredInsideVisitor, std::optional<bool>> {
3782 IsTypeDeclaredInsideVisitor(
const FunctionDecl *ParentDC)
3783 : ParentDC(ParentDC) {}
3785 bool CheckType(QualType T) {
3789 if (std::optional<bool> Res = Visit(T.
getTypePtr()))
3794 if (std::optional<bool> Res = Visit(DsT.
getTypePtr()))
3802 std::optional<bool> VisitTagType(
const TagType *T) {
3803 if (
auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(T->getDecl()))
3804 for (
const auto &Arg : Spec->getTemplateArgs().asArray())
3805 if (checkTemplateArgument(Arg))
3810 std::optional<bool> VisitPointerType(
const PointerType *T) {
3814 std::optional<bool> VisitReferenceType(
const ReferenceType *T) {
3818 std::optional<bool> VisitTypedefType(
const TypedefType *T) {
3822 std::optional<bool> VisitUsingType(
const UsingType *T) {
3827 VisitTemplateSpecializationType(
const TemplateSpecializationType *T) {
3828 for (
const auto &Arg : T->template_arguments())
3829 if (checkTemplateArgument(Arg))
3835 std::optional<bool> VisitUnaryTransformType(
const UnaryTransformType *T) {
3836 return CheckType(T->getBaseType());
3840 VisitSubstTemplateTypeParmType(
const SubstTemplateTypeParmType *T) {
3847 std::optional<bool> VisitConstantArrayType(
const ConstantArrayType *T) {
3854 std::optional<bool> VisitVariableArrayType(
const VariableArrayType *T) {
3856 "Variable array should not occur in deduced return type of a function");
3859 std::optional<bool> VisitIncompleteArrayType(
const IncompleteArrayType *T) {
3860 llvm_unreachable(
"Incomplete array should not occur in deduced return type "
3864 std::optional<bool> VisitDependentArrayType(
const IncompleteArrayType *T) {
3865 llvm_unreachable(
"Dependent array should not occur in deduced return type "
3870 const DeclContext *
const ParentDC;
3872 bool checkTemplateArgument(
const TemplateArgument &Arg) {
3892 if (checkTemplateArgument(PackArg))
3904 llvm_unreachable(
"Unknown TemplateArgument::ArgKind enum");
3914 assert(FromFPT &&
"Must be called on FunctionProtoType");
3916 auto IsCXX11Lambda = [&]() {
3917 if (Importer.FromContext.getLangOpts().CPlusPlus14)
3923 QualType RetT = FromFPT->getReturnType();
3926 IsTypeDeclaredInsideVisitor Visitor(Def ? Def : D);
3927 return Visitor.CheckType(RetT);
3937 ExplicitExpr = importChecked(Err, ESpec.
getExpr());
3944 auto RedeclIt = Redecls.begin();
3947 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
3950 return ToRedeclOrErr.takeError();
3952 assert(*RedeclIt == D);
3960 return std::move(Err);
3975 if (!FoundFunctionOrErr)
3976 return FoundFunctionOrErr.takeError();
3977 if (
FunctionDecl *FoundFunction = *FoundFunctionOrErr) {
3978 if (
Decl *Def = FindAndMapDefinition(D, FoundFunction))
3980 FoundByLookup = FoundFunction;
3988 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
3989 for (
auto *FoundDecl : FoundDecls) {
3990 if (!FoundDecl->isInIdentifierNamespace(IDNS))
3993 if (
auto *FoundFunction = dyn_cast<FunctionDecl>(FoundDecl)) {
3998 if (
Decl *Def = FindAndMapDefinition(D, FoundFunction))
4000 FoundByLookup = FoundFunction;
4007 if (Importer.getToContext().getLangOpts().CPlusPlus)
4011 Importer.ToDiag(Loc, diag::warn_odr_function_type_inconsistent)
4012 << Name << D->
getType() << FoundFunction->getType();
4013 Importer.ToDiag(FoundFunction->getLocation(), diag::note_odr_value_here)
4014 << FoundFunction->getType();
4015 ConflictingDecls.push_back(FoundDecl);
4019 if (!ConflictingDecls.empty()) {
4021 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
4023 Name = NameOrErr.get();
4025 return NameOrErr.takeError();
4035 if (FoundByLookup) {
4045 "Templated function mapped to non-templated?");
4046 Importer.MapImported(DescribedD,
4049 return Importer.MapImported(D, FoundByLookup);
4061 return std::move(Err);
4072 bool UsedDifferentProtoType =
false;
4074 QualType FromReturnTy = FromFPT->getReturnType();
4083 Importer.FindFunctionDeclImportCycle.isCycle(D)) {
4084 FromReturnTy = Importer.getFromContext().VoidTy;
4085 UsedDifferentProtoType =
true;
4096 FromEPI = DefaultEPI;
4097 UsedDifferentProtoType =
true;
4099 FromTy = Importer.getFromContext().getFunctionType(
4100 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
4101 FromTSI = Importer.getFromContext().getTrivialTypeSourceInfo(
4105 Error Err = Error::success();
4106 auto ScopedReturnTypeDeclCycleDetector =
4107 Importer.FindFunctionDeclImportCycle.makeScopedCycleDetection(D);
4118 return std::move(Err);
4124 Parameters.push_back(*ToPOrErr);
4126 return ToPOrErr.takeError();
4131 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
4133 importExplicitSpecifier(Err, FromConstructor->getExplicitSpecifier());
4135 return std::move(Err);
4137 if (FromConstructor->isInheritingConstructor()) {
4139 import(FromConstructor->getInheritedConstructor());
4140 if (!ImportedInheritedCtor)
4141 return ImportedInheritedCtor.takeError();
4142 ToInheritedConstructor = *ImportedInheritedCtor;
4144 if (GetImportedOrCreateDecl<CXXConstructorDecl>(
4146 ToInnerLocStart, NameInfo, T, TInfo, ESpec, D->
UsesFPIntrin(),
4148 ToInheritedConstructor, TrailingRequiresClause))
4152 Error Err = Error::success();
4154 Err,
const_cast<FunctionDecl *
>(FromDtor->getOperatorDelete()));
4155 auto ToThisArg =
importChecked(Err, FromDtor->getOperatorDeleteThisArg());
4157 return std::move(Err);
4159 if (GetImportedOrCreateDecl<CXXDestructorDecl>(
4161 ToInnerLocStart, NameInfo, T, TInfo, D->
UsesFPIntrin(),
4163 TrailingRequiresClause))
4170 dyn_cast<CXXConversionDecl>(D)) {
4172 importExplicitSpecifier(Err, FromConversion->getExplicitSpecifier());
4174 return std::move(Err);
4175 if (GetImportedOrCreateDecl<CXXConversionDecl>(
4177 ToInnerLocStart, NameInfo, T, TInfo, D->
UsesFPIntrin(),
4181 }
else if (
auto *
Method = dyn_cast<CXXMethodDecl>(D)) {
4182 if (GetImportedOrCreateDecl<CXXMethodDecl>(
4184 ToInnerLocStart, NameInfo, T, TInfo,
Method->getStorageClass(),
4188 }
else if (
auto *Guide = dyn_cast<CXXDeductionGuideDecl>(D)) {
4190 importExplicitSpecifier(Err, Guide->getExplicitSpecifier());
4196 return std::move(Err);
4197 if (GetImportedOrCreateDecl<CXXDeductionGuideDecl>(
4198 ToFunction, D, Importer.getToContext(), DC, ToInnerLocStart, ESpec,
4199 NameInfo, T, TInfo, ToEndLoc, Ctor,
4200 Guide->getDeductionCandidateKind(), TrailingRequiresClause,
4204 if (GetImportedOrCreateDecl(
4205 ToFunction, D, Importer.getToContext(), DC, ToInnerLocStart,
4213 if (FoundByLookup) {
4252 Importer.getToContext(), {}, Msg));
4255 for (
auto *Param : Parameters) {
4256 Param->setOwningFunction(ToFunction);
4259 LT->update(Param, Importer.getToContext().getTranslationUnitDecl());
4261 ToFunction->setParams(Parameters);
4268 for (
unsigned I = 0, N = Parameters.size(); I != N; ++I)
4269 ProtoLoc.setParam(I, Parameters[I]);
4275 auto ToFTOrErr =
import(FromFT);
4277 return ToFTOrErr.takeError();
4281 if (
auto *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
4282 if (
unsigned NumInitializers = FromConstructor->getNumCtorInitializers()) {
4286 FromConstructor->inits(), CtorInitializers))
4287 return std::move(Err);
4290 llvm::copy(CtorInitializers, Memory);
4292 ToCtor->setCtorInitializers(Memory);
4293 ToCtor->setNumCtorInitializers(NumInitializers);
4299 return std::move(Err);
4301 if (
auto *FromCXXMethod = dyn_cast<CXXMethodDecl>(D))
4304 return std::move(Err);
4310 return std::move(Err);
4314 if (UsedDifferentProtoType) {
4316 ToFunction->
setType(*TyOrErr);
4318 return TyOrErr.takeError();
4322 return TSIOrErr.takeError();
4327 addDeclToContexts(D, ToFunction);
4330 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4333 return ToRedeclOrErr.takeError();
4367 return std::move(Err);
4372 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4373 for (
auto *FoundDecl : FoundDecls) {
4374 if (
FieldDecl *FoundField = dyn_cast<FieldDecl>(FoundDecl)) {
4381 if (Importer.IsStructurallyEquivalent(D->
getType(),
4382 FoundField->getType())) {
4383 Importer.MapImported(D, FoundField);
4391 if (
ExpectedExpr ToInitializerOrErr =
import(FromInitializer)) {
4394 assert(FoundField->hasInClassInitializer() &&
4395 "Field should have an in-class initializer if it has an "
4396 "expression for it.");
4397 if (!FoundField->getInClassInitializer())
4398 FoundField->setInClassInitializer(*ToInitializerOrErr);
4400 return ToInitializerOrErr.takeError();
4407 Importer.ToDiag(Loc, diag::warn_odr_field_type_inconsistent)
4408 << Name << D->
getType() << FoundField->getType();
4409 Importer.ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4410 << FoundField->getType();
4416 Error Err = Error::success();
4422 return std::move(Err);
4423 const Type *ToCapturedVLAType =
nullptr;
4424 if (
Error Err = Importer.importInto(
4426 return std::move(Err);
4429 if (GetImportedOrCreateDecl(ToField, D, Importer.getToContext(), DC,
4431 ToType, ToTInfo, ToBitWidth, D->
isMutable(),
4438 if (ToCapturedVLAType)
4445 return std::move(Err);
4446 if (ToInitializer) {
4448 if (AlreadyImported)
4449 assert(ToInitializer == AlreadyImported &&
4450 "Duplicate import of in-class initializer.");
4465 return std::move(Err);
4470 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4471 for (
unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
4472 if (
auto *FoundField = dyn_cast<IndirectFieldDecl>(FoundDecls[I])) {
4479 if (Importer.IsStructurallyEquivalent(D->
getType(),
4480 FoundField->getType(),
4482 Importer.MapImported(D, FoundField);
4487 if (!Name && I < N-1)
4491 Importer.ToDiag(Loc, diag::warn_odr_field_type_inconsistent)
4492 << Name << D->
getType() << FoundField->getType();
4493 Importer.ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
4494 << FoundField->getType();
4501 auto TypeOrErr =
import(D->
getType());
4503 return TypeOrErr.takeError();
4509 for (
auto *PI : D->
chain())
4511 NamedChain[i++] = *ToD;
4513 return ToD.takeError();
4517 if (GetImportedOrCreateDecl(ToIndirectField, D, Importer.getToContext(), DC,
4520 return ToIndirectField;
4525 return ToIndirectField;
4556 unsigned int FriendCount = 0;
4560 for (
FriendDecl *FoundFriend : RD->friends()) {
4561 if (FoundFriend == FD) {
4562 FriendPosition = FriendCount;
4569 assert(FriendPosition &&
"Friend decl not found in own parent.");
4571 return {FriendCount, *FriendPosition};
4578 return std::move(Err);
4585 for (
FriendDecl *ImportedFriend : RD->friends())
4587 ImportedEquivalentFriends.push_back(ImportedFriend);
4592 assert(ImportedEquivalentFriends.size() <= CountAndPosition.
TotalCount &&
4593 "Class with non-matching friends is imported, ODR check wrong?");
4594 if (ImportedEquivalentFriends.size() == CountAndPosition.
TotalCount)
4595 return Importer.MapImported(
4596 D, ImportedEquivalentFriends[CountAndPosition.
IndexOfDecl]);
4604 return std::move(Err);
4615 return TSIOrErr.takeError();
4619 auto **FromTPLists = D->getTrailingObjects();
4620 for (
unsigned I = 0; I < D->NumTPLists; I++) {
4621 if (
auto ListOrErr =
import(FromTPLists[I]))
4622 ToTPLists[I] = *ListOrErr;
4624 return ListOrErr.takeError();
4629 return LocationOrErr.takeError();
4631 if (!FriendLocOrErr)
4632 return FriendLocOrErr.takeError();
4634 if (!EllipsisLocOrErr)
4635 return EllipsisLocOrErr.takeError();
4638 if (GetImportedOrCreateDecl(FrD, D, Importer.getToContext(), DC,
4639 *LocationOrErr, ToFU, *FriendLocOrErr,
4640 *EllipsisLocOrErr, ToTPLists))
4656 return std::move(Err);
4661 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4662 for (
auto *FoundDecl : FoundDecls) {
4663 if (
ObjCIvarDecl *FoundIvar = dyn_cast<ObjCIvarDecl>(FoundDecl)) {
4664 if (Importer.IsStructurallyEquivalent(D->
getType(),
4665 FoundIvar->getType())) {
4666 Importer.MapImported(D, FoundIvar);
4670 Importer.ToDiag(Loc, diag::warn_odr_ivar_type_inconsistent)
4671 << Name << D->
getType() << FoundIvar->getType();
4672 Importer.ToDiag(FoundIvar->getLocation(), diag::note_odr_value_here)
4673 << FoundIvar->getType();
4679 Error Err = Error::success();
4685 return std::move(Err);
4688 if (GetImportedOrCreateDecl(
4691 ToType, ToTypeSourceInfo,
4703 auto RedeclIt = Redecls.begin();
4706 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
4709 return RedeclOrErr.takeError();
4711 assert(*RedeclIt == D);
4719 return std::move(Err);
4725 VarDecl *FoundByLookup =
nullptr;
4729 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4730 for (
auto *FoundDecl : FoundDecls) {
4731 if (!FoundDecl->isInIdentifierNamespace(IDNS))
4734 if (
auto *FoundVar = dyn_cast<VarDecl>(FoundDecl)) {
4737 if (Importer.IsStructurallyEquivalent(D->
getType(),
4738 FoundVar->getType())) {
4746 return Importer.MapImported(D, FoundDef);
4750 const VarDecl *FoundDInit =
nullptr;
4751 if (D->
getInit() && FoundVar->getAnyInitializer(FoundDInit))
4753 return Importer.MapImported(D,
const_cast<VarDecl*
>(FoundDInit));
4755 FoundByLookup = FoundVar;
4760 = Importer.getToContext().getAsArrayType(FoundVar->getType());
4762 = Importer.getToContext().getAsArrayType(D->
getType());
4763 if (FoundArray && TArray) {
4767 if (
auto TyOrErr =
import(D->
getType()))
4768 FoundVar->setType(*TyOrErr);
4770 return TyOrErr.takeError();
4772 FoundByLookup = FoundVar;
4776 FoundByLookup = FoundVar;
4781 Importer.ToDiag(Loc, diag::warn_odr_variable_type_inconsistent)
4782 << Name << D->
getType() << FoundVar->getType();
4783 Importer.ToDiag(FoundVar->getLocation(), diag::note_odr_value_here)
4784 << FoundVar->getType();
4785 ConflictingDecls.push_back(FoundDecl);
4789 if (!ConflictingDecls.empty()) {
4791 Name, DC, IDNS, ConflictingDecls.data(), ConflictingDecls.size());
4793 Name = NameOrErr.get();
4795 return NameOrErr.takeError();
4799 Error Err = Error::success();
4805 return std::move(Err);
4808 if (
auto *FromDecomp = dyn_cast<DecompositionDecl>(D)) {
4812 return std::move(Err);
4814 if (GetImportedOrCreateDecl(
4815 ToDecomp, FromDecomp, Importer.getToContext(), DC, ToInnerLocStart,
4821 if (GetImportedOrCreateDecl(ToVar, D, Importer.getToContext(), DC,
4822 ToInnerLocStart, Loc,
4837 if (FoundByLookup) {
4846 return ToVTOrErr.takeError();
4853 return ToInstOrErr.takeError();
4854 if (
ExpectedSLoc POIOrErr =
import(MSI->getPointOfInstantiation()))
4857 return POIOrErr.takeError();
4861 return std::move(Err);
4866 addDeclToContexts(D, ToVar);
4869 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
4872 return RedeclOrErr.takeError();
4881 DeclContext *DC = Importer.getToContext().getTranslationUnitDecl();
4883 Error Err = Error::success();
4888 return std::move(Err);
4892 if (GetImportedOrCreateDecl(ToParm, D, Importer.getToContext(), DC,
4893 ToLocation, ToDeclName.getAsIdentifierInfo(),
4905 return LocOrErr.takeError();
4914 return ToDefArgOrErr.takeError();
4918 if (
auto ToDefArgOrErr =
import(FromParam->
getDefaultArg()))
4921 return ToDefArgOrErr.takeError();
4924 return Error::success();
4929 Error Err = Error::success();
4934 return std::move(Err);
4941 DeclContext *DC = Importer.getToContext().getTranslationUnitDecl();
4943 Error Err = Error::success();
4950 return std::move(Err);
4953 if (GetImportedOrCreateDecl(ToParm, D, Importer.getToContext(), DC,
4954 ToInnerLocStart, ToLocation,
4955 ToDeclName.getAsIdentifierInfo(), ToType,
4964 return std::move(Err);
4984 return std::move(Err);
4988 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
4989 for (
auto *FoundDecl : FoundDecls) {
4990 if (
auto *FoundMethod = dyn_cast<ObjCMethodDecl>(FoundDecl)) {
4996 FoundMethod->getReturnType())) {
4997 Importer.ToDiag(Loc, diag::warn_odr_objc_method_result_type_inconsistent)
4999 << FoundMethod->getReturnType();
5000 Importer.ToDiag(FoundMethod->getLocation(),
5001 diag::note_odr_objc_method_here)
5008 if (D->
param_size() != FoundMethod->param_size()) {
5009 Importer.ToDiag(Loc, diag::warn_odr_objc_method_num_params_inconsistent)
5011 << D->
param_size() << FoundMethod->param_size();
5012 Importer.ToDiag(FoundMethod->getLocation(),
5013 diag::note_odr_objc_method_here)
5021 PEnd = D->
param_end(), FoundP = FoundMethod->param_begin();
5022 P != PEnd; ++
P, ++FoundP) {
5023 if (!Importer.IsStructurallyEquivalent((*P)->getType(),
5024 (*FoundP)->getType())) {
5025 Importer.FromDiag((*P)->getLocation(),
5026 diag::warn_odr_objc_method_param_type_inconsistent)
5028 << (*P)->getType() << (*FoundP)->getType();
5029 Importer.ToDiag((*FoundP)->getLocation(), diag::note_odr_value_here)
5030 << (*FoundP)->getType();
5038 if (D->
isVariadic() != FoundMethod->isVariadic()) {
5039 Importer.ToDiag(Loc, diag::warn_odr_objc_method_variadic_inconsistent)
5041 Importer.ToDiag(FoundMethod->getLocation(),
5042 diag::note_odr_objc_method_here)
5049 return Importer.MapImported(D, FoundMethod);
5053 Error Err = Error::success();
5056 auto ToReturnTypeSourceInfo =
5059 return std::move(Err);
5062 if (GetImportedOrCreateDecl(
5063 ToMethod, D, Importer.getToContext(), Loc, ToEndLoc,
5077 ToParams.push_back(*ToPOrErr);
5079 return ToPOrErr.takeError();
5083 for (
auto *ToParam : ToParams) {
5084 ToParam->setOwningFunction(ToMethod);
5092 return std::move(Err);
5094 ToMethod->
setMethodParams(Importer.getToContext(), ToParams, ToSelLocs);
5116 return std::move(Err);
5120 Error Err = Error::success();
5126 return std::move(Err);
5129 if (GetImportedOrCreateDecl(
5133 ToColonLoc, ToTypeSourceInfo))
5139 return std::move(Err);
5140 Result->setTypeForDecl(ToTypeForDecl);
5141 Result->setLexicalDeclContext(LexicalDC);
5152 return std::move(Err);
5158 return std::move(Err);
5166 Error Err = Error::success();
5172 return std::move(Err);
5174 if (GetImportedOrCreateDecl(ToCategory, D, Importer.getToContext(), DC,
5190 return PListOrErr.takeError();
5199 FromProto != FromProtoEnd;
5200 ++FromProto, ++FromProtoLoc) {
5202 Protocols.push_back(*ToProtoOrErr);
5204 return ToProtoOrErr.takeError();
5206 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5207 ProtocolLocs.push_back(*ToProtoLocOrErr);
5209 return ToProtoLocOrErr.takeError();
5214 ProtocolLocs.data(), Importer.getToContext());
5217 Importer.MapImported(D, ToCategory);
5222 return std::move(Err);
5230 return ToImplOrErr.takeError();
5242 return Error::success();
5255 FromProto != FromProtoEnd;
5256 ++FromProto, ++FromProtoLoc) {
5258 Protocols.push_back(*ToProtoOrErr);
5260 return ToProtoOrErr.takeError();
5262 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5263 ProtocolLocs.push_back(*ToProtoLocOrErr);
5265 return ToProtoLocOrErr.takeError();
5271 ProtocolLocs.data(), Importer.getToContext());
5278 return Error::success();
5288 return Importer.MapImported(D, *ImportedDefOrErr);
5290 return ImportedDefOrErr.takeError();
5299 return std::move(Err);
5304 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5305 for (
auto *FoundDecl : FoundDecls) {
5309 if ((MergeWithProtocol = dyn_cast<ObjCProtocolDecl>(FoundDecl)))
5316 if (!ToAtBeginLocOrErr)
5317 return ToAtBeginLocOrErr.takeError();
5319 if (GetImportedOrCreateDecl(ToProto, D, Importer.getToContext(), DC,
5328 Importer.MapImported(D, ToProto);
5332 return std::move(Err);
5340 return std::move(Err);
5343 if (!ExternLocOrErr)
5344 return ExternLocOrErr.takeError();
5348 return LangLocOrErr.takeError();
5353 if (GetImportedOrCreateDecl(ToLinkageSpec, D, Importer.getToContext(), DC,
5354 *ExternLocOrErr, *LangLocOrErr,
5356 return ToLinkageSpec;
5360 if (!RBraceLocOrErr)
5361 return RBraceLocOrErr.takeError();
5368 return ToLinkageSpec;
5379 return ToShadowOrErr.takeError();
5390 return std::move(Err);
5394 Error Err = Error::success();
5399 return std::move(Err);
5403 return std::move(Err);
5406 if (GetImportedOrCreateDecl(ToUsing, D, Importer.getToContext(), DC,
5407 ToUsingLoc, ToQualifierLoc, NameInfo,
5415 Importer.getFromContext().getInstantiatedFromUsingDecl(D)) {
5417 Importer.getToContext().setInstantiatedFromUsingDecl(
5418 ToUsing, *ToPatternOrErr);
5420 return ToPatternOrErr.takeError();
5432 return std::move(Err);
5436 Error Err = Error::success();
5442 return std::move(Err);
5445 if (GetImportedOrCreateDecl(ToUsingEnum, D, Importer.getToContext(), DC,
5446 ToUsingLoc, ToEnumLoc, ToNameLoc, ToEnumType))
5453 Importer.getFromContext().getInstantiatedFromUsingEnumDecl(D)) {
5455 Importer.getToContext().setInstantiatedFromUsingEnumDecl(ToUsingEnum,
5458 return ToPatternOrErr.takeError();
5470 return std::move(Err);
5475 if (!ToIntroducerOrErr)
5476 return ToIntroducerOrErr.takeError();
5480 return ToTargetOrErr.takeError();
5483 if (
auto *FromConstructorUsingShadow =
5484 dyn_cast<ConstructorUsingShadowDecl>(D)) {
5485 Error Err = Error::success();
5487 Err, FromConstructorUsingShadow->getNominatedBaseClassShadowDecl());
5489 return std::move(Err);
5495 if (GetImportedOrCreateDecl<ConstructorUsingShadowDecl>(
5496 ToShadow, D, Importer.getToContext(), DC, Loc,
5498 Nominated ? Nominated : *ToTargetOrErr,
5499 FromConstructorUsingShadow->constructsVirtualBase()))
5502 if (GetImportedOrCreateDecl(ToShadow, D, Importer.getToContext(), DC, Loc,
5503 Name, *ToIntroducerOrErr, *ToTargetOrErr))
5511 Importer.getFromContext().getInstantiatedFromUsingShadowDecl(D)) {
5513 Importer.getToContext().setInstantiatedFromUsingShadowDecl(
5514 ToShadow, *ToPatternOrErr);
5518 return ToPatternOrErr.takeError();
5532 return std::move(Err);
5537 if (!ToComAncestorOrErr)
5538 return ToComAncestorOrErr.takeError();
5540 Error Err = Error::success();
5543 auto ToNamespaceKeyLocation =
5548 return std::move(Err);
5551 if (GetImportedOrCreateDecl(ToUsingDir, D, Importer.getToContext(), DC,
5553 ToNamespaceKeyLocation,
5556 ToNominatedNamespace, *ToComAncestorOrErr))
5571 return std::move(Err);
5575 auto ToInstantiatedFromUsingOrErr =
5577 if (!ToInstantiatedFromUsingOrErr)
5578 return ToInstantiatedFromUsingOrErr.takeError();
5581 return std::move(Err);
5584 if (GetImportedOrCreateDecl(ToUsingPack, D, Importer.getToContext(), DC,
5589 addDeclToContexts(D, ToUsingPack);
5601 return std::move(Err);
5605 Error Err = Error::success();
5611 return std::move(Err);
5615 return std::move(Err);
5618 if (GetImportedOrCreateDecl(ToUsingValue, D, Importer.getToContext(), DC,
5619 ToUsingLoc, ToQualifierLoc, NameInfo,
5621 return ToUsingValue;
5627 return ToUsingValue;
5637 return std::move(Err);
5641 Error Err = Error::success();
5647 return std::move(Err);
5650 if (GetImportedOrCreateDecl(ToUsing, D, Importer.getToContext(), DC,
5651 ToUsingLoc, ToTypenameLoc,
5652 ToQualifierLoc, Loc, Name, ToEllipsisLoc))
5663 Decl* ToD =
nullptr;
5665#define BuiltinTemplate(BTName) \
5666 case BuiltinTemplateKind::BTK##BTName: \
5667 ToD = Importer.getToContext().get##BTName##Decl(); \
5669#include "clang/Basic/BuiltinTemplates.inc"
5671 assert(ToD &&
"BuiltinTemplateDecl of unsupported kind!");
5672 Importer.MapImported(D, ToD);
5682 if (
auto FromSuperOrErr =
import(FromSuper))
5683 FromSuper = *FromSuperOrErr;
5685 return FromSuperOrErr.takeError();
5689 if ((
bool)FromSuper != (
bool)ToSuper ||
5692 diag::warn_odr_objc_superclass_inconsistent)
5699 diag::note_odr_objc_missing_superclass);
5702 diag::note_odr_objc_superclass)
5706 diag::note_odr_objc_missing_superclass);
5712 return Error::success();
5723 return SuperTInfoOrErr.takeError();
5734 FromProto != FromProtoEnd;
5735 ++FromProto, ++FromProtoLoc) {
5737 Protocols.push_back(*ToProtoOrErr);
5739 return ToProtoOrErr.takeError();
5741 if (
ExpectedSLoc ToProtoLocOrErr =
import(*FromProtoLoc))
5742 ProtocolLocs.push_back(*ToProtoLocOrErr);
5744 return ToProtoLocOrErr.takeError();
5750 ProtocolLocs.data(), Importer.getToContext());
5755 auto ToCatOrErr =
import(Cat);
5757 return ToCatOrErr.takeError();
5766 return ToImplOrErr.takeError();
5773 return Error::success();
5782 for (
auto *fromTypeParam : *list) {
5783 if (
auto toTypeParamOrErr =
import(fromTypeParam))
5784 toTypeParams.push_back(*toTypeParamOrErr);
5786 return toTypeParamOrErr.takeError();
5790 if (!LAngleLocOrErr)
5791 return LAngleLocOrErr.takeError();
5794 if (!RAngleLocOrErr)
5795 return RAngleLocOrErr.takeError();
5810 return Importer.MapImported(D, *ImportedDefOrErr);
5812 return ImportedDefOrErr.takeError();
5821 return std::move(Err);
5827 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
5828 for (
auto *FoundDecl : FoundDecls) {
5832 if ((MergeWithIface = dyn_cast<ObjCInterfaceDecl>(FoundDecl)))
5840 if (!AtBeginLocOrErr)
5841 return AtBeginLocOrErr.takeError();
5843 if (GetImportedOrCreateDecl(
5844 ToIface, D, Importer.getToContext(), DC,
5852 Importer.MapImported(D, ToIface);
5855 if (
auto ToPListOrErr =
5859 return ToPListOrErr.takeError();
5863 return std::move(Err);
5872 return std::move(Err);
5878 return std::move(Err);
5880 Error Err = Error::success();
5885 return std::move(Err);
5887 if (GetImportedOrCreateDecl(
5888 ToImpl, D, Importer.getToContext(), DC,
5889 Importer.Import(D->
getIdentifier()), Category->getClassInterface(),
5890 ToLocation, ToAtStartLoc, ToCategoryNameLoc))
5895 Category->setImplementation(ToImpl);
5898 Importer.MapImported(D, ToImpl);
5900 return std::move(Err);
5910 return std::move(Err);
5915 return std::move(Err);
5923 return std::move(Err);
5925 Error Err = Error::success();
5932 return std::move(Err);
5934 if (GetImportedOrCreateDecl(Impl, D, Importer.getToContext(),
5943 Impl->setLexicalDeclContext(LexicalDC);
5957 Importer.ToDiag(Impl->getLocation(),
5958 diag::warn_odr_objc_superclass_inconsistent)
5962 if (Impl->getSuperClass())
5963 Importer.ToDiag(Impl->getLocation(),
5964 diag::note_odr_objc_superclass)
5965 << Impl->getSuperClass()->getDeclName();
5967 Importer.ToDiag(Impl->getLocation(),
5968 diag::note_odr_objc_missing_superclass);
5971 diag::note_odr_objc_superclass)
5975 diag::note_odr_objc_missing_superclass);
5983 return std::move(Err);
5995 return std::move(Err);
6000 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6001 for (
auto *FoundDecl : FoundDecls) {
6002 if (
auto *FoundProp = dyn_cast<ObjCPropertyDecl>(FoundDecl)) {
6009 if (!Importer.IsStructurallyEquivalent(D->
getType(),
6010 FoundProp->getType())) {
6011 Importer.ToDiag(Loc, diag::warn_odr_objc_property_type_inconsistent)
6012 << Name << D->
getType() << FoundProp->getType();
6013 Importer.ToDiag(FoundProp->getLocation(), diag::note_odr_value_here)
6014 << FoundProp->getType();
6022 Importer.MapImported(D, FoundProp);
6027 Error Err = Error::success();
6033 return std::move(Err);
6037 if (GetImportedOrCreateDecl(
6038 ToProperty, D, Importer.getToContext(), DC, Loc,
6040 ToLParenLoc, ToType,
6052 return std::move(Err);
6072 return std::move(Err);
6076 return std::move(Err);
6083 return std::move(Err);
6086 = InImpl->FindPropertyImplDecl(
Property->getIdentifier(),
6090 Error Err = Error::success();
6093 auto ToPropertyIvarDeclLoc =
6096 return std::move(Err);
6098 if (GetImportedOrCreateDecl(ToImpl, D, Importer.getToContext(), DC,
6102 ToPropertyIvarDeclLoc))
6112 diag::warn_odr_objc_property_impl_kind_inconsistent)
6117 diag::note_odr_objc_property_impl_kind)
6128 diag::warn_odr_objc_synthesize_ivar_inconsistent)
6133 diag::note_odr_objc_synthesize_ivar_here)
6140 Importer.MapImported(D, ToImpl);
6148 Error Err = Error::success();
6152 return std::move(Err);
6156 return Importer.ToContext.getTemplateParamObjectDecl(T,
V);
6158 (void)GetImportedOrCreateSpecialDecl(ToD,
Create, D, ToType, ToValue);
6170 return BeginLocOrErr.takeError();
6174 return LocationOrErr.takeError();
6177 if (GetImportedOrCreateDecl(
6178 ToD, D, Importer.getToContext(),
6180 *BeginLocOrErr, *LocationOrErr,
6189 Error Err = Error::success();
6190 auto ToConceptRef =
importChecked(Err, TC->getConceptReference());
6191 auto ToIDC =
importChecked(Err, TC->getImmediatelyDeclaredConstraint());
6193 return std::move(Err);
6198 if (
Error Err = importTemplateParameterDefaultArgument(D, ToD))
6207 Error Err = Error::success();
6214 return std::move(Err);
6217 if (GetImportedOrCreateDecl(ToD, D, Importer.getToContext(),
6219 ToInnerLocStart, ToLocation, D->
getDepth(),
6221 ToDeclName.getAsIdentifierInfo(), ToType,
6225 Err = importTemplateParameterDefaultArgument(D, ToD);
6234 bool IsCanonical =
false;
6235 if (
auto *CanonD = Importer.getFromContext()
6236 .findCanonicalTemplateTemplateParmDeclInternal(D);
6243 return NameOrErr.takeError();
6248 return LocationOrErr.takeError();
6252 if (!TemplateParamsOrErr)
6253 return TemplateParamsOrErr.takeError();
6256 if (GetImportedOrCreateDecl(
6257 ToD, D, Importer.getToContext(),
6264 if (
Error Err = importTemplateParameterDefaultArgument(D, ToD))
6268 return Importer.getToContext()
6269 .insertCanonicalTemplateTemplateParmDeclInternal(ToD);
6277 assert(D->getTemplatedDecl() &&
"Should be called on templates only");
6278 auto *ToTemplatedDef = D->getTemplatedDecl()->getDefinition();
6279 if (!ToTemplatedDef)
6281 auto *TemplateWithDef = ToTemplatedDef->getDescribedTemplate();
6282 return cast_or_null<T>(TemplateWithDef);
6293 return std::move(Err);
6305 TD->getLexicalDeclContext()->isDependentContext();
6307 bool DependentFriend = IsDependentFriend(D);
6314 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6315 for (
auto *FoundDecl : FoundDecls) {
6320 auto *FoundTemplate = dyn_cast<ClassTemplateDecl>(FoundDecl);
6321 if (FoundTemplate) {
6326 bool IgnoreTemplateParmDepth =
6330 IgnoreTemplateParmDepth)) {
6331 if (DependentFriend || IsDependentFriend(FoundTemplate))
6337 return Importer.MapImported(D, TemplateWithDef);
6339 FoundByLookup = FoundTemplate;
6357 ConflictingDecls.push_back(FoundDecl);
6361 if (!ConflictingDecls.empty()) {
6364 ConflictingDecls.size());
6366 Name = NameOrErr.get();
6368 return NameOrErr.takeError();
6375 if (!TemplateParamsOrErr)
6376 return TemplateParamsOrErr.takeError();
6381 return std::move(Err);
6385 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), DC, Loc, Name,
6386 *TemplateParamsOrErr, ToTemplated))
6394 addDeclToContexts(D, D2);
6395 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6397 if (FoundByLookup) {
6411 "Found decl must have its templated decl set");
6414 if (ToTemplated != PrevTemplated)
6428 return std::move(Err);
6433 return std::move(Err);
6439 return std::move(Err);
6442 void *InsertPos =
nullptr;
6445 dyn_cast<ClassTemplatePartialSpecializationDecl>(D);
6453 return ToTPListOrErr.takeError();
6454 ToTPList = *ToTPListOrErr;
6465 Importer.MapImported(D, PrevDefinition);
6468 for (
auto *FromField : D->
fields()) {
6469 auto ToOrErr =
import(FromField);
6471 return ToOrErr.takeError();
6477 auto ToOrErr =
import(FromM);
6479 return ToOrErr.takeError();
6487 return PrevDefinition;
6498 return BeginLocOrErr.takeError();
6501 return IdLocOrErr.takeError();
6507 return std::move(Err);
6513 if (GetImportedOrCreateDecl<ClassTemplatePartialSpecializationDecl>(
6514 D2, D, Importer.getToContext(), D->
getTagKind(), DC, *BeginLocOrErr,
6515 *IdLocOrErr, ToTPList, ClassTemplate,
ArrayRef(TemplateArgs),
6517 cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl)))
6529 PartSpec2->setInstantiatedFromMember(*ToInstOrErr);
6531 return ToInstOrErr.takeError();
6533 updateLookupTableForTemplateParameters(*ToTPList);
6535 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), D->
getTagKind(),
6536 DC, *BeginLocOrErr, *IdLocOrErr, ClassTemplate,
6561 return BraceRangeOrErr.takeError();
6564 return std::move(Err);
6570 return LocOrErr.takeError();
6578 return LocOrErr.takeError();
6583 return LocOrErr.takeError();
6589 return POIOrErr.takeError();
6595 if (
auto *CTD = dyn_cast<ClassTemplateDecl *>(
P)) {
6596 if (
auto CTDorErr =
import(CTD))
6600 auto CTPSDOrErr =
import(CTPSD);
6602 return CTPSDOrErr.takeError();
6605 for (
unsigned I = 0; I < DArgs.
size(); ++I) {
6607 if (
auto ArgOrErr =
import(DArg))
6608 D2ArgsVec[I] = *ArgOrErr;
6610 return ArgOrErr.takeError();
6620 return std::move(Err);
6632 return std::move(Err);
6638 "Variable templates cannot be declared at function scope");
6641 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6643 for (
auto *FoundDecl : FoundDecls) {
6647 if (
VarTemplateDecl *FoundTemplate = dyn_cast<VarTemplateDecl>(FoundDecl)) {
6657 assert(FoundTemplate->getDeclContext()->isRecord() &&
6658 "Member variable template imported as non-member, "
6659 "inconsistent imported AST?");
6661 return Importer.MapImported(D, FoundDef);
6663 return Importer.MapImported(D, FoundTemplate);
6666 return Importer.MapImported(D, FoundDef);
6668 FoundByLookup = FoundTemplate;
6671 ConflictingDecls.push_back(FoundDecl);
6675 if (!ConflictingDecls.empty()) {
6678 ConflictingDecls.size());
6680 Name = NameOrErr.get();
6682 return NameOrErr.takeError();
6691 return TypeOrErr.takeError();
6696 return std::move(Err);
6700 if (!TemplateParamsOrErr)
6701 return TemplateParamsOrErr.takeError();
6704 if (GetImportedOrCreateDecl(ToVarTD, D, Importer.getToContext(), DC, Loc,
6705 Name, *TemplateParamsOrErr, ToTemplated))
6713 if (DC != Importer.getToContext().getTranslationUnitDecl())
6714 updateLookupTableForTemplateParameters(**TemplateParamsOrErr);
6716 if (FoundByLookup) {
6720 auto *PrevTemplated =
6722 if (ToTemplated != PrevTemplated)
6737 auto RedeclIt = Redecls.begin();
6740 for (; RedeclIt != Redecls.end() && *RedeclIt != D; ++RedeclIt) {
6743 return RedeclOrErr.takeError();
6745 assert(*RedeclIt == D);
6749 return std::move(Err);
6754 return std::move(Err);
6759 return BeginLocOrErr.takeError();
6763 return IdLocOrErr.takeError();
6769 return std::move(Err);
6772 void *InsertPos =
nullptr;
6774 VarTemplate->findSpecialization(TemplateArgs, InsertPos);
6775 if (FoundSpecialization) {
6783 "Member variable template specialization imported as non-member, "
6784 "inconsistent imported AST?");
6786 return Importer.MapImported(D, FoundDef);
6788 return Importer.MapImported(D, FoundSpecialization);
6793 return Importer.MapImported(D, FoundDef);
6805 return std::move(Err);
6810 if (
auto *FromPartial = dyn_cast<PartVarSpecDecl>(D)) {
6811 auto ToTPListOrErr =
import(FromPartial->getTemplateParameters());
6813 return ToTPListOrErr.takeError();
6815 PartVarSpecDecl *ToPartial;
6816 if (GetImportedOrCreateDecl(ToPartial, D, Importer.getToContext(), DC,
6817 *BeginLocOrErr, *IdLocOrErr, *ToTPListOrErr,
6823 import(FromPartial->getInstantiatedFromMember()))
6824 ToPartial->setInstantiatedFromMember(*ToInstOrErr);
6826 return ToInstOrErr.takeError();
6828 if (FromPartial->isMemberSpecialization())
6829 ToPartial->setMemberSpecialization();
6837 if (GetImportedOrCreateDecl(D2, D, Importer.getToContext(), DC,
6846 if (!
VarTemplate->findSpecialization(TemplateArgs, InsertPos))
6851 return std::move(Err);
6856 return TInfoOrErr.takeError();
6863 return POIOrErr.takeError();
6874 return LocOrErr.takeError();
6882 return std::move(Err);
6884 if (FoundSpecialization)
6887 addDeclToContexts(D, D2);
6890 for (++RedeclIt; RedeclIt != Redecls.end(); ++RedeclIt) {
6893 return RedeclOrErr.takeError();
6907 return std::move(Err);
6919 auto FoundDecls = Importer.findDeclsInToCtx(DC, Name);
6920 for (
auto *FoundDecl : FoundDecls) {
6921 if (!FoundDecl->isInIdentifierNamespace(IDNS))
6924 if (
auto *FoundTemplate = dyn_cast<FunctionTemplateDecl>(FoundDecl)) {
6931 return Importer.MapImported(D, TemplateWithDef);
6933 FoundByLookup = FoundTemplate;
6943 return ParamsOrErr.takeError();
6948 return std::move(Err);
6965 OldParamDC.reserve(Params->
size());
6966 llvm::transform(*Params, std::back_inserter(OldParamDC),
6970 if (GetImportedOrCreateDecl(ToFunc, D, Importer.getToContext(), DC, Loc, Name,
6971 Params, TemplatedFD))
6985 ToFunc->setLexicalDeclContext(LexicalDC);
6986 addDeclToContexts(D, ToFunc);
6989 if (LT && !OldParamDC.empty()) {
6990 for (
unsigned int I = 0; I < OldParamDC.size(); ++I)
6991 LT->updateForced(Params->
getParam(I), OldParamDC[I]);
6994 if (FoundByLookup) {
6999 "Found decl must have its templated decl set");
7000 auto *PrevTemplated =
7002 if (TemplatedFD != PrevTemplated)
7019 return std::move(Err);
7022 if (GetImportedOrCreateDecl(To, D, Importer.getToContext(), DC, LocationOrErr,
7023 NameDeclOrErr, ToTemplateParameters,
7037 return std::move(Err);
7040 if (GetImportedOrCreateDecl(To, D, Importer.getToContext(), DC, RequiresLoc))
7053 return std::move(Err);
7057 return std::move(Err);
7060 if (GetImportedOrCreateDecl(To, D, Importer.getToContext(), DC, ToSL, ToArgs))
7072 Importer.FromDiag(S->
getBeginLoc(), diag::err_unsupported_ast_node)
7079 if (Importer.returnWithErrorInTest())
7086 Names.push_back(ToII);
7089 for (
unsigned I = 0, E = S->
getNumInputs(); I != E; I++) {
7093 Names.push_back(ToII);
7099 Clobbers.push_back(*ClobberOrErr);
7101 return ClobberOrErr.takeError();
7108 Constraints.push_back(*OutputOrErr);
7110 return OutputOrErr.takeError();
7113 for (
unsigned I = 0, E = S->
getNumInputs(); I != E; I++) {
7115 Constraints.push_back(*InputOrErr);
7117 return InputOrErr.takeError();
7123 return std::move(Err);
7127 return std::move(Err);
7131 return std::move(Err);
7135 return AsmLocOrErr.takeError();
7138 return AsmStrOrErr.takeError();
7140 if (!RParenLocOrErr)
7141 return RParenLocOrErr.takeError();
7143 return new (Importer.getToContext())
GCCAsmStmt(
7144 Importer.getToContext(),
7162 Error Err = Error::success();
7167 return std::move(Err);
7168 return new (Importer.getToContext())
DeclStmt(ToDG, ToBeginLoc, ToEndLoc);
7173 if (!ToSemiLocOrErr)
7174 return ToSemiLocOrErr.takeError();
7175 return new (Importer.getToContext())
NullStmt(
7183 return std::move(Err);
7186 if (!ToLBracLocOrErr)
7187 return ToLBracLocOrErr.takeError();
7190 if (!ToRBracLocOrErr)
7191 return ToRBracLocOrErr.takeError();
7196 *ToLBracLocOrErr, *ToRBracLocOrErr);
7201 Error Err = Error::success();
7209 return std::move(Err);
7212 ToCaseLoc, ToEllipsisLoc, ToColonLoc);
7213 ToStmt->setSubStmt(ToSubStmt);
7220 Error Err = Error::success();
7225 return std::move(Err);
7228 ToDefaultLoc, ToColonLoc, ToSubStmt);
7233 Error Err = Error::success();
7238 return std::move(Err);
7240 return new (Importer.getToContext())
LabelStmt(
7241 ToIdentLoc, ToLabelDecl, ToSubStmt);
7246 if (!ToAttrLocOrErr)
7247 return ToAttrLocOrErr.takeError();
7251 return std::move(Err);
7253 if (!ToSubStmtOrErr)
7254 return ToSubStmtOrErr.takeError();
7257 Importer.getToContext(), *ToAttrLocOrErr, ToAttrs, *ToSubStmtOrErr);
7262 Error Err = Error::success();
7273 return std::move(Err);
7276 ToInit, ToConditionVariable, ToCond, ToLParenLoc,
7277 ToRParenLoc, ToThen, ToElseLoc, ToElse);
7282 Error Err = Error::success();
7291 return std::move(Err);
7295 ToCond, ToLParenLoc, ToRParenLoc);
7296 ToStmt->setBody(ToBody);
7297 ToStmt->setSwitchLoc(ToSwitchLoc);
7305 return ToSCOrErr.takeError();
7306 if (LastChainedSwitchCase)
7309 ToStmt->setSwitchCaseList(*ToSCOrErr);
7310 LastChainedSwitchCase = *ToSCOrErr;
7318 Error Err = Error::success();
7326 return std::move(Err);
7329 ToBody, ToWhileLoc, ToLParenLoc, ToRParenLoc);
7334 Error Err = Error::success();
7341 return std::move(Err);
7343 return new (Importer.getToContext())
DoStmt(
7344 ToBody, ToCond, ToDoLoc, ToWhileLoc, ToRParenLoc);
7349 Error Err = Error::success();
7359 return std::move(Err);
7361 return new (Importer.getToContext())
ForStmt(
7362 Importer.getToContext(),
7363 ToInit, ToCond, ToConditionVariable, ToInc, ToBody, ToForLoc, ToLParenLoc,
7369 Error Err = Error::success();
7374 return std::move(Err);
7376 return new (Importer.getToContext())
GotoStmt(
7377 ToLabel, ToGotoLoc, ToLabelLoc);
7382 Error Err = Error::success();
7387 return std::move(Err);
7390 ToGotoLoc, ToStarLoc, ToTarget);
7393template <
typename StmtClass>
7396 Error Err = Error::success();
7397 auto ToLoc = NodeImporter.
importChecked(Err, S->getKwLoc());
7398 auto ToLabelLoc = S->hasLabelTarget()
7401 auto ToDecl = S->hasLabelTarget()
7405 return std::move(Err);
7406 return new (Importer.
getToContext()) StmtClass(ToLoc, ToLabelLoc, ToDecl);
7419 Error Err = Error::success();
7424 return std::move(Err);
7432 Error Err = Error::success();
7437 return std::move(Err);
7440 ToCatchLoc, ToExceptionDecl, ToHandlerBlock);
7446 return ToTryLocOrErr.takeError();
7449 if (!ToTryBlockOrErr)
7450 return ToTryBlockOrErr.takeError();
7453 for (
unsigned HI = 0, HE = S->
getNumHandlers(); HI != HE; ++HI) {
7455 if (
auto ToHandlerOrErr =
import(FromHandler))
7456 ToHandlers[HI] = *ToHandlerOrErr;
7458 return ToHandlerOrErr.takeError();
7467 Error Err = Error::success();
7481 return std::move(Err);
7484 ToInit, ToRangeStmt, ToBeginStmt, ToEndStmt, ToCond, ToInc, ToLoopVarStmt,
7485 ToBody, ToForLoc, ToCoawaitLoc, ToColonLoc, ToRParenLoc);
7490 Error Err = Error::success();
7497 return std::move(Err);
7508 Error Err = Error::success();
7514 return std::move(Err);
7517 ToAtCatchLoc, ToRParenLoc, ToCatchParamDecl, ToCatchBody);
7522 if (!ToAtFinallyLocOrErr)
7523 return ToAtFinallyLocOrErr.takeError();
7525 if (!ToAtFinallyStmtOrErr)
7526 return ToAtFinallyStmtOrErr.takeError();
7528 *ToAtFinallyStmtOrErr);
7533 Error Err = Error::success();
7538 return std::move(Err);
7543 if (
ExpectedStmt ToCatchStmtOrErr =
import(FromCatchStmt))
7544 ToCatchStmts[CI] = *ToCatchStmtOrErr;
7546 return ToCatchStmtOrErr.takeError();
7550 ToAtTryLoc, ToTryBody,
7551 ToCatchStmts.begin(), ToCatchStmts.size(),
7558 Error Err = Error::success();
7563 return std::move(Err);
7566 ToAtSynchronizedLoc, ToSynchExpr, ToSynchBody);
7571 if (!ToThrowLocOrErr)
7572 return ToThrowLocOrErr.takeError();
7574 if (!ToThrowExprOrErr)
7575 return ToThrowExprOrErr.takeError();
7577 *ToThrowLocOrErr, *ToThrowExprOrErr);
7584 return ToAtLocOrErr.takeError();
7586 if (!ToSubStmtOrErr)
7587 return ToSubStmtOrErr.takeError();
7596 Importer.FromDiag(E->
getBeginLoc(), diag::err_unsupported_ast_node)
7602 Error Err = Error::success();
7607 return std::move(Err);
7609 if (!ParentContextOrErr)
7610 return ParentContextOrErr.takeError();
7612 return new (Importer.getToContext())
7614 RParenLoc, *ParentContextOrErr);
7619 Error Err = Error::success();
7626 return std::move(Err);
7628 return new (Importer.getToContext())
VAArgExpr(
7629 ToBuiltinLoc, ToSubExpr, ToWrittenTypeInfo, ToRParenLoc, ToType,
7635 Error Err = Error::success();
7643 return std::move(Err);
7652 return new (Importer.getToContext())
7653 ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType,
VK, OK,
7654 ToRParenLoc, CondIsTrue);
7658 Error Err = Error::success();
7665 return std::move(Err);
7668 Importer.getToContext(), ToSrcExpr, ToTSI, ToType, E->
getValueKind(),
7674 Error Err = Error::success();
7682 ToSubExprs.resize(NumSubExprs);
7685 return std::move(Err);
7688 Importer.getToContext(), ToSubExprs, ToType, ToBeginLoc, ToRParenLoc);
7694 return TypeOrErr.takeError();
7698 return BeginLocOrErr.takeError();
7700 return new (Importer.getToContext())
GNUNullExpr(*TypeOrErr, *BeginLocOrErr);
7705 Error Err = Error::success();
7707 Expr *ToControllingExpr =
nullptr;
7713 assert((ToControllingExpr || ToControllingType) &&
7714 "Either the controlling expr or type must be nonnull");
7718 return std::move(Err);
7723 return std::move(Err);
7728 return std::move(Err);
7730 const ASTContext &ToCtx = Importer.getToContext();
7732 if (ToControllingExpr) {
7734 ToCtx, ToGenericLoc, ToControllingExpr,
ArrayRef(ToAssocTypes),
7735 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
7739 ToCtx, ToGenericLoc, ToControllingType,
ArrayRef(ToAssocTypes),
7740 ArrayRef(ToAssocExprs), ToDefaultLoc, ToRParenLoc,
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,
7758 Error Err = Error::success();
7763 return std::move(Err);
7772 Error Err = Error::success();
7779 return std::move(Err);
7785 return FoundDOrErr.takeError();
7786 ToFoundD = *FoundDOrErr;
7795 return std::move(Err);
7796 ToResInfo = &ToTAInfo;
7800 Importer.getToContext(), ToQualifierLoc, ToTemplateKeywordLoc, ToDecl,
7804 ToE->setHadMultipleCandidates(
true);
7812 return TypeOrErr.takeError();
7820 return ToInitOrErr.takeError();
7823 if (!ToEqualOrColonLocOrErr)
7824 return ToEqualOrColonLocOrErr.takeError();
7830 ToIndexExprs[I - 1] = *ToArgOrErr;
7832 return ToArgOrErr.takeError();
7837 return std::move(Err);
7840 Importer.getToContext(), ToDesignators,
7841 ToIndexExprs, *ToEqualOrColonLocOrErr,
7849 return ToTypeOrErr.takeError();
7852 if (!ToLocationOrErr)
7853 return ToLocationOrErr.takeError();
7856 *ToTypeOrErr, *ToLocationOrErr);
7862 return ToTypeOrErr.takeError();
7865 if (!ToLocationOrErr)
7866 return ToLocationOrErr.takeError();
7869 Importer.getToContext(), E->
getValue(), *ToTypeOrErr, *ToLocationOrErr);
7876 return ToTypeOrErr.takeError();
7879 if (!ToLocationOrErr)
7880 return ToLocationOrErr.takeError();
7884 *ToTypeOrErr, *ToLocationOrErr);
7888 auto ToTypeOrErr =
import(E->
getType());
7890 return ToTypeOrErr.takeError();
7893 if (!ToSubExprOrErr)
7894 return ToSubExprOrErr.takeError();
7897 *ToSubExprOrErr, *ToTypeOrErr);
7901 auto ToTypeOrErr =
import(E->
getType());
7903 return ToTypeOrErr.takeError();
7906 if (!ToLocationOrErr)
7907 return ToLocationOrErr.takeError();
7910 Importer.getToContext(), E->
getValue(), *ToTypeOrErr, *ToLocationOrErr,
7911 Importer.getToContext().getFixedPointScale(*ToTypeOrErr));
7917 return ToTypeOrErr.takeError();
7920 if (!ToLocationOrErr)
7921 return ToLocationOrErr.takeError();
7930 return ToTypeOrErr.takeError();
7935 return std::move(Err);
7944 Error Err = Error::success();
7950 return std::move(Err);
7953 ToLParenLoc, ToTypeSourceInfo, ToType, E->
getValueKind(),
7959 Error Err = Error::success();
7964 return std::move(Err);
7970 return std::move(Err);
7972 return new (Importer.getToContext())
AtomicExpr(
7974 ToBuiltinLoc, ToExprs, ToType, E->
getOp(), ToRParenLoc);
7978 Error Err = Error::success();
7984 return std::move(Err);
7987 ToAmpAmpLoc, ToLabelLoc, ToLabel, ToType);
7990 Error Err = Error::success();
7994 return std::move(Err);
7999 Error Err = Error::success();
8004 return std::move(Err);
8006 return new (Importer.getToContext())
8007 ParenExpr(ToLParen, ToRParen, ToSubExpr);
8013 return std::move(Err);
8016 if (!ToLParenLocOrErr)
8017 return ToLParenLocOrErr.takeError();
8020 if (!ToRParenLocOrErr)
8021 return ToRParenLocOrErr.takeError();
8024 ToExprs, *ToRParenLocOrErr);
8028 Error Err = Error::success();
8034 return std::move(Err);
8036 return new (Importer.getToContext())
8037 StmtExpr(ToSubStmt, ToType, ToLParenLoc, ToRParenLoc,
8042 Error Err = Error::success();
8047 return std::move(Err);
8051 UO->setType(ToType);
8052 UO->setSubExpr(ToSubExpr);
8054 UO->setOperatorLoc(ToOperatorLoc);
8065 Error Err = Error::success();
8070 return std::move(Err);
8075 if (!ToArgumentTypeInfoOrErr)
8076 return ToArgumentTypeInfoOrErr.takeError();
8079 E->
getKind(), *ToArgumentTypeInfoOrErr, ToType, ToOperatorLoc,
8084 if (!ToArgumentExprOrErr)
8085 return ToArgumentExprOrErr.takeError();
8088 E->
getKind(), *ToArgumentExprOrErr, ToType, ToOperatorLoc, ToRParenLoc);
8092 Error Err = Error::success();
8098 return std::move(Err);
8101 Importer.getToContext(), ToLHS, ToRHS, E->
getOpcode(), ToType,
8107 Error Err = Error::success();
8115 return std::move(Err);
8118 ToCond, ToQuestionLoc, ToLHS, ToColonLoc, ToRHS, ToType,
8124 Error Err = Error::success();
8134 return std::move(Err);
8137 ToCommon, ToOpaqueValue, ToCond, ToTrueExpr, ToFalseExpr,
8144 Error Err = Error::success();
8147 return std::move(Err);
8149 return new (Importer.getToContext())
8154 Error Err = Error::success();
8156 auto ToQueriedTypeSourceInfo =
8162 return std::move(Err);
8166 ToDimensionExpression, ToEndLoc, ToType);
8170 Error Err = Error::success();
8176 return std::move(Err);
8184 Error Err = Error::success();
8189 return std::move(Err);
8196 Error Err = Error::success();
8202 return std::move(Err);
8211 Error Err = Error::success();
8216 auto ToComputationResultType =
8220 return std::move(Err);
8223 Importer.getToContext(), ToLHS, ToRHS, E->
getOpcode(), ToType,
8226 ToComputationLHSType, ToComputationResultType);
8233 if (
auto SpecOrErr =
import(*I))
8234 Path.push_back(*SpecOrErr);
8236 return SpecOrErr.takeError();
8244 return ToTypeOrErr.takeError();
8247 if (!ToSubExprOrErr)
8248 return ToSubExprOrErr.takeError();
8251 if (!ToBasePathOrErr)
8252 return ToBasePathOrErr.takeError();
8255 Importer.getToContext(), *ToTypeOrErr, E->
getCastKind(), *ToSubExprOrErr,
8260 Error Err = Error::success();
8265 return std::move(Err);
8268 if (!ToBasePathOrErr)
8269 return ToBasePathOrErr.takeError();
8273 case Stmt::CStyleCastExprClass: {
8275 ExpectedSLoc ToLParenLocOrErr =
import(CCE->getLParenLoc());
8276 if (!ToLParenLocOrErr)
8277 return ToLParenLocOrErr.takeError();
8278 ExpectedSLoc ToRParenLocOrErr =
import(CCE->getRParenLoc());
8279 if (!ToRParenLocOrErr)
8280 return ToRParenLocOrErr.takeError();
8283 ToSubExpr, ToBasePath, CCE->getFPFeatures(), ToTypeInfoAsWritten,
8284 *ToLParenLocOrErr, *ToRParenLocOrErr);
8287 case Stmt::CXXFunctionalCastExprClass: {
8289 ExpectedSLoc ToLParenLocOrErr =
import(FCE->getLParenLoc());
8290 if (!ToLParenLocOrErr)
8291 return ToLParenLocOrErr.takeError();
8292 ExpectedSLoc ToRParenLocOrErr =
import(FCE->getRParenLoc());
8293 if (!ToRParenLocOrErr)
8294 return ToRParenLocOrErr.takeError();
8296 Importer.getToContext(), ToType, E->
getValueKind(), ToTypeInfoAsWritten,
8297 E->
getCastKind(), ToSubExpr, ToBasePath, FCE->getFPFeatures(),
8298 *ToLParenLocOrErr, *ToRParenLocOrErr);
8301 case Stmt::ObjCBridgedCastExprClass: {
8303 ExpectedSLoc ToLParenLocOrErr =
import(OCE->getLParenLoc());
8304 if (!ToLParenLocOrErr)
8305 return ToLParenLocOrErr.takeError();
8306 ExpectedSLoc ToBridgeKeywordLocOrErr =
import(OCE->getBridgeKeywordLoc());
8307 if (!ToBridgeKeywordLocOrErr)
8308 return ToBridgeKeywordLocOrErr.takeError();
8310 *ToLParenLocOrErr, OCE->getBridgeKind(), E->
getCastKind(),
8311 *ToBridgeKeywordLocOrErr, ToTypeInfoAsWritten, ToSubExpr);
8313 case Stmt::BuiltinBitCastExprClass: {
8315 ExpectedSLoc ToKWLocOrErr =
import(BBC->getBeginLoc());
8317 return ToKWLocOrErr.takeError();
8318 ExpectedSLoc ToRParenLocOrErr =
import(BBC->getEndLoc());
8319 if (!ToRParenLocOrErr)
8320 return ToRParenLocOrErr.takeError();
8323 ToTypeInfoAsWritten, *ToKWLocOrErr, *ToRParenLocOrErr);
8326 llvm_unreachable(
"Cast expression of unsupported type!");
8339 Error Err = Error::success();
8343 return std::move(Err);
8352 auto ToBSOrErr =
import(FromNode.
getBase());
8354 return ToBSOrErr.takeError();
8359 auto ToFieldOrErr =
import(FromNode.
getField());
8361 return ToFieldOrErr.takeError();
8362 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, *ToFieldOrErr, ToEndLoc));
8367 ToNodes.push_back(
OffsetOfNode(ToBeginLoc, ToII, ToEndLoc));
8376 if (!ToIndexExprOrErr)
8377 return ToIndexExprOrErr.takeError();
8378 ToExprs[I] = *ToIndexExprOrErr;
8381 Error Err = Error::success();
8387 return std::move(Err);
8390 Importer.getToContext(), ToType, ToOperatorLoc, ToTypeSourceInfo, ToNodes,
8391 ToExprs, ToRParenLoc);
8395 Error Err = Error::success();
8401 return std::move(Err);
8410 ToType, ToOperand, ToCanThrow, ToBeginLoc, ToEndLoc);
8414 Error Err = Error::success();
8419 return std::move(Err);
8427 if (!ToUsedLocOrErr)
8428 return ToUsedLocOrErr.takeError();
8430 auto ToParamOrErr =
import(E->
getParam());
8432 return ToParamOrErr.takeError();
8434 auto UsedContextOrErr = Importer.ImportContext(E->
getUsedContext());
8435 if (!UsedContextOrErr)
8436 return UsedContextOrErr.takeError();
8446 std::optional<ParmVarDecl *> FromParam =
8447 Importer.getImportedFromDecl(ToParam);
8448 assert(FromParam &&
"ParmVarDecl was not imported?");
8451 return std::move(Err);
8453 Expr *RewrittenInit =
nullptr;
8457 return ExprOrErr.takeError();
8458 RewrittenInit = ExprOrErr.get();
8461 *ToParamOrErr, RewrittenInit,
8467 Error Err = Error::success();
8472 return std::move(Err);
8475 ToType, ToTypeSourceInfo, ToRParenLoc);
8481 if (!ToSubExprOrErr)
8482 return ToSubExprOrErr.takeError();
8484 auto ToDtorOrErr =
import(E->
getTemporary()->getDestructor());
8486 return ToDtorOrErr.takeError();
8496 Error Err = Error::success();
8502 return std::move(Err);
8506 return std::move(Err);
8509 Importer.getToContext(), ToConstructor, ToType, ToTypeSourceInfo, ToArgs,
8519 return std::move(Err);
8521 Error Err = Error::success();
8525 return std::move(Err);
8529 if (GetImportedOrCreateDecl(To, D, Temporary, ExtendingDecl,
8540 Error Err = Error::success();
8544 auto ToMaterializedDecl =
8547 return std::move(Err);
8549 if (!ToTemporaryExpr)
8550 ToTemporaryExpr =
cast<Expr>(ToMaterializedDecl->getTemporaryExpr());
8554 ToMaterializedDecl);
8560 Error Err = Error::success();
8564 return std::move(Err);
8566 return new (Importer.getToContext())
8571 Error Err = Error::success();
8577 return std::move(Err);
8586 ToPartialArguments))
8587 return std::move(Err);
8591 Importer.getToContext(), ToOperatorLoc, ToPack, ToPackLoc, ToRParenLoc,
8592 Length, ToPartialArguments);
8597 Error Err = Error::success();
8604 auto ToAllocatedTypeSourceInfo =
8609 return std::move(Err);
8614 return std::move(Err);
8617 Importer.getToContext(), E->
isGlobalNew(), ToOperatorNew,
8621 ToAllocatedTypeSourceInfo, ToSourceRange, ToDirectInitRange);
8625 Error Err = Error::success();
8631 return std::move(Err);
8640 Error Err = Error::success();
8646 return std::move(Err);
8650 return std::move(Err);
8653 Importer.getToContext(), ToType, ToLocation, ToConstructor,
8657 ToParenOrBraceRange);
8664 if (!ToSubExprOrErr)
8665 return ToSubExprOrErr.takeError();
8669 return std::move(Err);
8677 Error Err = Error::success();
8682 return std::move(Err);
8686 return std::move(Err);
8696 return ToTypeOrErr.takeError();
8699 if (!ToLocationOrErr)
8700 return ToLocationOrErr.takeError();
8709 return ToTypeOrErr.takeError();
8712 if (!ToLocationOrErr)
8713 return ToLocationOrErr.takeError();
8716 *ToTypeOrErr, *ToLocationOrErr);
8720 Error Err = Error::success();
8731 return std::move(Err);
8743 return std::move(Err);
8744 ResInfo = &ToTAInfo;
8748 ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8749 ToMemberDecl, ToFoundDecl, ToMemberNameInfo,
8756 Error Err = Error::success();
8764 return std::move(Err);
8770 if (!ToDestroyedTypeLocOrErr)
8771 return ToDestroyedTypeLocOrErr.takeError();
8777 return ToTIOrErr.takeError();
8781 Importer.getToContext(), ToBase, E->
isArrow(), ToOperatorLoc,
8782 ToQualifierLoc, ToScopeTypeInfo, ToColonColonLoc, ToTildeLoc, Storage);
8787 Error Err = Error::success();
8792 auto ToFirstQualifierFoundInScope =
8795 return std::move(Err);
8797 Expr *ToBase =
nullptr;
8800 ToBase = *ToBaseOrErr;
8802 return ToBaseOrErr.takeError();
8811 return std::move(Err);
8812 ResInfo = &ToTAInfo;
8817 return std::move(Err);
8823 return std::move(Err);
8826 Importer.getToContext(), ToBase, ToType, E->
isArrow(), ToOperatorLoc,
8827 ToQualifierLoc, ToTemplateKeywordLoc, ToFirstQualifierFoundInScope,
8828 ToMemberNameInfo, ResInfo);
8833 Error Err = Error::success();
8841 return std::move(Err);
8845 return std::move(Err);
8852 return std::move(Err);
8853 ResInfo = &ToTAInfo;
8857 Importer.getToContext(), ToQualifierLoc, ToTemplateKeywordLoc,
8858 ToNameInfo, ResInfo);
8863 Error Err = Error::success();
8869 return std::move(Err);
8874 return std::move(Err);
8877 Importer.getToContext(), ToType, ToTypeSourceInfo, ToLParenLoc,
8884 if (!ToNamingClassOrErr)
8885 return ToNamingClassOrErr.takeError();
8888 if (!ToQualifierLocOrErr)
8889 return ToQualifierLocOrErr.takeError();
8891 Error Err = Error::success();
8895 return std::move(Err);
8900 return std::move(Err);
8903 for (
auto *D : E->
decls())
8904 if (
auto ToDOrErr =
import(D))
8907 return ToDOrErr.takeError();
8914 return std::move(Err);
8917 if (!ToTemplateKeywordLocOrErr)
8918 return ToTemplateKeywordLocOrErr.takeError();
8920 const bool KnownDependent =
8922 ExprDependence::TypeValue;
8924 Importer.getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8925 *ToTemplateKeywordLocOrErr, ToNameInfo, E->
requiresADL(), &ToTAInfo,
8926 ToDecls.
begin(), ToDecls.
end(), KnownDependent,
8931 Importer.getToContext(), *ToNamingClassOrErr, *ToQualifierLocOrErr,
8939 Error Err = Error::success();
8947 return std::move(Err);
8952 return std::move(Err);
8956 if (
auto ToDOrErr =
import(D))
8959 return ToDOrErr.takeError();
8967 return std::move(Err);
8968 ResInfo = &ToTAInfo;
8971 Expr *ToBase =
nullptr;
8974 ToBase = *ToBaseOrErr;
8976 return ToBaseOrErr.takeError();
8981 E->
isArrow(), ToOperatorLoc, ToQualifierLoc, ToTemplateKeywordLoc,
8982 ToNameInfo, ResInfo, ToDecls.
begin(), ToDecls.
end());
8986 Error Err = Error::success();
8991 return std::move(Err);
8996 return std::move(Err);
8998 if (
const auto *OCE = dyn_cast<CXXOperatorCallExpr>(E)) {
9000 Importer.getToContext(), OCE->getOperator(), ToCallee, ToArgs, ToType,
9001 OCE->getValueKind(), ToRParenLoc, OCE->getFPFeatures(),
9002 OCE->getADLCallKind());
9012 auto ToClassOrErr =
import(FromClass);
9014 return ToClassOrErr.takeError();
9019 return ToCallOpOrErr.takeError();
9023 return std::move(Err);
9025 Error Err = Error::success();
9030 return std::move(Err);
9041 Error Err = Error::success();
9046 return std::move(Err);
9050 return std::move(Err);
9061 return ToFillerOrErr.takeError();
9065 if (
auto ToFDOrErr =
import(FromFD))
9068 return ToFDOrErr.takeError();
9072 if (
auto ToSyntFormOrErr =
import(SyntForm))
9075 return ToSyntFormOrErr.takeError();
9089 return ToTypeOrErr.takeError();
9092 if (!ToSubExprOrErr)
9093 return ToSubExprOrErr.takeError();
9096 *ToTypeOrErr, *ToSubExprOrErr);
9101 Error Err = Error::success();
9106 return std::move(Err);
9114 Error Err = Error::success();
9119 return std::move(Err);
9122 ToType, ToCommonExpr, ToSubExpr);
9128 return ToTypeOrErr.takeError();
9134 if (!ToBeginLocOrErr)
9135 return ToBeginLocOrErr.takeError();
9137 auto ToFieldOrErr =
import(E->
getField());
9139 return ToFieldOrErr.takeError();
9141 auto UsedContextOrErr = Importer.ImportContext(E->
getUsedContext());
9142 if (!UsedContextOrErr)
9143 return UsedContextOrErr.takeError();
9147 "Field should have in-class initializer if there is a default init "
9148 "expression that uses it.");
9153 auto ToInClassInitializerOrErr =
9154 import(E->
getField()->getInClassInitializer());
9155 if (!ToInClassInitializerOrErr)
9156 return ToInClassInitializerOrErr.takeError();
9160 Expr *RewrittenInit =
nullptr;
9164 return ExprOrErr.takeError();
9165 RewrittenInit = ExprOrErr.get();
9169 ToField, *UsedContextOrErr, RewrittenInit);
9173 Error Err = Error::success();
9181 return std::move(Err);
9186 if (!ToBasePathOrErr)
9187 return ToBasePathOrErr.takeError();
9189 if (
auto CCE = dyn_cast<CXXStaticCastExpr>(E)) {
9191 Importer.getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9192 ToTypeInfoAsWritten, CCE->getFPFeatures(), ToOperatorLoc, ToRParenLoc,
9196 Importer.getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9197 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9200 Importer.getToContext(), ToType,
VK, CK, ToSubExpr, &(*ToBasePathOrErr),
9201 ToTypeInfoAsWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9204 Importer.getToContext(), ToType,
VK, ToSubExpr, ToTypeInfoAsWritten,
9205 ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
9207 llvm_unreachable(
"Unknown cast type");
9208 return make_error<ASTImportError>();
9214 Error Err = Error::success();
9220 return std::move(Err);
9223 ToType, E->
getValueKind(), ToNameLoc, ToReplacement, ToAssociatedDecl,
9229 Error Err = Error::success();
9234 return std::move(Err);
9238 return std::move(Err);
9245 E->
getTrait(), ToArgs, ToEndLoc, ToValue);
9255 return ToTypeOrErr.takeError();
9258 if (!ToSourceRangeOrErr)
9259 return ToSourceRangeOrErr.takeError();
9264 *ToTypeOrErr, *ToTSIOrErr, *ToSourceRangeOrErr);
9266 return ToTSIOrErr.takeError();
9270 if (!ToExprOperandOrErr)
9271 return ToExprOperandOrErr.takeError();
9274 *ToTypeOrErr, *ToExprOperandOrErr, *ToSourceRangeOrErr);
9278 Error Err = Error::success();
9289 return std::move(Err);
9291 return new (Importer.getToContext())
9297 Error Err = Error::success();
9305 return std::move(Err);
9309 return std::move(Err);
9314 return std::move(Err);
9316 LParenLoc, LocalParameters, RParenLoc,
9317 Requirements, RBraceLoc);
9322 Error Err = Error::success();
9326 return std::move(Err);
9329 Importer.getToContext(),
CL,
9334 return std::move(Err);
9336 Importer.getToContext(),
CL,
9342 Error Err = Error::success();
9348 return std::move(Err);
9351 ToType, E->
getValueKind(), ToPackLoc, ToArgPack, ToAssociatedDecl,
9358 return std::move(Err);
9361 return ToSyntOrErr.takeError();
9368 Error Err = Error::success();
9374 return std::move(Err);
9378 return std::move(Err);
9381 ToInitLoc, ToBeginLoc, ToEndLoc);
9386 Error ImportErrors = Error::success();
9388 if (
auto ImportedOrErr =
import(FromOverriddenMethod))
9390 (*ImportedOrErr)->getCanonicalDecl()));
9393 joinErrors(std::move(ImportErrors), ImportedOrErr.takeError());
9395 return ImportErrors;
9401 std::shared_ptr<ASTImporterSharedState> SharedState)
9402 : SharedState(SharedState), ToContext(ToContext), FromContext(FromContext),
9403 ToFileManager(ToFileManager), FromFileManager(FromFileManager),
9408 this->SharedState = std::make_shared<ASTImporterSharedState>();
9411 ImportedDecls[FromContext.getTranslationUnitDecl()] =
9412 ToContext.getTranslationUnitDecl();
9419 "Try to get field index for non-field.");
9423 return std::nullopt;
9426 for (
const auto *D : Owner->decls()) {
9434 llvm_unreachable(
"Field was not found in its parent context.");
9436 return std::nullopt;
9439ASTImporter::FoundDeclsTy
9449 if (SharedState->getLookupTable()) {
9457 dyn_cast<NamespaceDecl>(ReDC));
9458 for (
auto *D : NSChain) {
9460 SharedState->getLookupTable()->lookup(dyn_cast<NamespaceDecl>(D),
9467 SharedState->getLookupTable()->lookup(ReDC, Name);
9468 return FoundDeclsTy(LookupResult.begin(), LookupResult.end());
9472 FoundDeclsTy
Result(NoloadLookupResult.
begin(), NoloadLookupResult.
end());
9489void ASTImporter::AddToLookupTable(
Decl *ToD) {
9490 SharedState->addDeclToLookup(ToD);
9496 return Importer.
Visit(FromD);
9520 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
9521 ImportedTypes.find(FromT);
9522 if (Pos != ImportedTypes.end())
9529 return ToTOrErr.takeError();
9532 ImportedTypes[FromT] = ToTOrErr->getTypePtr();
9534 return ToTOrErr->getTypePtr();
9543 return ToTyOrErr.takeError();
9556 return TOrErr.takeError();
9559 return BeginLocOrErr.takeError();
9561 return ToContext.getTrivialTypeSourceInfo(*TOrErr, *BeginLocOrErr);
9568template <
typename T>
struct AttrArgImporter {
9569 AttrArgImporter(
const AttrArgImporter<T> &) =
delete;
9570 AttrArgImporter(AttrArgImporter<T> &&) =
default;
9571 AttrArgImporter<T> &operator=(
const AttrArgImporter<T> &) =
delete;
9572 AttrArgImporter<T> &operator=(AttrArgImporter<T> &&) =
default;
9575 : To(I.importChecked(Err, From)) {}
9577 const T &value() {
return To; }
9588template <
typename T>
struct AttrArgArrayImporter {
9589 AttrArgArrayImporter(
const AttrArgArrayImporter<T> &) =
delete;
9590 AttrArgArrayImporter(AttrArgArrayImporter<T> &&) =
default;
9591 AttrArgArrayImporter<T> &operator=(
const AttrArgArrayImporter<T> &) =
delete;
9592 AttrArgArrayImporter<T> &operator=(AttrArgArrayImporter<T> &&) =
default;
9594 AttrArgArrayImporter(ASTNodeImporter &I,
Error &Err,
9595 const llvm::iterator_range<T *> &From,
9596 unsigned ArraySize) {
9599 To.reserve(ArraySize);
9603 T *value() {
return To.data(); }
9606 llvm::SmallVector<T, 2> To;
9610 Error Err{Error::success()};
9611 Attr *ToAttr =
nullptr;
9612 ASTImporter &Importer;
9613 ASTNodeImporter NImporter;
9616 AttrImporter(ASTImporter &I) : Importer(I), NImporter(I) {}
9619 template <
typename T> T *castAttrAs() {
return cast<T>(ToAttr); }
9620 template <
typename T>
const T *castAttrAs()
const {
return cast<T>(ToAttr); }
9625 template <
class T> AttrArgImporter<T> importArg(
const T &From) {
9626 return AttrArgImporter<T>(NImporter, Err, From);
9632 template <
typename T>
9633 AttrArgArrayImporter<T> importArrayArg(
const llvm::iterator_range<T *> &From,
9634 unsigned ArraySize) {
9635 return AttrArgArrayImporter<T>(NImporter, Err, From, ArraySize);
9646 template <
typename T,
typename... Arg>
9647 void importAttr(
const T *FromAttr, Arg &&...ImportedArg) {
9648 static_assert(std::is_base_of<Attr, T>::value,
9649 "T should be subclass of Attr.");
9650 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9652 const IdentifierInfo *ToAttrName = Importer.
Import(FromAttr->getAttrName());
9653 const IdentifierInfo *ToScopeName =
9654 Importer.
Import(FromAttr->getScopeName());
9655 SourceRange ToAttrRange =
9657 SourceLocation ToScopeLoc =
9663 AttributeCommonInfo ToI(
9664 ToAttrName, AttributeScopeInfo(ToScopeName, ToScopeLoc), ToAttrRange,
9665 FromAttr->getParsedKind(), FromAttr->getForm());
9669 std::forward<Arg>(ImportedArg)..., ToI);
9673 if (
auto *ToInheritableAttr = dyn_cast<InheritableAttr>(ToAttr))
9674 ToInheritableAttr->setInherited(FromAttr->isInherited());
9680 void cloneAttr(
const Attr *FromAttr) {
9681 assert(!ToAttr &&
"Use one AttrImporter to import one Attribute object.");
9693 llvm::Expected<Attr *> getResult() && {
9695 return std::move(Err);
9696 assert(ToAttr &&
"Attribute should be created.");
9703 AttrImporter AI(*
this);
9706 switch (FromAttr->
getKind()) {
9707 case attr::Aligned: {
9709 if (From->isAlignmentExpr())
9710 AI.importAttr(From,
true, AI.importArg(From->getAlignmentExpr()).value());
9712 AI.importAttr(From,
false,
9713 AI.importArg(From->getAlignmentType()).value());
9717 case attr::AlignValue: {
9719 AI.importAttr(From, AI.importArg(From->getAlignment()).value());
9723 case attr::Format: {
9725 AI.importAttr(From,
Import(From->getType()), From->getFormatIdx(),
9726 From->getFirstArg());
9730 case attr::EnableIf: {
9732 AI.importAttr(From, AI.importArg(From->getCond()).value(),
9733 From->getMessage());
9737 case attr::AssertCapability: {
9740 AI.importArrayArg(From->args(), From->args_size()).value(),
9744 case attr::AcquireCapability: {
9747 AI.importArrayArg(From->args(), From->args_size()).value(),
9751 case attr::TryAcquireCapability: {
9753 AI.importAttr(From, AI.importArg(From->getSuccessValue()).value(),
9754 AI.importArrayArg(From->args(), From->args_size()).value(),
9758 case attr::ReleaseCapability: {
9761 AI.importArrayArg(From->args(), From->args_size()).value(),
9765 case attr::RequiresCapability: {
9768 AI.importArrayArg(From->args(), From->args_size()).value(),
9772 case attr::GuardedBy: {
9775 AI.importArrayArg(From->args(), From->args_size()).value(),
9779 case attr::PtGuardedBy: {
9782 AI.importArrayArg(From->args(), From->args_size()).value(),
9786 case attr::AcquiredAfter: {
9789 AI.importArrayArg(From->args(), From->args_size()).value(),
9793 case attr::AcquiredBefore: {
9796 AI.importArrayArg(From->args(), From->args_size()).value(),
9800 case attr::LockReturned: {
9802 AI.importAttr(From, AI.importArg(From->getArg()).value());
9805 case attr::LocksExcluded: {
9808 AI.importArrayArg(From->args(), From->args_size()).value(),
9816 AI.cloneAttr(FromAttr);
9821 return std::move(AI).getResult();
9825 return ImportedDecls.lookup(FromD);
9829 auto FromDPos = ImportedFromDecls.find(ToD);
9830 if (FromDPos == ImportedFromDecls.end())
9840 ImportPath.push(FromD);
9841 llvm::scope_exit ImportPathBuilder([
this]() { ImportPath.pop(); });
9846 return make_error<ASTImportError>(*
Error);
9852 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9854 return make_error<ASTImportError>(*
Error);
9861 if (ImportPath.hasCycleAtBack())
9862 SavedImportPaths[FromD].push_back(ImportPath.copyCycleAtBack());
9871 auto Pos = ImportedDecls.find(FromD);
9872 bool ToDWasCreated = Pos != ImportedDecls.end();
9876 Decl *CreatedToD = ToDWasCreated ? Pos->second :
nullptr;
9877 if (ToDWasCreated) {
9880 auto *ToD = CreatedToD;
9881 ImportedDecls.erase(Pos);
9893 auto PosF = ImportedFromDecls.find(ToD);
9894 if (PosF != ImportedFromDecls.end()) {
9899 SharedState->removeDeclFromLookup(ToD);
9900 ImportedFromDecls.erase(PosF);
9912 handleAllErrors(ToDOrErr.takeError(),
9917 SharedState->setImportDeclError(CreatedToD, ErrOut);
9921 for (
const auto &Path : SavedImportPaths[FromD]) {
9924 Decl *PrevFromDi = FromD;
9925 for (
Decl *FromDi : Path) {
9927 if (FromDi == FromD)
9934 PrevFromDi = FromDi;
9938 auto Ii = ImportedDecls.find(FromDi);
9939 if (Ii != ImportedDecls.end())
9940 SharedState->setImportDeclError(Ii->second, ErrOut);
9945 SavedImportPaths.erase(FromD);
9948 return make_error<ASTImportError>(ErrOut);
9960 return make_error<ASTImportError>(*Err);
9966 if (
auto Error = SharedState->getImportDeclErrorIfAny(ToD)) {
9968 return make_error<ASTImportError>(*
Error);
9971 assert(ImportedDecls.count(FromD) != 0 &&
"Missing call to MapImported?");
9975 auto ToAttrOrErr =
Import(FromAttr);
9979 return ToAttrOrErr.takeError();
9986 SavedImportPaths.erase(FromD);
10001 return ToDCOrErr.takeError();
10006 if (
auto *ToRecord = dyn_cast<RecordDecl>(ToDC)) {
10008 if (ToRecord->isCompleteDefinition())
10016 if (FromRecord->getASTContext().getExternalSource() &&
10017 !FromRecord->isCompleteDefinition())
10018 FromRecord->getASTContext().getExternalSource()->CompleteType(FromRecord);
10020 if (FromRecord->isCompleteDefinition())
10023 return std::move(Err);
10024 }
else if (
auto *ToEnum = dyn_cast<EnumDecl>(ToDC)) {
10026 if (ToEnum->isCompleteDefinition()) {
10028 }
else if (FromEnum->isCompleteDefinition()) {
10031 return std::move(Err);
10035 }
else if (
auto *ToClass = dyn_cast<ObjCInterfaceDecl>(ToDC)) {
10037 if (ToClass->getDefinition()) {
10042 return std::move(Err);
10046 }
else if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(ToDC)) {
10048 if (ToProto->getDefinition()) {
10053 return std::move(Err);
10064 return cast_or_null<Expr>(*ToSOrErr);
10066 return ToSOrErr.takeError();
10074 llvm::DenseMap<Stmt *, Stmt *>::iterator Pos = ImportedStmts.find(FromS);
10075 if (Pos != ImportedStmts.end())
10076 return Pos->second;
10084 if (
auto *ToE = dyn_cast<Expr>(*ToSOrErr)) {
10088 ToE->setValueKind(FromE->getValueKind());
10089 ToE->setObjectKind(FromE->getObjectKind());
10090 ToE->setDependence(FromE->getDependence());
10094 ImportedStmts[FromS] = *ToSOrErr;
10105 auto NSOrErr =
Import(Namespace);
10107 return NSOrErr.takeError();
10108 auto PrefixOrErr =
Import(Prefix);
10110 return PrefixOrErr.takeError();
10118 return RDOrErr.takeError();
10123 return TyOrErr.takeError();
10126 llvm_unreachable(
"Invalid nested name specifier kind");
10138 NestedNames.push_back(NNS);
10144 while (!NestedNames.empty()) {
10145 NNS = NestedNames.pop_back_val();
10148 return std::move(Err);
10155 return std::move(Err);
10159 return std::move(Err);
10165 ToLocalBeginLoc, ToLocalEndLoc);
10171 return std::move(Err);
10184 if (!ToSourceRangeOrErr)
10185 return ToSourceRangeOrErr.takeError();
10188 ToSourceRangeOrErr->getBegin(),
10189 ToSourceRangeOrErr->getEnd());
10193 llvm_unreachable(
"unexpected null nested name specifier");
10206 return ToTemplateOrErr.takeError();
10211 for (
auto *I : *FromStorage) {
10212 if (
auto ToOrErr =
Import(I))
10215 return ToOrErr.takeError();
10217 return ToContext.getOverloadedTemplateName(ToTemplates.
begin(),
10218 ToTemplates.
end());
10224 if (!DeclNameOrErr)
10225 return DeclNameOrErr.takeError();
10226 return ToContext.getAssumedTemplateName(*DeclNameOrErr);
10232 if (!QualifierOrErr)
10233 return QualifierOrErr.takeError();
10236 return TNOrErr.takeError();
10237 return ToContext.getQualifiedTemplateName(
10244 if (!QualifierOrErr)
10245 return QualifierOrErr.takeError();
10246 return ToContext.getDependentTemplateName(
10254 if (!ReplacementOrErr)
10255 return ReplacementOrErr.takeError();
10258 if (!AssociatedDeclOrErr)
10259 return AssociatedDeclOrErr.takeError();
10261 return ToContext.getSubstTemplateTemplateParm(
10262 *ReplacementOrErr, *AssociatedDeclOrErr, Subst->
getIndex(),
10270 auto ArgPackOrErr =
10273 return ArgPackOrErr.takeError();
10276 if (!AssociatedDeclOrErr)
10277 return AssociatedDeclOrErr.takeError();
10279 return ToContext.getSubstTemplateTemplateParmPack(
10280 *ArgPackOrErr, *AssociatedDeclOrErr, SubstPack->
getIndex(),
10286 return UsingOrError.takeError();
10290 llvm_unreachable(
"Unexpected DeducedTemplate");
10293 llvm_unreachable(
"Invalid template name kind");
10305 if (!ToFileIDOrErr)
10306 return ToFileIDOrErr.takeError();
10314 return std::move(Err);
10316 return std::move(Err);
10322 llvm::DenseMap<FileID, FileID>::iterator Pos = ImportedFileIDs.find(FromID);
10323 if (Pos != ImportedFileIDs.end())
10324 return Pos->second;
10336 return ToSpLoc.takeError();
10339 return ToExLocS.takeError();
10349 return ToExLocE.takeError();
10355 if (!IsBuiltin && !
Cache->BufferOverridden) {
10359 return ToIncludeLoc.takeError();
10370 if (
Cache->OrigEntry &&
Cache->OrigEntry->getDir()) {
10376 ToFileManager.getOptionalFileRef(
Cache->OrigEntry->getName());
10381 ToID = ToSM.
createFileID(*Entry, ToIncludeLocOrFakeLoc,
10388 std::optional<llvm::MemoryBufferRef> FromBuf =
10389 Cache->getBufferOrNone(FromContext.getDiagnostics(),
10394 std::unique_ptr<llvm::MemoryBuffer> ToBuf =
10395 llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(),
10396 FromBuf->getBufferIdentifier());
10402 assert(ToID.
isValid() &&
"Unexpected invalid fileID was created.");
10404 ImportedFileIDs[FromID] = ToID;
10411 return ToExprOrErr.takeError();
10414 if (!LParenLocOrErr)
10415 return LParenLocOrErr.takeError();
10418 if (!RParenLocOrErr)
10419 return RParenLocOrErr.takeError();
10424 return ToTInfoOrErr.takeError();
10429 return std::move(Err);
10432 ToContext, *ToTInfoOrErr, From->
isBaseVirtual(), *LParenLocOrErr,
10433 *ToExprOrErr, *RParenLocOrErr, EllipsisLoc);
10437 return ToFieldOrErr.takeError();
10440 if (!MemberLocOrErr)
10441 return MemberLocOrErr.takeError();
10444 ToContext, cast_or_null<FieldDecl>(*ToFieldOrErr), *MemberLocOrErr,
10445 *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10448 if (!ToIFieldOrErr)
10449 return ToIFieldOrErr.takeError();
10452 if (!MemberLocOrErr)
10453 return MemberLocOrErr.takeError();
10456 ToContext, cast_or_null<IndirectFieldDecl>(*ToIFieldOrErr),
10457 *MemberLocOrErr, *LParenLocOrErr, *ToExprOrErr, *RParenLocOrErr);
10461 return ToTInfoOrErr.takeError();
10463 return new (ToContext)
10465 *ToExprOrErr, *RParenLocOrErr);
10468 return make_error<ASTImportError>();
10474 auto Pos = ImportedCXXBaseSpecifiers.find(BaseSpec);
10475 if (Pos != ImportedCXXBaseSpecifiers.end())
10476 return Pos->second;
10479 if (!ToSourceRange)
10480 return ToSourceRange.takeError();
10483 return ToTSI.takeError();
10485 if (!ToEllipsisLoc)
10486 return ToEllipsisLoc.takeError();
10490 ImportedCXXBaseSpecifiers[BaseSpec] =
Imported;
10502 return ToOrErr.takeError();
10503 Decl *To = *ToOrErr;
10508 if (
auto *ToRecord = dyn_cast<RecordDecl>(To)) {
10509 if (!ToRecord->getDefinition()) {
10516 if (
auto *ToEnum = dyn_cast<EnumDecl>(To)) {
10517 if (!ToEnum->getDefinition()) {
10523 if (
auto *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
10524 if (!ToIFace->getDefinition()) {
10531 if (
auto *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
10532 if (!ToProto->getDefinition()) {
10556 return ToSelOrErr.takeError();
10560 return ToContext.DeclarationNames.getCXXConstructorName(
10561 ToContext.getCanonicalType(*ToTyOrErr));
10563 return ToTyOrErr.takeError();
10568 return ToContext.DeclarationNames.getCXXDestructorName(
10569 ToContext.getCanonicalType(*ToTyOrErr));
10571 return ToTyOrErr.takeError();
10576 return ToContext.DeclarationNames.getCXXDeductionGuideName(
10579 return ToTemplateOrErr.takeError();
10584 return ToContext.DeclarationNames.getCXXConversionFunctionName(
10585 ToContext.getCanonicalType(*ToTyOrErr));
10587 return ToTyOrErr.takeError();
10591 return ToContext.DeclarationNames.getCXXOperatorName(
10595 return ToContext.DeclarationNames.getCXXLiteralOperatorName(
10603 llvm_unreachable(
"Invalid DeclarationName Kind!");
10631 for (
unsigned I = 1, N = FromSel.
getNumArgs(); I < N; ++I)
10633 return ToContext.Selectors.getSelector(FromSel.
getNumArgs(), Idents.data());
10639 llvm::Error Err = llvm::Error::success();
10640 auto ImportLoop = [&](
const APValue *From,
APValue *To,
unsigned Size) {
10641 for (
unsigned Idx = 0; Idx < Size; Idx++) {
10646 switch (FromValue.
getKind()) {
10660 ImportLoop(((
const APValue::Vec *)(
const char *)&FromValue.Data)->Elts,
10666 llvm_unreachable(
"Matrix APValue import not yet supported");
10670 ImportLoop(((
const APValue::Arr *)(
const char *)&FromValue.Data)->Elts,
10671 ((
const APValue::Arr *)(
const char *)&
Result.Data)->Elts,
10678 ((
const APValue::StructData *)(
const char *)&FromValue.Data)->Elts,
10679 ((
const APValue::StructData *)(
const char *)&
Result.Data)->Elts,
10687 return std::move(Err);
10692 Result.MakeAddrLabelDiff();
10696 return std::move(Err);
10702 const Decl *ImpMemPtrDecl =
10705 return std::move(Err);
10707 Result.setMemberPointerUninit(
10716 return std::move(Err);
10726 "in C++20 dynamic allocation are transient so they shouldn't "
10727 "appear in the AST");
10729 if (
const auto *E =
10731 FromElemTy = E->getType();
10734 return std::move(Err);
10744 return std::move(Err);
10756 return std::move(Err);
10769 for (
unsigned LoopIdx = 0; LoopIdx < PathLength; LoopIdx++) {
10771 const Decl *FromDecl =
10772 FromPath[LoopIdx].getAsBaseOrMember().getPointer();
10775 return std::move(Err);
10776 if (
auto *RD = dyn_cast<CXXRecordDecl>(FromDecl))
10777 FromElemTy = Importer.FromContext.getCanonicalTagType(RD);
10781 ImpDecl, FromPath[LoopIdx].getAsBaseOrMember().getInt()));
10784 Importer.FromContext.getAsArrayType(FromElemTy)->getElementType();
10786 FromPath[LoopIdx].getAsArrayIndex());
10794 return std::move(Err);
10802 unsigned NumDecls) {
10812 if (LastDiagFromFrom)
10813 ToContext.getDiagnostics().notePriorDiagnosticFrom(
10814 FromContext.getDiagnostics());
10815 LastDiagFromFrom =
false;
10816 return ToContext.getDiagnostics().Report(Loc, DiagID);
10820 if (!LastDiagFromFrom)
10821 FromContext.getDiagnostics().notePriorDiagnosticFrom(
10822 ToContext.getDiagnostics());
10823 LastDiagFromFrom =
true;
10824 return FromContext.getDiagnostics().Report(Loc, DiagID);
10828 if (
auto *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
10829 if (!ID->getDefinition())
10830 ID->startDefinition();
10832 else if (
auto *PD = dyn_cast<ObjCProtocolDecl>(D)) {
10833 if (!PD->getDefinition())
10834 PD->startDefinition();
10836 else if (
auto *TD = dyn_cast<TagDecl>(D)) {
10837 if (!TD->getDefinition() && !TD->isBeingDefined()) {
10838 TD->startDefinition();
10839 TD->setCompleteDefinition(
true);
10843 assert(0 &&
"CompleteDecl called on a Decl that can't be completed");
10848 auto [Pos, Inserted] = ImportedDecls.try_emplace(From, To);
10849 assert((Inserted || Pos->second == To) &&
10850 "Try to import an already imported Decl");
10852 return Pos->second;
10855 ImportedFromDecls[To] = From;
10860 AddToLookupTable(To);
10864std::optional<ASTImportError>
10866 auto Pos = ImportDeclErrors.find(FromD);
10867 if (Pos != ImportDeclErrors.end())
10868 return Pos->second;
10870 return std::nullopt;
10874 auto InsertRes = ImportDeclErrors.insert({From,
Error});
10878 assert(InsertRes.second || InsertRes.first->second.Error ==
Error.Error);
10883 llvm::DenseMap<const Type *, const Type *>::iterator Pos =
10885 if (Pos != ImportedTypes.end()) {
10887 if (ToContext.hasSameType(*ToFromOrErr, To))
10890 llvm::consumeError(ToFromOrErr.takeError());
10895 getToContext().getLangOpts(), FromContext, ToContext, NonEquivalentDecls,
Defines the clang::ASTContext interface.
static FriendCountAndPosition getFriendCountAndPosition(ASTImporter &Importer, FriendDecl *FD)
static bool IsEquivalentFriend(ASTImporter &Importer, FriendDecl *FD1, FriendDecl *FD2)
static ExpectedStmt ImportLoopControlStmt(ASTNodeImporter &NodeImporter, ASTImporter &Importer, StmtClass *S)
static auto getTemplateDefinition(T *D) -> T *
static bool isAncestorDeclContextOf(const DeclContext *DC, const Decl *D)
static Error setTypedefNameForAnonDecl(TagDecl *From, TagDecl *To, ASTImporter &Importer)
static StructuralEquivalenceKind getStructuralEquivalenceKind(const ASTImporter &Importer)
This file provides some common utility functions for processing Lambda related AST Constructs.
Defines enum values for all the target-independent builtin functions.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::FileManager interface and associated types.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Result
Implement __builtin_bit_cast and related operations.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the LambdaCapture class.
Defines the clang::LangOptions interface.
llvm::MachO::Record Record
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
Defines the clang::SourceLocation class and associated facilities.
Defines the SourceManager interface.
Defines various enumerations that describe declaration and type specifiers.
Defines the Objective-C statement AST node classes.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
llvm::APInt getValue() const
unsigned getVersion() const
QualType getTypeInfoType() const
static LValueBase getTypeInfo(TypeInfoLValue LV, QualType TypeInfo)
unsigned getCallIndex() const
A non-discriminated union of a base, field, or array index.
static LValuePathEntry ArrayIndex(uint64_t Index)
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
const LValueBase getLValueBase() const
ArrayRef< LValuePathEntry > getLValuePath() const
const FieldDecl * getUnionField() const
unsigned getStructNumFields() const
llvm::PointerIntPair< const Decl *, 1, bool > BaseOrMemberType
A FieldDecl or CXXRecordDecl, along with a flag indicating whether we mean a virtual or non-virtual b...
ValueKind getKind() const
bool isLValueOnePastTheEnd() const
bool isMemberPointerToDerivedMember() const
unsigned getArrayInitializedElts() const
unsigned getStructNumBases() const
bool hasLValuePath() const
const ValueDecl * getMemberPointerDecl() const
APValue & getUnionValue()
const AddrLabelExpr * getAddrLabelDiffRHS() const
CharUnits & getLValueOffset()
unsigned getVectorLength() const
ArrayRef< const CXXRecordDecl * > getMemberPointerPath() const
unsigned getArraySize() const
@ Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
@ None
There is no such object (it's outside its lifetime).
bool isNullPointer() const
const AddrLabelExpr * getAddrLabelDiffLHS() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getReadPipeType(QualType T) const
Return a read_only pipe type for the specified type.
const LangOptions & getLangOpts() const
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getWritePipeType(QualType T) const
Return a write_only pipe type for the specified type.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
std::error_code convertToErrorCode() const override
void log(llvm::raw_ostream &OS) const override
std::string toString() const
@ Unknown
Not supported node or case.
@ UnsupportedConstruct
Naming ambiguity (likely ODR violation).
auto makeScopedCycleDetection(const FunctionDecl *D)
bool isCycle(const FunctionDecl *D) const
Imports selected nodes from one AST context into another context, merging AST nodes where appropriate...
ASTContext & getToContext() const
Retrieve the context that AST nodes are being imported into.
DiagnosticBuilder ToDiag(SourceLocation Loc, unsigned DiagID)
Report a diagnostic in the "to" context.
Decl * MapImported(Decl *From, Decl *To)
Store and assign the imported declaration to its counterpart.
static UnsignedOrNone getFieldIndex(Decl *F)
Determine the index of a field in its parent record.
TranslationUnitDecl * GetFromTU(Decl *ToD)
Return the translation unit from where the declaration was imported.
llvm::Expected< DeclContext * > ImportContext(DeclContext *FromDC)
Import the given declaration context from the "from" AST context into the "to" AST context.
llvm::Error ImportDefinition(Decl *From)
Import the definition of the given declaration, including all of the declarations it contains.
virtual Expected< DeclarationName > HandleNameConflict(DeclarationName Name, DeclContext *DC, unsigned IDNS, NamedDecl **Decls, unsigned NumDecls)
Cope with a name conflict when importing a declaration into the given context.
void RegisterImportedDecl(Decl *FromD, Decl *ToD)
std::optional< ASTImportError > getImportDeclErrorIfAny(Decl *FromD) const
Return if import of the given declaration has failed and if yes the kind of the problem.
friend class ASTNodeImporter
llvm::Error ImportTemplateArguments(ArrayRef< TemplateArgument > FromArgs, SmallVectorImpl< TemplateArgument > &ToArgs)
llvm::Error importInto(ImportT &To, const ImportT &From)
Import the given object, returns the result.
virtual void Imported(Decl *From, Decl *To)
Subclasses can override this function to observe all of the From -> To declaration mappings as they a...
DiagnosticBuilder FromDiag(SourceLocation Loc, unsigned DiagID)
Report a diagnostic in the "from" context.
llvm::DenseSet< std::tuple< Decl *, Decl *, int > > NonEquivalentDeclSet
bool IsStructurallyEquivalent(QualType From, QualType To, bool Complain=true)
Determine whether the given types are structurally equivalent.
virtual Expected< Decl * > ImportImpl(Decl *From)
Can be overwritten by subclasses to implement their own import logic.
bool isMinimalImport() const
Whether the importer will perform a minimal import, creating to-be-completed forward declarations whe...
ASTImporter(ASTContext &ToContext, FileManager &ToFileManager, ASTContext &FromContext, FileManager &FromFileManager, bool MinimalImport, std::shared_ptr< ASTImporterSharedState > SharedState=nullptr)
llvm::Expected< ExprWithCleanups::CleanupObject > Import(ExprWithCleanups::CleanupObject From)
Import cleanup objects owned by ExprWithCleanup.
virtual void CompleteDecl(Decl *D)
Called for ObjCInterfaceDecl, ObjCProtocolDecl, and TagDecl.
Decl * GetAlreadyImportedOrNull(const Decl *FromD) const
Return the copy of the given declaration in the "to" context if it has already been imported from the...
void setImportDeclError(Decl *From, ASTImportError Error)
Mark (newly) imported declaration with error.
ExpectedDecl VisitObjCImplementationDecl(ObjCImplementationDecl *D)
ExpectedStmt VisitGenericSelectionExpr(GenericSelectionExpr *E)
ExpectedStmt VisitTypeTraitExpr(TypeTraitExpr *E)
ExpectedDecl VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
ExpectedDecl VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
ExpectedStmt VisitDeclRefExpr(DeclRefExpr *E)
ExpectedDecl VisitAccessSpecDecl(AccessSpecDecl *D)
ExpectedDecl VisitFunctionDecl(FunctionDecl *D)
ExpectedDecl VisitParmVarDecl(ParmVarDecl *D)
ExpectedStmt VisitImplicitValueInitExpr(ImplicitValueInitExpr *E)
ExpectedStmt VisitImplicitCastExpr(ImplicitCastExpr *E)
ExpectedDecl VisitCXXMethodDecl(CXXMethodDecl *D)
ExpectedDecl VisitUsingDecl(UsingDecl *D)
ExpectedDecl VisitObjCProtocolDecl(ObjCProtocolDecl *D)
ExpectedStmt VisitStmt(Stmt *S)
ExpectedDecl VisitTranslationUnitDecl(TranslationUnitDecl *D)
ExpectedDecl VisitFieldDecl(FieldDecl *D)
Error ImportFieldDeclDefinition(const FieldDecl *From, const FieldDecl *To)
Error ImportDefinitionIfNeeded(Decl *FromD, Decl *ToD=nullptr)
ExpectedStmt VisitCharacterLiteral(CharacterLiteral *E)
ExpectedStmt VisitCXXConstructExpr(CXXConstructExpr *E)
ExpectedStmt VisitObjCAtThrowStmt(ObjCAtThrowStmt *S)
ExpectedDecl VisitStaticAssertDecl(StaticAssertDecl *D)
ExpectedStmt VisitShuffleVectorExpr(ShuffleVectorExpr *E)
ExpectedDecl VisitObjCPropertyDecl(ObjCPropertyDecl *D)
ExpectedDecl VisitRecordDecl(RecordDecl *D)
ExpectedStmt VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E)
ExpectedDecl VisitUsingShadowDecl(UsingShadowDecl *D)
Error ImportArrayChecked(const InContainerTy &InContainer, OIter Obegin)
ExpectedStmt VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S)
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)
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)
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 VisitCXXParenListInitExpr(CXXParenListInitExpr *E)
ExpectedDecl VisitObjCCategoryDecl(ObjCCategoryDecl *D)
ExpectedStmt VisitAddrLabelExpr(AddrLabelExpr *E)
ExpectedStmt VisitBinaryConditionalOperator(BinaryConditionalOperator *E)
ExpectedStmt VisitSwitchStmt(SwitchStmt *S)
ExpectedType VisitType(const Type *T)
ExpectedDecl VisitVarTemplateDecl(VarTemplateDecl *D)
ExpectedDecl ImportUsingShadowDecls(BaseUsingDecl *D, BaseUsingDecl *ToSI)
ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E)
ExpectedStmt VisitOpaqueValueExpr(OpaqueValueExpr *E)
ExpectedDecl VisitNamespaceAliasDecl(NamespaceAliasDecl *D)
ExpectedStmt VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E)
ExpectedDecl VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
ExpectedStmt VisitPackExpansionExpr(PackExpansionExpr *E)
ExpectedStmt VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E)
ExpectedDecl VisitObjCMethodDecl(ObjCMethodDecl *D)
Error ImportTemplateArguments(ArrayRef< TemplateArgument > FromArgs, SmallVectorImpl< TemplateArgument > &ToArgs)
ExpectedDecl VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D)
ExpectedStmt VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E)
ExpectedDecl VisitImplicitParamDecl(ImplicitParamDecl *D)
ExpectedDecl VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D)
ExpectedStmt VisitExplicitCastExpr(ExplicitCastExpr *E)
ExpectedStmt VisitArrayInitIndexExpr(ArrayInitIndexExpr *E)
Error ImportTemplateArgumentListInfo(const InContainerTy &Container, TemplateArgumentListInfo &ToTAInfo)
ExpectedStmt VisitDoStmt(DoStmt *S)
ExpectedStmt VisitNullStmt(NullStmt *S)
ExpectedStmt VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E)
ExpectedDecl VisitBuiltinTemplateDecl(BuiltinTemplateDecl *D)
Error ImportOverriddenMethods(CXXMethodDecl *ToMethod, CXXMethodDecl *FromMethod)
ExpectedStmt VisitStringLiteral(StringLiteral *E)
Error ImportDeclarationNameLoc(const DeclarationNameInfo &From, DeclarationNameInfo &To)
ExpectedStmt VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E)
bool hasReturnTypeDeclaredInside(FunctionDecl *D)
This function checks if the given function has a return type that contains a reference (in any way) t...
ASTNodeImporter(ASTImporter &Importer)
ExpectedDecl VisitCXXDeductionGuideDecl(CXXDeductionGuideDecl *D)
ExpectedStmt VisitMemberExpr(MemberExpr *E)
ExpectedStmt VisitConceptSpecializationExpr(ConceptSpecializationExpr *E)
ExpectedStmt VisitCXXThisExpr(CXXThisExpr *E)
Error ImportInitializer(VarDecl *From, VarDecl *To)
ImportDefinitionKind
What we should import from the definition.
@ IDK_Everything
Import everything.
@ IDK_Default
Import the default subset of the definition, which might be nothing (if minimal import is set) or mig...
@ IDK_Basic
Import only the bare bones needed to establish a valid DeclContext.
ExpectedDecl VisitTypedefDecl(TypedefDecl *D)
ExpectedDecl VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
ExpectedStmt VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E)
ExpectedDecl VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D)
Expected< concepts::Requirement * > ImportExprRequirement(concepts::ExprRequirement *From)
ExpectedStmt VisitFloatingLiteral(FloatingLiteral *E)
ExpectedStmt VisitIfStmt(IfStmt *S)
ExpectedStmt VisitLabelStmt(LabelStmt *S)
ExpectedStmt VisitCXXTypeidExpr(CXXTypeidExpr *E)
ExpectedStmt VisitConvertVectorExpr(ConvertVectorExpr *E)
ExpectedDecl VisitUsingEnumDecl(UsingEnumDecl *D)
ExpectedStmt VisitGotoStmt(GotoStmt *S)
ExpectedStmt VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *E)
ExpectedStmt VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S)
ExpectedStmt VisitGCCAsmStmt(GCCAsmStmt *S)
ExpectedDecl VisitNamespaceDecl(NamespaceDecl *D)
ExpectedStmt VisitCXXTryStmt(CXXTryStmt *S)
Error ImportConstraintSatisfaction(const ASTConstraintSatisfaction &FromSat, ConstraintSatisfaction &ToSat)
ExpectedDecl VisitImportDecl(ImportDecl *D)
Error ImportFunctionDeclBody(FunctionDecl *FromFD, FunctionDecl *ToFD)
ExpectedStmt VisitArraySubscriptExpr(ArraySubscriptExpr *E)
Expected< concepts::Requirement * > ImportTypeRequirement(concepts::TypeRequirement *From)
ExpectedStmt VisitIntegerLiteral(IntegerLiteral *E)
ExpectedDecl VisitEmptyDecl(EmptyDecl *D)
ExpectedStmt VisitCXXNoexceptExpr(CXXNoexceptExpr *E)
ExpectedStmt VisitExpr(Expr *E)
Error ImportDefaultArgOfParmVarDecl(const ParmVarDecl *FromParam, ParmVarDecl *ToParam)
ExpectedStmt VisitArrayInitLoopExpr(ArrayInitLoopExpr *E)
ExpectedStmt VisitCXXCatchStmt(CXXCatchStmt *S)
ExpectedStmt VisitAttributedStmt(AttributedStmt *S)
ExpectedStmt VisitIndirectGotoStmt(IndirectGotoStmt *S)
ExpectedStmt VisitParenListExpr(ParenListExpr *E)
Expected< FunctionDecl * > FindFunctionTemplateSpecialization(FunctionDecl *FromFD)
ExpectedDecl VisitCXXConversionDecl(CXXConversionDecl *D)
ExpectedStmt VisitObjCAtCatchStmt(ObjCAtCatchStmt *S)
Error ImportTemplateInformation(FunctionDecl *FromFD, FunctionDecl *ToFD)
ExpectedStmt VisitStmtExpr(StmtExpr *E)
ExpectedStmt VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E)
bool shouldForceImportDeclContext(ImportDefinitionKind IDK)
ExpectedDecl VisitBindingDecl(BindingDecl *D)
std::tuple< FunctionTemplateDecl *, TemplateArgsTy > FunctionTemplateAndArgsTy
ExpectedStmt VisitBreakStmt(BreakStmt *S)
DesignatedInitExpr::Designator Designator
ExpectedDecl VisitTemplateParamObjectDecl(TemplateParamObjectDecl *D)
SourceLocation getColonLoc() const
SourceLocation getQuestionLoc() const
Represents an access specifier followed by colon ':'.
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
AddrLabelExpr - The GNU address of label extension, representing &&label.
SourceLocation getAmpAmpLoc() const
SourceLocation getLabelLoc() const
LabelDecl * getLabel() const
QualType getAdjustedType() const
QualType getOriginalType() 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.
ArraySizeModifier getSizeModifier() const
QualType getElementType() const
unsigned getIndexTypeCVRQualifiers() const
SourceLocation getAsmLoc() const
unsigned getNumClobbers() const
unsigned getNumOutputs() const
unsigned getNumInputs() const
A structure for storing the information associated with a name that has been assumed to be a template...
DeclarationName getDeclName() const
Get the name of the template.
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
SourceLocation getRParenLoc() const
static unsigned getNumSubExprs(AtomicOp Op)
Determine the number of arguments the specified atomic builtin should have.
SourceLocation getBuiltinLoc() const
Attr - This represents one attribute.
attr::Kind getKind() const
void setPackExpansion(bool PE)
Attr * clone(ASTContext &C) const
SourceRange getRange() const
void setRange(SourceRange R)
void setAttrName(const IdentifierInfo *AttrNameII)
const IdentifierInfo * getAttrName() const
Represents an attribute applied to a statement.
SourceLocation getAttrLoc() const
ArrayRef< const Attr * > getAttrs() const
static AttributedStmt * Create(const ASTContext &C, SourceLocation Loc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Represents a C++ declaration that introduces decls from somewhere else.
void addShadowDecl(UsingShadowDecl *S)
shadow_range shadows() const
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condition evaluates to false; ...
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value.
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression which will be evaluated if the condition evaluates to true; th...
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
A builtin binary operation expression such as "x + y" or "x <= y".
SourceLocation getOperatorLoc() const
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
FPOptionsOverride getFPFeatures() const
A binding in a decomposition declaration.
ValueDecl * getDecomposedDecl() const
Get the decomposition declaration that this binding represents a decomposition of.
Expr * getBinding() const
Get the expression to which this declaration is bound.
void setBinding(QualType DeclaredType, Expr *Binding)
Set the binding for this BindingDecl, along with its declared type (which should be a possibly-cv-qua...
void setDecomposedDecl(ValueDecl *Decomposed)
Set the decomposed variable for this BindingDecl.
unsigned getNumBits() const
QualType getPointeeType() const
decl_range dependent_decls() const
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)
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()
ArrayRef< Expr * > getUserSpecifiedInitExprs() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
TypeSourceInfo * getDestroyedTypeInfo() const
Retrieve the source location information for the type being destroyed.
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an '->' (otherwise,...
TypeSourceInfo * getScopeTypeInfo() const
Retrieve the scope type in a qualified pseudo-destructor expression.
SourceLocation getTildeLoc() const
Retrieve the location of the '~'.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieves the nested-name-specifier that qualifies the type name, with source-location information.
SourceLocation getDestroyedTypeLoc() const
Retrieve the starting location of the type being destroyed.
SourceLocation getColonColonLoc() const
Retrieve the location of the '::' in a qualified pseudo-destructor expression.
SourceLocation getOperatorLoc() const
Retrieve the location of the '.' or '->' operator.
const IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
Represents a C++ struct/union/class.
CXXRecordDecl * getMostRecentDecl()
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
method_range methods() const
CXXRecordDecl * getDefinition() const
static CXXRecordDecl * CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, unsigned DependencyKind, bool IsGeneric, LambdaCaptureDefault CaptureDefault)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
void setLambdaContextDecl(Decl *ContextDecl)
Set the context declaration for a lambda class.
void setDescribedClassTemplate(ClassTemplateDecl *Template)
void setLambdaNumbering(LambdaNumbering Numbering)
Set the mangling numbers for a lambda class.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization,...
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
CXXRecordDecl * getPreviousDecl()
static CXXReinterpretCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
A rewritten comparison expression that was originally written using operator syntax.
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
bool isReversed() const
Determine whether this expression was rewritten in reverse form.
An expression "T()" which creates an rvalue of a non-class type T.
TypeSourceInfo * getTypeSourceInfo() const
SourceLocation getRParenLoc() const
static CXXStaticCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, FPOptionsOverride FPO, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Represents a C++ functional cast expression that builds a temporary object.
static CXXTemporaryObjectExpr * Create(const ASTContext &Ctx, CXXConstructorDecl *Cons, QualType Ty, TypeSourceInfo *TSI, ArrayRef< Expr * > Args, SourceRange ParenOrBraceRange, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization)
TypeSourceInfo * getTypeSourceInfo() const
Represents a C++ temporary.
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
Represents the this expression in C++.
static CXXThisExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType Ty, bool IsImplicit)
SourceLocation getLocation() const
A C++ throw-expression (C++ [except.throw]).
const Expr * getSubExpr() const
SourceLocation getThrowLoc() const
bool isThrownVariableInScope() const
Determines whether the variable thrown by this expression (if any!) is within the innermost try block...
CXXTryStmt - A C++ try block, including all handlers.
SourceLocation getTryLoc() const
CXXCatchStmt * getHandler(unsigned i)
unsigned getNumHandlers() const
static CXXTryStmt * Create(const ASTContext &C, SourceLocation tryLoc, CompoundStmt *tryBlock, ArrayRef< Stmt * > handlers)
CompoundStmt * getTryBlock()
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
bool isTypeOperand() const
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Expr * getExprOperand() const
SourceRange getSourceRange() const LLVM_READONLY
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
bool isListInitialization() const
Determine whether this expression models list-initialization.
static CXXUnresolvedConstructExpr * Create(const ASTContext &Context, QualType T, TypeSourceInfo *TSI, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool IsListInit)
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
unsigned getNumArgs() const
Retrieve the number of arguments.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
ADLCallKind getADLCallKind() const
FPOptionsOverride getFPFeatures() const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
SourceLocation getRParenLoc() const
CaseStmt - Represent a case statement.
SourceLocation getEllipsisLoc() const
Get the location of the ... in a case statement of the form LHS ... RHS.
static CaseStmt * Create(const ASTContext &Ctx, Expr *lhs, Expr *rhs, SourceLocation caseLoc, SourceLocation ellipsisLoc, SourceLocation colonLoc)
Build a case statement.
SourceLocation getCaseLoc() const
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
path_iterator path_begin()
CastKind getCastKind() const
FPOptionsOverride getFPFeatures() const
CharUnits - This is an opaque type for sizes expressed in character units.
SourceLocation getLocation() const
unsigned getValue() const
CharacterLiteralKind getKind() const
How to handle import errors that occur when import of a child declaration of a DeclContext fails.
bool ignoreChildErrorOnParent(Decl *FromChildD) const
Determine if import failure of a child does not cause import failure of its parent.
ChildErrorHandlingStrategy(const Decl *FromD)
void handleChildImportResult(Error &ResultErr, Error &&ChildErr)
Process the import result of a child (of the current declaration).
ChildErrorHandlingStrategy(const DeclContext *FromDC)
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
SourceLocation getBuiltinLoc() const
bool isConditionDependent() const
bool isConditionTrue() const
isConditionTrue - Return whether the condition is true (i.e.
SourceLocation getRParenLoc() const
Declaration of a class template.
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
ClassTemplateDecl * getMostRecentDecl()
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
ClassTemplatePartialSpecializationDecl * findPartialSpecialization(ArrayRef< TemplateArgument > Args, TemplateParameterList *TPL, void *&InsertPos)
Return the partial specialization with the provided arguments if it exists, otherwise return the inse...
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary class pattern.
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
ClassTemplatePartialSpecializationDecl * getInstantiatedFromMember() const
Retrieve the member class template partial specialization from which this particular class template p...
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a class template specialization, which refers to a class template with a given set of temp...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
void setPointOfInstantiation(SourceLocation Loc)
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
void setExternKeywordLoc(SourceLocation Loc)
Sets the location of the extern keyword.
void setSpecializationKind(TemplateSpecializationKind TSK)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
SourceLocation getExternKeywordLoc() const
Gets the location of the extern keyword, if present.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
const TemplateArgumentList & getTemplateInstantiationArgs() const
Retrieve the set of template arguments that should be used to instantiate members of the class templa...
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getInstantiatedFrom() const
If this class template specialization is an instantiation of a template (rather than an explicit spec...
bool hasStrictPackMatch() const
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
Note that this class template specialization is actually an instantiation of the given class template...
bool isExplicitInstantiationOrSpecialization() const
True if this declaration is an explicit specialization, explicit instantiation declaration,...
void setTemplateArgsAsWritten(const ASTTemplateArgumentListInfo *ArgsWritten)
Set the template argument list as written in the sources.
QualType getElementType() const
CompoundAssignOperator - For compound assignments (e.g.
QualType getComputationLHSType() const
static CompoundAssignOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures, QualType CompLHSType=QualType(), QualType CompResultType=QualType())
QualType getComputationResultType() const
CompoundLiteralExpr - [C99 6.5.2.5].
SourceLocation getLParenLoc() const
const Expr * getInitializer() const
TypeSourceInfo * getTypeSourceInfo() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
FPOptionsOverride getStoredFPFeatures() const
Get FPOptionsOverride from trailing storage.
SourceLocation getLBracLoc() const
bool hasStoredFPFeatures() const
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)
SourceLocation getRBracLoc() const
Declaration of a C++20 concept.
Expr * getConstraintExpr() const
A reference to a concept and its template args, as it appears in the code.
const NestedNameSpecifierLoc & getNestedNameSpecifierLoc() const
NamedDecl * getFoundDecl() const
const DeclarationNameInfo & getConceptNameInfo() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
TemplateDecl * getNamedConcept() const
SourceLocation getTemplateKWLoc() const
Represents the specialization of a concept - evaluates to a prvalue of type bool.
static ConceptSpecializationExpr * Create(const ASTContext &C, ConceptReference *ConceptRef, ImplicitConceptSpecializationDecl *SpecDecl, const ConstraintSatisfaction *Satisfaction)
ConceptReference * getConceptReference() const
const ImplicitConceptSpecializationDecl * getSpecializationDecl() const
const ASTConstraintSatisfaction & getSatisfaction() const
Get elaborated satisfaction info about the template arguments' satisfaction of the named concept.
ConditionalOperator - The ?
Expr * getCond() const
getCond - Return the expression representing the condition for the ?
const Expr * getSizeExpr() const
Return a pointer to the size expression.
llvm::APInt getSize() const
Return the constant array size as an APInt.
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)
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
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.
bool isCountInBytes() const
Expr * getCountExpr() const
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
AccessSpecifier getAccess() const
The results of name lookup within a DeclContext.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
DeclContextLookupResult lookup_result
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void addDeclInternal(Decl *D)
Add the declaration D into this context, but suppress searches for external declarations with the sam...
bool containsDeclAndLoad(Decl *D) const
Checks whether a declaration is in this context.
void removeDecl(Decl *D)
Removes a declaration from this context.
lookup_result noload_lookup(DeclarationName Name)
Find the declarations with the given name that are visible within this context; don't attempt to retr...
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
void localUncachedLookup(DeclarationName Name, SmallVectorImpl< NamedDecl * > &Results)
A simplistic name lookup mechanism that performs name lookup into this declaration context without co...
static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls)
A reference to a declared variable, function, enum, etc.
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name,...
ArrayRef< TemplateArgumentLoc > template_arguments() const
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
bool hadMultipleCandidates() const
Returns true if this expression refers to a function that was resolved from an overloaded set having ...
SourceLocation getLocation() const
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
bool isImmediateEscalating() const
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
SourceLocation getEndLoc() const
const DeclGroupRef getDeclGroup() const
SourceLocation getBeginLoc() const LLVM_READONLY
A simple visitor class that helps create declaration visitors.
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEndLoc() const LLVM_READONLY
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration.
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
@ FOK_None
Not a friend object.
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration.
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
const char * getDeclKindName() const
IdentifierNamespace
IdentifierNamespace - The different namespaces in which declarations may appear.
@ IDNS_NonMemberOperator
This declaration is a C++ operator declared in a non-class context.
@ IDNS_TagFriend
This declaration is a friend class.
@ IDNS_Ordinary
Ordinary names.
@ IDNS_ObjCProtocol
Objective C @protocol.
@ IDNS_Namespace
Namespaces, declared with 'namespace foo {}'.
@ IDNS_OrdinaryFriend
This declaration is a friend function.
@ IDNS_Tag
Tags, declared with 'struct foo;' and referenced with 'struct foo'.
void setImplicit(bool I=true)
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
bool isInAnonymousNamespace() const
SourceLocation getBeginLoc() const LLVM_READONLY
TranslationUnitDecl * getTranslationUnitDecl()
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
void setLexicalDeclContext(DeclContext *DC)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
const IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it.
static DeclarationName getUsingDirectiveName()
Returns the name for all C++ using-directives.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
@ CXXConversionFunctionName
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
NameKind getNameKind() const
Determine what kind of name this is.
bool isEmpty() const
Evaluates true when this declaration name is empty.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
SourceLocation getBeginLoc() const LLVM_READONLY
const AssociatedConstraint & getTrailingRequiresClause() const
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
void setTypeSourceInfo(TypeSourceInfo *TI)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
TypeSourceInfo * getTypeSourceInfo() const
A decomposition declaration.
SourceLocation getDefaultLoc() const
Expr * getAddrSpaceExpr() const
QualType getPointeeType() const
SourceLocation getAttributeLoc() const
Expr * getNumBitsExpr() 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.
Expr * getSizeExpr() const
Expr * getSizeExpr() const
SourceLocation getAttributeLoc() const
QualType getElementType() const
Expr * getColumnExpr() const
Expr * getRowExpr() const
SourceLocation getAttributeLoc() 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?
Expr * getSizeExpr() const
VectorKind getVectorKind() const
SourceLocation getAttributeLoc() const
QualType getElementType() const
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 getLocation() const
Retrieve the location of the literal.
llvm::APInt getValue() const
Returns an internal integer representation of the literal.
SourceLocation getLocation() const
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
llvm::APFloat getValue() const
ForStmt - This represents a 'for (init;cond;inc)' stmt.
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
SourceLocation getRParenLoc() const
SourceLocation getForLoc() const
SourceLocation getLParenLoc() const
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
SourceLocation getFriendLoc() const
Retrieves the location of the 'friend' keyword.
SourceLocation getEllipsisLoc() const
Retrieves the location of the '...', if present.
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
const Expr * getSubExpr() const
static DefaultedOrDeletedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups, StringLiteral *DeletedMessage=nullptr)
Represents a function declaration or definition.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
ConstexprSpecKind getConstexprKind() const
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
void setIsPureVirtual(bool P=true)
void setDefaultedOrDeletedInfo(DefaultedOrDeletedFunctionInfo *Info)
void setFriendConstraintRefersToEnclosingTemplate(bool V=true)
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
StringLiteral * getDeletedMessage() const
Get the message that indicates why this function was deleted.
bool UsesFPIntrin() const
Determine whether the function was declared in source context that requires constrained FP intrinsics...
SourceLocation getDefaultLoc() const
ArrayRef< ParmVarDecl * > parameters() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
bool hasWrittenPrototype() const
Whether this function has a written prototype.
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization,...
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
void setDefaultLoc(SourceLocation NewLoc)
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
DependentFunctionTemplateSpecializationInfo * getDependentSpecializationInfo() const
@ TK_MemberSpecialization
@ TK_DependentNonTemplate
@ TK_FunctionTemplateSpecialization
@ TK_DependentFunctionTemplateSpecialization
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool FriendConstraintRefersToEnclosingTemplate() const
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
void setInstantiatedFromDecl(FunctionDecl *FD)
Specify that this function declaration was instantiated from a FunctionDecl FD.
bool isDeletedAsWritten() const
void setDependentTemplateSpecialization(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo *TemplateArgs)
Specifies that this function declaration is actually a dependent function template specialization.
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
FunctionDecl * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setVirtualAsWritten(bool V)
State that this function is marked as virtual explicitly.
void setIsDestroyingOperatorDelete(bool IsDestroyingDelete)
FunctionDecl * getDefinition()
Get the definition for this declaration.
bool isTypeAwareOperatorNewOrDelete() const
Determine whether this is a type aware operator new or delete.
void setIsTypeAwareOperatorNewOrDelete(bool IsTypeAwareOperator=true)
void setRangeEnd(SourceLocation E)
bool isDefaulted() const
Whether this function is defaulted.
FunctionDecl * getInstantiatedFromDecl() const
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
void setDefaulted(bool D=true)
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
void setDeletedAsWritten(bool D=true, StringLiteral *Message=nullptr)
void setExplicitlyDefaulted(bool ED=true)
State that this function is explicitly defaulted.
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization,...
DeclarationNameInfo getNameInfo() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
FunctionDecl * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Represents a prototype with parameter type info, e.g.
ExtProtoInfo getExtProtoInfo() const
ArrayRef< QualType > exceptions() const
ArrayRef< QualType > param_types() const
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isThisDeclarationADefinition() const
Returns whether this template declaration defines the primary pattern.
FunctionTemplateDecl * getMostRecentDecl()
ExtInfo getExtInfo() const
QualType getReturnType() const
This represents a GCC inline-assembly statement extension.
unsigned getNumLabels() const
SourceLocation getRParenLoc() const
IdentifierInfo * getInputIdentifier(unsigned i) const
const Expr * getOutputConstraintExpr(unsigned i) const
const Expr * getInputConstraintExpr(unsigned i) const
IdentifierInfo * getOutputIdentifier(unsigned i) const
const Expr * getAsmStringExpr() const
Expr * getClobberExpr(unsigned i)
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
SourceLocation getBeginLoc() const LLVM_READONLY
Represents a C11 generic selection.
TypeSourceInfo * getControllingType()
Return the controlling type of this generic selection expression.
ArrayRef< Expr * > getAssocExprs() const
bool isExprPredicate() const
Whether this generic selection uses an expression as its controlling argument.
SourceLocation getGenericLoc() const
SourceLocation getRParenLoc() const
unsigned getResultIndex() const
The zero-based index of the result expression's generic association in the generic selection's associ...
SourceLocation getDefaultLoc() const
static GenericSelectionExpr * Create(const ASTContext &Context, SourceLocation GenericLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > AssocTypes, ArrayRef< Expr * > AssocExprs, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool ContainsUnexpandedParameterPack, unsigned ResultIndex)
Create a non-result-dependent generic selection expression accepting an expression predicate.
bool isResultDependent() const
Whether this generic selection is result-dependent.
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
ArrayRef< TypeSourceInfo * > getAssocTypeSourceInfos() const
GotoStmt - This represents a direct goto.
SourceLocation getLabelLoc() const
SourceLocation getGotoLoc() const
LabelDecl * getLabel() const
One of these records is kept for each identifier that is lexed.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
void setBuiltinID(unsigned ID)
StringRef getName() const
Return the actual identifier string.
IfStmt - This represents an if/then/else.
static IfStmt * Create(const ASTContext &Ctx, SourceLocation IL, IfStatementKind Kind, Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LPL, SourceLocation RPL, Stmt *Then, SourceLocation EL=SourceLocation(), Stmt *Else=nullptr)
Create an IfStmt.
SourceLocation getIfLoc() const
IfStatementKind getStatementKind() const
SourceLocation getElseLoc() const
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
VarDecl * getConditionVariable()
Retrieve the variable declared in this "if" statement, if any.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
const Expr * getSubExpr() const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
ArrayRef< TemplateArgument > getTemplateArguments() const
ImplicitParamKind getParameterKind() const
Returns the implicit parameter kind.
Represents an implicitly-generated value initialization of an object of a given type.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Represents a field injected from an anonymous union/struct into the parent scope.
unsigned getChainingSize() const
ArrayRef< NamedDecl * > chain() const
IndirectGotoStmt - This represents an indirect goto.
SourceLocation getGotoLoc() const
SourceLocation getStarLoc() const
Description of a constructor that was inherited from a base class.
CXXConstructorDecl * getConstructor() const
ConstructorUsingShadowDecl * getShadowDecl() const
Describes an C or C++ initializer list.
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
void setSyntacticForm(InitListExpr *Init)
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
unsigned getNumInits() const
SourceLocation getLBraceLoc() const
void setArrayFiller(Expr *filler)
InitListExpr * getSyntacticForm() const
bool hadArrayRangeDesignator() const
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
SourceLocation getRBraceLoc() const
void setInitializedFieldInUnion(FieldDecl *FD)
ArrayRef< Expr * > inits() const
void sawArrayRangeDesignator(bool ARD=true)
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
SourceLocation getLocation() const
Retrieve the location of the literal.
ElaboratedTypeKeyword getKeyword() const
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.
QualType getUnderlyingType() const
const IdentifierInfo * getMacroIdentifier() const
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()
QualType getElementType() const
Returns type of the elements being stored in the matrix.
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.
NestedNameSpecifier getQualifier() const
CXXRecordDecl * getMostRecentCXXRecordDecl() const
Note: this can trigger extra deserialization when external AST sources are used.
QualType getPointeeType() const
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
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
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
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
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.
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
FieldDecl * getField() const
For a field offsetof node, returns the field.
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
@ Array
An index into an array.
@ Identifier
A field in a dependent type, known only by its name.
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
SourceLocation getBeginLoc() const LLVM_READONLY
Kind getKind() const
Determine what kind of offsetof node this is.
SourceLocation getEndLoc() const LLVM_READONLY
CXXBaseSpecifier * getBase() const
For a base class node, returns the base specifier.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
SourceLocation getLocation() const
Retrieve the location of this expression.
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
SourceLocation getNameLoc() const
Gets the location of the name.
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
llvm::iterator_range< decls_iterator > decls() const
void copyTemplateArgumentsInto(TemplateArgumentListInfo &List) const
Copies the template arguments into the given structure.
DeclarationName getName() const
Gets the name looked up.
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
ArrayRef< TemplateArgumentLoc > template_arguments() const
A structure for storing the information associated with an overloaded template name.
Represents a C++11 pack expansion that produces a sequence of expressions.
Expr * getPattern()
Retrieve the pattern of the pack expansion.
UnsignedOrNone getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated,...
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
ParenExpr - This represents a parenthesized expression, e.g.
SourceLocation getLParen() const
Get the location of the left parentheses '('.
const Expr * getSubExpr() const
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
ArrayRef< Expr * > exprs() const
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr * > Exprs, SourceLocation RParenLoc)
Create a paren list.
unsigned getNumExprs() const
Return the number of expressions in this paren list.
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
QualType getInnerType() 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)
QualType getElementType() const
QualType getPointeeType() const
[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.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the 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.
QualType getPointeeTypeAsWritten() const
Represents the body of a requires-expression.
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
SourceLocation getRBraceLoc() const
SourceLocation getRequiresKWLoc() const
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
RequiresExprBodyDecl * getBody() const
ArrayRef< concepts::Requirement * > getRequirements() const
ArrayRef< ParmVarDecl * > getLocalParameters() const
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
SourceLocation getReturnLoc() const
const VarDecl * getNRVOCandidate() const
Retrieve the variable that might be used for the named return value optimization.
static ReturnStmt * Create(const ASTContext &Ctx, SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)
Create a return statement.
Smart pointer class that efficiently represents Objective-C method names.
const IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
bool isNull() const
Determine whether this is the empty selector.
unsigned getNumArgs() const
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Expr ** getSubExprs()
Retrieve the array of expressions.
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
SourceLocation getRParenLoc() const
SourceLocation getBeginLoc() const LLVM_READONLY
Represents an expression that computes the length of a parameter pack.
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof... expression, such as is produced f...
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, UnsignedOrNone Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs={})
ArrayRef< TemplateArgument > getPartialArguments() const
Get.
SourceLocation getOperatorLoc() const
Determine the location of the 'sizeof' keyword.
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
NamedDecl * getPack() const
Retrieve the parameter pack.
unsigned getPackLength() const
Retrieve the length of the parameter pack.
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
SourceLocation getBeginLoc() const
const DeclContext * getParentContext() const
If the SourceLocExpr has been resolved return the subexpression representing the resolved value.
SourceLocation getEndLoc() const
SourceLocIdentKind getIdentKind() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
This class handles loading and caching of source files into memory.
FileIDAndOffset getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
bool isWrittenInBuiltinFile(SourceLocation Loc) const
Returns whether Loc is located in a <built-in> file.
FileID createFileID(FileEntryRef SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0)
Create a new FileID that represents the specified file being #included from the specified IncludePosi...
SourceLocation getComposedLoc(FileID FID, unsigned Offset) const
Form a SourceLocation from a FileID and Offset pair.
FileManager & getFileManager() const
FileID getMainFileID() const
Returns the FileID of the main source file.
unsigned getFileIDSize(FileID FID) const
The size of the SLocEntry that FID represents.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file.
SourceLocation createExpansionLoc(SourceLocation SpellingLoc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned Length, bool ExpansionIsTokenRange=true, int LoadedID=0, SourceLocation::UIntTy LoadedOffset=0)
Creates an expansion SLocEntry for a macro use.
const SrcMgr::SLocEntry & getSLocEntry(FileID FID, bool *Invalid=nullptr) const
SourceLocation createMacroArgExpansionLoc(SourceLocation SpellingLoc, SourceLocation ExpansionLoc, unsigned Length)
Creates an expansion SLocEntry for the substitution of an argument into a function-like macro's body.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
One instance of this struct is kept for every file loaded or used.
Each ExpansionInfo encodes the expansion location - where the token was ultimately expanded,...
SourceLocation getExpansionLocStart() const
bool isExpansionTokenRange() const
SourceLocation getSpellingLoc() const
bool isMacroArgExpansion() const
SourceLocation getExpansionLocEnd() const
const ContentCache & getContentCache() const
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
SourceLocation getIncludeLoc() const
This is a discriminated union of FileInfo and ExpansionInfo.
const FileInfo & getFile() const
const ExpansionInfo & getExpansion() const
Represents a C++11 static_assert declaration.
SourceLocation getRParenLoc() const
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
CompoundStmt * getSubStmt()
unsigned getTemplateDepth() const
SourceLocation getRParenLoc() const
SourceLocation getLParenLoc() const
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Stmt - This represents one statement.
child_iterator child_begin()
StmtClass getStmtClass() const
child_iterator child_end()
const char * getStmtClassName() const
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
tokloc_iterator tokloc_begin() const
tokloc_iterator tokloc_end() const
StringLiteralKind getKind() const
static StringLiteral * Create(const ASTContext &Ctx, StringRef Str, StringLiteralKind Kind, bool Pascal, QualType Ty, ArrayRef< SourceLocation > Locs)
This is the "fully general" constructor that allows representation of strings formed from one or more...
StringRef getBytes() const
Allow access to clients that need the byte representation, such as ASTWriterStmt::VisitStringLiteral(...
unsigned getNumConcatenated() const
getNumConcatenated - Get the number of string literal tokens that were concatenated in translation ph...
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
UnsignedOrNone getPackIndex() const
bool isReferenceParameter() const
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
SourceLocation getNameLoc() const
Expr * getReplacement() const
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
SourceLocation getParameterPackLocation() const
Retrieve the location of the parameter pack name.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
A structure for storing an already-substituted template template parameter pack.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
TemplateArgument getArgumentPack() const
Retrieve the template template argument pack with which this parameter was substituted.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
A structure for storing the information associated with a substituted template template parameter.
TemplateName getReplacement() const
UnsignedOrNone getPackIndex() const
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
void setNextSwitchCase(SwitchCase *SC)
SourceLocation getColonLoc() const
const SwitchCase * getNextSwitchCase() const
SwitchStmt - This represents a 'switch' stmt.
SourceLocation getSwitchLoc() const
SourceLocation getLParenLoc() const
SourceLocation getRParenLoc() const
static SwitchStmt * Create(const ASTContext &Ctx, Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a switch statement.
VarDecl * getConditionVariable()
Retrieve the variable declared in this "switch" statement, if any.
SwitchCase * getSwitchCaseList()
Represents the declaration of a struct/union/class/enum.
SourceRange getBraceRange() const
bool isBeingDefined() const
Return true if this decl is currently being defined.
TagDecl * getDefinition() const
Returns the TagDecl that actually defines this struct/union/class/enum.
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
TypedefNameDecl * getTypedefNameForAnonDecl() const
void startDefinition()
Starts the definition of this tag declaration.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
TagKind getTagKind() const
void setBraceRange(SourceRange R)
void setCompleteDefinition(bool V=true)
True if this decl has its body fully specified.
A convenient class for passing around template argument information.
SourceLocation getRAngleLoc() const
void addArgument(const TemplateArgumentLoc &Loc)
ArrayRef< TemplateArgumentLoc > arguments() const
SourceLocation getLAngleLoc() const
A template argument list.
static TemplateArgumentList * CreateCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument list that copies the given set of template arguments.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
ArrayRef< TemplateArgument > asArray() const
Produce this as an array ref.
Location wrapper for a TemplateArgument.
TemplateArgumentLocInfo getLocInfo() const
const TemplateArgument & getArgument() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
QualType getParamTypeForDecl() const
Expr * getAsExpr() const
Retrieve the template argument as an expression.
UnsignedOrNone getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce,...
QualType getAsType() const
Retrieve the type for a type template argument.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
unsigned pack_size() const
The number of template arguments in the given template argument pack.
QualType getIntegralType() const
Retrieve the type of the integral value.
bool getIsDefaulted() const
If returns 'true', this TemplateArgument corresponds to a default template parameter.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
bool isCanonicalExpr() const
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ OverloadedTemplate
A set of overloaded template declarations.
@ Template
A single template declaration.
@ DependentTemplate
A dependent template name that has not been resolved to a template (or set of templates).
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
@ DeducedTemplate
A template name that refers to another TemplateName with deduced default arguments.
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
@ AssumedTemplate
An unqualified-id that has been assumed to name a function template that will be found by ADL.
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
A template parameter object.
const APValue & getValue() const
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
SourceLocation getTemplateLoc() const
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
bool wasDeclaredWithTypename() const
Whether this template template parameter was declared with the 'typename' keyword.
TemplateNameKind templateParameterKind() const
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
unsigned getDepth() const
Get the nesting depth of the template parameter.
Declaration of a template type parameter.
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the 'typename' keyword.
unsigned getIndex() const
Retrieve the index of the template parameter.
void setTypeConstraint(ConceptReference *CR, Expr *ImmediatelyDeclaredConstraint, UnsignedOrNone ArgPackSubstIndex)
bool hasTypeConstraint() const
Determine whether this template parameter has a type-constraint.
const TypeConstraint * getTypeConstraint() const
Returns the type constraint associated with this template parameter (if any).
bool isParameterPack() const
Returns whether this is a parameter pack.
unsigned getDepth() const
Retrieve the depth of the template parameter.
The top declaration context.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
TypeAliasTemplateDecl * getDescribedAliasTemplate() const
Declaration of an alias template.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Models the abbreviated syntax to constrain a template type parameter: template <convertible_to<string...
SourceLocation getBeginLoc() const LLVM_READONLY
Symbolic representation of typeid(T) for some type T.
const Type * getType() const
SourceLocation getBeginLoc() const
Get the begin source location.
TypeOfKind getKind() const
Returns the kind of 'typeof' type this is.
Expr * getUnderlyingExpr() const
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.
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
TypedefNameDecl * getDecl() const
NestedNameSpecifier getQualifier() const
bool typeMatchesDecl() 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.
NestedNameSpecifier getQualifier() const
UnresolvedUsingTypenameDecl * getDecl() const
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.
UsingShadowDecl * getDecl() const
NestedNameSpecifier getQualifier() const
Represents a call to the builtin function __builtin_va_arg.
TypeSourceInfo * getWrittenTypeInfo() const
SourceLocation getBuiltinLoc() const
SourceLocation getRParenLoc() const
bool isMicrosoftABI() const
Returns whether this is really a Win64 ABI va_arg expression.
const Expr * getSubExpr() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
void setInstantiationOfStaticDataMember(VarDecl *VD, TemplateSpecializationKind TSK)
Specify that this variable is an instantiation of the static data member VD.
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()
Expr * getSizeExpr() const
unsigned getNumElements() const
VectorKind getVectorKind() const
QualType getElementType() const
WhileStmt - This represents a 'while' stmt.
SourceLocation getWhileLoc() const
SourceLocation getRParenLoc() const
VarDecl * getConditionVariable()
Retrieve the variable declared in this "while" statement, if any.
SourceLocation getLParenLoc() const
static WhileStmt * Create(const ASTContext &Ctx, VarDecl *Var, Expr *Cond, Stmt *Body, SourceLocation WL, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a while statement.
A requires-expression requirement which queries the validity and properties of an expression ('simple...
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
ConceptSpecializationExpr * getReturnTypeRequirementSubstitutedConstraintExpr() const
const ReturnTypeRequirement & getReturnTypeRequirement() const
SatisfactionStatus getSatisfactionStatus() const
SourceLocation getNoexceptLoc() const
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
bool hasInvalidConstraint() const
Expr * getConstraintExpr() const
StringRef getInvalidConstraintEntity()
A static requirement that can be used in a requires-expression to check properties of types and expre...
RequirementKind getKind() const
A requires-expression requirement which queries the existence of a type name or type template special...
bool isSubstitutionFailure() const
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
TypeSourceInfo * getType() const
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isa(CodeGen::Address addr)
llvm::Expected< SourceLocation > ExpectedSLoc
StructuralEquivalenceKind
Whether to perform a normal or minimal equivalence check.
llvm::Expected< const Type * > ExpectedTypePtr
CanThrowResult
Possible results from evaluation of a noexcept expression.
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
std::pair< FileID, unsigned > FileIDAndOffset
llvm::Expected< DeclarationName > ExpectedName
llvm::Expected< Decl * > ExpectedDecl
@ Property
The type of a property.
@ Result
The result type of a method or function.
OptionalUnsigned< unsigned > UnsignedOrNone
llvm::Expected< QualType > ExpectedType
@ Template
We are parsing a template declaration.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
@ VarTemplate
The name was classified as a variable template name.
std::pair< SourceLocation, StringRef > ConstraintSubstitutionDiagnostic
Unsatisfied constraint expressions if the template arguments could be substituted into them,...
CastKind
CastKind - The kind of operation required for a conversion.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
llvm::SmallVector< Decl *, 2 > getCanonicalForwardRedeclChain(Decl *D)
SmallVector< CXXBaseSpecifier *, 4 > CXXCastPath
A simple array of base specifiers.
llvm::Expected< Expr * > ExpectedExpr
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
U cast(CodeGen::Address addr)
bool isLambdaMethod(const DeclContext *DC)
llvm::Expected< Stmt * > ExpectedStmt
static void updateFlags(const Decl *From, Decl *To)
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),...
bool HasConstantDestruction
Whether this variable is known to have constant destruction.
bool HasConstantInitialization
Whether this variable is known to have constant initialization.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
RefQualifierKind RefQualifier
unsigned HasTrailingReturn
FunctionType::ExtInfo ExtInfo
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