Removed storing inode and device number in TranslationUnit.
Added "SourceFile" string to TranslationUnit to record corresponding
source file.
Updated serialization of TranslationUnits and logic in the driver to
correctly pass the source file information to the serializer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45211 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp
index 184f29a..202e030 100644
--- a/Driver/ASTConsumers.cpp
+++ b/Driver/ASTConsumers.cpp
@@ -614,10 +614,10 @@
TranslationUnit TU;
const llvm::sys::Path FName;
public:
- ASTSerializer(const llvm::sys::Path& F, Diagnostic &diags,
+ ASTSerializer(const std::string& SourceFile,
+ const llvm::sys::Path& F, Diagnostic &diags,
const LangOptions &LO)
- : Diags(diags), TU(LO), FName(F) {}
-
+ : Diags(diags), TU(SourceFile,LO), FName(F) {}
virtual void Initialize(ASTContext &Context, unsigned MainFileID) {
TU.setContext(&Context);
@@ -637,20 +637,24 @@
} // end anonymous namespace
-ASTConsumer* clang::CreateASTSerializer(const std::string& InFile,
+ASTConsumer* clang::CreateASTSerializer(const std::string& SourceFile,
Diagnostic &Diags,
const LangOptions &Features) {
-
- // FIXME: This is a hack: "/" separator not portable.
- std::string::size_type idx = InFile.rfind("/");
+ // FIXME: If the translation unit we are serializing came was itself
+ // deserialized from disk, we may overwrite that file. This
+ // is only a temporary bug, since the code in this function will
+ // be completely replaced momentarily.
- if (idx != std::string::npos && idx == InFile.size()-1)
+ // FIXME: This is a hack: "/" separator not portable.
+ std::string::size_type idx = SourceFile.rfind("/");
+
+ if (idx != std::string::npos && idx == SourceFile.size()-1)
return NULL;
std::string TargetPrefix( idx == std::string::npos ?
- InFile : InFile.substr(idx+1));
+ SourceFile : SourceFile.substr(idx+1));
llvm::sys::Path FName = llvm::sys::Path((TargetPrefix + ".ast").c_str());
- return new ASTSerializer(FName, Diags, Features);
+ return new ASTSerializer(SourceFile, FName, Diags, Features);
}