r197827 - clang-cl: Support /P and /E (preprocess to file or stdout)
Reid Kleckner
rnk at google.com
Fri Dec 20 10:49:55 PST 2013
Thanks, that inconsistency was bothering me.
On Fri, Dec 20, 2013 at 10:40 AM, Hans Wennborg <hans at hanshq.net> wrote:
> Author: hans
> Date: Fri Dec 20 12:40:46 2013
> New Revision: 197827
>
> URL: http://llvm.org/viewvc/llvm-project?rev=197827&view=rev
> Log:
> clang-cl: Support /P and /E (preprocess to file or stdout)
>
> Modified:
> cfe/trunk/include/clang/Driver/CLCompatOptions.td
> cfe/trunk/lib/Driver/Driver.cpp
> cfe/trunk/test/Driver/cl-options.c
> cfe/trunk/test/Driver/cl-outputs.c
>
> Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=197827&r1=197826&r2=197827&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
> +++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Fri Dec 20 12:40:46
> 2013
> @@ -57,6 +57,7 @@ def _SLASH_C : CLFlag<"C">, HelpText<"Do
> def _SLASH_c : CLFlag<"c">, HelpText<"Compile only">, Alias<c>;
> def _SLASH_D : CLJoinedOrSeparate<"D">, HelpText<"Define macro">,
> MetaVarName<"<macro[=value]>">, Alias<D>;
> +def _SLASH_E : CLFlag<"E">, HelpText<"Preprocess to stdout">, Alias<E>;
> def _SLASH_GR : CLFlag<"GR">, HelpText<"Enable RTTI">, Alias<frtti>;
> def _SLASH_GR_ : CLFlag<"GR-">, HelpText<"Disable RTTI">, Alias<fno_rtti>;
> def _SLASH_GF_ : CLFlag<"GF-">, HelpText<"Disable string pooling">,
> @@ -88,7 +89,6 @@ def _SLASH_Oy : CLFlag<"Oy">, HelpText<"
> Alias<fomit_frame_pointer>;
> def _SLASH_Oy_ : CLFlag<"Oy-">, HelpText<"Disable frame pointer
> omission">,
> Alias<fno_omit_frame_pointer>;
> -def _SLASH_P : CLFlag<"P">, HelpText<"Only run the preprocessor">,
> Alias<E>;
> def _SLASH_QUESTION : CLFlag<"?">, Alias<help>,
> HelpText<"Display available options">;
> def _SLASH_showIncludes : CLFlag<"showIncludes">,
> @@ -142,6 +142,7 @@ def _SLASH_MT : Option<["/", "-"], "MT",
> Flags<[CLOption, DriverOption]>, HelpText<"Use static run-time">;
> def _SLASH_MTd : Option<["/", "-"], "MTd", KIND_FLAG>,
> Group<_SLASH_M_Group>,
> Flags<[CLOption, DriverOption]>, HelpText<"Use static debug run-time">;
> +def _SLASH_P : CLFlag<"P">, HelpText<"Preprocess to file">;
> def _SLASH_Tc : CLCompileJoinedOrSeparate<"Tc">,
> HelpText<"Specify a C source file">, MetaVarName<"<filename>">;
> def _SLASH_TC : CLCompileFlag<"TC">, HelpText<"Treat all source files as
> C">;
> @@ -178,7 +179,6 @@ def _SLASH_arch : CLJoined<"arch:">;
> def _SLASH_bigobj : CLFlag<"bigobj">;
> def _SLASH_clr : CLJoined<"clr">;
> def _SLASH_doc : CLJoined<"doc">;
> -def _SLASH_E : CLFlag<"E">;
> def _SLASH_EH : CLJoined<"EH">;
> def _SLASH_EP : CLFlag<"EP">;
> def _SLASH_FA_joined : CLJoined<"FA">;
>
> Modified: cfe/trunk/lib/Driver/Driver.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=197827&r1=197826&r2=197827&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/Driver.cpp (original)
> +++ cfe/trunk/lib/Driver/Driver.cpp Fri Dec 20 12:40:46 2013
> @@ -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(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))
>
> Modified: cfe/trunk/test/Driver/cl-options.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=197827&r1=197826&r2=197827&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Driver/cl-options.c (original)
> +++ cfe/trunk/test/Driver/cl-options.c Fri Dec 20 12:40:46 2013
> @@ -14,6 +14,10 @@
> // RUN: %clang_cl /D foo=bar -### -- %s 2>&1 | FileCheck -check-prefix=D
> %s
> // D: "-D" "foo=bar"
>
> +// RUN: %clang_cl /E -### -- %s 2>&1 | FileCheck -check-prefix=E %s
> +// E: "-E"
> +// E: "-o" "-"
> +
> // RTTI is on by default; just check that we don't error.
> // RUN: %clang_cl /Zs /GR -- %s 2>&1
>
> @@ -56,9 +60,6 @@
> // RUN: %clang_cl /Oy- -### -- %s 2>&1 | FileCheck -check-prefix=Oy_ %s
> // Oy_: -mdisable-fp-elim
>
> -// RUN: %clang_cl /P -### -- %s 2>&1 | FileCheck -check-prefix=P %s
> -// P: -E
> -
> // RUN: %clang_cl /showIncludes -### -- %s 2>&1 | FileCheck
> -check-prefix=showIncludes %s
> // showIncludes: --show-includes
>
> @@ -140,7 +141,6 @@
> // RUN: /arch:sse2 \
> // RUN: /clr:pure \
> // RUN: /docname \
> -// RUN: /E \
> // RUN: /EHsc \
> // RUN: /EP \
> // RUN: /F \
>
> Modified: cfe/trunk/test/Driver/cl-outputs.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-outputs.c?rev=197827&r1=197826&r2=197827&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Driver/cl-outputs.c (original)
> +++ cfe/trunk/test/Driver/cl-outputs.c Fri Dec 20 12:40:46 2013
> @@ -105,3 +105,7 @@
> // FaDIRNAMEEXT: "-o" "foo.dir{{[/\\]+}}a.ext"
> // RUN: %clang_cl /Faa.asm -### -- %s %s 2>&1 | FileCheck
> -check-prefix=FaMULTIPLESOURCE %s
> // FaMULTIPLESOURCE: error: cannot specify '/Faa.asm' when compiling
> multiple source files
> +
> +// RUN: %clang_cl /P -### -- %s 2>&1 | FileCheck -check-prefix=P %s
> +// P: "-E"
> +// P: "-o" "cl-outputs.i"
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131220/2606e45f/attachment.html>
More information about the cfe-commits
mailing list