[clang] a2dd613 - [clang][Modules] Fix a regression in handling missing framework headers.
Iain Sandoe via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 19 01:13:40 PDT 2022
Author: Iain Sandoe
Date: 2022-08-19T09:13:22+01:00
New Revision: a2dd6130d49777d63c2d1b641bd8e56f26fa0822
URL: https://github.com/llvm/llvm-project/commit/a2dd6130d49777d63c2d1b641bd8e56f26fa0822
DIFF: https://github.com/llvm/llvm-project/commit/a2dd6130d49777d63c2d1b641bd8e56f26fa0822.diff
LOG: [clang][Modules] Fix a regression in handling missing framework headers.
The commit of af2d11b1d5c1508b506825df460656e0151cd3b0 missed a case where
the value of a suggested module needed to be reset to nullptr. Fixed thus
and added a testcase to cover the circumstance.
Added:
clang/test/Modules/missing-framework-header.cpp
Modified:
clang/lib/Lex/PPDirectives.cpp
Removed:
################################################################################
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 08ac45710e048..97d0bba1ea2e1 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -2286,6 +2286,7 @@ Preprocessor::ImportAction Preprocessor::HandleHeaderIncludeOrImport(
// actual module containing it exists (because the umbrella header is
// incomplete). Treat this as a textual inclusion.
SuggestedModule = ModuleMap::KnownHeader();
+ SM = nullptr;
} else if (Imported.isConfigMismatch()) {
// On a configuration mismatch, enter the header textually. We still know
// that it's part of the corresponding module.
diff --git a/clang/test/Modules/missing-framework-header.cpp b/clang/test/Modules/missing-framework-header.cpp
new file mode 100644
index 0000000000000..b618451bd3214
--- /dev/null
+++ b/clang/test/Modules/missing-framework-header.cpp
@@ -0,0 +1,27 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: split-file %s %t
+
+//--- frameworks/FW.framework/Modules/module.modulemap
+framework module FW {
+ umbrella header "FW.h"
+ module * { export * }
+}
+
+//--- frameworks/FW.framework/Headers/FW.h
+#include "One.h"
+//--- frameworks/FW.framework/Headers/One.h
+//--- frameworks/FW.framework/Headers/Two.h
+
+//--- module.modulemap
+module Mod { header "Mod.h" }
+//--- Mod.h
+#include "FW/Two.h"
+//--- from_module.m
+#include "Mod.h"
+
+// RUN: %clang -fmodules -fmodules-cache-path=%t/cache \
+// RUN: -iframework %t/frameworks -c %t/from_module.m -o %t/from_module.o \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK: warning: missing submodule 'FW.Two'
+
More information about the cfe-commits
mailing list