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