[PATCH] D114173: [clang][modules] Apply local submodule visibility to includes
Jan Svoboda via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 17 13:39:26 PDT 2023
jansvoboda11 updated this revision to Diff 541218.
jansvoboda11 edited the summary of this revision.
jansvoboda11 added a comment.
Rebase on top of D155503 <https://reviews.llvm.org/D155503>.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114173/new/
https://reviews.llvm.org/D114173
Files:
clang/include/clang/Lex/Preprocessor.h
clang/test/Modules/import-textual-noguard.mm
Index: clang/test/Modules/import-textual-noguard.mm
===================================================================
--- clang/test/Modules/import-textual-noguard.mm
+++ clang/test/Modules/import-textual-noguard.mm
@@ -1,7 +1,9 @@
// RUN: rm -rf %t
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -fmodules -fimplicit-module-maps -I%S/Inputs/import-textual/M2 -fmodules-cache-path=%t -x objective-c++ -fmodules-local-submodule-visibility %s -verify
-#include "A/A.h" // expected-error {{could not build module 'M'}}
+// expected-no-diagnostics
+
+#include "A/A.h"
#include "B/B.h"
typedef aint xxx;
Index: clang/include/clang/Lex/Preprocessor.h
===================================================================
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -976,6 +976,9 @@
/// The macros for the submodule.
MacroMap Macros;
+ /// The set of files that have been included in the submodule.
+ IncludedFilesSet IncludedFiles;
+
/// The set of modules that are visible within the submodule.
VisibleModuleSet VisibleModules;
@@ -995,9 +998,6 @@
/// Files included outside of any module (e.g. in PCH) have nullptr key.
llvm::DenseMap<Module *, IncludedFilesSet> IncludedFilesPerSubmodule;
- /// The files that have been included.
- IncludedFilesSet IncludedFiles;
-
/// The set of top-level modules that affected preprocessing, but were not
/// imported.
llvm::SmallSetVector<Module *, 2> AffectingClangModules;
@@ -1486,7 +1486,7 @@
/// of its dependencies (transitively).
void markTransitivelyIncluded(const FileEntry *File) {
HeaderInfo.getFileInfo(File);
- IncludedFiles.insert(File);
+ CurSubmoduleState->IncludedFiles.insert(File);
}
/// Mark the file as included in the current state and attribute it to the
@@ -1500,13 +1500,13 @@
: getCurrentModule();
IncludedFilesPerSubmodule[M].insert(File);
- return IncludedFiles.insert(File).second;
+ return CurSubmoduleState->IncludedFiles.insert(File).second;
}
/// Return true if this header has already been included.
bool alreadyIncluded(const FileEntry *File) const {
HeaderInfo.getFileInfo(File);
- return IncludedFiles.count(File);
+ return CurSubmoduleState->IncludedFiles.count(File);
}
/// Invoke the callback for every module known to include the given file.
@@ -1523,9 +1523,10 @@
return IncludedFilesPerSubmodule[M];
}
- /// Get the set of included files.
- IncludedFilesSet &getIncludedFiles() { return IncludedFiles; }
- const IncludedFilesSet &getIncludedFiles() const { return IncludedFiles; }
+ /// Get the set of files included in the current state.
+ IncludedFilesSet &getIncludedFiles() {
+ return CurSubmoduleState->IncludedFiles;
+ }
/// Return the name of the macro defined before \p Loc that has
/// spelling \p Tokens. If there are multiple macros with same spelling,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114173.541218.patch
Type: text/x-patch
Size: 2957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230717/e961e120/attachment.bin>
More information about the cfe-commits
mailing list