clang  6.0.0
ASTImporter.cpp
Go to the documentation of this file.
1 //===--- ASTImporter.cpp - Importing ASTs from other Contexts ---*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the ASTImporter class which imports AST nodes from one
11 // context into another context.
12 //
13 //===----------------------------------------------------------------------===//
14 #include "clang/AST/ASTImporter.h"
15 #include "clang/AST/ASTContext.h"
18 #include "clang/AST/DeclCXX.h"
19 #include "clang/AST/DeclObjC.h"
20 #include "clang/AST/DeclVisitor.h"
21 #include "clang/AST/StmtVisitor.h"
22 #include "clang/AST/TypeVisitor.h"
25 #include "llvm/Support/MemoryBuffer.h"
26 #include <deque>
27 
28 namespace clang {
29  class ASTNodeImporter : public TypeVisitor<ASTNodeImporter, QualType>,
30  public DeclVisitor<ASTNodeImporter, Decl *>,
31  public StmtVisitor<ASTNodeImporter, Stmt *> {
32  ASTImporter &Importer;
33 
34  public:
35  explicit ASTNodeImporter(ASTImporter &Importer) : Importer(Importer) { }
36 
40 
41  // Importing types
42  QualType VisitType(const Type *T);
55  // FIXME: DependentSizedArrayType
56  // FIXME: DependentSizedExtVectorType
65  // FIXME: DependentTypeOfExprType
71  // FIXME: DependentDecltypeType
79  // FIXME: DependentNameType
81  // FIXME: DependentTemplateSpecializationType
85 
86  // Importing declarations
87  bool ImportDeclParts(NamedDecl *D, DeclContext *&DC,
88  DeclContext *&LexicalDC, DeclarationName &Name,
89  NamedDecl *&ToD, SourceLocation &Loc);
90  void ImportDefinitionIfNeeded(Decl *FromD, Decl *ToD = nullptr);
93  void ImportDeclContext(DeclContext *FromDC, bool ForceImport = false);
94 
95  bool ImportCastPath(CastExpr *E, CXXCastPath &Path);
96 
98  Designator ImportDesignator(const Designator &D);
99 
100 
101  /// \brief What we should import from the definition.
103  /// \brief Import the default subset of the definition, which might be
104  /// nothing (if minimal import is set) or might be everything (if minimal
105  /// import is not set).
107  /// \brief Import everything.
109  /// \brief Import only the bare bones needed to establish a valid
110  /// DeclContext.
112  };
113 
115  return IDK == IDK_Everything ||
116  (IDK == IDK_Default && !Importer.isMinimalImport());
117  }
118 
119  bool ImportDefinition(RecordDecl *From, RecordDecl *To,
121  bool ImportDefinition(VarDecl *From, VarDecl *To,
123  bool ImportDefinition(EnumDecl *From, EnumDecl *To,
130  TemplateParameterList *Params);
133  const TemplateArgumentLoc &TALoc);
134  bool ImportTemplateArguments(const TemplateArgument *FromArgs,
135  unsigned NumFromArgs,
137  template <typename InContainerTy>
138  bool ImportTemplateArgumentListInfo(const InContainerTy &Container,
139  TemplateArgumentListInfo &ToTAInfo);
140  bool IsStructuralMatch(RecordDecl *FromRecord, RecordDecl *ToRecord,
141  bool Complain = true);
142  bool IsStructuralMatch(VarDecl *FromVar, VarDecl *ToVar,
143  bool Complain = true);
144  bool IsStructuralMatch(EnumDecl *FromEnum, EnumDecl *ToRecord);
150  Decl *VisitDecl(Decl *D);
157  Decl *VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias);
187 
188 
204 
205  // Importing statements
207 
208  Stmt *VisitStmt(Stmt *S);
217  Stmt *VisitIfStmt(IfStmt *S);
220  Stmt *VisitDoStmt(DoStmt *S);
227  // FIXME: MSAsmStmt
228  // FIXME: SEHExceptStmt
229  // FIXME: SEHFinallyStmt
230  // FIXME: SEHTryStmt
231  // FIXME: SEHLeaveStmt
232  // FIXME: CapturedStmt
236  // FIXME: MSDependentExistsStmt
244 
245  // Importing expressions
246  Expr *VisitExpr(Expr *E);
303 
304 
305  template<typename IIter, typename OIter>
306  void ImportArray(IIter Ibegin, IIter Iend, OIter Obegin) {
307  typedef typename std::remove_reference<decltype(*Obegin)>::type ItemT;
308  ASTImporter &ImporterRef = Importer;
309  std::transform(Ibegin, Iend, Obegin,
310  [&ImporterRef](ItemT From) -> ItemT {
311  return ImporterRef.Import(From);
312  });
313  }
314 
315  template<typename IIter, typename OIter>
316  bool ImportArrayChecked(IIter Ibegin, IIter Iend, OIter Obegin) {
318  ASTImporter &ImporterRef = Importer;
319  bool Failed = false;
320  std::transform(Ibegin, Iend, Obegin,
321  [&ImporterRef, &Failed](ItemT *From) -> ItemT * {
322  ItemT *To = cast_or_null<ItemT>(
323  ImporterRef.Import(From));
324  if (!To && From)
325  Failed = true;
326  return To;
327  });
328  return Failed;
329  }
330 
331  template<typename InContainerTy, typename OutContainerTy>
332  bool ImportContainerChecked(const InContainerTy &InContainer,
333  OutContainerTy &OutContainer) {
334  return ImportArrayChecked(InContainer.begin(), InContainer.end(),
335  OutContainer.begin());
336  }
337 
338  template<typename InContainerTy, typename OIter>
339  bool ImportArrayChecked(const InContainerTy &InContainer, OIter Obegin) {
340  return ImportArrayChecked(InContainer.begin(), InContainer.end(), Obegin);
341  }
342 
343  // Importing overrides.
344  void ImportOverrides(CXXMethodDecl *ToMethod, CXXMethodDecl *FromMethod);
345  };
346 }
347 
348 //----------------------------------------------------------------------------
349 // Import Types
350 //----------------------------------------------------------------------------
351 
352 using namespace clang;
353 
355  Importer.FromDiag(SourceLocation(), diag::err_unsupported_ast_node)
356  << T->getTypeClassName();
357  return QualType();
358 }
359 
361  QualType UnderlyingType = Importer.Import(T->getValueType());
362  if(UnderlyingType.isNull())
363  return QualType();
364 
365  return Importer.getToContext().getAtomicType(UnderlyingType);
366 }
367 
369  switch (T->getKind()) {
370 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
371  case BuiltinType::Id: \
372  return Importer.getToContext().SingletonId;
373 #include "clang/Basic/OpenCLImageTypes.def"
374 #define SHARED_SINGLETON_TYPE(Expansion)
375 #define BUILTIN_TYPE(Id, SingletonId) \
376  case BuiltinType::Id: return Importer.getToContext().SingletonId;
377 #include "clang/AST/BuiltinTypes.def"
378 
379  // FIXME: for Char16, Char32, and NullPtr, make sure that the "to"
380  // context supports C++.
381 
382  // FIXME: for ObjCId, ObjCClass, and ObjCSel, make sure that the "to"
383  // context supports ObjC.
384 
385  case BuiltinType::Char_U:
386  // The context we're importing from has an unsigned 'char'. If we're
387  // importing into a context with a signed 'char', translate to
388  // 'unsigned char' instead.
389  if (Importer.getToContext().getLangOpts().CharIsSigned)
390  return Importer.getToContext().UnsignedCharTy;
391 
392  return Importer.getToContext().CharTy;
393 
394  case BuiltinType::Char_S:
395  // The context we're importing from has an unsigned 'char'. If we're
396  // importing into a context with a signed 'char', translate to
397  // 'unsigned char' instead.
398  if (!Importer.getToContext().getLangOpts().CharIsSigned)
399  return Importer.getToContext().SignedCharTy;
400 
401  return Importer.getToContext().CharTy;
402 
403  case BuiltinType::WChar_S:
404  case BuiltinType::WChar_U:
405  // FIXME: If not in C++, shall we translate to the C equivalent of
406  // wchar_t?
407  return Importer.getToContext().WCharTy;
408  }
409 
410  llvm_unreachable("Invalid BuiltinType Kind!");
411 }
412 
414  QualType OrigT = Importer.Import(T->getOriginalType());
415  if (OrigT.isNull())
416  return QualType();
417 
418  return Importer.getToContext().getDecayedType(OrigT);
419 }
420 
422  QualType ToElementType = Importer.Import(T->getElementType());
423  if (ToElementType.isNull())
424  return QualType();
425 
426  return Importer.getToContext().getComplexType(ToElementType);
427 }
428 
430  QualType ToPointeeType = Importer.Import(T->getPointeeType());
431  if (ToPointeeType.isNull())
432  return QualType();
433 
434  return Importer.getToContext().getPointerType(ToPointeeType);
435 }
436 
438  // FIXME: Check for blocks support in "to" context.
439  QualType ToPointeeType = Importer.Import(T->getPointeeType());
440  if (ToPointeeType.isNull())
441  return QualType();
442 
443  return Importer.getToContext().getBlockPointerType(ToPointeeType);
444 }
445 
446 QualType
448  // FIXME: Check for C++ support in "to" context.
449  QualType ToPointeeType = Importer.Import(T->getPointeeTypeAsWritten());
450  if (ToPointeeType.isNull())
451  return QualType();
452 
453  return Importer.getToContext().getLValueReferenceType(ToPointeeType);
454 }
455 
456 QualType
458  // FIXME: Check for C++0x support in "to" context.
459  QualType ToPointeeType = Importer.Import(T->getPointeeTypeAsWritten());
460  if (ToPointeeType.isNull())
461  return QualType();
462 
463  return Importer.getToContext().getRValueReferenceType(ToPointeeType);
464 }
465 
467  // FIXME: Check for C++ support in "to" context.
468  QualType ToPointeeType = Importer.Import(T->getPointeeType());
469  if (ToPointeeType.isNull())
470  return QualType();
471 
472  QualType ClassType = Importer.Import(QualType(T->getClass(), 0));
473  return Importer.getToContext().getMemberPointerType(ToPointeeType,
474  ClassType.getTypePtr());
475 }
476 
478  QualType ToElementType = Importer.Import(T->getElementType());
479  if (ToElementType.isNull())
480  return QualType();
481 
482  return Importer.getToContext().getConstantArrayType(ToElementType,
483  T->getSize(),
484  T->getSizeModifier(),
486 }
487 
488 QualType
490  QualType ToElementType = Importer.Import(T->getElementType());
491  if (ToElementType.isNull())
492  return QualType();
493 
494  return Importer.getToContext().getIncompleteArrayType(ToElementType,
495  T->getSizeModifier(),
497 }
498 
500  QualType ToElementType = Importer.Import(T->getElementType());
501  if (ToElementType.isNull())
502  return QualType();
503 
504  Expr *Size = Importer.Import(T->getSizeExpr());
505  if (!Size)
506  return QualType();
507 
508  SourceRange Brackets = Importer.Import(T->getBracketsRange());
509  return Importer.getToContext().getVariableArrayType(ToElementType, Size,
510  T->getSizeModifier(),
512  Brackets);
513 }
514 
516  QualType ToElementType = Importer.Import(T->getElementType());
517  if (ToElementType.isNull())
518  return QualType();
519 
520  return Importer.getToContext().getVectorType(ToElementType,
521  T->getNumElements(),
522  T->getVectorKind());
523 }
524 
526  QualType ToElementType = Importer.Import(T->getElementType());
527  if (ToElementType.isNull())
528  return QualType();
529 
530  return Importer.getToContext().getExtVectorType(ToElementType,
531  T->getNumElements());
532 }
533 
534 QualType
536  // FIXME: What happens if we're importing a function without a prototype
537  // into C++? Should we make it variadic?
538  QualType ToResultType = Importer.Import(T->getReturnType());
539  if (ToResultType.isNull())
540  return QualType();
541 
542  return Importer.getToContext().getFunctionNoProtoType(ToResultType,
543  T->getExtInfo());
544 }
545 
547  QualType ToResultType = Importer.Import(T->getReturnType());
548  if (ToResultType.isNull())
549  return QualType();
550 
551  // Import argument types
552  SmallVector<QualType, 4> ArgTypes;
553  for (const auto &A : T->param_types()) {
554  QualType ArgType = Importer.Import(A);
555  if (ArgType.isNull())
556  return QualType();
557  ArgTypes.push_back(ArgType);
558  }
559 
560  // Import exception types
561  SmallVector<QualType, 4> ExceptionTypes;
562  for (const auto &E : T->exceptions()) {
563  QualType ExceptionType = Importer.Import(E);
564  if (ExceptionType.isNull())
565  return QualType();
566  ExceptionTypes.push_back(ExceptionType);
567  }
568 
571 
572  ToEPI.ExtInfo = FromEPI.ExtInfo;
573  ToEPI.Variadic = FromEPI.Variadic;
574  ToEPI.HasTrailingReturn = FromEPI.HasTrailingReturn;
575  ToEPI.TypeQuals = FromEPI.TypeQuals;
576  ToEPI.RefQualifier = FromEPI.RefQualifier;
577  ToEPI.ExceptionSpec.Type = FromEPI.ExceptionSpec.Type;
578  ToEPI.ExceptionSpec.Exceptions = ExceptionTypes;
580  Importer.Import(FromEPI.ExceptionSpec.NoexceptExpr);
581  ToEPI.ExceptionSpec.SourceDecl = cast_or_null<FunctionDecl>(
582  Importer.Import(FromEPI.ExceptionSpec.SourceDecl));
583  ToEPI.ExceptionSpec.SourceTemplate = cast_or_null<FunctionDecl>(
584  Importer.Import(FromEPI.ExceptionSpec.SourceTemplate));
585 
586  return Importer.getToContext().getFunctionType(ToResultType, ArgTypes, ToEPI);
587 }
588 
590  const UnresolvedUsingType *T) {
591  UnresolvedUsingTypenameDecl *ToD = cast_or_null<UnresolvedUsingTypenameDecl>(
592  Importer.Import(T->getDecl()));
593  if (!ToD)
594  return QualType();
595 
596  UnresolvedUsingTypenameDecl *ToPrevD =
597  cast_or_null<UnresolvedUsingTypenameDecl>(
598  Importer.Import(T->getDecl()->getPreviousDecl()));
599  if (!ToPrevD && T->getDecl()->getPreviousDecl())
600  return QualType();
601 
602  return Importer.getToContext().getTypeDeclType(ToD, ToPrevD);
603 }
604 
606  QualType ToInnerType = Importer.Import(T->getInnerType());
607  if (ToInnerType.isNull())
608  return QualType();
609 
610  return Importer.getToContext().getParenType(ToInnerType);
611 }
612 
614  TypedefNameDecl *ToDecl
615  = dyn_cast_or_null<TypedefNameDecl>(Importer.Import(T->getDecl()));
616  if (!ToDecl)
617  return QualType();
618 
619  return Importer.getToContext().getTypeDeclType(ToDecl);
620 }
621 
623  Expr *ToExpr = Importer.Import(T->getUnderlyingExpr());
624  if (!ToExpr)
625  return QualType();
626 
627  return Importer.getToContext().getTypeOfExprType(ToExpr);
628 }
629 
631  QualType ToUnderlyingType = Importer.Import(T->getUnderlyingType());
632  if (ToUnderlyingType.isNull())
633  return QualType();
634 
635  return Importer.getToContext().getTypeOfType(ToUnderlyingType);
636 }
637 
639  // FIXME: Make sure that the "to" context supports C++0x!
640  Expr *ToExpr = Importer.Import(T->getUnderlyingExpr());
641  if (!ToExpr)
642  return QualType();
643 
644  QualType UnderlyingType = Importer.Import(T->getUnderlyingType());
645  if (UnderlyingType.isNull())
646  return QualType();
647 
648  return Importer.getToContext().getDecltypeType(ToExpr, UnderlyingType);
649 }
650 
652  QualType ToBaseType = Importer.Import(T->getBaseType());
653  QualType ToUnderlyingType = Importer.Import(T->getUnderlyingType());
654  if (ToBaseType.isNull() || ToUnderlyingType.isNull())
655  return QualType();
656 
657  return Importer.getToContext().getUnaryTransformType(ToBaseType,
658  ToUnderlyingType,
659  T->getUTTKind());
660 }
661 
663  // FIXME: Make sure that the "to" context supports C++11!
664  QualType FromDeduced = T->getDeducedType();
665  QualType ToDeduced;
666  if (!FromDeduced.isNull()) {
667  ToDeduced = Importer.Import(FromDeduced);
668  if (ToDeduced.isNull())
669  return QualType();
670  }
671 
672  return Importer.getToContext().getAutoType(ToDeduced, T->getKeyword(),
673  /*IsDependent*/false);
674 }
675 
677  const InjectedClassNameType *T) {
678  CXXRecordDecl *D = cast_or_null<CXXRecordDecl>(Importer.Import(T->getDecl()));
679  if (!D)
680  return QualType();
681 
682  QualType InjType = Importer.Import(T->getInjectedSpecializationType());
683  if (InjType.isNull())
684  return QualType();
685 
686  // FIXME: ASTContext::getInjectedClassNameType is not suitable for AST reading
687  // See comments in InjectedClassNameType definition for details
688  // return Importer.getToContext().getInjectedClassNameType(D, InjType);
689  enum {
692  };
693 
694  return QualType(new (Importer.getToContext(), TypeAlignment)
695  InjectedClassNameType(D, InjType), 0);
696 }
697 
699  RecordDecl *ToDecl
700  = dyn_cast_or_null<RecordDecl>(Importer.Import(T->getDecl()));
701  if (!ToDecl)
702  return QualType();
703 
704  return Importer.getToContext().getTagDeclType(ToDecl);
705 }
706 
708  EnumDecl *ToDecl
709  = dyn_cast_or_null<EnumDecl>(Importer.Import(T->getDecl()));
710  if (!ToDecl)
711  return QualType();
712 
713  return Importer.getToContext().getTagDeclType(ToDecl);
714 }
715 
717  QualType FromModifiedType = T->getModifiedType();
718  QualType FromEquivalentType = T->getEquivalentType();
719  QualType ToModifiedType;
720  QualType ToEquivalentType;
721 
722  if (!FromModifiedType.isNull()) {
723  ToModifiedType = Importer.Import(FromModifiedType);
724  if (ToModifiedType.isNull())
725  return QualType();
726  }
727  if (!FromEquivalentType.isNull()) {
728  ToEquivalentType = Importer.Import(FromEquivalentType);
729  if (ToEquivalentType.isNull())
730  return QualType();
731  }
732 
733  return Importer.getToContext().getAttributedType(T->getAttrKind(),
734  ToModifiedType, ToEquivalentType);
735 }
736 
737 
739  const TemplateTypeParmType *T) {
740  TemplateTypeParmDecl *ParmDecl =
741  cast_or_null<TemplateTypeParmDecl>(Importer.Import(T->getDecl()));
742  if (!ParmDecl && T->getDecl())
743  return QualType();
744 
745  return Importer.getToContext().getTemplateTypeParmType(
746  T->getDepth(), T->getIndex(), T->isParameterPack(), ParmDecl);
747 }
748 
750  const SubstTemplateTypeParmType *T) {
751  const TemplateTypeParmType *Replaced =
752  cast_or_null<TemplateTypeParmType>(Importer.Import(
753  QualType(T->getReplacedParameter(), 0)).getTypePtr());
754  if (!Replaced)
755  return QualType();
756 
757  QualType Replacement = Importer.Import(T->getReplacementType());
758  if (Replacement.isNull())
759  return QualType();
760  Replacement = Replacement.getCanonicalType();
761 
762  return Importer.getToContext().getSubstTemplateTypeParmType(
763  Replaced, Replacement);
764 }
765 
767  const TemplateSpecializationType *T) {
768  TemplateName ToTemplate = Importer.Import(T->getTemplateName());
769  if (ToTemplate.isNull())
770  return QualType();
771 
772  SmallVector<TemplateArgument, 2> ToTemplateArgs;
773  if (ImportTemplateArguments(T->getArgs(), T->getNumArgs(), ToTemplateArgs))
774  return QualType();
775 
776  QualType ToCanonType;
777  if (!QualType(T, 0).isCanonical()) {
778  QualType FromCanonType
779  = Importer.getFromContext().getCanonicalType(QualType(T, 0));
780  ToCanonType =Importer.Import(FromCanonType);
781  if (ToCanonType.isNull())
782  return QualType();
783  }
784  return Importer.getToContext().getTemplateSpecializationType(ToTemplate,
785  ToTemplateArgs,
786  ToCanonType);
787 }
788 
790  NestedNameSpecifier *ToQualifier = nullptr;
791  // Note: the qualifier in an ElaboratedType is optional.
792  if (T->getQualifier()) {
793  ToQualifier = Importer.Import(T->getQualifier());
794  if (!ToQualifier)
795  return QualType();
796  }
797 
798  QualType ToNamedType = Importer.Import(T->getNamedType());
799  if (ToNamedType.isNull())
800  return QualType();
801 
802  return Importer.getToContext().getElaboratedType(T->getKeyword(),
803  ToQualifier, ToNamedType);
804 }
805 
807  QualType Pattern = Importer.Import(T->getPattern());
808  if (Pattern.isNull())
809  return QualType();
810 
811  return Importer.getToContext().getPackExpansionType(Pattern,
812  T->getNumExpansions());
813 }
814 
816  ObjCInterfaceDecl *Class
817  = dyn_cast_or_null<ObjCInterfaceDecl>(Importer.Import(T->getDecl()));
818  if (!Class)
819  return QualType();
820 
821  return Importer.getToContext().getObjCInterfaceType(Class);
822 }
823 
825  QualType ToBaseType = Importer.Import(T->getBaseType());
826  if (ToBaseType.isNull())
827  return QualType();
828 
829  SmallVector<QualType, 4> TypeArgs;
830  for (auto TypeArg : T->getTypeArgsAsWritten()) {
831  QualType ImportedTypeArg = Importer.Import(TypeArg);
832  if (ImportedTypeArg.isNull())
833  return QualType();
834 
835  TypeArgs.push_back(ImportedTypeArg);
836  }
837 
839  for (auto *P : T->quals()) {
840  ObjCProtocolDecl *Protocol
841  = dyn_cast_or_null<ObjCProtocolDecl>(Importer.Import(P));
842  if (!Protocol)
843  return QualType();
844  Protocols.push_back(Protocol);
845  }
846 
847  return Importer.getToContext().getObjCObjectType(ToBaseType, TypeArgs,
848  Protocols,
849  T->isKindOfTypeAsWritten());
850 }
851 
852 QualType
854  QualType ToPointeeType = Importer.Import(T->getPointeeType());
855  if (ToPointeeType.isNull())
856  return QualType();
857 
858  return Importer.getToContext().getObjCObjectPointerType(ToPointeeType);
859 }
860 
861 //----------------------------------------------------------------------------
862 // Import Declarations
863 //----------------------------------------------------------------------------
865  DeclContext *&LexicalDC,
866  DeclarationName &Name,
867  NamedDecl *&ToD,
868  SourceLocation &Loc) {
869  // Import the context of this declaration.
870  DC = Importer.ImportContext(D->getDeclContext());
871  if (!DC)
872  return true;
873 
874  LexicalDC = DC;
875  if (D->getDeclContext() != D->getLexicalDeclContext()) {
876  LexicalDC = Importer.ImportContext(D->getLexicalDeclContext());
877  if (!LexicalDC)
878  return true;
879  }
880 
881  // Import the name of this declaration.
882  Name = Importer.Import(D->getDeclName());
883  if (D->getDeclName() && !Name)
884  return true;
885 
886  // Import the location of this declaration.
887  Loc = Importer.Import(D->getLocation());
888  ToD = cast_or_null<NamedDecl>(Importer.GetAlreadyImportedOrNull(D));
889  return false;
890 }
891 
893  if (!FromD)
894  return;
895 
896  if (!ToD) {
897  ToD = Importer.Import(FromD);
898  if (!ToD)
899  return;
900  }
901 
902  if (RecordDecl *FromRecord = dyn_cast<RecordDecl>(FromD)) {
903  if (RecordDecl *ToRecord = cast_or_null<RecordDecl>(ToD)) {
904  if (FromRecord->getDefinition() && FromRecord->isCompleteDefinition() && !ToRecord->getDefinition()) {
905  ImportDefinition(FromRecord, ToRecord);
906  }
907  }
908  return;
909  }
910 
911  if (EnumDecl *FromEnum = dyn_cast<EnumDecl>(FromD)) {
912  if (EnumDecl *ToEnum = cast_or_null<EnumDecl>(ToD)) {
913  if (FromEnum->getDefinition() && !ToEnum->getDefinition()) {
914  ImportDefinition(FromEnum, ToEnum);
915  }
916  }
917  return;
918  }
919 }
920 
921 void
923  DeclarationNameInfo& To) {
924  // NOTE: To.Name and To.Loc are already imported.
925  // We only have to import To.LocInfo.
926  switch (To.getName().getNameKind()) {
933  return;
934 
936  SourceRange Range = From.getCXXOperatorNameRange();
937  To.setCXXOperatorNameRange(Importer.Import(Range));
938  return;
939  }
942  To.setCXXLiteralOperatorNameLoc(Importer.Import(Loc));
943  return;
944  }
948  TypeSourceInfo *FromTInfo = From.getNamedTypeInfo();
949  To.setNamedTypeInfo(Importer.Import(FromTInfo));
950  return;
951  }
952  }
953  llvm_unreachable("Unknown name kind.");
954 }
955 
956 void ASTNodeImporter::ImportDeclContext(DeclContext *FromDC, bool ForceImport) {
957  if (Importer.isMinimalImport() && !ForceImport) {
958  Importer.ImportContext(FromDC);
959  return;
960  }
961 
962  for (auto *From : FromDC->decls())
963  Importer.Import(From);
964 }
965 
968  if (To->getDefinition() || To->isBeingDefined()) {
969  if (Kind == IDK_Everything)
970  ImportDeclContext(From, /*ForceImport=*/true);
971 
972  return false;
973  }
974 
975  To->startDefinition();
976 
977  // Add base classes.
978  if (CXXRecordDecl *ToCXX = dyn_cast<CXXRecordDecl>(To)) {
979  CXXRecordDecl *FromCXX = cast<CXXRecordDecl>(From);
980 
981  struct CXXRecordDecl::DefinitionData &ToData = ToCXX->data();
982  struct CXXRecordDecl::DefinitionData &FromData = FromCXX->data();
983  ToData.UserDeclaredConstructor = FromData.UserDeclaredConstructor;
984  ToData.UserDeclaredSpecialMembers = FromData.UserDeclaredSpecialMembers;
985  ToData.Aggregate = FromData.Aggregate;
986  ToData.PlainOldData = FromData.PlainOldData;
987  ToData.Empty = FromData.Empty;
988  ToData.Polymorphic = FromData.Polymorphic;
989  ToData.Abstract = FromData.Abstract;
990  ToData.IsStandardLayout = FromData.IsStandardLayout;
991  ToData.HasNoNonEmptyBases = FromData.HasNoNonEmptyBases;
992  ToData.HasPrivateFields = FromData.HasPrivateFields;
993  ToData.HasProtectedFields = FromData.HasProtectedFields;
994  ToData.HasPublicFields = FromData.HasPublicFields;
995  ToData.HasMutableFields = FromData.HasMutableFields;
996  ToData.HasVariantMembers = FromData.HasVariantMembers;
997  ToData.HasOnlyCMembers = FromData.HasOnlyCMembers;
998  ToData.HasInClassInitializer = FromData.HasInClassInitializer;
999  ToData.HasUninitializedReferenceMember
1000  = FromData.HasUninitializedReferenceMember;
1001  ToData.HasUninitializedFields = FromData.HasUninitializedFields;
1002  ToData.HasInheritedConstructor = FromData.HasInheritedConstructor;
1003  ToData.HasInheritedAssignment = FromData.HasInheritedAssignment;
1004  ToData.NeedOverloadResolutionForCopyConstructor
1005  = FromData.NeedOverloadResolutionForCopyConstructor;
1006  ToData.NeedOverloadResolutionForMoveConstructor
1007  = FromData.NeedOverloadResolutionForMoveConstructor;
1008  ToData.NeedOverloadResolutionForMoveAssignment
1009  = FromData.NeedOverloadResolutionForMoveAssignment;
1010  ToData.NeedOverloadResolutionForDestructor
1011  = FromData.NeedOverloadResolutionForDestructor;
1012  ToData.DefaultedCopyConstructorIsDeleted
1013  = FromData.DefaultedCopyConstructorIsDeleted;
1014  ToData.DefaultedMoveConstructorIsDeleted
1015  = FromData.DefaultedMoveConstructorIsDeleted;
1016  ToData.DefaultedMoveAssignmentIsDeleted
1017  = FromData.DefaultedMoveAssignmentIsDeleted;
1018  ToData.DefaultedDestructorIsDeleted = FromData.DefaultedDestructorIsDeleted;
1019  ToData.HasTrivialSpecialMembers = FromData.HasTrivialSpecialMembers;
1020  ToData.HasIrrelevantDestructor = FromData.HasIrrelevantDestructor;
1021  ToData.HasConstexprNonCopyMoveConstructor
1022  = FromData.HasConstexprNonCopyMoveConstructor;
1023  ToData.HasDefaultedDefaultConstructor
1024  = FromData.HasDefaultedDefaultConstructor;
1025  ToData.CanPassInRegisters = FromData.CanPassInRegisters;
1026  ToData.DefaultedDefaultConstructorIsConstexpr
1027  = FromData.DefaultedDefaultConstructorIsConstexpr;
1028  ToData.HasConstexprDefaultConstructor
1029  = FromData.HasConstexprDefaultConstructor;
1030  ToData.HasNonLiteralTypeFieldsOrBases
1031  = FromData.HasNonLiteralTypeFieldsOrBases;
1032  // ComputedVisibleConversions not imported.
1033  ToData.UserProvidedDefaultConstructor
1034  = FromData.UserProvidedDefaultConstructor;
1035  ToData.DeclaredSpecialMembers = FromData.DeclaredSpecialMembers;
1036  ToData.ImplicitCopyConstructorCanHaveConstParamForVBase
1037  = FromData.ImplicitCopyConstructorCanHaveConstParamForVBase;
1038  ToData.ImplicitCopyConstructorCanHaveConstParamForNonVBase
1039  = FromData.ImplicitCopyConstructorCanHaveConstParamForNonVBase;
1040  ToData.ImplicitCopyAssignmentHasConstParam
1041  = FromData.ImplicitCopyAssignmentHasConstParam;
1042  ToData.HasDeclaredCopyConstructorWithConstParam
1043  = FromData.HasDeclaredCopyConstructorWithConstParam;
1044  ToData.HasDeclaredCopyAssignmentWithConstParam
1045  = FromData.HasDeclaredCopyAssignmentWithConstParam;
1046  ToData.IsLambda = FromData.IsLambda;
1047 
1049  for (const auto &Base1 : FromCXX->bases()) {
1050  QualType T = Importer.Import(Base1.getType());
1051  if (T.isNull())
1052  return true;
1053 
1054  SourceLocation EllipsisLoc;
1055  if (Base1.isPackExpansion())
1056  EllipsisLoc = Importer.Import(Base1.getEllipsisLoc());
1057 
1058  // Ensure that we have a definition for the base.
1059  ImportDefinitionIfNeeded(Base1.getType()->getAsCXXRecordDecl());
1060 
1061  Bases.push_back(
1062  new (Importer.getToContext())
1063  CXXBaseSpecifier(Importer.Import(Base1.getSourceRange()),
1064  Base1.isVirtual(),
1065  Base1.isBaseOfClass(),
1066  Base1.getAccessSpecifierAsWritten(),
1067  Importer.Import(Base1.getTypeSourceInfo()),
1068  EllipsisLoc));
1069  }
1070  if (!Bases.empty())
1071  ToCXX->setBases(Bases.data(), Bases.size());
1072  }
1073 
1074  if (shouldForceImportDeclContext(Kind))
1075  ImportDeclContext(From, /*ForceImport=*/true);
1076 
1077  To->completeDefinition();
1078  return false;
1079 }
1080 
1083  if (To->getAnyInitializer())
1084  return false;
1085 
1086  // FIXME: Can we really import any initializer? Alternatively, we could force
1087  // ourselves to import every declaration of a variable and then only use
1088  // getInit() here.
1089  To->setInit(Importer.Import(const_cast<Expr *>(From->getAnyInitializer())));
1090 
1091  // FIXME: Other bits to merge?
1092 
1093  return false;
1094 }
1095 
1098  if (To->getDefinition() || To->isBeingDefined()) {
1099  if (Kind == IDK_Everything)
1100  ImportDeclContext(From, /*ForceImport=*/true);
1101  return false;
1102  }
1103 
1104  To->startDefinition();
1105 
1106  QualType T = Importer.Import(Importer.getFromContext().getTypeDeclType(From));
1107  if (T.isNull())
1108  return true;
1109 
1110  QualType ToPromotionType = Importer.Import(From->getPromotionType());
1111  if (ToPromotionType.isNull())
1112  return true;
1113 
1114  if (shouldForceImportDeclContext(Kind))
1115  ImportDeclContext(From, /*ForceImport=*/true);
1116 
1117  // FIXME: we might need to merge the number of positive or negative bits
1118  // if the enumerator lists don't match.
1119  To->completeDefinition(T, ToPromotionType,
1120  From->getNumPositiveBits(),
1121  From->getNumNegativeBits());
1122  return false;
1123 }
1124 
1126  TemplateParameterList *Params) {
1127  SmallVector<NamedDecl *, 4> ToParams(Params->size());
1128  if (ImportContainerChecked(*Params, ToParams))
1129  return nullptr;
1130 
1131  Expr *ToRequiresClause;
1132  if (Expr *const R = Params->getRequiresClause()) {
1133  ToRequiresClause = Importer.Import(R);
1134  if (!ToRequiresClause)
1135  return nullptr;
1136  } else {
1137  ToRequiresClause = nullptr;
1138  }
1139 
1140  return TemplateParameterList::Create(Importer.getToContext(),
1141  Importer.Import(Params->getTemplateLoc()),
1142  Importer.Import(Params->getLAngleLoc()),
1143  ToParams,
1144  Importer.Import(Params->getRAngleLoc()),
1145  ToRequiresClause);
1146 }
1147 
1150  switch (From.getKind()) {
1152  return TemplateArgument();
1153 
1154  case TemplateArgument::Type: {
1155  QualType ToType = Importer.Import(From.getAsType());
1156  if (ToType.isNull())
1157  return TemplateArgument();
1158  return TemplateArgument(ToType);
1159  }
1160 
1162  QualType ToType = Importer.Import(From.getIntegralType());
1163  if (ToType.isNull())
1164  return TemplateArgument();
1165  return TemplateArgument(From, ToType);
1166  }
1167 
1169  ValueDecl *To = cast_or_null<ValueDecl>(Importer.Import(From.getAsDecl()));
1170  QualType ToType = Importer.Import(From.getParamTypeForDecl());
1171  if (!To || ToType.isNull())
1172  return TemplateArgument();
1173  return TemplateArgument(To, ToType);
1174  }
1175 
1177  QualType ToType = Importer.Import(From.getNullPtrType());
1178  if (ToType.isNull())
1179  return TemplateArgument();
1180  return TemplateArgument(ToType, /*isNullPtr*/true);
1181  }
1182 
1184  TemplateName ToTemplate = Importer.Import(From.getAsTemplate());
1185  if (ToTemplate.isNull())
1186  return TemplateArgument();
1187 
1188  return TemplateArgument(ToTemplate);
1189  }
1190 
1192  TemplateName ToTemplate
1193  = Importer.Import(From.getAsTemplateOrTemplatePattern());
1194  if (ToTemplate.isNull())
1195  return TemplateArgument();
1196 
1197  return TemplateArgument(ToTemplate, From.getNumTemplateExpansions());
1198  }
1199 
1201  if (Expr *ToExpr = Importer.Import(From.getAsExpr()))
1202  return TemplateArgument(ToExpr);
1203  return TemplateArgument();
1204 
1205  case TemplateArgument::Pack: {
1207  ToPack.reserve(From.pack_size());
1208  if (ImportTemplateArguments(From.pack_begin(), From.pack_size(), ToPack))
1209  return TemplateArgument();
1210 
1211  return TemplateArgument(
1212  llvm::makeArrayRef(ToPack).copy(Importer.getToContext()));
1213  }
1214  }
1215 
1216  llvm_unreachable("Invalid template argument kind");
1217 }
1218 
1222  TemplateArgumentLocInfo FromInfo = TALoc.getLocInfo();
1223  TemplateArgumentLocInfo ToInfo;
1224  if (Arg.getKind() == TemplateArgument::Expression) {
1225  Expr *E = Importer.Import(FromInfo.getAsExpr());
1226  ToInfo = TemplateArgumentLocInfo(E);
1227  if (!E)
1228  return None;
1229  } else if (Arg.getKind() == TemplateArgument::Type) {
1230  if (TypeSourceInfo *TSI = Importer.Import(FromInfo.getAsTypeSourceInfo()))
1231  ToInfo = TemplateArgumentLocInfo(TSI);
1232  else
1233  return None;
1234  } else {
1235  ToInfo = TemplateArgumentLocInfo(
1236  Importer.Import(FromInfo.getTemplateQualifierLoc()),
1237  Importer.Import(FromInfo.getTemplateNameLoc()),
1238  Importer.Import(FromInfo.getTemplateEllipsisLoc()));
1239  }
1240  return TemplateArgumentLoc(Arg, ToInfo);
1241 }
1242 
1244  unsigned NumFromArgs,
1246  for (unsigned I = 0; I != NumFromArgs; ++I) {
1247  TemplateArgument To = ImportTemplateArgument(FromArgs[I]);
1248  if (To.isNull() && !FromArgs[I].isNull())
1249  return true;
1250 
1251  ToArgs.push_back(To);
1252  }
1253 
1254  return false;
1255 }
1256 
1257 template <typename InContainerTy>
1259  const InContainerTy &Container, TemplateArgumentListInfo &ToTAInfo) {
1260  for (const auto &FromLoc : Container) {
1261  if (auto ToLoc = ImportTemplateArgumentLoc(FromLoc))
1262  ToTAInfo.addArgument(*ToLoc);
1263  else
1264  return true;
1265  }
1266  return false;
1267 }
1268 
1270  RecordDecl *ToRecord, bool Complain) {
1271  // Eliminate a potential failure point where we attempt to re-import
1272  // something we're trying to import while completing ToRecord.
1273  Decl *ToOrigin = Importer.GetOriginalDecl(ToRecord);
1274  if (ToOrigin) {
1275  RecordDecl *ToOriginRecord = dyn_cast<RecordDecl>(ToOrigin);
1276  if (ToOriginRecord)
1277  ToRecord = ToOriginRecord;
1278  }
1279 
1280  StructuralEquivalenceContext Ctx(Importer.getFromContext(),
1281  ToRecord->getASTContext(),
1282  Importer.getNonEquivalentDecls(),
1283  false, Complain);
1284  return Ctx.IsStructurallyEquivalent(FromRecord, ToRecord);
1285 }
1286 
1288  bool Complain) {
1290  Importer.getFromContext(), Importer.getToContext(),
1291  Importer.getNonEquivalentDecls(), false, Complain);
1292  return Ctx.IsStructurallyEquivalent(FromVar, ToVar);
1293 }
1294 
1296  StructuralEquivalenceContext Ctx(Importer.getFromContext(),
1297  Importer.getToContext(),
1298  Importer.getNonEquivalentDecls());
1299  return Ctx.IsStructurallyEquivalent(FromEnum, ToEnum);
1300 }
1301 
1303  FunctionTemplateDecl *To) {
1305  Importer.getFromContext(), Importer.getToContext(),
1306  Importer.getNonEquivalentDecls(), false, false);
1307  return Ctx.IsStructurallyEquivalent(From, To);
1308 }
1309 
1311  EnumConstantDecl *ToEC)
1312 {
1313  const llvm::APSInt &FromVal = FromEC->getInitVal();
1314  const llvm::APSInt &ToVal = ToEC->getInitVal();
1315 
1316  return FromVal.isSigned() == ToVal.isSigned() &&
1317  FromVal.getBitWidth() == ToVal.getBitWidth() &&
1318  FromVal == ToVal;
1319 }
1320 
1322  ClassTemplateDecl *To) {
1323  StructuralEquivalenceContext Ctx(Importer.getFromContext(),
1324  Importer.getToContext(),
1325  Importer.getNonEquivalentDecls());
1326  return Ctx.IsStructurallyEquivalent(From, To);
1327 }
1328 
1330  VarTemplateDecl *To) {
1331  StructuralEquivalenceContext Ctx(Importer.getFromContext(),
1332  Importer.getToContext(),
1333  Importer.getNonEquivalentDecls());
1334  return Ctx.IsStructurallyEquivalent(From, To);
1335 }
1336 
1338  Importer.FromDiag(D->getLocation(), diag::err_unsupported_ast_node)
1339  << D->getDeclKindName();
1340  return nullptr;
1341 }
1342 
1344  // Import the context of this declaration.
1345  DeclContext *DC = Importer.ImportContext(D->getDeclContext());
1346  if (!DC)
1347  return nullptr;
1348 
1349  DeclContext *LexicalDC = DC;
1350  if (D->getDeclContext() != D->getLexicalDeclContext()) {
1351  LexicalDC = Importer.ImportContext(D->getLexicalDeclContext());
1352  if (!LexicalDC)
1353  return nullptr;
1354  }
1355 
1356  // Import the location of this declaration.
1357  SourceLocation Loc = Importer.Import(D->getLocation());
1358 
1359  EmptyDecl *ToD = EmptyDecl::Create(Importer.getToContext(), DC, Loc);
1360  ToD->setLexicalDeclContext(LexicalDC);
1361  Importer.Imported(D, ToD);
1362  LexicalDC->addDeclInternal(ToD);
1363  return ToD;
1364 }
1365 
1367  TranslationUnitDecl *ToD =
1368  Importer.getToContext().getTranslationUnitDecl();
1369 
1370  Importer.Imported(D, ToD);
1371 
1372  return ToD;
1373 }
1374 
1376 
1377  SourceLocation Loc = Importer.Import(D->getLocation());
1378  SourceLocation ColonLoc = Importer.Import(D->getColonLoc());
1379 
1380  // Import the context of this declaration.
1381  DeclContext *DC = Importer.ImportContext(D->getDeclContext());
1382  if (!DC)
1383  return nullptr;
1384 
1386  = AccessSpecDecl::Create(Importer.getToContext(), D->getAccess(),
1387  DC, Loc, ColonLoc);
1388 
1389  if (!accessSpecDecl)
1390  return nullptr;
1391 
1392  // Lexical DeclContext and Semantic DeclContext
1393  // is always the same for the accessSpec.
1394  accessSpecDecl->setLexicalDeclContext(DC);
1395  DC->addDeclInternal(accessSpecDecl);
1396 
1397  return accessSpecDecl;
1398 }
1399 
1401  DeclContext *DC = Importer.ImportContext(D->getDeclContext());
1402  if (!DC)
1403  return nullptr;
1404 
1405  DeclContext *LexicalDC = DC;
1406 
1407  // Import the location of this declaration.
1408  SourceLocation Loc = Importer.Import(D->getLocation());
1409 
1410  Expr *AssertExpr = Importer.Import(D->getAssertExpr());
1411  if (!AssertExpr)
1412  return nullptr;
1413 
1414  StringLiteral *FromMsg = D->getMessage();
1415  StringLiteral *ToMsg = cast_or_null<StringLiteral>(Importer.Import(FromMsg));
1416  if (!ToMsg && FromMsg)
1417  return nullptr;
1418 
1420  Importer.getToContext(), DC, Loc, AssertExpr, ToMsg,
1421  Importer.Import(D->getRParenLoc()), D->isFailed());
1422 
1423  ToD->setLexicalDeclContext(LexicalDC);
1424  LexicalDC->addDeclInternal(ToD);
1425  Importer.Imported(D, ToD);
1426  return ToD;
1427 }
1428 
1430  // Import the major distinguishing characteristics of this namespace.
1431  DeclContext *DC, *LexicalDC;
1432  DeclarationName Name;
1433  SourceLocation Loc;
1434  NamedDecl *ToD;
1435  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
1436  return nullptr;
1437  if (ToD)
1438  return ToD;
1439 
1440  NamespaceDecl *MergeWithNamespace = nullptr;
1441  if (!Name) {
1442  // This is an anonymous namespace. Adopt an existing anonymous
1443  // namespace if we can.
1444  // FIXME: Not testable.
1445  if (TranslationUnitDecl *TU = dyn_cast<TranslationUnitDecl>(DC))
1446  MergeWithNamespace = TU->getAnonymousNamespace();
1447  else
1448  MergeWithNamespace = cast<NamespaceDecl>(DC)->getAnonymousNamespace();
1449  } else {
1450  SmallVector<NamedDecl *, 4> ConflictingDecls;
1451  SmallVector<NamedDecl *, 2> FoundDecls;
1452  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
1453  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
1454  if (!FoundDecls[I]->isInIdentifierNamespace(Decl::IDNS_Namespace))
1455  continue;
1456 
1457  if (NamespaceDecl *FoundNS = dyn_cast<NamespaceDecl>(FoundDecls[I])) {
1458  MergeWithNamespace = FoundNS;
1459  ConflictingDecls.clear();
1460  break;
1461  }
1462 
1463  ConflictingDecls.push_back(FoundDecls[I]);
1464  }
1465 
1466  if (!ConflictingDecls.empty()) {
1467  Name = Importer.HandleNameConflict(Name, DC, Decl::IDNS_Namespace,
1468  ConflictingDecls.data(),
1469  ConflictingDecls.size());
1470  }
1471  }
1472 
1473  // Create the "to" namespace, if needed.
1474  NamespaceDecl *ToNamespace = MergeWithNamespace;
1475  if (!ToNamespace) {
1476  ToNamespace = NamespaceDecl::Create(Importer.getToContext(), DC,
1477  D->isInline(),
1478  Importer.Import(D->getLocStart()),
1479  Loc, Name.getAsIdentifierInfo(),
1480  /*PrevDecl=*/nullptr);
1481  ToNamespace->setLexicalDeclContext(LexicalDC);
1482  LexicalDC->addDeclInternal(ToNamespace);
1483 
1484  // If this is an anonymous namespace, register it as the anonymous
1485  // namespace within its context.
1486  if (!Name) {
1487  if (TranslationUnitDecl *TU = dyn_cast<TranslationUnitDecl>(DC))
1488  TU->setAnonymousNamespace(ToNamespace);
1489  else
1490  cast<NamespaceDecl>(DC)->setAnonymousNamespace(ToNamespace);
1491  }
1492  }
1493  Importer.Imported(D, ToNamespace);
1494 
1495  ImportDeclContext(D);
1496 
1497  return ToNamespace;
1498 }
1499 
1501  // Import the major distinguishing characteristics of this namespace.
1502  DeclContext *DC, *LexicalDC;
1503  DeclarationName Name;
1504  SourceLocation Loc;
1505  NamedDecl *LookupD;
1506  if (ImportDeclParts(D, DC, LexicalDC, Name, LookupD, Loc))
1507  return nullptr;
1508  if (LookupD)
1509  return LookupD;
1510 
1511  // NOTE: No conflict resolution is done for namespace aliases now.
1512 
1513  NamespaceDecl *TargetDecl = cast_or_null<NamespaceDecl>(
1514  Importer.Import(D->getNamespace()));
1515  if (!TargetDecl)
1516  return nullptr;
1517 
1518  IdentifierInfo *ToII = Importer.Import(D->getIdentifier());
1519  if (!ToII)
1520  return nullptr;
1521 
1522  NestedNameSpecifierLoc ToQLoc = Importer.Import(D->getQualifierLoc());
1523  if (D->getQualifierLoc() && !ToQLoc)
1524  return nullptr;
1525 
1527  Importer.getToContext(), DC, Importer.Import(D->getNamespaceLoc()),
1528  Importer.Import(D->getAliasLoc()), ToII, ToQLoc,
1529  Importer.Import(D->getTargetNameLoc()), TargetDecl);
1530 
1531  ToD->setLexicalDeclContext(LexicalDC);
1532  Importer.Imported(D, ToD);
1533  LexicalDC->addDeclInternal(ToD);
1534 
1535  return ToD;
1536 }
1537 
1539  // Import the major distinguishing characteristics of this typedef.
1540  DeclContext *DC, *LexicalDC;
1541  DeclarationName Name;
1542  SourceLocation Loc;
1543  NamedDecl *ToD;
1544  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
1545  return nullptr;
1546  if (ToD)
1547  return ToD;
1548 
1549  // If this typedef is not in block scope, determine whether we've
1550  // seen a typedef with the same name (that we can merge with) or any
1551  // other entity by that name (which name lookup could conflict with).
1552  if (!DC->isFunctionOrMethod()) {
1553  SmallVector<NamedDecl *, 4> ConflictingDecls;
1554  unsigned IDNS = Decl::IDNS_Ordinary;
1555  SmallVector<NamedDecl *, 2> FoundDecls;
1556  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
1557  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
1558  if (!FoundDecls[I]->isInIdentifierNamespace(IDNS))
1559  continue;
1560  if (TypedefNameDecl *FoundTypedef =
1561  dyn_cast<TypedefNameDecl>(FoundDecls[I])) {
1562  if (Importer.IsStructurallyEquivalent(D->getUnderlyingType(),
1563  FoundTypedef->getUnderlyingType()))
1564  return Importer.Imported(D, FoundTypedef);
1565  }
1566 
1567  ConflictingDecls.push_back(FoundDecls[I]);
1568  }
1569 
1570  if (!ConflictingDecls.empty()) {
1571  Name = Importer.HandleNameConflict(Name, DC, IDNS,
1572  ConflictingDecls.data(),
1573  ConflictingDecls.size());
1574  if (!Name)
1575  return nullptr;
1576  }
1577  }
1578 
1579  // Import the underlying type of this typedef;
1580  QualType T = Importer.Import(D->getUnderlyingType());
1581  if (T.isNull())
1582  return nullptr;
1583 
1584  // Create the new typedef node.
1585  TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo());
1586  SourceLocation StartL = Importer.Import(D->getLocStart());
1587  TypedefNameDecl *ToTypedef;
1588  if (IsAlias)
1589  ToTypedef = TypeAliasDecl::Create(Importer.getToContext(), DC,
1590  StartL, Loc,
1591  Name.getAsIdentifierInfo(),
1592  TInfo);
1593  else
1594  ToTypedef = TypedefDecl::Create(Importer.getToContext(), DC,
1595  StartL, Loc,
1596  Name.getAsIdentifierInfo(),
1597  TInfo);
1598 
1599  ToTypedef->setAccess(D->getAccess());
1600  ToTypedef->setLexicalDeclContext(LexicalDC);
1601  Importer.Imported(D, ToTypedef);
1602  LexicalDC->addDeclInternal(ToTypedef);
1603 
1604  return ToTypedef;
1605 }
1606 
1608  return VisitTypedefNameDecl(D, /*IsAlias=*/false);
1609 }
1610 
1612  return VisitTypedefNameDecl(D, /*IsAlias=*/true);
1613 }
1614 
1616  // Import the major distinguishing characteristics of this typedef.
1617  DeclContext *DC, *LexicalDC;
1618  DeclarationName Name;
1619  SourceLocation Loc;
1620  NamedDecl *ToD;
1621  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
1622  return nullptr;
1623  if (ToD)
1624  return ToD;
1625 
1626  // If this typedef is not in block scope, determine whether we've
1627  // seen a typedef with the same name (that we can merge with) or any
1628  // other entity by that name (which name lookup could conflict with).
1629  if (!DC->isFunctionOrMethod()) {
1630  SmallVector<NamedDecl *, 4> ConflictingDecls;
1631  unsigned IDNS = Decl::IDNS_Ordinary;
1632  SmallVector<NamedDecl *, 2> FoundDecls;
1633  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
1634  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
1635  if (!FoundDecls[I]->isInIdentifierNamespace(IDNS))
1636  continue;
1637  if (auto *FoundAlias =
1638  dyn_cast<TypeAliasTemplateDecl>(FoundDecls[I]))
1639  return Importer.Imported(D, FoundAlias);
1640  ConflictingDecls.push_back(FoundDecls[I]);
1641  }
1642 
1643  if (!ConflictingDecls.empty()) {
1644  Name = Importer.HandleNameConflict(Name, DC, IDNS,
1645  ConflictingDecls.data(),
1646  ConflictingDecls.size());
1647  if (!Name)
1648  return nullptr;
1649  }
1650  }
1651 
1653  D->getTemplateParameters());
1654  if (!Params)
1655  return nullptr;
1656 
1657  NamedDecl *TemplDecl = cast_or_null<NamedDecl>(
1658  Importer.Import(D->getTemplatedDecl()));
1659  if (!TemplDecl)
1660  return nullptr;
1661 
1663  Importer.getToContext(), DC, Loc, Name, Params, TemplDecl);
1664 
1665  ToAlias->setAccess(D->getAccess());
1666  ToAlias->setLexicalDeclContext(LexicalDC);
1667  Importer.Imported(D, ToAlias);
1668  LexicalDC->addDeclInternal(ToAlias);
1669  return ToD;
1670 }
1671 
1673  // Import the major distinguishing characteristics of this label.
1674  DeclContext *DC, *LexicalDC;
1675  DeclarationName Name;
1676  SourceLocation Loc;
1677  NamedDecl *ToD;
1678  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
1679  return nullptr;
1680  if (ToD)
1681  return ToD;
1682 
1683  assert(LexicalDC->isFunctionOrMethod());
1684 
1685  LabelDecl *ToLabel = D->isGnuLocal()
1686  ? LabelDecl::Create(Importer.getToContext(),
1687  DC, Importer.Import(D->getLocation()),
1688  Name.getAsIdentifierInfo(),
1689  Importer.Import(D->getLocStart()))
1690  : LabelDecl::Create(Importer.getToContext(),
1691  DC, Importer.Import(D->getLocation()),
1692  Name.getAsIdentifierInfo());
1693  Importer.Imported(D, ToLabel);
1694 
1695  LabelStmt *Label = cast_or_null<LabelStmt>(Importer.Import(D->getStmt()));
1696  if (!Label)
1697  return nullptr;
1698 
1699  ToLabel->setStmt(Label);
1700  ToLabel->setLexicalDeclContext(LexicalDC);
1701  LexicalDC->addDeclInternal(ToLabel);
1702  return ToLabel;
1703 }
1704 
1706  // Import the major distinguishing characteristics of this enum.
1707  DeclContext *DC, *LexicalDC;
1708  DeclarationName Name;
1709  SourceLocation Loc;
1710  NamedDecl *ToD;
1711  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
1712  return nullptr;
1713  if (ToD)
1714  return ToD;
1715 
1716  // Figure out what enum name we're looking for.
1717  unsigned IDNS = Decl::IDNS_Tag;
1718  DeclarationName SearchName = Name;
1719  if (!SearchName && D->getTypedefNameForAnonDecl()) {
1720  SearchName = Importer.Import(D->getTypedefNameForAnonDecl()->getDeclName());
1721  IDNS = Decl::IDNS_Ordinary;
1722  } else if (Importer.getToContext().getLangOpts().CPlusPlus)
1723  IDNS |= Decl::IDNS_Ordinary;
1724 
1725  // We may already have an enum of the same name; try to find and match it.
1726  if (!DC->isFunctionOrMethod() && SearchName) {
1727  SmallVector<NamedDecl *, 4> ConflictingDecls;
1728  SmallVector<NamedDecl *, 2> FoundDecls;
1729  DC->getRedeclContext()->localUncachedLookup(SearchName, FoundDecls);
1730  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
1731  if (!FoundDecls[I]->isInIdentifierNamespace(IDNS))
1732  continue;
1733 
1734  Decl *Found = FoundDecls[I];
1735  if (TypedefNameDecl *Typedef = dyn_cast<TypedefNameDecl>(Found)) {
1736  if (const TagType *Tag = Typedef->getUnderlyingType()->getAs<TagType>())
1737  Found = Tag->getDecl();
1738  }
1739 
1740  if (EnumDecl *FoundEnum = dyn_cast<EnumDecl>(Found)) {
1741  if (IsStructuralMatch(D, FoundEnum))
1742  return Importer.Imported(D, FoundEnum);
1743  }
1744 
1745  ConflictingDecls.push_back(FoundDecls[I]);
1746  }
1747 
1748  if (!ConflictingDecls.empty()) {
1749  Name = Importer.HandleNameConflict(Name, DC, IDNS,
1750  ConflictingDecls.data(),
1751  ConflictingDecls.size());
1752  }
1753  }
1754 
1755  // Create the enum declaration.
1756  EnumDecl *D2 = EnumDecl::Create(Importer.getToContext(), DC,
1757  Importer.Import(D->getLocStart()),
1758  Loc, Name.getAsIdentifierInfo(), nullptr,
1759  D->isScoped(), D->isScopedUsingClassTag(),
1760  D->isFixed());
1761  // Import the qualifier, if any.
1762  D2->setQualifierInfo(Importer.Import(D->getQualifierLoc()));
1763  D2->setAccess(D->getAccess());
1764  D2->setLexicalDeclContext(LexicalDC);
1765  Importer.Imported(D, D2);
1766  LexicalDC->addDeclInternal(D2);
1767 
1768  // Import the integer type.
1769  QualType ToIntegerType = Importer.Import(D->getIntegerType());
1770  if (ToIntegerType.isNull())
1771  return nullptr;
1772  D2->setIntegerType(ToIntegerType);
1773 
1774  // Import the definition
1775  if (D->isCompleteDefinition() && ImportDefinition(D, D2))
1776  return nullptr;
1777 
1778  return D2;
1779 }
1780 
1782  // If this record has a definition in the translation unit we're coming from,
1783  // but this particular declaration is not that definition, import the
1784  // definition and map to that.
1785  TagDecl *Definition = D->getDefinition();
1786  if (Definition && Definition != D) {
1787  Decl *ImportedDef = Importer.Import(Definition);
1788  if (!ImportedDef)
1789  return nullptr;
1790 
1791  return Importer.Imported(D, ImportedDef);
1792  }
1793 
1794  // Import the major distinguishing characteristics of this record.
1795  DeclContext *DC, *LexicalDC;
1796  DeclarationName Name;
1797  SourceLocation Loc;
1798  NamedDecl *ToD;
1799  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
1800  return nullptr;
1801  if (ToD)
1802  return ToD;
1803 
1804  // Figure out what structure name we're looking for.
1805  unsigned IDNS = Decl::IDNS_Tag;
1806  DeclarationName SearchName = Name;
1807  if (!SearchName && D->getTypedefNameForAnonDecl()) {
1808  SearchName = Importer.Import(D->getTypedefNameForAnonDecl()->getDeclName());
1809  IDNS = Decl::IDNS_Ordinary;
1810  } else if (Importer.getToContext().getLangOpts().CPlusPlus)
1811  IDNS |= Decl::IDNS_Ordinary;
1812 
1813  // We may already have a record of the same name; try to find and match it.
1814  RecordDecl *AdoptDecl = nullptr;
1815  RecordDecl *PrevDecl = nullptr;
1816  if (!DC->isFunctionOrMethod()) {
1817  SmallVector<NamedDecl *, 4> ConflictingDecls;
1818  SmallVector<NamedDecl *, 2> FoundDecls;
1819  DC->getRedeclContext()->localUncachedLookup(SearchName, FoundDecls);
1820 
1821  if (!FoundDecls.empty()) {
1822  // We're going to have to compare D against potentially conflicting Decls, so complete it.
1825  }
1826 
1827  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
1828  if (!FoundDecls[I]->isInIdentifierNamespace(IDNS))
1829  continue;
1830 
1831  Decl *Found = FoundDecls[I];
1832  if (TypedefNameDecl *Typedef = dyn_cast<TypedefNameDecl>(Found)) {
1833  if (const TagType *Tag = Typedef->getUnderlyingType()->getAs<TagType>())
1834  Found = Tag->getDecl();
1835  }
1836 
1837  if (RecordDecl *FoundRecord = dyn_cast<RecordDecl>(Found)) {
1838  if (D->isAnonymousStructOrUnion() &&
1839  FoundRecord->isAnonymousStructOrUnion()) {
1840  // If both anonymous structs/unions are in a record context, make sure
1841  // they occur in the same location in the context records.
1842  if (Optional<unsigned> Index1 =
1844  D)) {
1846  findUntaggedStructOrUnionIndex(FoundRecord)) {
1847  if (*Index1 != *Index2)
1848  continue;
1849  }
1850  }
1851  }
1852 
1853  PrevDecl = FoundRecord;
1854 
1855  if (RecordDecl *FoundDef = FoundRecord->getDefinition()) {
1856  if ((SearchName && !D->isCompleteDefinition())
1857  || (D->isCompleteDefinition() &&
1859  == FoundDef->isAnonymousStructOrUnion() &&
1860  IsStructuralMatch(D, FoundDef))) {
1861  // The record types structurally match, or the "from" translation
1862  // unit only had a forward declaration anyway; call it the same
1863  // function.
1864  // FIXME: For C++, we should also merge methods here.
1865  return Importer.Imported(D, FoundDef);
1866  }
1867  } else if (!D->isCompleteDefinition()) {
1868  // We have a forward declaration of this type, so adopt that forward
1869  // declaration rather than building a new one.
1870 
1871  // If one or both can be completed from external storage then try one
1872  // last time to complete and compare them before doing this.
1873 
1874  if (FoundRecord->hasExternalLexicalStorage() &&
1875  !FoundRecord->isCompleteDefinition())
1876  FoundRecord->getASTContext().getExternalSource()->CompleteType(FoundRecord);
1877  if (D->hasExternalLexicalStorage())
1879 
1880  if (FoundRecord->isCompleteDefinition() &&
1881  D->isCompleteDefinition() &&
1882  !IsStructuralMatch(D, FoundRecord))
1883  continue;
1884 
1885  AdoptDecl = FoundRecord;
1886  continue;
1887  } else if (!SearchName) {
1888  continue;
1889  }
1890  }
1891 
1892  ConflictingDecls.push_back(FoundDecls[I]);
1893  }
1894 
1895  if (!ConflictingDecls.empty() && SearchName) {
1896  Name = Importer.HandleNameConflict(Name, DC, IDNS,
1897  ConflictingDecls.data(),
1898  ConflictingDecls.size());
1899  }
1900  }
1901 
1902  // Create the record declaration.
1903  RecordDecl *D2 = AdoptDecl;
1904  SourceLocation StartLoc = Importer.Import(D->getLocStart());
1905  if (!D2) {
1906  CXXRecordDecl *D2CXX = nullptr;
1907  if (CXXRecordDecl *DCXX = llvm::dyn_cast<CXXRecordDecl>(D)) {
1908  if (DCXX->isLambda()) {
1909  TypeSourceInfo *TInfo = Importer.Import(DCXX->getLambdaTypeInfo());
1910  D2CXX = CXXRecordDecl::CreateLambda(Importer.getToContext(),
1911  DC, TInfo, Loc,
1912  DCXX->isDependentLambda(),
1913  DCXX->isGenericLambda(),
1914  DCXX->getLambdaCaptureDefault());
1915  Decl *CDecl = Importer.Import(DCXX->getLambdaContextDecl());
1916  if (DCXX->getLambdaContextDecl() && !CDecl)
1917  return nullptr;
1918  D2CXX->setLambdaMangling(DCXX->getLambdaManglingNumber(), CDecl);
1919  } else if (DCXX->isInjectedClassName()) {
1920  // We have to be careful to do a similar dance to the one in
1921  // Sema::ActOnStartCXXMemberDeclarations
1922  CXXRecordDecl *const PrevDecl = nullptr;
1923  const bool DelayTypeCreation = true;
1924  D2CXX = CXXRecordDecl::Create(
1925  Importer.getToContext(), D->getTagKind(), DC, StartLoc, Loc,
1926  Name.getAsIdentifierInfo(), PrevDecl, DelayTypeCreation);
1927  Importer.getToContext().getTypeDeclType(
1928  D2CXX, llvm::dyn_cast<CXXRecordDecl>(DC));
1929  } else {
1930  D2CXX = CXXRecordDecl::Create(Importer.getToContext(),
1931  D->getTagKind(),
1932  DC, StartLoc, Loc,
1933  Name.getAsIdentifierInfo());
1934  }
1935  D2 = D2CXX;
1936  D2->setAccess(D->getAccess());
1937 
1938  Importer.Imported(D, D2);
1939 
1940  if (ClassTemplateDecl *FromDescribed =
1941  DCXX->getDescribedClassTemplate()) {
1942  ClassTemplateDecl *ToDescribed = cast_or_null<ClassTemplateDecl>(
1943  Importer.Import(FromDescribed));
1944  if (!ToDescribed)
1945  return nullptr;
1946  D2CXX->setDescribedClassTemplate(ToDescribed);
1947 
1948  } else if (MemberSpecializationInfo *MemberInfo =
1949  DCXX->getMemberSpecializationInfo()) {
1951  MemberInfo->getTemplateSpecializationKind();
1952  CXXRecordDecl *FromInst = DCXX->getInstantiatedFromMemberClass();
1953  CXXRecordDecl *ToInst =
1954  cast_or_null<CXXRecordDecl>(Importer.Import(FromInst));
1955  if (FromInst && !ToInst)
1956  return nullptr;
1957  D2CXX->setInstantiationOfMemberClass(ToInst, SK);
1959  Importer.Import(MemberInfo->getPointOfInstantiation()));
1960  }
1961 
1962  } else {
1963  D2 = RecordDecl::Create(Importer.getToContext(), D->getTagKind(),
1964  DC, StartLoc, Loc, Name.getAsIdentifierInfo());
1965  }
1966 
1967  D2->setQualifierInfo(Importer.Import(D->getQualifierLoc()));
1968  D2->setLexicalDeclContext(LexicalDC);
1969  LexicalDC->addDeclInternal(D2);
1970  if (D->isAnonymousStructOrUnion())
1971  D2->setAnonymousStructOrUnion(true);
1972  if (PrevDecl) {
1973  // FIXME: do this for all Redeclarables, not just RecordDecls.
1974  D2->setPreviousDecl(PrevDecl);
1975  }
1976  }
1977 
1978  Importer.Imported(D, D2);
1979 
1981  return nullptr;
1982 
1983  return D2;
1984 }
1985 
1987  // Import the major distinguishing characteristics of this enumerator.
1988  DeclContext *DC, *LexicalDC;
1989  DeclarationName Name;
1990  SourceLocation Loc;
1991  NamedDecl *ToD;
1992  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
1993  return nullptr;
1994  if (ToD)
1995  return ToD;
1996 
1997  QualType T = Importer.Import(D->getType());
1998  if (T.isNull())
1999  return nullptr;
2000 
2001  // Determine whether there are any other declarations with the same name and
2002  // in the same context.
2003  if (!LexicalDC->isFunctionOrMethod()) {
2004  SmallVector<NamedDecl *, 4> ConflictingDecls;
2005  unsigned IDNS = Decl::IDNS_Ordinary;
2006  SmallVector<NamedDecl *, 2> FoundDecls;
2007  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
2008  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
2009  if (!FoundDecls[I]->isInIdentifierNamespace(IDNS))
2010  continue;
2011 
2012  if (EnumConstantDecl *FoundEnumConstant
2013  = dyn_cast<EnumConstantDecl>(FoundDecls[I])) {
2014  if (IsStructuralMatch(D, FoundEnumConstant))
2015  return Importer.Imported(D, FoundEnumConstant);
2016  }
2017 
2018  ConflictingDecls.push_back(FoundDecls[I]);
2019  }
2020 
2021  if (!ConflictingDecls.empty()) {
2022  Name = Importer.HandleNameConflict(Name, DC, IDNS,
2023  ConflictingDecls.data(),
2024  ConflictingDecls.size());
2025  if (!Name)
2026  return nullptr;
2027  }
2028  }
2029 
2030  Expr *Init = Importer.Import(D->getInitExpr());
2031  if (D->getInitExpr() && !Init)
2032  return nullptr;
2033 
2034  EnumConstantDecl *ToEnumerator
2035  = EnumConstantDecl::Create(Importer.getToContext(), cast<EnumDecl>(DC), Loc,
2036  Name.getAsIdentifierInfo(), T,
2037  Init, D->getInitVal());
2038  ToEnumerator->setAccess(D->getAccess());
2039  ToEnumerator->setLexicalDeclContext(LexicalDC);
2040  Importer.Imported(D, ToEnumerator);
2041  LexicalDC->addDeclInternal(ToEnumerator);
2042  return ToEnumerator;
2043 }
2044 
2046  // Import the major distinguishing characteristics of this function.
2047  DeclContext *DC, *LexicalDC;
2048  DeclarationName Name;
2049  SourceLocation Loc;
2050  NamedDecl *ToD;
2051  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
2052  return nullptr;
2053  if (ToD)
2054  return ToD;
2055 
2056  const FunctionDecl *FoundWithoutBody = nullptr;
2057 
2058  // Try to find a function in our own ("to") context with the same name, same
2059  // type, and in the same context as the function we're importing.
2060  if (!LexicalDC->isFunctionOrMethod()) {
2061  SmallVector<NamedDecl *, 4> ConflictingDecls;
2062  unsigned IDNS = Decl::IDNS_Ordinary;
2063  SmallVector<NamedDecl *, 2> FoundDecls;
2064  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
2065  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
2066  if (!FoundDecls[I]->isInIdentifierNamespace(IDNS))
2067  continue;
2068 
2069  if (FunctionDecl *FoundFunction = dyn_cast<FunctionDecl>(FoundDecls[I])) {
2070  if (FoundFunction->hasExternalFormalLinkage() &&
2071  D->hasExternalFormalLinkage()) {
2072  if (Importer.IsStructurallyEquivalent(D->getType(),
2073  FoundFunction->getType())) {
2074  // FIXME: Actually try to merge the body and other attributes.
2075  const FunctionDecl *FromBodyDecl = nullptr;
2076  D->hasBody(FromBodyDecl);
2077  if (D == FromBodyDecl && !FoundFunction->hasBody()) {
2078  // This function is needed to merge completely.
2079  FoundWithoutBody = FoundFunction;
2080  break;
2081  }
2082  return Importer.Imported(D, FoundFunction);
2083  }
2084 
2085  // FIXME: Check for overloading more carefully, e.g., by boosting
2086  // Sema::IsOverload out to the AST library.
2087 
2088  // Function overloading is okay in C++.
2089  if (Importer.getToContext().getLangOpts().CPlusPlus)
2090  continue;
2091 
2092  // Complain about inconsistent function types.
2093  Importer.ToDiag(Loc, diag::err_odr_function_type_inconsistent)
2094  << Name << D->getType() << FoundFunction->getType();
2095  Importer.ToDiag(FoundFunction->getLocation(),
2096  diag::note_odr_value_here)
2097  << FoundFunction->getType();
2098  }
2099  }
2100 
2101  ConflictingDecls.push_back(FoundDecls[I]);
2102  }
2103 
2104  if (!ConflictingDecls.empty()) {
2105  Name = Importer.HandleNameConflict(Name, DC, IDNS,
2106  ConflictingDecls.data(),
2107  ConflictingDecls.size());
2108  if (!Name)
2109  return nullptr;
2110  }
2111  }
2112 
2113  DeclarationNameInfo NameInfo(Name, Loc);
2114  // Import additional name location/type info.
2115  ImportDeclarationNameLoc(D->getNameInfo(), NameInfo);
2116 
2117  QualType FromTy = D->getType();
2118  bool usedDifferentExceptionSpec = false;
2119 
2120  if (const FunctionProtoType *
2121  FromFPT = D->getType()->getAs<FunctionProtoType>()) {
2122  FunctionProtoType::ExtProtoInfo FromEPI = FromFPT->getExtProtoInfo();
2123  // FunctionProtoType::ExtProtoInfo's ExceptionSpecDecl can point to the
2124  // FunctionDecl that we are importing the FunctionProtoType for.
2125  // To avoid an infinite recursion when importing, create the FunctionDecl
2126  // with a simplified function type and update it afterwards.
2127  if (FromEPI.ExceptionSpec.SourceDecl ||
2128  FromEPI.ExceptionSpec.SourceTemplate ||
2129  FromEPI.ExceptionSpec.NoexceptExpr) {
2131  FromTy = Importer.getFromContext().getFunctionType(
2132  FromFPT->getReturnType(), FromFPT->getParamTypes(), DefaultEPI);
2133  usedDifferentExceptionSpec = true;
2134  }
2135  }
2136 
2137  // Import the type.
2138  QualType T = Importer.Import(FromTy);
2139  if (T.isNull())
2140  return nullptr;
2141 
2142  // Import the function parameters.
2143  SmallVector<ParmVarDecl *, 8> Parameters;
2144  for (auto P : D->parameters()) {
2145  ParmVarDecl *ToP = cast_or_null<ParmVarDecl>(Importer.Import(P));
2146  if (!ToP)
2147  return nullptr;
2148 
2149  Parameters.push_back(ToP);
2150  }
2151 
2152  // Create the imported function.
2153  TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo());
2154  FunctionDecl *ToFunction = nullptr;
2155  SourceLocation InnerLocStart = Importer.Import(D->getInnerLocStart());
2156  if (CXXConstructorDecl *FromConstructor = dyn_cast<CXXConstructorDecl>(D)) {
2157  ToFunction = CXXConstructorDecl::Create(Importer.getToContext(),
2158  cast<CXXRecordDecl>(DC),
2159  InnerLocStart,
2160  NameInfo, T, TInfo,
2161  FromConstructor->isExplicit(),
2162  D->isInlineSpecified(),
2163  D->isImplicit(),
2164  D->isConstexpr());
2165  if (unsigned NumInitializers = FromConstructor->getNumCtorInitializers()) {
2166  SmallVector<CXXCtorInitializer *, 4> CtorInitializers;
2167  for (CXXCtorInitializer *I : FromConstructor->inits()) {
2168  CXXCtorInitializer *ToI =
2169  cast_or_null<CXXCtorInitializer>(Importer.Import(I));
2170  if (!ToI && I)
2171  return nullptr;
2172  CtorInitializers.push_back(ToI);
2173  }
2174  CXXCtorInitializer **Memory =
2175  new (Importer.getToContext()) CXXCtorInitializer *[NumInitializers];
2176  std::copy(CtorInitializers.begin(), CtorInitializers.end(), Memory);
2177  CXXConstructorDecl *ToCtor = llvm::cast<CXXConstructorDecl>(ToFunction);
2178  ToCtor->setCtorInitializers(Memory);
2179  ToCtor->setNumCtorInitializers(NumInitializers);
2180  }
2181  } else if (isa<CXXDestructorDecl>(D)) {
2182  ToFunction = CXXDestructorDecl::Create(Importer.getToContext(),
2183  cast<CXXRecordDecl>(DC),
2184  InnerLocStart,
2185  NameInfo, T, TInfo,
2186  D->isInlineSpecified(),
2187  D->isImplicit());
2188  } else if (CXXConversionDecl *FromConversion
2189  = dyn_cast<CXXConversionDecl>(D)) {
2190  ToFunction = CXXConversionDecl::Create(Importer.getToContext(),
2191  cast<CXXRecordDecl>(DC),
2192  InnerLocStart,
2193  NameInfo, T, TInfo,
2194  D->isInlineSpecified(),
2195  FromConversion->isExplicit(),
2196  D->isConstexpr(),
2197  Importer.Import(D->getLocEnd()));
2198  } else if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) {
2199  ToFunction = CXXMethodDecl::Create(Importer.getToContext(),
2200  cast<CXXRecordDecl>(DC),
2201  InnerLocStart,
2202  NameInfo, T, TInfo,
2203  Method->getStorageClass(),
2204  Method->isInlineSpecified(),
2205  D->isConstexpr(),
2206  Importer.Import(D->getLocEnd()));
2207  } else {
2208  ToFunction = FunctionDecl::Create(Importer.getToContext(), DC,
2209  InnerLocStart,
2210  NameInfo, T, TInfo, D->getStorageClass(),
2211  D->isInlineSpecified(),
2212  D->hasWrittenPrototype(),
2213  D->isConstexpr());
2214  }
2215 
2216  // Import the qualifier, if any.
2217  ToFunction->setQualifierInfo(Importer.Import(D->getQualifierLoc()));
2218  ToFunction->setAccess(D->getAccess());
2219  ToFunction->setLexicalDeclContext(LexicalDC);
2220  ToFunction->setVirtualAsWritten(D->isVirtualAsWritten());
2221  ToFunction->setTrivial(D->isTrivial());
2222  ToFunction->setPure(D->isPure());
2223  Importer.Imported(D, ToFunction);
2224 
2225  // Set the parameters.
2226  for (unsigned I = 0, N = Parameters.size(); I != N; ++I) {
2227  Parameters[I]->setOwningFunction(ToFunction);
2228  ToFunction->addDeclInternal(Parameters[I]);
2229  }
2230  ToFunction->setParams(Parameters);
2231 
2232  if (FoundWithoutBody) {
2233  auto *Recent = const_cast<FunctionDecl *>(
2234  FoundWithoutBody->getMostRecentDecl());
2235  ToFunction->setPreviousDecl(Recent);
2236  }
2237 
2238  if (usedDifferentExceptionSpec) {
2239  // Update FunctionProtoType::ExtProtoInfo.
2240  QualType T = Importer.Import(D->getType());
2241  if (T.isNull())
2242  return nullptr;
2243  ToFunction->setType(T);
2244  }
2245 
2246  // Import the body, if any.
2247  if (Stmt *FromBody = D->getBody()) {
2248  if (Stmt *ToBody = Importer.Import(FromBody)) {
2249  ToFunction->setBody(ToBody);
2250  }
2251  }
2252 
2253  // FIXME: Other bits to merge?
2254 
2255  // Add this function to the lexical context.
2256  LexicalDC->addDeclInternal(ToFunction);
2257 
2258  if (auto *FromCXXMethod = dyn_cast<CXXMethodDecl>(D))
2259  ImportOverrides(cast<CXXMethodDecl>(ToFunction), FromCXXMethod);
2260 
2261  return ToFunction;
2262 }
2263 
2265  return VisitFunctionDecl(D);
2266 }
2267 
2269  return VisitCXXMethodDecl(D);
2270 }
2271 
2273  return VisitCXXMethodDecl(D);
2274 }
2275 
2277  return VisitCXXMethodDecl(D);
2278 }
2279 
2280 static unsigned getFieldIndex(Decl *F) {
2281  RecordDecl *Owner = dyn_cast<RecordDecl>(F->getDeclContext());
2282  if (!Owner)
2283  return 0;
2284 
2285  unsigned Index = 1;
2286  for (const auto *D : Owner->noload_decls()) {
2287  if (D == F)
2288  return Index;
2289 
2290  if (isa<FieldDecl>(*D) || isa<IndirectFieldDecl>(*D))
2291  ++Index;
2292  }
2293 
2294  return Index;
2295 }
2296 
2298  // Import the major distinguishing characteristics of a variable.
2299  DeclContext *DC, *LexicalDC;
2300  DeclarationName Name;
2301  SourceLocation Loc;
2302  NamedDecl *ToD;
2303  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
2304  return nullptr;
2305  if (ToD)
2306  return ToD;
2307 
2308  // Determine whether we've already imported this field.
2309  SmallVector<NamedDecl *, 2> FoundDecls;
2310  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
2311  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
2312  if (FieldDecl *FoundField = dyn_cast<FieldDecl>(FoundDecls[I])) {
2313  // For anonymous fields, match up by index.
2314  if (!Name && getFieldIndex(D) != getFieldIndex(FoundField))
2315  continue;
2316 
2317  if (Importer.IsStructurallyEquivalent(D->getType(),
2318  FoundField->getType())) {
2319  Importer.Imported(D, FoundField);
2320  return FoundField;
2321  }
2322 
2323  Importer.ToDiag(Loc, diag::err_odr_field_type_inconsistent)
2324  << Name << D->getType() << FoundField->getType();
2325  Importer.ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
2326  << FoundField->getType();
2327  return nullptr;
2328  }
2329  }
2330 
2331  // Import the type.
2332  QualType T = Importer.Import(D->getType());
2333  if (T.isNull())
2334  return nullptr;
2335 
2336  TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo());
2337  Expr *BitWidth = Importer.Import(D->getBitWidth());
2338  if (!BitWidth && D->getBitWidth())
2339  return nullptr;
2340 
2341  FieldDecl *ToField = FieldDecl::Create(Importer.getToContext(), DC,
2342  Importer.Import(D->getInnerLocStart()),
2343  Loc, Name.getAsIdentifierInfo(),
2344  T, TInfo, BitWidth, D->isMutable(),
2345  D->getInClassInitStyle());
2346  ToField->setAccess(D->getAccess());
2347  ToField->setLexicalDeclContext(LexicalDC);
2348  if (Expr *FromInitializer = D->getInClassInitializer()) {
2349  Expr *ToInitializer = Importer.Import(FromInitializer);
2350  if (ToInitializer)
2351  ToField->setInClassInitializer(ToInitializer);
2352  else
2353  return nullptr;
2354  }
2355  ToField->setImplicit(D->isImplicit());
2356  Importer.Imported(D, ToField);
2357  LexicalDC->addDeclInternal(ToField);
2358  return ToField;
2359 }
2360 
2362  // Import the major distinguishing characteristics of a variable.
2363  DeclContext *DC, *LexicalDC;
2364  DeclarationName Name;
2365  SourceLocation Loc;
2366  NamedDecl *ToD;
2367  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
2368  return nullptr;
2369  if (ToD)
2370  return ToD;
2371 
2372  // Determine whether we've already imported this field.
2373  SmallVector<NamedDecl *, 2> FoundDecls;
2374  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
2375  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
2376  if (IndirectFieldDecl *FoundField
2377  = dyn_cast<IndirectFieldDecl>(FoundDecls[I])) {
2378  // For anonymous indirect fields, match up by index.
2379  if (!Name && getFieldIndex(D) != getFieldIndex(FoundField))
2380  continue;
2381 
2382  if (Importer.IsStructurallyEquivalent(D->getType(),
2383  FoundField->getType(),
2384  !Name.isEmpty())) {
2385  Importer.Imported(D, FoundField);
2386  return FoundField;
2387  }
2388 
2389  // If there are more anonymous fields to check, continue.
2390  if (!Name && I < N-1)
2391  continue;
2392 
2393  Importer.ToDiag(Loc, diag::err_odr_field_type_inconsistent)
2394  << Name << D->getType() << FoundField->getType();
2395  Importer.ToDiag(FoundField->getLocation(), diag::note_odr_value_here)
2396  << FoundField->getType();
2397  return nullptr;
2398  }
2399  }
2400 
2401  // Import the type.
2402  QualType T = Importer.Import(D->getType());
2403  if (T.isNull())
2404  return nullptr;
2405 
2406  NamedDecl **NamedChain =
2407  new (Importer.getToContext())NamedDecl*[D->getChainingSize()];
2408 
2409  unsigned i = 0;
2410  for (auto *PI : D->chain()) {
2411  Decl *D = Importer.Import(PI);
2412  if (!D)
2413  return nullptr;
2414  NamedChain[i++] = cast<NamedDecl>(D);
2415  }
2416 
2417  IndirectFieldDecl *ToIndirectField = IndirectFieldDecl::Create(
2418  Importer.getToContext(), DC, Loc, Name.getAsIdentifierInfo(), T,
2419  {NamedChain, D->getChainingSize()});
2420 
2421  for (const auto *Attr : D->attrs())
2422  ToIndirectField->addAttr(Attr->clone(Importer.getToContext()));
2423 
2424  ToIndirectField->setAccess(D->getAccess());
2425  ToIndirectField->setLexicalDeclContext(LexicalDC);
2426  Importer.Imported(D, ToIndirectField);
2427  LexicalDC->addDeclInternal(ToIndirectField);
2428  return ToIndirectField;
2429 }
2430 
2432  // Import the major distinguishing characteristics of a declaration.
2433  DeclContext *DC = Importer.ImportContext(D->getDeclContext());
2434  DeclContext *LexicalDC = D->getDeclContext() == D->getLexicalDeclContext()
2435  ? DC : Importer.ImportContext(D->getLexicalDeclContext());
2436  if (!DC || !LexicalDC)
2437  return nullptr;
2438 
2439  // Determine whether we've already imported this decl.
2440  // FriendDecl is not a NamedDecl so we cannot use localUncachedLookup.
2441  auto *RD = cast<CXXRecordDecl>(DC);
2442  FriendDecl *ImportedFriend = RD->getFirstFriend();
2444  Importer.getFromContext(), Importer.getToContext(),
2445  Importer.getNonEquivalentDecls(), false, false);
2446 
2447  while (ImportedFriend) {
2448  if (D->getFriendDecl() && ImportedFriend->getFriendDecl()) {
2449  if (Context.IsStructurallyEquivalent(D->getFriendDecl(),
2450  ImportedFriend->getFriendDecl()))
2451  return Importer.Imported(D, ImportedFriend);
2452 
2453  } else if (D->getFriendType() && ImportedFriend->getFriendType()) {
2454  if (Importer.IsStructurallyEquivalent(
2455  D->getFriendType()->getType(),
2456  ImportedFriend->getFriendType()->getType(), true))
2457  return Importer.Imported(D, ImportedFriend);
2458  }
2459  ImportedFriend = ImportedFriend->getNextFriend();
2460  }
2461 
2462  // Not found. Create it.
2464  if (NamedDecl *FriendD = D->getFriendDecl())
2465  ToFU = cast_or_null<NamedDecl>(Importer.Import(FriendD));
2466  else
2467  ToFU = Importer.Import(D->getFriendType());
2468  if (!ToFU)
2469  return nullptr;
2470 
2471  SmallVector<TemplateParameterList *, 1> ToTPLists(D->NumTPLists);
2472  TemplateParameterList **FromTPLists =
2473  D->getTrailingObjects<TemplateParameterList *>();
2474  for (unsigned I = 0; I < D->NumTPLists; I++) {
2475  TemplateParameterList *List = ImportTemplateParameterList(FromTPLists[I]);
2476  if (!List)
2477  return nullptr;
2478  ToTPLists[I] = List;
2479  }
2480 
2481  FriendDecl *FrD = FriendDecl::Create(Importer.getToContext(), DC,
2482  Importer.Import(D->getLocation()),
2483  ToFU, Importer.Import(D->getFriendLoc()),
2484  ToTPLists);
2485 
2486  Importer.Imported(D, FrD);
2487  RD->pushFriendDecl(FrD);
2488 
2489  FrD->setAccess(D->getAccess());
2490  FrD->setLexicalDeclContext(LexicalDC);
2491  LexicalDC->addDeclInternal(FrD);
2492  return FrD;
2493 }
2494 
2496  // Import the major distinguishing characteristics of an ivar.
2497  DeclContext *DC, *LexicalDC;
2498  DeclarationName Name;
2499  SourceLocation Loc;
2500  NamedDecl *ToD;
2501  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
2502  return nullptr;
2503  if (ToD)
2504  return ToD;
2505 
2506  // Determine whether we've already imported this ivar
2507  SmallVector<NamedDecl *, 2> FoundDecls;
2508  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
2509  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
2510  if (ObjCIvarDecl *FoundIvar = dyn_cast<ObjCIvarDecl>(FoundDecls[I])) {
2511  if (Importer.IsStructurallyEquivalent(D->getType(),
2512  FoundIvar->getType())) {
2513  Importer.Imported(D, FoundIvar);
2514  return FoundIvar;
2515  }
2516 
2517  Importer.ToDiag(Loc, diag::err_odr_ivar_type_inconsistent)
2518  << Name << D->getType() << FoundIvar->getType();
2519  Importer.ToDiag(FoundIvar->getLocation(), diag::note_odr_value_here)
2520  << FoundIvar->getType();
2521  return nullptr;
2522  }
2523  }
2524 
2525  // Import the type.
2526  QualType T = Importer.Import(D->getType());
2527  if (T.isNull())
2528  return nullptr;
2529 
2530  TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo());
2531  Expr *BitWidth = Importer.Import(D->getBitWidth());
2532  if (!BitWidth && D->getBitWidth())
2533  return nullptr;
2534 
2535  ObjCIvarDecl *ToIvar = ObjCIvarDecl::Create(Importer.getToContext(),
2536  cast<ObjCContainerDecl>(DC),
2537  Importer.Import(D->getInnerLocStart()),
2538  Loc, Name.getAsIdentifierInfo(),
2539  T, TInfo, D->getAccessControl(),
2540  BitWidth, D->getSynthesize());
2541  ToIvar->setLexicalDeclContext(LexicalDC);
2542  Importer.Imported(D, ToIvar);
2543  LexicalDC->addDeclInternal(ToIvar);
2544  return ToIvar;
2545 
2546 }
2547 
2549  // Import the major distinguishing characteristics of a variable.
2550  DeclContext *DC, *LexicalDC;
2551  DeclarationName Name;
2552  SourceLocation Loc;
2553  NamedDecl *ToD;
2554  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
2555  return nullptr;
2556  if (ToD)
2557  return ToD;
2558 
2559  // Try to find a variable in our own ("to") context with the same name and
2560  // in the same context as the variable we're importing.
2561  if (D->isFileVarDecl()) {
2562  VarDecl *MergeWithVar = nullptr;
2563  SmallVector<NamedDecl *, 4> ConflictingDecls;
2564  unsigned IDNS = Decl::IDNS_Ordinary;
2565  SmallVector<NamedDecl *, 2> FoundDecls;
2566  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
2567  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
2568  if (!FoundDecls[I]->isInIdentifierNamespace(IDNS))
2569  continue;
2570 
2571  if (VarDecl *FoundVar = dyn_cast<VarDecl>(FoundDecls[I])) {
2572  // We have found a variable that we may need to merge with. Check it.
2573  if (FoundVar->hasExternalFormalLinkage() &&
2574  D->hasExternalFormalLinkage()) {
2575  if (Importer.IsStructurallyEquivalent(D->getType(),
2576  FoundVar->getType())) {
2577  MergeWithVar = FoundVar;
2578  break;
2579  }
2580 
2581  const ArrayType *FoundArray
2582  = Importer.getToContext().getAsArrayType(FoundVar->getType());
2583  const ArrayType *TArray
2584  = Importer.getToContext().getAsArrayType(D->getType());
2585  if (FoundArray && TArray) {
2586  if (isa<IncompleteArrayType>(FoundArray) &&
2587  isa<ConstantArrayType>(TArray)) {
2588  // Import the type.
2589  QualType T = Importer.Import(D->getType());
2590  if (T.isNull())
2591  return nullptr;
2592 
2593  FoundVar->setType(T);
2594  MergeWithVar = FoundVar;
2595  break;
2596  } else if (isa<IncompleteArrayType>(TArray) &&
2597  isa<ConstantArrayType>(FoundArray)) {
2598  MergeWithVar = FoundVar;
2599  break;
2600  }
2601  }
2602 
2603  Importer.ToDiag(Loc, diag::err_odr_variable_type_inconsistent)
2604  << Name << D->getType() << FoundVar->getType();
2605  Importer.ToDiag(FoundVar->getLocation(), diag::note_odr_value_here)
2606  << FoundVar->getType();
2607  }
2608  }
2609 
2610  ConflictingDecls.push_back(FoundDecls[I]);
2611  }
2612 
2613  if (MergeWithVar) {
2614  // An equivalent variable with external linkage has been found. Link
2615  // the two declarations, then merge them.
2616  Importer.Imported(D, MergeWithVar);
2617 
2618  if (VarDecl *DDef = D->getDefinition()) {
2619  if (VarDecl *ExistingDef = MergeWithVar->getDefinition()) {
2620  Importer.ToDiag(ExistingDef->getLocation(),
2621  diag::err_odr_variable_multiple_def)
2622  << Name;
2623  Importer.FromDiag(DDef->getLocation(), diag::note_odr_defined_here);
2624  } else {
2625  Expr *Init = Importer.Import(DDef->getInit());
2626  MergeWithVar->setInit(Init);
2627  if (DDef->isInitKnownICE()) {
2628  EvaluatedStmt *Eval = MergeWithVar->ensureEvaluatedStmt();
2629  Eval->CheckedICE = true;
2630  Eval->IsICE = DDef->isInitICE();
2631  }
2632  }
2633  }
2634 
2635  return MergeWithVar;
2636  }
2637 
2638  if (!ConflictingDecls.empty()) {
2639  Name = Importer.HandleNameConflict(Name, DC, IDNS,
2640  ConflictingDecls.data(),
2641  ConflictingDecls.size());
2642  if (!Name)
2643  return nullptr;
2644  }
2645  }
2646 
2647  // Import the type.
2648  QualType T = Importer.Import(D->getType());
2649  if (T.isNull())
2650  return nullptr;
2651 
2652  // Create the imported variable.
2653  TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo());
2654  VarDecl *ToVar = VarDecl::Create(Importer.getToContext(), DC,
2655  Importer.Import(D->getInnerLocStart()),
2656  Loc, Name.getAsIdentifierInfo(),
2657  T, TInfo,
2658  D->getStorageClass());
2659  ToVar->setQualifierInfo(Importer.Import(D->getQualifierLoc()));
2660  ToVar->setAccess(D->getAccess());
2661  ToVar->setLexicalDeclContext(LexicalDC);
2662  Importer.Imported(D, ToVar);
2663  LexicalDC->addDeclInternal(ToVar);
2664 
2665  if (!D->isFileVarDecl() &&
2666  D->isUsed())
2667  ToVar->setIsUsed();
2668 
2669  // Merge the initializer.
2670  if (ImportDefinition(D, ToVar))
2671  return nullptr;
2672 
2673  if (D->isConstexpr())
2674  ToVar->setConstexpr(true);
2675 
2676  return ToVar;
2677 }
2678 
2680  // Parameters are created in the translation unit's context, then moved
2681  // into the function declaration's context afterward.
2682  DeclContext *DC = Importer.getToContext().getTranslationUnitDecl();
2683 
2684  // Import the name of this declaration.
2685  DeclarationName Name = Importer.Import(D->getDeclName());
2686  if (D->getDeclName() && !Name)
2687  return nullptr;
2688 
2689  // Import the location of this declaration.
2690  SourceLocation Loc = Importer.Import(D->getLocation());
2691 
2692  // Import the parameter's type.
2693  QualType T = Importer.Import(D->getType());
2694  if (T.isNull())
2695  return nullptr;
2696 
2697  // Create the imported parameter.
2698  auto *ToParm = ImplicitParamDecl::Create(Importer.getToContext(), DC, Loc,
2699  Name.getAsIdentifierInfo(), T,
2700  D->getParameterKind());
2701  return Importer.Imported(D, ToParm);
2702 }
2703 
2705  // Parameters are created in the translation unit's context, then moved
2706  // into the function declaration's context afterward.
2707  DeclContext *DC = Importer.getToContext().getTranslationUnitDecl();
2708 
2709  // Import the name of this declaration.
2710  DeclarationName Name = Importer.Import(D->getDeclName());
2711  if (D->getDeclName() && !Name)
2712  return nullptr;
2713 
2714  // Import the location of this declaration.
2715  SourceLocation Loc = Importer.Import(D->getLocation());
2716 
2717  // Import the parameter's type.
2718  QualType T = Importer.Import(D->getType());
2719  if (T.isNull())
2720  return nullptr;
2721 
2722  // Create the imported parameter.
2723  TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo());
2724  ParmVarDecl *ToParm = ParmVarDecl::Create(Importer.getToContext(), DC,
2725  Importer.Import(D->getInnerLocStart()),
2726  Loc, Name.getAsIdentifierInfo(),
2727  T, TInfo, D->getStorageClass(),
2728  /*DefaultArg*/ nullptr);
2729 
2730  // Set the default argument.
2732  ToParm->setKNRPromoted(D->isKNRPromoted());
2733 
2734  Expr *ToDefArg = nullptr;
2735  Expr *FromDefArg = nullptr;
2736  if (D->hasUninstantiatedDefaultArg()) {
2737  FromDefArg = D->getUninstantiatedDefaultArg();
2738  ToDefArg = Importer.Import(FromDefArg);
2739  ToParm->setUninstantiatedDefaultArg(ToDefArg);
2740  } else if (D->hasUnparsedDefaultArg()) {
2741  ToParm->setUnparsedDefaultArg();
2742  } else if (D->hasDefaultArg()) {
2743  FromDefArg = D->getDefaultArg();
2744  ToDefArg = Importer.Import(FromDefArg);
2745  ToParm->setDefaultArg(ToDefArg);
2746  }
2747  if (FromDefArg && !ToDefArg)
2748  return nullptr;
2749 
2750  if (D->isUsed())
2751  ToParm->setIsUsed();
2752 
2753  return Importer.Imported(D, ToParm);
2754 }
2755 
2757  // Import the major distinguishing characteristics of a method.
2758  DeclContext *DC, *LexicalDC;
2759  DeclarationName Name;
2760  SourceLocation Loc;
2761  NamedDecl *ToD;
2762  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
2763  return nullptr;
2764  if (ToD)
2765  return ToD;
2766 
2767  SmallVector<NamedDecl *, 2> FoundDecls;
2768  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
2769  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
2770  if (ObjCMethodDecl *FoundMethod = dyn_cast<ObjCMethodDecl>(FoundDecls[I])) {
2771  if (FoundMethod->isInstanceMethod() != D->isInstanceMethod())
2772  continue;
2773 
2774  // Check return types.
2775  if (!Importer.IsStructurallyEquivalent(D->getReturnType(),
2776  FoundMethod->getReturnType())) {
2777  Importer.ToDiag(Loc, diag::err_odr_objc_method_result_type_inconsistent)
2778  << D->isInstanceMethod() << Name << D->getReturnType()
2779  << FoundMethod->getReturnType();
2780  Importer.ToDiag(FoundMethod->getLocation(),
2781  diag::note_odr_objc_method_here)
2782  << D->isInstanceMethod() << Name;
2783  return nullptr;
2784  }
2785 
2786  // Check the number of parameters.
2787  if (D->param_size() != FoundMethod->param_size()) {
2788  Importer.ToDiag(Loc, diag::err_odr_objc_method_num_params_inconsistent)
2789  << D->isInstanceMethod() << Name
2790  << D->param_size() << FoundMethod->param_size();
2791  Importer.ToDiag(FoundMethod->getLocation(),
2792  diag::note_odr_objc_method_here)
2793  << D->isInstanceMethod() << Name;
2794  return nullptr;
2795  }
2796 
2797  // Check parameter types.
2799  PEnd = D->param_end(), FoundP = FoundMethod->param_begin();
2800  P != PEnd; ++P, ++FoundP) {
2801  if (!Importer.IsStructurallyEquivalent((*P)->getType(),
2802  (*FoundP)->getType())) {
2803  Importer.FromDiag((*P)->getLocation(),
2804  diag::err_odr_objc_method_param_type_inconsistent)
2805  << D->isInstanceMethod() << Name
2806  << (*P)->getType() << (*FoundP)->getType();
2807  Importer.ToDiag((*FoundP)->getLocation(), diag::note_odr_value_here)
2808  << (*FoundP)->getType();
2809  return nullptr;
2810  }
2811  }
2812 
2813  // Check variadic/non-variadic.
2814  // Check the number of parameters.
2815  if (D->isVariadic() != FoundMethod->isVariadic()) {
2816  Importer.ToDiag(Loc, diag::err_odr_objc_method_variadic_inconsistent)
2817  << D->isInstanceMethod() << Name;
2818  Importer.ToDiag(FoundMethod->getLocation(),
2819  diag::note_odr_objc_method_here)
2820  << D->isInstanceMethod() << Name;
2821  return nullptr;
2822  }
2823 
2824  // FIXME: Any other bits we need to merge?
2825  return Importer.Imported(D, FoundMethod);
2826  }
2827  }
2828 
2829  // Import the result type.
2830  QualType ResultTy = Importer.Import(D->getReturnType());
2831  if (ResultTy.isNull())
2832  return nullptr;
2833 
2834  TypeSourceInfo *ReturnTInfo = Importer.Import(D->getReturnTypeSourceInfo());
2835 
2837  Importer.getToContext(), Loc, Importer.Import(D->getLocEnd()),
2838  Name.getObjCSelector(), ResultTy, ReturnTInfo, DC, D->isInstanceMethod(),
2839  D->isVariadic(), D->isPropertyAccessor(), D->isImplicit(), D->isDefined(),
2841 
2842  // FIXME: When we decide to merge method definitions, we'll need to
2843  // deal with implicit parameters.
2844 
2845  // Import the parameters
2847  for (auto *FromP : D->parameters()) {
2848  ParmVarDecl *ToP = cast_or_null<ParmVarDecl>(Importer.Import(FromP));
2849  if (!ToP)
2850  return nullptr;
2851 
2852  ToParams.push_back(ToP);
2853  }
2854 
2855  // Set the parameters.
2856  for (unsigned I = 0, N = ToParams.size(); I != N; ++I) {
2857  ToParams[I]->setOwningFunction(ToMethod);
2858  ToMethod->addDeclInternal(ToParams[I]);
2859  }
2861  D->getSelectorLocs(SelLocs);
2862  ToMethod->setMethodParams(Importer.getToContext(), ToParams, SelLocs);
2863 
2864  ToMethod->setLexicalDeclContext(LexicalDC);
2865  Importer.Imported(D, ToMethod);
2866  LexicalDC->addDeclInternal(ToMethod);
2867  return ToMethod;
2868 }
2869 
2871  // Import the major distinguishing characteristics of a category.
2872  DeclContext *DC, *LexicalDC;
2873  DeclarationName Name;
2874  SourceLocation Loc;
2875  NamedDecl *ToD;
2876  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
2877  return nullptr;
2878  if (ToD)
2879  return ToD;
2880 
2881  TypeSourceInfo *BoundInfo = Importer.Import(D->getTypeSourceInfo());
2882  if (!BoundInfo)
2883  return nullptr;
2884 
2886  Importer.getToContext(), DC,
2887  D->getVariance(),
2888  Importer.Import(D->getVarianceLoc()),
2889  D->getIndex(),
2890  Importer.Import(D->getLocation()),
2891  Name.getAsIdentifierInfo(),
2892  Importer.Import(D->getColonLoc()),
2893  BoundInfo);
2894  Importer.Imported(D, Result);
2895  Result->setLexicalDeclContext(LexicalDC);
2896  return Result;
2897 }
2898 
2900  // Import the major distinguishing characteristics of a category.
2901  DeclContext *DC, *LexicalDC;
2902  DeclarationName Name;
2903  SourceLocation Loc;
2904  NamedDecl *ToD;
2905  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
2906  return nullptr;
2907  if (ToD)
2908  return ToD;
2909 
2910  ObjCInterfaceDecl *ToInterface
2911  = cast_or_null<ObjCInterfaceDecl>(Importer.Import(D->getClassInterface()));
2912  if (!ToInterface)
2913  return nullptr;
2914 
2915  // Determine if we've already encountered this category.
2916  ObjCCategoryDecl *MergeWithCategory
2917  = ToInterface->FindCategoryDeclaration(Name.getAsIdentifierInfo());
2918  ObjCCategoryDecl *ToCategory = MergeWithCategory;
2919  if (!ToCategory) {
2920  ToCategory = ObjCCategoryDecl::Create(Importer.getToContext(), DC,
2921  Importer.Import(D->getAtStartLoc()),
2922  Loc,
2923  Importer.Import(D->getCategoryNameLoc()),
2924  Name.getAsIdentifierInfo(),
2925  ToInterface,
2926  /*TypeParamList=*/nullptr,
2927  Importer.Import(D->getIvarLBraceLoc()),
2928  Importer.Import(D->getIvarRBraceLoc()));
2929  ToCategory->setLexicalDeclContext(LexicalDC);
2930  LexicalDC->addDeclInternal(ToCategory);
2931  Importer.Imported(D, ToCategory);
2932  // Import the type parameter list after calling Imported, to avoid
2933  // loops when bringing in their DeclContext.
2935  D->getTypeParamList()));
2936 
2937  // Import protocols
2939  SmallVector<SourceLocation, 4> ProtocolLocs;
2941  = D->protocol_loc_begin();
2943  FromProtoEnd = D->protocol_end();
2944  FromProto != FromProtoEnd;
2945  ++FromProto, ++FromProtoLoc) {
2946  ObjCProtocolDecl *ToProto
2947  = cast_or_null<ObjCProtocolDecl>(Importer.Import(*FromProto));
2948  if (!ToProto)
2949  return nullptr;
2950  Protocols.push_back(ToProto);
2951  ProtocolLocs.push_back(Importer.Import(*FromProtoLoc));
2952  }
2953 
2954  // FIXME: If we're merging, make sure that the protocol list is the same.
2955  ToCategory->setProtocolList(Protocols.data(), Protocols.size(),
2956  ProtocolLocs.data(), Importer.getToContext());
2957 
2958  } else {
2959  Importer.Imported(D, ToCategory);
2960  }
2961 
2962  // Import all of the members of this category.
2963  ImportDeclContext(D);
2964 
2965  // If we have an implementation, import it as well.
2966  if (D->getImplementation()) {
2967  ObjCCategoryImplDecl *Impl
2968  = cast_or_null<ObjCCategoryImplDecl>(
2969  Importer.Import(D->getImplementation()));
2970  if (!Impl)
2971  return nullptr;
2972 
2973  ToCategory->setImplementation(Impl);
2974  }
2975 
2976  return ToCategory;
2977 }
2978 
2980  ObjCProtocolDecl *To,
2982  if (To->getDefinition()) {
2983  if (shouldForceImportDeclContext(Kind))
2984  ImportDeclContext(From);
2985  return false;
2986  }
2987 
2988  // Start the protocol definition
2989  To->startDefinition();
2990 
2991  // Import protocols
2993  SmallVector<SourceLocation, 4> ProtocolLocs;
2995  FromProtoLoc = From->protocol_loc_begin();
2996  for (ObjCProtocolDecl::protocol_iterator FromProto = From->protocol_begin(),
2997  FromProtoEnd = From->protocol_end();
2998  FromProto != FromProtoEnd;
2999  ++FromProto, ++FromProtoLoc) {
3000  ObjCProtocolDecl *ToProto
3001  = cast_or_null<ObjCProtocolDecl>(Importer.Import(*FromProto));
3002  if (!ToProto)
3003  return true;
3004  Protocols.push_back(ToProto);
3005  ProtocolLocs.push_back(Importer.Import(*FromProtoLoc));
3006  }
3007 
3008  // FIXME: If we're merging, make sure that the protocol list is the same.
3009  To->setProtocolList(Protocols.data(), Protocols.size(),
3010  ProtocolLocs.data(), Importer.getToContext());
3011 
3012  if (shouldForceImportDeclContext(Kind)) {
3013  // Import all of the members of this protocol.
3014  ImportDeclContext(From, /*ForceImport=*/true);
3015  }
3016  return false;
3017 }
3018 
3020  // If this protocol has a definition in the translation unit we're coming
3021  // from, but this particular declaration is not that definition, import the
3022  // definition and map to that.
3023  ObjCProtocolDecl *Definition = D->getDefinition();
3024  if (Definition && Definition != D) {
3025  Decl *ImportedDef = Importer.Import(Definition);
3026  if (!ImportedDef)
3027  return nullptr;
3028 
3029  return Importer.Imported(D, ImportedDef);
3030  }
3031 
3032  // Import the major distinguishing characteristics of a protocol.
3033  DeclContext *DC, *LexicalDC;
3034  DeclarationName Name;
3035  SourceLocation Loc;
3036  NamedDecl *ToD;
3037  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
3038  return nullptr;
3039  if (ToD)
3040  return ToD;
3041 
3042  ObjCProtocolDecl *MergeWithProtocol = nullptr;
3043  SmallVector<NamedDecl *, 2> FoundDecls;
3044  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
3045  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
3046  if (!FoundDecls[I]->isInIdentifierNamespace(Decl::IDNS_ObjCProtocol))
3047  continue;
3048 
3049  if ((MergeWithProtocol = dyn_cast<ObjCProtocolDecl>(FoundDecls[I])))
3050  break;
3051  }
3052 
3053  ObjCProtocolDecl *ToProto = MergeWithProtocol;
3054  if (!ToProto) {
3055  ToProto = ObjCProtocolDecl::Create(Importer.getToContext(), DC,
3056  Name.getAsIdentifierInfo(), Loc,
3057  Importer.Import(D->getAtStartLoc()),
3058  /*PrevDecl=*/nullptr);
3059  ToProto->setLexicalDeclContext(LexicalDC);
3060  LexicalDC->addDeclInternal(ToProto);
3061  }
3062 
3063  Importer.Imported(D, ToProto);
3064 
3065  if (D->isThisDeclarationADefinition() && ImportDefinition(D, ToProto))
3066  return nullptr;
3067 
3068  return ToProto;
3069 }
3070 
3072  DeclContext *DC = Importer.ImportContext(D->getDeclContext());
3073  DeclContext *LexicalDC = Importer.ImportContext(D->getLexicalDeclContext());
3074 
3075  SourceLocation ExternLoc = Importer.Import(D->getExternLoc());
3076  SourceLocation LangLoc = Importer.Import(D->getLocation());
3077 
3078  bool HasBraces = D->hasBraces();
3079 
3080  LinkageSpecDecl *ToLinkageSpec =
3081  LinkageSpecDecl::Create(Importer.getToContext(),
3082  DC,
3083  ExternLoc,
3084  LangLoc,
3085  D->getLanguage(),
3086  HasBraces);
3087 
3088  if (HasBraces) {
3089  SourceLocation RBraceLoc = Importer.Import(D->getRBraceLoc());
3090  ToLinkageSpec->setRBraceLoc(RBraceLoc);
3091  }
3092 
3093  ToLinkageSpec->setLexicalDeclContext(LexicalDC);
3094  LexicalDC->addDeclInternal(ToLinkageSpec);
3095 
3096  Importer.Imported(D, ToLinkageSpec);
3097 
3098  return ToLinkageSpec;
3099 }
3100 
3102  DeclContext *DC, *LexicalDC;
3103  DeclarationName Name;
3104  SourceLocation Loc;
3105  NamedDecl *ToD = nullptr;
3106  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
3107  return nullptr;
3108  if (ToD)
3109  return ToD;
3110 
3111  DeclarationNameInfo NameInfo(Name,
3112  Importer.Import(D->getNameInfo().getLoc()));
3113  ImportDeclarationNameLoc(D->getNameInfo(), NameInfo);
3114 
3115  UsingDecl *ToUsing = UsingDecl::Create(Importer.getToContext(), DC,
3116  Importer.Import(D->getUsingLoc()),
3117  Importer.Import(D->getQualifierLoc()),
3118  NameInfo, D->hasTypename());
3119  ToUsing->setLexicalDeclContext(LexicalDC);
3120  LexicalDC->addDeclInternal(ToUsing);
3121  Importer.Imported(D, ToUsing);
3122 
3123  if (NamedDecl *FromPattern =
3124  Importer.getFromContext().getInstantiatedFromUsingDecl(D)) {
3125  if (NamedDecl *ToPattern =
3126  dyn_cast_or_null<NamedDecl>(Importer.Import(FromPattern)))
3127  Importer.getToContext().setInstantiatedFromUsingDecl(ToUsing, ToPattern);
3128  else
3129  return nullptr;
3130  }
3131 
3132  for (UsingShadowDecl *FromShadow : D->shadows()) {
3133  if (UsingShadowDecl *ToShadow =
3134  dyn_cast_or_null<UsingShadowDecl>(Importer.Import(FromShadow)))
3135  ToUsing->addShadowDecl(ToShadow);
3136  else
3137  // FIXME: We return a nullptr here but the definition is already created
3138  // and available with lookups. How to fix this?..
3139  return nullptr;
3140  }
3141  return ToUsing;
3142 }
3143 
3145  DeclContext *DC, *LexicalDC;
3146  DeclarationName Name;
3147  SourceLocation Loc;
3148  NamedDecl *ToD = nullptr;
3149  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
3150  return nullptr;
3151  if (ToD)
3152  return ToD;
3153 
3154  UsingDecl *ToUsing = dyn_cast_or_null<UsingDecl>(
3155  Importer.Import(D->getUsingDecl()));
3156  if (!ToUsing)
3157  return nullptr;
3158 
3159  NamedDecl *ToTarget = dyn_cast_or_null<NamedDecl>(
3160  Importer.Import(D->getTargetDecl()));
3161  if (!ToTarget)
3162  return nullptr;
3163 
3165  Importer.getToContext(), DC, Loc, ToUsing, ToTarget);
3166 
3167  ToShadow->setLexicalDeclContext(LexicalDC);
3168  ToShadow->setAccess(D->getAccess());
3169  Importer.Imported(D, ToShadow);
3170 
3171  if (UsingShadowDecl *FromPattern =
3172  Importer.getFromContext().getInstantiatedFromUsingShadowDecl(D)) {
3173  if (UsingShadowDecl *ToPattern =
3174  dyn_cast_or_null<UsingShadowDecl>(Importer.Import(FromPattern)))
3175  Importer.getToContext().setInstantiatedFromUsingShadowDecl(ToShadow,
3176  ToPattern);
3177  else
3178  // FIXME: We return a nullptr here but the definition is already created
3179  // and available with lookups. How to fix this?..
3180  return nullptr;
3181  }
3182 
3183  LexicalDC->addDeclInternal(ToShadow);
3184 
3185  return ToShadow;
3186 }
3187 
3188 
3190  DeclContext *DC, *LexicalDC;
3191  DeclarationName Name;
3192  SourceLocation Loc;
3193  NamedDecl *ToD = nullptr;
3194  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
3195  return nullptr;
3196  if (ToD)
3197  return ToD;
3198 
3199  DeclContext *ToComAncestor = Importer.ImportContext(D->getCommonAncestor());
3200  if (!ToComAncestor)
3201  return nullptr;
3202 
3203  NamespaceDecl *ToNominated = cast_or_null<NamespaceDecl>(
3204  Importer.Import(D->getNominatedNamespace()));
3205  if (!ToNominated)
3206  return nullptr;
3207 
3209  Importer.getToContext(), DC, Importer.Import(D->getUsingLoc()),
3210  Importer.Import(D->getNamespaceKeyLocation()),
3211  Importer.Import(D->getQualifierLoc()),
3212  Importer.Import(D->getIdentLocation()), ToNominated, ToComAncestor);
3213  ToUsingDir->setLexicalDeclContext(LexicalDC);
3214  LexicalDC->addDeclInternal(ToUsingDir);
3215  Importer.Imported(D, ToUsingDir);
3216 
3217  return ToUsingDir;
3218 }
3219 
3222  DeclContext *DC, *LexicalDC;
3223  DeclarationName Name;
3224  SourceLocation Loc;
3225  NamedDecl *ToD = nullptr;
3226  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
3227  return nullptr;
3228  if (ToD)
3229  return ToD;
3230 
3231  DeclarationNameInfo NameInfo(Name, Importer.Import(D->getNameInfo().getLoc()));
3232  ImportDeclarationNameLoc(D->getNameInfo(), NameInfo);
3233 
3235  Importer.getToContext(), DC, Importer.Import(D->getUsingLoc()),
3236  Importer.Import(D->getQualifierLoc()), NameInfo,
3237  Importer.Import(D->getEllipsisLoc()));
3238 
3239  Importer.Imported(D, ToUsingValue);
3240  ToUsingValue->setAccess(D->getAccess());
3241  ToUsingValue->setLexicalDeclContext(LexicalDC);
3242  LexicalDC->addDeclInternal(ToUsingValue);
3243 
3244  return ToUsingValue;
3245 }
3246 
3249  DeclContext *DC, *LexicalDC;
3250  DeclarationName Name;
3251  SourceLocation Loc;
3252  NamedDecl *ToD = nullptr;
3253  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
3254  return nullptr;
3255  if (ToD)
3256  return ToD;
3257 
3259  Importer.getToContext(), DC, Importer.Import(D->getUsingLoc()),
3260  Importer.Import(D->getTypenameLoc()),
3261  Importer.Import(D->getQualifierLoc()), Loc, Name,
3262  Importer.Import(D->getEllipsisLoc()));
3263 
3264  Importer.Imported(D, ToUsing);
3265  ToUsing->setAccess(D->getAccess());
3266  ToUsing->setLexicalDeclContext(LexicalDC);
3267  LexicalDC->addDeclInternal(ToUsing);
3268 
3269  return ToUsing;
3270 }
3271 
3272 
3274  ObjCInterfaceDecl *To,
3276  if (To->getDefinition()) {
3277  // Check consistency of superclass.
3278  ObjCInterfaceDecl *FromSuper = From->getSuperClass();
3279  if (FromSuper) {
3280  FromSuper = cast_or_null<ObjCInterfaceDecl>(Importer.Import(FromSuper));
3281  if (!FromSuper)
3282  return true;
3283  }
3284 
3285  ObjCInterfaceDecl *ToSuper = To->getSuperClass();
3286  if ((bool)FromSuper != (bool)ToSuper ||
3287  (FromSuper && !declaresSameEntity(FromSuper, ToSuper))) {
3288  Importer.ToDiag(To->getLocation(),
3289  diag::err_odr_objc_superclass_inconsistent)
3290  << To->getDeclName();
3291  if (ToSuper)
3292  Importer.ToDiag(To->getSuperClassLoc(), diag::note_odr_objc_superclass)
3293  << To->getSuperClass()->getDeclName();
3294  else
3295  Importer.ToDiag(To->getLocation(),
3296  diag::note_odr_objc_missing_superclass);
3297  if (From->getSuperClass())
3298  Importer.FromDiag(From->getSuperClassLoc(),
3299  diag::note_odr_objc_superclass)
3300  << From->getSuperClass()->getDeclName();
3301  else
3302  Importer.FromDiag(From->getLocation(),
3303  diag::note_odr_objc_missing_superclass);
3304  }
3305 
3306  if (shouldForceImportDeclContext(Kind))
3307  ImportDeclContext(From);
3308  return false;
3309  }
3310 
3311  // Start the definition.
3312  To->startDefinition();
3313 
3314  // If this class has a superclass, import it.
3315  if (From->getSuperClass()) {
3316  TypeSourceInfo *SuperTInfo = Importer.Import(From->getSuperClassTInfo());
3317  if (!SuperTInfo)
3318  return true;
3319 
3320  To->setSuperClass(SuperTInfo);
3321  }
3322 
3323  // Import protocols
3325  SmallVector<SourceLocation, 4> ProtocolLocs;
3327  FromProtoLoc = From->protocol_loc_begin();
3328 
3329  for (ObjCInterfaceDecl::protocol_iterator FromProto = From->protocol_begin(),
3330  FromProtoEnd = From->protocol_end();
3331  FromProto != FromProtoEnd;
3332  ++FromProto, ++FromProtoLoc) {
3333  ObjCProtocolDecl *ToProto
3334  = cast_or_null<ObjCProtocolDecl>(Importer.Import(*FromProto));
3335  if (!ToProto)
3336  return true;
3337  Protocols.push_back(ToProto);
3338  ProtocolLocs.push_back(Importer.Import(*FromProtoLoc));
3339  }
3340 
3341  // FIXME: If we're merging, make sure that the protocol list is the same.
3342  To->setProtocolList(Protocols.data(), Protocols.size(),
3343  ProtocolLocs.data(), Importer.getToContext());
3344 
3345  // Import categories. When the categories themselves are imported, they'll
3346  // hook themselves into this interface.
3347  for (auto *Cat : From->known_categories())
3348  Importer.Import(Cat);
3349 
3350  // If we have an @implementation, import it as well.
3351  if (From->getImplementation()) {
3352  ObjCImplementationDecl *Impl = cast_or_null<ObjCImplementationDecl>(
3353  Importer.Import(From->getImplementation()));
3354  if (!Impl)
3355  return true;
3356 
3357  To->setImplementation(Impl);
3358  }
3359 
3360  if (shouldForceImportDeclContext(Kind)) {
3361  // Import all of the members of this class.
3362  ImportDeclContext(From, /*ForceImport=*/true);
3363  }
3364  return false;
3365 }
3366 
3369  if (!list)
3370  return nullptr;
3371 
3373  for (auto fromTypeParam : *list) {
3374  auto toTypeParam = cast_or_null<ObjCTypeParamDecl>(
3375  Importer.Import(fromTypeParam));
3376  if (!toTypeParam)
3377  return nullptr;
3378 
3379  toTypeParams.push_back(toTypeParam);
3380  }
3381 
3382  return ObjCTypeParamList::create(Importer.getToContext(),
3383  Importer.Import(list->getLAngleLoc()),
3384  toTypeParams,
3385  Importer.Import(list->getRAngleLoc()));
3386 }
3387 
3389  // If this class has a definition in the translation unit we're coming from,
3390  // but this particular declaration is not that definition, import the
3391  // definition and map to that.
3392  ObjCInterfaceDecl *Definition = D->getDefinition();
3393  if (Definition && Definition != D) {
3394  Decl *ImportedDef = Importer.Import(Definition);
3395  if (!ImportedDef)
3396  return nullptr;
3397 
3398  return Importer.Imported(D, ImportedDef);
3399  }
3400 
3401  // Import the major distinguishing characteristics of an @interface.
3402  DeclContext *DC, *LexicalDC;
3403  DeclarationName Name;
3404  SourceLocation Loc;
3405  NamedDecl *ToD;
3406  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
3407  return nullptr;
3408  if (ToD)
3409  return ToD;
3410 
3411  // Look for an existing interface with the same name.
3412  ObjCInterfaceDecl *MergeWithIface = nullptr;
3413  SmallVector<NamedDecl *, 2> FoundDecls;
3414  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
3415  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
3416  if (!FoundDecls[I]->isInIdentifierNamespace(Decl::IDNS_Ordinary))
3417  continue;
3418 
3419  if ((MergeWithIface = dyn_cast<ObjCInterfaceDecl>(FoundDecls[I])))
3420  break;
3421  }
3422 
3423  // Create an interface declaration, if one does not already exist.
3424  ObjCInterfaceDecl *ToIface = MergeWithIface;
3425  if (!ToIface) {
3426  ToIface = ObjCInterfaceDecl::Create(Importer.getToContext(), DC,
3427  Importer.Import(D->getAtStartLoc()),
3428  Name.getAsIdentifierInfo(),
3429  /*TypeParamList=*/nullptr,
3430  /*PrevDecl=*/nullptr, Loc,
3432  ToIface->setLexicalDeclContext(LexicalDC);
3433  LexicalDC->addDeclInternal(ToIface);
3434  }
3435  Importer.Imported(D, ToIface);
3436  // Import the type parameter list after calling Imported, to avoid
3437  // loops when bringing in their DeclContext.
3440 
3441  if (D->isThisDeclarationADefinition() && ImportDefinition(D, ToIface))
3442  return nullptr;
3443 
3444  return ToIface;
3445 }
3446 
3448  ObjCCategoryDecl *Category = cast_or_null<ObjCCategoryDecl>(
3449  Importer.Import(D->getCategoryDecl()));
3450  if (!Category)
3451  return nullptr;
3452 
3453  ObjCCategoryImplDecl *ToImpl = Category->getImplementation();
3454  if (!ToImpl) {
3455  DeclContext *DC = Importer.ImportContext(D->getDeclContext());
3456  if (!DC)
3457  return nullptr;
3458 
3459  SourceLocation CategoryNameLoc = Importer.Import(D->getCategoryNameLoc());
3460  ToImpl = ObjCCategoryImplDecl::Create(Importer.getToContext(), DC,
3461  Importer.Import(D->getIdentifier()),
3462  Category->getClassInterface(),
3463  Importer.Import(D->getLocation()),
3464  Importer.Import(D->getAtStartLoc()),
3465  CategoryNameLoc);
3466 
3467  DeclContext *LexicalDC = DC;
3468  if (D->getDeclContext() != D->getLexicalDeclContext()) {
3469  LexicalDC = Importer.ImportContext(D->getLexicalDeclContext());
3470  if (!LexicalDC)
3471  return nullptr;
3472 
3473  ToImpl->setLexicalDeclContext(LexicalDC);
3474  }
3475 
3476  LexicalDC->addDeclInternal(ToImpl);
3477  Category->setImplementation(ToImpl);
3478  }
3479 
3480  Importer.Imported(D, ToImpl);
3481  ImportDeclContext(D);
3482  return ToImpl;
3483 }
3484 
3486  // Find the corresponding interface.
3487  ObjCInterfaceDecl *Iface = cast_or_null<ObjCInterfaceDecl>(
3488  Importer.Import(D->getClassInterface()));
3489  if (!Iface)
3490  return nullptr;
3491 
3492  // Import the superclass, if any.
3493  ObjCInterfaceDecl *Super = nullptr;
3494  if (D->getSuperClass()) {
3495  Super = cast_or_null<ObjCInterfaceDecl>(
3496  Importer.Import(D->getSuperClass()));
3497  if (!Super)
3498  return nullptr;
3499  }
3500 
3501  ObjCImplementationDecl *Impl = Iface->getImplementation();
3502  if (!Impl) {
3503  // We haven't imported an implementation yet. Create a new @implementation
3504  // now.
3505  Impl = ObjCImplementationDecl::Create(Importer.getToContext(),
3506  Importer.ImportContext(D->getDeclContext()),
3507  Iface, Super,
3508  Importer.Import(D->getLocation()),
3509  Importer.Import(D->getAtStartLoc()),
3510  Importer.Import(D->getSuperClassLoc()),
3511  Importer.Import(D->getIvarLBraceLoc()),
3512  Importer.Import(D->getIvarRBraceLoc()));
3513 
3514  if (D->getDeclContext() != D->getLexicalDeclContext()) {
3515  DeclContext *LexicalDC
3516  = Importer.ImportContext(D->getLexicalDeclContext());
3517  if (!LexicalDC)
3518  return nullptr;
3519  Impl->setLexicalDeclContext(LexicalDC);
3520  }
3521 
3522  // Associate the implementation with the class it implements.
3523  Iface->setImplementation(Impl);
3524  Importer.Imported(D, Iface->getImplementation());
3525  } else {
3526  Importer.Imported(D, Iface->getImplementation());
3527 
3528  // Verify that the existing @implementation has the same superclass.
3529  if ((Super && !Impl->getSuperClass()) ||
3530  (!Super && Impl->getSuperClass()) ||
3531  (Super && Impl->getSuperClass() &&
3533  Impl->getSuperClass()))) {
3534  Importer.ToDiag(Impl->getLocation(),
3535  diag::err_odr_objc_superclass_inconsistent)
3536  << Iface->getDeclName();
3537  // FIXME: It would be nice to have the location of the superclass
3538  // below.
3539  if (Impl->getSuperClass())
3540  Importer.ToDiag(Impl->getLocation(),
3541  diag::note_odr_objc_superclass)
3542  << Impl->getSuperClass()->getDeclName();
3543  else
3544  Importer.ToDiag(Impl->getLocation(),
3545  diag::note_odr_objc_missing_superclass);
3546  if (D->getSuperClass())
3547  Importer.FromDiag(D->getLocation(),
3548  diag::note_odr_objc_superclass)
3549  << D->getSuperClass()->getDeclName();
3550  else
3551  Importer.FromDiag(D->getLocation(),
3552  diag::note_odr_objc_missing_superclass);
3553  return nullptr;
3554  }
3555  }
3556 
3557  // Import all of the members of this @implementation.
3558  ImportDeclContext(D);
3559 
3560  return Impl;
3561 }
3562 
3564  // Import the major distinguishing characteristics of an @property.
3565  DeclContext *DC, *LexicalDC;
3566  DeclarationName Name;
3567  SourceLocation Loc;
3568  NamedDecl *ToD;
3569  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
3570  return nullptr;
3571  if (ToD)
3572  return ToD;
3573 
3574  // Check whether we have already imported this property.
3575  SmallVector<NamedDecl *, 2> FoundDecls;
3576  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
3577  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
3578  if (ObjCPropertyDecl *FoundProp
3579  = dyn_cast<ObjCPropertyDecl>(FoundDecls[I])) {
3580  // Check property types.
3581  if (!Importer.IsStructurallyEquivalent(D->getType(),
3582  FoundProp->getType())) {
3583  Importer.ToDiag(Loc, diag::err_odr_objc_property_type_inconsistent)
3584  << Name << D->getType() << FoundProp->getType();
3585  Importer.ToDiag(FoundProp->getLocation(), diag::note_odr_value_here)
3586  << FoundProp->getType();
3587  return nullptr;
3588  }
3589 
3590  // FIXME: Check property attributes, getters, setters, etc.?
3591 
3592  // Consider these properties to be equivalent.
3593  Importer.Imported(D, FoundProp);
3594  return FoundProp;
3595  }
3596  }
3597 
3598  // Import the type.
3599  TypeSourceInfo *TSI = Importer.Import(D->getTypeSourceInfo());
3600  if (!TSI)
3601  return nullptr;
3602 
3603  // Create the new property.
3604  ObjCPropertyDecl *ToProperty
3605  = ObjCPropertyDecl::Create(Importer.getToContext(), DC, Loc,
3606  Name.getAsIdentifierInfo(),
3607  Importer.Import(D->getAtLoc()),
3608  Importer.Import(D->getLParenLoc()),
3609  Importer.Import(D->getType()),
3610  TSI,
3612  Importer.Imported(D, ToProperty);
3613  ToProperty->setLexicalDeclContext(LexicalDC);
3614  LexicalDC->addDeclInternal(ToProperty);
3615 
3616  ToProperty->setPropertyAttributes(D->getPropertyAttributes());
3617  ToProperty->setPropertyAttributesAsWritten(
3619  ToProperty->setGetterName(Importer.Import(D->getGetterName()),
3620  Importer.Import(D->getGetterNameLoc()));
3621  ToProperty->setSetterName(Importer.Import(D->getSetterName()),
3622  Importer.Import(D->getSetterNameLoc()));
3623  ToProperty->setGetterMethodDecl(
3624  cast_or_null<ObjCMethodDecl>(Importer.Import(D->getGetterMethodDecl())));
3625  ToProperty->setSetterMethodDecl(
3626  cast_or_null<ObjCMethodDecl>(Importer.Import(D->getSetterMethodDecl())));
3627  ToProperty->setPropertyIvarDecl(
3628  cast_or_null<ObjCIvarDecl>(Importer.Import(D->getPropertyIvarDecl())));
3629  return ToProperty;
3630 }
3631 
3633  ObjCPropertyDecl *Property = cast_or_null<ObjCPropertyDecl>(
3634  Importer.Import(D->getPropertyDecl()));
3635  if (!Property)
3636  return nullptr;
3637 
3638  DeclContext *DC = Importer.ImportContext(D->getDeclContext());
3639  if (!DC)
3640  return nullptr;
3641 
3642  // Import the lexical declaration context.
3643  DeclContext *LexicalDC = DC;
3644  if (D->getDeclContext() != D->getLexicalDeclContext()) {
3645  LexicalDC = Importer.ImportContext(D->getLexicalDeclContext());
3646  if (!LexicalDC)
3647  return nullptr;
3648  }
3649 
3650  ObjCImplDecl *InImpl = dyn_cast<ObjCImplDecl>(LexicalDC);
3651  if (!InImpl)
3652  return nullptr;
3653 
3654  // Import the ivar (for an @synthesize).
3655  ObjCIvarDecl *Ivar = nullptr;
3656  if (D->getPropertyIvarDecl()) {
3657  Ivar = cast_or_null<ObjCIvarDecl>(
3658  Importer.Import(D->getPropertyIvarDecl()));
3659  if (!Ivar)
3660  return nullptr;
3661  }
3662 
3663  ObjCPropertyImplDecl *ToImpl
3664  = InImpl->FindPropertyImplDecl(Property->getIdentifier(),
3665  Property->getQueryKind());
3666  if (!ToImpl) {
3667  ToImpl = ObjCPropertyImplDecl::Create(Importer.getToContext(), DC,
3668  Importer.Import(D->getLocStart()),
3669  Importer.Import(D->getLocation()),
3670  Property,
3672  Ivar,
3673  Importer.Import(D->getPropertyIvarDeclLoc()));
3674  ToImpl->setLexicalDeclContext(LexicalDC);
3675  Importer.Imported(D, ToImpl);
3676  LexicalDC->addDeclInternal(ToImpl);
3677  } else {
3678  // Check that we have the same kind of property implementation (@synthesize
3679  // vs. @dynamic).
3680  if (D->getPropertyImplementation() != ToImpl->getPropertyImplementation()) {
3681  Importer.ToDiag(ToImpl->getLocation(),
3682  diag::err_odr_objc_property_impl_kind_inconsistent)
3683  << Property->getDeclName()
3684  << (ToImpl->getPropertyImplementation()
3686  Importer.FromDiag(D->getLocation(),
3687  diag::note_odr_objc_property_impl_kind)
3688  << D->getPropertyDecl()->getDeclName()
3690  return nullptr;
3691  }
3692 
3693  // For @synthesize, check that we have the same
3695  Ivar != ToImpl->getPropertyIvarDecl()) {
3696  Importer.ToDiag(ToImpl->getPropertyIvarDeclLoc(),
3697  diag::err_odr_objc_synthesize_ivar_inconsistent)
3698  << Property->getDeclName()
3699  << ToImpl->getPropertyIvarDecl()->getDeclName()
3700  << Ivar->getDeclName();
3701  Importer.FromDiag(D->getPropertyIvarDeclLoc(),
3702  diag::note_odr_objc_synthesize_ivar_here)
3703  << D->getPropertyIvarDecl()->getDeclName();
3704  return nullptr;
3705  }
3706 
3707  // Merge the existing implementation with the new implementation.
3708  Importer.Imported(D, ToImpl);
3709  }
3710 
3711  return ToImpl;
3712 }
3713 
3715  // For template arguments, we adopt the translation unit as our declaration
3716  // context. This context will be fixed when the actual template declaration
3717  // is created.
3718 
3719  // FIXME: Import default argument.
3720  return TemplateTypeParmDecl::Create(Importer.getToContext(),
3721  Importer.getToContext().getTranslationUnitDecl(),
3722  Importer.Import(D->getLocStart()),
3723  Importer.Import(D->getLocation()),
3724  D->getDepth(),
3725  D->getIndex(),
3726  Importer.Import(D->getIdentifier()),
3728  D->isParameterPack());
3729 }
3730 
3731 Decl *
3733  // Import the name of this declaration.
3734  DeclarationName Name = Importer.Import(D->getDeclName());
3735  if (D->getDeclName() && !Name)
3736  return nullptr;
3737 
3738  // Import the location of this declaration.
3739  SourceLocation Loc = Importer.Import(D->getLocation());
3740 
3741  // Import the type of this declaration.
3742  QualType T = Importer.Import(D->getType());
3743  if (T.isNull())
3744  return nullptr;
3745 
3746  // Import type-source information.
3747  TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo());
3748  if (D->getTypeSourceInfo() && !TInfo)
3749  return nullptr;
3750 
3751  // FIXME: Import default argument.
3752 
3753  return NonTypeTemplateParmDecl::Create(Importer.getToContext(),
3754  Importer.getToContext().getTranslationUnitDecl(),
3755  Importer.Import(D->getInnerLocStart()),
3756  Loc, D->getDepth(), D->getPosition(),
3757  Name.getAsIdentifierInfo(),
3758  T, D->isParameterPack(), TInfo);
3759 }
3760 
3761 Decl *
3763  // Import the name of this declaration.
3764  DeclarationName Name = Importer.Import(D->getDeclName());
3765  if (D->getDeclName() && !Name)
3766  return nullptr;
3767 
3768  // Import the location of this declaration.
3769  SourceLocation Loc = Importer.Import(D->getLocation());
3770 
3771  // Import template parameters.
3772  TemplateParameterList *TemplateParams
3774  if (!TemplateParams)
3775  return nullptr;
3776 
3777  // FIXME: Import default argument.
3778 
3779  return TemplateTemplateParmDecl::Create(Importer.getToContext(),
3780  Importer.getToContext().getTranslationUnitDecl(),
3781  Loc, D->getDepth(), D->getPosition(),
3782  D->isParameterPack(),
3783  Name.getAsIdentifierInfo(),
3784  TemplateParams);
3785 }
3786 
3788  // If this record has a definition in the translation unit we're coming from,
3789  // but this particular declaration is not that definition, import the
3790  // definition and map to that.
3791  CXXRecordDecl *Definition
3792  = cast_or_null<CXXRecordDecl>(D->getTemplatedDecl()->getDefinition());
3793  if (Definition && Definition != D->getTemplatedDecl()) {
3794  Decl *ImportedDef
3795  = Importer.Import(Definition->getDescribedClassTemplate());
3796  if (!ImportedDef)
3797  return nullptr;
3798 
3799  return Importer.Imported(D, ImportedDef);
3800  }
3801 
3802  // Import the major distinguishing characteristics of this class template.
3803  DeclContext *DC, *LexicalDC;
3804  DeclarationName Name;
3805  SourceLocation Loc;
3806  NamedDecl *ToD;
3807  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
3808  return nullptr;
3809  if (ToD)
3810  return ToD;
3811 
3812  // We may already have a template of the same name; try to find and match it.
3813  if (!DC->isFunctionOrMethod()) {
3814  SmallVector<NamedDecl *, 4> ConflictingDecls;
3815  SmallVector<NamedDecl *, 2> FoundDecls;
3816  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
3817  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
3818  if (!FoundDecls[I]->isInIdentifierNamespace(Decl::IDNS_Ordinary))
3819  continue;
3820 
3821  Decl *Found = FoundDecls[I];
3822  if (ClassTemplateDecl *FoundTemplate
3823  = dyn_cast<ClassTemplateDecl>(Found)) {
3824  if (IsStructuralMatch(D, FoundTemplate)) {
3825  // The class templates structurally match; call it the same template.
3826  // FIXME: We may be filling in a forward declaration here. Handle
3827  // this case!
3828  Importer.Imported(D->getTemplatedDecl(),
3829  FoundTemplate->getTemplatedDecl());
3830  return Importer.Imported(D, FoundTemplate);
3831  }
3832  }
3833 
3834  ConflictingDecls.push_back(FoundDecls[I]);
3835  }
3836 
3837  if (!ConflictingDecls.empty()) {
3838  Name = Importer.HandleNameConflict(Name, DC, Decl::IDNS_Ordinary,
3839  ConflictingDecls.data(),
3840  ConflictingDecls.size());
3841  }
3842 
3843  if (!Name)
3844  return nullptr;
3845  }
3846 
3847  CXXRecordDecl *DTemplated = D->getTemplatedDecl();
3848 
3849  // Create the declaration that is being templated.
3850  CXXRecordDecl *D2Templated = cast_or_null<CXXRecordDecl>(
3851  Importer.Import(DTemplated));
3852  if (!D2Templated)
3853  return nullptr;
3854 
3855  // Resolve possible cyclic import.
3856  if (Decl *AlreadyImported = Importer.GetAlreadyImportedOrNull(D))
3857  return AlreadyImported;
3858 
3859  // Create the class template declaration itself.
3860  TemplateParameterList *TemplateParams
3862  if (!TemplateParams)
3863  return nullptr;
3864 
3865  ClassTemplateDecl *D2 = ClassTemplateDecl::Create(Importer.getToContext(), DC,
3866  Loc, Name, TemplateParams,
3867  D2Templated);
3868  D2Templated->setDescribedClassTemplate(D2);
3869 
3870  D2->setAccess(D->getAccess());
3871  D2->setLexicalDeclContext(LexicalDC);
3872  LexicalDC->addDeclInternal(D2);
3873 
3874  // Note the relationship between the class templates.
3875  Importer.Imported(D, D2);
3876  Importer.Imported(DTemplated, D2Templated);
3877 
3878  if (DTemplated->isCompleteDefinition() &&
3879  !D2Templated->isCompleteDefinition()) {
3880  // FIXME: Import definition!
3881  }
3882 
3883  return D2;
3884 }
3885 
3888  // If this record has a definition in the translation unit we're coming from,
3889  // but this particular declaration is not that definition, import the
3890  // definition and map to that.
3891  TagDecl *Definition = D->getDefinition();
3892  if (Definition && Definition != D) {
3893  Decl *ImportedDef = Importer.Import(Definition);
3894  if (!ImportedDef)
3895  return nullptr;
3896 
3897  return Importer.Imported(D, ImportedDef);
3898  }
3899 
3900  ClassTemplateDecl *ClassTemplate
3901  = cast_or_null<ClassTemplateDecl>(Importer.Import(
3902  D->getSpecializedTemplate()));
3903  if (!ClassTemplate)
3904  return nullptr;
3905 
3906  // Import the context of this declaration.
3907  DeclContext *DC = ClassTemplate->getDeclContext();
3908  if (!DC)
3909  return nullptr;
3910 
3911  DeclContext *LexicalDC = DC;
3912  if (D->getDeclContext() != D->getLexicalDeclContext()) {
3913  LexicalDC = Importer.ImportContext(D->getLexicalDeclContext());
3914  if (!LexicalDC)
3915  return nullptr;
3916  }
3917 
3918  // Import the location of this declaration.
3919  SourceLocation StartLoc = Importer.Import(D->getLocStart());
3920  SourceLocation IdLoc = Importer.Import(D->getLocation());
3921 
3922  // Import template arguments.
3923  SmallVector<TemplateArgument, 2> TemplateArgs;
3925  D->getTemplateArgs().size(),
3926  TemplateArgs))
3927  return nullptr;
3928 
3929  // Try to find an existing specialization with these template arguments.
3930  void *InsertPos = nullptr;
3932  = ClassTemplate->findSpecialization(TemplateArgs, InsertPos);
3933  if (D2) {
3934  // We already have a class template specialization with these template
3935  // arguments.
3936 
3937  // FIXME: Check for specialization vs. instantiation errors.
3938 
3939  if (RecordDecl *FoundDef = D2->getDefinition()) {
3940  if (!D->isCompleteDefinition() || IsStructuralMatch(D, FoundDef)) {
3941  // The record types structurally match, or the "from" translation
3942  // unit only had a forward declaration anyway; call it the same
3943  // function.
3944  return Importer.Imported(D, FoundDef);
3945  }
3946  }
3947  } else {
3948  // Create a new specialization.
3949  if (ClassTemplatePartialSpecializationDecl *PartialSpec =
3950  dyn_cast<ClassTemplatePartialSpecializationDecl>(D)) {
3951 
3952  // Import TemplateArgumentListInfo
3953  TemplateArgumentListInfo ToTAInfo;
3954  auto &ASTTemplateArgs = *PartialSpec->getTemplateArgsAsWritten();
3955  for (unsigned I = 0, E = ASTTemplateArgs.NumTemplateArgs; I < E; ++I) {
3956  if (auto ToLoc = ImportTemplateArgumentLoc(ASTTemplateArgs[I]))
3957  ToTAInfo.addArgument(*ToLoc);
3958  else
3959  return nullptr;
3960  }
3961 
3962  QualType CanonInjType = Importer.Import(
3963  PartialSpec->getInjectedSpecializationType());
3964  if (CanonInjType.isNull())
3965  return nullptr;
3966  CanonInjType = CanonInjType.getCanonicalType();
3967 
3969  PartialSpec->getTemplateParameters());
3970  if (!ToTPList && PartialSpec->getTemplateParameters())
3971  return nullptr;
3972 
3974  Importer.getToContext(), D->getTagKind(), DC, StartLoc, IdLoc,
3975  ToTPList, ClassTemplate,
3976  llvm::makeArrayRef(TemplateArgs.data(), TemplateArgs.size()),
3977  ToTAInfo, CanonInjType, nullptr);
3978 
3979  } else {
3980  D2 = ClassTemplateSpecializationDecl::Create(Importer.getToContext(),
3981  D->getTagKind(), DC,
3982  StartLoc, IdLoc,
3983  ClassTemplate,
3984  TemplateArgs,
3985  /*PrevDecl=*/nullptr);
3986  }
3987 
3989 
3990  // Add this specialization to the class template.
3991  ClassTemplate->AddSpecialization(D2, InsertPos);
3992 
3993  // Import the qualifier, if any.
3994  D2->setQualifierInfo(Importer.Import(D->getQualifierLoc()));
3995 
3996  Importer.Imported(D, D2);
3997 
3998  if (auto *TSI = D->getTypeAsWritten()) {
3999  TypeSourceInfo *TInfo = Importer.Import(TSI);
4000  if (!TInfo)
4001  return nullptr;
4002  D2->setTypeAsWritten(TInfo);
4003  D2->setTemplateKeywordLoc(Importer.Import(D->getTemplateKeywordLoc()));
4004  D2->setExternLoc(Importer.Import(D->getExternLoc()));
4005  }
4006 
4007  SourceLocation POI = Importer.Import(D->getPointOfInstantiation());
4008  if (POI.isValid())
4009  D2->setPointOfInstantiation(POI);
4010  else if (D->getPointOfInstantiation().isValid())
4011  return nullptr;
4012 
4014 
4015  // Add the specialization to this context.
4016  D2->setLexicalDeclContext(LexicalDC);
4017  LexicalDC->addDeclInternal(D2);
4018  }
4019  Importer.Imported(D, D2);
4020  if (D->isCompleteDefinition() && ImportDefinition(D, D2))
4021  return nullptr;
4022 
4023  return D2;
4024 }
4025 
4027  // If this variable has a definition in the translation unit we're coming
4028  // from,
4029  // but this particular declaration is not that definition, import the
4030  // definition and map to that.
4031  VarDecl *Definition =
4032  cast_or_null<VarDecl>(D->getTemplatedDecl()->getDefinition());
4033  if (Definition && Definition != D->getTemplatedDecl()) {
4034  Decl *ImportedDef = Importer.Import(Definition->getDescribedVarTemplate());
4035  if (!ImportedDef)
4036  return nullptr;
4037 
4038  return Importer.Imported(D, ImportedDef);
4039  }
4040 
4041  // Import the major distinguishing characteristics of this variable template.
4042  DeclContext *DC, *LexicalDC;
4043  DeclarationName Name;
4044  SourceLocation Loc;
4045  NamedDecl *ToD;
4046  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
4047  return nullptr;
4048  if (ToD)
4049  return ToD;
4050 
4051  // We may already have a template of the same name; try to find and match it.
4052  assert(!DC->isFunctionOrMethod() &&
4053  "Variable templates cannot be declared at function scope");
4054  SmallVector<NamedDecl *, 4> ConflictingDecls;
4055  SmallVector<NamedDecl *, 2> FoundDecls;
4056  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
4057  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
4058  if (!FoundDecls[I]->isInIdentifierNamespace(Decl::IDNS_Ordinary))
4059  continue;
4060 
4061  Decl *Found = FoundDecls[I];
4062  if (VarTemplateDecl *FoundTemplate = dyn_cast<VarTemplateDecl>(Found)) {
4063  if (IsStructuralMatch(D, FoundTemplate)) {
4064  // The variable templates structurally match; call it the same template.
4065  Importer.Imported(D->getTemplatedDecl(),
4066  FoundTemplate->getTemplatedDecl());
4067  return Importer.Imported(D, FoundTemplate);
4068  }
4069  }
4070 
4071  ConflictingDecls.push_back(FoundDecls[I]);
4072  }
4073 
4074  if (!ConflictingDecls.empty()) {
4075  Name = Importer.HandleNameConflict(Name, DC, Decl::IDNS_Ordinary,
4076  ConflictingDecls.data(),
4077  ConflictingDecls.size());
4078  }
4079 
4080  if (!Name)
4081  return nullptr;
4082 
4083  VarDecl *DTemplated = D->getTemplatedDecl();
4084 
4085  // Import the type.
4086  QualType T = Importer.Import(DTemplated->getType());
4087  if (T.isNull())
4088  return nullptr;
4089 
4090  // Create the declaration that is being templated.
4091  SourceLocation StartLoc = Importer.Import(DTemplated->getLocStart());
4092  SourceLocation IdLoc = Importer.Import(DTemplated->getLocation());
4093  TypeSourceInfo *TInfo = Importer.Import(DTemplated->getTypeSourceInfo());
4094  VarDecl *D2Templated = VarDecl::Create(Importer.getToContext(), DC, StartLoc,
4095  IdLoc, Name.getAsIdentifierInfo(), T,
4096  TInfo, DTemplated->getStorageClass());
4097  D2Templated->setAccess(DTemplated->getAccess());
4098  D2Templated->setQualifierInfo(Importer.Import(DTemplated->getQualifierLoc()));
4099  D2Templated->setLexicalDeclContext(LexicalDC);
4100 
4101  // Importer.Imported(DTemplated, D2Templated);
4102  // LexicalDC->addDeclInternal(D2Templated);
4103 
4104  // Merge the initializer.
4105  if (ImportDefinition(DTemplated, D2Templated))
4106  return nullptr;
4107 
4108  // Create the variable template declaration itself.
4109  TemplateParameterList *TemplateParams =
4111  if (!TemplateParams)
4112  return nullptr;
4113 
4115  Importer.getToContext(), DC, Loc, Name, TemplateParams, D2Templated);
4116  D2Templated->setDescribedVarTemplate(D2);
4117 
4118  D2->setAccess(D->getAccess());
4119  D2->setLexicalDeclContext(LexicalDC);
4120  LexicalDC->addDeclInternal(D2);
4121 
4122  // Note the relationship between the variable templates.
4123  Importer.Imported(D, D2);
4124  Importer.Imported(DTemplated, D2Templated);
4125 
4126  if (DTemplated->isThisDeclarationADefinition() &&
4127  !D2Templated->isThisDeclarationADefinition()) {
4128  // FIXME: Import definition!
4129  }
4130 
4131  return D2;
4132 }
4133 
4136  // If this record has a definition in the translation unit we're coming from,
4137  // but this particular declaration is not that definition, import the
4138  // definition and map to that.
4139  VarDecl *Definition = D->getDefinition();
4140  if (Definition && Definition != D) {
4141  Decl *ImportedDef = Importer.Import(Definition);
4142  if (!ImportedDef)
4143  return nullptr;
4144 
4145  return Importer.Imported(D, ImportedDef);
4146  }
4147 
4148  VarTemplateDecl *VarTemplate = cast_or_null<VarTemplateDecl>(
4149  Importer.Import(D->getSpecializedTemplate()));
4150  if (!VarTemplate)
4151  return nullptr;
4152 
4153  // Import the context of this declaration.
4154  DeclContext *DC = VarTemplate->getDeclContext();
4155  if (!DC)
4156  return nullptr;
4157 
4158  DeclContext *LexicalDC = DC;
4159  if (D->getDeclContext() != D->getLexicalDeclContext()) {
4160  LexicalDC = Importer.ImportContext(D->getLexicalDeclContext());
4161  if (!LexicalDC)
4162  return nullptr;
4163  }
4164 
4165  // Import the location of this declaration.
4166  SourceLocation StartLoc = Importer.Import(D->getLocStart());
4167  SourceLocation IdLoc = Importer.Import(D->getLocation());
4168 
4169  // Import template arguments.
4170  SmallVector<TemplateArgument, 2> TemplateArgs;
4172  D->getTemplateArgs().size(), TemplateArgs))
4173  return nullptr;
4174 
4175  // Try to find an existing specialization with these template arguments.
4176  void *InsertPos = nullptr;
4178  TemplateArgs, InsertPos);
4179  if (D2) {
4180  // We already have a variable template specialization with these template
4181  // arguments.
4182 
4183  // FIXME: Check for specialization vs. instantiation errors.
4184 
4185  if (VarDecl *FoundDef = D2->getDefinition()) {
4186  if (!D->isThisDeclarationADefinition() ||
4187  IsStructuralMatch(D, FoundDef)) {
4188  // The record types structurally match, or the "from" translation
4189  // unit only had a forward declaration anyway; call it the same
4190  // variable.
4191  return Importer.Imported(D, FoundDef);
4192  }
4193  }
4194  } else {
4195 
4196  // Import the type.
4197  QualType T = Importer.Import(D->getType());
4198  if (T.isNull())
4199  return nullptr;
4200  TypeSourceInfo *TInfo = Importer.Import(D->getTypeSourceInfo());
4201 
4202  // Create a new specialization.
4204  Importer.getToContext(), DC, StartLoc, IdLoc, VarTemplate, T, TInfo,
4205  D->getStorageClass(), TemplateArgs);
4208 
4209  // Add this specialization to the class template.
4210  VarTemplate->AddSpecialization(D2, InsertPos);
4211 
4212  // Import the qualifier, if any.
4213  D2->setQualifierInfo(Importer.Import(D->getQualifierLoc()));
4214 
4215  // Add the specialization to this context.
4216  D2->setLexicalDeclContext(LexicalDC);
4217  LexicalDC->addDeclInternal(D2);
4218  }
4219  Importer.Imported(D, D2);
4220 
4222  return nullptr;
4223 
4224  return D2;
4225 }
4226 
4228  DeclContext *DC, *LexicalDC;
4229  DeclarationName Name;
4230  SourceLocation Loc;
4231  NamedDecl *ToD;
4232 
4233  if (ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
4234  return nullptr;
4235 
4236  if (ToD)
4237  return ToD;
4238 
4239  // Try to find a function in our own ("to") context with the same name, same
4240  // type, and in the same context as the function we're importing.
4241  if (!LexicalDC->isFunctionOrMethod()) {
4242  unsigned IDNS = Decl::IDNS_Ordinary;
4243  SmallVector<NamedDecl *, 2> FoundDecls;
4244  DC->getRedeclContext()->localUncachedLookup(Name, FoundDecls);
4245  for (unsigned I = 0, N = FoundDecls.size(); I != N; ++I) {
4246  if (!FoundDecls[I]->isInIdentifierNamespace(IDNS))
4247  continue;
4248 
4249  if (FunctionTemplateDecl *FoundFunction =
4250  dyn_cast<FunctionTemplateDecl>(FoundDecls[I])) {
4251  if (FoundFunction->hasExternalFormalLinkage() &&
4252  D->hasExternalFormalLinkage()) {
4253  if (IsStructuralMatch(D, FoundFunction)) {
4254  Importer.Imported(D, FoundFunction);
4255  // FIXME: Actually try to merge the body and other attributes.
4256  return FoundFunction;
4257  }
4258  }
4259  }
4260  }
4261  }
4262 
4263  TemplateParameterList *Params =
4265  if (!Params)
4266  return nullptr;
4267 
4268  FunctionDecl *TemplatedFD =
4269  cast_or_null<FunctionDecl>(Importer.Import(D->getTemplatedDecl()));
4270  if (!TemplatedFD)
4271  return nullptr;
4272 
4274  Importer.getToContext(), DC, Loc, Name, Params, TemplatedFD);
4275 
4276  TemplatedFD->setDescribedFunctionTemplate(ToFunc);
4277  ToFunc->setAccess(D->getAccess());
4278  ToFunc->setLexicalDeclContext(LexicalDC);
4279  Importer.Imported(D, ToFunc);
4280 
4281  LexicalDC->addDeclInternal(ToFunc);
4282  return ToFunc;
4283 }
4284 
4285 //----------------------------------------------------------------------------
4286 // Import Statements
4287 //----------------------------------------------------------------------------
4288 
4290  if (DG.isNull())
4291  return DeclGroupRef::Create(Importer.getToContext(), nullptr, 0);
4292  size_t NumDecls = DG.end() - DG.begin();
4293  SmallVector<Decl *, 1> ToDecls(NumDecls);
4294  auto &_Importer = this->Importer;
4295  std::transform(DG.begin(), DG.end(), ToDecls.begin(),
4296  [&_Importer](Decl *D) -> Decl * {
4297  return _Importer.Import(D);
4298  });
4299  return DeclGroupRef::Create(Importer.getToContext(),
4300  ToDecls.begin(),
4301  NumDecls);
4302 }
4303 
4305  Importer.FromDiag(S->getLocStart(), diag::err_unsupported_ast_node)
4306  << S->getStmtClassName();
4307  return nullptr;
4308  }
4309 
4310 
4313  for (unsigned I = 0, E = S->getNumOutputs(); I != E; I++) {
4314  IdentifierInfo *ToII = Importer.Import(S->getOutputIdentifier(I));
4315  // ToII is nullptr when no symbolic name is given for output operand
4316  // see ParseStmtAsm::ParseAsmOperandsOpt
4317  if (!ToII && S->getOutputIdentifier(I))
4318  return nullptr;
4319  Names.push_back(ToII);
4320  }
4321  for (unsigned I = 0, E = S->getNumInputs(); I != E; I++) {
4322  IdentifierInfo *ToII = Importer.Import(S->getInputIdentifier(I));
4323  // ToII is nullptr when no symbolic name is given for input operand
4324  // see ParseStmtAsm::ParseAsmOperandsOpt
4325  if (!ToII && S->getInputIdentifier(I))
4326  return nullptr;
4327  Names.push_back(ToII);
4328  }
4329 
4331  for (unsigned I = 0, E = S->getNumClobbers(); I != E; I++) {
4332  StringLiteral *Clobber = cast_or_null<StringLiteral>(
4333  Importer.Import(S->getClobberStringLiteral(I)));
4334  if (!Clobber)
4335  return nullptr;
4336  Clobbers.push_back(Clobber);
4337  }
4338 
4339  SmallVector<StringLiteral *, 4> Constraints;
4340  for (unsigned I = 0, E = S->getNumOutputs(); I != E; I++) {
4341  StringLiteral *Output = cast_or_null<StringLiteral>(
4342  Importer.Import(S->getOutputConstraintLiteral(I)));
4343  if (!Output)
4344  return nullptr;
4345  Constraints.push_back(Output);
4346  }
4347 
4348  for (unsigned I = 0, E = S->getNumInputs(); I != E; I++) {
4349  StringLiteral *Input = cast_or_null<StringLiteral>(
4350  Importer.Import(S->getInputConstraintLiteral(I)));
4351  if (!Input)
4352  return nullptr;
4353  Constraints.push_back(Input);
4354  }
4355 
4357  if (ImportContainerChecked(S->outputs(), Exprs))
4358  return nullptr;
4359 
4360  if (ImportArrayChecked(S->inputs(), Exprs.begin() + S->getNumOutputs()))
4361  return nullptr;
4362 
4363  StringLiteral *AsmStr = cast_or_null<StringLiteral>(
4364  Importer.Import(S->getAsmString()));
4365  if (!AsmStr)
4366  return nullptr;
4367 
4368  return new (Importer.getToContext()) GCCAsmStmt(
4369  Importer.getToContext(),
4370  Importer.Import(S->getAsmLoc()),
4371  S->isSimple(),
4372  S->isVolatile(),
4373  S->getNumOutputs(),
4374  S->getNumInputs(),
4375  Names.data(),
4376  Constraints.data(),
4377  Exprs.data(),
4378  AsmStr,
4379  S->getNumClobbers(),
4380  Clobbers.data(),
4381  Importer.Import(S->getRParenLoc()));
4382 }
4383 
4386  for (Decl *ToD : ToDG) {
4387  if (!ToD)
4388  return nullptr;
4389  }
4390  SourceLocation ToStartLoc = Importer.Import(S->getStartLoc());
4391  SourceLocation ToEndLoc = Importer.Import(S->getEndLoc());
4392  return new (Importer.getToContext()) DeclStmt(ToDG, ToStartLoc, ToEndLoc);
4393 }
4394 
4396  SourceLocation ToSemiLoc = Importer.Import(S->getSemiLoc());
4397  return new (Importer.getToContext()) NullStmt(ToSemiLoc,
4398  S->hasLeadingEmptyMacro());
4399 }
4400 
4402  llvm::SmallVector<Stmt *, 8> ToStmts(S->size());
4403 
4404  if (ImportContainerChecked(S->body(), ToStmts))
4405  return nullptr;
4406 
4407  SourceLocation ToLBraceLoc = Importer.Import(S->getLBracLoc());
4408  SourceLocation ToRBraceLoc = Importer.Import(S->getRBracLoc());
4409  return CompoundStmt::Create(Importer.getToContext(), ToStmts, ToLBraceLoc,
4410  ToRBraceLoc);
4411 }
4412 
4414  Expr *ToLHS = Importer.Import(S->getLHS());
4415  if (!ToLHS)
4416  return nullptr;
4417  Expr *ToRHS = Importer.Import(S->getRHS());
4418  if (!ToRHS && S->getRHS())
4419  return nullptr;
4420  Stmt *ToSubStmt = Importer.Import(S->getSubStmt());
4421  if (!ToSubStmt && S->getSubStmt())
4422  return nullptr;
4423  SourceLocation ToCaseLoc = Importer.Import(S->getCaseLoc());
4424  SourceLocation ToEllipsisLoc = Importer.Import(S->getEllipsisLoc());
4425  SourceLocation ToColonLoc = Importer.Import(S->getColonLoc());
4426  CaseStmt *ToStmt = new (Importer.getToContext())
4427  CaseStmt(ToLHS, ToRHS, ToCaseLoc, ToEllipsisLoc, ToColonLoc);
4428  ToStmt->setSubStmt(ToSubStmt);
4429  return ToStmt;
4430 }
4431 
4433  SourceLocation ToDefaultLoc = Importer.Import(S->getDefaultLoc());
4434  SourceLocation ToColonLoc = Importer.Import(S->getColonLoc());
4435  Stmt *ToSubStmt = Importer.Import(S->getSubStmt());
4436  if (!ToSubStmt && S->getSubStmt())
4437  return nullptr;
4438  return new (Importer.getToContext()) DefaultStmt(ToDefaultLoc, ToColonLoc,
4439  ToSubStmt);
4440 }
4441 
4443  SourceLocation ToIdentLoc = Importer.Import(S->getIdentLoc());
4444  LabelDecl *ToLabelDecl =
4445  cast_or_null<LabelDecl>(Importer.Import(S->getDecl()));
4446  if (!ToLabelDecl && S->getDecl())
4447  return nullptr;
4448  Stmt *ToSubStmt = Importer.Import(S->getSubStmt());
4449  if (!ToSubStmt && S->getSubStmt())
4450  return nullptr;
4451  return new (Importer.getToContext()) LabelStmt(ToIdentLoc, ToLabelDecl,
4452  ToSubStmt);
4453 }
4454 
4456  SourceLocation ToAttrLoc = Importer.Import(S->getAttrLoc());
4457  ArrayRef<const Attr*> FromAttrs(S->getAttrs());
4458  SmallVector<const Attr *, 1> ToAttrs(FromAttrs.size());
4459  ASTContext &_ToContext = Importer.getToContext();
4460  std::transform(FromAttrs.begin(), FromAttrs.end(), ToAttrs.begin(),
4461  [&_ToContext](const Attr *A) -> const Attr * {
4462  return A->clone(_ToContext);
4463  });
4464  for (const Attr *ToA : ToAttrs) {
4465  if (!ToA)
4466  return nullptr;
4467  }
4468  Stmt *ToSubStmt = Importer.Import(S->getSubStmt());
4469  if (!ToSubStmt && S->getSubStmt())
4470  return nullptr;
4471  return AttributedStmt::Create(Importer.getToContext(), ToAttrLoc,
4472  ToAttrs, ToSubStmt);
4473 }
4474 
4476  SourceLocation ToIfLoc = Importer.Import(S->getIfLoc());
4477  Stmt *ToInit = Importer.Import(S->getInit());
4478  if (!ToInit && S->getInit())
4479  return nullptr;
4480  VarDecl *ToConditionVariable = nullptr;
4481  if (VarDecl *FromConditionVariable = S->getConditionVariable()) {
4482  ToConditionVariable =
4483  dyn_cast_or_null<VarDecl>(Importer.Import(FromConditionVariable));
4484  if (!ToConditionVariable)
4485  return nullptr;
4486  }
4487  Expr *ToCondition = Importer.Import(S->getCond());
4488  if (!ToCondition && S->getCond())
4489  return nullptr;
4490  Stmt *ToThenStmt = Importer.Import(S->getThen());
4491  if (!ToThenStmt && S->getThen())
4492  return nullptr;
4493  SourceLocation ToElseLoc = Importer.Import(S->getElseLoc());
4494  Stmt *ToElseStmt = Importer.Import(S->getElse());
4495  if (!ToElseStmt && S->getElse())
4496  return nullptr;
4497  return new (Importer.getToContext()) IfStmt(Importer.getToContext(),
4498  ToIfLoc, S->isConstexpr(),
4499  ToInit,
4500  ToConditionVariable,
4501  ToCondition, ToThenStmt,
4502  ToElseLoc, ToElseStmt);
4503 }
4504 
4506  Stmt *ToInit = Importer.Import(S->getInit());
4507  if (!ToInit && S->getInit())
4508  return nullptr;
4509  VarDecl *ToConditionVariable = nullptr;
4510  if (VarDecl *FromConditionVariable = S->getConditionVariable()) {
4511  ToConditionVariable =
4512  dyn_cast_or_null<VarDecl>(Importer.Import(FromConditionVariable));
4513  if (!ToConditionVariable)
4514  return nullptr;
4515  }
4516  Expr *ToCondition = Importer.Import(S->getCond());
4517  if (!ToCondition && S->getCond())
4518  return nullptr;
4519  SwitchStmt *ToStmt = new (Importer.getToContext()) SwitchStmt(
4520  Importer.getToContext(), ToInit,
4521  ToConditionVariable, ToCondition);
4522  Stmt *ToBody = Importer.Import(S->getBody());
4523  if (!ToBody && S->getBody())
4524  return nullptr;
4525  ToStmt->setBody(ToBody);
4526  ToStmt->setSwitchLoc(Importer.Import(S->getSwitchLoc()));
4527  // Now we have to re-chain the cases.
4528  SwitchCase *LastChainedSwitchCase = nullptr;
4529  for (SwitchCase *SC = S->getSwitchCaseList(); SC != nullptr;
4530  SC = SC->getNextSwitchCase()) {
4531  SwitchCase *ToSC = dyn_cast_or_null<SwitchCase>(Importer.Import(SC));
4532  if (!ToSC)
4533  return nullptr;
4534  if (LastChainedSwitchCase)
4535  LastChainedSwitchCase->setNextSwitchCase(ToSC);
4536  else
4537  ToStmt->setSwitchCaseList(ToSC);
4538  LastChainedSwitchCase = ToSC;
4539  }
4540  return ToStmt;
4541 }
4542 
4544  VarDecl *ToConditionVariable = nullptr;
4545  if (VarDecl *FromConditionVariable = S->getConditionVariable()) {
4546  ToConditionVariable =
4547  dyn_cast_or_null<VarDecl>(Importer.Import(FromConditionVariable));
4548  if (!ToConditionVariable)
4549  return nullptr;
4550  }
4551  Expr *ToCondition = Importer.Import(S->getCond());
4552  if (!ToCondition && S->getCond())
4553  return nullptr;
4554  Stmt *ToBody = Importer.Import(S->getBody());
4555  if (!ToBody && S->getBody())
4556  return nullptr;
4557  SourceLocation ToWhileLoc = Importer.Import(S->getWhileLoc());
4558  return new (Importer.getToContext()) WhileStmt(Importer.getToContext(),
4559  ToConditionVariable,
4560  ToCondition, ToBody,
4561  ToWhileLoc);
4562 }
4563 
4565  Stmt *ToBody = Importer.Import(S->getBody());
4566  if (!ToBody && S->getBody())
4567  return nullptr;
4568  Expr *ToCondition = Importer.Import(S->getCond());
4569  if (!ToCondition && S->getCond())
4570  return nullptr;
4571  SourceLocation ToDoLoc = Importer.Import(S->getDoLoc());
4572  SourceLocation ToWhileLoc = Importer.Import(S->getWhileLoc());
4573  SourceLocation ToRParenLoc = Importer.Import(S->getRParenLoc());
4574  return new (Importer.getToContext()) DoStmt(ToBody, ToCondition,
4575  ToDoLoc, ToWhileLoc,
4576  ToRParenLoc);
4577 }
4578 
4580  Stmt *ToInit = Importer.Import(S->getInit());
4581  if (!ToInit && S->getInit())
4582  return nullptr;
4583  Expr *ToCondition = Importer.Import(S->getCond());
4584  if (!ToCondition && S->getCond())
4585  return nullptr;
4586  VarDecl *ToConditionVariable = nullptr;
4587  if (VarDecl *FromConditionVariable = S->getConditionVariable()) {
4588  ToConditionVariable =
4589  dyn_cast_or_null<VarDecl>(Importer.Import(FromConditionVariable));
4590  if (!ToConditionVariable)
4591  return nullptr;
4592  }
4593  Expr *ToInc = Importer.Import(S->getInc());
4594  if (!ToInc && S->getInc())
4595  return nullptr;
4596  Stmt *ToBody = Importer.Import(S->getBody());
4597  if (!ToBody && S->getBody())
4598  return nullptr;
4599  SourceLocation ToForLoc = Importer.Import(S->getForLoc());
4600  SourceLocation ToLParenLoc = Importer.Import(S->getLParenLoc());
4601  SourceLocation ToRParenLoc = Importer.Import(S->getRParenLoc());
4602  return new (Importer.getToContext()) ForStmt(Importer.getToContext(),
4603  ToInit, ToCondition,
4604  ToConditionVariable,
4605  ToInc, ToBody,
4606  ToForLoc, ToLParenLoc,
4607  ToRParenLoc);
4608 }
4609 
4611  LabelDecl *ToLabel = nullptr;
4612  if (LabelDecl *FromLabel = S->getLabel()) {
4613  ToLabel = dyn_cast_or_null<LabelDecl>(Importer.Import(FromLabel));
4614  if (!ToLabel)
4615  return nullptr;
4616  }
4617  SourceLocation ToGotoLoc = Importer.Import(S->getGotoLoc());
4618  SourceLocation ToLabelLoc = Importer.Import(S->getLabelLoc());
4619  return new (Importer.getToContext()) GotoStmt(ToLabel,
4620  ToGotoLoc, ToLabelLoc);
4621 }
4622 
4624  SourceLocation ToGotoLoc = Importer.Import(S->getGotoLoc());
4625  SourceLocation ToStarLoc = Importer.Import(S->getStarLoc());
4626  Expr *ToTarget = Importer.Import(S->getTarget());
4627  if (!ToTarget && S->getTarget())
4628  return nullptr;
4629  return new (Importer.getToContext()) IndirectGotoStmt(ToGotoLoc, ToStarLoc,
4630  ToTarget);
4631 }
4632 
4634  SourceLocation ToContinueLoc = Importer.Import(S->getContinueLoc());
4635  return new (Importer.getToContext()) ContinueStmt(ToContinueLoc);
4636 }
4637 
4639  SourceLocation ToBreakLoc = Importer.Import(S->getBreakLoc());
4640  return new (Importer.getToContext()) BreakStmt(ToBreakLoc);
4641 }
4642 
4644  SourceLocation ToRetLoc = Importer.Import(S->getReturnLoc());
4645  Expr *ToRetExpr = Importer.Import(S->getRetValue());
4646  if (!ToRetExpr && S->getRetValue())
4647  return nullptr;
4648  VarDecl *NRVOCandidate = const_cast<VarDecl*>(S->getNRVOCandidate());
4649  VarDecl *ToNRVOCandidate = cast_or_null<VarDecl>(Importer.Import(NRVOCandidate));
4650  if (!ToNRVOCandidate && NRVOCandidate)
4651  return nullptr;
4652  return new (Importer.getToContext()) ReturnStmt(ToRetLoc, ToRetExpr,
4653  ToNRVOCandidate);
4654 }
4655 
4657  SourceLocation ToCatchLoc = Importer.Import(S->getCatchLoc());
4658  VarDecl *ToExceptionDecl = nullptr;
4659  if (VarDecl *FromExceptionDecl = S->getExceptionDecl()) {
4660  ToExceptionDecl =
4661  dyn_cast_or_null<VarDecl>(Importer.Import(FromExceptionDecl));
4662  if (!ToExceptionDecl)
4663  return nullptr;
4664  }
4665  Stmt *ToHandlerBlock = Importer.Import(S->getHandlerBlock());
4666  if (!ToHandlerBlock && S->getHandlerBlock())
4667  return nullptr;
4668  return new (Importer.getToContext()) CXXCatchStmt(ToCatchLoc,
4669  ToExceptionDecl,
4670  ToHandlerBlock);
4671 }
4672 
4674  SourceLocation ToTryLoc = Importer.Import(S->getTryLoc());
4675  Stmt *ToTryBlock = Importer.Import(S->getTryBlock());
4676  if (!ToTryBlock && S->getTryBlock())
4677  return nullptr;
4678  SmallVector<Stmt *, 1> ToHandlers(S->getNumHandlers());
4679  for (unsigned HI = 0, HE = S->getNumHandlers(); HI != HE; ++HI) {
4680  CXXCatchStmt *FromHandler = S->getHandler(HI);
4681  if (Stmt *ToHandler = Importer.Import(FromHandler))
4682  ToHandlers[HI] = ToHandler;
4683  else
4684  return nullptr;
4685  }
4686  return CXXTryStmt::Create(Importer.getToContext(), ToTryLoc, ToTryBlock,
4687  ToHandlers);
4688 }
4689 
4691  DeclStmt *ToRange =
4692  dyn_cast_or_null<DeclStmt>(Importer.Import(S->getRangeStmt()));
4693  if (!ToRange && S->getRangeStmt())
4694  return nullptr;
4695  DeclStmt *ToBegin =
4696  dyn_cast_or_null<DeclStmt>(Importer.Import(S->getBeginStmt()));
4697  if (!ToBegin && S->getBeginStmt())
4698  return nullptr;
4699  DeclStmt *ToEnd =
4700  dyn_cast_or_null<DeclStmt>(Importer.Import(S->getEndStmt()));
4701  if (!ToEnd && S->getEndStmt())
4702  return nullptr;
4703  Expr *ToCond = Importer.Import(S->getCond());
4704  if (!ToCond && S->getCond())
4705  return nullptr;
4706  Expr *ToInc = Importer.Import(S->getInc());
4707  if (!ToInc && S->getInc())
4708  return nullptr;
4709  DeclStmt *ToLoopVar =
4710  dyn_cast_or_null<DeclStmt>(Importer.Import(S->getLoopVarStmt()));
4711  if (!ToLoopVar && S->getLoopVarStmt())
4712  return nullptr;
4713  Stmt *ToBody = Importer.Import(S->getBody());
4714  if (!ToBody && S->getBody())
4715  return nullptr;
4716  SourceLocation ToForLoc = Importer.Import(S->getForLoc());
4717  SourceLocation ToCoawaitLoc = Importer.Import(S->getCoawaitLoc());
4718  SourceLocation ToColonLoc = Importer.Import(S->getColonLoc());
4719  SourceLocation ToRParenLoc = Importer.Import(S->getRParenLoc());
4720  return new (Importer.getToContext()) CXXForRangeStmt(ToRange, ToBegin, ToEnd,
4721  ToCond, ToInc,
4722  ToLoopVar, ToBody,
4723  ToForLoc, ToCoawaitLoc,
4724  ToColonLoc, ToRParenLoc);
4725 }
4726 
4728  Stmt *ToElem = Importer.Import(S->getElement());
4729  if (!ToElem && S->getElement())
4730  return nullptr;
4731  Expr *ToCollect = Importer.Import(S->getCollection());
4732  if (!ToCollect && S->getCollection())
4733  return nullptr;
4734  Stmt *ToBody = Importer.Import(S->getBody());
4735  if (!ToBody && S->getBody())
4736  return nullptr;
4737  SourceLocation ToForLoc = Importer.Import(S->getForLoc());
4738  SourceLocation ToRParenLoc = Importer.Import(S->getRParenLoc());
4739  return new (Importer.getToContext()) ObjCForCollectionStmt(ToElem,
4740  ToCollect,
4741  ToBody, ToForLoc,
4742  ToRParenLoc);
4743 }
4744 
4746  SourceLocation ToAtCatchLoc = Importer.Import(S->getAtCatchLoc());
4747  SourceLocation ToRParenLoc = Importer.Import(S->getRParenLoc());
4748  VarDecl *ToExceptionDecl = nullptr;
4749  if (VarDecl *FromExceptionDecl = S->getCatchParamDecl()) {
4750  ToExceptionDecl =
4751  dyn_cast_or_null<VarDecl>(Importer.Import(FromExceptionDecl));
4752  if (!ToExceptionDecl)
4753  return nullptr;
4754  }
4755  Stmt *ToBody = Importer.Import(S->getCatchBody());
4756  if (!ToBody && S->getCatchBody())
4757  return nullptr;
4758  return new (Importer.getToContext()) ObjCAtCatchStmt(ToAtCatchLoc,
4759  ToRParenLoc,
4760  ToExceptionDecl,
4761  ToBody);
4762 }
4763 
4765  SourceLocation ToAtFinallyLoc = Importer.Import(S->getAtFinallyLoc());
4766  Stmt *ToAtFinallyStmt = Importer.Import(S->getFinallyBody());
4767  if (!ToAtFinallyStmt && S->getFinallyBody())
4768  return nullptr;
4769  return new (Importer.getToContext()) ObjCAtFinallyStmt(ToAtFinallyLoc,
4770  ToAtFinallyStmt);
4771 }
4772 
4774  SourceLocation ToAtTryLoc = Importer.Import(S->getAtTryLoc());
4775  Stmt *ToAtTryStmt = Importer.Import(S->getTryBody());
4776  if (!ToAtTryStmt && S->getTryBody())
4777  return nullptr;
4778  SmallVector<Stmt *, 1> ToCatchStmts(S->getNumCatchStmts());
4779  for (unsigned CI = 0, CE = S->getNumCatchStmts(); CI != CE; ++CI) {
4780  ObjCAtCatchStmt *FromCatchStmt = S->getCatchStmt(CI);
4781  if (Stmt *ToCatchStmt = Importer.Import(FromCatchStmt))
4782  ToCatchStmts[CI] = ToCatchStmt;
4783  else
4784  return nullptr;
4785  }
4786  Stmt *ToAtFinallyStmt = Importer.Import(S->getFinallyStmt());
4787  if (!ToAtFinallyStmt && S->getFinallyStmt())
4788  return nullptr;
4789  return ObjCAtTryStmt::Create(Importer.getToContext(),
4790  ToAtTryLoc, ToAtTryStmt,
4791  ToCatchStmts.begin(), ToCatchStmts.size(),
4792  ToAtFinallyStmt);
4793 }
4794 
4797  SourceLocation ToAtSynchronizedLoc =
4798  Importer.Import(S->getAtSynchronizedLoc());
4799  Expr *ToSynchExpr = Importer.Import(S->getSynchExpr());
4800  if (!ToSynchExpr && S->getSynchExpr())
4801  return nullptr;
4802  Stmt *ToSynchBody = Importer.Import(S->getSynchBody());
4803  if (!ToSynchBody && S->getSynchBody())
4804  return nullptr;
4805  return new (Importer.getToContext()) ObjCAtSynchronizedStmt(
4806  ToAtSynchronizedLoc, ToSynchExpr, ToSynchBody);
4807 }
4808 
4810  SourceLocation ToAtThrowLoc = Importer.Import(S->getThrowLoc());
4811  Expr *ToThrow = Importer.Import(S->getThrowExpr());
4812  if (!ToThrow && S->getThrowExpr())
4813  return nullptr;
4814  return new (Importer.getToContext()) ObjCAtThrowStmt(ToAtThrowLoc, ToThrow);
4815 }
4816 
4819  SourceLocation ToAtLoc = Importer.Import(S->getAtLoc());
4820  Stmt *ToSubStmt = Importer.Import(S->getSubStmt());
4821  if (!ToSubStmt && S->getSubStmt())
4822  return nullptr;
4823  return new (Importer.getToContext()) ObjCAutoreleasePoolStmt(ToAtLoc,
4824  ToSubStmt);
4825 }
4826 
4827 //----------------------------------------------------------------------------
4828 // Import Expressions
4829 //----------------------------------------------------------------------------
4831  Importer.FromDiag(E->getLocStart(), diag::err_unsupported_ast_node)
4832  << E->getStmtClassName();
4833  return nullptr;
4834 }
4835 
4837  QualType T = Importer.Import(E->getType());
4838  if (T.isNull())
4839  return nullptr;
4840 
4841  Expr *SubExpr = Importer.Import(E->getSubExpr());
4842  if (!SubExpr && E->getSubExpr())
4843  return nullptr;
4844 
4845  TypeSourceInfo *TInfo = Importer.Import(E->getWrittenTypeInfo());
4846  if (!TInfo)
4847  return nullptr;
4848 
4849  return new (Importer.getToContext()) VAArgExpr(
4850  Importer.Import(E->getBuiltinLoc()), SubExpr, TInfo,
4851  Importer.Import(E->getRParenLoc()), T, E->isMicrosoftABI());
4852 }
4853 
4854 
4856  QualType T = Importer.Import(E->getType());
4857  if (T.isNull())
4858  return nullptr;
4859 
4860  return new (Importer.getToContext()) GNUNullExpr(
4861  T, Importer.Import(E->getLocStart()));
4862 }
4863 
4865  QualType T = Importer.Import(E->getType());
4866  if (T.isNull())
4867  return nullptr;
4868 
4869  StringLiteral *SL = cast_or_null<StringLiteral>(
4870  Importer.Import(E->getFunctionName()));
4871  if (!SL && E->getFunctionName())
4872  return nullptr;
4873 
4874  return new (Importer.getToContext()) PredefinedExpr(
4875  Importer.Import(E->getLocStart()), T, E->getIdentType(), SL);
4876 }
4877 
4879  ValueDecl *ToD = cast_or_null<ValueDecl>(Importer.Import(E->getDecl()));
4880  if (!ToD)
4881  return nullptr;
4882 
4883  NamedDecl *FoundD = nullptr;
4884  if (E->getDecl() != E->getFoundDecl()) {
4885  FoundD = cast_or_null<NamedDecl>(Importer.Import(E->getFoundDecl()));
4886  if (!FoundD)
4887  return nullptr;
4888  }
4889 
4890  QualType T = Importer.Import(E->getType());
4891  if (T.isNull())
4892  return nullptr;
4893 
4894 
4895  TemplateArgumentListInfo ToTAInfo;
4896  TemplateArgumentListInfo *ResInfo = nullptr;
4897  if (E->hasExplicitTemplateArgs()) {
4898  for (const auto &FromLoc : E->template_arguments()) {
4899  if (auto ToTALoc = ImportTemplateArgumentLoc(FromLoc))
4900  ToTAInfo.addArgument(*ToTALoc);
4901  else
4902  return nullptr;
4903  }
4904  ResInfo = &ToTAInfo;
4905  }
4906 
4907  DeclRefExpr *DRE = DeclRefExpr::Create(Importer.getToContext(),
4908  Importer.Import(E->getQualifierLoc()),
4909  Importer.Import(E->getTemplateKeywordLoc()),
4910  ToD,
4912  Importer.Import(E->getLocation()),
4913  T, E->getValueKind(),
4914  FoundD, ResInfo);
4915  if (E->hadMultipleCandidates())
4916  DRE->setHadMultipleCandidates(true);
4917  return DRE;
4918 }
4919 
4921  QualType T = Importer.Import(E->getType());
4922  if (T.isNull())
4923  return nullptr;
4924 
4925  return new (Importer.getToContext()) ImplicitValueInitExpr(T);
4926 }
4927 
4930  if (D.isFieldDesignator()) {
4931  IdentifierInfo *ToFieldName = Importer.Import(D.getFieldName());
4932  // Caller checks for import error
4933  return Designator(ToFieldName, Importer.Import(D.getDotLoc()),
4934  Importer.Import(D.getFieldLoc()));
4935  }
4936  if (D.isArrayDesignator())
4937  return Designator(D.getFirstExprIndex(),
4938  Importer.Import(D.getLBracketLoc()),
4939  Importer.Import(D.getRBracketLoc()));
4940 
4941  assert(D.isArrayRangeDesignator());
4942  return Designator(D.getFirstExprIndex(),
4943  Importer.Import(D.getLBracketLoc()),
4944  Importer.Import(D.getEllipsisLoc()),
4945  Importer.Import(D.getRBracketLoc()));
4946 }
4947 
4948 
4950  Expr *Init = cast_or_null<Expr>(Importer.Import(DIE->getInit()));
4951  if (!Init)
4952  return nullptr;
4953 
4954  SmallVector<Expr *, 4> IndexExprs(DIE->getNumSubExprs() - 1);
4955  // List elements from the second, the first is Init itself
4956  for (unsigned I = 1, E = DIE->getNumSubExprs(); I < E; I++) {
4957  if (Expr *Arg = cast_or_null<Expr>(Importer.Import(DIE->getSubExpr(I))))
4958  IndexExprs[I - 1] = Arg;
4959  else
4960  return nullptr;
4961  }
4962 
4963  SmallVector<Designator, 4> Designators(DIE->size());
4964  llvm::transform(DIE->designators(), Designators.begin(),
4965  [this](const Designator &D) -> Designator {
4966  return ImportDesignator(D);
4967  });
4968 
4969  for (const Designator &D : DIE->designators())
4970  if (D.isFieldDesignator() && !D.getFieldName())
4971  return nullptr;
4972 
4974  Importer.getToContext(), Designators,
4975  IndexExprs, Importer.Import(DIE->getEqualOrColonLoc()),
4976  DIE->usesGNUSyntax(), Init);
4977 }
4978 
4980  QualType T = Importer.Import(E->getType());
4981  if (T.isNull())
4982  return nullptr;
4983 
4984  return new (Importer.getToContext())
4985  CXXNullPtrLiteralExpr(T, Importer.Import(E->getLocation()));
4986 }
4987 
4989  QualType T = Importer.Import(E->getType());
4990  if (T.isNull())
4991  return nullptr;
4992 
4993  return IntegerLiteral::Create(Importer.getToContext(),
4994  E->getValue(), T,
4995  Importer.Import(E->getLocation()));
4996 }
4997 
4999  QualType T = Importer.Import(E->getType());
5000  if (T.isNull())
5001  return nullptr;
5002 
5003  return FloatingLiteral::Create(Importer.getToContext(),
5004  E->getValue(), E->isExact(), T,
5005  Importer.Import(E->getLocation()));
5006 }
5007 
5009  QualType T = Importer.Import(E->getType());
5010  if (T.isNull())
5011  return nullptr;
5012 
5013  return new (Importer.getToContext()) CharacterLiteral(E->getValue(),
5014  E->getKind(), T,
5015  Importer.Import(E->getLocation()));
5016 }
5017 
5019  QualType T = Importer.Import(E->getType());
5020  if (T.isNull())
5021  return nullptr;
5022 
5024  ImportArray(E->tokloc_begin(), E->tokloc_end(), Locations.begin());
5025 
5026  return StringLiteral::Create(Importer.getToContext(), E->getBytes(),
5027  E->getKind(), E->isPascal(), T,
5028  Locations.data(), Locations.size());
5029 }
5030 
5032  QualType T = Importer.Import(E->getType());
5033  if (T.isNull())
5034  return nullptr;
5035 
5036  TypeSourceInfo *TInfo = Importer.Import(E->getTypeSourceInfo());
5037  if (!TInfo)
5038  return nullptr;
5039 
5040  Expr *Init = Importer.Import(E->getInitializer());
5041  if (!Init)
5042  return nullptr;
5043 
5044  return new (Importer.getToContext()) CompoundLiteralExpr(
5045  Importer.Import(E->getLParenLoc()), TInfo, T, E->getValueKind(),
5046  Init, E->isFileScope());
5047 }
5048 
5050  QualType T = Importer.Import(E->getType());
5051  if (T.isNull())
5052  return nullptr;
5053 
5055  if (ImportArrayChecked(
5056  E->getSubExprs(), E->getSubExprs() + E->getNumSubExprs(),
5057  Exprs.begin()))
5058  return nullptr;
5059 
5060  return new (Importer.getToContext()) AtomicExpr(
5061  Importer.Import(E->getBuiltinLoc()), Exprs, T, E->getOp(),
5062  Importer.Import(E->getRParenLoc()));
5063 }
5064 
5066  QualType T = Importer.Import(E->getType());
5067  if (T.isNull())
5068  return nullptr;
5069 
5070  LabelDecl *ToLabel = cast_or_null<LabelDecl>(Importer.Import(E->getLabel()));
5071  if (!ToLabel)
5072  return nullptr;
5073 
5074  return new (Importer.getToContext()) AddrLabelExpr(
5075  Importer.Import(E->getAmpAmpLoc()), Importer.Import(E->getLabelLoc()),
5076  ToLabel, T);
5077 }
5078 
5080  Expr *SubExpr = Importer.Import(E->getSubExpr());
5081  if (!SubExpr)
5082  return nullptr;
5083 
5084  return new (Importer.getToContext())
5085  ParenExpr(Importer.Import(E->getLParen()),
5086  Importer.Import(E->getRParen()),
5087  SubExpr);
5088 }
5089 
5091  SmallVector<Expr *, 4> Exprs(E->getNumExprs());
5092  if (ImportContainerChecked(E->exprs(), Exprs))
5093  return nullptr;
5094 
5095  return new (Importer.getToContext()) ParenListExpr(
5096  Importer.getToContext(), Importer.Import(E->getLParenLoc()),
5097  Exprs, Importer.Import(E->getLParenLoc()));
5098 }
5099 
5101  QualType T = Importer.Import(E->getType());
5102  if (T.isNull())
5103  return nullptr;
5104 
5105  CompoundStmt *ToSubStmt = cast_or_null<CompoundStmt>(
5106  Importer.Import(E->getSubStmt()));
5107  if (!ToSubStmt && E->getSubStmt())
5108  return nullptr;
5109 
5110  return new (Importer.getToContext()) StmtExpr(ToSubStmt, T,
5111  Importer.Import(E->getLParenLoc()), Importer.Import(E->getRParenLoc()));
5112 }
5113 
5115  QualType T = Importer.Import(E->getType());
5116  if (T.isNull())
5117  return nullptr;
5118 
5119  Expr *SubExpr = Importer.Import(E->getSubExpr());
5120  if (!SubExpr)
5121  return nullptr;
5122 
5123  return new (Importer.getToContext()) UnaryOperator(SubExpr, E->getOpcode(),
5124  T, E->getValueKind(),
5125  E->getObjectKind(),
5126  Importer.Import(E->getOperatorLoc()));
5127 }
5128 
5131  QualType ResultType = Importer.Import(E->getType());
5132 
5133  if (E->isArgumentType()) {
5134  TypeSourceInfo *TInfo = Importer.Import(E->getArgumentTypeInfo());
5135  if (!TInfo)
5136  return nullptr;
5137 
5138  return new (Importer.getToContext()) UnaryExprOrTypeTraitExpr(E->getKind(),
5139  TInfo, ResultType,
5140  Importer.Import(E->getOperatorLoc()),
5141  Importer.Import(E->getRParenLoc()));
5142  }
5143 
5144  Expr *SubExpr = Importer.Import(E->getArgumentExpr());
5145  if (!SubExpr)
5146  return nullptr;
5147 
5148  return new (Importer.getToContext()) UnaryExprOrTypeTraitExpr(E->getKind(),
5149  SubExpr, ResultType,
5150  Importer.Import(E->getOperatorLoc()),
5151  Importer.Import(E->getRParenLoc()));
5152 }
5153 
5155  QualType T = Importer.Import(E->getType());
5156  if (T.isNull())
5157  return nullptr;
5158 
5159  Expr *LHS = Importer.Import(E->getLHS());
5160  if (!LHS)
5161  return nullptr;
5162 
5163  Expr *RHS = Importer.Import(E->getRHS());
5164  if (!RHS)
5165  return nullptr;
5166 
5167  return new (Importer.getToContext()) BinaryOperator(LHS, RHS, E->getOpcode(),
5168  T, E->getValueKind(),
5169  E->getObjectKind(),
5170  Importer.Import(E->getOperatorLoc()),
5171  E->getFPFeatures());
5172 }
5173 
5175  QualType T = Importer.Import(E->getType());
5176  if (T.isNull())
5177  return nullptr;
5178 
5179  Expr *ToLHS = Importer.Import(E->getLHS());
5180  if (!ToLHS)
5181  return nullptr;
5182 
5183  Expr *ToRHS = Importer.Import(E->getRHS());
5184  if (!ToRHS)
5185  return nullptr;
5186 
5187  Expr *ToCond = Importer.Import(E->getCond());
5188  if (!ToCond)
5189  return nullptr;
5190 
5191  return new (Importer.getToContext()) ConditionalOperator(
5192  ToCond, Importer.Import(E->getQuestionLoc()),
5193  ToLHS, Importer.Import(E->getColonLoc()),
5194  ToRHS, T, E->getValueKind(), E->getObjectKind());
5195 }
5196 
5199  QualType T = Importer.Import(E->getType());
5200  if (T.isNull())
5201  return nullptr;
5202 
5203  Expr *Common = Importer.Import(E->getCommon());
5204  if (!Common)
5205  return nullptr;
5206 
5207  Expr *Cond = Importer.Import(E->getCond());
5208  if (!Cond)
5209  return nullptr;
5210 
5211  OpaqueValueExpr *OpaqueValue = cast_or_null<OpaqueValueExpr>(
5212  Importer.Import(E->getOpaqueValue()));
5213  if (!OpaqueValue)
5214  return nullptr;
5215 
5216  Expr *TrueExpr = Importer.Import(E->getTrueExpr());
5217  if (!TrueExpr)
5218  return nullptr;
5219 
5220  Expr *FalseExpr = Importer.Import(E->getFalseExpr());
5221  if (!FalseExpr)
5222  return nullptr;
5223 
5224  return new (Importer.getToContext()) BinaryConditionalOperator(
5225  Common, OpaqueValue, Cond, TrueExpr, FalseExpr,
5226  Importer.Import(E->getQuestionLoc()), Importer.Import(E->getColonLoc()),
5227  T, E->getValueKind(), E->getObjectKind());
5228 }
5229 
5231  QualType T = Importer.Import(E->getType());
5232  if (T.isNull())
5233  return nullptr;
5234 
5235  TypeSourceInfo *ToQueried = Importer.Import(E->getQueriedTypeSourceInfo());
5236  if (!ToQueried)
5237  return nullptr;
5238 
5239  Expr *Dim = Importer.Import(E->getDimensionExpression());
5240  if (!Dim && E->getDimensionExpression())
5241  return nullptr;
5242 
5243  return new (Importer.getToContext()) ArrayTypeTraitExpr(
5244  Importer.Import(E->getLocStart()), E->getTrait(), ToQueried,
5245  E->getValue(), Dim, Importer.Import(E->getLocEnd()), T);
5246 }
5247 
5249  QualType T = Importer.Import(E->getType());
5250  if (T.isNull())
5251  return nullptr;
5252 
5253  Expr *ToQueried = Importer.Import(E->getQueriedExpression());
5254  if (!ToQueried)
5255  return nullptr;
5256 
5257  return new (Importer.getToContext()) ExpressionTraitExpr(
5258  Importer.Import(E->getLocStart()), E->getTrait(), ToQueried,
5259  E->getValue(), Importer.Import(E->getLocEnd()), T);
5260 }
5261 
5263  QualType T = Importer.Import(E->getType());
5264  if (T.isNull())
5265  return nullptr;
5266 
5267  Expr *SourceExpr = Importer.Import(E->getSourceExpr());
5268  if (!SourceExpr && E->getSourceExpr())
5269  return nullptr;
5270 
5271  return new (Importer.getToContext()) OpaqueValueExpr(
5272  Importer.Import(E->getLocation()), T, E->getValueKind(),
5273  E->getObjectKind(), SourceExpr);
5274 }
5275 
5277  QualType T = Importer.Import(E->getType());
5278  if (T.isNull())
5279  return nullptr;
5280 
5281  Expr *ToLHS = Importer.Import(E->getLHS());
5282  if (!ToLHS)
5283  return nullptr;
5284 
5285  Expr *ToRHS = Importer.Import(E->getRHS());
5286  if (!ToRHS)
5287  return nullptr;
5288 
5289  return new (Importer.getToContext()) ArraySubscriptExpr(
5290  ToLHS, ToRHS, T, E->getValueKind(), E->getObjectKind(),
5291  Importer.Import(E->getRBracketLoc()));
5292 }
5293 
5295  QualType T = Importer.Import(E->getType());
5296  if (T.isNull())
5297  return nullptr;
5298 
5299  QualType CompLHSType = Importer.Import(E->getComputationLHSType());
5300  if (CompLHSType.isNull())
5301  return nullptr;
5302 
5303  QualType CompResultType = Importer.Import(E->getComputationResultType());
5304  if (CompResultType.isNull())
5305  return nullptr;
5306 
5307  Expr *LHS = Importer.Import(E->getLHS());
5308  if (!LHS)
5309  return nullptr;
5310 
5311  Expr *RHS = Importer.Import(E->getRHS());
5312  if (!RHS)
5313  return nullptr;
5314 
5315  return new (Importer.getToContext())
5316  CompoundAssignOperator(LHS, RHS, E->getOpcode(),
5317  T, E->getValueKind(),
5318  E->getObjectKind(),
5319  CompLHSType, CompResultType,
5320  Importer.Import(E->getOperatorLoc()),
5321  E->getFPFeatures());
5322 }
5323 
5325  for (auto I = CE->path_begin(), E = CE->path_end(); I != E; ++I) {
5326  if (CXXBaseSpecifier *Spec = Importer.Import(*I))
5327  Path.push_back(Spec);
5328  else
5329  return true;
5330  }
5331  return false;
5332 }
5333 
5335  QualType T = Importer.Import(E->getType());
5336  if (T.isNull())
5337  return nullptr;
5338 
5339  Expr *SubExpr = Importer.Import(E->getSubExpr());
5340  if (!SubExpr)
5341  return nullptr;
5342 
5343  CXXCastPath BasePath;
5344  if (ImportCastPath(E, BasePath))
5345  return nullptr;
5346 
5347  return ImplicitCastExpr::Create(Importer.getToContext(), T, E->getCastKind(),
5348  SubExpr, &BasePath, E->getValueKind());
5349 }
5350 
5352  QualType T = Importer.Import(E->getType());
5353  if (T.isNull())
5354  return nullptr;
5355 
5356  Expr *SubExpr = Importer.Import(E->getSubExpr());
5357  if (!SubExpr)
5358  return nullptr;
5359 
5360  TypeSourceInfo *TInfo = Importer.Import(E->getTypeInfoAsWritten());
5361  if (!TInfo && E->getTypeInfoAsWritten())
5362  return nullptr;
5363 
5364  CXXCastPath BasePath;
5365  if (ImportCastPath(E, BasePath))
5366  return nullptr;
5367 
5368  switch (E->getStmtClass()) {
5369  case Stmt::CStyleCastExprClass: {
5370  CStyleCastExpr *CCE = cast<CStyleCastExpr>(E);
5371  return CStyleCastExpr::Create(Importer.getToContext(), T,
5372  E->getValueKind(), E->getCastKind(),
5373  SubExpr, &BasePath, TInfo,
5374  Importer.Import(CCE->getLParenLoc()),
5375  Importer.Import(CCE->getRParenLoc()));
5376  }
5377 
5378  case Stmt::CXXFunctionalCastExprClass: {
5379  CXXFunctionalCastExpr *FCE = cast<CXXFunctionalCastExpr>(E);
5380  return CXXFunctionalCastExpr::Create(Importer.getToContext(), T,
5381  E->getValueKind(), TInfo,
5382  E->getCastKind(), SubExpr, &BasePath,
5383  Importer.Import(FCE->getLParenLoc()),
5384  Importer.Import(FCE->getRParenLoc()));
5385  }
5386 
5387  case Stmt::ObjCBridgedCastExprClass: {
5388  ObjCBridgedCastExpr *OCE = cast<ObjCBridgedCastExpr>(E);
5389  return new (Importer.getToContext()) ObjCBridgedCastExpr(
5390  Importer.Import(OCE->getLParenLoc()), OCE->getBridgeKind(),
5391  E->getCastKind(), Importer.Import(OCE->getBridgeKeywordLoc()),
5392  TInfo, SubExpr);
5393  }
5394  default:
5395  break; // just fall through
5396  }
5397 
5398  CXXNamedCastExpr *Named = cast<CXXNamedCastExpr>(E);
5399  SourceLocation ExprLoc = Importer.Import(Named->getOperatorLoc()),
5400  RParenLoc = Importer.Import(Named->getRParenLoc());
5401  SourceRange Brackets = Importer.Import(Named->getAngleBrackets());
5402 
5403  switch (E->getStmtClass()) {
5404  case Stmt::CXXStaticCastExprClass:
5405  return CXXStaticCastExpr::Create(Importer.getToContext(), T,
5406  E->getValueKind(), E->getCastKind(),
5407  SubExpr, &BasePath, TInfo,
5408  ExprLoc, RParenLoc, Brackets);
5409 
5410  case Stmt::CXXDynamicCastExprClass:
5411  return CXXDynamicCastExpr::Create(Importer.getToContext(), T,
5412  E->getValueKind(), E->getCastKind(),
5413  SubExpr, &BasePath, TInfo,
5414  ExprLoc, RParenLoc, Brackets);
5415 
5416  case Stmt::CXXReinterpretCastExprClass:
5417  return CXXReinterpretCastExpr::Create(Importer.getToContext(), T,
5418  E->getValueKind(), E->getCastKind(),
5419  SubExpr, &BasePath, TInfo,
5420  ExprLoc, RParenLoc, Brackets);
5421 
5422  case Stmt::CXXConstCastExprClass:
5423  return CXXConstCastExpr::Create(Importer.getToContext(), T,
5424  E->getValueKind(), SubExpr, TInfo, ExprLoc,
5425  RParenLoc, Brackets);
5426  default:
5427  llvm_unreachable("Cast expression of unsupported type!");
5428  return nullptr;
5429  }
5430 }
5431 
5433  QualType T = Importer.Import(OE->getType());
5434  if (T.isNull())
5435  return nullptr;
5436 
5438  for (int I = 0, E = OE->getNumComponents(); I < E; ++I) {
5439  const OffsetOfNode &Node = OE->getComponent(I);
5440 
5441  switch (Node.getKind()) {
5442  case OffsetOfNode::Array:
5443  Nodes.push_back(OffsetOfNode(Importer.Import(Node.getLocStart()),
5444  Node.getArrayExprIndex(),
5445  Importer.Import(Node.getLocEnd())));
5446  break;
5447 
5448  case OffsetOfNode::Base: {
5449  CXXBaseSpecifier *BS = Importer.Import(Node.getBase());
5450  if (!BS && Node.getBase())
5451  return nullptr;
5452  Nodes.push_back(OffsetOfNode(BS));
5453  break;
5454  }
5455  case OffsetOfNode::Field: {
5456  FieldDecl *FD = cast_or_null<FieldDecl>(Importer.Import(Node.getField()));
5457  if (!FD)
5458  return nullptr;
5459  Nodes.push_back(OffsetOfNode(Importer.Import(Node.getLocStart()), FD,
5460  Importer.Import(Node.getLocEnd())));
5461  break;
5462  }
5463  case OffsetOfNode::Identifier: {
5464  IdentifierInfo *ToII = Importer.Import(Node.getFieldName());
5465  if (!ToII)
5466  return nullptr;
5467  Nodes.push_back(OffsetOfNode(Importer.Import(Node.getLocStart()), ToII,
5468  Importer.Import(Node.getLocEnd())));
5469  break;
5470  }
5471  }
5472  }
5473 
5475  for (int I = 0, E = OE->getNumExpressions(); I < E; ++I) {
5476  Expr *ToIndexExpr = Importer.Import(OE->getIndexExpr(I));
5477  if (!ToIndexExpr)
5478  return nullptr;
5479  Exprs[I] = ToIndexExpr;
5480  }
5481 
5482  TypeSourceInfo *TInfo = Importer.Import(OE->getTypeSourceInfo());
5483  if (!TInfo && OE->getTypeSourceInfo())
5484  return nullptr;
5485 
5486  return OffsetOfExpr::Create(Importer.getToContext(), T,
5487  Importer.Import(OE->getOperatorLoc()),
5488  TInfo, Nodes, Exprs,
5489  Importer.Import(OE->getRParenLoc()));
5490 }
5491 
5493  QualType T = Importer.Import(E->getType());
5494  if (T.isNull())
5495  return nullptr;
5496 
5497  Expr *Operand = Importer.Import(E->getOperand());
5498  if (!Operand)
5499  return nullptr;
5500 
5502  if (E->isValueDependent())
5503  CanThrow = CT_Dependent;
5504  else
5505  CanThrow = E->getValue() ? CT_Can : CT_Cannot;
5506 
5507  return new (Importer.getToContext()) CXXNoexceptExpr(
5508  T, Operand, CanThrow,
5509  Importer.Import(E->getLocStart()), Importer.Import(E->getLocEnd()));
5510 }
5511 
5513  QualType T = Importer.Import(E->getType());
5514  if (T.isNull())
5515  return nullptr;
5516 
5517  Expr *SubExpr = Importer.Import(E->getSubExpr());
5518  if (!SubExpr && E->getSubExpr())
5519  return nullptr;
5520 
5521  return new (Importer.getToContext()) CXXThrowExpr(
5522  SubExpr, T, Importer.Import(E->getThrowLoc()),
5524 }
5525 
5527  ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
5528  Importer.Import(E->getParam()));
5529  if (!Param)
5530  return nullptr;
5531 
5533  Importer.getToContext(), Importer.Import(E->getUsedLocation()), Param);
5534 }
5535 
5537  QualType T = Importer.Import(E->getType());
5538  if (T.isNull())
5539  return nullptr;
5540 
5541  TypeSourceInfo *TypeInfo = Importer.Import(E->getTypeSourceInfo());
5542  if (!TypeInfo)
5543  return nullptr;
5544 
5545  return new (Importer.getToContext()) CXXScalarValueInitExpr(
5546  T, TypeInfo, Importer.Import(E->getRParenLoc()));
5547 }
5548 
5550  Expr *SubExpr = Importer.Import(E->getSubExpr());
5551  if (!SubExpr)
5552  return nullptr;
5553 
5554  auto *Dtor = cast_or_null<CXXDestructorDecl>(
5555  Importer.Import(const_cast<CXXDestructorDecl *>(
5556  E->getTemporary()->getDestructor())));
5557  if (!Dtor)
5558  return nullptr;
5559 
5560  ASTContext &ToCtx = Importer.getToContext();
5561  CXXTemporary *Temp = CXXTemporary::Create(ToCtx, Dtor);
5562  return CXXBindTemporaryExpr::Create(ToCtx, Temp, SubExpr);
5563 }
5564 
5566  QualType T = Importer.Import(CE->getType());
5567  if (T.isNull())
5568  return nullptr;
5569 
5570  SmallVector<Expr *, 8> Args(CE->getNumArgs());
5571  if (ImportContainerChecked(CE->arguments(), Args))
5572  return nullptr;
5573 
5574  auto *Ctor = cast_or_null<CXXConstructorDecl>(
5575  Importer.Import(CE->getConstructor()));
5576  if (!Ctor)
5577  return nullptr;
5578 
5580  Importer.getToContext(), T,
5581  Importer.Import(CE->getLocStart()),
5582  Ctor,
5583  CE->isElidable(),
5584  Args,
5585  CE->hadMultipleCandidates(),
5586  CE->isListInitialization(),
5589  CE->getConstructionKind(),
5590  Importer.Import(CE->getParenOrBraceRange()));
5591 }
5592 
5593 Expr *
5595  QualType T = Importer.Import(E->getType());
5596  if (T.isNull())
5597  return nullptr;
5598 
5599  Expr *TempE = Importer.Import(E->GetTemporaryExpr());
5600  if (!TempE)
5601  return nullptr;
5602 
5603  ValueDecl *ExtendedBy = cast_or_null<ValueDecl>(
5604  Importer.Import(const_cast<ValueDecl *>(E->getExtendingDecl())));
5605  if (!ExtendedBy && E->getExtendingDecl())
5606  return nullptr;
5607 
5608  auto *ToMTE = new (Importer.getToContext()) MaterializeTemporaryExpr(
5609  T, TempE, E->isBoundToLvalueReference());
5610 
5611  // FIXME: Should ManglingNumber get numbers associated with 'to' context?
5612  ToMTE->setExtendingDecl(ExtendedBy, E->getManglingNumber());
5613  return ToMTE;
5614 }
5615 
5617  QualType T = Importer.Import(E->getType());
5618  if (T.isNull())
5619  return nullptr;
5620 
5621  Expr *Pattern = Importer.Import(E->getPattern());
5622  if (!Pattern)
5623  return nullptr;
5624 
5625  return new (Importer.getToContext()) PackExpansionExpr(
5626  T, Pattern, Importer.Import(E->getEllipsisLoc()),
5627  E->getNumExpansions());
5628 }
5629 
5631  QualType T = Importer.Import(CE->getType());
5632  if (T.isNull())
5633  return nullptr;
5634 
5635  SmallVector<Expr *, 4> PlacementArgs(CE->getNumPlacementArgs());
5636  if (ImportContainerChecked(CE->placement_arguments(), PlacementArgs))
5637  return nullptr;
5638 
5639  FunctionDecl *OperatorNewDecl = cast_or_null<FunctionDecl>(
5640  Importer.Import(CE->getOperatorNew()));
5641  if (!OperatorNewDecl && CE->getOperatorNew())
5642  return nullptr;
5643 
5644  FunctionDecl *OperatorDeleteDecl = cast_or_null<FunctionDecl>(
5645  Importer.Import(CE->getOperatorDelete()));
5646  if (!OperatorDeleteDecl && CE->getOperatorDelete())
5647  return nullptr;
5648 
5649  Expr *ToInit = Importer.Import(CE->getInitializer());
5650  if (!ToInit && CE->getInitializer())
5651  return nullptr;
5652 
5653  TypeSourceInfo *TInfo = Importer.Import(CE->getAllocatedTypeSourceInfo());
5654  if (!TInfo)
5655  return nullptr;
5656 
5657  Expr *ToArrSize = Importer.Import(CE->getArraySize());
5658  if (!ToArrSize && CE->getArraySize())
5659  return nullptr;
5660 
5661  return new (Importer.getToContext()) CXXNewExpr(
5662  Importer.getToContext(),
5663  CE->isGlobalNew(),
5664  OperatorNewDecl, OperatorDeleteDecl,
5665  CE->passAlignment(),
5667  PlacementArgs,
5668  Importer.Import(CE->getTypeIdParens()),
5669  ToArrSize, CE->getInitializationStyle(), ToInit, T, TInfo,
5670  Importer.Import(CE->getSourceRange()),
5671  Importer.Import(CE->getDirectInitRange()));
5672 }
5673 
5675  QualType T = Importer.Import(E->getType());
5676  if (T.isNull())
5677  return nullptr;
5678 
5679  FunctionDecl *OperatorDeleteDecl = cast_or_null<FunctionDecl>(
5680  Importer.Import(E->getOperatorDelete()));
5681  if (!OperatorDeleteDecl && E->getOperatorDelete())
5682  return nullptr;
5683 
5684  Expr *ToArg = Importer.Import(E->getArgument());
5685  if (!ToArg && E->getArgument())
5686  return nullptr;
5687 
5688  return new (Importer.getToContext()) CXXDeleteExpr(
5689  T, E->isGlobalDelete(),
5690  E->isArrayForm(),
5691  E->isArrayFormAsWritten(),
5693  OperatorDeleteDecl,
5694  ToArg,
5695  Importer.Import(E->getLocStart()));
5696 }
5697 
5699  QualType T = Importer.Import(E->getType());
5700  if (T.isNull())
5701  return nullptr;
5702 
5703  CXXConstructorDecl *ToCCD =
5704  dyn_cast_or_null<CXXConstructorDecl>(Importer.Import(E->getConstructor()));
5705  if (!ToCCD)
5706  return nullptr;
5707 
5708  SmallVector<Expr *, 6> ToArgs(E->getNumArgs());
5709  if (ImportContainerChecked(E->arguments(), ToArgs))
5710  return nullptr;
5711 
5712  return CXXConstructExpr::Create(Importer.getToContext(), T,
5713  Importer.Import(E->getLocation()),
5714  ToCCD, E->isElidable(),
5715  ToArgs, E->hadMultipleCandidates(),
5716  E->isListInitialization(),
5719  E->getConstructionKind(),
5720  Importer.Import(E->getParenOrBraceRange()));
5721 }
5722 
5724  Expr *SubExpr = Importer.Import(EWC->getSubExpr());
5725  if (!SubExpr && EWC->getSubExpr())
5726  return nullptr;
5727 
5729  for (unsigned I = 0, E = EWC->getNumObjects(); I < E; I++)
5731  cast_or_null<BlockDecl>(Importer.Import(EWC->getObject(I))))
5732  Objs[I] = Obj;
5733  else
5734  return nullptr;
5735 
5736  return ExprWithCleanups::Create(Importer.getToContext(),
5737  SubExpr, EWC->cleanupsHaveSideEffects(),
5738  Objs);
5739 }
5740 
5742  QualType T = Importer.Import(E->getType());
5743  if (T.isNull())
5744  return nullptr;
5745 
5746  Expr *ToFn = Importer.Import(E->getCallee());
5747  if (!ToFn)
5748  return nullptr;
5749 
5750  SmallVector<Expr *, 4> ToArgs(E->getNumArgs());
5751  if (ImportContainerChecked(E->arguments(), ToArgs))
5752  return nullptr;
5753 
5754  return new (Importer.getToContext()) CXXMemberCallExpr(
5755  Importer.getToContext(), ToFn, ToArgs, T, E->getValueKind(),
5756  Importer.Import(E->getRParenLoc()));
5757 }
5758 
5760  QualType T = Importer.Import(E->getType());
5761  if (T.isNull())
5762  return nullptr;
5763 
5764  return new (Importer.getToContext())
5765  CXXThisExpr(Importer.Import(E->getLocation()), T, E->isImplicit());
5766 }
5767 
5769  QualType T = Importer.Import(E->getType());
5770  if (T.isNull())
5771  return nullptr;
5772 
5773  return new (Importer.getToContext())
5774  CXXBoolLiteralExpr(E->getValue(), T, Importer.Import(E->getLocation()));
5775 }
5776 
5777 
5779  QualType T = Importer.Import(E->getType());
5780  if (T.isNull())
5781  return nullptr;
5782 
5783  Expr *ToBase = Importer.Import(E->getBase());
5784  if (!ToBase && E->getBase())
5785  return nullptr;
5786 
5787  ValueDecl *ToMember = dyn_cast<ValueDecl>(Importer.Import(E->getMemberDecl()));
5788  if (!ToMember && E->getMemberDecl())
5789  return nullptr;
5790 
5791  DeclAccessPair ToFoundDecl = DeclAccessPair::make(
5792  dyn_cast<NamedDecl>(Importer.Import(E->getFoundDecl().getDecl())),
5793  E->getFoundDecl().getAccess());
5794 
5795  DeclarationNameInfo ToMemberNameInfo(
5796  Importer.Import(E->getMemberNameInfo().getName()),
5797  Importer.Import(E->getMemberNameInfo().getLoc()));
5798 
5799  if (E->hasExplicitTemplateArgs()) {
5800  return nullptr; // FIXME: handle template arguments
5801  }
5802 
5803  return MemberExpr::Create(Importer.getToContext(), ToBase,
5804  E->isArrow(),
5805  Importer.Import(E->getOperatorLoc()),
5806  Importer.Import(E->getQualifierLoc()),
5807  Importer.Import(E->getTemplateKeywordLoc()),
5808  ToMember, ToFoundDecl, ToMemberNameInfo,
5809  nullptr, T, E->getValueKind(),
5810  E->getObjectKind());
5811 }
5812 
5815 
5816  Expr *BaseE = Importer.Import(E->getBase());
5817  if (!BaseE)
5818  return nullptr;
5819 
5820  TypeSourceInfo *ScopeInfo = Importer.Import(E->getScopeTypeInfo());
5821  if (!ScopeInfo && E->getScopeTypeInfo())
5822  return nullptr;
5823 
5825  if (IdentifierInfo *FromII = E->getDestroyedTypeIdentifier()) {
5826  IdentifierInfo *ToII = Importer.Import(FromII);
5827  if (!ToII)
5828  return nullptr;
5829  Storage = PseudoDestructorTypeStorage(
5830  ToII, Importer.Import(E->getDestroyedTypeLoc()));
5831  } else {
5832  TypeSourceInfo *TI = Importer.Import(E->getDestroyedTypeInfo());
5833  if (!TI)
5834  return nullptr;
5835  Storage = PseudoDestructorTypeStorage(TI);
5836  }
5837 
5838  return new (Importer.getToContext()) CXXPseudoDestructorExpr(
5839  Importer.getToContext(), BaseE, E->isArrow(),
5840  Importer.Import(E->getOperatorLoc()),
5841  Importer.Import(E->getQualifierLoc()),
5842  ScopeInfo, Importer.Import(E->getColonColonLoc()),
5843  Importer.Import(E->getTildeLoc()), Storage);
5844 }
5845 
5848  Expr *Base = nullptr;
5849  if (!E->isImplicitAccess()) {
5850  Base = Importer.Import(E->getBase());
5851  if (!Base)
5852  return nullptr;
5853  }
5854 
5855  QualType BaseType = Importer.Import(E->getBaseType());
5856  if (BaseType.isNull())
5857  return nullptr;
5858 
5859  TemplateArgumentListInfo ToTAInfo(Importer.Import(E->getLAngleLoc()),
5860  Importer.Import(E->getRAngleLoc()));
5861  TemplateArgumentListInfo *ResInfo = nullptr;
5862  if (E->hasExplicitTemplateArgs()) {
5864  return nullptr;
5865  ResInfo = &ToTAInfo;
5866  }
5867 
5868  DeclarationName Name = Importer.Import(E->getMember());
5869  if (!E->getMember().isEmpty() && Name.isEmpty())
5870  return nullptr;
5871 
5872  DeclarationNameInfo MemberNameInfo(Name, Importer.Import(E->getMemberLoc()));
5873  // Import additional name location/type info.
5874  ImportDeclarationNameLoc(E->getMemberNameInfo(), MemberNameInfo);
5875  auto ToFQ = Importer.Import(E->getFirstQualifierFoundInScope());
5876  if (!ToFQ && E->getFirstQualifierFoundInScope())
5877  return nullptr;
5878 
5880  Importer.getToContext(), Base, BaseType, E->isArrow(),
5881  Importer.Import(E->getOperatorLoc()),
5882  Importer.Import(E->getQualifierLoc()),
5883  Importer.Import(E->getTemplateKeywordLoc()),
5884  cast_or_null<NamedDecl>(ToFQ), MemberNameInfo, ResInfo);
5885 }
5886 
5888  QualType T = Importer.Import(E->getType());
5889  if (T.isNull())
5890  return nullptr;
5891 
5892  Expr *ToCallee = Importer.Import(E->getCallee());
5893  if (!ToCallee && E->getCallee())
5894  return nullptr;
5895 
5896  unsigned NumArgs = E->getNumArgs();
5897 
5898  llvm::SmallVector<Expr *, 2> ToArgs(NumArgs);
5899 
5900  for (unsigned ai = 0, ae = NumArgs; ai != ae; ++ai) {
5901  Expr *FromArg = E->getArg(ai);
5902  Expr *ToArg = Importer.Import(FromArg);
5903  if (!ToArg)
5904  return nullptr;
5905  ToArgs[ai] = ToArg;
5906  }
5907 
5908  Expr **ToArgs_Copied = new (Importer.getToContext())
5909  Expr*[NumArgs];
5910 
5911  for (unsigned ai = 0, ae = NumArgs; ai != ae; ++ai)
5912  ToArgs_Copied[ai] = ToArgs[ai];
5913 
5914  return new (Importer.getToContext())
5915  CallExpr(Importer.getToContext(), ToCallee,
5916  llvm::makeArrayRef(ToArgs_Copied, NumArgs), T, E->getValueKind(),
5917  Importer.Import(E->getRParenLoc()));
5918 }
5919 
5921  QualType T = Importer.Import(ILE->getType());
5922  if (T.isNull())
5923  return nullptr;
5924 
5926  if (ImportContainerChecked(ILE->inits(), Exprs))
5927  return nullptr;
5928 
5929  ASTContext &ToCtx = Importer.getToContext();
5930  InitListExpr *To = new (ToCtx) InitListExpr(
5931  ToCtx, Importer.Import(ILE->getLBraceLoc()),
5932  Exprs, Importer.Import(ILE->getLBraceLoc()));
5933  To->setType(T);
5934 
5935  if (ILE->hasArrayFiller()) {
5936  Expr *Filler = Importer.Import(ILE->getArrayFiller());
5937  if (!Filler)
5938  return nullptr;
5939  To->setArrayFiller(Filler);
5940  }
5941 
5942  if (FieldDecl *FromFD = ILE->getInitializedFieldInUnion()) {
5943  FieldDecl *ToFD = cast_or_null<FieldDecl>(Importer.Import(FromFD));
5944  if (!ToFD)
5945  return nullptr;
5946  To->setInitializedFieldInUnion(ToFD);
5947  }
5948 
5949  if (InitListExpr *SyntForm = ILE->getSyntacticForm()) {
5950  InitListExpr *ToSyntForm = cast_or_null<InitListExpr>(
5951  Importer.Import(SyntForm));
5952  if (!ToSyntForm)
5953  return nullptr;
5954  To->setSyntacticForm(ToSyntForm);
5955  }
5956 
5958  To->setValueDependent(ILE->isValueDependent());
5960 
5961  return To;
5962 }
5963 
5965  QualType ToType = Importer.Import(E->getType());
5966  if (ToType.isNull())
5967  return nullptr;
5968 
5969  Expr *ToCommon = Importer.Import(E->getCommonExpr());
5970  if (!ToCommon && E->getCommonExpr())
5971  return nullptr;
5972 
5973  Expr *ToSubExpr = Importer.Import(E->getSubExpr());
5974  if (!ToSubExpr && E->getSubExpr())
5975  return nullptr;
5976 
5977  return new (Importer.getToContext())
5978  ArrayInitLoopExpr(ToType, ToCommon, ToSubExpr);
5979 }
5980 
5982  QualType ToType = Importer.Import(E->getType());
5983  if (ToType.isNull())
5984  return nullptr;
5985  return new (Importer.getToContext()) ArrayInitIndexExpr(ToType);
5986 }
5987 
5989  FieldDecl *ToField = llvm::dyn_cast_or_null<FieldDecl>(
5990  Importer.Import(DIE->getField()));
5991  if (!ToField && DIE->getField())
5992  return nullptr;
5993 
5995  Importer.getToContext(), Importer.Import(DIE->getLocStart()), ToField);
5996 }
5997 
5999  QualType ToType = Importer.Import(E->getType());
6000  if (ToType.isNull() && !E->getType().isNull())
6001  return nullptr;
6002  ExprValueKind VK = E->getValueKind();
6003  CastKind CK = E->getCastKind();
6004  Expr *ToOp = Importer.Import(E->getSubExpr());
6005  if (!ToOp && E->getSubExpr())
6006  return nullptr;
6007  CXXCastPath BasePath;
6008  if (ImportCastPath(E, BasePath))
6009  return nullptr;
6010  TypeSourceInfo *ToWritten = Importer.Import(E->getTypeInfoAsWritten());
6011  SourceLocation ToOperatorLoc = Importer.Import(E->getOperatorLoc());
6012  SourceLocation ToRParenLoc = Importer.Import(E->getRParenLoc());
6013  SourceRange ToAngleBrackets = Importer.Import(E->getAngleBrackets());
6014 
6015  if (isa<CXXStaticCastExpr>(E)) {
6017  Importer.getToContext(), ToType, VK, CK, ToOp, &BasePath,
6018  ToWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
6019  } else if (isa<CXXDynamicCastExpr>(E)) {
6021  Importer.getToContext(), ToType, VK, CK, ToOp, &BasePath,
6022  ToWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
6023  } else if (isa<CXXReinterpretCastExpr>(E)) {
6025  Importer.getToContext(), ToType, VK, CK, ToOp, &BasePath,
6026  ToWritten, ToOperatorLoc, ToRParenLoc, ToAngleBrackets);
6027  } else {
6028  return nullptr;
6029  }
6030 }
6031 
6032 
6035  QualType T = Importer.Import(E->getType());
6036  if (T.isNull())
6037  return nullptr;
6038 
6039  NonTypeTemplateParmDecl *Param = cast_or_null<NonTypeTemplateParmDecl>(
6040  Importer.Import(E->getParameter()));
6041  if (!Param)
6042  return nullptr;
6043 
6044  Expr *Replacement = Importer.Import(E->getReplacement());
6045  if (!Replacement)
6046  return nullptr;
6047 
6048  return new (Importer.getToContext()) SubstNonTypeTemplateParmExpr(
6049  T, E->getValueKind(), Importer.Import(E->getExprLoc()), Param,
6050  Replacement);
6051 }
6052 
6054  QualType ToType = Importer.Import(E->getType());
6055  if (ToType.isNull())
6056  return nullptr;
6057 
6059  if (ImportContainerChecked(E->getArgs(), ToArgs))
6060  return nullptr;
6061 
6062  // According to Sema::BuildTypeTrait(), if E is value-dependent,
6063  // Value is always false.
6064  bool ToValue = false;
6065  if (!E->isValueDependent())
6066  ToValue = E->getValue();
6067 
6068  return TypeTraitExpr::Create(
6069  Importer.getToContext(), ToType, Importer.Import(E->getLocStart()),
6070  E->getTrait(), ToArgs, Importer.Import(E->getLocEnd()), ToValue);
6071 }
6072 
6074  CXXMethodDecl *FromMethod) {
6075  for (auto *FromOverriddenMethod : FromMethod->overridden_methods())
6076  ToMethod->addOverriddenMethod(
6077  cast<CXXMethodDecl>(Importer.Import(const_cast<CXXMethodDecl*>(
6078  FromOverriddenMethod))));
6079 }
6080 
6082  ASTContext &FromContext, FileManager &FromFileManager,
6083  bool MinimalImport)
6084  : ToContext(ToContext), FromContext(FromContext),
6085  ToFileManager(ToFileManager), FromFileManager(FromFileManager),
6086  Minimal(MinimalImport), LastDiagFromFrom(false)
6087 {
6088  ImportedDecls[FromContext.getTranslationUnitDecl()]
6089  = ToContext.getTranslationUnitDecl();
6090 }
6091 
6093 
6095  if (FromT.isNull())
6096  return QualType();
6097 
6098  const Type *fromTy = FromT.getTypePtr();
6099 
6100  // Check whether we've already imported this type.
6101  llvm::DenseMap<const Type *, const Type *>::iterator Pos
6102  = ImportedTypes.find(fromTy);
6103  if (Pos != ImportedTypes.end())
6104  return ToContext.getQualifiedType(Pos->second, FromT.getLocalQualifiers());
6105 
6106  // Import the type
6107  ASTNodeImporter Importer(*this);
6108  QualType ToT = Importer.Visit(fromTy);
6109  if (ToT.isNull())
6110  return ToT;
6111 
6112  // Record the imported type.
6113  ImportedTypes[fromTy] = ToT.getTypePtr();
6114 
6115  return ToContext.getQualifiedType(ToT, FromT.getLocalQualifiers());
6116 }
6117 
6119  if (!FromTSI)
6120  return FromTSI;
6121 
6122  // FIXME: For now we just create a "trivial" type source info based
6123  // on the type and a single location. Implement a real version of this.
6124  QualType T = Import(FromTSI->getType());
6125  if (T.isNull())
6126  return nullptr;
6127 
6128  return ToContext.getTrivialTypeSourceInfo(T,
6129  Import(FromTSI->getTypeLoc().getLocStart()));
6130 }
6131 
6133  llvm::DenseMap<Decl *, Decl *>::iterator Pos = ImportedDecls.find(FromD);
6134  if (Pos != ImportedDecls.end()) {
6135  Decl *ToD = Pos->second;
6136  ASTNodeImporter(*this).ImportDefinitionIfNeeded(FromD, ToD);
6137  return ToD;
6138  } else {
6139  return nullptr;
6140  }
6141 }
6142 
6144  if (!FromD)
6145  return nullptr;
6146 
6147  ASTNodeImporter Importer(*this);
6148 
6149  // Check whether we've already imported this declaration.
6150  llvm::DenseMap<Decl *, Decl *>::iterator Pos = ImportedDecls.find(FromD);
6151  if (Pos != ImportedDecls.end()) {
6152  Decl *ToD = Pos->second;
6153  Importer.ImportDefinitionIfNeeded(FromD, ToD);
6154  return ToD;
6155  }
6156 
6157  // Import the type
6158  Decl *ToD = Importer.Visit(FromD);
6159  if (!ToD)
6160  return nullptr;
6161 
6162  // Record the imported declaration.
6163  ImportedDecls[FromD] = ToD;
6164 
6165  if (TagDecl *FromTag = dyn_cast<TagDecl>(FromD)) {
6166  // Keep track of anonymous tags that have an associated typedef.
6167  if (FromTag->getTypedefNameForAnonDecl())
6168  AnonTagsWithPendingTypedefs.push_back(FromTag);
6169  } else if (TypedefNameDecl *FromTypedef = dyn_cast<TypedefNameDecl>(FromD)) {
6170  // When we've finished transforming a typedef, see whether it was the
6171  // typedef for an anonymous tag.
6173  FromTag = AnonTagsWithPendingTypedefs.begin(),
6174  FromTagEnd = AnonTagsWithPendingTypedefs.end();
6175  FromTag != FromTagEnd; ++FromTag) {
6176  if ((*FromTag)->getTypedefNameForAnonDecl() == FromTypedef) {
6177  if (TagDecl *ToTag = cast_or_null<TagDecl>(Import(*FromTag))) {
6178  // We found the typedef for an anonymous tag; link them.
6179  ToTag->setTypedefNameForAnonDecl(cast<TypedefNameDecl>(ToD));
6180  AnonTagsWithPendingTypedefs.erase(FromTag);
6181  break;
6182  }
6183  }
6184  }
6185  }
6186 
6187  return ToD;
6188 }
6189 
6191  if (!FromDC)
6192  return FromDC;
6193 
6194  DeclContext *ToDC = cast_or_null<DeclContext>(Import(cast<Decl>(FromDC)));
6195  if (!ToDC)
6196  return nullptr;
6197 
6198  // When we're using a record/enum/Objective-C class/protocol as a context, we
6199  // need it to have a definition.
6200  if (RecordDecl *ToRecord = dyn_cast<RecordDecl>(ToDC)) {
6201  RecordDecl *FromRecord = cast<RecordDecl>(FromDC);
6202  if (ToRecord->isCompleteDefinition()) {
6203  // Do nothing.
6204  } else if (FromRecord->isCompleteDefinition()) {
6205  ASTNodeImporter(*this).ImportDefinition(FromRecord, ToRecord,
6207  } else {
6208  CompleteDecl(ToRecord);
6209  }
6210  } else if (EnumDecl *ToEnum = dyn_cast<EnumDecl>(ToDC)) {
6211  EnumDecl *FromEnum = cast<EnumDecl>(FromDC);
6212  if (ToEnum->isCompleteDefinition()) {
6213  // Do nothing.
6214  } else if (FromEnum->isCompleteDefinition()) {
6215  ASTNodeImporter(*this).ImportDefinition(FromEnum, ToEnum,
6217  } else {
6218  CompleteDecl(ToEnum);
6219  }
6220  } else if (ObjCInterfaceDecl *ToClass = dyn_cast<ObjCInterfaceDecl>(ToDC)) {
6221  ObjCInterfaceDecl *FromClass = cast<ObjCInterfaceDecl>(FromDC);
6222  if (ToClass->getDefinition()) {
6223  // Do nothing.
6224  } else if (ObjCInterfaceDecl *FromDef = FromClass->getDefinition()) {
6225  ASTNodeImporter(*this).ImportDefinition(FromDef, ToClass,
6227  } else {
6228  CompleteDecl(ToClass);
6229  }
6230  } else if (ObjCProtocolDecl *ToProto = dyn_cast<ObjCProtocolDecl>(ToDC)) {
6231  ObjCProtocolDecl *FromProto = cast<ObjCProtocolDecl>(FromDC);
6232  if (ToProto->getDefinition()) {
6233  // Do nothing.
6234  } else if (ObjCProtocolDecl *FromDef = FromProto->getDefinition()) {
6235  ASTNodeImporter(*this).ImportDefinition(FromDef, ToProto,
6237  } else {
6238  CompleteDecl(ToProto);
6239  }
6240  }
6241 
6242  return ToDC;
6243 }
6244 
6246  if (!FromE)
6247  return nullptr;
6248 
6249  return cast_or_null<Expr>(Import(cast<Stmt>(FromE)));
6250 }
6251 
6253  if (!FromS)
6254  return nullptr;
6255 
6256  // Check whether we've already imported this declaration.
6257  llvm::DenseMap<Stmt *, Stmt *>::iterator Pos = ImportedStmts.find(FromS);
6258  if (Pos != ImportedStmts.end())
6259  return Pos->second;
6260 
6261  // Import the type
6262  ASTNodeImporter Importer(*this);
6263  Stmt *ToS = Importer.Visit(FromS);
6264  if (!ToS)
6265  return nullptr;
6266 
6267  // Record the imported declaration.
6268  ImportedStmts[FromS] = ToS;
6269  return ToS;
6270 }
6271 
6273  if (!FromNNS)
6274  return nullptr;
6275 
6276  NestedNameSpecifier *prefix = Import(FromNNS->getPrefix());
6277 
6278  switch (FromNNS->getKind()) {
6280  if (IdentifierInfo *II = Import(FromNNS->getAsIdentifier())) {
6281  return NestedNameSpecifier::Create(ToContext, prefix, II);
6282  }
6283  return nullptr;
6284 
6286  if (NamespaceDecl *NS =
6287  cast_or_null<NamespaceDecl>(Import(FromNNS->getAsNamespace()))) {
6288  return NestedNameSpecifier::Create(ToContext, prefix, NS);
6289  }
6290  return nullptr;
6291 
6293  if (NamespaceAliasDecl *NSAD =
6294  cast_or_null<NamespaceAliasDecl>(Import(FromNNS->getAsNamespaceAlias()))) {
6295  return NestedNameSpecifier::Create(ToContext, prefix, NSAD);
6296  }
6297  return nullptr;
6298 
6300  return NestedNameSpecifier::GlobalSpecifier(ToContext);
6301 
6303  if (CXXRecordDecl *RD =
6304  cast_or_null<CXXRecordDecl>(Import(FromNNS->getAsRecordDecl()))) {
6305  return NestedNameSpecifier::SuperSpecifier(ToContext, RD);
6306  }
6307  return nullptr;
6308 
6311  QualType T = Import(QualType(FromNNS->getAsType(), 0u));
6312  if (!T.isNull()) {
6313  bool bTemplate = FromNNS->getKind() ==
6315  return NestedNameSpecifier::Create(ToContext, prefix,
6316  bTemplate, T.getTypePtr());
6317  }
6318  }
6319  return nullptr;
6320  }
6321 
6322  llvm_unreachable("Invalid nested name specifier kind");
6323 }
6324 
6326  // Copied from NestedNameSpecifier mostly.
6328  NestedNameSpecifierLoc NNS = FromNNS;
6329 
6330  // Push each of the nested-name-specifiers's onto a stack for
6331  // serialization in reverse order.
6332  while (NNS) {
6333  NestedNames.push_back(NNS);
6334  NNS = NNS.getPrefix();
6335  }
6336 
6338 
6339  while (!NestedNames.empty()) {
6340  NNS = NestedNames.pop_back_val();
6342  if (!Spec)
6343  return NestedNameSpecifierLoc();
6344 
6346  switch (Kind) {
6348  Builder.Extend(getToContext(),
6349  Spec->getAsIdentifier(),
6350  Import(NNS.getLocalBeginLoc()),
6351  Import(NNS.getLocalEndLoc()));
6352  break;
6353 
6355  Builder.Extend(getToContext(),
6356  Spec->getAsNamespace(),
6357  Import(NNS.getLocalBeginLoc()),
6358  Import(NNS.getLocalEndLoc()));
6359  break;
6360 
6362  Builder.Extend(getToContext(),
6363  Spec->getAsNamespaceAlias(),
6364  Import(NNS.getLocalBeginLoc()),
6365  Import(NNS.getLocalEndLoc()));
6366  break;
6367 
6371  QualType(Spec->getAsType(), 0));
6372  Builder.Extend(getToContext(),
6373  Import(NNS.getLocalBeginLoc()),
6374  TSI->getTypeLoc(),
6375  Import(NNS.getLocalEndLoc()));
6376  break;
6377  }
6378 
6380  Builder.MakeGlobal(getToContext(), Import(NNS.getLocalBeginLoc()));
6381  break;
6382 
6384  SourceRange ToRange = Import(NNS.getSourceRange());
6385  Builder.MakeSuper(getToContext(),
6386  Spec->getAsRecordDecl(),
6387  ToRange.getBegin(),
6388  ToRange.getEnd());
6389  }
6390  }
6391  }
6392 
6393  return Builder.getWithLocInContext(getToContext());
6394 }
6395 
6397  switch (From.getKind()) {
6399  if (TemplateDecl *ToTemplate
6400  = cast_or_null<TemplateDecl>(Import(From.getAsTemplateDecl())))
6401  return TemplateName(ToTemplate);
6402 
6403  return TemplateName();
6404 
6406  OverloadedTemplateStorage *FromStorage = From.getAsOverloadedTemplate();
6407  UnresolvedSet<2> ToTemplates;
6408  for (OverloadedTemplateStorage::iterator I = FromStorage->begin(),
6409  E = FromStorage->end();
6410  I != E; ++I) {
6411  if (NamedDecl *To = cast_or_null<NamedDecl>(Import(*I)))
6412  ToTemplates.addDecl(To);
6413  else
6414  return TemplateName();
6415  }
6416  return ToContext.getOverloadedTemplateName(ToTemplates.begin(),
6417  ToTemplates.end());
6418  }
6419 
6422  NestedNameSpecifier *Qualifier = Import(QTN->getQualifier());
6423  if (!Qualifier)
6424  return TemplateName();
6425 
6426  if (TemplateDecl *ToTemplate
6427  = cast_or_null<TemplateDecl>(Import(From.getAsTemplateDecl())))
6428  return ToContext.getQualifiedTemplateName(Qualifier,
6429  QTN->hasTemplateKeyword(),
6430  ToTemplate);
6431 
6432  return TemplateName();
6433  }
6434 
6437  NestedNameSpecifier *Qualifier = Import(DTN->getQualifier());
6438  if (!Qualifier)
6439  return TemplateName();
6440 
6441  if (DTN->isIdentifier()) {
6442  return ToContext.getDependentTemplateName(Qualifier,
6443  Import(DTN->getIdentifier()));
6444  }
6445 
6446  return ToContext.getDependentTemplateName(Qualifier, DTN->getOperator());
6447  }
6448 
6453  = cast_or_null<TemplateTemplateParmDecl>(Import(subst->getParameter()));
6454  if (!param)
6455  return TemplateName();
6456 
6457  TemplateName replacement = Import(subst->getReplacement());
6458  if (replacement.isNull()) return TemplateName();
6459 
6460  return ToContext.getSubstTemplateTemplateParm(param, replacement);
6461  }
6462 
6467  = cast_or_null<TemplateTemplateParmDecl>(
6468  Import(SubstPack->getParameterPack()));
6469  if (!Param)
6470  return TemplateName();
6471 
6472  ASTNodeImporter Importer(*this);
6473  TemplateArgument ArgPack
6474  = Importer.ImportTemplateArgument(SubstPack->getArgumentPack());
6475  if (ArgPack.isNull())
6476  return TemplateName();
6477 
6478  return ToContext.getSubstTemplateTemplateParmPack(Param, ArgPack);
6479  }
6480  }
6481 
6482  llvm_unreachable("Invalid template name kind");
6483 }
6484 
6486  if (FromLoc.isInvalid())
6487  return SourceLocation();
6488 
6489  SourceManager &FromSM = FromContext.getSourceManager();
6490 
6491  // For now, map everything down to its file location, so that we
6492  // don't have to import macro expansions.
6493  // FIXME: Import macro expansions!
6494  FromLoc = FromSM.getFileLoc(FromLoc);
6495  std::pair<FileID, unsigned> Decomposed = FromSM.getDecomposedLoc(FromLoc);
6496  SourceManager &ToSM = ToContext.getSourceManager();
6497  FileID ToFileID = Import(Decomposed.first);
6498  if (ToFileID.isInvalid())
6499  return SourceLocation();
6500  SourceLocation ret = ToSM.getLocForStartOfFile(ToFileID)
6501  .getLocWithOffset(Decomposed.second);
6502  return ret;
6503 }
6504 
6506  return SourceRange(Import(FromRange.getBegin()), Import(FromRange.getEnd()));
6507 }
6508 
6510  llvm::DenseMap<FileID, FileID>::iterator Pos
6511  = ImportedFileIDs.find(FromID);
6512  if (Pos != ImportedFileIDs.end())
6513  return Pos->second;
6514 
6515  SourceManager &FromSM = FromContext.getSourceManager();
6516  SourceManager &ToSM = ToContext.getSourceManager();
6517  const SrcMgr::SLocEntry &FromSLoc = FromSM.getSLocEntry(FromID);
6518  assert(FromSLoc.isFile() && "Cannot handle macro expansions yet");
6519 
6520  // Include location of this file.
6521  SourceLocation ToIncludeLoc = Import(FromSLoc.getFile().getIncludeLoc());
6522 
6523  // Map the FileID for to the "to" source manager.
6524  FileID ToID;
6525  const SrcMgr::ContentCache *Cache = FromSLoc.getFile().getContentCache();
6526  if (Cache->OrigEntry && Cache->OrigEntry->getDir()) {
6527  // FIXME: We probably want to use getVirtualFile(), so we don't hit the
6528  // disk again
6529  // FIXME: We definitely want to re-use the existing MemoryBuffer, rather
6530  // than mmap the files several times.
6531  const FileEntry *Entry = ToFileManager.getFile(Cache->OrigEntry->getName());
6532  if (!Entry)
6533  return FileID();
6534  ToID = ToSM.createFileID(Entry, ToIncludeLoc,
6535  FromSLoc.getFile().getFileCharacteristic());
6536  } else {
6537  // FIXME: We want to re-use the existing MemoryBuffer!
6538  const llvm::MemoryBuffer *
6539  FromBuf = Cache->getBuffer(FromContext.getDiagnostics(), FromSM);
6540  std::unique_ptr<llvm::MemoryBuffer> ToBuf
6541  = llvm::MemoryBuffer::getMemBufferCopy(FromBuf->getBuffer(),
6542  FromBuf->getBufferIdentifier());
6543  ToID = ToSM.createFileID(std::move(ToBuf),
6544  FromSLoc.getFile().getFileCharacteristic());
6545  }
6546 
6547 
6548  ImportedFileIDs[FromID] = ToID;
6549  return ToID;
6550 }
6551 
6553  Expr *ToExpr = Import(From->getInit());
6554  if (!ToExpr && From->getInit())
6555  return nullptr;
6556 
6557  if (From->isBaseInitializer()) {
6558  TypeSourceInfo *ToTInfo = Import(From->getTypeSourceInfo());
6559  if (!ToTInfo && From->getTypeSourceInfo())
6560  return nullptr;
6561 
6562  return new (ToContext) CXXCtorInitializer(
6563  ToContext, ToTInfo, From->isBaseVirtual(), Import(From->getLParenLoc()),
6564  ToExpr, Import(From->getRParenLoc()),
6565  From->isPackExpansion() ? Import(From->getEllipsisLoc())
6566  : SourceLocation());
6567  } else if (From->isMemberInitializer()) {
6568  FieldDecl *ToField =
6569  llvm::cast_or_null<FieldDecl>(Import(From->getMember()));
6570  if (!ToField && From->getMember())
6571  return nullptr;
6572 
6573  return new (ToContext) CXXCtorInitializer(
6574  ToContext, ToField, Import(From->getMemberLocation()),
6575  Import(From->getLParenLoc()), ToExpr, Import(From->getRParenLoc()));
6576  } else if (From->isIndirectMemberInitializer()) {
6577  IndirectFieldDecl *ToIField = llvm::cast_or_null<IndirectFieldDecl>(
6578  Import(From->getIndirectMember()));
6579  if (!ToIField && From->getIndirectMember())
6580  return nullptr;
6581 
6582  return new (ToContext) CXXCtorInitializer(
6583  ToContext, ToIField, Import(From->getMemberLocation()),
6584  Import(From->getLParenLoc()), ToExpr, Import(From->getRParenLoc()));
6585  } else if (From->isDelegatingInitializer()) {
6586  TypeSourceInfo *ToTInfo = Import(From->getTypeSourceInfo());
6587  if (!ToTInfo && From->getTypeSourceInfo())
6588  return nullptr;
6589 
6590  return new (ToContext)
6591  CXXCtorInitializer(ToContext, ToTInfo, Import(From->getLParenLoc()),
6592  ToExpr, Import(From->getRParenLoc()));
6593  } else {
6594  return nullptr;
6595  }
6596 }
6597 
6598 
6600  auto Pos = ImportedCXXBaseSpecifiers.find(BaseSpec);
6601  if (Pos != ImportedCXXBaseSpecifiers.end())
6602  return Pos->second;
6603 
6604  CXXBaseSpecifier *Imported = new (ToContext) CXXBaseSpecifier(
6605  Import(BaseSpec->getSourceRange()),
6606  BaseSpec->isVirtual(), BaseSpec->isBaseOfClass(),
6607  BaseSpec->getAccessSpecifierAsWritten(),
6608  Import(BaseSpec->getTypeSourceInfo()),
6609  Import(BaseSpec->getEllipsisLoc()));
6610  ImportedCXXBaseSpecifiers[BaseSpec] = Imported;
6611  return Imported;
6612 }
6613 
6615  Decl *To = Import(From);
6616  if (!To)
6617  return;
6618 
6619  if (DeclContext *FromDC = cast<DeclContext>(From)) {
6620  ASTNodeImporter Importer(*this);
6621 
6622  if (RecordDecl *ToRecord = dyn_cast<RecordDecl>(To)) {
6623  if (!ToRecord->getDefinition()) {
6624  Importer.ImportDefinition(cast<RecordDecl>(FromDC), ToRecord,
6626  return;
6627  }
6628  }
6629 
6630  if (EnumDecl *ToEnum = dyn_cast<EnumDecl>(To)) {
6631  if (!ToEnum->getDefinition()) {
6632  Importer.ImportDefinition(cast<EnumDecl>(FromDC), ToEnum,
6634  return;
6635  }
6636  }
6637 
6638  if (ObjCInterfaceDecl *ToIFace = dyn_cast<ObjCInterfaceDecl>(To)) {
6639  if (!ToIFace->getDefinition()) {
6640  Importer.ImportDefinition(cast<ObjCInterfaceDecl>(FromDC), ToIFace,
6642  return;
6643  }
6644  }
6645 
6646  if (ObjCProtocolDecl *ToProto = dyn_cast<ObjCProtocolDecl>(To)) {
6647  if (!ToProto->getDefinition()) {
6648  Importer.ImportDefinition(cast<ObjCProtocolDecl>(FromDC), ToProto,
6650  return;
6651  }
6652  }
6653 
6654  Importer.ImportDeclContext(FromDC, true);
6655  }
6656 }
6657 
6659  if (!FromName)
6660  return DeclarationName();
6661 
6662  switch (FromName.getNameKind()) {
6664  return Import(FromName.getAsIdentifierInfo());
6665 
6669  return Import(FromName.getObjCSelector());
6670 
6672  QualType T = Import(FromName.getCXXNameType());
6673  if (T.isNull())
6674  return DeclarationName();
6675 
6676  return ToContext.DeclarationNames.getCXXConstructorName(
6677  ToContext.getCanonicalType(T));
6678  }
6679 
6681  QualType T = Import(FromName.getCXXNameType());
6682  if (T.isNull())
6683  return DeclarationName();
6684 
6685  return ToContext.DeclarationNames.getCXXDestructorName(
6686  ToContext.getCanonicalType(T));
6687  }
6688 
6690  TemplateDecl *Template = cast_or_null<TemplateDecl>(
6691  Import(FromName.getCXXDeductionGuideTemplate()));
6692  if (!Template)
6693  return DeclarationName();
6694  return ToContext.DeclarationNames.getCXXDeductionGuideName(Template);
6695  }
6696 
6698  QualType T = Import(FromName.getCXXNameType());
6699  if (T.isNull())
6700  return DeclarationName();
6701 
6703  ToContext.getCanonicalType(T));
6704  }
6705 
6707  return ToContext.DeclarationNames.getCXXOperatorName(
6708  FromName.getCXXOverloadedOperator());
6709 
6712  Import(FromName.getCXXLiteralIdentifier()));
6713 
6715  // FIXME: STATICS!
6717  }
6718 
6719  llvm_unreachable("Invalid DeclarationName Kind!");
6720 }
6721 
6723  if (!FromId)
6724  return nullptr;
6725 
6726  IdentifierInfo *ToId = &ToContext.Idents.get(FromId->getName());
6727 
6728  if (!ToId->getBuiltinID() && FromId->getBuiltinID())
6729  ToId->setBuiltinID(FromId->getBuiltinID());
6730 
6731  return ToId;
6732 }
6733 
6735  if (FromSel.isNull())
6736  return Selector();
6737 
6739  Idents.push_back(Import(FromSel.getIdentifierInfoForSlot(0)));
6740  for (unsigned I = 1, N = FromSel.getNumArgs(); I < N; ++I)
6741  Idents.push_back(Import(FromSel.getIdentifierInfoForSlot(I)));
6742  return ToContext.Selectors.getSelector(FromSel.getNumArgs(), Idents.data());
6743 }
6744 
6746  DeclContext *DC,
6747  unsigned IDNS,
6748  NamedDecl **Decls,
6749  unsigned NumDecls) {
6750  return Name;
6751 }
6752 
6754  if (LastDiagFromFrom)
6756  FromContext.getDiagnostics());
6757  LastDiagFromFrom = false;
6758  return ToContext.getDiagnostics().Report(Loc, DiagID);
6759 }
6760 
6762  if (!LastDiagFromFrom)
6764  ToContext.getDiagnostics());
6765  LastDiagFromFrom = true;
6766  return FromContext.getDiagnostics().Report(Loc, DiagID);
6767 }
6768 
6770  if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
6771  if (!ID->getDefinition())
6772  ID->startDefinition();
6773  }
6774  else if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl>(D)) {
6775  if (!PD->getDefinition())
6776  PD->startDefinition();
6777  }
6778  else if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
6779  if (!TD->getDefinition() && !TD->isBeingDefined()) {
6780  TD->startDefinition();
6781  TD->setCompleteDefinition(true);
6782  }
6783  }
6784  else {
6785  assert (0 && "CompleteDecl called on a Decl that can't be completed");
6786  }
6787 }
6788 
6790  if (From->hasAttrs()) {
6791  for (Attr *FromAttr : From->getAttrs())
6792  To->addAttr(FromAttr->clone(To->getASTContext()));
6793  }
6794  if (From->isUsed()) {
6795  To->setIsUsed();
6796  }
6797  if (From->isImplicit()) {
6798  To->setImplicit();
6799  }
6800  ImportedDecls[From] = To;
6801  return To;
6802 }
6803 
6805  bool Complain) {
6806  llvm::DenseMap<const Type *, const Type *>::iterator Pos
6807  = ImportedTypes.find(From.getTypePtr());
6808  if (Pos != ImportedTypes.end() && ToContext.hasSameType(Import(From), To))
6809  return true;
6810 
6811  StructuralEquivalenceContext Ctx(FromContext, ToContext, NonEquivalentDecls,
6812  false, Complain);
6813  return Ctx.IsStructurallyEquivalent(From, To);
6814 }
SourceLocation getRParenLoc() const
Definition: Stmt.h:1188
Expr * getInc()
Definition: Stmt.h:1241
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
Definition: Decl.cpp:2397
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
Definition: DeclCXX.h:2238
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
bool hasArrayFiller() const
Return true if this is an array initializer and its array "filler" has been set.
Definition: Expr.h:3976
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
Represents a single C99 designator.
Definition: Expr.h:4181
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl)
Definition: DeclCXX.cpp:2307
SourceLocation getStartLoc() const
Definition: Stmt.h:511
SourceLocation getGetterNameLoc() const
Definition: DeclObjC.h:924
TemplateTemplateParmDecl * getParameterPack() const
Retrieve the template template parameter pack being substituted.
Definition: TemplateName.h:135
void setValueDependent(bool VD)
Set whether this expression is value-dependent or not.
Definition: Expr.h:152
QualType getPattern() const
Retrieve the pattern of this pack expansion, which is the type that will be repeatedly instantiated w...
Definition: Type.h:5021
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
SourceLocation getRBracLoc() const
Definition: Stmt.h:684
Defines the clang::ASTContext interface.
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it&#39;s either not been deduced or was deduce...
Definition: Type.h:4387
IdentifierInfo * getInputIdentifier(unsigned i) const
Definition: Stmt.h:1738
Decl * VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D)
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
Definition: Type.h:4784
ObjCPropertyQueryKind getQueryKind() const
Definition: DeclObjC.h:898
const FileEntry * OrigEntry
Reference to the file entry representing this ContentCache.
void setOwningFunction(DeclContext *FD)
setOwningFunction - Sets the function declaration that owns this ParmVarDecl.
Definition: Decl.h:1659
TemplateParameterList * ImportTemplateParameterList(TemplateParameterList *Params)
Stmt * VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S)
Expr * VisitCXXMemberCallExpr(CXXMemberCallExpr *E)
SourceLocation getRParenLoc() const
Definition: Stmt.h:1641
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:3128
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:565
const CXXDestructorDecl * getDestructor() const
Definition: ExprCXX.h:1175
Expr * VisitConditionalOperator(ConditionalOperator *E)
static unsigned getFieldIndex(Decl *F)
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:1620
void setImplicit(bool I=true)
Definition: DeclBase.h:552
Decl * VisitCXXMethodDecl(CXXMethodDecl *D)
An instance of this class is created to represent a function declaration or definition.
Definition: Decl.h:1697
SourceLocation getForLoc() const
Definition: StmtCXX.h:193
NamedDecl * getFoundDecl()
Get the NamedDecl through which this reference occurred.
Definition: Expr.h:1078
QualType VisitVectorType(const VectorType *T)
bool getValue() const
Definition: ExprCXX.h:2382
Decl * VisitEnumDecl(EnumDecl *D)
void localUncachedLookup(DeclarationName Name, SmallVectorImpl< NamedDecl *> &Results)
A simplistic name lookup mechanism that performs name lookup into this declaration context without co...
Definition: DeclBase.cpp:1626
Expr * getLHS() const
Definition: Expr.h:3314
Expr * getInit() const
Get the initializer.
Definition: DeclCXX.h:2367
bool isKindOfTypeAsWritten() const
Whether this is a "__kindof" type as written.
Definition: Type.h:5301
const Stmt * getElse() const
Definition: Stmt.h:973
unsigned getNumInputs() const
Definition: Stmt.h:1536
SourceLocation getRParenLoc() const
Definition: Expr.h:2345
void setArrayFiller(Expr *filler)
Definition: Expr.cpp:1909
Stmt * VisitDoStmt(DoStmt *S)
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
Smart pointer class that efficiently represents Objective-C method names.
This is a discriminated union of FileInfo and ExpansionInfo.
SourceLocation getForLoc() const
Definition: Stmt.h:1254
void setAnonymousStructOrUnion(bool Anon)
Definition: Decl.h:3557
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2283
ArrayRef< QualType > getTypeArgsAsWritten() const
Retrieve the type arguments of this object type as they were written.
Definition: Type.h:5295
QualType getPointeeType() const
Definition: Type.h:2296
llvm::iterator_range< arg_iterator > placement_arguments()
Definition: ExprCXX.h:2015
SourceLocation getUsedLocation() const
Retrieve the location where this default argument was actually used.
Definition: ExprCXX.h:1086
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
Definition: Type.h:3727
bool hasTemplateKeyword() const
Whether the template name was prefixed by the "template" keyword.
Definition: TemplateName.h:392
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2146
A (possibly-)qualified type.
Definition: Type.h:653
uint64_t getValue() const
Definition: ExprCXX.h:2472
QualType VisitDecltypeType(const DecltypeType *T)
Decl * VisitUsingShadowDecl(UsingShadowDecl *D)
const char * getDeclKindName() const
Definition: DeclBase.cpp:123
StringKind getKind() const
Definition: Expr.h:1597
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
Definition: TemplateName.h:494
base_class_range bases()
Definition: DeclCXX.h:773
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Definition: Expr.h:2483
void setTemplateKeywordLoc(SourceLocation Loc)
Sets the location of the template keyword.
unsigned param_size() const
Definition: DeclObjC.h:379
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:2278
Stmt * VisitCaseStmt(CaseStmt *S)
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2344
QualType getInjectedSpecializationType() const
Definition: Type.h:4665
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
Definition: TemplateName.h:478
Implements support for file system lookup, file system caching, and directory search management...
Definition: FileManager.h:116
SourceRange getCXXOperatorNameRange() const
getCXXOperatorNameRange - Gets the range of the operator name (without the operator keyword)...
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
Definition: DeclObjC.cpp:603
SourceLocation getEllipsisLoc() const
Definition: Stmt.h:759
SourceLocation getLParen() const
Get the location of the left parentheses &#39;(&#39;.
Definition: Expr.h:1689
ObjCTypeParamList * ImportObjCTypeParamList(ObjCTypeParamList *list)
const Expr * getSubExpr() const
Definition: ExprCXX.h:1007
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition: DeclCXX.h:3553
SourceLocation getLParenLoc() const
Definition: DeclCXX.h:2363
Expr * getCond()
Definition: Stmt.h:1131
inputs_range inputs()
Definition: Stmt.h:1569
QualType VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T)
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
Definition: DeclObjC.h:1549
Defines the clang::FileManager interface and associated types.
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:2846
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
static CXXDependentScopeMemberExpr * Create(const ASTContext &C, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Definition: ExprCXX.cpp:1147
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2339
Stmt * VisitObjCAtCatchStmt(ObjCAtCatchStmt *S)
CompoundStmt * getSubStmt()
Definition: Expr.h:3504
DeclarationName getCXXConstructorName(CanQualType Ty)
getCXXConstructorName - Returns the name of a C++ constructor for the given Type. ...
Decl * VisitDecl(Decl *D)
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
Definition: Decl.h:2590
Expr * getUnderlyingExpr() const
Definition: Type.h:3862
Stmt * VisitContinueStmt(ContinueStmt *S)
SourceLocation getRParenLoc() const
Definition: StmtObjC.h:104
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, llvm::MutableArrayRef< NamedDecl *> CH)
Definition: Decl.cpp:4306
bool isThrownVariableInScope() const
Determines whether the variable thrown by this expression (if any!) is within the innermost try block...
Definition: ExprCXX.h:1017
Stmt - This represents one statement.
Definition: Stmt.h:66
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition: Expr.h:2266
Expr * getDimensionExpression() const
Definition: ExprCXX.h:2474
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
Definition: StmtObjC.h:224
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2402
Expr * getBitWidth() const
Definition: Decl.h:2556
Kind getKind() const
Definition: Type.h:2164
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
Definition: Decl.h:4111
CXXCatchStmt * getHandler(unsigned i)
Definition: StmtCXX.h:104
bool IsICE
Whether this statement is an integral constant expression, or in C++11, whether the statement is a co...
Definition: Decl.h:794
bool isArrayFormAsWritten() const
Definition: ExprCXX.h:2113
IfStmt - This represents an if/then/else.
Definition: Stmt.h:933
ClassTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition: Expr.h:1961
SourceLocation getLocation() const
Definition: Expr.h:1439
Expr * VisitImplicitCastExpr(ImplicitCastExpr *E)
Expr * VisitExpressionTraitExpr(ExpressionTraitExpr *E)
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
Definition: Decl.h:2671
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)
Definition: ExprCXX.cpp:579
SourceLocation getSuperClassLoc() const
Retrieve the starting location of the superclass.
Definition: DeclObjC.cpp:350
Expr * VisitCXXConstructExpr(CXXConstructExpr *E)
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1009
Decl * VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D)
TypedefDecl - Represents the declaration of a typedef-name via the &#39;typedef&#39; type specifier...
Definition: Decl.h:2898
unsigned getNumOutputs() const
Definition: Stmt.h:1514
Defines the SourceManager interface.
Microsoft&#39;s &#39;__super&#39; specifier, stored as a CXXRecordDecl* of the class it appeared in...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
Definition: Decl.h:2042
Expr * VisitBinaryOperator(BinaryOperator *E)
SourceLocation getRBracketLoc() const
Definition: Expr.h:4264
The template argument is an expression, and we&#39;ve not resolved it to one of the other forms yet...
Definition: TemplateBase.h:87
Expr * getBase() const
Definition: Expr.h:2477
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Definition: DeclTemplate.h:270
static TemplateTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params)
const StringLiteral * getAsmString() const
Definition: Stmt.h:1646
DeclarationName getCXXConversionFunctionName(CanQualType Ty)
getCXXConversionFunctionName - Returns the name of a C++ conversion function for the given Type...
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:2673
iterator end()
Definition: DeclGroup.h:106
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Definition: ASTContext.h:1880
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1150
bool hasLeadingEmptyMacro() const
Definition: Stmt.h:580
Stmt * getHandlerBlock() const
Definition: StmtCXX.h:52
DeclGroupRef ImportDeclGroup(DeclGroupRef DG)
Expr * VisitPackExpansionExpr(PackExpansionExpr *E)
llvm::APFloat getValue() const
Definition: Expr.h:1405
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition: Expr.h:4545
FunctionDecl * getOperatorNew() const
Definition: ExprCXX.h:1942
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
Definition: Decl.cpp:2083
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
Definition: DeclCXX.h:244
void setType(QualType t)
Definition: Expr.h:129
Selector getObjCSelector() const
getObjCSelector - Get the Objective-C selector stored in this declaration name.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
const Expr * getSubExpr() const
Definition: Expr.h:3796
Opcode getOpcode() const
Definition: Expr.h:3026
Represents a C++11 auto or C++14 decltype(auto) type.
Definition: Type.h:4401
unsigned getNumSubExprs() const
Retrieve the total number of subexpressions in this designated initializer expression, including the actual initialized value and any expressions that occur within array and array-range designators.
Definition: Expr.h:4352
SourceLocation getIdentLoc() const
Definition: Stmt.h:858
void setPure(bool P=true)
Definition: Decl.cpp:2632
Represents an attribute applied to a statement.
Definition: Stmt.h:881
bool hasWrittenPrototype() const
Definition: Decl.h:2034
static ObjCProtocolDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc, ObjCProtocolDecl *PrevDecl)
Definition: DeclObjC.cpp:1820
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:1665
known_categories_range known_categories() const
Definition: DeclObjC.h:1706
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
Definition: DeclBase.h:952
NamedDecl * getDecl() const
static ObjCPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, SourceLocation AtLocation, SourceLocation LParenLocation, QualType T, TypeSourceInfo *TSI, PropertyControl propControl=None)
Definition: DeclObjC.cpp:2187
SourceLocation getColonLoc() const
The location of the colon following the access specifier.
Definition: DeclCXX.h:153
SourceLocation getLocStart() const LLVM_READONLY
Definition: Expr.h:3761
The base class of the type hierarchy.
Definition: Type.h:1351
Represents an empty-declaration.
Definition: Decl.h:4081
Represents Objective-C&#39;s @throw statement.
Definition: StmtObjC.h:313
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called...
Definition: ExprCXX.h:1329
DiagnosticsEngine & getDiagnostics() const
QualType VisitTemplateSpecializationType(const TemplateSpecializationType *T)
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1207
bool hasExplicitTemplateArgs() const
Determines whether this declaration reference was followed by an explicit template argument list...
Definition: Expr.h:1119
SourceLocation getLocation() const
Definition: ExprCXX.h:580
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Definition: Type.h:2558
Declaration of a variable template.
SourceLocation getRParenLoc() const
Definition: Expr.h:2101
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Definition: TemplateBase.h:64
NamespaceDecl - Represent a C++ namespace.
Definition: Decl.h:505
Expr * VisitOffsetOfExpr(OffsetOfExpr *OE)
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1239
RetTy Visit(const Type *T)
Performs the operation associated with this visitor object.
Definition: TypeVisitor.h:69
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to...
Definition: Expr.h:2906
protocol_iterator protocol_begin() const
Definition: DeclObjC.h:1389
FPOptions getFPFeatures() const
Definition: Expr.h:3157
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Definition: ExprCXX.h:2423
void setSpecializationKind(TemplateSpecializationKind TSK)
virtual void completeDefinition()
completeDefinition - Notes that the definition of this type is now complete.
Definition: Decl.cpp:3969
SourceLocation getLParenLoc() const
Definition: Expr.h:2948
Decl * VisitFieldDecl(FieldDecl *D)
A container of type source information.
Definition: Decl.h:86
void setSwitchCaseList(SwitchCase *SC)
Set the case list for this switch statement.
Definition: Stmt.h:1060
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
Definition: Type.h:5629
bool isEmpty() const
Evaluates true when this declaration name is empty.
Decl * VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D)
static AttributedStmt * Create(const ASTContext &C, SourceLocation Loc, ArrayRef< const Attr *> Attrs, Stmt *SubStmt)
Definition: Stmt.cpp:336
Expr * VisitTypeTraitExpr(TypeTraitExpr *E)
static StringLiteral * Create(const ASTContext &C, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumStrs)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
Definition: Expr.cpp:854
bool ImportTemplateArgumentListInfo(const InContainerTy &Container, TemplateArgumentListInfo &ToTAInfo)
QualType VisitInjectedClassNameType(const InjectedClassNameType *T)
SourceLocation getGotoLoc() const
Definition: Stmt.h:1328
void setTemplateArgsInfo(const TemplateArgumentListInfo &ArgsInfo)
static CXXFunctionalCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, TypeSourceInfo *Written, CastKind Kind, Expr *Op, const CXXCastPath *Path, SourceLocation LPLoc, SourceLocation RPLoc)
Definition: ExprCXX.cpp:675
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclBase.h:412
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:1825
const Expr * getAnyInitializer() const
getAnyInitializer - Get the initializer for this variable, no matter which declaration it is attached...
Definition: Decl.h:1202
SourceLocation getColonLoc() const
Retrieve the location of the &#39;:&#39; separating the type parameter name from the explicitly-specified bou...
Definition: DeclObjC.h:640
Decl * VisitNamespaceAliasDecl(NamespaceAliasDecl *D)
param_const_iterator param_end() const
Definition: DeclObjC.h:390
TemplateTypeParmDecl * getDecl() const
Definition: Type.h:4222
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2397
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:4035
A template template parameter that has been substituted for some other template name.
Definition: TemplateName.h:206
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition: Decl.h:1991
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
bool isPackExpansion() const
Determine whether this initializer is a pack expansion.
Definition: DeclCXX.h:2271
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
Definition: DeclCXX.h:3039
QualType getElementType() const
Definition: Type.h:2593
DeclarationName getCXXDeductionGuideName(TemplateDecl *TD)
Returns the name of a C++ deduction guide for the given template.
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
Definition: Decl.h:3097
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "while" statement, if any.
Definition: Stmt.cpp:900
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
Definition: TemplateName.h:484
SourceLocation getCoawaitLoc() const
Definition: StmtCXX.h:194
Expr * getIndexExpr(unsigned Idx)
Definition: Expr.h:1989
bool isIndirectMemberInitializer() const
Definition: DeclCXX.h:2250
An identifier, stored as an IdentifierInfo*.
Stmt * getSubStmt()
Definition: Stmt.h:814
Expr * VisitStringLiteral(StringLiteral *E)
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:2052
unsigned getDepth() const
Get the nesting depth of the template parameter.
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Definition: DeclFriend.h:54
QualType VisitPointerType(const PointerType *T)
VarDecl - An instance of this class is created to represent a variable declaration or definition...
Definition: Decl.h:806
void setImplementation(ObjCCategoryImplDecl *ImplD)
Definition: DeclObjC.cpp:1989
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isExplicit, bool isConstexpr, SourceLocation EndLocation)
Definition: DeclCXX.cpp:2229
const VarDecl * getNRVOCandidate() const
Retrieve the variable that might be used for the named return value optimization. ...
Definition: Stmt.h:1444
SourceLocation getLParenLoc() const
Definition: Stmt.h:1256
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:2637
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
SourceLocation getOperatorLoc() const
Retrieve the location of the &#39;.&#39; or &#39;->&#39; operator.
Definition: ExprCXX.h:2263
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
Stmt * VisitLabelStmt(LabelStmt *S)
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Definition: Decl.h:3426
OpaqueValueExpr * getCommonExpr() const
Get the common subexpression shared by all initializations (the source array).
Definition: Expr.h:4507
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:6305
bool hasDefaultArg() const
hasDefaultArg - Determines whether this parameter has a default argument, either parsed or not...
Definition: Decl.cpp:2541
ObjCCategoryImplDecl * getImplementation() const
Definition: DeclObjC.cpp:1984
Expr * VisitIntegerLiteral(IntegerLiteral *E)
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
Definition: ExprCXX.h:2388
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:57
SourceLocation getExternLoc() const
Gets the location of the extern keyword, if present.
Extra information about a function prototype.
Definition: Type.h:3387
bool hasInheritedDefaultArg() const
Definition: Decl.h:1641
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Definition: DeclBase.h:1580
SourceLocation getColonLoc() const
Definition: Expr.h:3259
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
Represents a variable template specialization, which refers to a variable template with a given set o...
SourceLocation getLocStart() const LLVM_READONLY
Definition: Expr.h:1228
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
SourceLocation getLAngleLoc() const
Definition: DeclTemplate.h:173
Decl * VisitVarDecl(VarDecl *D)
A namespace, stored as a NamespaceDecl*.
DiagnosticBuilder ToDiag(SourceLocation Loc, unsigned DiagID)
Report a diagnostic in the "to" context.
llvm::PointerUnion< NamedDecl *, TypeSourceInfo * > FriendUnion
Definition: DeclFriend.h:60
SourceLocation getIfLoc() const
Definition: Stmt.h:980
Expr * VisitUnaryOperator(UnaryOperator *E)
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:68
unsigned getNumPlacementArgs() const
Definition: ExprCXX.h:1956
Expr * VisitAtomicExpr(AtomicExpr *E)
TypeSourceInfo * getArgumentTypeInfo() const
Definition: Expr.h:2071
bool isMemberInitializer() const
Determine whether this initializer is initializing a non-static data member.
Definition: DeclCXX.h:2244
TemplateName getSubstTemplateTemplateParm(TemplateTemplateParmDecl *param, TemplateName replacement) const
SourceLocation getEllipsisLoc() const
Definition: DeclCXX.h:2276
unsigned getNumExpressions() const
Definition: Expr.h:2004
SourceLocation getLocation() const
Retrieve the location of the literal.
Definition: Expr.h:1321
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
QualType Import(QualType FromT)
Import the given type from the "from" context into the "to" context.
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:985
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Definition: ExprCXX.h:3000
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
Definition: DeclCXX.h:162
ParmVarDecl - Represents a parameter to a function.
Definition: Decl.h:1513
bool ImportTemplateArguments(const TemplateArgument *FromArgs, unsigned NumFromArgs, SmallVectorImpl< TemplateArgument > &ToArgs)
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:4256
DeclarationNameInfo getNameInfo() const
Definition: DeclCXX.h:3543
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "switch" statement, if any.
Definition: Stmt.cpp:866
SourceLocation getRParenLoc() const
Definition: DeclCXX.h:2364
QualType getIntegralType() const
Retrieve the type of the integral value.
Definition: TemplateBase.h:315
BoundNodesTreeBuilder Nodes
const ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.h:2708
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
Decl * VisitStaticAssertDecl(StaticAssertDecl *D)
const Stmt * getSubStmt() const
Definition: StmtObjC.h:356
void setTemplateSpecializationKind(TemplateSpecializationKind TSK)
Set the kind of specialization or template instantiation this is.
Definition: DeclCXX.cpp:1398
const char * getStmtClassName() const
Definition: Stmt.cpp:74
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
Definition: Decl.h:265
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Definition: ExprCXX.h:279
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:842
SourceLocation getDotLoc() const
Definition: Expr.h:4248
RecordDecl - Represents a struct/union/class.
Definition: Decl.h:3488
Represents a C99 designated initializer expression.
Definition: Expr.h:4106
LanguageIDs getLanguage() const
Return the language specified by this linkage specification.
Definition: DeclCXX.h:2789
SourceLocation getVarianceLoc() const
Retrieve the location of the variance keyword.
Definition: DeclObjC.h:629
Decl * VisitObjCCategoryDecl(ObjCCategoryDecl *D)
QualType VisitBlockPointerType(const BlockPointerType *T)
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the class template specialization.
virtual 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.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
Definition: Decl.h:291
QualType getOriginalType() const
Definition: Type.h:2347
TypeSourceInfo * getScopeTypeInfo() const
Retrieve the scope type in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2274
FunctionType::ExtInfo ExtInfo
Definition: Type.h:3388
SourceLocation getColonLoc() const
Definition: Stmt.h:820
One of these records is kept for each identifier that is lexed.
Represents a class template specialization, which refers to a class template with a given set of temp...
Stmt * getBody()
Definition: Stmt.h:1179
void setIntegerType(QualType T)
Set the underlying integer type.
Definition: Decl.h:3373
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Definition: ExprCXX.h:4076
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition: DeclFriend.h:124
unsigned getDepth() const
Retrieve the depth of the template parameter.
SourceLocation getTildeLoc() const
Retrieve the location of the &#39;~&#39;.
Definition: ExprCXX.h:2281
Decl * VisitTypedefDecl(TypedefDecl *D)
FieldDecl * getField() const
For a field offsetof node, returns the field.
Definition: Expr.h:1886
DiagnosticBuilder FromDiag(SourceLocation Loc, unsigned DiagID)
Report a diagnostic in the "from" context.
SourceLocation getRParenLoc() const
Definition: Expr.h:5194
StringLiteral * getMessage()
Definition: DeclCXX.h:3695
bool cleanupsHaveSideEffects() const
Definition: ExprCXX.h:3043
Designator ImportDesignator(const Designator &D)
QualType getComputationResultType() const
Definition: Expr.h:3217
Decl * VisitClassTemplateSpecializationDecl(ClassTemplateSpecializationDecl *D)
Expr * VisitCompoundAssignOperator(CompoundAssignOperator *E)
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2715
Represents a class type in Objective C.
Definition: Type.h:5184
SourceLocation getRParen() const
Get the location of the right parentheses &#39;)&#39;.
Definition: Expr.h:1693
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
Definition: Decl.cpp:3922
QualType getPointeeType() const
Definition: Type.h:2400
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:330
void setUninstantiatedDefaultArg(Expr *arg)
Definition: Decl.cpp:2530
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:149
A C++ nested-name-specifier augmented with source location information.
Expr * getInit() const
Retrieve the initializer value.
Definition: Expr.h:4340
bool isInline() const
Returns true if this is an inline namespace declaration.
Definition: Decl.h:566
Represents a dependent template name that cannot be resolved prior to template instantiation.
Definition: TemplateName.h:422
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
bool CheckedICE
Whether we already checked whether this statement was an integral constant expression.
Definition: Decl.h:785
NamespaceDecl * getNamespace()
Retrieve the namespace declaration aliased by this directive.
Definition: DeclCXX.h:3020
bool ImportArrayChecked(IIter Ibegin, IIter Iend, OIter Obegin)
Decl * VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D)
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:72
QualType VisitMemberPointerType(const MemberPointerType *T)
bool isFileScope() const
Definition: Expr.h:2667
static CXXConstructExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr *> Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, ConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Definition: ExprCXX.cpp:791
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
RecordDecl * getDefinition() const
getDefinition - Returns the RecordDecl that actually defines this struct/union/class.
Definition: Decl.h:3609
QualType VisitDecayedType(const DecayedType *T)
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2463
SourceLocation getAmpAmpLoc() const
Definition: Expr.h:3458
SourceLocation getEndLoc() const
Definition: Stmt.h:513
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
Definition: Decl.h:2467
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Definition: Type.h:4563
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this class.
Definition: DeclObjC.cpp:321
TypeSourceInfo * getTypeSourceInfo() const
Returns the declarator information for a base class or delegating initializer.
Definition: DeclCXX.h:2299
QualType VisitParenType(const ParenType *T)
protocol_iterator protocol_begin() const
Definition: DeclObjC.h:2152
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
const llvm::APSInt & getInitVal() const
Definition: Decl.h:2692
NonTypeTemplateParmDecl * getParameter() const
Definition: ExprCXX.h:3872
static DesignatedInitExpr * Create(const ASTContext &C, llvm::ArrayRef< Designator > Designators, ArrayRef< Expr *> IndexExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
Definition: Expr.cpp:3744
An operation on a type.
Definition: TypeVisitor.h:65
One instance of this struct is kept for every file loaded or used.
Definition: SourceManager.h:95
bool isDefined() const
Definition: DeclObjC.h:462
unsigned getArrayExprIndex() const
For an array element node, returns the index into the array of expressions.
Definition: Expr.h:1880
const Expr * getRetValue() const
Definition: Stmt.cpp:928
SourceLocation getLabelLoc() const
Definition: Expr.h:3460
void startDefinition()
Starts the definition of this tag declaration.
Definition: Decl.cpp:3725
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
Definition: Expr.h:2542
void setSuperClass(TypeSourceInfo *superClass)
Definition: DeclObjC.h:1607
SourceLocation getOperatorLoc() const
Definition: Expr.h:2098
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition: Expr.h:3744
Optional< unsigned > getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce...
SourceLocation getRParenLoc() const
Definition: Expr.h:2951
ObjCMethodDecl * getSetterMethodDecl() const
Definition: DeclObjC.h:942
NamedDecl * getFriendDecl() const
If this friend declaration doesn&#39;t name a type, return the inner declaration.
Definition: DeclFriend.h:139
static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName, SourceLocation EllipsisLoc)
Definition: DeclCXX.cpp:2536
ObjCTypeParamList * getTypeParamListAsWritten() const
Retrieve the type parameters written on this particular declaration of the class. ...
Definition: DeclObjC.h:1330
unsigned getPosition() const
Get the position of the template parameter within its parameter list.
DeclarationName getCXXDestructorName(CanQualType Ty)
getCXXDestructorName - Returns the name of a C++ destructor for the given Type.
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)
Definition: Expr.cpp:391
int Category
Definition: Format.cpp:1348
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:926
protocol_iterator protocol_end() const
Definition: DeclObjC.h:1400
const DeclGroupRef getDeclGroup() const
Definition: Stmt.h:507
Expr * VisitExpr(Expr *E)
Decl * VisitObjCImplementationDecl(ObjCImplementationDecl *D)
Expr * getSubExpr()
Definition: Expr.h:2761
Represents an access specifier followed by colon &#39;:&#39;.
Definition: DeclCXX.h:131
void startDefinition()
Starts the definition of this Objective-C protocol.
Definition: DeclObjC.cpp:1880
SourceLocation getQuestionLoc() const
Definition: Expr.h:3258
static CXXRecordDecl * CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, bool DependentLambda, bool IsGeneric, LambdaCaptureDefault CaptureDefault)
Definition: DeclCXX.cpp:138
bool isGnuLocal() const
Definition: Decl.h:486
SourceLocation getTemplateLoc() const
Definition: DeclTemplate.h:172
void setSubStmt(Stmt *S)
Definition: Stmt.h:778
QualType VisitObjCInterfaceType(const ObjCInterfaceType *T)
unsigned getIndex() const
Retrieve the index into its type parameter list.
Definition: DeclObjC.h:632
QualType getParamTypeForDecl() const
Definition: TemplateBase.h:269
IdentifierTable & Idents
Definition: ASTContext.h:537
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
QualType VisitComplexType(const ComplexType *T)
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition: Type.h:5737
bool hadArrayRangeDesignator() const
Definition: Expr.h:4040
Decl * VisitFriendDecl(FriendDecl *D)
SourceLocation getCatchLoc() const
Definition: StmtCXX.h:49
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2167
Represents Objective-C&#39;s @catch statement.
Definition: StmtObjC.h:74
void setBody(Stmt *S)
Definition: Stmt.h:1056
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:1312
SourceLocation getMemberLoc() const
Definition: ExprCXX.h:3338
Describes an C or C++ initializer list.
Definition: Expr.h:3872
Represents a C++ using-declaration.
Definition: DeclCXX.h:3275
QualType VisitVariableArrayType(const VariableArrayType *T)
bool isInvalid() const
Stmt * VisitBreakStmt(BreakStmt *S)
bool ImportArrayChecked(const InContainerTy &InContainer, OIter Obegin)
Decl * VisitCXXConstructorDecl(CXXConstructorDecl *D)
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2717
Expr * getArraySize()
Definition: ExprCXX.h:1949
An rvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2484
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
UnresolvedUsingTypenameDecl * getDecl() const
Definition: Type.h:3738
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
Decl * VisitUsingDecl(UsingDecl *D)
ForStmt - This represents a &#39;for (init;cond;inc)&#39; stmt.
Definition: Stmt.h:1207
A qualified template name, where the qualification is kept to describe the source code as written...
Definition: TemplateName.h:198
unsigned getFirstExprIndex() const
Definition: Expr.h:4276
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
Definition: DeclObjC.cpp:1417
QualType VisitElaboratedType(const ElaboratedType *T)
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition: Decl.cpp:2616
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2123
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
bool isElidable() const
Whether this construction is elidable.
Definition: ExprCXX.h:1308
Expr * getOperand() const
Definition: ExprCXX.h:3619
const Expr * getThrowExpr() const
Definition: StmtObjC.h:325
Stmt * VisitAttributedStmt(AttributedStmt *S)
bool isBaseVirtual() const
Returns whether the base is virtual or not.
Definition: DeclCXX.h:2291
TagKind getTagKind() const
Definition: Decl.h:3156
Namespaces, declared with &#39;namespace foo {}&#39;.
Definition: DeclBase.h:140
bool isGlobalNew() const
Definition: ExprCXX.h:1974
void setCXXOperatorNameRange(SourceRange R)
setCXXOperatorNameRange - Sets the range of the operator name (without the operator keyword)...
A convenient class for passing around template argument information.
Definition: TemplateBase.h:546
bool isKNRPromoted() const
True if the value passed to this parameter must undergo K&R-style default argument promotion: ...
Definition: Decl.h:1587
static ObjCCategoryDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation AtLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, ObjCTypeParamList *typeParamList, SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
Definition: DeclObjC.cpp:1951
const FileInfo & getFile() const
const TemplateArgumentList & getTemplateArgs() const
Retrieve the template arguments of the variable template specialization.
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
Definition: ExprCXX.h:2119
LabelDecl * getDecl() const
Definition: Stmt.h:859
static ObjCPropertyImplDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation atLoc, SourceLocation L, ObjCPropertyDecl *property, Kind PK, ObjCIvarDecl *ivarDecl, SourceLocation ivarLoc)
Definition: DeclObjC.cpp:2215
SourceLocation getLBracLoc() const
Definition: Stmt.h:683
static EnumConstantDecl * Create(ASTContext &C, EnumDecl *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)
Definition: Decl.cpp:4278
ArrayRef< NamedDecl * > chain() const
Definition: Decl.h:2733
SourceLocation getRParenLoc() const
Definition: StmtCXX.h:196
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
Definition: TemplateBase.h:275
Expr * getInitializer()
The initializer of this new-expression.
Definition: ExprCXX.h:1987
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Definition: Expr.h:405
path_iterator path_begin()
Definition: Expr.h:2777
Stmt * getBody()
Definition: Stmt.h:1242
PropertyAttributeKind getPropertyAttributes() const
Definition: DeclObjC.h:857
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
QualType VisitTemplateTypeParmType(const TemplateTypeParmType *T)
Decl * VisitObjCPropertyDecl(ObjCPropertyDecl *D)
Represents a typeof (or typeof) expression (a GCC extension).
Definition: Type.h:3782
Expr * VisitCharacterLiteral(CharacterLiteral *E)
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack)
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:2985
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Definition: Decl.h:745
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum...
Definition: Decl.h:3390
void setLambdaMangling(unsigned ManglingNumber, Decl *ContextDecl)
Set the mangling number and context declaration for a lambda class.
Definition: DeclCXX.h:1845
tokloc_iterator tokloc_end() const
Definition: Expr.h:1643
Stmt * getInit()
Definition: Stmt.h:1221
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt *> Stmts, SourceLocation LB, SourceLocation RB)
Definition: Stmt.cpp:316
iterator begin()
Definition: DeclGroup.h:100
Decl * VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D)
SourceLocation getThrowLoc() const
Definition: ExprCXX.h:1010
const StringLiteral * getInputConstraintLiteral(unsigned i) const
Definition: Stmt.h:1751
const Type * getClass() const
Definition: Type.h:2536
CXXForRangeStmt - This represents C++0x [stmt.ranged]&#39;s ranged for statement, represented as &#39;for (ra...
Definition: StmtCXX.h:128
Stmt * VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S)
CXXRecordDecl * getDecl() const
Definition: Type.cpp:3159
bool isArrow() const
Definition: Expr.h:2582
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1366
VarTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
Definition: DeclObjC.h:2229
SourceLocation getEqualOrColonLoc() const
Retrieve the location of the &#39;=&#39; that precedes the initializer value itself, if present.
Definition: Expr.h:4331
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3356
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:3621
void setSpecializationKind(TemplateSpecializationKind TSK)
Expr * getSizeExpr() const
Definition: Type.h:2737
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:5718
const TemplateArgument * getArgs() const
Retrieve the template arguments.
Definition: Type.h:4566
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
bool isNull() const
Definition: DeclGroup.h:80
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
Definition: DeclBase.h:1153
bool hasUnparsedDefaultArg() const
hasUnparsedDefaultArg - Determines whether this parameter has a default argument that has not yet bee...
Definition: Decl.h:1624
Expr * getCond()
Definition: Stmt.h:1240
void setTrivial(bool IT)
Definition: Decl.h:2008
Decl * VisitObjCProtocolDecl(ObjCProtocolDecl *D)
SourceLocation getContinueLoc() const
Definition: Stmt.h:1364
const Expr * getInitExpr() const
Definition: Decl.h:2690
SourceLocation getPropertyIvarDeclLoc() const
Definition: DeclObjC.h:2849
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:2710
FieldDecl * getField()
Get the field whose initializer will be used.
Definition: ExprCXX.h:1137
Helper class for OffsetOfExpr.
Definition: Expr.h:1822
SourceLocation getExternLoc() const
Definition: DeclCXX.h:2801
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2083
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1196
bool IsStructurallyEquivalent(QualType From, QualType To, bool Complain=true)
Determine whether the given types are structurally equivalent.
StringLiteral * getClobberStringLiteral(unsigned i)
Definition: Stmt.h:1785
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
Definition: DeclBase.h:820
TemplateTemplateParmDecl * getParameter() const
Definition: TemplateName.h:338
SourceLocation getBuiltinLoc() const
Definition: Expr.h:3807
CXXTemporary * getTemporary()
Definition: ExprCXX.h:1215
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
Definition: Decl.cpp:1869
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace)
Definition: DeclCXX.cpp:2362
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value &#39;V&#39; and type &#39;type&#39;.
Definition: Expr.cpp:748
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name, with source-location information.
Definition: Expr.h:1060
Stmt * VisitNullStmt(NullStmt *S)
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
Definition: DeclObjC.h:2196
PropertyControl getPropertyImplementation() const
Definition: DeclObjC.h:950
Stmt * VisitCXXCatchStmt(CXXCatchStmt *S)
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
Definition: DeclTemplate.h:273
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3202
SourceLocation getLocStart() const LLVM_READONLY
Definition: Expr.h:1908
Represents an ObjC class declaration.
Definition: DeclObjC.h:1191
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
Definition: Stmt.cpp:838
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclObjC.cpp:937
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
Definition: DeclCXX.h:2305
Represents a linkage specification.
Definition: DeclCXX.h:2743
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition: Expr.h:1748
QualType getReturnType() const
Definition: DeclObjC.h:361
SourceLocation getIncludeLoc() const
Stmt * VisitCXXTryStmt(CXXTryStmt *S)
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
Definition: Type.h:3375
bool ImportDefinition(RecordDecl *From, RecordDecl *To, ImportDefinitionKind Kind=IDK_Default)
ASTImporter(ASTContext &ToContext, FileManager &ToFileManager, ASTContext &FromContext, FileManager &FromFileManager, bool MinimalImport)
Create a new AST importer.
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1821
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
Ordinary names.
Definition: DeclBase.h:144
Stmt * getInit()
Definition: Stmt.h:966
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1042
Expr * VisitGNUNullExpr(GNUNullExpr *E)
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl *> Params, ArrayRef< SourceLocation > SelLocs=llvm::None)
Sets the method&#39;s parameters and selector source locations.
Definition: DeclObjC.cpp:841
bool isExact() const
Definition: Expr.h:1431
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, bool isConstexprSpecified=false)
Definition: Decl.h:1881
QualType getPointeeTypeAsWritten() const
Definition: Type.h:2438
Expr * VisitSubstNonTypeTemplateParmExpr(SubstNonTypeTemplateParmExpr *E)
SourceLocation getAtStartLoc() const
Definition: DeclObjC.h:1133
Import the default subset of the definition, which might be nothing (if minimal import is set) or mig...
QualType VisitUnresolvedUsingType(const UnresolvedUsingType *T)
void addDeclInternal(Decl *D)
Add the declaration D into this context, but suppress searches for external declarations with the sam...
Definition: DeclBase.cpp:1433
Stmt * VisitDeclStmt(DeclStmt *S)
ASTContext & getToContext() const
Retrieve the context that AST nodes are being imported into.
Definition: ASTImporter.h:269
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Whether this is an anonymous struct or union.
Definition: Decl.h:3556
NamedDecl * getFirstQualifierFoundInScope() const
Retrieve the first part of the nested-name-specifier that was found in the scope of the member access...
Definition: ExprCXX.h:3322
Represents the this expression in C++.
Definition: ExprCXX.h:945
TypeSourceInfo * getAllocatedTypeSourceInfo() const
Definition: ExprCXX.h:1921
NestedNameSpecifierLoc getQualifierLoc() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: Expr.h:2502
Class that aids in the construction of nested-name-specifiers along with source-location information ...
SourceLocation getRParenLoc() const
Definition: DeclCXX.h:3700
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition: ExprCXX.h:2470
bool IsStructurallyEquivalent(Decl *D1, Decl *D2)
Determine whether the two declarations are structurally equivalent.
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
Definition: DeclObjC.cpp:835
bool isArrayForm() const
Definition: ExprCXX.h:2112
static ImplicitParamDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, ImplicitParamKind ParamKind)
Create implicit parameter.
Definition: Decl.cpp:4210
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
Definition: StmtObjC.h:206
Represents a K&R-style &#39;int foo()&#39; function, which has no information available about its arguments...
Definition: Type.h:3233
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2778
SourceLocation getOperatorLoc() const LLVM_READONLY
Definition: Expr.h:2580
SourceLocation getEllipsisLoc() const
Definition: Expr.h:4270
Decl * VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias)
bool hasBraces() const
Determines whether this linkage specification had braces in its syntactic form.
Definition: DeclCXX.h:2796
const FileEntry * getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
void completeDefinition(QualType NewType, QualType PromotionType, unsigned NumPositiveBits, unsigned NumNegativeBits)
completeDefinition - When created, the EnumDecl corresponds to a forward-declared enum...
Definition: Decl.cpp:3834
Decl * VisitCXXDestructorDecl(CXXDestructorDecl *D)
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:3269
QualType getBaseType() const
Gets the base type of this object type.
Definition: Type.h:5247
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclObjC.h:2834
QualType VisitObjCObjectType(const ObjCObjectType *T)
const ValueDecl * getExtendingDecl() const
Get the declaration which triggered the lifetime-extension of this temporary, if any.
Definition: ExprCXX.h:4098
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1324
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2197
TypeAliasDecl - Represents the declaration of a typedef-name via a C++0x alias-declaration.
Definition: Decl.h:2918
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:955
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:595
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3268
bool isFileVarDecl() const
isFileVarDecl - Returns true for file scoped variable declaration.
Definition: Decl.h:1186
Decl * VisitRecordDecl(RecordDecl *D)
bool isMicrosoftABI() const
Returns whether this is really a Win64 ABI va_arg expression.
Definition: Expr.h:3801
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:2787
Expr ** getSubExprs()
Definition: Expr.h:5170
Decl * VisitCXXConversionDecl(CXXConversionDecl *D)
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Definition: ExprCXX.h:1302
Objective C @protocol.
Definition: DeclBase.h:147
QualType getComputationLHSType() const
Definition: Expr.h:3214
SourceLocation getTypenameLoc() const
Returns the source location of the &#39;typename&#39; keyword.
Definition: DeclCXX.h:3622
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
Definition: DeclCXX.cpp:1386
CastKind
CastKind - The kind of operation required for a conversion.
qual_range quals() const
Definition: Type.h:5084
QualType getPromotionType() const
getPromotionType - Return the integer type that enumerators should promote to.
Definition: Decl.h:3356
bool isDelegatingInitializer() const
Determine whether this initializer is creating a delegating constructor.
Definition: DeclCXX.h:2266
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
Definition: Expr.cpp:1718
decl_range noload_decls() const
noload_decls_begin/end - Iterate over the declarations stored in this context that are currently load...
Definition: DeclBase.h:1588
DeclarationNameTable DeclarationNames
Definition: ASTContext.h:540
A dependent template name that has not been resolved to a template (or set of templates).
Definition: TemplateName.h:202
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
Expr * VisitArrayInitLoopExpr(ArrayInitLoopExpr *E)
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
Definition: Expr.h:2031
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
SourceLocation getTryLoc() const
Definition: StmtCXX.h:91
bool isConstexpr() const
Definition: Stmt.h:985
Stmt * VisitObjCForCollectionStmt(ObjCForCollectionStmt *S)
SourceLocation getLocation() const
Definition: ExprCXX.h:1304
SourceLocation getLocation() const
Definition: Expr.h:1049
void setTypeParamList(ObjCTypeParamList *TPL)
Set the type parameters of this category.
Definition: DeclObjC.cpp:1993
const FunctionType * getFunctionType(bool BlocksToo=true) const
Looks through the Decl&#39;s underlying type to extract a FunctionType when possible. ...
Definition: DeclBase.cpp:933
static EmptyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
Definition: Decl.cpp:4424
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
Definition: ExprCXX.h:2397
ImportDefinitionKind
What we should import from the definition.
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param)
Definition: ExprCXX.h:1067
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:3778
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
Definition: TemplateBase.h:264
static StaticAssertDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc, bool Failed)
Definition: DeclCXX.cpp:2557
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:2847
SourceLocation getLabelLoc() const
Definition: Stmt.h:1295
void setInClassInitializer(Expr *Init)
setInClassInitializer - Set the C++11 in-class initializer for this member.
Definition: Decl.h:2615
SourceLocation getThrowLoc() const LLVM_READONLY
Definition: StmtObjC.h:329
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
static unsigned getNumSubExprs(AtomicOp Op)
Determine the number of arguments the specified atomic builtin should have.
Definition: Expr.cpp:4005
unsigned getValue() const
Definition: Expr.h:1372
static NestedNameSpecifier * SuperSpecifier(const ASTContext &Context, CXXRecordDecl *RD)
Returns the nested name specifier representing the __super scope for the given CXXRecordDecl.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared)
Definition: DeclCXX.cpp:2196
Expr * VisitParenExpr(ParenExpr *E)
SourceLocation getDestroyedTypeLoc() const
Retrieve the starting location of the type being destroyed.
Definition: ExprCXX.h:2305
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:432
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Definition: ExprCXX.h:1802
Expr * getCond() const
Definition: Expr.h:3303
QualType getElementType() const
Definition: Type.h:2236
void setGetterMethodDecl(ObjCMethodDecl *gDecl)
Definition: DeclObjC.h:940
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition: Decl.h:2241
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
Definition: Decl.h:3695
llvm::MutableArrayRef< Designator > designators()
Definition: Expr.h:4309
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
llvm::MemoryBuffer * getBuffer(DiagnosticsEngine &Diag, const SourceManager &SM, SourceLocation Loc=SourceLocation(), bool *Invalid=nullptr) const
Returns the memory buffer for the associated content.
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
Definition: Expr.h:2487
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Definition: Decl.h:627
Expr - This represents one expression.
Definition: Expr.h:106
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3315
Stmt * VisitGotoStmt(GotoStmt *S)
SourceLocation getElseLoc() const
Definition: Stmt.h:982
Decl * VisitEnumConstantDecl(EnumConstantDecl *D)
DeclStmt * getEndStmt()
Definition: StmtCXX.h:158
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.
Definition: ExprCXX.cpp:1419
unsigned getChainingSize() const
Definition: Decl.h:2739
SourceLocation getAliasLoc() const
Returns the location of the alias name, i.e.
Definition: DeclCXX.h:3033
static ObjCMethodDecl * Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isPropertyAccessor=false, bool isImplicitlyDeclared=false, bool isDefined=false, ImplementationControl impControl=None, bool HasRelatedResultType=false)
Definition: DeclObjC.cpp:772
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:104
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, const TemplateArgumentListInfo &ArgInfos, QualType CanonInjectedType, ClassTemplatePartialSpecializationDecl *PrevDecl)
Selector getSetterName() const
Definition: DeclObjC.h:931
Stmt * VisitCXXForRangeStmt(CXXForRangeStmt *S)
std::string Label
IdentifierInfo * getFieldName() const
For a field or identifier offsetof node, returns the name of the field.
Definition: Expr.cpp:1391
CXXBaseSpecifier * getBase() const
For a base class node, returns the base specifier.
Definition: Expr.h:1896
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3420
Decl * VisitEmptyDecl(EmptyDecl *D)
const FunctionProtoType * T
TypeSourceInfo * getSuperClassTInfo() const
Definition: DeclObjC.h:1592
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.cpp:780
Declaration of a template type parameter.
void setSetterMethodDecl(ObjCMethodDecl *gDecl)
Definition: DeclObjC.h:943
SourceLocation getDefaultLoc() const
Definition: Stmt.h:818
unsigned getIndex() const
Definition: Type.h:4219
FileID createFileID(const FileEntry *SourceFile, SourceLocation IncludePos, SrcMgr::CharacteristicKind FileCharacter, int LoadedID=0, unsigned LoadedOffset=0)
Create a new FileID that represents the specified file being #included from the specified IncludePosi...
SourceLocation getWhileLoc() const
Definition: Stmt.h:1138
TypeSourceInfo * getTypeSourceInfo() const
Definition: DeclObjC.h:844
DeclarationNameInfo getNameInfo() const
Definition: DeclCXX.h:3322
Expr * VisitDeclRefExpr(DeclRefExpr *E)
void setSyntacticForm(InitListExpr *Init)
Definition: Expr.h:4033
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1530
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:68
const Stmt * getThen() const
Definition: Stmt.h:971
bool IsStructuralMatch(RecordDecl *FromRecord, RecordDecl *ToRecord, bool Complain=true)
static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc)
Definition: DeclCXX.cpp:2508
SourceLocation getLocation() const
Definition: ExprCXX.h:961
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2620
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver&#39;s type...
Definition: DeclObjC.h:306
void setInit(Expr *I)
Definition: Decl.cpp:2156
VarDecl * getExceptionDecl() const
Definition: StmtCXX.h:50
IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
Definition: ExprCXX.h:2297
unsigned getNumInits() const
Definition: Expr.h:3902
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
Definition: DeclObjC.h:2240
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Definition: ExprCXX.cpp:1189
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:551
Expr * getSubExpr() const
Get the initializer to use for each array element.
Definition: Expr.h:4512
const Expr * getCallee() const
Definition: Expr.h:2249
void setRBraceLoc(SourceLocation L)
Definition: DeclCXX.h:2804
const char * getTypeClassName() const
Definition: Type.cpp:2570
Stmt * VisitIfStmt(IfStmt *S)
static CXXStaticCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition: ExprCXX.cpp:554
Decl * VisitLinkageSpecDecl(LinkageSpecDecl *D)
bool isArrow() const
Determine whether this pseudo-destructor expression was written using an &#39;->&#39; (otherwise, it used a &#39;.
Definition: ExprCXX.h:2260
Stmt * getBody()
Definition: Stmt.h:1134
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
Expr * VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E)
overridden_method_range overridden_methods() const
Definition: DeclCXX.cpp:1926
static ObjCTypeParamDecl * Create(ASTContext &ctx, DeclContext *dc, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, SourceLocation nameLoc, IdentifierInfo *name, SourceLocation colonLoc, TypeSourceInfo *boundInfo)
Definition: DeclObjC.cpp:1346
Expr * VisitAddrLabelExpr(AddrLabelExpr *E)
arg_range arguments()
Definition: ExprCXX.h:1348
const CompoundStmt * getSynchBody() const
Definition: StmtObjC.h:282
Expr * VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E)
DeclContext * getDeclContext()
Definition: DeclBase.h:425
SourceLocation getLParenLoc() const
Definition: Expr.h:4636
Decl * VisitAccessSpecDecl(AccessSpecDecl *D)
A structure for storing the information associated with a substituted template template parameter...
Definition: TemplateName.h:325
Expr * getRHS()
Definition: Stmt.h:765
CXXRecordDecl * getDefinition() const
Definition: DeclCXX.h:731
QualType getBaseType() const
Definition: Type.h:3921
QualType VisitFunctionNoProtoType(const FunctionNoProtoType *T)
Represents Objective-C&#39;s @synchronized statement.
Definition: StmtObjC.h:262
ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.cpp:330
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:1968
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl *> typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
Definition: DeclObjC.cpp:1395
unsigned size() const
Returns the number of designators in this initializer.
Definition: Expr.h:4306
CXXTryStmt - A C++ try block, including all handlers.
Definition: StmtCXX.h:65
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:2237
SourceLocation getAtTryLoc() const
Retrieve the location of the @ in the @try.
Definition: StmtObjC.h:193
Expr * VisitPredefinedExpr(PredefinedExpr *E)
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
Definition: Expr.h:1165
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
Definition: Expr.cpp:774
Represents a C++ template name within the type system.
Definition: TemplateName.h:178
Represents the type decltype(expr) (C++11).
Definition: Type.h:3852
QualType VisitConstantArrayType(const ConstantArrayType *T)
ArrayTypeTrait getTrait() const
Definition: ExprCXX.h:2466
EnumDecl * getDefinition() const
Definition: Decl.h:3309
bool isIdentifier() const
Determine whether this template name refers to an identifier.
Definition: TemplateName.h:481
A namespace alias, stored as a NamespaceAliasDecl*.
ParmVarDecl *const * param_iterator
Definition: DeclObjC.h:382
protocol_loc_iterator protocol_loc_begin() const
Definition: DeclObjC.h:1418
unsigned size() const
Definition: Stmt.h:621
ArrayRef< Expr * > inits()
Definition: Expr.h:3912
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn&#39;t a simple identifier.
void setImplementation(ObjCImplementationDecl *ImplD)
Definition: DeclObjC.cpp:1526
void setConstexpr(bool IC)
Definition: Decl.h:1369
Expr * VisitCXXDeleteExpr(CXXDeleteExpr *E)
SourceRange getAngleBrackets() const LLVM_READONLY
Definition: ExprCXX.h:283
Kind getKind() const
Determine what kind of offsetof node this is.
Definition: Expr.h:1876
Stmt * VisitObjCAtTryStmt(ObjCAtTryStmt *S)
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition).
Definition: Decl.cpp:2580
QualType getType() const
Definition: Expr.h:128
bool isFunctionOrMethod() const
Definition: DeclBase.h:1384
Expr * VisitCXXThisExpr(CXXThisExpr *E)
A unary type transform, which is a type constructed from another.
Definition: Type.h:3895
Optional< TemplateArgumentLoc > ImportTemplateArgumentLoc(const TemplateArgumentLoc &TALoc)
SourceLocation getSwitchLoc() const
Definition: Stmt.h:1062
Declaration of an alias template.
void ImportDeclarationNameLoc(const DeclarationNameInfo &From, DeclarationNameInfo &To)
LabelDecl * getLabel() const
Definition: Stmt.h:1290
const Stmt * getTryBody() const
Retrieve the @try body.
Definition: StmtObjC.h:197
Decl * GetAlreadyImportedOrNull(Decl *FromD)
Return the copy of the given declaration in the "to" context if it has already been imported from the...
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
Definition: Stmt.h:1417
SourceLocation getDoLoc() const
Definition: Stmt.h:1183
Expr * VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E)
SourceLocation getAtLoc() const
Definition: StmtObjC.h:363
SourceLocation getLBracketLoc() const
Definition: Expr.h:4258
SourceLocation getRBracketLoc() const
Definition: Expr.h:2183
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression&#39;s (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
Definition: Expr.h:1717
bool isInstanceMethod() const
Definition: DeclObjC.h:452
Represents a GCC generic vector type.
Definition: Type.h:2914
ArraySizeModifier getSizeModifier() const
Definition: Type.h:2595
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
Definition: Expr.h:4336
static bool CanThrow(Expr *E, ASTContext &Ctx)
Definition: CFG.cpp:2037
AtomicOp getOp() const
Definition: Expr.h:5167
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this class is an instantiation of a member class of a class template specialization, retrieves the member specialization information.
Definition: DeclCXX.cpp:1364
An lvalue reference type, per C++11 [dcl.ref].
Definition: Type.h:2466
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Stmt * VisitReturnStmt(ReturnStmt *S)
UTTKind getUTTKind() const
Definition: Type.h:3923
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:3838
bool isBaseOfClass() const
Determine whether this base class is a base of a class declared with the &#39;class&#39; keyword (vs...
Definition: DeclCXX.h:248
const OffsetOfNode & getComponent(unsigned Idx) const
Definition: Expr.h:1975
unsigned getNumArgs() const
Expr * getTrueExpr() const
getTrueExpr - Return the subexpression which will be evaluated if the condition evaluates to true; th...
Definition: Expr.h:3394
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: Expr.h:1094
ValueDecl * getDecl()
Definition: Expr.h:1041
void setDescribedClassTemplate(ClassTemplateDecl *Template)
Definition: DeclCXX.cpp:1382
SourceLocation getRParenLoc() const
Definition: Expr.h:3810
Represents a C++ conversion function within a class.
Definition: DeclCXX.h:2682
The result type of a method or function.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Definition: Decl.h:2007
SourceLocation getForLoc() const
Definition: StmtObjC.h:53
const Expr * getSubExpr() const
Definition: Expr.h:1681
ObjCBridgeCastKind getBridgeKind() const
Determine which kind of bridge is being performed via this cast.
Definition: ExprObjC.h:1599
const Expr * getSubExpr() const
Definition: ExprCXX.h:1219
CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr.cast]), which uses the syntax (Type)expr.
Definition: Expr.h:2922
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:719
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
Definition: Expr.h:2154
QualType getType() const
Definition: DeclObjC.h:846
bool getValue() const
Definition: ExprCXX.h:543
bool hadMultipleCandidates() const
Returns true if this expression refers to a function that was resolved from an overloaded set having ...
Definition: Expr.h:1153
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Expr * getUnderlyingExpr() const
Definition: Type.h:3791
Decl * VisitObjCMethodDecl(ObjCMethodDecl *D)
ObjCProtocolList::iterator protocol_iterator
Definition: DeclObjC.h:1382
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
Definition: DeclCXX.cpp:122
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition: Expr.h:412
DoStmt - This represents a &#39;do/while&#39; stmt.
Definition: Stmt.h:1158
SourceLocation getOperatorLoc() const
Retrieve the location of the &#39;->&#39; or &#39;.&#39; operator.
Definition: ExprCXX.h:3299
AttrVec & getAttrs()
Definition: DeclBase.h:477
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
bool hasAttrs() const
Definition: DeclBase.h:471
QualType VisitEnumType(const EnumType *T)
TypeSourceInfo * getReturnTypeSourceInfo() const
Definition: DeclObjC.h:375
RecordDecl * getDecl() const
Definition: Type.h:3986
const DirectoryEntry * getDir() const
Return the directory the file lives in.
Definition: FileManager.h:94
void addAttr(Attr *A)
Definition: DeclBase.h:484
SpecifierKind
The kind of specifier that completes this nested name specifier.
SourceLocation getLocStart() const LLVM_READONLY
Definition: DeclBase.h:408
Expr * getArgument()
Definition: ExprCXX.h:2125
SourceLocation getUsingLoc() const
Return the location of the using keyword.
Definition: DeclCXX.h:2914
NestedNameSpecifier * getQualifier() const
Return the nested name specifier that qualifies this name.
Definition: TemplateName.h:388
Expr * VisitParenListExpr(ParenListExpr *E)
A template template parameter pack that has been substituted for a template template argument pack...
Definition: TemplateName.h:211
CanThrowResult
Possible results from evaluation of a noexcept expression.
SourceLocation getUsingLoc() const
Returns the source location of the &#39;using&#39; keyword.
Definition: DeclCXX.h:3526
bool getValue() const
Definition: ExprCXX.h:3625
IdentifierInfo * getCXXLiteralIdentifier() const
getCXXLiteralIdentifier - If this name is the name of a literal operator, retrieve the identifier ass...
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:868
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template.
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:3622
#define false
Definition: stdbool.h:33
TemplateName getDependentTemplateName(NestedNameSpecifier *NNS, const IdentifierInfo *Name) const
Retrieve the template name that represents a dependent template name such as MetaFun::template apply...
SourceLocation getLParenLoc() const
Definition: Expr.h:2670
SelectorTable & Selectors
Definition: ASTContext.h:538
static CXXConstCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, Expr *Op, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)
Definition: ExprCXX.cpp:661
Kind
static CXXBindTemporaryExpr * Create(const ASTContext &C, CXXTemporary *Temp, Expr *SubExpr)
Definition: ExprCXX.cpp:753
A field in a dependent type, known only by its name.
Definition: Expr.h:1831
QualType getCanonicalType() const
Definition: Type.h:5757
Decl * VisitIndirectFieldDecl(IndirectFieldDecl *D)
ExpressionTrait getTrait() const
Definition: ExprCXX.h:2530
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:3365
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
Definition: Expr.h:191
param_type_range param_types() const
Definition: Type.h:3637
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
ElaboratedTypeKeyword getKeyword() const
Definition: Type.h:4745
ExtProtoInfo getExtProtoInfo() const
Definition: Type.h:3500
const ContentCache * getContentCache() const
static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, ClassTemplateSpecializationDecl *PrevDecl)
void setKNRPromoted(bool promoted)
Definition: Decl.h:1590
Decl * VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D)
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2527
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList *> FriendTypeTPLists=None)
Definition: DeclFriend.cpp:35
unsigned getNumExprs() const
Definition: Expr.h:4618
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into &#39;__super&#39; nested-name-specifier.
bool isParameterPack() const
Returns whether this is a parameter pack.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Encodes a location in the source.
bool getSynthesize() const
Definition: DeclObjC.h:2010
ObjCInterfaceDecl * getDecl() const
Get the declaration of this interface.
Definition: Type.h:5397
body_range body()
Definition: Stmt.h:626
Sugar for parentheses used when specifying types.
Definition: Type.h:2253
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
QualType getReturnType() const
Definition: Type.h:3201
bool isPure() const
Whether this virtual function is pure, i.e.
Definition: Decl.h:1996
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
Definition: Type.h:4002
SourceLocation getOperatorLoc() const
Definition: Expr.h:3023
QualType VisitFunctionProtoType(const FunctionProtoType *T)
StringRef getName() const
Definition: FileManager.h:84
ObjCProtocolList::iterator protocol_iterator
Definition: DeclObjC.h:2372
const Stmt * getCatchBody() const
Definition: StmtObjC.h:90
unsigned getNumHandlers() const
Definition: StmtCXX.h:103
Expr * getSubExpr() const
Definition: Expr.h:1744
SourceLocation getSuperClassLoc() const
Definition: DeclObjC.h:2710
Represents a C++ temporary.
Definition: ExprCXX.h:1164
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
Definition: ExprCXX.h:3366
Represents typeof(type), a GCC extension.
Definition: Type.h:3825
Interfaces are the core concept in Objective-C for object oriented design.
Definition: Type.h:5384
Attr * clone(ASTContext &C) const
NestedNameSpecifierLoc getQualifierLoc() const
Retrieves the nested-name-specifier that qualifies the type name, with source-location information...
Definition: ExprCXX.h:2249
QualType VisitBuiltinType(const BuiltinType *T)
SourceLocation getNamespaceKeyLocation() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:2918
CastKind getCastKind() const
Definition: Expr.h:2757
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameter list associated with this category or extension.
Definition: DeclObjC.h:2349
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:608
Expr * getSubExpr(unsigned Idx) const
Definition: Expr.h:4354
A structure for storing an already-substituted template template parameter pack.
Definition: TemplateName.h:121
const SwitchCase * getSwitchCaseList() const
Definition: Stmt.h:1051
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
Definition: ExprCXX.h:276
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:1842
void setExternLoc(SourceLocation Loc)
Sets the location of the extern keyword.
Expr * getLHS()
Definition: Stmt.h:764
bool wasDeclaredWithTypename() const
Whether this template type parameter was declared with the &#39;typename&#39; keyword.
DeclarationName getName() const
getName - Returns the embedded declaration name.
ArrayRef< const Attr * > getAttrs() const
Definition: Stmt.h:915
TagDecl - Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:2944
SourceLocation getUsingLoc() const
Return the source location of the &#39;using&#39; keyword.
Definition: DeclCXX.h:3308
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Definition: ExprCXX.h:3688
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2546
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:164
ASTContext & getASTContext() const LLVM_READONLY
Definition: DeclBase.cpp:378
ObjCCategoryDecl * getCategoryDecl() const
Definition: DeclObjC.cpp:2029
QualType getElementType() const
Definition: Type.h:2949
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:487
Decl * VisitTranslationUnitDecl(TranslationUnitDecl *D)
LabelDecl - Represents the declaration of a label.
Definition: Decl.h:459
void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal)
Definition: DeclObjC.h:873
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3494
Cached information about one file (either on disk or in the virtual file system). ...
Definition: FileManager.h:59
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3536
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
Definition: Decl.h:2604
Decl * VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D)
Expr * VisitMemberExpr(MemberExpr *E)
void setCtorInitializers(CXXCtorInitializer **Initializers)
Definition: DeclCXX.h:2503
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr *> exprs, SourceLocation RParenLoc)
Definition: Expr.cpp:1345
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2134
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1964
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
Definition: ExprCXX.cpp:1058
SourceLocation getFriendLoc() const
Retrieves the location of the &#39;friend&#39; keyword.
Definition: DeclFriend.h:144
bool shouldForceImportDeclContext(ImportDefinitionKind IDK)
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location...
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:186
SourceLocation getRParenLoc() const
Definition: Expr.h:3513
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
Definition: DeclTemplate.h:163
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void addOverriddenMethod(const CXXMethodDecl *MD)
Definition: DeclCXX.cpp:1901
SourceLocation getIdentLocation() const
Returns the location of this using declaration&#39;s identifier.
Definition: DeclCXX.h:2921
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
Definition: DeclObjC.h:1511
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier &#39;::&#39;.
bool isBoundToLvalueReference() const
Determine whether this materialized temporary is bound to an lvalue reference; otherwise, it&#39;s bound to an rvalue reference.
Definition: ExprCXX.h:4111
bool isParameterPack() const
Definition: Type.h:4220
bool isPascal() const
Definition: Expr.h:1605
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:2888
Decl * VisitFunctionDecl(FunctionDecl *D)
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2299
unsigned pack_size() const
The number of template arguments in the given template argument pack.
Definition: TemplateBase.h:360
QualType getEquivalentType() const
Definition: Type.h:4104
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load, __atomic_store, and __atomic_compare_exchange_*, for the similarly-named C++11 instructions, and __c11 variants for <stdatomic.h>, and corresponding __opencl_atomic_* for OpenCL 2.0.
Definition: Expr.h:5103
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:2062
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
Definition: DeclBase.h:1889
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3415
void addDecl(NamedDecl *D)
Definition: UnresolvedSet.h:89
QualType VisitTypedefType(const TypedefType *T)
Expr * VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E)
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
Definition: Expr.h:149
const TemplateArgumentListInfo & getTemplateArgsInfo() const
QualType getInnerType() const
Definition: Type.h:2266
SourceLocation getLParenLoc() const
Definition: Expr.h:3511
arg_range arguments()
Definition: Expr.h:2303
SourceLocation getGotoLoc() const
Definition: Stmt.h:1293
SourceLocation getAtFinallyLoc() const
Definition: StmtObjC.h:141
AccessSpecifier getAccess() const
void setPointOfInstantiation(SourceLocation Loc)
StringLiteral * getFunctionName()
Definition: Expr.cpp:469
bool isMinimalImport() const
Whether the importer will perform a minimal import, creating to-be-completed forward declarations whe...
Definition: ASTImporter.h:110
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
Definition: Stmt.h:1723
static CXXDefaultInitExpr * Create(const ASTContext &C, SourceLocation Loc, FieldDecl *Field)
Field is the non-static data member whose default initializer is used by this expression.
Definition: ExprCXX.h:1131
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:746
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
Definition: DeclObjC.h:2363
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2403
ASTNodeImporter(ASTImporter &Importer)
Definition: ASTImporter.cpp:35
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:2822
Stmt * VisitForStmt(ForStmt *S)
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
Definition: Type.h:4810
SourceLocation getAtCatchLoc() const
Definition: StmtObjC.h:102
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:70
CharacterKind getKind() const
Definition: Expr.h:1365
bool hasUninstantiatedDefaultArg() const
Definition: Decl.h:1628
AutoTypeKeyword getKeyword() const
Definition: Type.h:4416
QualType VisitRecordType(const RecordType *T)
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
Definition: DeclBase.cpp:399
Decl * VisitVarTemplateDecl(VarTemplateDecl *D)
IdentType getIdentType() const
Definition: Expr.h:1215
Stmt * VisitCompoundStmt(CompoundStmt *S)
Stmt * VisitIndirectGotoStmt(IndirectGotoStmt *S)
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
An expression trait intrinsic.
Definition: ExprCXX.h:2493
Decl * VisitImplicitParamDecl(ImplicitParamDecl *D)
SourceLocation getRAngleLoc() const
Definition: DeclTemplate.h:174
SourceLocation getMemberLocation() const
Definition: DeclCXX.h:2325
bool isImplicitInterfaceDecl() const
isImplicitInterfaceDecl - check that this is an implicitly declared ObjCInterfaceDecl node...
Definition: DeclObjC.h:1912
EnumDecl * getDecl() const
Definition: Type.h:4009
Expr * VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E)
ArrayRef< Expr * > exprs()
Definition: Expr.h:4632
DeclarationNameInfo getNameInfo() const
Definition: Decl.h:1907
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3669
Stmt * VisitWhileStmt(WhileStmt *S)
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:3488
bool isArgumentType() const
Definition: Expr.h:2067
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: ExprCXX.h:3394
ObjCImplementationDecl * getImplementation() const
Definition: DeclObjC.cpp:1513
SourceLocation getRBraceLoc() const
Definition: DeclCXX.h:2802
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:5025
Expr * VisitCallExpr(CallExpr *E)
Expr * getArrayFiller()
If this initializer list initializes an array with more elements than there are initializers in the l...
Definition: Expr.h:3966
Decl * VisitLabelDecl(LabelDecl *D)
TypeSourceInfo * getTypeSourceInfo() const
Retrieves the type and source location of the base class.
Definition: DeclCXX.h:295
SourceLocation getStarLoc() const
Definition: Stmt.h:1330
QualType VisitObjCObjectPointerType(const ObjCObjectPointerType *T)
void setHasInheritedDefaultArg(bool I=true)
Definition: Decl.h:1645
bool passAlignment() const
Indicates whether the required alignment should be implicitly passed to the allocation function...
Definition: ExprCXX.h:2001
void sawArrayRangeDesignator(bool ARD=true)
Definition: Expr.h:4043
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:586
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:1944
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)
Definition: ExprCXX.cpp:638
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl, Expr *AssociatedConstraints=nullptr)
Create a class template node.
SourceLocation getIvarLBraceLoc() const
Definition: DeclObjC.h:2436
static MemberExpr * Create(const ASTContext &C, Expr *base, bool isarrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *memberdecl, DeclAccessPair founddecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *targs, QualType ty, ExprValueKind VK, ExprObjectKind OK)
Definition: Expr.cpp:1437
Represents a pointer type decayed from an array or function type.
Definition: Type.h:2368
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:216
The injected class name of a C++ class template or class template partial specialization.
Definition: Type.h:4633
void setVirtualAsWritten(bool V)
Definition: Decl.h:1992
const Expr * getInitializer() const
Definition: Expr.h:2663
Represents a pack expansion of types.
Definition: Type.h:4994
InitializationStyle getInitializationStyle() const
The kind of initializer this new-expression has.
Definition: ExprCXX.h:1980
Expr * getLHS() const
Definition: Expr.h:3029
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Definition: Decl.cpp:4379
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:3191
A POD class for pairing a NamedDecl* with an access specifier.
StringRef getName() const
Return the actual identifier string.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Definition: Decl.h:3204
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3444
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
Definition: ExprObjC.h:1572
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2802
ast_type_traits::DynTypedNode Node
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Represents a template argument.
Definition: TemplateBase.h:51
OpaqueValueExpr * getOpaqueValue() const
getOpaqueValue - Return the opaque value placeholder.
Definition: Expr.h:3385
LabelStmt * getStmt() const
Definition: Decl.h:483
unsigned getManglingNumber() const
Definition: ExprCXX.h:4105
bool ImportDeclParts(NamedDecl *D, DeclContext *&DC, DeclContext *&LexicalDC, DeclarationName &Name, NamedDecl *&ToD, SourceLocation &Loc)
TypeSourceInfo * getDestroyedTypeInfo() const
Retrieve the source location information for the type being destroyed.
Definition: ExprCXX.h:2290
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "if" statement, if any.
Definition: Stmt.cpp:803
void setBody(Stmt *B)
Definition: Decl.cpp:2626
static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls)
Definition: DeclGroup.h:69
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
Represents a template name that was expressed as a qualified name.
Definition: TemplateName.h:366
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Definition: Expr.h:3401
protocol_iterator protocol_end() const
Definition: DeclObjC.h:2159
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:556
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2459
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
Definition: DeclCXX.cpp:2288
Expr * VisitCXXNamedCastExpr(CXXNamedCastExpr *E)
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition: Decl.cpp:2455
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
Definition: DeclCXX.cpp:2250
virtual void CompleteDecl(Decl *D)
Called for ObjCInterfaceDecl, ObjCProtocolDecl, and TagDecl.
SourceLocation getLocation() const
Definition: ExprCXX.h:549
bool isNull() const
Determine whether this template name is NULL.
Dataflow Directional Tag Classes.
void setExtendingDecl(const ValueDecl *ExtendedBy, unsigned ManglingNumber)
Definition: ExprCXX.cpp:1372
TemplateName getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param, const TemplateArgument &ArgPack) const
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool isVolatile() const
Definition: Stmt.h:1501
tokloc_iterator tokloc_begin() const
Definition: Expr.h:1642
void ImportDeclContext(DeclContext *FromDC, bool ForceImport=false)
ExtInfo getExtInfo() const
Definition: Type.h:3212
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:493
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1188
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
Definition: Expr.h:2575
void setGetterName(Selector Sel, SourceLocation Loc=SourceLocation())
Definition: DeclObjC.h:926
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1256
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2071
IdentifierInfo * getOutputIdentifier(unsigned i) const
Definition: Stmt.h:1710
PropertyAttributeKind getPropertyAttributesAsWritten() const
Definition: DeclObjC.h:869
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:399
bool isSimple() const
Definition: Stmt.h:1498
TemplateArgument ImportTemplateArgument(const TemplateArgument &From)
Kind getPropertyImplementation() const
Definition: DeclObjC.h:2842
QualType VisitIncompleteArrayType(const IncompleteArrayType *T)
virtual Decl * Imported(Decl *From, Decl *To)
Note that we have imported the "from" declaration by mapping it to the (potentially-newly-created) "t...
const Stmt * getFinallyBody() const
Definition: StmtObjC.h:132
SourceLocation getLocStart() const LLVM_READONLY
Definition: TypeLoc.h:154
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:80
SourceLocation getAtLoc() const
Definition: DeclObjC.h:838
QualType VisitAttributedType(const AttributedType *T)
bool isImplicit() const
Definition: ExprCXX.h:967
attr_range attrs() const
Definition: DeclBase.h:494
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
Definition: Decl.h:2711
QualType getUnderlyingType() const
Definition: Decl.h:2853
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:3011
DeclContext * getCommonAncestor()
Returns the common ancestor context of this using-directive and its nominated namespace.
Definition: DeclCXX.h:2910
AccessSpecifier getAccess() const
Definition: DeclBase.h:460
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
Definition: DeclObjC.h:1568
QualType getUnderlyingType() const
Definition: Type.h:3863
unsigned getIndex() const
Retrieve the index of the template parameter.
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3334
SourceLocation getLBraceLoc() const
Definition: Expr.h:4017
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3590
SourceLocation getSemiLoc() const
Definition: Stmt.h:577
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
Definition: DeclCXX.cpp:2267
DeclarationName - The name of a declaration.
StmtClass getStmtClass() const
Definition: Stmt.h:378
VectorKind getVectorKind() const
Definition: Type.h:2959
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:576
ArrayRef< QualType > exceptions() const
Definition: Type.h:3651
Expr * getDefaultArg()
Definition: Decl.cpp:2493
Expr * VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E)
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3626
Expr * VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E)
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:3652
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1317
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
Definition: DeclCXX.cpp:1357
static ObjCImplementationDecl * Create(ASTContext &C, DeclContext *DC, ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *superDecl, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc=SourceLocation(), SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
Definition: DeclObjC.cpp:2116
Decl * VisitClassTemplateDecl(ClassTemplateDecl *D)
A set of unresolved declarations.
void setInstantiationDependent(bool ID)
Set whether this expression is instantiation-dependent or not.
Definition: Expr.h:196
SourceLocation getLocStart() const LLVM_READONLY
Definition: Decl.h:731
EnumDecl - Represents an enum.
Definition: Decl.h:3239
const Expr * getSynchExpr() const
Definition: StmtObjC.h:290
void ImportArray(IIter Ibegin, IIter Iend, OIter Obegin)
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2502
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:143
Expr * VisitExplicitCastExpr(ExplicitCastExpr *E)
Expr * VisitImplicitValueInitExpr(ImplicitValueInitExpr *ILE)
ExplicitCastExpr - An explicit cast written in the source code.
Definition: Expr.h:2888
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Tags, declared with &#39;struct foo;&#39; and referenced with &#39;struct foo&#39;.
Definition: DeclBase.h:125
void setInitializedFieldInUnion(FieldDecl *FD)
Definition: Expr.h:3990
Decl * VisitFunctionTemplateDecl(FunctionTemplateDecl *D)
A type that was preceded by the &#39;template&#39; keyword, stored as a Type*.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
Definition: ASTContext.h:1048
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
Definition: Decl.cpp:3808
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
Definition: TemplateBase.h:340
const TemplateTypeParmType * getReplacedParameter() const
Gets the template parameter that was substituted for.
Definition: Type.h:4271
SourceLocation getSetterNameLoc() const
Definition: DeclObjC.h:932
Decl * VisitObjCIvarDecl(ObjCIvarDecl *D)
bool isNull() const
Determine whether this template argument has no value.
Definition: TemplateBase.h:238
Expr * VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *CE)
SourceLocation getLParenLoc() const
Definition: ExprObjC.h:1596
VarTemplateSpecializationDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
Definition: Decl.cpp:4174
const Stmt * getBody() const
Definition: Stmt.h:1050
Decl * VisitVarTemplateSpecializationDecl(VarTemplateSpecializationDecl *D)
llvm::APInt getValue() const
Definition: Expr.h:1279
QualType getUnderlyingType() const
Definition: Type.h:3920
QualType getModifiedType() const
Definition: Type.h:4103
LabelDecl * getLabel() const
Definition: Expr.h:3466
QualType VisitLValueReferenceType(const LValueReferenceType *T)
path_iterator path_end()
Definition: Expr.h:2778
Represents a pointer to an Objective C object.
Definition: Type.h:5440
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:3600
SwitchStmt - This represents a &#39;switch&#39; stmt.
Definition: Stmt.h:1011
Pointer to a block type.
Definition: Type.h:2385
UsingDecl * getUsingDecl() const
Gets the using declaration to which this declaration is tied.
Definition: DeclCXX.cpp:2406
SourceLocation getColonColonLoc() const
Retrieve the location of the &#39;::&#39; in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2278
SourceLocation getFieldLoc() const
Definition: Expr.h:4253
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
Definition: DeclObjC.cpp:1712
void ImportOverrides(CXXMethodDecl *ToMethod, CXXMethodDecl *FromMethod)
Expr * VisitFloatingLiteral(FloatingLiteral *E)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2571
SourceLocation getRParenLoc() const
Definition: StmtObjC.h:55
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition: Type.h:3379
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:3976
Complex values, per C99 6.2.5p11.
Definition: Type.h:2223
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:450
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
Definition: DeclBase.h:566
unsigned getIndexTypeCVRQualifiers() const
Definition: Type.h:2603
unsigned getNumArgs() const
Retrieve the number of template arguments.
Definition: Type.h:4571
void setUnparsedDefaultArg()
setUnparsedDefaultArg - Specify that this parameter has an unparsed default argument.
Definition: Decl.h:1637
Expr * getUninstantiatedDefaultArg()
Definition: Decl.cpp:2535
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
Definition: Decl.cpp:3771
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2528
Imports selected nodes from one AST context into another context, merging AST nodes where appropriate...
Definition: ASTImporter.h:40
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2121
Represents Objective-C&#39;s collection statement.
Definition: StmtObjC.h:24
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2172
Expr * VisitCXXNoexceptExpr(CXXNoexceptExpr *E)
Expr * VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E)
unsigned getNumObjects() const
Definition: ExprCXX.h:3033
IndirectFieldDecl * getIndirectMember() const
Definition: DeclCXX.h:2319
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
Definition: Decl.cpp:1722
SourceLocation getLocation() const
Retrieve the location of this expression.
Definition: Expr.h:897
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
static CStyleCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *BasePath, TypeSourceInfo *WrittenTy, SourceLocation L, SourceLocation R)
Definition: Expr.cpp:1739
An implicit indirection through a C++ base class, when the field found is in a base class...
Definition: Expr.h:1834
const llvm::APInt & getSize() const
Definition: Type.h:2636
Kind getAttrKind() const
Definition: Type.h:4099
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value...
Definition: Expr.h:3389
protocol_iterator protocol_begin() const
Definition: DeclObjC.h:2379
void setBuiltinID(unsigned ID)
void setSwitchLoc(SourceLocation L)
Definition: Stmt.h:1063
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:707
Stmt * getInit()
Definition: Stmt.h:1046
static llvm::Optional< unsigned > findUntaggedStructOrUnionIndex(RecordDecl *Anon)
Find the index of the given anonymous struct/union within its context.
bool doesUsualArrayDeleteWantSize() const
Answers whether the usual array deallocation function for the allocated type expects the size of the ...
Definition: ExprCXX.h:2008
ExtVectorType - Extended vector type.
Definition: Type.h:2988
SourceRange getDirectInitRange() const
Definition: ExprCXX.h:2050
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the member name, with source location information...
Definition: ExprCXX.h:3309
Opcode getOpcode() const
Definition: Expr.h:1741
virtual void CompleteType(TagDecl *Tag)
Gives the external AST source an opportunity to complete an incomplete type.
param_const_iterator param_begin() const
Definition: DeclObjC.h:386
SourceRange getBracketsRange() const
Definition: Type.h:2743
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
Definition: DeclBase.cpp:1663
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Definition: ASTContext.h:2190
static UsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target)
Definition: DeclCXX.h:3101
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
Definition: DeclObjC.h:1934
StringRef getBytes() const
Allow access to clients that need the byte representation, such as ASTWriterStmt::VisitStringLiteral(...
Definition: Expr.h:1565
Represents Objective-C&#39;s @finally statement.
Definition: StmtObjC.h:120
DesignatedInitExpr::Designator Designator
Definition: ASTImporter.cpp:97
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, bool isConstexpr, SourceLocation EndLocation)
Definition: DeclCXX.cpp:1696
The template argument is a type.
Definition: TemplateBase.h:60
QualType getUnderlyingType() const
Definition: Type.h:3840
void setInstantiationOfMemberClass(CXXRecordDecl *RD, TemplateSpecializationKind TSK)
Specify that this record is an instantiation of the member class RD.
Definition: DeclCXX.cpp:1369
void setSetterName(Selector Sel, SourceLocation Loc=SourceLocation())
Definition: DeclObjC.h:934
bool ImportContainerChecked(const InContainerTy &InContainer, OutContainerTy &OutContainer)
The template argument is actually a parameter pack.
Definition: TemplateBase.h:91
bool isArrow() const
Determine whether this member expression used the &#39;->&#39; operator; otherwise, it used the &#39;...
Definition: ExprCXX.h:3296
Represents a base class of a C++ class.
Definition: DeclCXX.h:191
Decl * VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D)
QualType VisitUnaryTransformType(const UnaryTransformType *T)
bool hasTypename() const
Return true if the using declaration has &#39;typename&#39;.
Definition: DeclCXX.h:3330
const Expr * Replacement
Definition: AttributeList.h:59
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
unsigned getNumClobbers() const
Definition: Stmt.h:1546
Decl * VisitObjCTypeParamDecl(ObjCTypeParamDecl *D)
SourceLocation getRParenLoc() const
Definition: Stmt.h:1258
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:3368
SourceManager & getSourceManager()
Definition: ASTContext.h:643
The type-property cache.
Definition: Type.cpp:3350
Expr * VisitCXXNewExpr(CXXNewExpr *CE)
DeclStmt * getRangeStmt()
Definition: StmtCXX.h:154
Stmt * VisitObjCAtThrowStmt(ObjCAtThrowStmt *S)
ImplementationControl getImplementationControl() const
Definition: DeclObjC.h:502
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2464
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2174
SourceLocation getAsmLoc() const
Definition: Stmt.h:1495
outputs_range outputs()
Definition: Stmt.h:1598
GotoStmt - This represents a direct goto.
Definition: Stmt.h:1278
void ImportDefinition(Decl *From)
Import the definition of the given declaration, including all of the declarations it contains...
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1113
Expr * getTarget()
Definition: Stmt.h:1332
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a function that was resolved from an overload...
Definition: Expr.h:1159
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:239
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3349
SourceLocation getCXXLiteralOperatorNameLoc() const
getCXXLiteralOperatorNameLoc - Returns the location of the literal operator name (not the operator ke...
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition: DeclCXX.cpp:1378
TypedefNameDecl * getDecl() const
Definition: Type.h:3773
const SwitchCase * getNextSwitchCase() const
Definition: Stmt.h:713
Decl * VisitTypeAliasDecl(TypeAliasDecl *D)
Expr * NoexceptExpr
Noexcept expression, if this is EST_ComputedNoexcept.
Definition: Type.h:3371
ArrayRef< TemplateArgumentLoc > template_arguments() const
Definition: Expr.h:1147
Expr * VisitInitListExpr(InitListExpr *E)
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:235
shadow_range shadows() const
Definition: DeclCXX.h:3375
unsigned getDepth() const
Definition: Type.h:4218
DeclarationName getCXXLiteralOperatorName(IdentifierInfo *II)
getCXXLiteralOperatorName - Get the name of the literal operator function with II as the identifier...
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:4031
Expr * getCond()
Definition: Stmt.h:1176
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:989
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2387
Decl * VisitUsingDirectiveDecl(UsingDirectiveDecl *D)
SourceLocation getWhileLoc() const
Definition: Stmt.h:1185
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos)
Insert the specified specialization knowing that it is not already in.
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2432
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
TypedefNameDecl * getTypedefNameForAnonDecl() const
Definition: Decl.h:3187
void setDefaultArg(Expr *defarg)
Definition: Decl.cpp:2505
bool isMutable() const
isMutable - Determines whether this field is mutable (C++ only).
Definition: Decl.h:2542
Represents a C++ struct/union/class.
Definition: DeclCXX.h:299
ContinueStmt - This represents a continue.
Definition: Stmt.h:1355
ObjCPropertyImplDecl * FindPropertyImplDecl(IdentifierInfo *propertyId, ObjCPropertyQueryKind queryKind) const
FindPropertyImplDecl - This method looks up a previous ObjCPropertyImplDecl added to the list of thos...
Definition: DeclObjC.cpp:2077
Expr * VisitDesignatedInitExpr(DesignatedInitExpr *E)
Represents a loop initializing the elements of an array.
Definition: Expr.h:4490
The template argument is a template name that was provided for a template template parameter...
Definition: TemplateBase.h:76
void setDescribedVarTemplate(VarTemplateDecl *Template)
Definition: Decl.cpp:2402
static CXXTryStmt * Create(const ASTContext &C, SourceLocation tryLoc, Stmt *tryBlock, ArrayRef< Stmt *> handlers)
Definition: StmtCXX.cpp:26
SourceLocation getColonLoc() const
Definition: StmtCXX.h:195
Represents a C array with an unspecified size.
Definition: Type.h:2672
TemplateArgumentLocInfo getLocInfo() const
Definition: TemplateBase.h:497
SourceLocation getEllipsisLoc() const
For a pack expansion, determine the location of the ellipsis.
Definition: DeclCXX.h:262
SourceLocation getAttrLoc() const
Definition: Stmt.h:914
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
Definition: ExprCXX.cpp:748
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:3342
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:29
An index into an array.
Definition: Expr.h:1827
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Definition: ExprCXX.h:1471
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
Definition: Decl.h:3407
Expr * getRHS() const
Definition: Expr.h:3315
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1964
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:962
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Definition: Decl.cpp:4327
Provides information a specialization of a member of a class template, which may be a member function...
Definition: DeclTemplate.h:607
QualType getNamedType() const
Retrieve the type named by the qualified-id.
Definition: Type.h:4813
WhileStmt - This represents a &#39;while&#39; stmt.
Definition: Stmt.h:1102
A structure for storing the information associated with an overloaded template name.
Definition: TemplateName.h:95
SourceRange getParenOrBraceRange() const
Definition: ExprCXX.h:1382
CleanupObject getObject(unsigned i) const
Definition: ExprCXX.h:3035
unsigned getNumConcatenated() const
getNumConcatenated - Get the number of string literal tokens that were concatenated in translation ph...
Definition: Expr.h:1617
bool isNull() const
Determine whether this is the empty selector.
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Definition: Type.h:4277
Location information for a TemplateArgument.
Definition: TemplateBase.h:393
SourceLocation getLParenLoc() const
Definition: ExprCXX.h:1502
bool isFailed() const
Definition: DeclCXX.h:3698
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
Definition: DeclCXX.cpp:2466
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
Declaration of a class template.
SourceLocation getAtSynchronizedLoc() const
Definition: StmtObjC.h:279
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:654
Stmt * VisitSwitchStmt(SwitchStmt *S)
This class is used for builtin types like &#39;int&#39;.
Definition: Type.h:2143
Optional< unsigned > getNumExpansions() const
Determine the number of expansions that will be produced when this pack expansion is instantiated...
Definition: ExprCXX.h:3692
bool isVariadic() const
Definition: DeclObjC.h:454
CompoundStmt * getTryBlock()
Definition: StmtCXX.h:96
bool ImportCastPath(CastExpr *E, CXXCastPath &Path)
SourceLocation getBreakLoc() const
Definition: Stmt.h:1393
SourceLocation getCaseLoc() const
Definition: Stmt.h:757
void setPropertyAttributes(PropertyAttributeKind PRVal)
Definition: DeclObjC.h:861
Expr * VisitArraySubscriptExpr(ArraySubscriptExpr *E)
Represents Objective-C&#39;s @try ... @catch ... @finally statement.
Definition: StmtObjC.h:154
protocol_iterator protocol_end() const
Definition: DeclObjC.h:2383
bool isGlobalDelete() const
Definition: ExprCXX.h:2111
Expr * VisitVAArgExpr(VAArgExpr *E)
const internal::VariadicDynCastAllOfMatcher< Decl, AccessSpecDecl > accessSpecDecl
Matches C++ access specifier declarations.
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
Definition: StmtObjC.h:203
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3287
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1509
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2209
Expr * VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E)
Expr * VisitArrayInitIndexExpr(ArrayInitIndexExpr *E)
SourceRange getTypeIdParens() const
Definition: ExprCXX.h:1972
QualType getIntegerType() const
getIntegerType - Return the integer type this enum decl corresponds to.
Definition: Decl.h:3364
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:3681
Expr * VisitOpaqueValueExpr(OpaqueValueExpr *E)
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
Definition: Decl.cpp:3230
Stmt * VisitDefaultStmt(DefaultStmt *S)
Import only the bare bones needed to establish a valid DeclContext.
SourceLocation getEllipsisLoc() const
Get the location of the ellipsis if this is a pack expansion.
Definition: DeclCXX.h:3643
NameKind getKind() const
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition: ExprCXX.h:246
unsigned getNumElements() const
Definition: Type.h:2950
QualType VisitExtVectorType(const ExtVectorType *T)
void setNextSwitchCase(SwitchCase *SC)
Definition: Stmt.h:717
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Definition: Redeclarable.h:230
TranslationUnitDecl - The top declaration context.
Definition: Decl.h:107
void ImportDefinitionIfNeeded(Decl *FromD, Decl *ToD=nullptr)
unsigned getNumComponents() const
Definition: Expr.h:1985
const ParmVarDecl * getParam() const
Definition: ExprCXX.h:1073
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:257
QualType VisitTypeOfExprType(const TypeOfExprType *T)
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:956
Expr * VisitBinaryConditionalOperator(BinaryConditionalOperator *E)
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:4493
Expr * getRHS() const
Definition: Expr.h:3031
ObjCPropertyDecl * getPropertyDecl() const
Definition: DeclObjC.h:2837
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
Definition: DeclObjC.h:619
SourceLocation getColonLoc() const
Definition: Stmt.h:761
BreakStmt - This represents a break.
Definition: Stmt.h:1381
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form &#39;type...
SourceLocation getUsingLoc() const
Returns the source location of the &#39;using&#39; keyword.
Definition: DeclCXX.h:3619
const VarDecl * getCatchParamDecl() const
Definition: StmtObjC.h:94
SourceLocation getLocation() const
Definition: Expr.h:1364
Expr * VisitExprWithCleanups(ExprWithCleanups *EWC)
FieldDecl * getInitializedFieldInUnion()
If this initializes a union, specifies which field in the union to initialize.
Definition: Expr.h:3984
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
Definition: ExprCXX.h:3342
Expr * VisitCompoundLiteralExpr(CompoundLiteralExpr *E)
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
Definition: Decl.cpp:1980
Stmt * getSubStmt()
Definition: Stmt.h:862
SourceLocation getBridgeKeywordLoc() const
The location of the bridge keyword.
Definition: ExprObjC.h:1607
bool hadMultipleCandidates() const
Whether the referred constructor was resolved from an overloaded set having size greater than 1...
Definition: ExprCXX.h:1313
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
Definition: Decl.h:588
SourceLocation getNamespaceLoc() const
Returns the location of the namespace keyword.
Definition: DeclCXX.h:3036
Expr * VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E)
DeclStmt * getLoopVarStmt()
Definition: StmtCXX.h:161
QualType getType() const
Definition: Decl.h:638
AccessSpecifier getAccessSpecifierAsWritten() const
Retrieves the access specifier as written in the source code (which may mean that no access specifier...
Definition: DeclCXX.h:283
TemplateArgument getArgumentPack() const
Retrieve the template template argument pack with which this parameter was substituted.
unsigned getNumArgs() const
Definition: ExprCXX.h:1362
protocol_loc_iterator protocol_loc_begin() const
Definition: DeclObjC.h:2173
A set of overloaded template declarations.
Definition: TemplateName.h:194
const Expr * getCond() const
Definition: Stmt.h:969
A trivial tuple used to represent a source range.
static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, ArrayRef< TemplateArgument > Args)
void setLexicalDeclContext(DeclContext *DC)
Definition: DeclBase.cpp:301
ObjCMethodDecl * getGetterMethodDecl() const
Definition: DeclObjC.h:939
NamedDecl - This represents a decl with a name.
Definition: Decl.h:245
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
Definition: Expr.h:2518
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:530
Expr * VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E)
static ObjCCategoryImplDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, ObjCInterfaceDecl *classInterface, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation CategoryNameLoc)
Definition: DeclObjC.cpp:2010
static DeclarationName getUsingDirectiveName()
getUsingDirectiveName - Return name for all using-directives.
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:1926
protocol_loc_iterator protocol_loc_begin() const
Definition: DeclObjC.h:2393
void setAccess(AccessSpecifier AS)
Definition: DeclBase.h:455
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Expr.h:1909
Represents a C array with a specified size that is not an integer-constant-expression.
Definition: Type.h:2717
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2532
Decl * VisitNamespaceDecl(NamespaceDecl *D)
Represents a C++ namespace alias.
Definition: DeclCXX.h:2947
Decl * VisitObjCInterfaceDecl(ObjCInterfaceDecl *D)
SourceLocation getBuiltinLoc() const
Definition: Expr.h:5193
Stmt * VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S)
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:1504
QualType VisitAtomicType(const AtomicType *T)
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
Definition: DeclCXX.h:234
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Definition: TemplateBase.h:281
AccessControl getAccessControl() const
Definition: DeclObjC.h:2003
SourceLocation getIvarRBraceLoc() const
Definition: DeclObjC.h:2438
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
Definition: Expr.h:3382
bool isPropertyAccessor() const
Definition: DeclObjC.h:459
TypeSourceInfo * getWrittenTypeInfo() const
Definition: Expr.h:3804
Selector getGetterName() const
Definition: DeclObjC.h:923
ImplicitParamKind getParameterKind() const
Returns the implicit parameter kind.
Definition: Decl.h:1503
Represents C++ using-directive.
Definition: DeclCXX.h:2843
DeclStmt * getBeginStmt()
Definition: StmtCXX.h:155
SourceLocation getLParenLoc() const
Definition: DeclObjC.h:841
const Expr * getCond() const
Definition: Stmt.h:1049
void setTypeAsWritten(TypeSourceInfo *T)
Sets the type of this specialization as it was written by the user.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
Definition: Decl.cpp:3631
void setPointOfInstantiation(SourceLocation POI)
Set the first point of instantiation.
Definition: DeclTemplate.h:652
The global specifier &#39;::&#39;. There is no stored value.
ObjCProtocolList::iterator protocol_iterator
Definition: DeclObjC.h:2145
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
Definition: TemplateBase.h:288
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.cpp:277
void setType(QualType newType)
Definition: Decl.h:639
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr, InheritedConstructor Inherited=InheritedConstructor())
Definition: DeclCXX.cpp:2057
SourceLocation getBegin() const
TranslationUnitDecl * getTranslationUnitDecl()
Definition: DeclBase.cpp:363
SourceLocation ColonLoc
Location of &#39;:&#39;.
Definition: OpenMPClause.h:97
SourceLocation getRParenLoc() const
Return the location of the right parentheses.
Definition: Expr.h:1965
Decl * VisitParmVarDecl(ParmVarDecl *D)
SourceLocation getInnerLocStart() const
getInnerLocStart - Return SourceLocation representing start of source range ignoring outer template d...
Definition: Decl.h:722
QualType VisitRValueReferenceType(const RValueReferenceType *T)
Represents Objective-C&#39;s @autoreleasepool Statement.
Definition: StmtObjC.h:345
Stmt * VisitGCCAsmStmt(GCCAsmStmt *S)
QualType VisitAutoType(const AutoType *T)
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration...
Definition: DeclObjC.h:2518
IdentifierInfo * getFieldName() const
Definition: Expr.cpp:3670
This class handles loading and caching of source files into memory.
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2618
Stmt * getSubStmt()
Definition: Stmt.h:919
ExceptionSpecInfo ExceptionSpec
Definition: Type.h:3393
QualType VisitType(const Type *T)
DeclContext * ImportContext(DeclContext *FromDC)
Import the given declaration context from the "from" AST context into the "to" AST context...
InitListExpr * getSyntacticForm() const
Definition: Expr.h:4029
Declaration of a template function.
Definition: DeclTemplate.h:967
void setPropertyIvarDecl(ObjCIvarDecl *Ivar)
Definition: DeclObjC.h:958
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:4580
static ObjCAtTryStmt * Create(const ASTContext &Context, SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt)
Definition: StmtObjC.cpp:46
SourceLocation getReturnLoc() const
Definition: Stmt.h:1436
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
Expr * VisitCXXThrowExpr(CXXThrowExpr *E)
Stmt * VisitStmt(Stmt *S)
Attr - This represents one attribute.
Definition: Attr.h:43
SourceLocation getLocation() const
Definition: DeclBase.h:416
QualType VisitTypeOfType(const TypeOfType *T)
QualType getPointeeType() const
Definition: Type.h:2522
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
Definition: DeclCXX.h:3066
QualType getType() const
Return the type wrapped by this type source info.
Definition: Decl.h:97
TypeTrait getTrait() const
Determine which type trait this expression uses.
Definition: ExprCXX.h:2378
A single template declaration.
Definition: TemplateName.h:191
bool isBeingDefined() const
isBeingDefined - Return true if this decl is currently being defined.
Definition: Decl.h:3108
std::pair< FileID, unsigned > getDecomposedLoc(SourceLocation Loc) const
Decompose the specified location into a raw FileID + Offset pair.
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3328
ArrayRef< ParmVarDecl * > parameters() const
Definition: DeclObjC.h:405
Expr * VisitStmtExpr(StmtExpr *E)
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form, which contains extra information on the evaluated value of the initializer.
Definition: Decl.cpp:2195
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
Definition: Decl.h:366
ConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Definition: ExprCXX.h:1336
ObjCCategoryDecl * FindCategoryDeclaration(IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
Definition: DeclObjC.cpp:1628
DeclarationName getCXXOperatorName(OverloadedOperatorKind Op)
getCXXOperatorName - Get the name of the overloadable C++ operator corresponding to Op...
Structure used to store a statement, the constant value to which it was evaluated (if any)...
Definition: Decl.h:776
QualType VisitPackExpansionType(const PackExpansionType *T)
Stmt * getSubStmt()
Definition: Stmt.h:766
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
Definition: Type.h:5456
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.
void notePriorDiagnosticFrom(const DiagnosticsEngine &Other)
Note that the prior diagnostic was emitted by some other DiagnosticsEngine, and we may be attaching a...
Definition: Diagnostic.h:714