diff options
author | Hans Wennborg <hans@hanshq.net> | 2013-12-20 18:40:46 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2013-12-20 18:40:46 +0000 |
commit | e0053474b92ba0acf8399138db890e78523c5671 (patch) | |
tree | 99778fc446359e0297a163eb10a5b19285e0a0c5 /clang/lib/Driver/Driver.cpp | |
parent | c1fb2d61119d3a4bb7ffa453521b072949d77c19 (diff) | |
download | bcm5719-llvm-e0053474b92ba0acf8399138db890e78523c5671.tar.gz bcm5719-llvm-e0053474b92ba0acf8399138db890e78523c5671.zip |
clang-cl: Support /P and /E (preprocess to file or stdout)
llvm-svn: 197827
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 7826cb30fcf..5ccd0412a8e 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -159,10 +159,11 @@ const { Arg *PhaseArg = 0; phases::ID FinalPhase; - // -{E,M,MM} only run the preprocessor. + // -{E,M,MM} and /P only run the preprocessor. if (CCCIsCPP() || (PhaseArg = DAL.getLastArg(options::OPT_E)) || - (PhaseArg = DAL.getLastArg(options::OPT_M, options::OPT_MM))) { + (PhaseArg = DAL.getLastArg(options::OPT_M, options::OPT_MM)) || + (PhaseArg = DAL.getLastArg(options::OPT__SLASH_P))) { FinalPhase = phases::Preprocess; // -{fsyntax-only,-analyze,emit-ast,S} only run up to the compiler. @@ -1627,6 +1628,14 @@ const char *Driver::GetNamedOutputPath(Compilation &C, return C.addResultFile(FinalOutput->getValue(), &JA); } + // For /P, preprocess to file named after BaseInput. + if (C.getArgs().hasArg(options::OPT__SLASH_P)) { + assert(AtTopLevel && isa<PreprocessJobAction>(JA)); + StringRef BaseName = llvm::sys::path::filename(BaseInput); + return C.addResultFile(MakeCLOutputFilename(C.getArgs(), "", BaseName, + types::TY_PP_C), &JA); + } + // Default to writing to stdout? if (AtTopLevel && !CCGenDiagnostics && (isa<PreprocessJobAction>(JA) || JA.getType() == types::TY_ModuleFile)) |