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