yamaguchi created this revision. yamaguchi added reviewers: rsmith, v.g.vassilev.
This is a follow-up patch of https://reviews.llvm.org/rL338503: [Modules] Do not emit relocation error when -fno-validate-pch is set File modification with modules is also fine for our usecase as we want to reuse pcms. This enables us to use the same build directory again without deleting pcm directory. https://reviews.llvm.org/D52513 Files: clang/lib/Serialization/ASTReader.cpp clang/test/Modules/module-file-novalidate.c Index: clang/test/Modules/module-file-novalidate.c =================================================================== --- /dev/null +++ clang/test/Modules/module-file-novalidate.c @@ -0,0 +1,11 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: echo 'int foo = 0;' > %t/a.h +// RUN: echo 'module A { header "a.h" }' > %t/m.modulemap +// RUN: %clang_cc1 -fmodules -emit-module -fmodule-name=A -x c %t/m.modulemap -o %t/m.pcm +// RUN: echo 'int bar;' > %t/a.h +// RUN: not %clang_cc1 -fmodules -fmodule-file=%t/m.pcm -fmodule-map-file=%t/m.modulemap -fno-validate-pch -x c %s -I%t -fsyntax-only 2>&1 | FileCheck %s +#include "a.h" +int foo = 0; // redefinition of 'foo' +// CHECK-NOT: fatal error: file {{.*}} has been modified since the module file {{.*}} was built +// REQUIRES: shell Index: clang/lib/Serialization/ASTReader.cpp =================================================================== --- clang/lib/Serialization/ASTReader.cpp +++ clang/lib/Serialization/ASTReader.cpp @@ -2175,7 +2175,8 @@ bool IsOutOfDate = false; // For an overridden file, there is nothing to validate. - if (!Overridden && // + // Don't emit file modification error if we have -fno-validate-pch + if (!Overridden && !PP.getPreprocessorOpts().DisablePCHValidation && (StoredSize != File->getSize() || (StoredTime && StoredTime != File->getModificationTime() && !DisableValidation)
Index: clang/test/Modules/module-file-novalidate.c =================================================================== --- /dev/null +++ clang/test/Modules/module-file-novalidate.c @@ -0,0 +1,11 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: echo 'int foo = 0;' > %t/a.h +// RUN: echo 'module A { header "a.h" }' > %t/m.modulemap +// RUN: %clang_cc1 -fmodules -emit-module -fmodule-name=A -x c %t/m.modulemap -o %t/m.pcm +// RUN: echo 'int bar;' > %t/a.h +// RUN: not %clang_cc1 -fmodules -fmodule-file=%t/m.pcm -fmodule-map-file=%t/m.modulemap -fno-validate-pch -x c %s -I%t -fsyntax-only 2>&1 | FileCheck %s +#include "a.h" +int foo = 0; // redefinition of 'foo' +// CHECK-NOT: fatal error: file {{.*}} has been modified since the module file {{.*}} was built +// REQUIRES: shell Index: clang/lib/Serialization/ASTReader.cpp =================================================================== --- clang/lib/Serialization/ASTReader.cpp +++ clang/lib/Serialization/ASTReader.cpp @@ -2175,7 +2175,8 @@ bool IsOutOfDate = false; // For an overridden file, there is nothing to validate. - if (!Overridden && // + // Don't emit file modification error if we have -fno-validate-pch + if (!Overridden && !PP.getPreprocessorOpts().DisablePCHValidation && (StoredSize != File->getSize() || (StoredTime && StoredTime != File->getModificationTime() && !DisableValidation)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits