ASTImporter.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- ASTImporter.h - Importing ASTs from other Contexts -------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file defines the ASTImporter class which imports AST nodes from one
  15. // context into another context.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CLANG_AST_ASTIMPORTER_H
  19. #define LLVM_CLANG_AST_ASTIMPORTER_H
  20. #include "clang/AST/ASTImportError.h"
  21. #include "clang/AST/DeclBase.h"
  22. #include "clang/AST/DeclarationName.h"
  23. #include "clang/AST/ExprCXX.h"
  24. #include "clang/AST/NestedNameSpecifier.h"
  25. #include "clang/AST/TemplateName.h"
  26. #include "clang/AST/Type.h"
  27. #include "clang/Basic/Diagnostic.h"
  28. #include "clang/Basic/IdentifierTable.h"
  29. #include "clang/Basic/LLVM.h"
  30. #include "clang/Basic/SourceLocation.h"
  31. #include "llvm/ADT/DenseMap.h"
  32. #include "llvm/ADT/DenseSet.h"
  33. #include "llvm/ADT/SmallVector.h"
  34. #include <optional>
  35. #include <utility>
  36. namespace clang {
  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. // \brief Returns with a list of declarations started from the canonical decl
  52. // then followed by subsequent decls in the translation unit.
  53. // This gives a canonical list for each entry in the redecl chain.
  54. // `Decl::redecls()` gives a list of decls which always start from the
  55. // previous decl and the next item is actually the previous item in the order
  56. // of source locations. Thus, `Decl::redecls()` gives different lists for
  57. // the different entries in a given redecl chain.
  58. llvm::SmallVector<Decl*, 2> getCanonicalForwardRedeclChain(Decl* D);
  59. /// Imports selected nodes from one AST context into another context,
  60. /// merging AST nodes where appropriate.
  61. class ASTImporter {
  62. friend class ASTNodeImporter;
  63. public:
  64. using NonEquivalentDeclSet = llvm::DenseSet<std::pair<Decl *, Decl *>>;
  65. using ImportedCXXBaseSpecifierMap =
  66. llvm::DenseMap<const CXXBaseSpecifier *, CXXBaseSpecifier *>;
  67. enum class ODRHandlingType { Conservative, Liberal };
  68. // An ImportPath is the list of the AST nodes which we visit during an
  69. // Import call.
  70. // If node `A` depends on node `B` then the path contains an `A`->`B` edge.
  71. // From the call stack of the import functions we can read the very same
  72. // path.
  73. //
  74. // Now imagine the following AST, where the `->` represents dependency in
  75. // therms of the import.
  76. // ```
  77. // A->B->C->D
  78. // `->E
  79. // ```
  80. // We would like to import A.
  81. // The import behaves like a DFS, so we will visit the nodes in this order:
  82. // ABCDE.
  83. // During the visitation we will have the following ImportPaths:
  84. // ```
  85. // A
  86. // AB
  87. // ABC
  88. // ABCD
  89. // ABC
  90. // AB
  91. // ABE
  92. // AB
  93. // A
  94. // ```
  95. // If during the visit of E there is an error then we set an error for E,
  96. // then as the call stack shrinks for B, then for A:
  97. // ```
  98. // A
  99. // AB
  100. // ABC
  101. // ABCD
  102. // ABC
  103. // AB
  104. // ABE // Error! Set an error to E
  105. // AB // Set an error to B
  106. // A // Set an error to A
  107. // ```
  108. // However, during the import we could import C and D without any error and
  109. // they are independent from A,B and E.
  110. // We must not set up an error for C and D.
  111. // So, at the end of the import we have an entry in `ImportDeclErrors` for
  112. // A,B,E but not for C,D.
  113. //
  114. // Now what happens if there is a cycle in the import path?
  115. // Let's consider this AST:
  116. // ```
  117. // A->B->C->A
  118. // `->E
  119. // ```
  120. // During the visitation we will have the below ImportPaths and if during
  121. // the visit of E there is an error then we will set up an error for E,B,A.
  122. // But what's up with C?
  123. // ```
  124. // A
  125. // AB
  126. // ABC
  127. // ABCA
  128. // ABC
  129. // AB
  130. // ABE // Error! Set an error to E
  131. // AB // Set an error to B
  132. // A // Set an error to A
  133. // ```
  134. // This time we know that both B and C are dependent on A.
  135. // This means we must set up an error for C too.
  136. // As the call stack reverses back we get to A and we must set up an error
  137. // to all nodes which depend on A (this includes C).
  138. // But C is no longer on the import path, it just had been previously.
  139. // Such situation can happen only if during the visitation we had a cycle.
  140. // If we didn't have any cycle, then the normal way of passing an Error
  141. // object through the call stack could handle the situation.
  142. // This is why we must track cycles during the import process for each
  143. // visited declaration.
  144. class ImportPathTy {
  145. public:
  146. using VecTy = llvm::SmallVector<Decl *, 32>;
  147. void push(Decl *D) {
  148. Nodes.push_back(D);
  149. ++Aux[D];
  150. }
  151. void pop() {
  152. if (Nodes.empty())
  153. return;
  154. --Aux[Nodes.back()];
  155. Nodes.pop_back();
  156. }
  157. /// Returns true if the last element can be found earlier in the path.
  158. bool hasCycleAtBack() const {
  159. auto Pos = Aux.find(Nodes.back());
  160. return Pos != Aux.end() && Pos->second > 1;
  161. }
  162. using Cycle = llvm::iterator_range<VecTy::const_reverse_iterator>;
  163. Cycle getCycleAtBack() const {
  164. assert(Nodes.size() >= 2);
  165. return Cycle(Nodes.rbegin(),
  166. std::find(Nodes.rbegin() + 1, Nodes.rend(), Nodes.back()) +
  167. 1);
  168. }
  169. /// Returns the copy of the cycle.
  170. VecTy copyCycleAtBack() const {
  171. auto R = getCycleAtBack();
  172. return VecTy(R.begin(), R.end());
  173. }
  174. private:
  175. // All nodes of the path.
  176. VecTy Nodes;
  177. // Auxiliary container to be able to answer "Do we have a cycle ending
  178. // at last element?" as fast as possible.
  179. // We count each Decl's occurrence over the path.
  180. llvm::SmallDenseMap<Decl *, int, 32> Aux;
  181. };
  182. private:
  183. std::shared_ptr<ASTImporterSharedState> SharedState = nullptr;
  184. /// The path which we go through during the import of a given AST node.
  185. ImportPathTy ImportPath;
  186. /// Sometimes we have to save some part of an import path, so later we can
  187. /// set up properties to the saved nodes.
  188. /// We may have several of these import paths associated to one Decl.
  189. using SavedImportPathsForOneDecl =
  190. llvm::SmallVector<ImportPathTy::VecTy, 32>;
  191. using SavedImportPathsTy =
  192. llvm::SmallDenseMap<Decl *, SavedImportPathsForOneDecl, 32>;
  193. SavedImportPathsTy SavedImportPaths;
  194. /// The contexts we're importing to and from.
  195. ASTContext &ToContext, &FromContext;
  196. /// The file managers we're importing to and from.
  197. FileManager &ToFileManager, &FromFileManager;
  198. /// Whether to perform a minimal import.
  199. bool Minimal;
  200. ODRHandlingType ODRHandling;
  201. /// Whether the last diagnostic came from the "from" context.
  202. bool LastDiagFromFrom = false;
  203. /// Mapping from the already-imported types in the "from" context
  204. /// to the corresponding types in the "to" context.
  205. llvm::DenseMap<const Type *, const Type *> ImportedTypes;
  206. /// Mapping from the already-imported declarations in the "from"
  207. /// context to the corresponding declarations in the "to" context.
  208. llvm::DenseMap<Decl *, Decl *> ImportedDecls;
  209. /// Mapping from the already-imported declarations in the "from"
  210. /// context to the error status of the import of that declaration.
  211. /// This map contains only the declarations that were not correctly
  212. /// imported. The same declaration may or may not be included in
  213. /// ImportedDecls. This map is updated continuously during imports and never
  214. /// cleared (like ImportedDecls).
  215. llvm::DenseMap<Decl *, ASTImportError> ImportDeclErrors;
  216. /// Mapping from the already-imported declarations in the "to"
  217. /// context to the corresponding declarations in the "from" context.
  218. llvm::DenseMap<Decl *, Decl *> ImportedFromDecls;
  219. /// Mapping from the already-imported statements in the "from"
  220. /// context to the corresponding statements in the "to" context.
  221. llvm::DenseMap<Stmt *, Stmt *> ImportedStmts;
  222. /// Mapping from the already-imported FileIDs in the "from" source
  223. /// manager to the corresponding FileIDs in the "to" source manager.
  224. llvm::DenseMap<FileID, FileID> ImportedFileIDs;
  225. /// Mapping from the already-imported CXXBasesSpecifier in
  226. /// the "from" source manager to the corresponding CXXBasesSpecifier
  227. /// in the "to" source manager.
  228. ImportedCXXBaseSpecifierMap ImportedCXXBaseSpecifiers;
  229. /// Declaration (from, to) pairs that are known not to be equivalent
  230. /// (which we have already complained about).
  231. NonEquivalentDeclSet NonEquivalentDecls;
  232. using FoundDeclsTy = SmallVector<NamedDecl *, 2>;
  233. FoundDeclsTy findDeclsInToCtx(DeclContext *DC, DeclarationName Name);
  234. void AddToLookupTable(Decl *ToD);
  235. protected:
  236. /// Can be overwritten by subclasses to implement their own import logic.
  237. /// The overwritten method should call this method if it didn't import the
  238. /// decl on its own.
  239. virtual Expected<Decl *> ImportImpl(Decl *From);
  240. /// Used only in unittests to verify the behaviour of the error handling.
  241. virtual bool returnWithErrorInTest() { return false; };
  242. public:
  243. /// \param ToContext The context we'll be importing into.
  244. ///
  245. /// \param ToFileManager The file manager we'll be importing into.
  246. ///
  247. /// \param FromContext The context we'll be importing from.
  248. ///
  249. /// \param FromFileManager The file manager we'll be importing into.
  250. ///
  251. /// \param MinimalImport If true, the importer will attempt to import
  252. /// as little as it can, e.g., by importing declarations as forward
  253. /// declarations that can be completed at a later point.
  254. ///
  255. /// \param SharedState The importer specific lookup table which may be
  256. /// shared amongst several ASTImporter objects.
  257. /// If not set then the original C/C++ lookup is used.
  258. ASTImporter(ASTContext &ToContext, FileManager &ToFileManager,
  259. ASTContext &FromContext, FileManager &FromFileManager,
  260. bool MinimalImport,
  261. std::shared_ptr<ASTImporterSharedState> SharedState = nullptr);
  262. virtual ~ASTImporter();
  263. /// Whether the importer will perform a minimal import, creating
  264. /// to-be-completed forward declarations when possible.
  265. bool isMinimalImport() const { return Minimal; }
  266. void setODRHandling(ODRHandlingType T) { ODRHandling = T; }
  267. /// \brief Import the given object, returns the result.
  268. ///
  269. /// \param To Import the object into this variable.
  270. /// \param From Object to import.
  271. /// \return Error information (success or error).
  272. template <typename ImportT>
  273. [[nodiscard]] llvm::Error importInto(ImportT &To, const ImportT &From) {
  274. auto ToOrErr = Import(From);
  275. if (ToOrErr)
  276. To = *ToOrErr;
  277. return ToOrErr.takeError();
  278. }
  279. /// Import cleanup objects owned by ExprWithCleanup.
  280. llvm::Expected<ExprWithCleanups::CleanupObject>
  281. Import(ExprWithCleanups::CleanupObject From);
  282. /// Import the given type from the "from" context into the "to"
  283. /// context.
  284. ///
  285. /// \returns The equivalent type in the "to" context, or the import error.
  286. llvm::Expected<const Type *> Import(const Type *FromT);
  287. /// Import the given qualified type from the "from" context into the "to"
  288. /// context. A null type is imported as a null type (no error).
  289. ///
  290. /// \returns The equivalent type in the "to" context, or the import error.
  291. llvm::Expected<QualType> Import(QualType FromT);
  292. /// Import the given type source information from the
  293. /// "from" context into the "to" context.
  294. ///
  295. /// \returns The equivalent type source information in the "to"
  296. /// context, or the import error.
  297. llvm::Expected<TypeSourceInfo *> Import(TypeSourceInfo *FromTSI);
  298. /// Import the given attribute from the "from" context into the
  299. /// "to" context.
  300. ///
  301. /// \returns The equivalent attribute in the "to" context, or the import
  302. /// error.
  303. llvm::Expected<Attr *> Import(const Attr *FromAttr);
  304. /// Import the given declaration from the "from" context into the
  305. /// "to" context.
  306. ///
  307. /// \returns The equivalent declaration in the "to" context, or the import
  308. /// error.
  309. llvm::Expected<Decl *> Import(Decl *FromD);
  310. llvm::Expected<const Decl *> Import(const Decl *FromD) {
  311. return Import(const_cast<Decl *>(FromD));
  312. }
  313. llvm::Expected<InheritedConstructor>
  314. Import(const InheritedConstructor &From);
  315. /// Return the copy of the given declaration in the "to" context if
  316. /// it has already been imported from the "from" context. Otherwise return
  317. /// nullptr.
  318. Decl *GetAlreadyImportedOrNull(const Decl *FromD) const;
  319. /// Return the translation unit from where the declaration was
  320. /// imported. If it does not exist nullptr is returned.
  321. TranslationUnitDecl *GetFromTU(Decl *ToD);
  322. /// Return the declaration in the "from" context from which the declaration
  323. /// in the "to" context was imported. If it was not imported or of the wrong
  324. /// type a null value is returned.
  325. template <typename DeclT>
  326. std::optional<DeclT *> getImportedFromDecl(const DeclT *ToD) const {
  327. auto FromI = ImportedFromDecls.find(ToD);
  328. if (FromI == ImportedFromDecls.end())
  329. return {};
  330. auto *FromD = dyn_cast<DeclT>(FromI->second);
  331. if (!FromD)
  332. return {};
  333. return FromD;
  334. }
  335. /// Import the given declaration context from the "from"
  336. /// AST context into the "to" AST context.
  337. ///
  338. /// \returns the equivalent declaration context in the "to"
  339. /// context, or error value.
  340. llvm::Expected<DeclContext *> ImportContext(DeclContext *FromDC);
  341. /// Import the given expression from the "from" context into the
  342. /// "to" context.
  343. ///
  344. /// \returns The equivalent expression in the "to" context, or the import
  345. /// error.
  346. llvm::Expected<Expr *> Import(Expr *FromE);
  347. /// Import the given statement from the "from" context into the
  348. /// "to" context.
  349. ///
  350. /// \returns The equivalent statement in the "to" context, or the import
  351. /// error.
  352. llvm::Expected<Stmt *> Import(Stmt *FromS);
  353. /// Import the given nested-name-specifier from the "from"
  354. /// context into the "to" context.
  355. ///
  356. /// \returns The equivalent nested-name-specifier in the "to"
  357. /// context, or the import error.
  358. llvm::Expected<NestedNameSpecifier *> Import(NestedNameSpecifier *FromNNS);
  359. /// Import the given nested-name-specifier-loc from the "from"
  360. /// context into the "to" context.
  361. ///
  362. /// \returns The equivalent nested-name-specifier-loc in the "to"
  363. /// context, or the import error.
  364. llvm::Expected<NestedNameSpecifierLoc>
  365. Import(NestedNameSpecifierLoc FromNNS);
  366. /// Import the given template name from the "from" context into the
  367. /// "to" context, or the import error.
  368. llvm::Expected<TemplateName> Import(TemplateName From);
  369. /// Import the given source location from the "from" context into
  370. /// the "to" context.
  371. ///
  372. /// \returns The equivalent source location in the "to" context, or the
  373. /// import error.
  374. llvm::Expected<SourceLocation> Import(SourceLocation FromLoc);
  375. /// Import the given source range from the "from" context into
  376. /// the "to" context.
  377. ///
  378. /// \returns The equivalent source range in the "to" context, or the import
  379. /// error.
  380. llvm::Expected<SourceRange> Import(SourceRange FromRange);
  381. /// Import the given declaration name from the "from"
  382. /// context into the "to" context.
  383. ///
  384. /// \returns The equivalent declaration name in the "to" context, or the
  385. /// import error.
  386. llvm::Expected<DeclarationName> Import(DeclarationName FromName);
  387. /// Import the given identifier from the "from" context
  388. /// into the "to" context.
  389. ///
  390. /// \returns The equivalent identifier in the "to" context. Note: It
  391. /// returns nullptr only if the FromId was nullptr.
  392. IdentifierInfo *Import(const IdentifierInfo *FromId);
  393. /// Import the given Objective-C selector from the "from"
  394. /// context into the "to" context.
  395. ///
  396. /// \returns The equivalent selector in the "to" context, or the import
  397. /// error.
  398. llvm::Expected<Selector> Import(Selector FromSel);
  399. /// Import the given file ID from the "from" context into the
  400. /// "to" context.
  401. ///
  402. /// \returns The equivalent file ID in the source manager of the "to"
  403. /// context, or the import error.
  404. llvm::Expected<FileID> Import(FileID, bool IsBuiltin = false);
  405. /// Import the given C++ constructor initializer from the "from"
  406. /// context into the "to" context.
  407. ///
  408. /// \returns The equivalent initializer in the "to" context, or the import
  409. /// error.
  410. llvm::Expected<CXXCtorInitializer *> Import(CXXCtorInitializer *FromInit);
  411. /// Import the given CXXBaseSpecifier from the "from" context into
  412. /// the "to" context.
  413. ///
  414. /// \returns The equivalent CXXBaseSpecifier in the source manager of the
  415. /// "to" context, or the import error.
  416. llvm::Expected<CXXBaseSpecifier *> Import(const CXXBaseSpecifier *FromSpec);
  417. /// Import the given APValue from the "from" context into
  418. /// the "to" context.
  419. ///
  420. /// \return the equivalent APValue in the "to" context or the import
  421. /// error.
  422. llvm::Expected<APValue> Import(const APValue &FromValue);
  423. /// Import the definition of the given declaration, including all of
  424. /// the declarations it contains.
  425. [[nodiscard]] llvm::Error ImportDefinition(Decl *From);
  426. /// Cope with a name conflict when importing a declaration into the
  427. /// given context.
  428. ///
  429. /// This routine is invoked whenever there is a name conflict while
  430. /// importing a declaration. The returned name will become the name of the
  431. /// imported declaration. By default, the returned name is the same as the
  432. /// original name, leaving the conflict unresolve such that name lookup
  433. /// for this name is likely to find an ambiguity later.
  434. ///
  435. /// Subclasses may override this routine to resolve the conflict, e.g., by
  436. /// renaming the declaration being imported.
  437. ///
  438. /// \param Name the name of the declaration being imported, which conflicts
  439. /// with other declarations.
  440. ///
  441. /// \param DC the declaration context (in the "to" AST context) in which
  442. /// the name is being imported.
  443. ///
  444. /// \param IDNS the identifier namespace in which the name will be found.
  445. ///
  446. /// \param Decls the set of declarations with the same name as the
  447. /// declaration being imported.
  448. ///
  449. /// \param NumDecls the number of conflicting declarations in \p Decls.
  450. ///
  451. /// \returns the name that the newly-imported declaration should have. Or
  452. /// an error if we can't handle the name conflict.
  453. virtual Expected<DeclarationName>
  454. HandleNameConflict(DeclarationName Name, DeclContext *DC, unsigned IDNS,
  455. NamedDecl **Decls, unsigned NumDecls);
  456. /// Retrieve the context that AST nodes are being imported into.
  457. ASTContext &getToContext() const { return ToContext; }
  458. /// Retrieve the context that AST nodes are being imported from.
  459. ASTContext &getFromContext() const { return FromContext; }
  460. /// Retrieve the file manager that AST nodes are being imported into.
  461. FileManager &getToFileManager() const { return ToFileManager; }
  462. /// Retrieve the file manager that AST nodes are being imported from.
  463. FileManager &getFromFileManager() const { return FromFileManager; }
  464. /// Report a diagnostic in the "to" context.
  465. DiagnosticBuilder ToDiag(SourceLocation Loc, unsigned DiagID);
  466. /// Report a diagnostic in the "from" context.
  467. DiagnosticBuilder FromDiag(SourceLocation Loc, unsigned DiagID);
  468. /// Return the set of declarations that we know are not equivalent.
  469. NonEquivalentDeclSet &getNonEquivalentDecls() { return NonEquivalentDecls; }
  470. /// Called for ObjCInterfaceDecl, ObjCProtocolDecl, and TagDecl.
  471. /// Mark the Decl as complete, filling it in as much as possible.
  472. ///
  473. /// \param D A declaration in the "to" context.
  474. virtual void CompleteDecl(Decl* D);
  475. /// Subclasses can override this function to observe all of the \c From ->
  476. /// \c To declaration mappings as they are imported.
  477. virtual void Imported(Decl *From, Decl *To) {}
  478. void RegisterImportedDecl(Decl *FromD, Decl *ToD);
  479. /// Store and assign the imported declaration to its counterpart.
  480. /// It may happen that several decls from the 'from' context are mapped to
  481. /// the same decl in the 'to' context.
  482. Decl *MapImported(Decl *From, Decl *To);
  483. /// Called by StructuralEquivalenceContext. If a RecordDecl is
  484. /// being compared to another RecordDecl as part of import, completing the
  485. /// other RecordDecl may trigger importation of the first RecordDecl. This
  486. /// happens especially for anonymous structs. If the original of the second
  487. /// RecordDecl can be found, we can complete it without the need for
  488. /// importation, eliminating this loop.
  489. virtual Decl *GetOriginalDecl(Decl *To) { return nullptr; }
  490. /// Return if import of the given declaration has failed and if yes
  491. /// the kind of the problem. This gives the first error encountered with
  492. /// the node.
  493. std::optional<ASTImportError> getImportDeclErrorIfAny(Decl *FromD) const;
  494. /// Mark (newly) imported declaration with error.
  495. void setImportDeclError(Decl *From, ASTImportError Error);
  496. /// Determine whether the given types are structurally
  497. /// equivalent.
  498. bool IsStructurallyEquivalent(QualType From, QualType To,
  499. bool Complain = true);
  500. /// Determine the index of a field in its parent record.
  501. /// F should be a field (or indirect field) declaration.
  502. /// \returns The index of the field in its parent context (starting from 0).
  503. /// On error `std::nullopt` is returned (parent context is non-record).
  504. static std::optional<unsigned> getFieldIndex(Decl *F);
  505. };
  506. } // namespace clang
  507. #endif // LLVM_CLANG_AST_ASTIMPORTER_H
  508. #ifdef __GNUC__
  509. #pragma GCC diagnostic pop
  510. #endif