r181489 - [modules] When building a module, make sure we don't serialize out HeaderFileInfo for headers not belonging to the module.
NAKAMURA Takumi
geek4civic at gmail.com
Wed May 15 05:28:57 PDT 2013
Argyrios,
Could you let the test avoid <float.h>, for now, and use another system header?
<float.h> has an issue around #include_next for mingw32.
FYI: mingw-gcc searches /mingw/include prior to $(GCC_LIB)/include.
mingw32's <float.h> assumes compiler's <float.h> with #include_next <float.h>.
I wonder what would be better solution.
...Takumi
2013/5/9 Argyrios Kyrtzidis <akyrtzi at gmail.com>:
> Author: akirtzidis
> Date: Wed May 8 18:46:46 2013
> New Revision: 181489
>
> URL: http://llvm.org/viewvc/llvm-project?rev=181489&view=rev
> Log:
> [modules] When building a module, make sure we don't serialize out HeaderFileInfo for headers not belonging to the module.
>
> After r180934 we may initiate module map parsing for modules not related to the module what we are building,
> make sure we ignore the header file info of headers from such modules.
>
> First part of rdar://13840148
>
> Added:
> cfe/trunk/test/Modules/self-import-header/
> cfe/trunk/test/Modules/self-import-header/af.framework/
> cfe/trunk/test/Modules/self-import-header/af.framework/Headers/
> cfe/trunk/test/Modules/self-import-header/af.framework/Headers/a1.h
> cfe/trunk/test/Modules/self-import-header/af.framework/Headers/a2.h
> cfe/trunk/test/Modules/self-import-header/af.framework/module.map
> cfe/trunk/test/Modules/self-import-header/depend_builtin/
> cfe/trunk/test/Modules/self-import-header/depend_builtin/h1.h
> cfe/trunk/test/Modules/self-import-header/depend_builtin/module.map
> cfe/trunk/test/Modules/self-import-header/test.m
> Modified:
> cfe/trunk/include/clang/Lex/HeaderSearch.h
> cfe/trunk/include/clang/Lex/ModuleMap.h
> cfe/trunk/lib/Lex/HeaderSearch.cpp
> cfe/trunk/lib/Lex/ModuleMap.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
>
> Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=181489&r1=181488&r2=181489&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
> +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Wed May 8 18:46:46 2013
> @@ -53,6 +53,9 @@ struct HeaderFileInfo {
>
> /// \brief Whether this header is part of a module.
> unsigned isModuleHeader : 1;
> +
> + /// \brief Whether this header is part of the module that we are building.
> + unsigned isCompilingModuleHeader : 1;
>
> /// \brief Whether this structure is considered to already have been
> /// "resolved", meaning that it was loaded from the external source.
> @@ -93,8 +96,8 @@ struct HeaderFileInfo {
>
> HeaderFileInfo()
> : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User),
> - External(false), isModuleHeader(false), Resolved(false),
> - IndexHeaderMapHeader(false),
> + External(false), isModuleHeader(false), isCompilingModuleHeader(false),
> + Resolved(false), IndexHeaderMapHeader(false),
> NumIncludes(0), ControllingMacroID(0), ControllingMacro(0) {}
>
> /// \brief Retrieve the controlling macro for this header file, if
> @@ -405,7 +408,7 @@ public:
> }
>
> /// \brief Mark the specified file as part of a module.
> - void MarkFileModuleHeader(const FileEntry *File);
> + void MarkFileModuleHeader(const FileEntry *File, bool IsCompiledModuleHeader);
>
> /// \brief Increment the count for the number of times the specified
> /// FileEntry has been entered.
>
> Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=181489&r1=181488&r2=181489&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
> +++ cfe/trunk/include/clang/Lex/ModuleMap.h Wed May 8 18:46:46 2013
> @@ -52,6 +52,9 @@ class ModuleMap {
> /// These are always simple C language options.
> LangOptions MMapLangOpts;
>
> + // The module that we are building; related to \c LangOptions::CurrentModule.
> + Module *CompilingModule;
> +
> /// \brief The top-level modules that are known.
> llvm::StringMap<Module *> Modules;
>
>
> Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=181489&r1=181488&r2=181489&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
> +++ cfe/trunk/lib/Lex/HeaderSearch.cpp Wed May 8 18:46:46 2013
> @@ -866,12 +866,14 @@ bool HeaderSearch::isFileMultipleInclude
> HFI.ControllingMacro || HFI.ControllingMacroID;
> }
>
> -void HeaderSearch::MarkFileModuleHeader(const FileEntry *FE) {
> +void HeaderSearch::MarkFileModuleHeader(const FileEntry *FE,
> + bool isCompilingModuleHeader) {
> if (FE->getUID() >= FileInfo.size())
> FileInfo.resize(FE->getUID()+1);
>
> HeaderFileInfo &HFI = FileInfo[FE->getUID()];
> HFI.isModuleHeader = true;
> + HFI.isCompilingModuleHeader = isCompilingModuleHeader;
> }
>
> void HeaderSearch::setHeaderFileInfoForUID(HeaderFileInfo HFI, unsigned UID) {
>
> Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=181489&r1=181488&r2=181489&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
> +++ cfe/trunk/lib/Lex/ModuleMap.cpp Wed May 8 18:46:46 2013
> @@ -87,7 +87,7 @@ ModuleMap::ModuleMap(FileManager &FileMg
> const LangOptions &LangOpts, const TargetInfo *Target,
> HeaderSearch &HeaderInfo)
> : LangOpts(LangOpts), Target(Target), HeaderInfo(HeaderInfo),
> - BuiltinIncludeDir(0)
> + BuiltinIncludeDir(0), CompilingModule(0)
> {
> IntrusiveRefCntPtr<DiagnosticIDs> DiagIDs(new DiagnosticIDs);
> Diags = IntrusiveRefCntPtr<DiagnosticsEngine>(
> @@ -388,8 +388,13 @@ ModuleMap::findOrCreateModule(StringRef
> // Create a new module with this name.
> Module *Result = new Module(Name, SourceLocation(), Parent, IsFramework,
> IsExplicit);
> - if (!Parent)
> + if (!Parent) {
> Modules[Name] = Result;
> + if (!LangOpts.CurrentModule.empty() && !CompilingModule &&
> + Name == LangOpts.CurrentModule) {
> + CompilingModule = Result;
> + }
> + }
> return std::make_pair(Result, true);
> }
>
> @@ -605,7 +610,8 @@ void ModuleMap::addHeader(Module *Mod, c
> Mod->ExcludedHeaders.push_back(Header);
> } else {
> Mod->Headers.push_back(Header);
> - HeaderInfo.MarkFileModuleHeader(Header);
> + bool isCompilingModuleHeader = Mod->getTopLevelModule() == CompilingModule;
> + HeaderInfo.MarkFileModuleHeader(Header, isCompilingModuleHeader);
> }
> Headers[Header] = KnownHeader(Mod, Excluded);
> }
>
> Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=181489&r1=181488&r2=181489&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed May 8 18:46:46 2013
> @@ -1542,6 +1542,8 @@ void ASTWriter::WriteHeaderSearch(const
> const HeaderFileInfo &HFI = HS.getFileInfo(File);
> if (HFI.External && Chain)
> continue;
> + if (HFI.isModuleHeader && !HFI.isCompilingModuleHeader)
> + continue;
>
> // Turn the file name into an absolute path, if it isn't already.
> const char *Filename = File->getName();
>
> Added: cfe/trunk/test/Modules/self-import-header/af.framework/Headers/a1.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/self-import-header/af.framework/Headers/a1.h?rev=181489&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/self-import-header/af.framework/Headers/a1.h (added)
> +++ cfe/trunk/test/Modules/self-import-header/af.framework/Headers/a1.h Wed May 8 18:46:46 2013
> @@ -0,0 +1,4 @@
> + at import DepBuiltin;
> +
> + at interface Foo
> + at end
>
> Added: cfe/trunk/test/Modules/self-import-header/af.framework/Headers/a2.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/self-import-header/af.framework/Headers/a2.h?rev=181489&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/self-import-header/af.framework/Headers/a2.h (added)
> +++ cfe/trunk/test/Modules/self-import-header/af.framework/Headers/a2.h Wed May 8 18:46:46 2013
> @@ -0,0 +1 @@
> +#import "a1.h"
>
> Added: cfe/trunk/test/Modules/self-import-header/af.framework/module.map
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/self-import-header/af.framework/module.map?rev=181489&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/self-import-header/af.framework/module.map (added)
> +++ cfe/trunk/test/Modules/self-import-header/af.framework/module.map Wed May 8 18:46:46 2013
> @@ -0,0 +1,4 @@
> +framework module af {
> + header "a1.h"
> + header "a2.h"
> +}
>
> Added: cfe/trunk/test/Modules/self-import-header/depend_builtin/h1.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/self-import-header/depend_builtin/h1.h?rev=181489&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/self-import-header/depend_builtin/h1.h (added)
> +++ cfe/trunk/test/Modules/self-import-header/depend_builtin/h1.h Wed May 8 18:46:46 2013
> @@ -0,0 +1 @@
> +#include <float.h>
>
> Added: cfe/trunk/test/Modules/self-import-header/depend_builtin/module.map
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/self-import-header/depend_builtin/module.map?rev=181489&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/self-import-header/depend_builtin/module.map (added)
> +++ cfe/trunk/test/Modules/self-import-header/depend_builtin/module.map Wed May 8 18:46:46 2013
> @@ -0,0 +1,5 @@
> +module DepBuiltin {
> +header "h1.h"
> + export *
> +}
> +
>
> Added: cfe/trunk/test/Modules/self-import-header/test.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/self-import-header/test.m?rev=181489&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/self-import-header/test.m (added)
> +++ cfe/trunk/test/Modules/self-import-header/test.m Wed May 8 18:46:46 2013
> @@ -0,0 +1,7 @@
> +// rdar://13840148
> +
> +// RUN: rm -rf %t
> +// RUN: %clang -fsyntax-only -isysroot %S/../Inputs/System/usr/include -fmodules -fmodules-cache-path=%t \
> +// RUN: -F %S -I %S %s -D__need_wint_t -Werror=implicit-function-declaration
> +
> + at import af;
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list