[clang] 3cc3c0f - Add support to -Wa,--version in clang

Jian Cai via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 31 16:30:14 PDT 2021


Author: Jian Cai
Date: 2021-03-31T16:29:02-07:00
New Revision: 3cc3c0f8352ec33ca2f2636f94cb1d85fc57ac16

URL: https://github.com/llvm/llvm-project/commit/3cc3c0f8352ec33ca2f2636f94cb1d85fc57ac16
DIFF: https://github.com/llvm/llvm-project/commit/3cc3c0f8352ec33ca2f2636f94cb1d85fc57ac16.diff

LOG: Add support to -Wa,--version in clang

Clang currently only supports -Wa,--version when -no-integrated-as is
used. This adds support to -Wa,--version with -integrated-as.

Link:
https://github.com/ClangBuiltLinux/linux/issues/1320

Reviewed By: nickdesaulniers, MaskRay

Differential Revision: https://reviews.llvm.org/D99556

Added: 
    clang/test/Driver/as-version.s

Modified: 
    clang/lib/Driver/ToolChains/Clang.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 804f528838c58..9d3c725198f4d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2549,6 +2549,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
         // -fdebug-compilation-dir (without '=') here.
         CmdArgs.push_back("-fdebug-compilation-dir");
         CmdArgs.push_back(Value.data());
+      } else if (Value == "--version") {
+        D.PrintVersion(C, llvm::outs());
       } else {
         D.Diag(diag::err_drv_unsupported_option_argument)
             << A->getOption().getName() << Value;

diff  --git a/clang/test/Driver/as-version.s b/clang/test/Driver/as-version.s
new file mode 100644
index 0000000000000..9d2801e4ee379
--- /dev/null
+++ b/clang/test/Driver/as-version.s
@@ -0,0 +1,9 @@
+// Test version information.
+
+// RUN: %clang -Wa,--version -c -fintegrated-as %s -o /dev/null \
+// RUN:   | FileCheck --check-prefix=IAS %s
+// IAS: clang version
+
+// RUN: %clang -Wa,--version -c -fno-integrated-as %s -o /dev/null \
+// RUN:   | FileCheck --check-prefix=GAS %s
+// GAS-NOT: clang


        


More information about the cfe-commits mailing list