[clang-tools-extra] d951ca5 - Revert "[Driver] Enable to use C++20 standalne by -fcxx-modules"

Adrian Prantl via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 1 12:12:09 PDT 2022


Author: Adrian Prantl
Date: 2022-06-01T12:11:57-07:00
New Revision: d951ca5439bb8726cfe1ceb2d12e220f29fe5125

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

LOG: Revert "[Driver] Enable to use C++20 standalne by -fcxx-modules"

This reverts commit a544710cd43ba9f7729a613c58729f146e792a8e.

See discussion in D120540.

This breaks C++ Clang modules on Darwin and also more than a dozen
tests in the LLDB testsuite.  I think we need to be more careful to
separate out the enabling of Clang C++ modules and C++20
modules. Either by having -fmodules-ts control the HaveModules flag,
or by adding a way to explicitly turn them off.

Added: 
    

Modified: 
    clang-tools-extra/test/pp-trace/pp-trace-modules.cpp
    clang/include/clang/Driver/Options.td
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/modules.cpp

Removed: 
    clang/test/Modules/cxx-modules.cppm


################################################################################
diff  --git a/clang-tools-extra/test/pp-trace/pp-trace-modules.cpp b/clang-tools-extra/test/pp-trace/pp-trace-modules.cpp
index 028c967a4e0d8..32d6c48e5d448 100644
--- a/clang-tools-extra/test/pp-trace/pp-trace-modules.cpp
+++ b/clang-tools-extra/test/pp-trace/pp-trace-modules.cpp
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' %s -- -x objective-c++ -undef -target x86_64 -std=c++11 -fmodules -fmodules-cache-path=%t -I%S -I%S/Input | FileCheck --strict-whitespace %s
+// RUN: pp-trace -callbacks '*,-FileChanged,-MacroDefined' %s -- -x objective-c++ -undef -target x86_64 -std=c++11 -fmodules -fcxx-modules -fmodules-cache-path=%t -I%S -I%S/Input | FileCheck --strict-whitespace %s
 
 // CHECK: ---
 

diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 074dc56f2aa23..1cef95a0d4efe 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1414,7 +1414,7 @@ defm async_exceptions: BoolFOption<"async-exceptions",
   PosFlag<SetTrue, [CC1Option], "Enable EH Asynchronous exceptions">, NegFlag<SetFalse>>;
 defm cxx_modules : BoolFOption<"cxx-modules",
   LangOpts<"CPlusPlusModules">, Default<cpp20.KeyPath>,
-  NegFlag<SetFalse, [CC1Option], "Disable">, PosFlag<SetTrue, [CC1Option], "Enable">,
+  NegFlag<SetFalse, [CC1Option], "Disable">, PosFlag<SetTrue, [], "Enable">,
   BothFlags<[NoXarchOption], " modules for C++">>,
   ShouldParseIf<cplusplus.KeyPath>;
 def fdebug_pass_arguments : Flag<["-"], "fdebug-pass-arguments">, Group<f_Group>;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index f32dfdcdfe4bb..2328e3db1973f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3630,12 +3630,6 @@ static void RenderModulesOptions(Compilation &C, const Driver &D,
     HaveModules = true;
   }
 
-  if (Args.hasFlag(options::OPT_fcxx_modules, options::OPT_fno_cxx_modules,
-                   false)) {
-    CmdArgs.push_back("-fcxx-modules");
-    HaveModules = true;
-  }
-
   // -fmodule-maps enables implicit reading of module map files. By default,
   // this is enabled if we are using Clang's flavor of precompiled modules.
   if (Args.hasFlag(options::OPT_fimplicit_module_maps,

diff  --git a/clang/test/Driver/modules.cpp b/clang/test/Driver/modules.cpp
index bac9f715f13a4..87b6cc640cb0d 100644
--- a/clang/test/Driver/modules.cpp
+++ b/clang/test/Driver/modules.cpp
@@ -73,14 +73,3 @@ import "foo.h";
 // CHECK-HEADER-UNIT-USE: BAR;
 FOO;
 #endif
-
-// Check the independent use of -fcxx-modules
-//
-// RUN: %clang++ -fcxx-modules -std=c++17 -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX17-MODULES
-// CHECK-CXX17-MODULES: "-fcxx-modules"
-// RUN: %clang++ -fcxx-modules -std=c++14 -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX14-MODULES
-// CHECK-CXX14-MODULES: "-fcxx-modules"
-// RUN: %clang++ -fcxx-modules -std=c++11 -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX11-MODULES
-// CHECK-CXX11-MODULES: "-fcxx-modules"
-// RUN: %clang++ -fcxx-modules -std=c++03 -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX03-MODULES
-// CHECK-CXX03-MODULES: "-fcxx-modules"

diff  --git a/clang/test/Modules/cxx-modules.cppm b/clang/test/Modules/cxx-modules.cppm
deleted file mode 100644
index be17f85f8d17d..0000000000000
--- a/clang/test/Modules/cxx-modules.cppm
+++ /dev/null
@@ -1,7 +0,0 @@
-// This tests that we could use C++20 modules standalone.
-// RUN: %clang -std=c++03 -fcxx-modules -fsyntax-only -Xclang -verify %s
-// RUN: %clang -std=c++11 -fcxx-modules -fsyntax-only -Xclang -verify %s
-// RUN: %clang -std=c++14 -fcxx-modules -fsyntax-only -Xclang -verify %s
-// RUN: %clang -std=c++17 -fcxx-modules -fsyntax-only -Xclang -verify %s
-// expected-no-diagnostics
-export module M;


        


More information about the cfe-commits mailing list