summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2018-08-01 10:45:08 +0200
committerIvan Donchevskii <ivan.donchevskii@qt.io>2018-08-01 12:39:03 +0000
commitf8db5041bcff568499b3740c5272960e7f20e023 (patch)
tree6de24ad043542abe6abb40e6df997f5096153ff0 /include
parentc959fde3859389bf20235ce515f4cff548034f8a (diff)
Index whild build. Part 1
https://reviews.llvm.org/D39050 adapted for 6.0 Change-Id: I2cb9c7d94c95fde7c3eb3042a6de0e55ab186974 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'include')
-rw-r--r--include/clang/Basic/AllDiagnostics.h1
-rw-r--r--include/clang/Basic/CMakeLists.txt1
-rw-r--r--include/clang/Basic/Diagnostic.td1
-rw-r--r--include/clang/Basic/DiagnosticGroups.td1
-rw-r--r--include/clang/Basic/DiagnosticIDs.h4
-rw-r--r--include/clang/Basic/DiagnosticIndexKinds.td31
-rw-r--r--include/clang/Driver/Job.h6
-rw-r--r--include/clang/Driver/Options.td7
-rw-r--r--include/clang/Frontend/CompilerInstance.h18
-rw-r--r--include/clang/Frontend/FrontendOptions.h10
-rw-r--r--include/clang/Index/DeclOccurrence.h42
-rw-r--r--include/clang/Index/IndexDataConsumer.h5
-rw-r--r--include/clang/Index/IndexDiagnostic.h29
-rw-r--r--include/clang/Index/IndexingAction.h10
-rw-r--r--include/clang/Index/RecordingAction.h59
-rw-r--r--include/clang/Index/UnitIndexDataConsumer.h74
-rw-r--r--include/clang/Index/UnitIndexingAction.h87
-rw-r--r--include/clang/module.modulemap1
18 files changed, 377 insertions, 10 deletions
diff --git a/include/clang/Basic/AllDiagnostics.h b/include/clang/Basic/AllDiagnostics.h
index 1c83e2d0f8..5c61996024 100644
--- a/include/clang/Basic/AllDiagnostics.h
+++ b/include/clang/Basic/AllDiagnostics.h
@@ -21,6 +21,7 @@
#include "clang/CrossTU/CrossTUDiagnostic.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Index/IndexDiagnostic.h"
#include "clang/Lex/LexDiagnostic.h"
#include "clang/Parse/ParseDiagnostic.h"
#include "clang/Sema/SemaDiagnostic.h"
diff --git a/include/clang/Basic/CMakeLists.txt b/include/clang/Basic/CMakeLists.txt
index 821c405913..b2dd03630e 100644
--- a/include/clang/Basic/CMakeLists.txt
+++ b/include/clang/Basic/CMakeLists.txt
@@ -12,6 +12,7 @@ clang_diag_gen(Common)
clang_diag_gen(CrossTU)
clang_diag_gen(Driver)
clang_diag_gen(Frontend)
+clang_diag_gen(Index)
clang_diag_gen(Lex)
clang_diag_gen(Parse)
clang_diag_gen(Refactoring)
diff --git a/include/clang/Basic/Diagnostic.td b/include/clang/Basic/Diagnostic.td
index 52ccf350e6..3cc357c434 100644
--- a/include/clang/Basic/Diagnostic.td
+++ b/include/clang/Basic/Diagnostic.td
@@ -136,6 +136,7 @@ include "DiagnosticCommonKinds.td"
include "DiagnosticCrossTUKinds.td"
include "DiagnosticDriverKinds.td"
include "DiagnosticFrontendKinds.td"
+include "DiagnosticIndexKinds.td"
include "DiagnosticLexKinds.td"
include "DiagnosticParseKinds.td"
include "DiagnosticRefactoringKinds.td"
diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td
index 2d471f1fa5..40b5aef08c 100644
--- a/include/clang/Basic/DiagnosticGroups.td
+++ b/include/clang/Basic/DiagnosticGroups.td
@@ -327,6 +327,7 @@ def MissingFieldInitializers : DiagGroup<"missing-field-initializers">;
def ModuleBuild : DiagGroup<"module-build">;
def ModuleConflict : DiagGroup<"module-conflict">;
def ModuleFileExtension : DiagGroup<"module-file-extension">;
+def IndexStore : DiagGroup<"index-store">;
def NewlineEOF : DiagGroup<"newline-eof">;
def Nullability : DiagGroup<"nullability">;
def NullabilityDeclSpec : DiagGroup<"nullability-declspec">;
diff --git a/include/clang/Basic/DiagnosticIDs.h b/include/clang/Basic/DiagnosticIDs.h
index b4ea85ba85..92792097c8 100644
--- a/include/clang/Basic/DiagnosticIDs.h
+++ b/include/clang/Basic/DiagnosticIDs.h
@@ -40,6 +40,7 @@ namespace clang {
DIAG_SIZE_SEMA = 3500,
DIAG_SIZE_ANALYSIS = 100,
DIAG_SIZE_REFACTORING = 1000,
+ DIAG_SIZE_INDEX = 100,
};
// Start position for diagnostics.
enum {
@@ -55,7 +56,8 @@ namespace clang {
DIAG_START_SEMA = DIAG_START_CROSSTU + DIAG_SIZE_COMMENT,
DIAG_START_ANALYSIS = DIAG_START_SEMA + DIAG_SIZE_SEMA,
DIAG_START_REFACTORING = DIAG_START_ANALYSIS + DIAG_SIZE_ANALYSIS,
- DIAG_UPPER_LIMIT = DIAG_START_REFACTORING + DIAG_SIZE_REFACTORING
+ DIAG_START_INDEX = DIAG_START_REFACTORING + DIAG_SIZE_REFACTORING,
+ DIAG_UPPER_LIMIT = DIAG_START_INDEX + DIAG_SIZE_INDEX,
};
class CustomDiagInfo;
diff --git a/include/clang/Basic/DiagnosticIndexKinds.td b/include/clang/Basic/DiagnosticIndexKinds.td
new file mode 100644
index 0000000000..0f0525847a
--- /dev/null
+++ b/include/clang/Basic/DiagnosticIndexKinds.td
@@ -0,0 +1,31 @@
+//==--- DiagnosticIndexKinds.td - indexing diagnostics --------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+//===----------------------------------------------------------------------===//
+// Indexing Diagnostics
+//===----------------------------------------------------------------------===//
+
+let Component = "Index" in {
+
+let CategoryName = "Index Store Issue" in {
+
+def err_index_store_dir_create_failed : Error<"failed creating the index store "
+ "directory: %0">;
+def err_index_store_file_status_failed : Error<"failed file status check: %0">;
+def err_index_store_record_write_failed : Error<"failed writing record '%0': "
+ "%1">;
+def err_index_store_unit_write_failed : Error<"failed writing unit data: %0">;
+
+def remark_index_producing_module_file_data : Remark<"producing index data for "
+ "module file '%0'">,
+ InGroup<IndexStore>;
+
+}
+
+} // end of Indexing diagnostics
diff --git a/include/clang/Driver/Job.h b/include/clang/Driver/Job.h
index b74b3b4b35..b45ae92f26 100644
--- a/include/clang/Driver/Job.h
+++ b/include/clang/Driver/Job.h
@@ -34,9 +34,11 @@ using llvm::opt::ArgStringList;
struct CrashReportInfo {
StringRef Filename;
StringRef VFSPath;
+ StringRef IndexStorePath;
- CrashReportInfo(StringRef Filename, StringRef VFSPath)
- : Filename(Filename), VFSPath(VFSPath) {}
+ CrashReportInfo(StringRef Filename, StringRef VFSPath,
+ StringRef IndexStorePath)
+ : Filename(Filename), VFSPath(VFSPath), IndexStorePath(IndexStorePath) {}
};
/// Command - An executable path/name and argument vector to
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td
index 288bd482bb..504bb0ddf7 100644
--- a/include/clang/Driver/Options.td
+++ b/include/clang/Driver/Options.td
@@ -324,6 +324,13 @@ def objcmt_whitelist_dir_path: Joined<["-"], "objcmt-whitelist-dir-path=">, Flag
def : Joined<["-"], "objcmt-white-list-dir-path=">, Flags<[CC1Option]>,
Alias<objcmt_whitelist_dir_path>;
+def index_store_path : Separate<["-"], "index-store-path">, Flags<[CC1Option]>,
+ HelpText<"Enable indexing with the specified data store path">;
+def index_ignore_system_symbols : Flag<["-"], "index-ignore-system-symbols">, Flags<[CC1Option]>,
+ HelpText<"Ignore symbols from system headers">;
+def index_record_codegen_name : Flag<["-"], "index-record-codegen-name">, Flags<[CC1Option]>,
+ HelpText<"Record the codegen name for symbols">;
+
// Make sure all other -ccc- options are rejected.
def ccc_ : Joined<["-"], "ccc-">, Group<internal_Group>, Flags<[Unsupported]>;
diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h
index 90a9501475..148c639e03 100644
--- a/include/clang/Frontend/CompilerInstance.h
+++ b/include/clang/Frontend/CompilerInstance.h
@@ -183,6 +183,14 @@ class CompilerInstance : public ModuleLoader {
/// The list of active output files.
std::list<OutputFile> OutputFiles;
+ typedef std::function<std::unique_ptr<FrontendAction>(
+ const FrontendOptions &Opts, std::unique_ptr<FrontendAction> Action)>
+ ActionWrapperTy;
+
+ /// \brief An optional callback function used to wrap any
+ /// GenerateModuleActions created and executed when loading modules.
+ ActionWrapperTy GenModuleActionWrapper;
+
CompilerInstance(const CompilerInstance &) = delete;
void operator=(const CompilerInstance &) = delete;
public:
@@ -447,7 +455,7 @@ public:
return *PP;
}
- std::shared_ptr<Preprocessor> getPreprocessorPtr() { return PP; }
+ std::shared_ptr<Preprocessor> getPreprocessorPtr() const { return PP; }
void resetAndLeakPreprocessor() {
BuryPointer(new std::shared_ptr<Preprocessor>(PP));
@@ -796,6 +804,14 @@ public:
bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override;
+ void setGenModuleActionWrapper(ActionWrapperTy Wrapper) {
+ GenModuleActionWrapper = Wrapper;
+ };
+
+ ActionWrapperTy getGenModuleActionWrapper() const {
+ return GenModuleActionWrapper;
+ }
+
void addDependencyCollector(std::shared_ptr<DependencyCollector> Listener) {
DependencyCollectors.push_back(std::move(Listener));
}
diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h
index 5192a3774c..72fa3b6eac 100644
--- a/include/clang/Frontend/FrontendOptions.h
+++ b/include/clang/Frontend/FrontendOptions.h
@@ -259,6 +259,13 @@ public:
std::string MTMigrateDir;
std::string ARCMTMigrateReportOut;
+ /// The path to write index data to
+ std::string IndexStorePath;
+ /// Whether to ignore system files when writing out index data
+ unsigned IndexIgnoreSystemSymbols : 1;
+ /// Whether to include the codegen name of symbols in the index data
+ unsigned IndexRecordCodegenName : 1;
+
/// The input files and their types.
std::vector<FrontendInputFile> Inputs;
@@ -337,7 +344,8 @@ public:
GenerateGlobalModuleIndex(true), ASTDumpDecls(false), ASTDumpLookups(false),
BuildingImplicitModule(false), ModulesEmbedAllFiles(false),
IncludeTimestamps(true), ARCMTAction(ARCMT_None),
- ObjCMTAction(ObjCMT_None), ProgramAction(frontend::ParseSyntaxOnly)
+ ObjCMTAction(ObjCMT_None), ProgramAction(frontend::ParseSyntaxOnly),
+ IndexIgnoreSystemSymbols(false), IndexRecordCodegenName(false)
{}
/// getInputKindForExtension - Return the appropriate input kind for a file
diff --git a/include/clang/Index/DeclOccurrence.h b/include/clang/Index/DeclOccurrence.h
new file mode 100644
index 0000000000..44d7f85620
--- /dev/null
+++ b/include/clang/Index/DeclOccurrence.h
@@ -0,0 +1,42 @@
+//===--- DeclOccurrence.h - An occurrence of a decl within a file ---------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_INDEX_DECLOCCURRENCE_H
+#define LLVM_CLANG_INDEX_DECLOCCURRENCE_H
+
+#include "clang/Basic/LLVM.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang {
+class Decl;
+
+namespace index {
+
+struct DeclOccurrence {
+ SymbolRoleSet Roles;
+ unsigned Offset;
+ const Decl *Dcl;
+ SmallVector<SymbolRelation, 3> Relations;
+
+ DeclOccurrence(SymbolRoleSet R, unsigned Offset, const Decl *D,
+ ArrayRef<SymbolRelation> Relations)
+ : Roles(R), Offset(Offset), Dcl(D),
+ Relations(Relations.begin(), Relations.end()) {}
+
+ friend bool operator<(const DeclOccurrence &LHS, const DeclOccurrence &RHS) {
+ return LHS.Offset < RHS.Offset;
+ }
+};
+
+} // namespace index
+} // namespace clang
+
+#endif
diff --git a/include/clang/Index/IndexDataConsumer.h b/include/clang/Index/IndexDataConsumer.h
index 080f4cb4d0..7cfaa15132 100644
--- a/include/clang/Index/IndexDataConsumer.h
+++ b/include/clang/Index/IndexDataConsumer.h
@@ -43,17 +43,18 @@ public:
virtual bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles,
ArrayRef<SymbolRelation> Relations,
FileID FID, unsigned Offset,
+ bool IsInSystemFile,
ASTNodeInfo ASTNode);
/// \returns true to continue indexing, or false to abort.
virtual bool handleMacroOccurence(const IdentifierInfo *Name,
const MacroInfo *MI, SymbolRoleSet Roles,
- FileID FID, unsigned Offset);
+ FileID FID, unsigned Offset, bool IsInSystemFile);
/// \returns true to continue indexing, or false to abort.
virtual bool handleModuleOccurence(const ImportDecl *ImportD,
SymbolRoleSet Roles,
- FileID FID, unsigned Offset);
+ FileID FID, unsigned Offset, bool IsInSystemFile);
virtual void finish() {}
diff --git a/include/clang/Index/IndexDiagnostic.h b/include/clang/Index/IndexDiagnostic.h
new file mode 100644
index 0000000000..b2903b9df7
--- /dev/null
+++ b/include/clang/Index/IndexDiagnostic.h
@@ -0,0 +1,29 @@
+//===--- IndexDiagnostic.h - ------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_INDEX_INDEXDIAGNOSTIC_H
+#define LLVM_CLANG_INDEX_INDEXDIAGNOSTIC_H
+
+#include "clang/Basic/Diagnostic.h"
+
+namespace clang {
+namespace diag {
+enum {
+#define DIAG(ENUM, FLAGS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR, \
+ SHOWINSYSHEADER, CATEGORY) \
+ ENUM,
+#define INDEXSTART
+#include "clang/Basic/DiagnosticIndexKinds.inc"
+#undef DIAG
+ NUM_BUILTIN_INDEX_DIAGNOSTICS
+};
+} // end namespace diag
+} // end namespace clang
+
+#endif // LLVM_CLANG_INDEX_INDEXDIAGNOSTIC_H
diff --git a/include/clang/Index/IndexingAction.h b/include/clang/Index/IndexingAction.h
index fb703be4e5..5b0585695a 100644
--- a/include/clang/Index/IndexingAction.h
+++ b/include/clang/Index/IndexingAction.h
@@ -1,4 +1,4 @@
-//===--- IndexingAction.h - Frontend index action -------------------------===//
+//===--- IndexingAction.h - Frontend AST indexing action ------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -13,6 +13,7 @@
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/ArrayRef.h"
#include <memory>
+#include <string>
namespace clang {
class ASTContext;
@@ -35,11 +36,14 @@ struct IndexingOptions {
All,
};
- SystemSymbolFilterKind SystemSymbolFilter
- = SystemSymbolFilterKind::DeclarationsOnly;
+ SystemSymbolFilterKind SystemSymbolFilter =
+ SystemSymbolFilterKind::DeclarationsOnly;
bool IndexFunctionLocals = false;
};
+/// Creates a frontend action that provides decl occurrence information from the
+/// AST to the given \c IndexDataConsumer.
+///
/// \param WrappedAction another frontend action to wrap over or null.
std::unique_ptr<FrontendAction>
createIndexingAction(std::shared_ptr<IndexDataConsumer> DataConsumer,
diff --git a/include/clang/Index/RecordingAction.h b/include/clang/Index/RecordingAction.h
new file mode 100644
index 0000000000..15e987574c
--- /dev/null
+++ b/include/clang/Index/RecordingAction.h
@@ -0,0 +1,59 @@
+//===--- RecordingAction.h - Frontend index recording action --------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_INDEX_INDEXRECORDINGACTION_H
+#define LLVM_CLANG_INDEX_INDEXRECORDINGACTION_H
+
+#include "clang/Basic/LLVM.h"
+#include "clang/Index/UnitIndexingAction.h"
+#include "llvm/ADT/ArrayRef.h"
+
+namespace clang {
+class CompilerInstance;
+class FrontendAction;
+class FrontendOptions;
+
+namespace serialization {
+class ModuleFile;
+}
+
+namespace index {
+
+struct RecordingOptions : UnitIndexingOptions {
+ std::string DataDirPath;
+ bool RecordSymbolCodeGenName = false;
+};
+
+RecordingOptions
+getRecordingOptionsFromFrontendOptions(const FrontendOptions &FEOpts);
+
+/// \brief Creates a frontend action that collects dependency, file inclusion
+/// and decl ocurrence information for the translation unit and persists it to
+/// an index store.
+///
+/// FIXME: Not implemented yet.
+///
+/// \param WrappedAction another frontend action to wrap over or null.
+std::unique_ptr<FrontendAction>
+createIndexDataRecordingAction(RecordingOptions RecordOpts,
+ std::unique_ptr<FrontendAction> WrappedAction);
+
+/// Collects dependency, file inclusion and decl occurrence information for a
+/// \c ModuleFile and persists it to an index store. Does \b not check if
+/// the store already has up-to-date information for the provided module file.
+///
+/// FIXME: Not implemented yet.
+void recordIndexDataForModuleFile(serialization::ModuleFile *ModFile,
+ RecordingOptions RecordOpts,
+ const CompilerInstance &CI);
+
+} // namespace index
+} // namespace clang
+
+#endif
diff --git a/include/clang/Index/UnitIndexDataConsumer.h b/include/clang/Index/UnitIndexDataConsumer.h
new file mode 100644
index 0000000000..9ee0d82b9a
--- /dev/null
+++ b/include/clang/Index/UnitIndexDataConsumer.h
@@ -0,0 +1,74 @@
+//===--- UnitIndexDataConsumer.h - Abstract unit index data consumer ------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_INDEX_UNITINDEXDATACONSUMER_H
+#define LLVM_CLANG_INDEX_UNITINDEXDATACONSUMER_H
+
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Index/DeclOccurrence.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/ArrayRef.h"
+
+namespace clang {
+namespace serialization {
+class ModuleFile;
+}
+
+namespace index {
+
+/// Consumer for the index data associated with a translation unit.
+class UnitIndexDataConsumer {
+public:
+ virtual ~UnitIndexDataConsumer() = default;
+
+ /// Called for each file dependency of the translation unit.
+ virtual void handleFileDependency(const FileEntry *FE, bool IsSystem) {}
+
+ /// Called for each file include in the translation unit.
+ virtual void handleInclude(const FileEntry *Source, unsigned Line,
+ const FileEntry *Target) {}
+
+ /// Called for each each module imported by the translation unit.
+ virtual void handleModuleImport(const serialization::ModuleFile &Mod,
+ bool IsSystem) {}
+
+ /// Determines whether to collect the index data associated with the given
+ /// dependency of this translation unit or not.
+ ///
+ /// \param OutFilePath the output file path of the dependency.
+ /// \returns true to collect index data for \c Mod.
+ virtual bool
+ shouldIndexModuleDependency(const serialization::ModuleFile &Mod) {
+ return false;
+ }
+
+ /// Called with the decl occurrences in each file and AST file dependency,
+ /// sorted by offset.
+ ///
+ /// \returns true to cancel consuming data for this translation unit. Finish
+ /// will not be called.
+ virtual bool
+ handleFileOccurrences(FileID FID,
+ ArrayRef<DeclOccurrence> OccurrencesSortedByOffset,
+ bool IsSystem) {
+ return false;
+ }
+
+ /// Called when there is no more data to handle.
+ virtual void finish() {}
+
+private:
+ // avoid duplicate vtables
+ virtual void _anchor();
+};
+
+} // namespace index
+} // namespace clang
+
+#endif
diff --git a/include/clang/Index/UnitIndexingAction.h b/include/clang/Index/UnitIndexingAction.h
new file mode 100644
index 0000000000..f661093941
--- /dev/null
+++ b/include/clang/Index/UnitIndexingAction.h
@@ -0,0 +1,87 @@
+//===--- UnitIndexingAction.h - Frontend unit indexing action -------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_INDEX_UNITINDEXINGACTION_H
+#define LLVM_CLANG_INDEX_UNITINDEXINGACTION_H
+
+#include "clang/Basic/LLVM.h"
+#include "clang/Index/IndexingAction.h"
+#include "llvm/ADT/ArrayRef.h"
+
+namespace clang {
+class CompilerInstance;
+class FileEntry;
+class FrontendAction;
+class Module;
+
+namespace serialization {
+class ModuleFile;
+}
+
+namespace index {
+class UnitIndexDataConsumer;
+
+struct UnitIndexingOptions : IndexingOptions {
+ enum class FileIncludeFilterKind {
+ None,
+ UserOnly, // only record includes inside non-system files.
+ All,
+ };
+
+ bool IncludeSystemDependencies = true;
+ FileIncludeFilterKind FileIncludeFilter = FileIncludeFilterKind::UserOnly;
+};
+
+/// \brief Information about a translation unit useful for indexing.
+///
+struct UnitDetails {
+ const CompilerInstance &CI; ///< The owning compiler instance.
+
+ Module *UnitModule; ///< The corresponding \c Module (module units only).
+ std::string ModuleName; ///< The \c Module name (module units only).
+ const FileEntry *RootFile; ///< The root \c FileEntry (non-module units only).
+
+ std::string OutputFile; ///< The output file path.
+ StringRef SysrootPath; ///< The "virtual system root" path.
+ bool IsSystemUnit;
+ bool IsModuleUnit;
+ bool IsDebugCompilation;
+};
+
+/// Factory function type for producing UnitIndexDataConsumers for a given
+/// translation unit
+typedef std::function<std::unique_ptr<UnitIndexDataConsumer>(
+ UnitDetails UnitInfo)>
+ IndexUnitDataConsumerFactory;
+
+/// \brief Creates a frontend action that provides dependency, file inclusion
+/// and decl ocurrence information for the translation unit, and optionally its
+/// module dependencies.
+///
+/// Decl occurrence information is provided per-file, sorted by offset.
+///
+/// \param ConsumerFactory provides an \c IndexUnitDataConsumer to use for a
+/// translation unit.
+/// \param WrappedAction another frontend action to wrap over or null.
+std::unique_ptr<FrontendAction>
+createUnitIndexingAction(IndexUnitDataConsumerFactory ConsumerFactory,
+ UnitIndexingOptions UnitIndexOpts,
+ std::unique_ptr<FrontendAction> WrappedAction);
+
+/// Collects and provides dependency, file inclusion and decl occurrence
+/// information for a \c ModuleFile to an \c IndexUnitDataConsumer constructed
+/// from the provided \c IndexUnitDataConsumerFactory.
+void indexModuleFile(serialization::ModuleFile &Mod, const CompilerInstance &CI,
+ IndexUnitDataConsumerFactory UnitConsumerFactory,
+ UnitIndexingOptions Opts);
+
+} // namespace index
+} // namespace clang
+
+#endif
diff --git a/include/clang/module.modulemap b/include/clang/module.modulemap
index 4097ad2dc7..1625f284df 100644
--- a/include/clang/module.modulemap
+++ b/include/clang/module.modulemap
@@ -68,6 +68,7 @@ module Clang_Diagnostics {
module Comment { header "AST/CommentDiagnostic.h" export * }
module Driver { header "Driver/DriverDiagnostic.h" export * }
module Frontend { header "Frontend/FrontendDiagnostic.h" export * }
+ module Index { header "Index/IndexDiagnostic.h" export * }
module Lex { header "Lex/LexDiagnostic.h" export * }
module Parse { header "Parse/ParseDiagnostic.h" export * }
module Sema { header "Sema/SemaDiagnostic.h" export * }