<div dir="ltr">It didn't pass for targeting *-win32, since MicrosoftRecordLayoutBuilder doesn't have ability of -Wpadded.<div>Tweaked in r301898.<br></div><div><br></div><div>I guess other diag would be available here but I have no good idea.</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, May 2, 2017 at 7:23 AM Richard Smith via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Mon May 1 17:10:47 2017<br>
New Revision: 301846<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=301846&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=301846&view=rev</a><br>
Log:<br>
Fix initial diagnostic state setup for an explicit module with no diagnostic pragmas.<br>
<br>
If a file has no diagnostic pragmas, we build its diagnostic state lazily, but<br>
in this case we never set up the root state to be the diagnostic state in which<br>
the module was originally built, so the diagnostic flags for files in the<br>
module with no diagnostic pragmas were incorrectly based on the user of the<br>
module rather than the diagnostic state when the module was built.<br>
<br>
Added:<br>
cfe/trunk/test/Modules/diag-flags.cpp<br>
Modified:<br>
cfe/trunk/lib/Serialization/ASTReader.cpp<br>
cfe/trunk/test/Modules/Inputs/module.map<br>
<br>
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=301846&r1=301845&r2=301846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=301846&r1=301845&r2=301846&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon May 1 17:10:47 2017<br>
@@ -3765,6 +3765,13 @@ ASTReader::ASTReadResult ASTReader::Read<br>
SourceMgr.getLoadedSLocEntryByID(Index);<br>
}<br>
<br>
+ // Map the original source file ID into the ID space of the current<br>
+ // compilation.<br>
+ if (F.OriginalSourceFileID.isValid()) {<br>
+ F.OriginalSourceFileID = FileID::get(<br>
+ F.SLocEntryBaseID + F.OriginalSourceFileID.getOpaqueValue() - 1);<br>
+ }<br>
+<br>
// Preload all the pending interesting identifiers by marking them out of<br>
// date.<br>
for (auto Offset : F.PreloadIdentifierOffsets) {<br>
@@ -3873,10 +3880,6 @@ ASTReader::ASTReadResult ASTReader::Read<br>
<br>
ModuleFile &PrimaryModule = ModuleMgr.getPrimaryModule();<br>
if (PrimaryModule.OriginalSourceFileID.isValid()) {<br>
- PrimaryModule.OriginalSourceFileID<br>
- = FileID::get(PrimaryModule.SLocEntryBaseID<br>
- + PrimaryModule.OriginalSourceFileID.getOpaqueValue() - 1);<br>
-<br>
// If this AST file is a precompiled preamble, then set the<br>
// preamble file ID of the source manager to the file source file<br>
// from which the preamble was built.<br>
@@ -5575,6 +5578,13 @@ void ASTReader::ReadPragmaDiagnosticMapp<br>
FirstState = ReadDiagState(<br>
F.isModule() ? DiagState() : *Diag.DiagStatesByLoc.CurDiagState,<br>
SourceLocation(), F.isModule());<br>
+<br>
+ // For an explicit module, set up the root buffer of the module to start<br>
+ // with the initial diagnostic state of the module itself, to cover files<br>
+ // that contain no explicit transitions.<br>
+ if (F.isModule())<br>
+ Diag.DiagStatesByLoc.Files[F.OriginalSourceFileID]<br>
+ .StateTransitions.push_back({FirstState, 0});<br>
}<br>
<br>
// Read the state transitions.<br>
<br>
Modified: cfe/trunk/test/Modules/Inputs/module.map<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=301846&r1=301845&r2=301846&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=301846&r1=301845&r2=301846&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/Inputs/module.map (original)<br>
+++ cfe/trunk/test/Modules/Inputs/module.map Mon May 1 17:10:47 2017<br>
@@ -261,6 +261,10 @@ module config {<br>
config_macros [exhaustive] WANT_FOO, WANT_BAR<br>
}<br>
<br>
+module diag_flags {<br>
+ header "diag_flags.h"<br>
+}<br>
+<br>
module diag_pragma {<br>
header "diag_pragma.h"<br>
}<br>
<br>
Added: cfe/trunk/test/Modules/diag-flags.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/diag-flags.cpp?rev=301846&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/diag-flags.cpp?rev=301846&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Modules/diag-flags.cpp (added)<br>
+++ cfe/trunk/test/Modules/diag-flags.cpp Mon May 1 17:10:47 2017<br>
@@ -0,0 +1,22 @@<br>
+// RUN: rm -rf %t<br>
+//<br>
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -emit-module -fmodules-cache-path=%t -fmodule-name=diag_flags -x c++ %S/Inputs/module.map -fmodules-ts<br>
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts<br>
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DIMPLICIT_FLAG -Werror=padded<br>
+//<br>
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -emit-module -fmodule-name=diag_flags -x c++ %S/Inputs/module.map -fmodules-ts -o %t/explicit.pcm -Werror=string-plus-int -Wpadded<br>
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DEXPLICIT_FLAG -fmodule-file=%t/explicit.pcm<br>
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -verify -fmodules-cache-path=%t -I %S/Inputs %s -fmodules-ts -DEXPLICIT_FLAG -fmodule-file=%t/explicit.pcm -Werror=padded<br>
+<br>
+import diag_flags;<br>
+<br>
+// Diagnostic flags from the module user make no difference to diagnostics<br>
+// emitted within the module when using an explicitly-loaded module.<br>
+#ifdef IMPLICIT_FLAG<br>
+// expected-error@diag_flags.h:14 {{padding struct}}<br>
+#elif defined(EXPLICIT_FLAG)<br>
+// expected-warning@diag_flags.h:14 {{padding struct}}<br>
+#else<br>
+// expected-no-diagnostics<br>
+#endif<br>
+unsigned n = sizeof(Padded);<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>