[Driver] Fix -f[no-]unwind-tables -Wunused-command-line-argument after 4388b56d525c08...
authorFangrui Song <i@maskray.me>
Wed, 21 Sep 2022 03:13:30 +0000 (20:13 -0700)
committerFangrui Song <i@maskray.me>
Wed, 21 Sep 2022 03:13:30 +0000 (20:13 -0700)
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/clang-translation.c

index fb64722..4fe68f6 100644 (file)
@@ -5469,13 +5469,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   auto SanitizeArgs = TC.getSanitizerArgs(Args);
   auto UnwindTables = TC.getDefaultUnwindTableLevel(Args);
 
+  const bool HasSyncUnwindTables = Args.hasFlag(
+      options::OPT_funwind_tables, options::OPT_fno_unwind_tables, false);
   if (Args.hasFlag(options::OPT_fasynchronous_unwind_tables,
                    options::OPT_fno_asynchronous_unwind_tables,
                    SanitizeArgs.needsUnwindTables()) &&
       !Freestanding)
     UnwindTables = ToolChain::UnwindTableLevel::Asynchronous;
-  else if (Args.hasFlag(options::OPT_funwind_tables,
-                        options::OPT_fno_unwind_tables, false))
+  else if (HasSyncUnwindTables)
     UnwindTables = ToolChain::UnwindTableLevel::Synchronous;
   else if (Args.hasFlag(options::OPT_fno_unwind_tables,
                    options::OPT_fno_asynchronous_unwind_tables,
index ffa732c..715b0b3 100644 (file)
@@ -10,7 +10,7 @@
 // I386: "-o"
 // I386: clang-translation
 
-// RUN: %clang -target i386-unknown-unknown -### -S %s -fasynchronous-unwind-tables -fno-unwind-tables 2>&1 | FileCheck --check-prefix=UNWIND-TABLES %s
+// RUN: %clang -target i386-unknown-unknown -### -S %s -fasynchronous-unwind-tables -fno-unwind-tables 2>&1 | FileCheck --check-prefix=UNWIND-TABLES %s --implicit-check-not=warning:
 // UNWIND-TABLES: "-funwind-tables=2"
 
 // RUN: %clang -target i386-apple-darwin9 -### -S %s -o %t.s 2>&1 | \