r355477 - Modules: Add -Rmodule-import
Duncan P. N. Exon Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 5 18:50:46 PST 2019
Author: dexonsmith
Date: Tue Mar 5 18:50:46 2019
New Revision: 355477
URL: http://llvm.org/viewvc/llvm-project?rev=355477&view=rev
Log:
Modules: Add -Rmodule-import
Add a remark for importing modules. Depending on whether this is a
direct import (into the TU being built by this compiler instance) or
transitive import (into an already-imported module), the diagnostic has
two forms:
importing module 'Foo' from 'path/to/Foo.pcm'
importing module 'Foo' into 'Bar' from 'path/to/Foo.pcm'
Also drop a redundant FileCheck invocation in Rmodule-build.m that was
using -Reverything, since the notes from -Rmodule-import were confusing
it.
https://reviews.llvm.org/D58891
Added:
cfe/trunk/test/Modules/Inputs/Rmodule-import/
cfe/trunk/test/Modules/Inputs/Rmodule-import/A.h
cfe/trunk/test/Modules/Inputs/Rmodule-import/B.h
cfe/trunk/test/Modules/Inputs/Rmodule-import/C.h
cfe/trunk/test/Modules/Inputs/Rmodule-import/D.h
cfe/trunk/test/Modules/Inputs/Rmodule-import/module.modulemap
cfe/trunk/test/Modules/Rmodule-import.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/Rmodule-build.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=355477&r1=355476&r2=355477&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Mar 5 18:50:46 2019
@@ -351,6 +351,7 @@ def MismatchedReturnTypes : DiagGroup<"m
def MismatchedTags : DiagGroup<"mismatched-tags">;
def MissingFieldInitializers : DiagGroup<"missing-field-initializers">;
def ModuleBuild : DiagGroup<"module-build">;
+def ModuleImport : DiagGroup<"module-import">;
def ModuleConflict : DiagGroup<"module-conflict">;
def ModuleFileExtension : DiagGroup<"module-file-extension">;
def NewlineEOF : DiagGroup<"newline-eof">;
Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=355477&r1=355476&r2=355477&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Tue Mar 5 18:50:46 2019
@@ -72,6 +72,10 @@ def note_module_file_imported_by : Note<
def err_module_file_not_module : Error<
"AST file '%0' was not built as a module">, DefaultFatal;
+def remark_module_import : Remark<
+ "importing module '%0'%select{| into '%3'}2 from '%1'">,
+ InGroup<ModuleImport>;
+
def err_imported_module_not_found : Error<
"module '%0' in AST file '%1' (imported by AST file '%2') "
"is not defined in any loaded module map file; "
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=355477&r1=355476&r2=355477&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Mar 5 18:50:46 2019
@@ -2610,6 +2610,9 @@ ASTReader::ReadControlBlock(ModuleFile &
case MODULE_NAME:
F.ModuleName = Blob;
+ Diag(diag::remark_module_import)
+ << F.ModuleName << F.FileName << (ImportedBy ? true : false)
+ << (ImportedBy ? StringRef(ImportedBy->ModuleName) : StringRef());
if (Listener)
Listener->ReadModuleName(F.ModuleName);
@@ -4141,6 +4144,9 @@ ASTReader::ReadASTCore(StringRef FileNam
switch (AddResult) {
case ModuleManager::AlreadyLoaded:
+ Diag(diag::remark_module_import)
+ << M->ModuleName << M->FileName << (ImportedBy ? true : false)
+ << (ImportedBy ? StringRef(ImportedBy->ModuleName) : StringRef());
return Success;
case ModuleManager::NewlyLoaded:
Added: cfe/trunk/test/Modules/Inputs/Rmodule-import/A.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/Rmodule-import/A.h?rev=355477&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/Rmodule-import/A.h (added)
+++ cfe/trunk/test/Modules/Inputs/Rmodule-import/A.h Tue Mar 5 18:50:46 2019
@@ -0,0 +1,2 @@
+// A
+#include "B.h"
Added: cfe/trunk/test/Modules/Inputs/Rmodule-import/B.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/Rmodule-import/B.h?rev=355477&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/Rmodule-import/B.h (added)
+++ cfe/trunk/test/Modules/Inputs/Rmodule-import/B.h Tue Mar 5 18:50:46 2019
@@ -0,0 +1,2 @@
+// B
+#include "C.h"
Added: cfe/trunk/test/Modules/Inputs/Rmodule-import/C.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/Rmodule-import/C.h?rev=355477&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/Rmodule-import/C.h (added)
+++ cfe/trunk/test/Modules/Inputs/Rmodule-import/C.h Tue Mar 5 18:50:46 2019
@@ -0,0 +1 @@
+// C
Added: cfe/trunk/test/Modules/Inputs/Rmodule-import/D.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/Rmodule-import/D.h?rev=355477&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/Rmodule-import/D.h (added)
+++ cfe/trunk/test/Modules/Inputs/Rmodule-import/D.h Tue Mar 5 18:50:46 2019
@@ -0,0 +1 @@
+// D
Added: cfe/trunk/test/Modules/Inputs/Rmodule-import/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/Rmodule-import/module.modulemap?rev=355477&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/Rmodule-import/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/Rmodule-import/module.modulemap Tue Mar 5 18:50:46 2019
@@ -0,0 +1,4 @@
+module A { header "A.h" }
+module B { header "B.h" }
+module C { header "C.h" }
+module D { header "D.h" }
Modified: cfe/trunk/test/Modules/Rmodule-build.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Rmodule-build.m?rev=355477&r1=355476&r2=355477&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Rmodule-build.m (original)
+++ cfe/trunk/test/Modules/Rmodule-build.m Tue Mar 5 18:50:46 2019
@@ -19,10 +19,6 @@
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fsyntax-only %s -I %t \
// RUN: -Rmodule-build 2>&1 | FileCheck %s
-// RUN: echo ' ' >> %t/C.h
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fsyntax-only %s -I %t \
-// RUN: -Reverything 2>&1 | FileCheck %s
-
// RUN: echo ' ' >> %t/B.h
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -fsyntax-only %s -I %t \
// RUN: 2>&1 | FileCheck -allow-empty -check-prefix=NO-REMARKS %s
Added: cfe/trunk/test/Modules/Rmodule-import.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Rmodule-import.m?rev=355477&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Rmodule-import.m (added)
+++ cfe/trunk/test/Modules/Rmodule-import.m Tue Mar 5 18:50:46 2019
@@ -0,0 +1,46 @@
+// RUN: rm -rf %t1 %t2
+
+// Run with -verify, which onliy gets remarks from the main TU.
+//
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t1 \
+// RUN: -fdisable-module-hash -fsyntax-only -I%S/Inputs/Rmodule-import \
+// RUN: -Rmodule-build -Rmodule-import -verify %s
+
+// Run again, using FileCheck to check remarks from the module builds.
+//
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t2 \
+// RUN: -fdisable-module-hash -fsyntax-only -I%S/Inputs/Rmodule-import \
+// RUN: -Rmodule-build -Rmodule-import %s 2>&1 |\
+// RUN: FileCheck %s -implicit-check-not "remark:"
+
+#include "A.h" // \
+ expected-remark-re{{building module 'A' as '{{.*}}/A.pcm'}} \
+ expected-remark{{finished building module 'A'}} \
+ expected-remark-re{{importing module 'A' from '{{.*}}/A.pcm'}} \
+ expected-remark-re{{importing module 'B' into 'A' from '{{.*}}/B.pcm'}} \
+ expected-remark-re{{importing module 'C' into 'B' from '{{.*}}/C.pcm'}}
+// CHECK: remark: building module 'A'
+// CHECK: remark: building module 'B'
+// CHECK: remark: building module 'C'
+// CHECK: remark: finished building module 'C'
+// CHECK: remark: importing module 'C' from '{{.*}}/C.pcm'
+// CHECK: remark: finished building module 'B'
+// CHECK: remark: importing module 'B' from '{{.*}}/B.pcm'
+// CHECK: remark: importing module 'C' into 'B' from '{{.*}}/C.pcm'
+// CHECK: remark: finished building module 'A'
+// CHECK: remark: importing module 'A' from '{{.*}}/A.pcm'
+// CHECK: remark: importing module 'B' into 'A' from '{{.*}}/B.pcm'
+// CHECK: remark: importing module 'C' into 'B' from '{{.*}}/C.pcm'
+#include "B.h" // \
+ expected-remark-re{{importing module 'B' from '{{.*}}/B.pcm'}}
+// CHECK: remark: importing module 'B' from '{{.*}}/B.pcm'
+#include "C.h" // \
+ expected-remark-re{{importing module 'C' from '{{.*}}/C.pcm'}}
+// CHECK: remark: importing module 'C' from '{{.*}}/C.pcm'
+ at import D; // \
+ expected-remark-re{{building module 'D' as '{{.*}}/D.pcm'}} \
+ expected-remark{{finished building module 'D'}} \
+ expected-remark-re{{importing module 'D' from '{{.*}}/D.pcm'}}
+// CHECK: remark: building module 'D'
+// CHECK: remark: finished building module 'D'
+// CHECK: remark: importing module 'D' from '{{.*}}/D.pcm'
More information about the cfe-commits
mailing list