[clang-tools-extra] 55a2dee - [clang-tidy] Fix redefinition of module in the same module.modulemap file

Dmitry Polukhin via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 23 05:20:36 PDT 2020


Author: Dmitry Polukhin
Date: 2020-10-23T13:20:18+01:00
New Revision: 55a2deed075b87646db62abc7bcd476541eda403

URL: https://github.com/llvm/llvm-project/commit/55a2deed075b87646db62abc7bcd476541eda403
DIFF: https://github.com/llvm/llvm-project/commit/55a2deed075b87646db62abc7bcd476541eda403.diff

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

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

Fixes PR47839

Differential Revision: https://reviews.llvm.org/D89886

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
index 4299baedd79f..9e693b62e50d 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
@@ -13,13 +13,22 @@
 #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 modulemap files because it breaks same file detection.
+    if (!(File->getName().endswith("module.modulemap") ||
+          File->getName().endswith("module.private.modulemap") ||
+          File->getName().endswith("module.map") ||
+          File->getName().endswith("module_private.map")))
+      FilesToRecord.insert(File);
+  }
 
   /// Records content for a file and adds it to the FileSystem.
   void recordFileContent(const FileEntry *File,
@@ -44,8 +53,8 @@ class ExpandModularHeadersPPCallbacks::FileRecorder {
   /// `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:


        


More information about the cfe-commits mailing list