summaryrefslogtreecommitdiffstats
path: root/include/clang/Serialization
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2014-12-05 02:33:27 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2014-12-05 02:33:27 +0000
commitaddfc6605e182cf8ca385653651ce1df777c1d99 (patch)
tree57c76e16eb5e04e0e245002eca47f2787111a95e /include/clang/Serialization
parentb3f723284dd7fd4d3ae9a0dcc99de8cfbc211cc4 (diff)
[modules] Instead of storing absolute paths in a .pcm file, store the path to
the root of the module and use paths relative to that directory wherever possible. This is a step towards allowing explicit modules to be relocated without being rebuilt, which is important for some kinds of distributed builds, for good paths in diagnostics, and for appropriate .d output. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223443 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Serialization')
-rw-r--r--include/clang/Serialization/ASTBitCodes.h5
-rw-r--r--include/clang/Serialization/ASTReader.h14
-rw-r--r--include/clang/Serialization/ASTWriter.h25
-rw-r--r--include/clang/Serialization/Module.h3
4 files changed, 34 insertions, 13 deletions
diff --git a/include/clang/Serialization/ASTBitCodes.h b/include/clang/Serialization/ASTBitCodes.h
index 85495839d3..d8629c2dde 100644
--- a/include/clang/Serialization/ASTBitCodes.h
+++ b/include/clang/Serialization/ASTBitCodes.h
@@ -291,7 +291,10 @@ namespace clang {
MODULE_MAP_FILE = 14,
/// \brief Record code for the signature that identifiers this AST file.
- SIGNATURE = 15
+ SIGNATURE = 15,
+
+ /// \brief Record code for the module build directory.
+ MODULE_DIRECTORY = 16,
};
/// \brief Record types that occur within the input-files block
diff --git a/include/clang/Serialization/ASTReader.h b/include/clang/Serialization/ASTReader.h
index 1b0347e91f..91ad34bd1c 100644
--- a/include/clang/Serialization/ASTReader.h
+++ b/include/clang/Serialization/ASTReader.h
@@ -1113,12 +1113,11 @@ private:
serialization::InputFile getInputFile(ModuleFile &F, unsigned ID,
bool Complain = true);
- /// \brief Get a FileEntry out of stored-in-PCH filename, making sure we take
- /// into account all the necessary relocations.
- const FileEntry *getFileEntry(StringRef filename);
-
- void MaybeAddSystemRootToFilename(ModuleFile &M, std::string &Filename);
+public:
+ void ResolveImportedPath(ModuleFile &M, std::string &Filename);
+ static void ResolveImportedPath(std::string &Filename, StringRef Prefix);
+private:
struct ImportedModule {
ModuleFile *Mod;
ModuleFile *ImportedBy;
@@ -1141,7 +1140,7 @@ private:
const ModuleFile *ImportedBy,
unsigned ClientLoadCapabilities);
ASTReadResult ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities);
- bool ParseLineTable(ModuleFile &F, SmallVectorImpl<uint64_t> &Record);
+ bool ParseLineTable(ModuleFile &F, const RecordData &Record);
bool ReadSourceManagerBlock(ModuleFile &F);
llvm::BitstreamCursor &SLocCursorForID(int ID);
SourceLocation getImportLocation(ModuleFile *F);
@@ -2045,6 +2044,9 @@ public:
// \brief Read a string
static std::string ReadString(const RecordData &Record, unsigned &Idx);
+ // \brief Read a path
+ std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx);
+
/// \brief Read a version tuple.
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx);
diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h
index 20e9935c0c..9907fae676 100644
--- a/include/clang/Serialization/ASTWriter.h
+++ b/include/clang/Serialization/ASTWriter.h
@@ -111,7 +111,10 @@ private:
/// \brief The module we're currently writing, if any.
Module *WritingModule;
-
+
+ /// \brief The base directory for any relative paths we emit.
+ std::string BaseDirectory;
+
/// \brief Indicates when the AST writing is actively performing
/// serialization, rather than just queueing updates.
bool WritingAST;
@@ -457,13 +460,11 @@ private:
StringRef isysroot, const std::string &OutputFile);
void WriteInputFiles(SourceManager &SourceMgr,
HeaderSearchOptions &HSOpts,
- StringRef isysroot,
bool Modules);
void WriteSourceManagerBlock(SourceManager &SourceMgr,
- const Preprocessor &PP,
- StringRef isysroot);
+ const Preprocessor &PP);
void WritePreprocessor(const Preprocessor &PP, bool IsModule);
- void WriteHeaderSearch(const HeaderSearch &HS, StringRef isysroot);
+ void WriteHeaderSearch(const HeaderSearch &HS);
void WritePreprocessorDetail(PreprocessingRecord &PPRec);
void WriteSubmodules(Module *WritingModule);
@@ -539,7 +540,8 @@ public:
/// writing a precompiled header.
///
/// \param isysroot if non-empty, write a relocatable file whose headers
- /// are relative to the given system root.
+ /// are relative to the given system root. If we're writing a module, its
+ /// build directory will be used in preference to this if both are available.
void WriteAST(Sema &SemaRef,
const std::string &OutputFile,
Module *WritingModule, StringRef isysroot,
@@ -686,6 +688,17 @@ public:
/// \brief Add a string to the given record.
void AddString(StringRef Str, RecordDataImpl &Record);
+ /// \brief Convert a path from this build process into one that is appropriate
+ /// for emission in the module file.
+ bool PreparePathForOutput(SmallVectorImpl<char> &Path);
+
+ /// \brief Add a path to the given record.
+ void AddPath(StringRef Path, RecordDataImpl &Record);
+
+ /// \brief Emit the current record with the given path as a blob.
+ void EmitRecordWithPath(unsigned Abbrev, RecordDataImpl &Record,
+ StringRef Path);
+
/// \brief Add a version tuple to the given record
void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record);
diff --git a/include/clang/Serialization/Module.h b/include/clang/Serialization/Module.h
index f6889cfe8e..426cec5dd7 100644
--- a/include/clang/Serialization/Module.h
+++ b/include/clang/Serialization/Module.h
@@ -125,6 +125,9 @@ public:
/// \brief The name of the module.
std::string ModuleName;
+ /// \brief The base directory of the module.
+ std::string BaseDirectory;
+
std::string getTimestampFilename() const {
return FileName + ".timestamp";
}