[PATCH] D157794: [Driver] Make /Zi and /Z7 aliases of -g rather than handling them specially

Justin Bogner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 14 10:27:31 PDT 2023


bogner added inline comments.


================
Comment at: clang/test/Driver/cl-options.c:567
 
-// This test was super sneaky: "/Z7" means "line-tables", but "-gdwarf" occurs
-// later on the command line, so it should win. Interestingly the cc1 arguments
-// came out right, but had wrong semantics, because an invariant assumed by
-// CompilerInvocation was violated: it expects that at most one of {gdwarfN,
-// line-tables-only} appear. If you assume that, then you can safely use
-// Args.hasArg to test whether a boolean flag is present without caring
-// where it appeared. And for this test, it appeared to the left of -gdwarf
-// which made it "win". This test could not detect that bug.
+// If We specify both /Z7 and -gdwarf we should get dwarf, not codeview.
 // RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck -check-prefix=Z7_gdwarf %s
----------------
smeenai wrote:
> bogner wrote:
> > rnk wrote:
> > > I think Meta folks depend on a mode that emits both codeview and DWARF. + at smeenai
> > Hopefully if that's the case there's a better test somewhere than this one that discusses in detail how `/Z7` is an alias for `-gline-tables-only`, which hasn't been true since 2017.
> Thanks for the headers up :) We don't depend on that mode any more though, so no problems on our end.
Also note that this change does not affect what happens if we specify both `-gcodeview` and `-gdwarf` together. That continues to pass both `-gcodeview` and `-dwarf-version=...` to `clang -cc1`. However, I don't see any tests that actually check that behaviour, so if that is a mode that's useful to keep working we definitely have some gaps there.

This change means that if you want to ask `-cc1` for dwarf *and* codeview with `/Z7` or `/Zi`, you'll need to specify `-gdwarf` and `-gcodeview` now. This matches how you would get both sets of options to render with `-g`, which I think makes sense.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157794/new/

https://reviews.llvm.org/D157794



More information about the cfe-commits mailing list