aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorVolodymyr Sapsai <vsapsai@apple.com>2022-07-19 14:27:02 -0700
committerVolodymyr Sapsai <vsapsai@apple.com>2022-07-21 17:42:04 -0700
commit381fcaa1365b4fd8f9682a6a1e09f5b3fd4bbfc2 (patch)
tree5e13e6c45ef3460bb881a15b356d1af19fb85788 /clang/lib
parent98186def3f1f6f3862e6c91ca01dfd278ad1929e (diff)
downloadllvm-381fcaa1365b4fd8f9682a6a1e09f5b3fd4bbfc2.zip
llvm-381fcaa1365b4fd8f9682a6a1e09f5b3fd4bbfc2.tar.gz
llvm-381fcaa1365b4fd8f9682a6a1e09f5b3fd4bbfc2.tar.bz2
[modules] Replace `-Wauto-import` with `-Rmodule-include-translation`.
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 Differential Revision: https://reviews.llvm.org/D130138
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Lex/PPDirectives.cpp18
1 files changed, 3 insertions, 15 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 352e1f2..4679cb4 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -1806,22 +1806,14 @@ static void diagnoseAutoModuleImport(
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 @@ static void diagnoseAutoModuleImport(
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