10ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann//===--- MultiplexExternalSemaSource.h - External Sema Interface-*- C++ -*-===//
20ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann//
30ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann//                     The LLVM Compiler Infrastructure
40ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann//
50ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann// This file is distributed under the University of Illinois Open Source
60ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann// License. See LICENSE.TXT for details.
70ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann//
80ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann//===----------------------------------------------------------------------===//
90ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann//
100ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann//  This file defines ExternalSemaSource interface, dispatching to all clients
110ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann//
120ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann//===----------------------------------------------------------------------===//
130ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann#ifndef LLVM_CLANG_SEMA_MULTIPLEX_EXTERNAL_SEMA_SOURCE_H
140ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann#define LLVM_CLANG_SEMA_MULTIPLEX_EXTERNAL_SEMA_SOURCE_H
150ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
160ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann#include "clang/Sema/ExternalSemaSource.h"
170ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann#include "clang/Sema/Weak.h"
180ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann#include "llvm/ADT/SmallVector.h"
190ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann#include <utility>
200ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
210ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumannnamespace clang {
220ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
230ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  class CXXConstructorDecl;
240ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  class CXXRecordDecl;
250ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  class DeclaratorDecl;
260ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  struct ExternalVTableUse;
270ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  class LookupResult;
280ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  class NamespaceDecl;
290ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  class Scope;
300ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  class Sema;
310ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  class TypedefNameDecl;
320ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  class ValueDecl;
330ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  class VarDecl;
340ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
350ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
360ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann/// \brief An abstract interface that should be implemented by
370ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann/// external AST sources that also provide information for semantic
380ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann/// analysis.
390ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumannclass MultiplexExternalSemaSource : public ExternalSemaSource {
400ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
410ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumannprivate:
42cfa88f893915ceb8ae4ce2f17c46c24a4d67502fDmitri Gribenko  SmallVector<ExternalSemaSource *, 2> Sources; // doesn't own them.
430ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
440ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumannpublic:
450ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
460ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///\brief Constructs a new multiplexing external sema source and appends the
470ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// given element to it.
480ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
490ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///\param[in] s1 - A non-null (old) ExternalSemaSource.
500ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///\param[in] s2 - A non-null (new) ExternalSemaSource.
510ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
520ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  MultiplexExternalSemaSource(ExternalSemaSource& s1, ExternalSemaSource& s2);
530ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
540ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ~MultiplexExternalSemaSource();
550ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
560ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///\brief Appends new source to the source list.
570ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
580ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///\param[in] source - An ExternalSemaSource.
590ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
600ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  void addSource(ExternalSemaSource &source);
610ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
620ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  //===--------------------------------------------------------------------===//
630ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  // ExternalASTSource.
640ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  //===--------------------------------------------------------------------===//
650ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
660ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Resolve a declaration ID into a declaration, potentially
670ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// building a new declaration.
68651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  Decl *GetExternalDecl(uint32_t ID) override;
690ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
706bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines  /// \brief Complete the redeclaration chain if it's been extended since the
716bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines  /// previous generation of the AST source.
726bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines  void CompleteRedeclChain(const Decl *D) override;
736bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines
740ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Resolve a selector ID into a selector.
75651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  Selector GetExternalSelector(uint32_t ID) override;
760ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
770ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Returns the number of selectors known to the external AST
780ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// source.
79651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  uint32_t GetNumExternalSelectors() override;
800ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
810ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Resolve the offset of a statement in the decl stream into
820ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// a statement.
83651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  Stmt *GetExternalDeclStmt(uint64_t Offset) override;
840ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
850ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Resolve the offset of a set of C++ base specifiers in the decl
860ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// stream into an array of specifiers.
87651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset) override;
880ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
893646c68676c3c46a026b23d52188ef6e0d856178Richard Smith  /// \brief Find all declarations with the given name in the
900ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// given context.
91651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  bool
92651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override;
930ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
940ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Ensures that the table of all visible declarations inside this
950ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// context is up to date.
96651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void completeVisibleDeclsMap(const DeclContext *DC) override;
970ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
980ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Finds all declarations lexically contained within the given
990ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// DeclContext, after applying an optional filter predicate.
1000ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
1010ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \param isKindWeWant a predicate function that returns true if the passed
1020ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// declaration kind is one we are looking for. If NULL, all declarations
1030ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// are returned.
1040ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
1050ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \return an indication of whether the load succeeded or failed.
106651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC,
107651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                                bool (*isKindWeWant)(Decl::Kind),
108651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                                SmallVectorImpl<Decl*> &Result) override;
1090ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
1100ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Finds all declarations lexically contained within the given
1110ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// DeclContext.
1120ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
1130ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \return true if an error occurred
1140ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC,
1150ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann                                SmallVectorImpl<Decl*> &Result) {
1166bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines    return FindExternalLexicalDecls(DC, nullptr, Result);
1170ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  }
1180ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
1190ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  template <typename DeclTy>
1200ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ExternalLoadResult FindExternalLexicalDeclsBy(const DeclContext *DC,
1210ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann                                  SmallVectorImpl<Decl*> &Result) {
1220ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann    return FindExternalLexicalDecls(DC, DeclTy::classofKind, Result);
1230ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  }
1240ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
1250ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Get the decls that are contained in a file in the Offset/Length
1260ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// range. \p Length can be 0 to indicate a point at \p Offset instead of
1270ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// a range.
128651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void FindFileRegionDecls(FileID File, unsigned Offset,unsigned Length,
129651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                           SmallVectorImpl<Decl *> &Decls) override;
1300ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
1310ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Gives the external AST source an opportunity to complete
1320ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// an incomplete type.
133651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void CompleteType(TagDecl *Tag) override;
1340ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
1350ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Gives the external AST source an opportunity to complete an
1360ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// incomplete Objective-C class.
1370ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
1380ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// This routine will only be invoked if the "externally completed" bit is
1390ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// set on the ObjCInterfaceDecl via the function
1400ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \c ObjCInterfaceDecl::setExternallyCompleted().
141651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void CompleteType(ObjCInterfaceDecl *Class) override;
1420ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
1430ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Loads comment ranges.
144651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ReadComments() override;
1450ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
1460ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Notify ExternalASTSource that we started deserialization of
1470ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// a decl or type so until FinishedDeserializing is called there may be
1480ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// decls that are initializing. Must be paired with FinishedDeserializing.
149651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void StartedDeserializing() override;
1500ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
1510ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Notify ExternalASTSource that we finished the deserialization of
1520ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// a decl or type. Must be paired with StartedDeserializing.
153651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void FinishedDeserializing() override;
1540ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
1550ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Function that will be invoked when we begin parsing a new
1560ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// translation unit involving this external AST source.
157651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void StartTranslationUnit(ASTConsumer *Consumer) override;
1580ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
1590ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Print any statistics that have been gathered regarding
1600ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// the external AST source.
161651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void PrintStats() override;
1620ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
1630ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
1640ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Perform layout on the given record.
1650ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
1660ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// This routine allows the external AST source to provide an specific
1670ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// layout for a record, overriding the layout that would normally be
1680ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// constructed. It is intended for clients who receive specific layout
1690ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// details rather than source code (such as LLDB). The client is expected
1700ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// to fill in the field offsets, base offsets, virtual base offsets, and
1710ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// complete object size.
1720ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
1730ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \param Record The record whose layout is being requested.
1740ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
1750ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \param Size The final size of the record, in bits.
1760ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
1770ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \param Alignment The final alignment of the record, in bits.
1780ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
1790ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \param FieldOffsets The offset of each of the fields within the record,
1800ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// expressed in bits. All of the fields must be provided with offsets.
1810ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
1820ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \param BaseOffsets The offset of each of the direct, non-virtual base
1830ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// classes. If any bases are not given offsets, the bases will be laid
1840ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// out according to the ABI.
1850ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
1860ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \param VirtualBaseOffsets The offset of each of the virtual base classes
1870ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// (either direct or not). If any bases are not given offsets, the bases will
1880ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// be laid out according to the ABI.
1890ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
1900ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \returns true if the record layout was provided, false otherwise.
191651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  bool
1920ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  layoutRecordType(const RecordDecl *Record,
1930ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann                   uint64_t &Size, uint64_t &Alignment,
1940ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann                   llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
1950ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann                 llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
196651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                 llvm::DenseMap<const CXXRecordDecl *,
197651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                                CharUnits> &VirtualBaseOffsets) override;
1980ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
1990ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// Return the amount of memory used by memory buffers, breaking down
2000ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// by heap-backed versus mmap'ed memory.
201651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override;
2020ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
2030ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  //===--------------------------------------------------------------------===//
2040ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  // ExternalSemaSource.
2050ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  //===--------------------------------------------------------------------===//
2060ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
2070ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Initialize the semantic source with the Sema instance
2080ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// being used to perform semantic analysis on the abstract syntax
2090ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// tree.
210651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void InitializeSema(Sema &S) override;
2110ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
2120ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Inform the semantic consumer that Sema is no longer available.
213651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ForgetSema() override;
2140ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
2150ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Load the contents of the global method pool for a given
2160ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// selector.
217651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ReadMethodPool(Selector Sel) override;
2180ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
2190ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Load the set of namespaces that are known to the external source,
2200ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// which will be used during typo correction.
221651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void
222651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  ReadKnownNamespaces(SmallVectorImpl<NamespaceDecl*> &Namespaces) override;
22301a41140cd8ec9475ed0c33384310fbdd3b6de11Nick Lewycky
224cd0655b17249c4c4908ca91462657f62285017e6Nick Lewycky  /// \brief Load the set of used but not defined functions or variables with
225cd0655b17249c4c4908ca91462657f62285017e6Nick Lewycky  /// internal linkage, or used but not defined inline functions.
226651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ReadUndefinedButUsed(
227651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                llvm::DenseMap<NamedDecl*, SourceLocation> &Undefined) override;
228651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines
2290ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Do last resort, unqualified lookup on a LookupResult that
2300ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// Sema cannot find.
2310ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
2320ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \param R a LookupResult that is being recovered.
2330ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
2340ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \param S the Scope of the identifier occurrence.
2350ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
2360ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \return true to tell Sema to recover using the LookupResult.
237651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  bool LookupUnqualified(LookupResult &R, Scope *S) override;
2380ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
2390ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Read the set of tentative definitions known to the external Sema
2400ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// source.
2410ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
2420ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// The external source should append its own tentative definitions to the
2430ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// given vector of tentative definitions. Note that this routine may be
2440ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// invoked multiple times; the external source should take care not to
2450ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// introduce the same declarations repeatedly.
246651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ReadTentativeDefinitions(SmallVectorImpl<VarDecl*> &Defs) override;
247651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines
2480ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Read the set of unused file-scope declarations known to the
2490ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// external Sema source.
2500ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
2510ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// The external source should append its own unused, filed-scope to the
2520ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// given vector of declarations. Note that this routine may be
2530ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// invoked multiple times; the external source should take care not to
2540ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// introduce the same declarations repeatedly.
255651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ReadUnusedFileScopedDecls(
256651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                        SmallVectorImpl<const DeclaratorDecl*> &Decls) override;
257651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines
2580ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Read the set of delegating constructors known to the
2590ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// external Sema source.
2600ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
2610ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// The external source should append its own delegating constructors to the
2620ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// given vector of declarations. Note that this routine may be
2630ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// invoked multiple times; the external source should take care not to
2640ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// introduce the same declarations repeatedly.
265651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ReadDelegatingConstructors(
266651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                          SmallVectorImpl<CXXConstructorDecl*> &Decls) override;
2670ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
2680ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Read the set of ext_vector type declarations known to the
2690ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// external Sema source.
2700ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
2710ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// The external source should append its own ext_vector type declarations to
2720ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// the given vector of declarations. Note that this routine may be
2730ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// invoked multiple times; the external source should take care not to
2740ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// introduce the same declarations repeatedly.
275651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl*> &Decls) override;
2760ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
2770ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Read the set of dynamic classes known to the external Sema source.
2780ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
2790ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// The external source should append its own dynamic classes to
2800ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// the given vector of declarations. Note that this routine may be
2810ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// invoked multiple times; the external source should take care not to
2820ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// introduce the same declarations repeatedly.
283651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl*> &Decls) override;
2840ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
2855ea6ef490547917426d5e2ed14c9f36521bbeacfRichard Smith  /// \brief Read the set of locally-scoped extern "C" declarations known to the
2860ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// external Sema source.
2870ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
2880ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// The external source should append its own locally-scoped external
2895ea6ef490547917426d5e2ed14c9f36521bbeacfRichard Smith  /// declarations to the given vector of declarations. Note that this routine
2905ea6ef490547917426d5e2ed14c9f36521bbeacfRichard Smith  /// may be invoked multiple times; the external source should take care not
2910ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// to introduce the same declarations repeatedly.
292651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ReadLocallyScopedExternCDecls(
293651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                                   SmallVectorImpl<NamedDecl*> &Decls) override;
2940ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
2950ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Read the set of referenced selectors known to the
2960ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// external Sema source.
2970ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
2980ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// The external source should append its own referenced selectors to the
2990ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// given vector of selectors. Note that this routine
3000ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// may be invoked multiple times; the external source should take care not
3010ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// to introduce the same selectors repeatedly.
302651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ReadReferencedSelectors(SmallVectorImpl<std::pair<Selector,
303651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                                              SourceLocation> > &Sels) override;
3040ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
3050ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Read the set of weak, undeclared identifiers known to the
3060ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// external Sema source.
3070ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
3080ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// The external source should append its own weak, undeclared identifiers to
3090ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// the given vector. Note that this routine may be invoked multiple times;
3100ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// the external source should take care not to introduce the same identifiers
3110ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// repeatedly.
312651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ReadWeakUndeclaredIdentifiers(
313651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines           SmallVectorImpl<std::pair<IdentifierInfo*, WeakInfo> > &WI) override;
3140ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
3150ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Read the set of used vtables known to the external Sema source.
3160ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
3170ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// The external source should append its own used vtables to the given
3180ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// vector. Note that this routine may be invoked multiple times; the external
3190ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// source should take care not to introduce the same vtables repeatedly.
320651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) override;
3210ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
3220ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// \brief Read the set of pending instantiations known to the external
3230ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// Sema source.
3240ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  ///
3250ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// The external source should append its own pending instantiations to the
3260ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// given vector. Note that this routine may be invoked multiple times; the
3270ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// external source should take care not to introduce the same instantiations
3280ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  /// repeatedly.
329651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ReadPendingInstantiations(
330651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines     SmallVectorImpl<std::pair<ValueDecl*, SourceLocation> >& Pending) override;
3310ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
332ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith  /// \brief Read the set of late parsed template functions for this source.
333ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith  ///
334ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith  /// The external source should insert its own late parsed template functions
335ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith  /// into the map. Note that this routine may be invoked multiple times; the
336ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith  /// external source should take care not to introduce the same map entries
337ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith  /// repeatedly.
338651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  void ReadLateParsedTemplates(
339651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                         llvm::DenseMap<const FunctionDecl *,
340651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                                        LateParsedTemplate *> &LPTMap) override;
341ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith
34270571f43ab9ae399cd005eaee02f4ca1ecbc3a81Kaelyn Uhrain  /// \copydoc ExternalSemaSource::CorrectTypo
34370571f43ab9ae399cd005eaee02f4ca1ecbc3a81Kaelyn Uhrain  /// \note Returns the first nonempty correction.
344651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo,
345651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                             int LookupKind, Scope *S, CXXScopeSpec *SS,
346651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                             CorrectionCandidateCallback &CCC,
347651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                             DeclContext *MemberContext,
348651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                             bool EnteringContext,
349651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                             const ObjCObjectPointerType *OPT) override;
35070571f43ab9ae399cd005eaee02f4ca1ecbc3a81Kaelyn Uhrain
3515d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain  /// \brief Produces a diagnostic note if one of the attached sources
3525d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain  /// contains a complete definition for \p T. Queries the sources in list
3535d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain  /// order until the first one claims that a diagnostic was produced.
3545d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain  ///
3555d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain  /// \param Loc the location at which a complete type was required but not
3565d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain  /// provided
3575d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain  ///
3585d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain  /// \param T the \c QualType that should have been complete at \p Loc
3595d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain  ///
3605d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain  /// \return true if a diagnostic was produced, false otherwise.
361651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  bool MaybeDiagnoseMissingCompleteType(SourceLocation Loc,
362651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines                                        QualType T) override;
3635d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain
3640ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  // isa/cast/dyn_cast support
3650ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  static bool classof(const MultiplexExternalSemaSource*) { return true; }
3660ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann  //static bool classof(const ExternalSemaSource*) { return true; }
3670ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann};
3680ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
3690ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann} // end namespace clang
3700ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann
3710ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann#endif // LLVM_CLANG_SEMA_MULTIPLEX_EXTERNAL_SEMA_SOURCE_H
372