<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 30, 2015 at 6:51 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard-llvm@metafoo.co.uk" target="_blank">richard-llvm@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rsmith<br>
Date: Tue Jun 30 20:51:38 2015<br>
New Revision: 241135<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D241135-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=7DIEba_x-oiVQsRKt8OD7i_UzwXngcEE0QJssdmLKFY&s=Wh3vCGcHKtXEWOuKtvfBPvHKM_nz-s4z63V-P672FM8&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=241135&view=rev</a><br>
Log:<br>
[modules] Make the include guard optimization fire a bit more when considering<br>
re-entering a modular header.<br>
<br>
When we do the include guard check, we're in the visibility state for the file<br>
with the #include; the include guard may not be visible there, but we don't<br>
actually need it to be: if we've already parsed the submodule we're considering<br>
entering, it's always safe to skip it.<br>
<br>
Modified:<br>
    cfe/trunk/include/clang/Lex/HeaderSearch.h<br>
    cfe/trunk/lib/Lex/HeaderSearch.cpp<br>
    cfe/trunk/lib/Lex/PPDirectives.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_Lex_HeaderSearch.h-3Frev-3D241135-26r1-3D241134-26r2-3D241135-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=7DIEba_x-oiVQsRKt8OD7i_UzwXngcEE0QJssdmLKFY&s=I4q5x3ECZo83Ajuy1J2l_smdO8jYes3NGDvuC6bAFQ8&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=241135&r1=241134&r2=241135&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)<br>
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Jun 30 20:51:38 2015<br>
@@ -421,7 +421,7 @@ public:<br>
   /// \return false if \#including the file will have no effect or true<br>
   /// if we should include it.<br>
   bool ShouldEnterIncludeFile(Preprocessor &PP, const FileEntry *File,<br>
-                              bool isImport);<br>
+                              bool isImport, Module *CorrespondingModule);<br>
<br>
   /// \brief Return whether the specified file is a normal header,<br>
   /// a system header, or a C++ friendly system header.<br>
<br>
Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Lex_HeaderSearch.cpp-3Frev-3D241135-26r1-3D241134-26r2-3D241135-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=7DIEba_x-oiVQsRKt8OD7i_UzwXngcEE0QJssdmLKFY&s=cWZUVqRcU8WRd7iYOHIb9WmSzKg-EMgMi-jwy1rPjeQ&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=241135&r1=241134&r2=241135&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)<br>
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Tue Jun 30 20:51:38 2015<br>
@@ -1025,7 +1025,7 @@ void HeaderSearch::MarkFileModuleHeader(<br>
<br>
 bool HeaderSearch::ShouldEnterIncludeFile(Preprocessor &PP,<br>
                                           const FileEntry *File,<br>
-                                          bool isImport) {<br>
+                                          bool isImport, Module *M) {<br></blockquote><div><br></div><div>Did you intend to use a different variable name here than in the declaration in the header?</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
   ++NumIncluded; // Count # of attempted #includes.<br>
<br>
   // Get information about this file.<br>
@@ -1050,7 +1050,11 @@ bool HeaderSearch::ShouldEnterIncludeFil<br>
   // if the macro that guards it is defined, we know the #include has no effect.<br>
   if (const IdentifierInfo *ControllingMacro<br>
       = FileInfo.getControllingMacro(ExternalLookup))<br>
-    if (PP.isMacroDefined(ControllingMacro)) {<br>
+    // If the include file is part of a module, and we already know what its<br>
+    // controlling macro is, then we've already parsed it and can safely just<br>
+    // make it visible. This saves us needing to switch into the visibility<br>
+    // state of the module just to check whether the macro is defined within it.<br>
+    if (M || PP.isMacroDefined(ControllingMacro)) {<br>
       ++NumMultiIncludeFileOptzn;<br>
       return false;<br>
     }<br>
<br>
Modified: cfe/trunk/lib/Lex/PPDirectives.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_Lex_PPDirectives.cpp-3Frev-3D241135-26r1-3D241134-26r2-3D241135-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=BSqEv9KvKMW_Ob8SyngJ70KdZISM_ASROnREeq0cCxk&m=7DIEba_x-oiVQsRKt8OD7i_UzwXngcEE0QJssdmLKFY&s=k7FSqXFdK2j8ZKlopAk4z0Iyp4RhLWBbaPiJSdsz_1k&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=241135&r1=241134&r2=241135&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)<br>
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Jun 30 20:51:38 2015<br>
@@ -1749,7 +1749,8 @@ void Preprocessor::HandleIncludeDirectiv<br>
   // Ask HeaderInfo if we should enter this #include file.  If not, #including<br>
   // this file will have no effect.<br>
   if (ShouldEnter &&<br>
-      !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport)) {<br>
+      !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport,<br>
+                                         SuggestedModule.getModule())) {<br>
     ShouldEnter = false;<br>
     if (Callbacks)<br>
       Callbacks->FileSkipped(*File, FilenameTok, FileCharacter);<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>