aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-15 20:48:40 +0000
committerChris Lattner <sabre@nondot.org>2007-12-15 20:48:40 +0000
commitdee7359a59e6327206ba710cf22f3851e2a0fc48 (patch)
treea089e68daf69d43f2e20efbc4fe56892fcb8bf49
parentf816f77480e70caadfdbd741cf17d84a6be30b71 (diff)
simplify the interfaces to ProcessInputFile and InitializePreprocessor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45060 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Driver/PrintPreprocessedOutput.cpp3
-rw-r--r--Driver/clang.cpp31
-rw-r--r--Driver/clang.h4
3 files changed, 13 insertions, 25 deletions
diff --git a/Driver/PrintPreprocessedOutput.cpp b/Driver/PrintPreprocessedOutput.cpp
index bdf6d04bc1..109664b8cc 100644
--- a/Driver/PrintPreprocessedOutput.cpp
+++ b/Driver/PrintPreprocessedOutput.cpp
@@ -531,8 +531,7 @@ bool PrintPPOutputPPCallbacks::AvoidConcat(const Token &PrevTok,
/// DoPrintPreprocessedInput - This implements -E mode.
///
-void clang::DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP,
- const LangOptions &Options) {
+void clang::DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP) {
// Inform the preprocessor whether we want it to retain comments or not, due
// to -C or -CC.
PP.SetCommentRetentionState(EnableCommentOutput, EnableMacroCommentOutput);
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index bcffeb73b7..806e7b1c54 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -507,15 +507,13 @@ static void DefineBuiltinMacro(std::vector<char> &Buf, const char *Macro,
///
static unsigned InitializePreprocessor(Preprocessor &PP,
const std::string &InFile,
- SourceManager &SourceMgr,
- HeaderSearch &HeaderInfo,
- const LangOptions &LangInfo,
std::vector<char> &PredefineBuffer) {
- FileManager &FileMgr = HeaderInfo.getFileMgr();
+ FileManager &FileMgr = PP.getFileManager();
// Figure out where to get and map in the main file.
unsigned MainFileID = 0;
+ SourceManager &SourceMgr = PP.getSourceManager();
if (InFile != "-") {
const FileEntry *File = FileMgr.getFile(InFile);
if (File) MainFileID = SourceMgr.createFileID(File, SourceLocation());
@@ -879,10 +877,7 @@ static ASTConsumer* CreateASTConsumer(const std::string& InFile,
///
static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID,
const std::string &InFile,
- SourceManager &SourceMgr,
- TextDiagnostics &OurDiagnosticClient,
- HeaderSearch &HeaderInfo,
- const LangOptions &LangInfo) {
+ TextDiagnostics &OurDiagnosticClient) {
ASTConsumer* Consumer = NULL;
bool ClearSourceMgr = false;
@@ -890,7 +885,7 @@ static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID,
switch (ProgAction) {
default:
Consumer = CreateASTConsumer(InFile, PP.getDiagnostics(),
- HeaderInfo.getFileMgr(),
+ PP.getFileManager(),
PP.getLangOptions());
if (!Consumer) {
@@ -923,7 +918,7 @@ static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID,
}
case PrintPreprocessedInput: // -E mode.
- DoPrintPreprocessedInput(MainFileID, PP, LangInfo);
+ DoPrintPreprocessedInput(MainFileID, PP);
ClearSourceMgr = true;
break;
@@ -955,18 +950,17 @@ static void ProcessInputFile(Preprocessor &PP, unsigned MainFileID,
fprintf(stderr, "\nSTATISTICS FOR '%s':\n", InFile.c_str());
PP.PrintStats();
PP.getIdentifierTable().PrintStats();
- HeaderInfo.PrintStats();
+ PP.getHeaderSearchInfo().PrintStats();
if (ClearSourceMgr)
- SourceMgr.PrintStats();
+ PP.getSourceManager().PrintStats();
fprintf(stderr, "\n");
}
// For a multi-file compilation, some things are ok with nuking the source
// manager tables, other require stable fileid/macroid's across multiple
// files.
- if (ClearSourceMgr) {
- SourceMgr.clearIDTables();
- }
+ if (ClearSourceMgr)
+ PP.getSourceManager().clearIDTables();
}
static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag,
@@ -1112,14 +1106,11 @@ int main(int argc, char **argv) {
Preprocessor PP(Diags, LangInfo, *Target, SourceMgr, HeaderInfo);
std::vector<char> PredefineBuffer;
- unsigned MainFileID = InitializePreprocessor(PP, InFile, SourceMgr,
- HeaderInfo, LangInfo,
- PredefineBuffer);
+ unsigned MainFileID = InitializePreprocessor(PP, InFile, PredefineBuffer);
if (!MainFileID) continue;
- ProcessInputFile(PP, MainFileID, InFile, SourceMgr,
- *DiagClient, HeaderInfo, LangInfo);
+ ProcessInputFile(PP, MainFileID, InFile, *DiagClient);
HeaderInfo.ClearFileInfo();
diff --git a/Driver/clang.h b/Driver/clang.h
index 079794d480..77ce59ed1c 100644
--- a/Driver/clang.h
+++ b/Driver/clang.h
@@ -19,7 +19,6 @@
namespace clang {
class Preprocessor;
-struct LangOptions;
class MinimalAction;
class TargetInfo;
class Diagnostic;
@@ -28,8 +27,7 @@ class IdentifierTable;
class SourceManager;
/// DoPrintPreprocessedInput - Implement -E mode.
-void DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP,
- const LangOptions &Options);
+void DoPrintPreprocessedInput(unsigned MainFileID, Preprocessor &PP);
/// CreatePrintParserActionsAction - Return the actions implementation that
/// implements the -parse-print-callbacks option.