diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-11-11 10:07:22 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-11-11 10:07:22 +0000 |
commit | 775bee71ad21c84bc130af22ac47c1c8e0f9e72f (patch) | |
tree | 2552c42ca1c5837ff2e825fd0d814a6bbbdfa897 /lib/Frontend/PrintPreprocessedOutput.cpp | |
parent | 29a790ba422cfeeea9546b6e76777d98fa73cd67 (diff) |
Add PreprocessorOutputOptions, for things like -dM, -C, -CC which control -E
mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86827 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PrintPreprocessedOutput.cpp')
-rw-r--r-- | lib/Frontend/PrintPreprocessedOutput.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp index 630a093a4b..b1a1936150 100644 --- a/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/lib/Frontend/PrintPreprocessedOutput.cpp @@ -13,13 +13,14 @@ //===----------------------------------------------------------------------===// #include "clang/Frontend/Utils.h" +#include "clang/Basic/Diagnostic.h" +#include "clang/Basic/SourceManager.h" +#include "clang/Frontend/PreprocessorOutputOptions.h" #include "clang/Lex/MacroInfo.h" #include "clang/Lex/PPCallbacks.h" -#include "clang/Lex/Preprocessor.h" #include "clang/Lex/Pragma.h" +#include "clang/Lex/Preprocessor.h" #include "clang/Lex/TokenConcatenation.h" -#include "clang/Basic/SourceManager.h" -#include "clang/Basic/Diagnostic.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Config/config.h" @@ -439,7 +440,7 @@ namespace { }; } -void clang::DoPrintMacros(Preprocessor &PP, llvm::raw_ostream *OS) { +static void DoPrintMacros(Preprocessor &PP, llvm::raw_ostream *OS) { // -dM mode just scans and ignores all tokens in the files, then dumps out // the macro table at the end. PP.EnterMainSourceFile(); @@ -467,18 +468,23 @@ void clang::DoPrintMacros(Preprocessor &PP, llvm::raw_ostream *OS) { /// DoPrintPreprocessedInput - This implements -E mode. /// void clang::DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream *OS, - bool EnableCommentOutput, - bool EnableMacroCommentOutput, - bool DisableLineMarkers, - bool DumpDefines) { + PreprocessorOutputOptions &Opts) { + // Show macros with no output is handled specially. + if (!Opts.ShowCPP) { + assert(Opts.ShowMacros && "Not yet implemented!"); + DoPrintMacros(PP, OS); + return; + } + // Inform the preprocessor whether we want it to retain comments or not, due // to -C or -CC. - PP.SetCommentRetentionState(EnableCommentOutput, EnableMacroCommentOutput); + PP.SetCommentRetentionState(Opts.ShowComments, Opts.ShowMacroComments); OS->SetBufferSize(64*1024); PrintPPOutputPPCallbacks *Callbacks = - new PrintPPOutputPPCallbacks(PP, *OS, DisableLineMarkers, DumpDefines); + new PrintPPOutputPPCallbacks(PP, *OS, !Opts.ShowLineMarkers, + Opts.ShowMacros); PP.AddPragmaHandler(0, new UnknownPragmaHandler("#pragma", Callbacks)); PP.AddPragmaHandler("GCC", new UnknownPragmaHandler("#pragma GCC", Callbacks)); |