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