[PATCH] D89886: [clang-tidy] Fix redefinition of module in the same module.modulemap file

Dmitry Polukhin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 21 07:59:01 PDT 2020


DmitryPolukhin created this revision.
DmitryPolukhin added reviewers: alexfh, gribozavr, klimek.
DmitryPolukhin added a project: clang-tools-extra.
Herald added subscribers: kbarton, xazax.hun, nemanjai.
Herald added a project: clang.
DmitryPolukhin requested review of this revision.

In memory VFS cannot handle aceesssing the same file with different paths.
This diff just stops using VFS for modulemap files.

Fixes PR47839


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89886

Files:
  clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp


Index: clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
===================================================================
--- clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
+++ clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
@@ -13,13 +13,20 @@
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Serialization/ASTReader.h"
 
+#define DEBUG_TYPE "clang-tidy"
+
 namespace clang {
 namespace tooling {
 
 class ExpandModularHeadersPPCallbacks::FileRecorder {
 public:
   /// Records that a given file entry is needed for replaying callbacks.
-  void addNecessaryFile(const FileEntry *File) { FilesToRecord.insert(File); }
+  void addNecessaryFile(const FileEntry *File) {
+    // Don't record module.modulemap files because it breaks same file
+    // detection.
+    if (!File->getName().endswith("module.modulemap"))
+      FilesToRecord.insert(File);
+  }
 
   /// Records content for a file and adds it to the FileSystem.
   void recordFileContent(const FileEntry *File,
@@ -44,8 +51,8 @@
   /// `FilesToRecord` should be empty.
   void checkAllFilesRecorded() {
     for (auto FileEntry : FilesToRecord)
-      llvm::errs() << "Did not record contents for input file: "
-                   << FileEntry->getName() << "\n";
+      LLVM_DEBUG(llvm::dbgs() << "Did not record contents for input file: "
+                              << FileEntry->getName() << "\n");
   }
 
 private:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89886.299694.patch
Type: text/x-patch
Size: 1448 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201021/b92925f7/attachment.bin>


More information about the cfe-commits mailing list