<div dir="auto"><div><div class="gmail_extra"><div class="gmail_quote">On 1 May 2017 10:29 pm, "NAKAMURA Takumi" <<a href="mailto:geek4civic@gmail.com">geek4civic@gmail.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It didn't pass for targeting *-win32, since MicrosoftRecordLayoutBuilder doesn't have ability of -Wpadded.<div>Tweaked in r301898.</div></div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Thank you!</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I guess other diag would be available here but I have no good idea.</div></div><div class="elided-text"><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" target="_blank">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-<wbr>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-<wbr>flags.cpp<br>
Modified:<br>
    cfe/trunk/lib/Serialization/<wbr>ASTReader.cpp<br>
    cfe/trunk/test/Modules/Inputs/<wbr>module.map<br>
<br>
Modified: cfe/trunk/lib/Serialization/<wbr>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-<wbr>project/cfe/trunk/lib/<wbr>Serialization/ASTReader.cpp?<wbr>rev=301846&r1=301845&r2=<wbr>301846&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Serialization/<wbr>ASTReader.cpp (original)<br>
+++ cfe/trunk/lib/Serialization/<wbr>ASTReader.cpp Mon May  1 17:10:47 2017<br>
@@ -3765,6 +3765,13 @@ ASTReader::ASTReadResult ASTReader::Read<br>
       SourceMgr.<wbr>getLoadedSLocEntryByID(Index);<br>
     }<br>
<br>
+    // Map the original source file ID into the ID space of the current<br>
+    // compilation.<br>
+    if (F.OriginalSourceFileID.<wbr>isValid()) {<br>
+      F.OriginalSourceFileID = FileID::get(<br>
+          F.SLocEntryBaseID + F.OriginalSourceFileID.<wbr>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.<wbr>OriginalSourceFileID.isValid()<wbr>) {<br>
-    PrimaryModule.<wbr>OriginalSourceFileID<br>
-      = FileID::get(PrimaryModule.<wbr>SLocEntryBaseID<br>
-                    + PrimaryModule.<wbr>OriginalSourceFileID.<wbr>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::<wbr>ReadPragmaDiagnosticMapp<br>
       FirstState = ReadDiagState(<br>
           F.isModule() ? DiagState() : *Diag.DiagStatesByLoc.<wbr>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.<wbr>OriginalSourceFileID]<br>
+            .StateTransitions.push_back({<wbr>FirstState, 0});<br>
     }<br>
<br>
     // Read the state transitions.<br>
<br>
Modified: cfe/trunk/test/Modules/Inputs/<wbr>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-<wbr>project/cfe/trunk/test/<wbr>Modules/Inputs/module.map?rev=<wbr>301846&r1=301845&r2=301846&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Modules/Inputs/<wbr>module.map (original)<br>
+++ cfe/trunk/test/Modules/Inputs/<wbr>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-<wbr>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-<wbr>project/cfe/trunk/test/<wbr>Modules/diag-flags.cpp?rev=<wbr>301846&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Modules/diag-<wbr>flags.cpp (added)<br>
+++ cfe/trunk/test/Modules/diag-<wbr>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:<wbr>14 {{padding struct}}<br>
+#else<br>
+// expected-no-diagnostics<br>
+#endif<br>
+unsigned n = sizeof(Padded);<br>
<br>
<br>
______________________________<wbr>_________________<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/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div>
</div></blockquote></div><br></div></div></div>