[PATCH] D96783: [Driver] Support -gdwarf64 for assembly files

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 16 10:43:07 PST 2021


dblaikie accepted this revision.
dblaikie added a comment.

Looks good to me - thanks



================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3757-3771
+  if (DwarfFormatArg &&
+      DwarfFormatArg->getOption().matches(options::OPT_gdwarf64)) {
+    if (DwarfVersion < 3)
+      D.Diag(diag::err_drv_argument_only_allowed_with)
+          << DwarfFormatArg->getAsString(Args) << "DWARFv3 or greater";
+    else if (!T.isArch64Bit())
+      D.Diag(diag::err_drv_argument_only_allowed_with)
----------------
Could simplify this with an early return:
```
if (!DwarfFormatArg)
  return;
...
```

So DwarfFormatArg isn't tested twice/reduces indentation/etc.


================
Comment at: clang/tools/driver/cc1as_main.cpp:237
+  if (auto *DwarfFormatArg = Args.getLastArg(OPT_gdwarf64, OPT_gdwarf32))
+    Opts.Dwarf64 = DwarfFormatArg->getOption().matches(OPT_gdwarf64) ? 1 : 0;
   Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags);
----------------
No need for the ` ? 1 : 0`, that's what booleans convert to anyway. (unless there's prior art/other instances of this idiom in this file that this is consistent with)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96783



More information about the cfe-commits mailing list