summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-03-05 01:03:53 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-03-05 01:03:53 +0000
commit11e6f0a6c30e4352f8146f9d7e3c9439c67f3f3d (patch)
treeb715b9189c297184a94e31b3663fc97944ec39d1 /clang/lib/Serialization/ASTWriter.cpp
parent4954bc1d9d68bfbe6d39cf2c6d7a5d9944e31a73 (diff)
downloadbcm5719-llvm-11e6f0a6c30e4352f8146f9d7e3c9439c67f3f3d.tar.gz
bcm5719-llvm-11e6f0a6c30e4352f8146f9d7e3c9439c67f3f3d.zip
Currently we can only remap a file by creating a MemoryBuffer and replacing the file contents with it.
Allow remapping a file by specifying another filename whose contents should be loaded if the original file gets loaded. This allows to override files without having to create & load buffers in advance. llvm-svn: 127052
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 90849d77faf..78a01e29b7e 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1428,7 +1428,7 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
// Figure out which record code to use.
unsigned Code;
if (SLoc->isFile()) {
- if (SLoc->getFile().getContentCache()->Entry)
+ if (SLoc->getFile().getContentCache()->OrigEntry)
Code = SM_SLOC_FILE_ENTRY;
else
Code = SM_SLOC_BUFFER_ENTRY;
@@ -1445,16 +1445,19 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
Record.push_back(File.hasLineDirectives());
const SrcMgr::ContentCache *Content = File.getContentCache();
- if (Content->Entry) {
+ if (Content->OrigEntry) {
+ assert(Content->OrigEntry == Content->ContentsEntry &&
+ "Writing to AST an overriden file is not supported");
+
// The source location entry is a file. The blob associated
// with this entry is the file name.
// Emit size/modification time for this file.
- Record.push_back(Content->Entry->getSize());
- Record.push_back(Content->Entry->getModificationTime());
+ Record.push_back(Content->OrigEntry->getSize());
+ Record.push_back(Content->OrigEntry->getModificationTime());
// Turn the file name into an absolute path, if it isn't already.
- const char *Filename = Content->Entry->getName();
+ const char *Filename = Content->OrigEntry->getName();
llvm::SmallString<128> FilePath(Filename);
llvm::sys::fs::make_absolute(FilePath);
Filename = FilePath.c_str();
OpenPOWER on IntegriCloud