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//===----------------------------------------------------------------------===// 13176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines#ifndef LLVM_CLANG_SEMA_MULTIPLEXEXTERNALSEMASOURCE_H 14176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines#define LLVM_CLANG_SEMA_MULTIPLEXEXTERNALSEMASOURCE_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 5433337ca4d89605025818daf83390ab4271d598d9Pirama Arumuga Nainar ~MultiplexExternalSemaSource() override; 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 893ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// \brief Resolve a handle to a list of ctor initializers into the list of 903ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar /// initializers themselves. 913ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar CXXCtorInitializer **GetExternalCXXCtorInitializers(uint64_t Offset) override; 923ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar 933646c68676c3c46a026b23d52188ef6e0d856178Richard Smith /// \brief Find all declarations with the given name in the 940ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// given context. 953ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar bool FindExternalVisibleDeclsByName(const DeclContext *DC, 963ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar DeclarationName Name) override; 970ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 980ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Ensures that the table of all visible declarations inside this 990ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// context is up to date. 100651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void completeVisibleDeclsMap(const DeclContext *DC) override; 1010ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 1020ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Finds all declarations lexically contained within the given 1030ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// DeclContext, after applying an optional filter predicate. 1040ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 1050ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \param isKindWeWant a predicate function that returns true if the passed 1060ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// declaration kind is one we are looking for. If NULL, all declarations 1070ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// are returned. 1080ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 1090ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \return an indication of whether the load succeeded or failed. 110651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC, 111651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool (*isKindWeWant)(Decl::Kind), 112651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<Decl*> &Result) override; 1130ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 1140ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Finds all declarations lexically contained within the given 1150ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// DeclContext. 1160ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 1170ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \return true if an error occurred 1180ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC, 1190ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann SmallVectorImpl<Decl*> &Result) { 1206bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines return FindExternalLexicalDecls(DC, nullptr, Result); 1210ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann } 1220ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 1230ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann template <typename DeclTy> 1240ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann ExternalLoadResult FindExternalLexicalDeclsBy(const DeclContext *DC, 1250ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann SmallVectorImpl<Decl*> &Result) { 1260ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann return FindExternalLexicalDecls(DC, DeclTy::classofKind, Result); 1270ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann } 1280ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 1290ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Get the decls that are contained in a file in the Offset/Length 1300ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// range. \p Length can be 0 to indicate a point at \p Offset instead of 1310ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// a range. 132651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void FindFileRegionDecls(FileID File, unsigned Offset,unsigned Length, 133651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<Decl *> &Decls) override; 1340ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 1350ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Gives the external AST source an opportunity to complete 1360ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// an incomplete type. 137651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void CompleteType(TagDecl *Tag) override; 1380ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 1390ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Gives the external AST source an opportunity to complete an 1400ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// incomplete Objective-C class. 1410ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 1420ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// This routine will only be invoked if the "externally completed" bit is 1430ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// set on the ObjCInterfaceDecl via the function 1440ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \c ObjCInterfaceDecl::setExternallyCompleted(). 145651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void CompleteType(ObjCInterfaceDecl *Class) override; 1460ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 1470ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Loads comment ranges. 148651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadComments() override; 1490ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 1500ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Notify ExternalASTSource that we started deserialization of 1510ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// a decl or type so until FinishedDeserializing is called there may be 1520ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// decls that are initializing. Must be paired with FinishedDeserializing. 153651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void StartedDeserializing() override; 1540ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 1550ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Notify ExternalASTSource that we finished the deserialization of 1560ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// a decl or type. Must be paired with StartedDeserializing. 157651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void FinishedDeserializing() override; 1580ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 1590ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Function that will be invoked when we begin parsing a new 1600ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// translation unit involving this external AST source. 161651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void StartTranslationUnit(ASTConsumer *Consumer) override; 1620ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 1630ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Print any statistics that have been gathered regarding 1640ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// the external AST source. 165651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void PrintStats() override; 1660ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 1670ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 1680ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Perform layout on the given record. 1690ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 1700ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// This routine allows the external AST source to provide an specific 1710ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// layout for a record, overriding the layout that would normally be 1720ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// constructed. It is intended for clients who receive specific layout 1730ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// details rather than source code (such as LLDB). The client is expected 1740ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// to fill in the field offsets, base offsets, virtual base offsets, and 1750ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// complete object size. 1760ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 1770ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \param Record The record whose layout is being requested. 1780ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 1790ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \param Size The final size of the record, in bits. 1800ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 1810ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \param Alignment The final alignment of the record, in bits. 1820ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 1830ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \param FieldOffsets The offset of each of the fields within the record, 1840ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// expressed in bits. All of the fields must be provided with offsets. 1850ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 1860ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \param BaseOffsets The offset of each of the direct, non-virtual base 1870ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// classes. If any bases are not given offsets, the bases will be laid 1880ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// out according to the ABI. 1890ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 1900ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \param VirtualBaseOffsets The offset of each of the virtual base classes 1910ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// (either direct or not). If any bases are not given offsets, the bases will 1920ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// be laid out according to the ABI. 1930ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 1940ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \returns true if the record layout was provided, false otherwise. 195651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool 1960ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann layoutRecordType(const RecordDecl *Record, 1970ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann uint64_t &Size, uint64_t &Alignment, 1980ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets, 1990ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets, 200651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines llvm::DenseMap<const CXXRecordDecl *, 201651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines CharUnits> &VirtualBaseOffsets) override; 2020ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 2030ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// Return the amount of memory used by memory buffers, breaking down 2040ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// by heap-backed versus mmap'ed memory. 205651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override; 2060ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 2070ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann //===--------------------------------------------------------------------===// 2080ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann // ExternalSemaSource. 2090ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann //===--------------------------------------------------------------------===// 2100ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 2110ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Initialize the semantic source with the Sema instance 2120ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// being used to perform semantic analysis on the abstract syntax 2130ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// tree. 214651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void InitializeSema(Sema &S) override; 2150ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 2160ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Inform the semantic consumer that Sema is no longer available. 217651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ForgetSema() override; 2180ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 2190ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Load the contents of the global method pool for a given 2200ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// selector. 221651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadMethodPool(Selector Sel) override; 2220ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 2230ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Load the set of namespaces that are known to the external source, 2240ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// which will be used during typo correction. 225651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void 226651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines ReadKnownNamespaces(SmallVectorImpl<NamespaceDecl*> &Namespaces) override; 22701a41140cd8ec9475ed0c33384310fbdd3b6de11Nick Lewycky 228cd0655b17249c4c4908ca91462657f62285017e6Nick Lewycky /// \brief Load the set of used but not defined functions or variables with 229cd0655b17249c4c4908ca91462657f62285017e6Nick Lewycky /// internal linkage, or used but not defined inline functions. 230651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadUndefinedButUsed( 231651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines llvm::DenseMap<NamedDecl*, SourceLocation> &Undefined) override; 232651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 2330ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Do last resort, unqualified lookup on a LookupResult that 2340ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// Sema cannot find. 2350ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 2360ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \param R a LookupResult that is being recovered. 2370ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 2380ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \param S the Scope of the identifier occurrence. 2390ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 2400ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \return true to tell Sema to recover using the LookupResult. 241651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool LookupUnqualified(LookupResult &R, Scope *S) override; 2420ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 2430ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Read the set of tentative definitions known to the external Sema 2440ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// source. 2450ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 2460ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// The external source should append its own tentative definitions to the 2470ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// given vector of tentative definitions. Note that this routine may be 2480ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// invoked multiple times; the external source should take care not to 2490ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// introduce the same declarations repeatedly. 250651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadTentativeDefinitions(SmallVectorImpl<VarDecl*> &Defs) override; 251651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 2520ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Read the set of unused file-scope declarations known to the 2530ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// external Sema source. 2540ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 2550ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// The external source should append its own unused, filed-scope to the 2560ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// given vector of declarations. Note that this routine may be 2570ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// invoked multiple times; the external source should take care not to 2580ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// introduce the same declarations repeatedly. 259651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadUnusedFileScopedDecls( 260651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<const DeclaratorDecl*> &Decls) override; 261651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 2620ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Read the set of delegating constructors known to the 2630ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// external Sema source. 2640ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 2650ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// The external source should append its own delegating constructors to the 2660ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// given vector of declarations. Note that this routine may be 2670ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// invoked multiple times; the external source should take care not to 2680ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// introduce the same declarations repeatedly. 269651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadDelegatingConstructors( 270651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<CXXConstructorDecl*> &Decls) override; 2710ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 2720ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Read the set of ext_vector type declarations known to the 2730ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// external Sema source. 2740ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 2750ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// The external source should append its own ext_vector type declarations to 2760ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// the given vector of declarations. Note that this routine may be 2770ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// invoked multiple times; the external source should take care not to 2780ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// introduce the same declarations repeatedly. 279651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl*> &Decls) override; 2800ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 281176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// \brief Read the set of potentially unused typedefs known to the source. 282176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// 283176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// The external source should append its own potentially unused local 284176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// typedefs to the given vector of declarations. Note that this routine may 285176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// be invoked multiple times; the external source should take care not to 286176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines /// introduce the same declarations repeatedly. 287176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines void ReadUnusedLocalTypedefNameCandidates( 288176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) override; 289176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines 2900ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Read the set of referenced selectors known to the 2910ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// external Sema source. 2920ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 2930ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// The external source should append its own referenced selectors to the 2940ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// given vector of selectors. Note that this routine 2950ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// may be invoked multiple times; the external source should take care not 2960ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// to introduce the same selectors repeatedly. 297651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadReferencedSelectors(SmallVectorImpl<std::pair<Selector, 298651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SourceLocation> > &Sels) override; 2990ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 3000ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Read the set of weak, undeclared identifiers known to the 3010ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// external Sema source. 3020ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 3030ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// The external source should append its own weak, undeclared identifiers to 3040ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// the given vector. Note that this routine may be invoked multiple times; 3050ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// the external source should take care not to introduce the same identifiers 3060ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// repeatedly. 307651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadWeakUndeclaredIdentifiers( 308651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<std::pair<IdentifierInfo*, WeakInfo> > &WI) override; 3090ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 3100ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Read the set of used vtables known to the external Sema source. 3110ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 3120ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// The external source should append its own used vtables to the given 3130ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// vector. Note that this routine may be invoked multiple times; the external 3140ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// source should take care not to introduce the same vtables repeatedly. 315651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) override; 3160ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 3170ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// \brief Read the set of pending instantiations known to the external 3180ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// Sema source. 3190ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// 3200ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// The external source should append its own pending instantiations to the 3210ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// given vector. Note that this routine may be invoked multiple times; the 3220ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// external source should take care not to introduce the same instantiations 3230ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann /// repeatedly. 324651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadPendingInstantiations( 325651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<std::pair<ValueDecl*, SourceLocation> >& Pending) override; 3260ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 327ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith /// \brief Read the set of late parsed template functions for this source. 328ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith /// 329ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith /// The external source should insert its own late parsed template functions 330ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith /// into the map. Note that this routine may be invoked multiple times; the 331ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith /// external source should take care not to introduce the same map entries 332ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith /// repeatedly. 333651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void ReadLateParsedTemplates( 3343ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar llvm::MapVector<const FunctionDecl *, LateParsedTemplate *> &LPTMap) 3353ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar override; 336ac32d9044b9c1e7492cef929a322d23ce899d276Richard Smith 33770571f43ab9ae399cd005eaee02f4ca1ecbc3a81Kaelyn Uhrain /// \copydoc ExternalSemaSource::CorrectTypo 33870571f43ab9ae399cd005eaee02f4ca1ecbc3a81Kaelyn Uhrain /// \note Returns the first nonempty correction. 339651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, 340651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines int LookupKind, Scope *S, CXXScopeSpec *SS, 341651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines CorrectionCandidateCallback &CCC, 342651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines DeclContext *MemberContext, 343651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool EnteringContext, 344651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines const ObjCObjectPointerType *OPT) override; 34570571f43ab9ae399cd005eaee02f4ca1ecbc3a81Kaelyn Uhrain 3465d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain /// \brief Produces a diagnostic note if one of the attached sources 3475d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain /// contains a complete definition for \p T. Queries the sources in list 3485d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain /// order until the first one claims that a diagnostic was produced. 3495d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain /// 3505d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain /// \param Loc the location at which a complete type was required but not 3515d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain /// provided 3525d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain /// 3535d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain /// \param T the \c QualType that should have been complete at \p Loc 3545d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain /// 3555d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain /// \return true if a diagnostic was produced, false otherwise. 356651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool MaybeDiagnoseMissingCompleteType(SourceLocation Loc, 357651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines QualType T) override; 3585d937b3fe7832f8ffa0a258d1b037c64708e97c1Kaelyn Uhrain 3590ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann // isa/cast/dyn_cast support 3600ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann static bool classof(const MultiplexExternalSemaSource*) { return true; } 3610ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann //static bool classof(const ExternalSemaSource*) { return true; } 3620ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann}; 3630ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 3640ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann} // end namespace clang 3650ec56b7add7be643f490ea9b430823570f01b4e2Axel Naumann 366176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines#endif 367