summaryrefslogtreecommitdiffstats
path: root/clang/Driver/clang.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-12-19 19:27:38 +0000
committerTed Kremenek <kremenek@apple.com>2007-12-19 19:27:38 +0000
commit0061aeb316964411908c9dffdc5734d6940f7492 (patch)
treec49e4302c4477b0db203ee2db661cf05ab40801d /clang/Driver/clang.cpp
parent6a4f74593c5d6c5b75ca7134512bf400fc3705cc (diff)
downloadbcm5719-llvm-0061aeb316964411908c9dffdc5734d6940f7492.tar.gz
bcm5719-llvm-0061aeb316964411908c9dffdc5734d6940f7492.zip
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. llvm-svn: 45211
Diffstat (limited to 'clang/Driver/clang.cpp')
-rw-r--r--clang/Driver/clang.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp
index 8afd71833fd..dc435f945a3 100644
--- a/clang/Driver/clang.cpp
+++ b/clang/Driver/clang.cpp
@@ -39,6 +39,7 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/System/Signals.h"
#include "llvm/Config/config.h"
+#include "llvm/ADT/scoped_ptr.h"
#include <memory>
using namespace clang;
@@ -887,7 +888,7 @@ static void ParseFile(Preprocessor &PP, MinimalAction *PA, unsigned MainFileID){
/// CreateASTConsumer - Create the ASTConsumer for the corresponding program
/// action. These consumers can operate on both ASTs that are freshly
/// parsed from source files as well as those deserialized from Bitcode.
-static ASTConsumer* CreateASTConsumer(const std::string& InFile,
+static ASTConsumer* CreateASTConsumer(const std::string& SourceFile,
Diagnostic& Diag, FileManager& FileMgr,
const LangOptions& LangOpts) {
switch (ProgAction) {
@@ -917,14 +918,14 @@ static ASTConsumer* CreateASTConsumer(const std::string& InFile,
return CreateUnitValsChecker(Diag);
case TestSerialization:
- return CreateSerializationTest(Diag, FileMgr, LangOpts);
+ return CreateSerializationTest(SourceFile, Diag, FileMgr, LangOpts);
case EmitLLVM:
return CreateLLVMEmitter(Diag, LangOpts);
case SerializeAST:
// FIXME: Allow user to tailor where the file is written.
- return CreateASTSerializer(InFile, Diag, LangOpts);
+ return CreateASTSerializer(SourceFile, Diag, LangOpts);
case RewriteTest:
return CreateCodeRewriterTest(Diag);
@@ -934,7 +935,7 @@ static ASTConsumer* CreateASTConsumer(const std::string& InFile,
/// ProcessInputFile - Process a single input file with the specified state.
///
static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID,
- const std::string &InFile,
+ const std::string &SourceFile,
TextDiagnostics &OurDiagnosticClient) {
ASTConsumer* Consumer = NULL;
@@ -942,7 +943,7 @@ static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID,
switch (ProgAction) {
default:
- Consumer = CreateASTConsumer(InFile, PP.getDiagnostics(),
+ Consumer = CreateASTConsumer(SourceFile, PP.getDiagnostics(),
PP.getFileManager(),
PP.getLangOptions());
@@ -1005,7 +1006,7 @@ static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID,
}
if (Stats) {
- fprintf(stderr, "\nSTATISTICS FOR '%s':\n", InFile.c_str());
+ fprintf(stderr, "\nSTATISTICS FOR '%s':\n", SourceFile.c_str());
PP.PrintStats();
PP.getIdentifierTable().PrintStats();
PP.getHeaderSearchInfo().PrintStats();
@@ -1036,7 +1037,7 @@ static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag,
exit (1);
}
- TranslationUnit* TU = ReadASTBitcodeFile(Filename,FileMgr);
+ llvm::scoped_ptr<TranslationUnit> TU(ReadASTBitcodeFile(Filename,FileMgr));
if (!TU) {
fprintf(stderr, "error: file '%s' could not be deserialized\n",
@@ -1044,8 +1045,11 @@ static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag,
exit (1);
}
- ASTConsumer* Consumer = CreateASTConsumer(InFile,Diag,
- FileMgr,TU->getLangOpts());
+ // Observe that we use the source file name stored in the deserialized
+ // translation unit, rather than InFile.
+ llvm::scoped_ptr<ASTConsumer>
+ Consumer(CreateASTConsumer(TU->getSourceFile(), Diag, FileMgr,
+ TU->getLangOpts()));
if (!Consumer) {
fprintf(stderr, "Unsupported program action with serialized ASTs!\n");
@@ -1053,12 +1057,10 @@ static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag,
}
// FIXME: only work on consumers that do not require MainFileID.
- Consumer->Initialize(*TU->getContext(),0);
+ Consumer->Initialize(*TU->getContext(), 0);
for (TranslationUnit::iterator I=TU->begin(), E=TU->end(); I!=E; ++I)
Consumer->HandleTopLevelDecl(*I);
-
- delete Consumer;
}
OpenPOWER on IntegriCloud