r241135 - [modules] Make the include guard optimization fire a bit more when considering
Sean Silva
chisophugis at gmail.com
Tue Jun 30 20:09:48 PDT 2015
On Tue, Jun 30, 2015 at 6:51 PM, Richard Smith <richard-llvm at metafoo.co.uk>
wrote:
> Author: rsmith
> Date: Tue Jun 30 20:51:38 2015
> New Revision: 241135
>
> URL: http://llvm.org/viewvc/llvm-project?rev=241135&view=rev
> Log:
> [modules] Make the include guard optimization fire a bit more when
> considering
> re-entering a modular header.
>
> When we do the include guard check, we're in the visibility state for the
> file
> with the #include; the include guard may not be visible there, but we don't
> actually need it to be: if we've already parsed the submodule we're
> considering
> entering, it's always safe to skip it.
>
> Modified:
> cfe/trunk/include/clang/Lex/HeaderSearch.h
> cfe/trunk/lib/Lex/HeaderSearch.cpp
> cfe/trunk/lib/Lex/PPDirectives.cpp
>
> Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=241135&r1=241134&r2=241135&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
> +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Jun 30 20:51:38 2015
> @@ -421,7 +421,7 @@ public:
> /// \return false if \#including the file will have no effect or true
> /// if we should include it.
> bool ShouldEnterIncludeFile(Preprocessor &PP, const FileEntry *File,
> - bool isImport);
> + bool isImport, Module *CorrespondingModule);
>
> /// \brief Return whether the specified file is a normal header,
> /// a system header, or a C++ friendly system header.
>
> Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=241135&r1=241134&r2=241135&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
> +++ cfe/trunk/lib/Lex/HeaderSearch.cpp Tue Jun 30 20:51:38 2015
> @@ -1025,7 +1025,7 @@ void HeaderSearch::MarkFileModuleHeader(
>
> bool HeaderSearch::ShouldEnterIncludeFile(Preprocessor &PP,
> const FileEntry *File,
> - bool isImport) {
> + bool isImport, Module *M) {
>
Did you intend to use a different variable name here than in the
declaration in the header?
-- Sean Silva
> ++NumIncluded; // Count # of attempted #includes.
>
> // Get information about this file.
> @@ -1050,7 +1050,11 @@ bool HeaderSearch::ShouldEnterIncludeFil
> // if the macro that guards it is defined, we know the #include has no
> effect.
> if (const IdentifierInfo *ControllingMacro
> = FileInfo.getControllingMacro(ExternalLookup))
> - if (PP.isMacroDefined(ControllingMacro)) {
> + // If the include file is part of a module, and we already know what
> its
> + // controlling macro is, then we've already parsed it and can safely
> just
> + // make it visible. This saves us needing to switch into the
> visibility
> + // state of the module just to check whether the macro is defined
> within it.
> + if (M || PP.isMacroDefined(ControllingMacro)) {
> ++NumMultiIncludeFileOptzn;
> return false;
> }
>
> Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=241135&r1=241134&r2=241135&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
> +++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Jun 30 20:51:38 2015
> @@ -1749,7 +1749,8 @@ void Preprocessor::HandleIncludeDirectiv
> // Ask HeaderInfo if we should enter this #include file. If not,
> #including
> // this file will have no effect.
> if (ShouldEnter &&
> - !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport)) {
> + !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport,
> + SuggestedModule.getModule())) {
> ShouldEnter = false;
> if (Callbacks)
> Callbacks->FileSkipped(*File, FilenameTok, FileCharacter);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150630/6953066b/attachment.html>
More information about the cfe-commits
mailing list