r220780 - [modules] Allow -I, -D, -W flags to change between building a module and

Richard Smith richard-llvm at metafoo.co.uk
Tue Oct 28 09:24:08 PDT 2014


Author: rsmith
Date: Tue Oct 28 11:24:08 2014
New Revision: 220780

URL: http://llvm.org/viewvc/llvm-project?rev=220780&view=rev
Log:
[modules] Allow -I, -D, -W flags to change between building a module and
explicitly using the resulting .pcm file. Unlike for an implicit module build,
we don't need nor want to require these flags to match between the module
and its users.

Added:
    cfe/trunk/test/Modules/explicit-build-flags.cpp
Modified:
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=220780&r1=220779&r2=220780&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Oct 28 11:24:08 2014
@@ -2155,12 +2155,23 @@ InputFile ASTReader::getInputFile(Module
   bool IsOutOfDate = false;
 
   // For an overridden file, there is nothing to validate.
-  if (!Overridden && (StoredSize != File->getSize()
-#if !defined(LLVM_ON_WIN32)
+  if (!Overridden && //
+      (StoredSize != File->getSize() ||
+#if defined(LLVM_ON_WIN32)
+       false
+#else
        // In our regression testing, the Windows file system seems to
        // have inconsistent modification times that sometimes
        // erroneously trigger this error-handling path.
-       || StoredTime != File->getModificationTime()
+       //
+       // This also happens in networked file systems, so disable this
+       // check if validation is disabled or if we have an explicitly
+       // built PCM file.
+       //
+       // FIXME: Should we also do this for PCH files? They could also
+       // reasonably get shared across a network during a distributed build.
+       (StoredTime != File->getModificationTime() && !DisableValidation &&
+        F.Kind != MK_ExplicitModule)
 #endif
        )) {
     if (Complain) {
@@ -2423,6 +2434,7 @@ ASTReader::ReadControlBlock(ModuleFile &
     case DIAGNOSTIC_OPTIONS: {
       bool Complain = (ClientLoadCapabilities & ARR_OutOfDate)==0;
       if (Listener && &F == *ModuleMgr.begin() &&
+          F.Kind != MK_ExplicitModule &&
           ParseDiagnosticOptions(Record, Complain, *Listener) &&
           !DisableValidation)
         return OutOfDate;
@@ -2432,6 +2444,7 @@ ASTReader::ReadControlBlock(ModuleFile &
     case FILE_SYSTEM_OPTIONS: {
       bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch)==0;
       if (Listener && &F == *ModuleMgr.begin() &&
+          F.Kind != MK_ExplicitModule &&
           ParseFileSystemOptions(Record, Complain, *Listener) &&
           !DisableValidation && !AllowConfigurationMismatch)
         return ConfigurationMismatch;
@@ -2441,6 +2454,7 @@ ASTReader::ReadControlBlock(ModuleFile &
     case HEADER_SEARCH_OPTIONS: {
       bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch)==0;
       if (Listener && &F == *ModuleMgr.begin() &&
+          F.Kind != MK_ExplicitModule &&
           ParseHeaderSearchOptions(Record, Complain, *Listener) &&
           !DisableValidation && !AllowConfigurationMismatch)
         return ConfigurationMismatch;
@@ -2450,6 +2464,7 @@ ASTReader::ReadControlBlock(ModuleFile &
     case PREPROCESSOR_OPTIONS: {
       bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch)==0;
       if (Listener && &F == *ModuleMgr.begin() &&
+          F.Kind != MK_ExplicitModule &&
           ParsePreprocessorOptions(Record, Complain, *Listener,
                                    SuggestedPredefines) &&
           !DisableValidation && !AllowConfigurationMismatch)

Added: cfe/trunk/test/Modules/explicit-build-flags.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/explicit-build-flags.cpp?rev=220780&view=auto
==============================================================================
--- cfe/trunk/test/Modules/explicit-build-flags.cpp (added)
+++ cfe/trunk/test/Modules/explicit-build-flags.cpp Tue Oct 28 11:24:08 2014
@@ -0,0 +1,27 @@
+// REQUIRES: shell
+
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo 'module tmp { header "tmp.h" }' > %t/map
+// RUN: touch %t/tmp.h
+// RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-name=tmp %t/map -emit-module -o %t/tmp.pcm
+
+// Can use the module.
+// RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
+
+// Can use the module if an input file is newer. (This happens on
+// remote file systems.)
+// RUN: sleep 1
+// RUN: touch %t/tmp.h
+// RUN: %clang_cc1 -fmodules -DFOO=1 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
+
+// Can use the module if -D flags change.
+// RUN: %clang_cc1 -fmodules -DFOO=2 -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
+
+// Can use the module if -W flags change.
+// RUN: %clang_cc1 -fmodules -Wextra -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
+
+// Can use the module if -I flags change.
+// RUN: %clang_cc1 -fmodules -I. -x c++ -fmodule-map-file=%t/map -fmodule-file=%t/tmp.pcm -verify -I%t %s
+
+#include "tmp.h" // expected-no-diagnostics





More information about the cfe-commits mailing list