r307316 - Reject attempts to build a module without -fmodules, rather than silently doing weird things.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 6 14:05:56 PDT 2017
Author: rsmith
Date: Thu Jul 6 14:05:56 2017
New Revision: 307316
URL: http://llvm.org/viewvc/llvm-project?rev=307316&view=rev
Log:
Reject attempts to build a module without -fmodules, rather than silently doing weird things.
Added:
cfe/trunk/test/Modules/missing-flag.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/include/clang/Frontend/FrontendActions.h
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/test/Modules/preprocess-build.cpp
cfe/trunk/test/Modules/relative-dep-gen.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=307316&r1=307315&r2=307316&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Thu Jul 6 14:05:56 2017
@@ -179,6 +179,8 @@ def warn_incompatible_analyzer_plugin_ap
def note_incompatible_analyzer_plugin_api : Note<
"current API version is '%0', but plugin was compiled with version '%1'">;
+def err_module_build_requires_fmodules : Error<
+ "module compilation requires '-fmodules'">;
def err_module_interface_requires_modules_ts : Error<
"module interface compilation requires '-fmodules-ts'">;
def warn_module_config_mismatch : Warning<
Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=307316&r1=307315&r2=307316&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendActions.h Thu Jul 6 14:05:56 2017
@@ -111,6 +111,8 @@ protected:
class GenerateModuleFromModuleMapAction : public GenerateModuleAction {
private:
+ bool BeginSourceFileAction(CompilerInstance &CI) override;
+
std::unique_ptr<raw_pwrite_stream>
CreateOutputFile(CompilerInstance &CI, StringRef InFile) override;
};
Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=307316&r1=307315&r2=307316&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Thu Jul 6 14:05:56 2017
@@ -163,6 +163,16 @@ GenerateModuleAction::CreateASTConsumer(
return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
}
+bool GenerateModuleFromModuleMapAction::BeginSourceFileAction(
+ CompilerInstance &CI) {
+ if (!CI.getLangOpts().Modules) {
+ CI.getDiagnostics().Report(diag::err_module_build_requires_fmodules);
+ return false;
+ }
+
+ return GenerateModuleAction::BeginSourceFileAction(CI);
+}
+
std::unique_ptr<raw_pwrite_stream>
GenerateModuleFromModuleMapAction::CreateOutputFile(CompilerInstance &CI,
StringRef InFile) {
Added: cfe/trunk/test/Modules/missing-flag.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/missing-flag.cpp?rev=307316&view=auto
==============================================================================
--- cfe/trunk/test/Modules/missing-flag.cpp (added)
+++ cfe/trunk/test/Modules/missing-flag.cpp Thu Jul 6 14:05:56 2017
@@ -0,0 +1,4 @@
+// RUN: not %clang_cc1 -x c++-module-map %s -emit-module -fmodule-name=Foo -o %t 2>&1 | FileCheck %s
+// CHECK: module compilation requires '-fmodules'
+module Foo {}
+#pragma clang module contents
Modified: cfe/trunk/test/Modules/preprocess-build.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess-build.cpp?rev=307316&r1=307315&r2=307316&view=diff
==============================================================================
--- cfe/trunk/test/Modules/preprocess-build.cpp (original)
+++ cfe/trunk/test/Modules/preprocess-build.cpp Thu Jul 6 14:05:56 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1z %s -verify
+// RUN: %clang_cc1 -std=c++1z -fmodules %s -verify
#pragma clang module build baz
module baz {}
Modified: cfe/trunk/test/Modules/relative-dep-gen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/relative-dep-gen.cpp?rev=307316&r1=307315&r2=307316&view=diff
==============================================================================
--- cfe/trunk/test/Modules/relative-dep-gen.cpp (original)
+++ cfe/trunk/test/Modules/relative-dep-gen.cpp Thu Jul 6 14:05:56 2017
@@ -2,17 +2,17 @@
// RUN: rm -rf %t
// RUN: mkdir %t
//
-// RUN: %clang_cc1 -cc1 -fno-implicit-modules -fmodule-name=relative-dep-gen -emit-module -x c++ Inputs/relative-dep-gen.modulemap -dependency-file %t/build.d -MT mod.pcm -o %t/mod.pcm
-// RUN: %clang_cc1 -cc1 -fno-implicit-modules -fmodule-map-file=Inputs/relative-dep-gen.modulemap -fmodule-file=%t/mod.pcm -dependency-file %t/use-explicit.d -MT use.o relative-dep-gen.cpp -fsyntax-only
-// RUN: %clang_cc1 -cc1 -fno-implicit-modules -fmodule-map-file=Inputs/relative-dep-gen.modulemap -dependency-file %t/use-implicit.d relative-dep-gen.cpp -MT use.o -fsyntax-only
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-name=relative-dep-gen -emit-module -x c++ Inputs/relative-dep-gen.modulemap -dependency-file %t/build.d -MT mod.pcm -o %t/mod.pcm
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-map-file=Inputs/relative-dep-gen.modulemap -fmodule-file=%t/mod.pcm -dependency-file %t/use-explicit.d -MT use.o relative-dep-gen.cpp -fsyntax-only
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodule-map-file=Inputs/relative-dep-gen.modulemap -dependency-file %t/use-implicit.d relative-dep-gen.cpp -MT use.o -fsyntax-only
//
// RUN: FileCheck --check-prefix=CHECK-BUILD %s < %t/build.d
-// RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-explicit.d
-// RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-implicit.d
+// RUN: FileCheck --check-prefix=CHECK-USE --check-prefix=CHECK-EXPLICIT %s < %t/use-explicit.d
+// RUN: FileCheck --check-prefix=CHECK-USE --check-prefix=CHECK-IMPLICIT %s < %t/use-implicit.d
//
-// RUN: %clang_cc1 -cc1 -fno-implicit-modules -fmodule-name=relative-dep-gen -emit-module -x c++ Inputs/relative-dep-gen-cwd.modulemap -dependency-file %t/build-cwd.d -MT mod.pcm -o %t/mod-cwd.pcm -fmodule-map-file-home-is-cwd
-// RUN: %clang_cc1 -cc1 -fno-implicit-modules -fmodule-map-file=Inputs/relative-dep-gen-cwd.modulemap -fmodule-file=%t/mod-cwd.pcm -dependency-file %t/use-explicit-cwd.d -MT use.o relative-dep-gen.cpp -fsyntax-only -fmodule-map-file-home-is-cwd
-// RUN: %clang_cc1 -cc1 -fno-implicit-modules -fmodule-map-file=Inputs/relative-dep-gen-cwd.modulemap -dependency-file %t/use-implicit-cwd.d relative-dep-gen.cpp -MT use.o -fsyntax-only -fmodule-map-file-home-is-cwd
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-name=relative-dep-gen -emit-module -x c++ Inputs/relative-dep-gen-cwd.modulemap -dependency-file %t/build-cwd.d -MT mod.pcm -o %t/mod-cwd.pcm -fmodule-map-file-home-is-cwd
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-map-file=Inputs/relative-dep-gen-cwd.modulemap -fmodule-file=%t/mod-cwd.pcm -dependency-file %t/use-explicit-cwd.d -MT use.o relative-dep-gen.cpp -fsyntax-only -fmodule-map-file-home-is-cwd
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodule-map-file=Inputs/relative-dep-gen-cwd.modulemap -dependency-file %t/use-implicit-cwd.d relative-dep-gen.cpp -MT use.o -fsyntax-only -fmodule-map-file-home-is-cwd
//
// RUN: FileCheck --check-prefix=CHECK-BUILD %s < %t/build-cwd.d
// RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-explicit-cwd.d
@@ -23,7 +23,7 @@
// RUN: cp %S/Inputs/relative-dep-gen-1.h %t/Inputs
// RUN: cp %s %t
// RUN: cd %t
-// RUN: %clang_cc1 -cc1 -fno-implicit-modules -fmodule-file=%t/mod-cwd.pcm -dependency-file %t/use-explicit-no-map-cwd.d -MT use.o relative-dep-gen.cpp -fsyntax-only -fmodule-map-file-home-is-cwd
+// RUN: %clang_cc1 -fmodules -fno-implicit-modules -fmodule-file=%t/mod-cwd.pcm -dependency-file %t/use-explicit-no-map-cwd.d -MT use.o relative-dep-gen.cpp -fsyntax-only -fmodule-map-file-home-is-cwd
// RUN: cat %t/use-explicit-no-map-cwd.d
// RUN: FileCheck --check-prefix=CHECK-USE %s < %t/use-explicit-no-map-cwd.d
@@ -35,4 +35,5 @@
// CHECK-BUILD: {{[ \t]}}Inputs/relative-dep-gen-2.h
// CHECK-USE: use.o:
// CHECK-USE-DAG: {{[ \t]}}relative-dep-gen.cpp
-// CHECK-USE-DAG: {{[ \t]}}Inputs{{[/\\]}}relative-dep-gen-1.h
+// CHECK-EXPLICIT-DAG: mod.pcm
+// CHECK-IMPLICIT-DAG: {{[ \t]}}Inputs{{[/\\]}}relative-dep-gen-1.h
More information about the cfe-commits
mailing list