vsapsai created this revision. vsapsai added reviewers: iains, rsmith, benlangmuir, arphaman. Herald added a subscriber: ributzka. Herald added a project: All. vsapsai requested review of this revision. Herald added a project: clang.
Diagnostic for `-Wauto-import` shouldn't be a warning because it doesn't represent a potential problem in code that should be fixed. And the emitted fix-it is likely to trigger `-Watimport-in-framework-header` which makes it challenging to have a warning-free codebase. But it is still useful to see how include directives are translated into modular imports and which module a header belongs to, that's why keep it as a remark. Keep `-Wauto-import` for now to allow a gradual migration for codebases using `-Wno-auto-import`, e.g., `-Weverything -Wno-auto-import`. rdar://79594287 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D130138 Files: clang/include/clang/Basic/DiagnosticGroups.td clang/include/clang/Basic/DiagnosticLexKinds.td clang/lib/Lex/PPDirectives.cpp clang/test/Modules/auto-module-import.m clang/test/Modules/conflicts.m clang/test/Modules/cxx20-include-translation.cpp clang/test/Modules/framework-name.m clang/test/Modules/global_index.m clang/test/Modules/implementation-of-module.m clang/test/Modules/inferred-frameworks.m clang/test/Modules/inferred-submodules.m clang/test/Modules/requires.m clang/test/Modules/requires.mm clang/test/Modules/resolution-change.m clang/test/Modules/subframeworks.m clang/test/Modules/submodules.m clang/test/VFS/real-path-found-first.m
Index: clang/test/VFS/real-path-found-first.m =================================================================== --- clang/test/VFS/real-path-found-first.m +++ clang/test/VFS/real-path-found-first.m @@ -11,13 +11,13 @@ // Build // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-cache -F %t \ -// RUN: -ivfsoverlay %t.yaml -fsyntax-only %s -verify -Wauto-import \ +// RUN: -ivfsoverlay %t.yaml -fsyntax-only %s -verify -Rmodule-include-translation \ // RUN: -Werror=non-modular-include-in-framework-module // Rebuild // RUN: echo ' ' >> %t/SomeFramework.framework/Modules/module.modulemap // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-cache -F %t \ -// RUN: -ivfsoverlay %t.yaml -fsyntax-only %s -verify -Wauto-import \ +// RUN: -ivfsoverlay %t.yaml -fsyntax-only %s -verify -Rmodule-include-translation \ // RUN: -Werror=non-modular-include-in-framework-module // Load from PCH @@ -32,11 +32,11 @@ // While indexing // RUN: c-index-test -index-file %s -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-cache -F %t \ -// RUN: -ivfsoverlay %t.yaml -fsyntax-only -Wauto-import \ +// RUN: -ivfsoverlay %t.yaml -fsyntax-only -Rmodule-include-translation \ // RUN: -Werror=non-modular-include-in-framework-module | FileCheck %s // RUN: echo ' ' >> %t/SomeFramework.framework/Modules/module.modulemap // RUN: c-index-test -index-file %s -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-cache -F %t \ -// RUN: -ivfsoverlay %t.yaml -fsyntax-only -Wauto-import \ +// RUN: -ivfsoverlay %t.yaml -fsyntax-only -Rmodule-include-translation \ // RUN: -Werror=non-modular-include-in-framework-module | FileCheck %s // CHECK: warning: treating // CHECK-NOT: error @@ -49,11 +49,11 @@ // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-cache -F %t \ // RUN: -ivfsoverlay %t.yaml -ivfsoverlay %t2.yaml -fsyntax-only %s -verify \ -// RUN: -Wauto-import -Werror=non-modular-include-in-framework-module +// RUN: -Rmodule-include-translation -Werror=non-modular-include-in-framework-module // RUN: echo ' ' >> %t/hide_module.map // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t-cache -F %t \ // RUN: -ivfsoverlay %t.yaml -ivfsoverlay %t2.yaml -fsyntax-only %s -verify \ -// RUN: -Wauto-import -Werror=non-modular-include-in-framework-module +// RUN: -Rmodule-include-translation -Werror=non-modular-include-in-framework-module // Within a module build // RUN: echo '@import import_some_frame;' | \ @@ -67,8 +67,8 @@ // RUN: -Werror=non-modular-include-in-framework-module -x objective-c -I %t #ifndef WITH_PREFIX -#import <SomeFramework/public_header.h> // expected-warning{{treating}} -#import <SomeFramework/public_header2.h> // expected-warning{{treating}} -#import <SomeFramework/public_header3.h> // expected-warning{{treating}} +#import <SomeFramework/public_header.h> // expected-remark{{treating}} +#import <SomeFramework/public_header2.h> // expected-remark{{treating}} +#import <SomeFramework/public_header3.h> // expected-remark{{treating}} @import SomeFramework.public_header2; #endif Index: clang/test/Modules/submodules.m =================================================================== --- clang/test/Modules/submodules.m +++ clang/test/Modules/submodules.m @@ -1,6 +1,6 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify +// RUN: %clang_cc1 -Rmodule-include-translation -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify // expected-no-diagnostics // Note: transitively imports Module.Sub2. Index: clang/test/Modules/subframeworks.m =================================================================== --- clang/test/Modules/subframeworks.m +++ clang/test/Modules/subframeworks.m @@ -1,6 +1,6 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s -verify -// RUN: %clang_cc1 -x objective-c++ -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s -verify +// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s -verify +// RUN: %clang_cc1 -x objective-c++ -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -F %S/Inputs/DependsOnModule.framework/Frameworks %s -verify @import DependsOnModule; @@ -24,7 +24,7 @@ @import HasSubModules; -// expected-warning@Inputs/HasSubModules.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h:1{{treating #include as an import of module 'HasSubModules.Sub.Types'}} +// expected-remark@Inputs/HasSubModules.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h:1{{treating #include as an import of module 'HasSubModules.Sub.Types'}} #import <HasSubModules/HasSubModulesPriv.h> struct FrameworkSubStruct ss; Index: clang/test/Modules/resolution-change.m =================================================================== --- clang/test/Modules/resolution-change.m +++ clang/test/Modules/resolution-change.m @@ -7,7 +7,7 @@ // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path1/A -include-pch %t-A.pch %s -fsyntax-only -Werror // Different -W options are ok -// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path1/A -include-pch %t-A.pch %s -fsyntax-only -Werror -Wauto-import +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path1/A -include-pch %t-A.pch %s -fsyntax-only -Werror -Rmodule-include-translation // Use the PCH with no way to resolve DependsOnA // RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -include-pch %t-A.pch %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-NODOA %s Index: clang/test/Modules/requires.mm =================================================================== --- clang/test/Modules/requires.mm +++ clang/test/Modules/requires.mm @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs/DependsOnModule.framework %s -verify +// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs/DependsOnModule.framework %s -verify @import DependsOnModule.CXX; // expected-er...@module.map:11 {{module 'DependsOnModule.NotCXX' is incompatible with feature 'cplusplus'}} Index: clang/test/Modules/requires.m =================================================================== --- clang/test/Modules/requires.m +++ clang/test/Modules/requires.m @@ -1,6 +1,6 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs %s -verify -fmodule-feature custom_req1 -// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs %s -verify -std=c89 -DTEST_C_FEATURES +// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs %s -verify -fmodule-feature custom_req1 +// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs %s -verify -std=c89 -DTEST_C_FEATURES #ifndef TEST_C_FEATURES // expected-error@DependsOnModule.framework/module.map:7 {{module 'DependsOnModule.CXX' requires feature 'cplusplus'}} @import DependsOnModule.CXX; // expected-note {{module imported here}} Index: clang/test/Modules/inferred-submodules.m =================================================================== --- clang/test/Modules/inferred-submodules.m +++ clang/test/Modules/inferred-submodules.m @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -x objective-c -Wauto-import -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify +// RUN: %clang_cc1 -x objective-c -Rmodule-include-translation -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify // expected-no-diagnostics @import Module.Sub; Index: clang/test/Modules/inferred-frameworks.m =================================================================== --- clang/test/Modules/inferred-frameworks.m +++ clang/test/Modules/inferred-frameworks.m @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -x objective-c -Wauto-import -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify +// RUN: %clang_cc1 -x objective-c -Rmodule-include-translation -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify #include <NotAModule/NotAModule.h> Index: clang/test/Modules/implementation-of-module.m =================================================================== --- clang/test/Modules/implementation-of-module.m +++ clang/test/Modules/implementation-of-module.m @@ -1,25 +1,25 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=auto-import %s -I %S/Inputs \ +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-include-translation %s -I %S/Inputs \ // RUN: -fmodule-implementation-of category_right -fsyntax-only -// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=auto-import %s -I %S/Inputs \ +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-include-translation %s -I %S/Inputs \ // RUN: -fmodule-implementation-of category_right -dM -E -o - 2>&1 | FileCheck %s // CHECK-NOT: __building_module -// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=auto-import %s -I %S/Inputs \ +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-include-translation %s -I %S/Inputs \ // RUN: -fmodule-implementation-of category_left -verify -// RUN: %clang_cc1 -x objective-c-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=auto-import %s -I %S/Inputs \ +// RUN: %clang_cc1 -x objective-c-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-include-translation %s -I %S/Inputs \ // RUN: -fmodule-implementation-of category_right -emit-pch -o %t.pch -// RUN: %clang_cc1 -x objective-c-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Werror=auto-import %s -I %S/Inputs \ +// RUN: %clang_cc1 -x objective-c-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-include-translation %s -I %S/Inputs \ // RUN: -DWITH_PREFIX -fmodules-ignore-macro=WITH_PREFIX -include-pch %t.pch -fmodule-implementation-of category_right #ifndef WITH_PREFIX @import category_left; // expected-error{{@import of module 'category_left' in implementation of 'category_left'; use #import}} @import category_left.sub; // expected-error{{@import of module 'category_left.sub' in implementation of 'category_left'; use #import}} -#import "category_right.h" // expected-error{{treating}} -#import "category_right_sub.h" // expected-error{{treating}} +#import "category_right.h" // expected-remark{{treating}} +#import "category_right_sub.h" // expected-remark{{treating}} #endif Index: clang/test/Modules/global_index.m =================================================================== --- clang/test/Modules/global_index.m +++ clang/test/Modules/global_index.m @@ -1,12 +1,12 @@ // RUN: rm -rf %t // Run without global module index -// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fdisable-module-hash -fmodules -fimplicit-module-maps -fno-modules-global-index -F %S/Inputs %s -verify +// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fdisable-module-hash -fmodules -fimplicit-module-maps -fno-modules-global-index -F %S/Inputs %s -verify // RUN: ls %t|not grep modules.idx // Run and create the global module index -// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fdisable-module-hash -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify +// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fdisable-module-hash -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify // RUN: ls %t|grep modules.idx // Run and use the global module index -// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fdisable-module-hash -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify -print-stats 2>&1 | FileCheck %s +// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fdisable-module-hash -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify -print-stats 2>&1 | FileCheck %s // expected-no-diagnostics @import DependsOnModule; Index: clang/test/Modules/framework-name.m =================================================================== --- clang/test/Modules/framework-name.m +++ clang/test/Modules/framework-name.m @@ -3,14 +3,14 @@ // RUN: mkdir -p %t // RUN: ln -s %S/Inputs/NameInDir2.framework %t/NameInImport.framework // RUN: ln -s %S/Inputs/NameInDirInferred.framework %t/NameInImportInferred.framework -// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.mcp -fimplicit-module-maps -I %S/Inputs -F %S/Inputs -F %t -Wauto-import -verify %s +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t.mcp -fimplicit-module-maps -I %S/Inputs -F %S/Inputs -F %t -Rmodule-include-translation -verify %s // Verify that we won't somehow find non-canonical module names or modules where // we shouldn't search the framework. -// RUN: echo '@import NameInModMap;' | not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -F %S/Inputs -F %t -Wauto-import -x objective-c - 2>&1 | FileCheck %s -// RUN: echo '@import NameInDir;' | not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -F %S/Inputs -F %t -Wauto-import -x objective-c - 2>&1 | FileCheck %s -// RUN: echo '@import NameInImport;' | not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -F %S/Inputs -F %t -Wauto-import -x objective-c - 2>&1 | FileCheck %s -// RUN: echo '@import NameInImportInferred;' | not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -F %S/Inputs -F %t -Wauto-import -x objective-c - 2>&1 | FileCheck %s +// RUN: echo '@import NameInModMap;' | not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -F %S/Inputs -F %t -Rmodule-include-translation -x objective-c - 2>&1 | FileCheck %s +// RUN: echo '@import NameInDir;' | not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -F %S/Inputs -F %t -Rmodule-include-translation -x objective-c - 2>&1 | FileCheck %s +// RUN: echo '@import NameInImport;' | not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -F %S/Inputs -F %t -Rmodule-include-translation -x objective-c - 2>&1 | FileCheck %s +// RUN: echo '@import NameInImportInferred;' | not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t.mcp -F %S/Inputs -F %t -Rmodule-include-translation -x objective-c - 2>&1 | FileCheck %s // CHECK: module '{{.*}}' not found // FIXME: We might want to someday lock down framework modules so that these @@ -18,14 +18,14 @@ // it's important that they map correctly to module imports. // The module map name doesn't match the directory name. -#import <NameInDir/NameInDir.h> // expected-warning {{import of module 'NameInModMap'}} +#import <NameInDir/NameInDir.h> // expected-remark {{import of module 'NameInModMap'}} // The name in the import doesn't match the module name. -#import <NameInImport/NameInDir2.h> // expected-warning {{import of module 'NameInDir2'}} +#import <NameInImport/NameInDir2.h> // expected-remark {{import of module 'NameInDir2'}} @import NameInDir2; // OK // The name in the import doesn't match the module name (inferred framework module). -#import <NameInImportInferred/NameInDirInferred.h> // expected-warning {{import of module 'NameInDirInferred'}} +#import <NameInImportInferred/NameInDirInferred.h> // expected-remark {{import of module 'NameInDirInferred'}} @import ImportNameInDir; #ifdef NAME_IN_DIR Index: clang/test/Modules/cxx20-include-translation.cpp =================================================================== --- clang/test/Modules/cxx20-include-translation.cpp +++ clang/test/Modules/cxx20-include-translation.cpp @@ -10,7 +10,7 @@ // RUN: %clang_cc1 -std=c++20 Xlate.cpp -emit-module-interface -o Xlate.pcm \ // RUN: -fmodule-file=h1.pcm -fmodule-file=h2.pcm -fmodule-file=h3.pcm \ -// RUN: -fmodule-file=h4.pcm -fsyntax-only -Wauto-import -verify +// RUN: -fmodule-file=h4.pcm -fsyntax-only -Rmodule-include-translation -verify // Check that we do the intended translation and not more. // RUN: %clang_cc1 -std=c++20 Xlate.cpp \ @@ -80,7 +80,7 @@ module /*nothing here*/; // This should be include-translated, when the header unit for h1 is available. -#include "h1.h" // expected-warning {{treating #include as an import of module './h1.h'}} +#include "h1.h" // expected-remark {{treating #include as an import of module './h1.h'}} // Import of a header unit is allowed, named modules are not. import "h2.h"; // A regular, untranslated, header Index: clang/test/Modules/conflicts.m =================================================================== --- clang/test/Modules/conflicts.m +++ clang/test/Modules/conflicts.m @@ -1,5 +1,5 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -Wauto-import -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/Conflicts %s -verify +// RUN: %clang_cc1 -Rmodule-include-translation -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/Conflicts %s -verify @import Conflicts; Index: clang/test/Modules/auto-module-import.m =================================================================== --- clang/test/Modules/auto-module-import.m +++ clang/test/Modules/auto-module-import.m @@ -1,12 +1,12 @@ // RUN: rm -rf %t -// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify -DERRORS -// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify -// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -xobjective-c++ %s -verify +// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify -DERRORS +// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs %s -verify +// RUN: %clang_cc1 -Rmodule-include-translation -Wno-private-module -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -F %S/Inputs -xobjective-c++ %s -verify // // Test both with and without the declarations that refer to unimported // entities. For error recovery, those cases implicitly trigger an import. -#include <DependsOnModule/DependsOnModule.h> // expected-warning{{treating #include as an import of module 'DependsOnModule'}} +#include <DependsOnModule/DependsOnModule.h> // expected-remark{{treating #include as an import of module 'DependsOnModule'}} #ifdef MODULE_H_MACRO # error MODULE_H_MACRO should have been hidden @@ -20,7 +20,7 @@ Module *mod; // expected-error{{declaration of 'Module' must be imported from module 'Module' before it is required}} // expected-note@Inputs/Module.framework/Headers/Module.h:15 {{not visible}} #else -#import <AlsoDependsOnModule/AlsoDependsOnModule.h> // expected-warning{{treating #import as an import of module 'AlsoDependsOnModule'}} +#import <AlsoDependsOnModule/AlsoDependsOnModule.h> // expected-remark{{treating #import as an import of module 'AlsoDependsOnModule'}} #endif Module *mod2; @@ -34,16 +34,16 @@ } // Test umbrella-less submodule includes -#include <NoUmbrella/A.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.A'}} +#include <NoUmbrella/A.h> // expected-remark{{treating #include as an import of module 'NoUmbrella.A'}} int getNoUmbrellaA(void) { return no_umbrella_A; } // Test umbrella-less submodule includes -#include <NoUmbrella/SubDir/C.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.SubDir.C'}} +#include <NoUmbrella/SubDir/C.h> // expected-remark{{treating #include as an import of module 'NoUmbrella.SubDir.C'}} int getNoUmbrellaC(void) { return no_umbrella_C; } #ifndef ERRORS // Test header cross-subframework include pattern. -#include <DependsOnModule/../Frameworks/SubFramework.framework/Headers/Other.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.SubFramework.Other'}} +#include <DependsOnModule/../Frameworks/SubFramework.framework/Headers/Other.h> // expected-remark{{treating #include as an import of module 'DependsOnModule.SubFramework.Other'}} #endif void testSubframeworkOtherAgain(void) { @@ -54,14 +54,14 @@ char *msf = module_subframework; } -#include <Module/../Frameworks/SubFramework.framework/Headers/SubFramework.h> // expected-warning{{treating #include as an import of module 'Module.SubFramework'}} +#include <Module/../Frameworks/SubFramework.framework/Headers/SubFramework.h> // expected-remark{{treating #include as an import of module 'Module.SubFramework'}} void testModuleSubFrameworkAgain(void) { char *msf = module_subframework; } // Test inclusion of private headers. -#include <DependsOnModule/DependsOnModulePrivate.h> // expected-warning{{treating #include as an import of module 'DependsOnModule.Private.DependsOnModule'}} +#include <DependsOnModule/DependsOnModulePrivate.h> // expected-remark{{treating #include as an import of module 'DependsOnModule.Private.DependsOnModule'}} int getDependsOnModulePrivate(void) { return depends_on_module_private; } @@ -69,7 +69,7 @@ int getModulePrivate(void) { return module_private; } -#include <NoUmbrella/A_Private.h> // expected-warning{{treating #include as an import of module 'NoUmbrella.Private.A_Private'}} +#include <NoUmbrella/A_Private.h> // expected-remark{{treating #include as an import of module 'NoUmbrella.Private.A_Private'}} int getNoUmbrellaAPrivate(void) { return no_umbrella_A_private; } int getNoUmbrellaBPrivateFail(void) { return no_umbrella_B_private; } // expected-error{{declaration of 'no_umbrella_B_private' must be imported from module 'NoUmbrella.Private.B_Private'}} @@ -77,7 +77,7 @@ // Test inclusion of headers that are under an umbrella directory but // not actually part of the module. -#include <Module/NotInModule.h> // expected-warning{{treating #include as an import of module 'Module.NotInModule'}} \ +#include <Module/NotInModule.h> // expected-remark{{treating #include as an import of module 'Module.NotInModule'}} \ // expected-warning{{missing submodule 'Module.NotInModule'}} int getNotInModule(void) { @@ -85,17 +85,17 @@ } void includeNotAtTopLevel(void) { // expected-note {{function 'includeNotAtTopLevel' begins here}} - #include <NoUmbrella/A.h> // expected-warning {{treating #include as an import}} \ + #include <NoUmbrella/A.h> // expected-remark {{treating #include as an import}} \ expected-error {{redundant #include of module 'NoUmbrella.A' appears within function 'includeNotAtTopLevel'}} } #ifdef __cplusplus namespace NS { // expected-note {{begins here}} -#include <NoUmbrella/A.h> // expected-warning {{treating #include as an import}} \ +#include <NoUmbrella/A.h> // expected-remark {{treating #include as an import}} \ expected-error {{redundant #include of module 'NoUmbrella.A' appears within namespace 'NS'}} } extern "C" { // expected-note {{begins here}} -#include <NoUmbrella/A.h> // expected-warning {{treating #include as an import}} \ +#include <NoUmbrella/A.h> // expected-remark {{treating #include as an import}} \ expected-error {{import of C++ module 'NoUmbrella.A' appears within extern "C"}} } #endif Index: clang/lib/Lex/PPDirectives.cpp =================================================================== --- clang/lib/Lex/PPDirectives.cpp +++ clang/lib/Lex/PPDirectives.cpp @@ -1806,22 +1806,14 @@ Preprocessor &PP, SourceLocation HashLoc, Token &IncludeTok, ArrayRef<std::pair<IdentifierInfo *, SourceLocation>> Path, SourceLocation PathEnd) { - StringRef ImportKeyword; - if (PP.getLangOpts().ObjC) - ImportKeyword = "@import"; - else if (PP.getLangOpts().ModulesTS || PP.getLangOpts().CPlusPlusModules) - ImportKeyword = "import"; - else - return; // no import syntax available - SmallString<128> PathString; for (size_t I = 0, N = Path.size(); I != N; ++I) { if (I) PathString += '.'; PathString += Path[I].first->getName(); } - int IncludeKind = 0; + int IncludeKind = 0; switch (IncludeTok.getIdentifierInfo()->getPPKeywordID()) { case tok::pp_include: IncludeKind = 0; @@ -1843,12 +1835,8 @@ llvm_unreachable("unknown include directive kind"); } - CharSourceRange ReplaceRange(SourceRange(HashLoc, PathEnd), - /*IsTokenRange=*/false); - PP.Diag(HashLoc, diag::warn_auto_module_import) - << IncludeKind << PathString - << FixItHint::CreateReplacement( - ReplaceRange, (ImportKeyword + " " + PathString + ";").str()); + PP.Diag(HashLoc, diag::remark_pp_include_directive_modular_translation) + << IncludeKind << PathString; } // Given a vector of path components and a string containing the real Index: clang/include/clang/Basic/DiagnosticLexKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticLexKinds.td +++ clang/include/clang/Basic/DiagnosticLexKinds.td @@ -851,9 +851,9 @@ "public framework header includes private framework header '%0'" >, InGroup<FrameworkIncludePrivateFromPublic>; -def warn_auto_module_import : Warning< +def remark_pp_include_directive_modular_translation : Remark< "treating #%select{include|import|include_next|__include_macros}0 as an " - "import of module '%1'">, InGroup<AutoImport>, DefaultIgnore; + "import of module '%1'">, InGroup<ModuleIncludeDirectiveTranslation>; def note_implicit_top_level_module_import_here : Note< "submodule of top-level module '%0' implicitly imported here">; def warn_uncovered_module_header : Warning< Index: clang/include/clang/Basic/DiagnosticGroups.td =================================================================== --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -35,7 +35,7 @@ def AutoDisableVptrSanitizer : DiagGroup<"auto-disable-vptr-sanitizer">; def Availability : DiagGroup<"availability">; def Section : DiagGroup<"section">; -def AutoImport : DiagGroup<"auto-import">; +def : DiagGroup<"auto-import">; def FrameworkHdrQuotedInclude : DiagGroup<"quoted-include-in-framework-header">; def FrameworkIncludePrivateFromPublic : DiagGroup<"framework-include-private-from-public">; @@ -490,6 +490,7 @@ def ModuleImport : DiagGroup<"module-import">; def ModuleConflict : DiagGroup<"module-conflict">; def ModuleFileExtension : DiagGroup<"module-file-extension">; +def ModuleIncludeDirectiveTranslation : DiagGroup<"module-include-translation">; def RoundTripCC1Args : DiagGroup<"round-trip-cc1-args">; def NewlineEOF : DiagGroup<"newline-eof">; def Nullability : DiagGroup<"nullability">;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits