mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Keep track of source files created for macro expansions and such.
Introduce a new source file kind to describe source files for macro expansions, and include the macro expression that they expand. This establishes a "parent" relationship Also track every kind of auxiliary source file---whether for macro expansions or other reasons---that is introduced into a module, adding an operation that allows us to find the source file that contains a given source location.
This commit is contained in:
@@ -106,7 +106,8 @@ enum class SourceFileKind {
|
||||
Library, ///< A normal .swift file.
|
||||
Main, ///< A .swift file that can have top-level code.
|
||||
SIL, ///< Came from a .sil file.
|
||||
Interface ///< Came from a .swiftinterface file, representing another module.
|
||||
Interface, ///< Came from a .swiftinterface file, representing another module.
|
||||
MacroExpansion, ///< Came from a macro expansion.
|
||||
};
|
||||
|
||||
/// Contains information about where a particular path is used in
|
||||
@@ -158,6 +159,10 @@ enum class ResilienceStrategy : unsigned {
|
||||
|
||||
class OverlayFile;
|
||||
|
||||
/// A mapping used to find the source file that contains a particular source
|
||||
/// location.
|
||||
class ModuleSourceFileLocationMap;
|
||||
|
||||
/// The minimum unit of compilation.
|
||||
///
|
||||
/// A module is made up of several file-units, which are all part of the same
|
||||
@@ -229,6 +234,13 @@ private:
|
||||
|
||||
SmallVector<FileUnit *, 2> Files;
|
||||
|
||||
/// Mapping used to find the source file associated with a given source
|
||||
/// location.
|
||||
ModuleSourceFileLocationMap *sourceFileLocationMap = nullptr;
|
||||
|
||||
/// The set of auxiliary source files build as part of this module.
|
||||
SmallVector<SourceFile *, 2> AuxiliaryFiles;
|
||||
|
||||
llvm::SmallDenseMap<Identifier, SmallVector<OverlayFile *, 1>>
|
||||
declaredCrossImports;
|
||||
|
||||
@@ -328,6 +340,13 @@ public:
|
||||
/// SynthesizedFileUnit instead.
|
||||
void addFile(FileUnit &newFile);
|
||||
|
||||
/// Add an auxiliary source file, introduced as part of the translation.
|
||||
void addAuxiliaryFile(SourceFile &sourceFile);
|
||||
|
||||
/// Produces the source file that contains the given source location, or
|
||||
/// \c nullptr if the source location isn't in this module.
|
||||
SourceFile *getSourceFileContainingLocation(SourceLoc loc);
|
||||
|
||||
/// Creates a map from \c #filePath strings to corresponding \c #fileID
|
||||
/// strings, diagnosing any conflicts.
|
||||
///
|
||||
@@ -414,6 +433,9 @@ private:
|
||||
/// present overlays as if they were part of their underlying module.
|
||||
std::pair<ModuleDecl *, Identifier> getDeclaringModuleAndBystander();
|
||||
|
||||
/// Update the source-file location map to make it current.
|
||||
void updateSourceFileLocationMap();
|
||||
|
||||
public:
|
||||
/// If this is a traditional (non-cross-import) overlay, get its underlying
|
||||
/// module if one exists.
|
||||
|
||||
Reference in New Issue
Block a user