r223724 - [modules] If the same .pcm file is imported via two different paths, don't

Richard Smith richard-llvm at metafoo.co.uk
Mon Dec 8 16:14:37 PST 2014


Author: rsmith
Date: Mon Dec  8 18:14:36 2014
New Revision: 223724

URL: http://llvm.org/viewvc/llvm-project?rev=223724&view=rev
Log:
[modules] If the same .pcm file is imported via two different paths, don't
complain that the contained modules are defined twice.

Added:
    cfe/trunk/test/Modules/explicit-build-relpath.cpp
Modified:
    cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=223724&r1=223723&r2=223724&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Dec  8 18:14:36 2014
@@ -1300,7 +1300,9 @@ bool CompilerInstance::loadModuleFile(St
         TopFileIsModule = true;
 
       auto &ModuleFile = CI.ModuleFileOverrides[ModuleName];
-      if (!ModuleFile.empty() && ModuleFile != ModuleFileStack.back())
+      if (!ModuleFile.empty() &&
+          CI.getFileManager().getFile(ModuleFile) !=
+              CI.getFileManager().getFile(ModuleFileStack.back()))
         CI.getDiagnostics().Report(SourceLocation(),
                                    diag::err_conflicting_module_files)
             << ModuleName << ModuleFile << ModuleFileStack.back();

Added: cfe/trunk/test/Modules/explicit-build-relpath.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/explicit-build-relpath.cpp?rev=223724&view=auto
==============================================================================
--- cfe/trunk/test/Modules/explicit-build-relpath.cpp (added)
+++ cfe/trunk/test/Modules/explicit-build-relpath.cpp Mon Dec  8 18:14:36 2014
@@ -0,0 +1,49 @@
+// REQUIRES: shell
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cd %t
+
+// ----------------------
+// Build modules A and B.
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-name=a -emit-module %S/Inputs/explicit-build/module.modulemap -o a.pcm
+//
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-file=a.pcm \
+// RUN:            -fmodule-name=b -emit-module %S/Inputs/explicit-build/module.modulemap -o b-rel.pcm
+//
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -fmodule-file=%t/a.pcm \
+// RUN:            -fmodule-name=b -emit-module %S/Inputs/explicit-build/module.modulemap -o b-abs.pcm
+
+// ------------------------------------------
+// Mix and match relative and absolute paths.
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -I%S/Inputs/explicit-build \
+// RUN:            -fmodule-file=%t/a.pcm \
+// RUN:            -fmodule-file=a.pcm \
+// RUN:            -verify %s
+//
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -I%S/Inputs/explicit-build \
+// RUN:            -fmodule-file=%t/a.pcm \
+// RUN:            -fmodule-file=b-rel.pcm \
+// RUN:            -verify %s
+//
+// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -I%S/Inputs/explicit-build \
+// RUN:            -fmodule-file=a.pcm \
+// RUN:            -fmodule-file=b-abs.pcm \
+// RUN:            -verify %s
+//
+// RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \
+// RUN:            -I%S/Inputs/explicit-build \
+// RUN:            -fmodule-file=b-rel.pcm \
+// RUN:            -fmodule-file=b-abs.pcm \
+// RUN:            -verify %s 2>&1 | FileCheck %s
+// CHECK: module 'b' is defined in both '{{.*}}b-rel.pcm' and '{{.*}}b-abs.pcm'
+
+#include "a.h"
+static_assert(a == 1, "");
+// expected-no-diagnostics





More information about the cfe-commits mailing list