[PATCH] D128409: [clang-cl] Add -emit-ast to clang-cl driver

Tobias Hieta via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 23 01:42:21 PDT 2022

thieta created this revision.
thieta added reviewers: hans, mstorsjo.
Herald added a project: All.
thieta requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: clang.

Also make the output of -emit-ast end up where /Fo or /o points.
The same with .plist files from the static analyzer.

These are changes needed to make it possible to do CTU static
analysing work with clang-cl.

  rG LLVM Github Monorepo



Index: clang/lib/Driver/Driver.cpp
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -5625,7 +5625,8 @@
   // Determine what the derived output name should be.
   const char *NamedOutput;
-  if ((JA.getType() == types::TY_Object || JA.getType() == types::TY_LTO_BC) &&
+  if ((JA.getType() == types::TY_Object || JA.getType() == types::TY_LTO_BC ||
+       JA.getType() == types::TY_AST || JA.getType() == types::TY_Plist) &&
       C.getArgs().hasArg(options::OPT__SLASH_Fo, options::OPT__SLASH_o)) {
     // The /Fo or /o flag decides the object filename.
     StringRef Val =
Index: clang/include/clang/Driver/Options.td
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -831,7 +831,7 @@
   HelpText<"Pass <arg> to the linker">, MetaVarName<"<arg>">,
 def Xoffload_linker : JoinedAndSeparate<["-"], "Xoffload-linker">,
-  HelpText<"Pass <arg> to the offload linkers or the ones idenfied by -<triple>">, 
+  HelpText<"Pass <arg> to the offload linkers or the ones idenfied by -<triple>">,
   MetaVarName<"<triple> <arg>">, Group<Link_Group>;
 def Xpreprocessor : Separate<["-"], "Xpreprocessor">, Group<Preprocessor_Group>,
   HelpText<"Pass <arg> to the preprocessor">, MetaVarName<"<arg>">;
@@ -1091,7 +1091,7 @@
 def dynamic : Flag<["-"], "dynamic">, Flags<[NoArgumentUnused]>;
 def d_Flag : Flag<["-"], "d">, Group<d_Group>;
 def d_Joined : Joined<["-"], "d">, Group<d_Group>;
-def emit_ast : Flag<["-"], "emit-ast">,
+def emit_ast : Flag<["-"], "emit-ast">, Flags<[CoreOption]>,
   HelpText<"Emit Clang AST files for source inputs">;
 def emit_llvm : Flag<["-"], "emit-llvm">, Flags<[CC1Option, FC1Option, FlangOption]>, Group<Action_Group>,
   HelpText<"Use the LLVM representation for assembler and object files">;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128409.439274.patch
Type: text/x-patch
Size: 1938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220623/77548188/attachment.bin>

More information about the cfe-commits mailing list