clang  12.0.0git
ASTImporter.h
Go to the documentation of this file.
1 //===- ASTImporter.h - Importing ASTs from other Contexts -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the ASTImporter class which imports AST nodes from one
10 // context into another context.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_AST_ASTIMPORTER_H
15 #define LLVM_CLANG_AST_ASTIMPORTER_H
16 
17 #include "clang/AST/DeclBase.h"
19 #include "clang/AST/ExprCXX.h"
21 #include "clang/AST/TemplateName.h"
22 #include "clang/AST/Type.h"
23 #include "clang/Basic/Diagnostic.h"
25 #include "clang/Basic/LLVM.h"
27 #include "llvm/ADT/DenseMap.h"
28 #include "llvm/ADT/DenseSet.h"
29 #include "llvm/ADT/Optional.h"
30 #include "llvm/ADT/SmallVector.h"
31 #include "llvm/Support/Error.h"
32 #include <utility>
33 
34 namespace clang {
35 
36 class ASTContext;
37 class ASTImporterSharedState;
38 class Attr;
39 class CXXBaseSpecifier;
40 class CXXCtorInitializer;
41 class Decl;
42 class DeclContext;
43 class Expr;
44 class FileManager;
45 class NamedDecl;
46 class Stmt;
47 class TagDecl;
48 class TranslationUnitDecl;
49 class TypeSourceInfo;
50 
51  class ImportError : public llvm::ErrorInfo<ImportError> {
52  public:
53  /// \brief Kind of error when importing an AST component.
54  enum ErrorKind {
55  NameConflict, /// Naming ambiguity (likely ODR violation).
56  UnsupportedConstruct, /// Not supported node or case.
57  Unknown /// Other error.
58  };
59 
61 
62  static char ID;
63 
64  ImportError() : Error(Unknown) {}
65  ImportError(const ImportError &Other) : Error(Other.Error) {}
67  Error = Other.Error;
68  return *this;
69  }
70  ImportError(ErrorKind Error) : Error(Error) { }
71 
72  std::string toString() const;
73 
74  void log(raw_ostream &OS) const override;
75  std::error_code convertToErrorCode() const override;
76  };
77 
78  // \brief Returns with a list of declarations started from the canonical decl
79  // then followed by subsequent decls in the translation unit.
80  // This gives a canonical list for each entry in the redecl chain.
81  // `Decl::redecls()` gives a list of decls which always start from the
82  // previous decl and the next item is actually the previous item in the order
83  // of source locations. Thus, `Decl::redecls()` gives different lists for
84  // the different entries in a given redecl chain.
86 
87  /// Imports selected nodes from one AST context into another context,
88  /// merging AST nodes where appropriate.
89  class ASTImporter {
90  friend class ASTNodeImporter;
91  public:
94  llvm::DenseMap<const CXXBaseSpecifier *, CXXBaseSpecifier *>;
96  std::function<void(FileID /*ToID*/, FileID /*FromID*/)>;
97 
98  enum class ODRHandlingType { Conservative, Liberal };
99 
100  // An ImportPath is the list of the AST nodes which we visit during an
101  // Import call.
102  // If node `A` depends on node `B` then the path contains an `A`->`B` edge.
103  // From the call stack of the import functions we can read the very same
104  // path.
105  //
106  // Now imagine the following AST, where the `->` represents dependency in
107  // therms of the import.
108  // ```
109  // A->B->C->D
110  // `->E
111  // ```
112  // We would like to import A.
113  // The import behaves like a DFS, so we will visit the nodes in this order:
114  // ABCDE.
115  // During the visitation we will have the following ImportPaths:
116  // ```
117  // A
118  // AB
119  // ABC
120  // ABCD
121  // ABC
122  // AB
123  // ABE
124  // AB
125  // A
126  // ```
127  // If during the visit of E there is an error then we set an error for E,
128  // then as the call stack shrinks for B, then for A:
129  // ```
130  // A
131  // AB
132  // ABC
133  // ABCD
134  // ABC
135  // AB
136  // ABE // Error! Set an error to E
137  // AB // Set an error to B
138  // A // Set an error to A
139  // ```
140  // However, during the import we could import C and D without any error and
141  // they are independent from A,B and E.
142  // We must not set up an error for C and D.
143  // So, at the end of the import we have an entry in `ImportDeclErrors` for
144  // A,B,E but not for C,D.
145  //
146  // Now what happens if there is a cycle in the import path?
147  // Let's consider this AST:
148  // ```
149  // A->B->C->A
150  // `->E
151  // ```
152  // During the visitation we will have the below ImportPaths and if during
153  // the visit of E there is an error then we will set up an error for E,B,A.
154  // But what's up with C?
155  // ```
156  // A
157  // AB
158  // ABC
159  // ABCA
160  // ABC
161  // AB
162  // ABE // Error! Set an error to E
163  // AB // Set an error to B
164  // A // Set an error to A
165  // ```
166  // This time we know that both B and C are dependent on A.
167  // This means we must set up an error for C too.
168  // As the call stack reverses back we get to A and we must set up an error
169  // to all nodes which depend on A (this includes C).
170  // But C is no longer on the import path, it just had been previously.
171  // Such situation can happen only if during the visitation we had a cycle.
172  // If we didn't have any cycle, then the normal way of passing an Error
173  // object through the call stack could handle the situation.
174  // This is why we must track cycles during the import process for each
175  // visited declaration.
176  class ImportPathTy {
177  public:
179 
180  void push(Decl *D) {
181  Nodes.push_back(D);
182  ++Aux[D];
183  }
184 
185  void pop() {
186  if (Nodes.empty())
187  return;
188  --Aux[Nodes.back()];
189  Nodes.pop_back();
190  }
191 
192  /// Returns true if the last element can be found earlier in the path.
193  bool hasCycleAtBack() const {
194  auto Pos = Aux.find(Nodes.back());
195  return Pos != Aux.end() && Pos->second > 1;
196  }
197 
198  using Cycle = llvm::iterator_range<VecTy::const_reverse_iterator>;
200  assert(Nodes.size() >= 2);
201  return Cycle(Nodes.rbegin(),
202  std::find(Nodes.rbegin() + 1, Nodes.rend(), Nodes.back()) +
203  1);
204  }
205 
206  /// Returns the copy of the cycle.
208  auto R = getCycleAtBack();
209  return VecTy(R.begin(), R.end());
210  }
211 
212  private:
213  // All nodes of the path.
214  VecTy Nodes;
215  // Auxiliary container to be able to answer "Do we have a cycle ending
216  // at last element?" as fast as possible.
217  // We count each Decl's occurrence over the path.
218  llvm::SmallDenseMap<Decl *, int, 32> Aux;
219  };
220 
221  private:
222  FileIDImportHandlerType FileIDImportHandler;
223 
224  std::shared_ptr<ASTImporterSharedState> SharedState = nullptr;
225 
226  /// The path which we go through during the import of a given AST node.
227  ImportPathTy ImportPath;
228  /// Sometimes we have to save some part of an import path, so later we can
229  /// set up properties to the saved nodes.
230  /// We may have several of these import paths associated to one Decl.
233  using SavedImportPathsTy =
234  llvm::SmallDenseMap<Decl *, SavedImportPathsForOneDecl, 32>;
235  SavedImportPathsTy SavedImportPaths;
236 
237  /// The contexts we're importing to and from.
238  ASTContext &ToContext, &FromContext;
239 
240  /// The file managers we're importing to and from.
241  FileManager &ToFileManager, &FromFileManager;
242 
243  /// Whether to perform a minimal import.
244  bool Minimal;
245 
246  ODRHandlingType ODRHandling;
247 
248  /// Whether the last diagnostic came from the "from" context.
249  bool LastDiagFromFrom = false;
250 
251  /// Mapping from the already-imported types in the "from" context
252  /// to the corresponding types in the "to" context.
253  llvm::DenseMap<const Type *, const Type *> ImportedTypes;
254 
255  /// Mapping from the already-imported declarations in the "from"
256  /// context to the corresponding declarations in the "to" context.
257  llvm::DenseMap<Decl *, Decl *> ImportedDecls;
258 
259  /// Mapping from the already-imported declarations in the "from"
260  /// context to the error status of the import of that declaration.
261  /// This map contains only the declarations that were not correctly
262  /// imported. The same declaration may or may not be included in
263  /// ImportedDecls. This map is updated continuously during imports and never
264  /// cleared (like ImportedDecls).
265  llvm::DenseMap<Decl *, ImportError> ImportDeclErrors;
266 
267  /// Mapping from the already-imported declarations in the "to"
268  /// context to the corresponding declarations in the "from" context.
269  llvm::DenseMap<Decl *, Decl *> ImportedFromDecls;
270 
271  /// Mapping from the already-imported statements in the "from"
272  /// context to the corresponding statements in the "to" context.
273  llvm::DenseMap<Stmt *, Stmt *> ImportedStmts;
274 
275  /// Mapping from the already-imported FileIDs in the "from" source
276  /// manager to the corresponding FileIDs in the "to" source manager.
277  llvm::DenseMap<FileID, FileID> ImportedFileIDs;
278 
279  /// Mapping from the already-imported CXXBasesSpecifier in
280  /// the "from" source manager to the corresponding CXXBasesSpecifier
281  /// in the "to" source manager.
282  ImportedCXXBaseSpecifierMap ImportedCXXBaseSpecifiers;
283 
284  /// Declaration (from, to) pairs that are known not to be equivalent
285  /// (which we have already complained about).
286  NonEquivalentDeclSet NonEquivalentDecls;
287 
289  FoundDeclsTy findDeclsInToCtx(DeclContext *DC, DeclarationName Name);
290 
291  void AddToLookupTable(Decl *ToD);
292 
293  protected:
294  /// Can be overwritten by subclasses to implement their own import logic.
295  /// The overwritten method should call this method if it didn't import the
296  /// decl on its own.
297  virtual Expected<Decl *> ImportImpl(Decl *From);
298 
299  /// Used only in unittests to verify the behaviour of the error handling.
300  virtual bool returnWithErrorInTest() { return false; };
301 
302  public:
303 
304  /// \param ToContext The context we'll be importing into.
305  ///
306  /// \param ToFileManager The file manager we'll be importing into.
307  ///
308  /// \param FromContext The context we'll be importing from.
309  ///
310  /// \param FromFileManager The file manager we'll be importing into.
311  ///
312  /// \param MinimalImport If true, the importer will attempt to import
313  /// as little as it can, e.g., by importing declarations as forward
314  /// declarations that can be completed at a later point.
315  ///
316  /// \param SharedState The importer specific lookup table which may be
317  /// shared amongst several ASTImporter objects.
318  /// If not set then the original C/C++ lookup is used.
319  ASTImporter(ASTContext &ToContext, FileManager &ToFileManager,
320  ASTContext &FromContext, FileManager &FromFileManager,
321  bool MinimalImport,
322  std::shared_ptr<ASTImporterSharedState> SharedState = nullptr);
323 
324  virtual ~ASTImporter();
325 
326  /// Set a callback function for FileID import handling.
327  /// The function is invoked when a FileID is imported from the From context.
328  /// The imported FileID in the To context and the original FileID in the
329  /// From context is passed to it.
331  FileIDImportHandler = H;
332  }
333 
334  /// Whether the importer will perform a minimal import, creating
335  /// to-be-completed forward declarations when possible.
336  bool isMinimalImport() const { return Minimal; }
337 
338  void setODRHandling(ODRHandlingType T) { ODRHandling = T; }
339 
340  /// \brief Import the given object, returns the result.
341  ///
342  /// \param To Import the object into this variable.
343  /// \param From Object to import.
344  /// \return Error information (success or error).
345  template <typename ImportT>
346  LLVM_NODISCARD llvm::Error importInto(ImportT &To, const ImportT &From) {
347  auto ToOrErr = Import(From);
348  if (ToOrErr)
349  To = *ToOrErr;
350  return ToOrErr.takeError();
351  }
352 
353  /// Import cleanup objects owned by ExprWithCleanup.
355  Import(ExprWithCleanups::CleanupObject From);
356 
357  /// Import the given type from the "from" context into the "to"
358  /// context. A null type is imported as a null type (no error).
359  ///
360  /// \returns The equivalent type in the "to" context, or the import error.
361  llvm::Expected<QualType> Import(QualType FromT);
362 
363  /// Import the given type source information from the
364  /// "from" context into the "to" context.
365  ///
366  /// \returns The equivalent type source information in the "to"
367  /// context, or the import error.
369 
370  /// Import the given attribute from the "from" context into the
371  /// "to" context.
372  ///
373  /// \returns The equivalent attribute in the "to" context, or the import
374  /// error.
375  llvm::Expected<Attr *> Import(const Attr *FromAttr);
376 
377  /// Import the given declaration from the "from" context into the
378  /// "to" context.
379  ///
380  /// \returns The equivalent declaration in the "to" context, or the import
381  /// error.
382  llvm::Expected<Decl *> Import(Decl *FromD);
384  return Import(const_cast<Decl *>(FromD));
385  }
386 
387  /// Return the copy of the given declaration in the "to" context if
388  /// it has already been imported from the "from" context. Otherwise return
389  /// nullptr.
390  Decl *GetAlreadyImportedOrNull(const Decl *FromD) const;
391 
392  /// Return the translation unit from where the declaration was
393  /// imported. If it does not exist nullptr is returned.
394  TranslationUnitDecl *GetFromTU(Decl *ToD);
395 
396  /// Return the declaration in the "from" context from which the declaration
397  /// in the "to" context was imported. If it was not imported or of the wrong
398  /// type a null value is returned.
399  template <typename DeclT>
401  auto FromI = ImportedFromDecls.find(ToD);
402  if (FromI == ImportedFromDecls.end())
403  return {};
404  auto *FromD = dyn_cast<DeclT>(FromI->second);
405  if (!FromD)
406  return {};
407  return FromD;
408  }
409 
410  /// Import the given declaration context from the "from"
411  /// AST context into the "to" AST context.
412  ///
413  /// \returns the equivalent declaration context in the "to"
414  /// context, or error value.
415  llvm::Expected<DeclContext *> ImportContext(DeclContext *FromDC);
416 
417  /// Import the given expression from the "from" context into the
418  /// "to" context.
419  ///
420  /// \returns The equivalent expression in the "to" context, or the import
421  /// error.
422  llvm::Expected<Expr *> Import(Expr *FromE);
423 
424  /// Import the given statement from the "from" context into the
425  /// "to" context.
426  ///
427  /// \returns The equivalent statement in the "to" context, or the import
428  /// error.
429  llvm::Expected<Stmt *> Import(Stmt *FromS);
430 
431  /// Import the given nested-name-specifier from the "from"
432  /// context into the "to" context.
433  ///
434  /// \returns The equivalent nested-name-specifier in the "to"
435  /// context, or the import error.
437 
438  /// Import the given nested-name-specifier-loc from the "from"
439  /// context into the "to" context.
440  ///
441  /// \returns The equivalent nested-name-specifier-loc in the "to"
442  /// context, or the import error.
444  Import(NestedNameSpecifierLoc FromNNS);
445 
446  /// Import the given template name from the "from" context into the
447  /// "to" context, or the import error.
449 
450  /// Import the given source location from the "from" context into
451  /// the "to" context.
452  ///
453  /// \returns The equivalent source location in the "to" context, or the
454  /// import error.
456 
457  /// Import the given source range from the "from" context into
458  /// the "to" context.
459  ///
460  /// \returns The equivalent source range in the "to" context, or the import
461  /// error.
462  llvm::Expected<SourceRange> Import(SourceRange FromRange);
463 
464  /// Import the given declaration name from the "from"
465  /// context into the "to" context.
466  ///
467  /// \returns The equivalent declaration name in the "to" context, or the
468  /// import error.
470 
471  /// Import the given identifier from the "from" context
472  /// into the "to" context.
473  ///
474  /// \returns The equivalent identifier in the "to" context. Note: It
475  /// returns nullptr only if the FromId was nullptr.
476  IdentifierInfo *Import(const IdentifierInfo *FromId);
477 
478  /// Import the given Objective-C selector from the "from"
479  /// context into the "to" context.
480  ///
481  /// \returns The equivalent selector in the "to" context, or the import
482  /// error.
483  llvm::Expected<Selector> Import(Selector FromSel);
484 
485  /// Import the given file ID from the "from" context into the
486  /// "to" context.
487  ///
488  /// \returns The equivalent file ID in the source manager of the "to"
489  /// context, or the import error.
490  llvm::Expected<FileID> Import(FileID, bool IsBuiltin = false);
491 
492  /// Import the given C++ constructor initializer from the "from"
493  /// context into the "to" context.
494  ///
495  /// \returns The equivalent initializer in the "to" context, or the import
496  /// error.
498 
499  /// Import the given CXXBaseSpecifier from the "from" context into
500  /// the "to" context.
501  ///
502  /// \returns The equivalent CXXBaseSpecifier in the source manager of the
503  /// "to" context, or the import error.
505 
506  /// Import the definition of the given declaration, including all of
507  /// the declarations it contains.
508  LLVM_NODISCARD llvm::Error ImportDefinition(Decl *From);
509 
510  /// Cope with a name conflict when importing a declaration into the
511  /// given context.
512  ///
513  /// This routine is invoked whenever there is a name conflict while
514  /// importing a declaration. The returned name will become the name of the
515  /// imported declaration. By default, the returned name is the same as the
516  /// original name, leaving the conflict unresolve such that name lookup
517  /// for this name is likely to find an ambiguity later.
518  ///
519  /// Subclasses may override this routine to resolve the conflict, e.g., by
520  /// renaming the declaration being imported.
521  ///
522  /// \param Name the name of the declaration being imported, which conflicts
523  /// with other declarations.
524  ///
525  /// \param DC the declaration context (in the "to" AST context) in which
526  /// the name is being imported.
527  ///
528  /// \param IDNS the identifier namespace in which the name will be found.
529  ///
530  /// \param Decls the set of declarations with the same name as the
531  /// declaration being imported.
532  ///
533  /// \param NumDecls the number of conflicting declarations in \p Decls.
534  ///
535  /// \returns the name that the newly-imported declaration should have. Or
536  /// an error if we can't handle the name conflict.
538  HandleNameConflict(DeclarationName Name, DeclContext *DC, unsigned IDNS,
539  NamedDecl **Decls, unsigned NumDecls);
540 
541  /// Retrieve the context that AST nodes are being imported into.
542  ASTContext &getToContext() const { return ToContext; }
543 
544  /// Retrieve the context that AST nodes are being imported from.
545  ASTContext &getFromContext() const { return FromContext; }
546 
547  /// Retrieve the file manager that AST nodes are being imported into.
548  FileManager &getToFileManager() const { return ToFileManager; }
549 
550  /// Retrieve the file manager that AST nodes are being imported from.
551  FileManager &getFromFileManager() const { return FromFileManager; }
552 
553  /// Report a diagnostic in the "to" context.
554  DiagnosticBuilder ToDiag(SourceLocation Loc, unsigned DiagID);
555 
556  /// Report a diagnostic in the "from" context.
557  DiagnosticBuilder FromDiag(SourceLocation Loc, unsigned DiagID);
558 
559  /// Return the set of declarations that we know are not equivalent.
560  NonEquivalentDeclSet &getNonEquivalentDecls() { return NonEquivalentDecls; }
561 
562  /// Called for ObjCInterfaceDecl, ObjCProtocolDecl, and TagDecl.
563  /// Mark the Decl as complete, filling it in as much as possible.
564  ///
565  /// \param D A declaration in the "to" context.
566  virtual void CompleteDecl(Decl* D);
567 
568  /// Subclasses can override this function to observe all of the \c From ->
569  /// \c To declaration mappings as they are imported.
570  virtual void Imported(Decl *From, Decl *To) {}
571 
572  void RegisterImportedDecl(Decl *FromD, Decl *ToD);
573 
574  /// Store and assign the imported declaration to its counterpart.
575  /// It may happen that several decls from the 'from' context are mapped to
576  /// the same decl in the 'to' context.
577  Decl *MapImported(Decl *From, Decl *To);
578 
579  /// Called by StructuralEquivalenceContext. If a RecordDecl is
580  /// being compared to another RecordDecl as part of import, completing the
581  /// other RecordDecl may trigger importation of the first RecordDecl. This
582  /// happens especially for anonymous structs. If the original of the second
583  /// RecordDecl can be found, we can complete it without the need for
584  /// importation, eliminating this loop.
585  virtual Decl *GetOriginalDecl(Decl *To) { return nullptr; }
586 
587  /// Return if import of the given declaration has failed and if yes
588  /// the kind of the problem. This gives the first error encountered with
589  /// the node.
590  llvm::Optional<ImportError> getImportDeclErrorIfAny(Decl *FromD) const;
591 
592  /// Mark (newly) imported declaration with error.
593  void setImportDeclError(Decl *From, ImportError Error);
594 
595  /// Determine whether the given types are structurally
596  /// equivalent.
598  bool Complain = true);
599 
600  /// Determine the index of a field in its parent record.
601  /// F should be a field (or indirect field) declaration.
602  /// \returns The index of the field in its parent context (starting from 0).
603  /// On error `None` is returned (parent context is non-record).
604  static llvm::Optional<unsigned> getFieldIndex(Decl *F);
605  };
606 
607 } // namespace clang
608 
609 #endif // LLVM_CLANG_AST_ASTIMPORTER_H
static char ID
Definition: ASTImporter.h:62
Smart pointer class that efficiently represents Objective-C method names.
A (possibly-)qualified type.
Definition: Type.h:655
Implements support for file system lookup, file system caching, and directory search management...
Definition: FileManager.h:172
Stmt - This represents one statement.
Definition: Stmt.h:68
C Language Family Type Representation.
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
VecTy copyCycleAtBack() const
Returns the copy of the cycle.
Definition: ASTImporter.h:207
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
A container of type source information.
Definition: Type.h:6373
Not supported node or case.
Definition: ASTImporter.h:57
virtual bool returnWithErrorInTest()
Used only in unittests to verify the behaviour of the error handling.
Definition: ASTImporter.h:300
virtual Decl * GetOriginalDecl(Decl *To)
Called by StructuralEquivalenceContext.
Definition: ASTImporter.h:585
llvm::iterator_range< VecTy::const_reverse_iterator > Cycle
Definition: ASTImporter.h:198
FileManager & getFromFileManager() const
Retrieve the file manager that AST nodes are being imported from.
Definition: ASTImporter.h:551
Defines the clang::Expr interface and subclasses for C++ expressions.
BoundNodesTreeBuilder Nodes
One of these records is kept for each identifier that is lexed.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:174
A C++ nested-name-specifier augmented with source location information.
ImportError & operator=(const ImportError &Other)
Definition: ASTImporter.h:66
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
llvm::Optional< DeclT * > getImportedFromDecl(const DeclT *ToD) const
Return the declaration in the "from" context from which the declaration in the "to" context was impor...
Definition: ASTImporter.h:400
Defines the Diagnostic-related interfaces.
void log(raw_ostream &OS) const override
llvm::DenseMap< const CXXBaseSpecifier *, CXXBaseSpecifier * > ImportedCXXBaseSpecifierMap
Definition: ASTImporter.h:94
ASTContext & getToContext() const
Retrieve the context that AST nodes are being imported into.
Definition: ASTImporter.h:542
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:1062
This represents one expression.
Definition: Expr.h:110
llvm::PointerUnion< BlockDecl *, CompoundLiteralExpr * > CleanupObject
The type of objects that are kept in the cleanup.
Definition: ExprCXX.h:3306
Represents a C++ template name within the type system.
Definition: TemplateName.h:192
llvm::SmallVector< Decl *, 2 > getCanonicalForwardRedeclChain(Decl *D)
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
std::error_code convertToErrorCode() const override
ImportError(ErrorKind Error)
Definition: ASTImporter.h:70
void setFileIDImportHandler(FileIDImportHandlerType H)
Set a callback function for FileID import handling.
Definition: ASTImporter.h:330
Encodes a location in the source.
static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, QualType T1, QualType T2)
Determine structural equivalence of two types.
ImportError(const ImportError &Other)
Definition: ASTImporter.h:65
virtual void Imported(Decl *From, Decl *To)
Subclasses can override this function to observe all of the From -> To declaration mappings as they a...
Definition: ASTImporter.h:570
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isMinimalImport() const
Whether the importer will perform a minimal import, creating to-be-completed forward declarations whe...
Definition: ASTImporter.h:336
FileManager & getToFileManager() const
Retrieve the file manager that AST nodes are being imported into.
Definition: ASTImporter.h:548
void setODRHandling(ODRHandlingType T)
Definition: ASTImporter.h:338
Naming ambiguity (likely ODR violation).
Definition: ASTImporter.h:56
llvm::Expected< const Decl * > Import(const Decl *FromD)
Definition: ASTImporter.h:383
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
NonEquivalentDeclSet & getNonEquivalentDecls()
Return the set of declarations that we know are not equivalent.
Definition: ASTImporter.h:560
Dataflow Directional Tag Classes.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1303
bool hasCycleAtBack() const
Returns true if the last element can be found earlier in the path.
Definition: ASTImporter.h:193
LLVM_NODISCARD llvm::Error importInto(ImportT &To, const ImportT &From)
Import the given object, returns the result.
Definition: ASTImporter.h:346
The name of a declaration.
Imports selected nodes from one AST context into another context, merging AST nodes where appropriate...
Definition: ASTImporter.h:89
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2185
Represents a base class of a C++ class.
Definition: DeclCXX.h:146
Defines the clang::SourceLocation class and associated facilities.
ASTContext & getFromContext() const
Retrieve the context that AST nodes are being imported from.
Definition: ASTImporter.h:545
The top declaration context.
Definition: Decl.h:82
std::string toString() const
Definition: ASTImporter.cpp:86
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
Definition: Decl.h:223
std::function< void(FileID, FileID)> FileIDImportHandlerType
Definition: ASTImporter.h:96
Attr - This represents one attribute.
Definition: Attr.h:46
ErrorKind
Kind of error when importing an AST component.
Definition: ASTImporter.h:54