[PATCH] D25806: Module: correctly set the module file kind when emitting diagnostics for file_modified
Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 21 16:44:27 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL284899: Module: correctly set the module file kind when emitting file_modified. (authored by mren).
Changed prior to commit:
https://reviews.llvm.org/D25806?vs=75326&id=75510#toc
Repository:
rL LLVM
https://reviews.llvm.org/D25806
Files:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/module-file-modified.c
Index: cfe/trunk/lib/Serialization/ASTReader.cpp
===================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp
+++ cfe/trunk/lib/Serialization/ASTReader.cpp
@@ -1983,6 +1983,7 @@
return R;
}
+static unsigned moduleKindForDiagnostic(ModuleKind Kind);
InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
// If this ID is bogus, just return an empty input file.
if (ID == 0 || ID > F.InputFilesLoaded.size())
@@ -2079,7 +2080,13 @@
// The top-level PCH is stale.
StringRef TopLevelPCHName(ImportStack.back()->FileName);
- Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+ unsigned DiagnosticKind = moduleKindForDiagnostic(ImportStack.back()->Kind);
+ if (DiagnosticKind == 0)
+ Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+ else if (DiagnosticKind == 1)
+ Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName);
+ else
+ Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName);
// Print the import stack.
if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
Index: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
===================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -21,6 +21,12 @@
def err_fe_pch_file_modified : Error<
"file '%0' has been modified since the precompiled header '%1' was built">,
DefaultFatal;
+def err_fe_module_file_modified : Error<
+ "file '%0' has been modified since the module file '%1' was built">,
+ DefaultFatal;
+def err_fe_ast_file_modified : Error<
+ "file '%0' has been modified since the AST file '%1' was built">,
+ DefaultFatal;
def err_fe_pch_file_overridden : Error<
"file '%0' from the precompiled header has been overridden">;
def note_pch_required_by : Note<"'%0' required by '%1'">;
Index: cfe/trunk/test/Modules/module-file-modified.c
===================================================================
--- cfe/trunk/test/Modules/module-file-modified.c
+++ cfe/trunk/test/Modules/module-file-modified.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 -x c %s -I%t -fsyntax-only 2>&1 | FileCheck %s
+#include "a.h"
+int foo = 0; // redefinition of 'foo'
+// CHECK: fatal error: file {{.*}} has been modified since the module file {{.*}} was built
+// REQUIRES: shell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25806.75510.patch
Type: text/x-patch
Size: 2857 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161021/17cf05c4/attachment.bin>
More information about the cfe-commits
mailing list