https://github.com/cyndyishida created 
https://github.com/llvm/llvm-project/pull/231244

This reverts commit dd3534fd5af15575d0d8dea116740b2abb8f3328.

Which effectively re-enables relocation checking after the underlying issue has 
been addressed in d397ab3cacd6

>From c196c8e23743d74035bf5f9dd6fd5fc9e99164d3 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida <[email protected]>
Date: Mon, 12 Oct 2026 10:04:02 -0700
Subject: [PATCH] Revert "[clang][DepScan] Disable relocation checks (#225563)"

This reverts commit dd3534fd5af15575d0d8dea116740b2abb8f3328.

Which effectively re-enables relocation checking after the underlying
issue has been addressed in d397ab3cacd6
---
 .../DependencyScanningWorker.cpp              |  3 -
 ...ild-session-validation-relocated-modules.c | 71 +++++++++++++++++++
 .../modules-relocated-mm-macro.c              | 15 ++--
 3 files changed, 77 insertions(+), 12 deletions(-)
 create mode 100644 
clang/test/ClangScanDeps/build-session-validation-relocated-modules.c

diff --git a/clang/lib/DependencyScanning/DependencyScanningWorker.cpp 
b/clang/lib/DependencyScanning/DependencyScanningWorker.cpp
index 8ab67e150bb5d..1196369174e9b 100644
--- a/clang/lib/DependencyScanning/DependencyScanningWorker.cpp
+++ b/clang/lib/DependencyScanning/DependencyScanningWorker.cpp
@@ -432,9 +432,6 @@ createScanCompilerInvocation(const CompilerInvocation 
&Invocation,
       true;
   ScanInvocation->getHeaderSearchOpts().ModulesForceValidateUserHeaders = 
false;
 
-  // Avoid some checks and module map parsing when loading PCM files.
-  ScanInvocation->getPreprocessorOpts().ModulesCheckRelocated = false;
-
   // FIXME: Do this even with PCHs by marking the option as something like
   // "preprocessor benign" in LangOptions.def so that it passes the
   // compatibility checks in ASTReader.
diff --git 
a/clang/test/ClangScanDeps/build-session-validation-relocated-modules.c 
b/clang/test/ClangScanDeps/build-session-validation-relocated-modules.c
new file mode 100644
index 0000000000000..93f9d37cb00d1
--- /dev/null
+++ b/clang/test/ClangScanDeps/build-session-validation-relocated-modules.c
@@ -0,0 +1,71 @@
+// Check that a relocated module is rebuilt and no error occurs. 
+// This is required when a incremental build adds a newer version of an 
+//    already built library into a preexisting search path.
+// In this example, on the second scan, `DepThatLoadsOldPCMs` is resolved 
first and 
+//    populates `MovedDep` into memory. 
+//  Then when `InvalidatedDep` is loaded, it's input file is out of date 
+//    and requires a rebuild.
+// When that happens the compiler notices `MovedDep` is in a earlier search 
path.
+
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/compile-commands.json.in > 
%t/compile-commands.json
+
+// RUN: clang-scan-deps -format experimental-full -j 1 \
+// RUN:   -compilation-database %t/compile-commands.json -o %t/deps1.json 
+// RUN: cat %t/deps1.json | FileCheck %s --check-prefix=DEPS1 
+
+// Model update where same framework appears in earlier search path.
+// This can occur on an incremental build where dependency relationships are 
updated.
+// RUN: sleep 1
+// RUN: mkdir %t/preferred_frameworks/
+// RUN: cp -R %t/fallback_frameworks/MovedDep.framework 
%t/preferred_frameworks/
+// RUN: touch 
%t/fallback_frameworks/InvalidatedDep.framework/Modules/module.modulemap
+
+// RUN: clang-scan-deps -format experimental-full -j 1 \
+// RUN:   -compilation-database %t/compile-commands.json -o %t/deps2.json
+// RUN: cat %t/deps2.json | FileCheck %s --check-prefix=DEPS2
+
+// DEPS1: "clang-module-deps": [],
+// DEPS1-NEXT: "clang-modulemap-file": 
"{{.*}}fallback_frameworks{{.*}}MovedDep.framework
+// DEPS1: "name": "MovedDep"
+
+// DEPS2: "clang-module-deps": [],
+// DEPS2-NEXT: "clang-modulemap-file": 
"{{.*}}preferred_frameworks{{.*}}MovedDep.framework
+// DEPS2: "name": "MovedDep"
+
+//--- compile-commands.json.in
+[
+{
+  "directory": "DIR",
+  "command": "clang -c DIR/tu1.c -fmodules -fmodules-cache-path=DIR/cache 
-FDIR/preferred_frameworks -FDIR/fallback_frameworks  
-fbuild-session-file=DIR/session.timestamp 
-fmodules-validate-once-per-build-session -o DIR/tu1.o ",
+  "file": "DIR/tu1.c"                                                          
             
+}
+]
+
+//--- session.timestamp
+
+//--- fallback_frameworks/MovedDep.framework/Modules/module.modulemap
+framework module MovedDep { header "MovedDep.h" }
+//--- fallback_frameworks/MovedDep.framework/Headers/MovedDep.h
+int foo(void);
+
+//--- fallback_frameworks/InvalidatedDep.framework/Modules/module.modulemap
+framework module InvalidatedDep { header "InvalidatedDep.h" }
+//--- fallback_frameworks/InvalidatedDep.framework/Headers/InvalidatedDep.h
+#include <MovedDep/MovedDep.h>
+
+//--- fallback_frameworks/DirectDep.framework/Modules/module.modulemap
+framework module DirectDep { header "DirectDep.h" }
+//--- fallback_frameworks/DirectDep.framework/Headers/DirectDep.h
+#include <DepThatLoadsOldPCMs/DepThatLoadsOldPCMs.h>
+#include <InvalidatedDep/InvalidatedDep.h>
+
+//--- 
fallback_frameworks/DepThatLoadsOldPCMs.framework/Modules/module.modulemap
+framework module DepThatLoadsOldPCMs { header "DepThatLoadsOldPCMs.h" }
+//--- 
fallback_frameworks/DepThatLoadsOldPCMs.framework/Headers/DepThatLoadsOldPCMs.h
+#include <MovedDep/MovedDep.h>
+
+//--- tu1.c
+#include <DirectDep/DirectDep.h>
diff --git a/clang/test/ClangScanDeps/modules-relocated-mm-macro.c 
b/clang/test/ClangScanDeps/modules-relocated-mm-macro.c
index 6e69f7550d1ea..c5337ce612124 100644
--- a/clang/test/ClangScanDeps/modules-relocated-mm-macro.c
+++ b/clang/test/ClangScanDeps/modules-relocated-mm-macro.c
@@ -1,5 +1,5 @@
 // This test checks that we don't crash when we load two conflicting PCM files
-// and instead emit the appropriate diagnostics.
+// and instead use the newer copy.
 
 // RUN: rm -rf %t
 // RUN: split-file %s %t
@@ -13,14 +13,11 @@
 
 // RUN: cp -R %t/frameworks2/A.framework %t/frameworks1
 
-// RUN: not clang-scan-deps -format experimental-full -o %t/deps2.json 
2>%t/errs -- \
+// RUN: clang-scan-deps -format experimental-full -o %t/deps2.json 2>&1 -- \
 // RUN:   %clang -fmodules -fmodules-cache-path=%t/cache \
 // RUN:   -F %t/frameworks1 -F %t/frameworks2 \
-// RUN:   -c %t/tu2.m -o %t/tu2.o
-// RUN: FileCheck --input-file=%t/errs %s
-
-// CHECK:      fatal error: module 'A' is defined in both '{{.*}}.pcm' and 
'{{.*}}.pcm'
-// CHECK-NEXT: note: compiled from '{{.*}}frameworks1{{.*}}' and 
'{{.*}}frameworks2{{.*}}'
+// RUN:   -c %t/tu2.m -o %t/tu2.o \
+// RUN: | FileCheck %s --allow-empty --implicit-check-not="warning"
 
 //--- frameworks2/A.framework/Modules/module.modulemap
 framework module A { header "A.h" }
@@ -37,7 +34,7 @@ framework module B { header "B.h" }
 
 //--- tu2.m
 #include <A/A.h>
-#include <B/B.h> // This results in a conflict and a fatal loader error.
+#include <B/B.h> // This results in a rebuild of B. 
 
-#if MACRO_A // This crashes with lexer that does not respect `cutOfLexing()`.
+#if MACRO_A // This previously crashed with lexer that does not respect 
`cutOfLexing()`.
 #endif

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to