<div dir="ltr">Thanks, it turns out this was a pre-existing bug that was exposed by my change. Should be fixed in r267914.<br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 28, 2016 at 4:04 AM, Silviu Baranga via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Richard,<br>
<br>
I believe this commit is causing the failure at<br>
<a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/12319/steps/check-clang%20msan/logs/stdio" rel="noreferrer" target="_blank">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/12319/steps/check-clang%20msan/logs/stdio</a><br>
<br>
I can also see this failure on my box. Reverting it solves the problem for me.<br>
<br>
Thanks,<br>
Silviu<br>
<div><div class="h5"><br>
> -----Original Message-----<br>
> From: cfe-commits [mailto:<a href="mailto:cfe-commits-bounces@lists.llvm.org">cfe-commits-bounces@lists.llvm.org</a>] On Behalf<br>
> Of Richard Smith via cfe-commits<br>
> Sent: 27 April 2016 22:57<br>
> To: <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> Subject: r267802 - [modules] When diagnosing a missing module import,<br>
> suggest adding a #include if<br>
><br>
> Author: rsmith<br>
> Date: Wed Apr 27 16:57:05 2016<br>
> New Revision: 267802<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=267802&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=267802&view=rev</a><br>
> Log:<br>
> [modules] When diagnosing a missing module import, suggest adding a<br>
> #include if the current language doesn't have an import syntax and we can<br>
> figure out a suitable file to include.<br>
><br>
> Added:<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/empty.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/module.modulemap<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/private1.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/private2.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/private3.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/textual1.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/textual2.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/textual3.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/textual4.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/textual5.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/useprivate1.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/useprivate3.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/usetextual1.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/usetextual2.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/usetextual3.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/usetextual4.h<br>
> cfe/trunk/test/Modules/Inputs/suggest-include/usetextual5.h<br>
> cfe/trunk/test/Modules/suggest-include.cpp<br>
> Modified:<br>
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
> cfe/trunk/include/clang/Lex/HeaderSearch.h<br>
> cfe/trunk/include/clang/Lex/ModuleMap.h<br>
> cfe/trunk/include/clang/Lex/Preprocessor.h<br>
> cfe/trunk/lib/Lex/HeaderSearch.cpp<br>
> cfe/trunk/lib/Lex/ModuleMap.cpp<br>
> cfe/trunk/lib/Lex/PPDirectives.cpp<br>
> cfe/trunk/lib/Sema/SemaLookup.cpp<br>
><br>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=267802&<br>
> r1=267801&r2=267802&view=diff<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Apr 27<br>
</div></div>> +++ 16:57:05 2016<br>
<div><div class="h5">> @@ -8262,6 +8262,10 @@ def err_module_private_local_class : Err def<br>
> err_module_unimported_use : Error<<br>
> "%select{declaration|definition|default argument}0 of %1 must be<br>
> imported "<br>
> "from module '%2' before it is required">;<br>
> +def err_module_unimported_use_header : Error<<br>
> + "missing '#include %3'; "<br>
> + "%select{declaration|definition|default argument}0 of %1 must be<br>
> imported "<br>
> + "from module '%2' before it is required">;<br>
> def err_module_unimported_use_multiple : Error<<br>
> "%select{declaration|definition|default argument}0 of %1 must be<br>
> imported "<br>
> "from one of the following modules before it is required:%2">;<br>
><br>
> Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=267802&r1=26780<br>
> 1&r2=267802&view=diff<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)<br>
> +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Wed Apr 27 16:57:05 2016<br>
> @@ -634,13 +634,18 @@ public:<br>
> /// \brief Retrieve a uniqued framework name.<br>
> StringRef getUniqueFrameworkName(StringRef Framework);<br>
><br>
> + /// \brief Suggest a path by which the specified file could be found,<br>
</div></div>> + for /// use in diagnostics to suggest a #include.<br>
<span class="">> + ///<br>
> + /// \param IsSystem If non-null, filled in to indicate whether the suggested<br>
> + /// path is relative to a system header directory.<br>
> + std::string suggestPathToFileForDiagnostics(const FileEntry *File,<br>
> + bool *IsSystem =<br>
</span>> + nullptr);<br>
<div><div class="h5">> +<br>
> void PrintStats();<br>
><br>
> size_t getTotalMemory() const;<br>
><br>
> - static std::string NormalizeDashIncludePath(StringRef File,<br>
> - FileManager &FileMgr);<br>
> -<br>
> private:<br>
> /// \brief Describes what happened when we tried to load a module map<br>
> file.<br>
> enum LoadModuleMapResult {<br>
><br>
> Modified: cfe/trunk/include/clang/Lex/ModuleMap.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=267802&r1=267801<br>
> &r2=267802&view=diff<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/include/clang/Lex/ModuleMap.h (original)<br>
> +++ cfe/trunk/include/clang/Lex/ModuleMap.h Wed Apr 27 16:57:05 2016<br>
> @@ -130,6 +130,12 @@ public:<br>
> return getModule()->isAvailable();<br>
> }<br>
><br>
> + /// \brief Whether this header is accessible from the specified module.<br>
> + bool isAccessibleFrom(Module *M) const {<br>
> + return !(getRole() & PrivateHeader) ||<br>
> + (M && M->getTopLevelModule() == getModule()-<br>
> >getTopLevelModule());<br>
> + }<br>
> +<br>
> // \brief Whether this known header is valid (i.e., it has an<br>
> // associated module).<br>
> explicit operator bool() const {<br>
><br>
> Modified: cfe/trunk/include/clang/Lex/Preprocessor.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=267802&r1=267801<br>
> &r2=267802&view=diff<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/include/clang/Lex/Preprocessor.h (original)<br>
> +++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Apr 27 16:57:05 2016<br>
> @@ -1891,6 +1891,19 @@ public:<br>
> /// directly or indirectly.<br>
> Module *getModuleContainingLocation(SourceLocation Loc);<br>
><br>
> + /// \brief We want to produce a diagnostic at location IncLoc<br>
</div></div>> + concerning a /// missing module import.<br>
<div><div class="h5">> + ///<br>
> + /// \param IncLoc The location at which the missing import was detected.<br>
> + /// \param MLoc A location within the desired module at which some<br>
> desired<br>
> + /// effect occurred (eg, where a desired entity was declared).<br>
> + ///<br>
> + /// \return A file that can be #included to import a module containing<br>
> MLoc.<br>
> + /// Null if no such file could be determined or if a #include is not<br>
> + /// appropriate.<br>
> + const FileEntry<br>
> *getModuleHeaderToIncludeForDiagnostics(SourceLocation IncLoc,<br>
> +<br>
> + SourceLocation MLoc);<br>
> +<br>
> private:<br>
> // Macro handling.<br>
> void HandleDefineDirective(Token &Tok, bool<br>
> ImmediatelyAfterTopLevelIfndef);<br>
><br>
> Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=267802&r1=267801&r2=26<br>
> 7802&view=diff<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)<br>
> +++ cfe/trunk/lib/Lex/HeaderSearch.cpp Wed Apr 27 16:57:05 2016<br>
> @@ -1419,3 +1419,54 @@ void HeaderSearch::loadSubdirectoryModul<br>
><br>
> SearchDir.setSearchedAllModuleMaps(true);<br>
> }<br>
> +<br>
> +std::string HeaderSearch::suggestPathToFileForDiagnostics(const FileEntry<br>
> *File,<br>
> + bool<br>
</div></div>> +*IsSystem) {<br>
<span class="">> + // FIXME: We assume that the path name currently cached in the<br>
</span>> +FileEntry is<br>
<span class="">> + // the most appropriate one for this analysis (and that it's spelled<br>
</span>> +the same<br>
<div><div class="h5">> + // way as the corresponding header search path).<br>
> + const char *Name = File->getName();<br>
> +<br>
> + unsigned BestPrefixLength = 0;<br>
> + unsigned BestSearchDir;<br>
> +<br>
> + for (unsigned I = 0; I != SearchDirs.size(); ++I) {<br>
> + // FIXME: Support this search within frameworks and header maps.<br>
> + if (!SearchDirs[I].isNormalDir())<br>
> + continue;<br>
> +<br>
> + const char *Dir = SearchDirs[I].getDir()->getName();<br>
> + for (auto NI = llvm::sys::path::begin(Name),<br>
> + NE = llvm::sys::path::end(Name),<br>
> + DI = llvm::sys::path::begin(Dir),<br>
> + DE = llvm::sys::path::end(Dir);<br>
> + /*termination condition in loop*/; ++NI, ++DI) {<br>
> + // '.' components in Name are ignored.<br>
> + while (NI != NE && *NI == ".")<br>
> + ++NI;<br>
> + if (NI == NE)<br>
> + break;<br>
> +<br>
> + // '.' components in Dir are ignored.<br>
> + while (DI != DE && *DI == ".")<br>
> + ++DI;<br>
> + if (DI == DE) {<br>
> + // Dir is a prefix of Name, up to '.' components and choice of path<br>
> + // separators.<br>
> + unsigned PrefixLength = NI - llvm::sys::path::begin(Name);<br>
> + if (PrefixLength > BestPrefixLength) {<br>
> + BestPrefixLength = PrefixLength;<br>
> + BestSearchDir = I;<br>
> + }<br>
> + break;<br>
> + }<br>
> +<br>
> + if (*NI != *DI)<br>
> + break;<br>
> + }<br>
> + }<br>
> +<br>
> + if (IsSystem)<br>
> + *IsSystem = BestPrefixLength ? BestSearchDir >= SystemDirIdx :<br>
</div></div>> +false;<br>
<div><div class="h5">> + return Name + BestPrefixLength;<br>
> +}<br>
><br>
> Modified: cfe/trunk/lib/Lex/ModuleMap.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=267802&r1=267801&r2=2678<br>
> 02&view=diff<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/lib/Lex/ModuleMap.cpp (original)<br>
> +++ cfe/trunk/lib/Lex/ModuleMap.cpp Wed Apr 27 16:57:05 2016<br>
> @@ -209,29 +209,25 @@ ModuleMap::findHeaderInUmbrellaDirs(cons<br>
><br>
> static bool violatesPrivateInclude(Module *RequestingModule,<br>
> const FileEntry *IncFileEnt,<br>
> - ModuleMap::ModuleHeaderRole Role,<br>
> - Module *RequestedModule) {<br>
> - bool IsPrivateRole = Role & ModuleMap::PrivateHeader;<br>
> + ModuleMap::KnownHeader Header) {<br>
> #ifndef NDEBUG<br>
> - if (IsPrivateRole) {<br>
> + if (Header.getRole() & ModuleMap::PrivateHeader) {<br>
> // Check for consistency between the module header role<br>
> // as obtained from the lookup and as obtained from the module.<br>
> // This check is not cheap, so enable it only for debugging.<br>
> bool IsPrivate = false;<br>
> SmallVectorImpl<Module::Header> *HeaderList[] = {<br>
> - &RequestedModule->Headers[Module::HK_Private],<br>
> - &RequestedModule->Headers[Module::HK_PrivateTextual]};<br>
> + &Header.getModule()->Headers[Module::HK_Private],<br>
> + &Header.getModule()->Headers[Module::HK_PrivateTextual]};<br>
> for (auto *Hs : HeaderList)<br>
> IsPrivate |=<br>
> std::find_if(Hs->begin(), Hs->end(), [&](const Module::Header &H) {<br>
> return H.Entry == IncFileEnt;<br>
> }) != Hs->end();<br>
> - assert((!IsPrivateRole || IsPrivate) && "inconsistent headers and roles");<br>
> + assert(IsPrivate && "inconsistent headers and roles");<br>
> }<br>
> #endif<br>
> - return IsPrivateRole && (!RequestingModule ||<br>
> - RequestedModule->getTopLevelModule() !=<br>
> - RequestingModule->getTopLevelModule());<br>
> + return !Header.isAccessibleFrom(RequestingModule);<br>
> }<br>
><br>
> static Module *getTopLevelOrNull(Module *M) { @@ -259,8 +255,7 @@<br>
> void ModuleMap::diagnoseHeaderInclusion(<br>
> if (Known != Headers.end()) {<br>
> for (const KnownHeader &Header : Known->second) {<br>
> // Remember private headers for later printing of a diagnostic.<br>
> - if (violatesPrivateInclude(RequestingModule, File, Header.getRole(),<br>
> - Header.getModule())) {<br>
> + if (violatesPrivateInclude(RequestingModule, File, Header)) {<br>
> Private = Header.getModule();<br>
> continue;<br>
> }<br>
><br>
> Modified: cfe/trunk/lib/Lex/PPDirectives.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=267802&r1=267801&r2=2678<br>
> 02&view=diff<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/lib/Lex/PPDirectives.cpp (original)<br>
> +++ cfe/trunk/lib/Lex/PPDirectives.cpp Wed Apr 27 16:57:05 2016<br>
> @@ -597,6 +597,62 @@ Module *Preprocessor::getModuleContainin<br>
> FullSourceLoc(Loc, SourceMgr));<br>
> }<br>
><br>
> +const FileEntry *<br>
> +Preprocessor::getModuleHeaderToIncludeForDiagnostics(SourceLocation<br>
> IncLoc,<br>
> + SourceLocation<br>
</div></div>> +Loc) {<br>
<span class="">> + // If we have a module import syntax, we shouldn't include a header<br>
</span>> +to<br>
<span class="">> + // make a particular module visible.<br>
> + if (getLangOpts().ObjC2)<br>
> + return nullptr;<br>
> +<br>
> + // Figure out which module we'd want to import.<br>
</span>> + Module *M = getModuleContainingLocation(Loc); if (!M)<br>
> + return nullptr;<br>
> +<br>
> + Module *TopM = M->getTopLevelModule(); Module *IncM =<br>
> + getModuleForLocation(IncLoc);<br>
<span class="">> +<br>
> + // Walk up through the include stack, looking through textual headers<br>
</span>> + of M // until we hit a non-textual header that we can #include. (We<br>
> + assume textual // headers of a module with non-textual headers aren't<br>
> + meant to be used to // import entities from the module.) auto &SM =<br>
> + getSourceManager(); while (!Loc.isInvalid() && !SM.isInMainFile(Loc))<br>
> + {<br>
<div><div class="h5">> + auto ID = SM.getFileID(SM.getExpansionLoc(Loc));<br>
> + auto *FE = SM.getFileEntryForID(ID);<br>
> +<br>
> + bool InTextualHeader = false;<br>
> + for (auto Header :<br>
> HeaderInfo.getModuleMap().findAllModulesForHeader(FE)) {<br>
> + if (!Header.getModule()->isSubModuleOf(TopM))<br>
> + continue;<br>
> +<br>
> + if (!(Header.getRole() & ModuleMap::TextualHeader)) {<br>
> + // If this is an accessible, non-textual header of M's top-level module<br>
> + // that transitively includes the given location and makes the<br>
> + // corresponding module visible, this is the thing to #include.<br>
> + if (Header.isAccessibleFrom(IncM))<br>
> + return FE;<br>
> +<br>
> + // It's in a private header; we can't #include it.<br>
> + // FIXME: If there's a public header in some module that re-exports it,<br>
> + // then we could suggest including that, but it's not clear that's the<br>
> + // expected way to make this entity visible.<br>
> + continue;<br>
> + }<br>
> +<br>
> + InTextualHeader = true;<br>
> + }<br>
> +<br>
> + if (!InTextualHeader)<br>
> + break;<br>
> +<br>
> + Loc = SM.getIncludeLoc(ID);<br>
> + }<br>
> +<br>
> + return nullptr;<br>
> +}<br>
> +<br>
> const FileEntry *Preprocessor::LookupFile(<br>
> SourceLocation FilenameLoc,<br>
> StringRef Filename,<br>
><br>
> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=267802&r1=267801&r2=2<br>
> 67802&view=diff<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)<br>
> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Apr 27 16:57:05 2016<br>
> @@ -4929,6 +4929,16 @@ void Sema::diagnoseMissingImport(SourceL<br>
> Recover);<br>
> }<br>
><br>
> +/// \brief Get a "quoted.h" or <angled.h> include path to use in a<br>
</div></div>> +diagnostic /// suggesting the addition of a #include of the specified file.<br>
<span class="">> +static std::string getIncludeStringForHeader(Preprocessor &PP,<br>
> + const FileEntry *E) {<br>
> + bool IsSystem;<br>
> + auto Path =<br>
> + PP.getHeaderSearchInfo().suggestPathToFileForDiagnostics(E,<br>
</span>> +&IsSystem);<br>
<span class="">> + return (IsSystem ? '<' : '"') + Path + (IsSystem ? '>' : '"'); }<br>
> +<br>
</span><div><div class="h5">> void Sema::diagnoseMissingImport(SourceLocation UseLoc, NamedDecl<br>
> *Decl,<br>
> SourceLocation DeclLoc,<br>
> ArrayRef<Module *> Modules, @@ -4949,6 +4959,16 @@<br>
> void Sema::diagnoseMissingImport(SourceL<br>
><br>
> Diag(UseLoc, diag::err_module_unimported_use_multiple)<br>
> << (int)MIK << Decl << ModuleList;<br>
> + } else if (const FileEntry *E =<br>
> + PP.getModuleHeaderToIncludeForDiagnostics(UseLoc, DeclLoc)) {<br>
> + // The right way to make the declaration visible is to include a header;<br>
> + // suggest doing so.<br>
> + //<br>
> + // FIXME: Find a smart place to suggest inserting a #include, and add<br>
> + // a FixItHint there.<br>
> + Diag(UseLoc, diag::err_module_unimported_use_header)<br>
> + << (int)MIK << Decl << Modules[0]->getFullModuleName()<br>
> + << getIncludeStringForHeader(PP, E);<br>
> } else {<br>
> Diag(UseLoc, diag::err_module_unimported_use)<br>
> << (int)MIK << Decl << Modules[0]->getFullModuleName();<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/empty.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/empty.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> (empty)<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/module.modulemap<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/module.modulemap?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/module.modulemap<br>
> (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/module.modulemap<br>
> Wed<br>
</div></div>> +++ Apr 27 16:57:05 2016<br>
<div><div class="h5">> @@ -0,0 +1,22 @@<br>
> +module X {<br>
> + module Empty { header "empty.h" }<br>
> +<br>
> + exclude header "textual1.h"<br>
> + textual header "textual2.h"<br>
> + textual header "textual3.h"<br>
> +<br>
> + module A { header "usetextual1.h" }<br>
> + module B { header "usetextual2.h" }<br>
> + module C { header "usetextual3.h" }<br>
> + module D { header "usetextual4.h" }<br>
> + module E { header "usetextual5.h" }<br>
> +<br>
> + module P { private header "private1.h" }<br>
> + module Q { private header "private2.h" }<br>
> + module R { private header "private3.h" }<br>
> + module S { header "useprivate1.h" export * }<br>
> + module T { header "useprivate3.h" }<br>
> +}<br>
> +<br>
> +module Other { textual header "textual4.h" }<br>
> +<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/private1.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/private1.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/private1.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/private1.h Wed Apr 27<br>
</div></div>> +++ 16:57:05 2016<br>
<span class="">> @@ -0,0 +1 @@<br>
> +extern int private1;<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/private2.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/private2.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/private2.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/private2.h Wed Apr 27<br>
</span>> +++ 16:57:05 2016<br>
<span class="">> @@ -0,0 +1 @@<br>
> +extern int private2;<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/private3.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/private3.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/private3.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/private3.h Wed Apr 27<br>
</span>> +++ 16:57:05 2016<br>
<span class="">> @@ -0,0 +1 @@<br>
> +extern int private3;<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/textual1.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/textual1.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/textual1.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/textual1.h Wed Apr 27<br>
</span>> +++ 16:57:05 2016<br>
<span class="">> @@ -0,0 +1 @@<br>
> +#define FOO(X) X<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/textual2.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/textual2.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/textual2.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/textual2.h Wed Apr 27<br>
</span>> +++ 16:57:05 2016<br>
<span class="">> @@ -0,0 +1 @@<br>
> +EXPAND_MACRO<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/textual3.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/textual3.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/textual3.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/textual3.h Wed Apr 27<br>
</span>> +++ 16:57:05 2016<br>
<span class="">> @@ -0,0 +1 @@<br>
> +extern int textual3;<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/textual4.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/textual4.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/textual4.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/textual4.h Wed Apr 27<br>
</span>> +++ 16:57:05 2016<br>
<span class="">> @@ -0,0 +1 @@<br>
> +extern int textual4;<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/textual5.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/textual5.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/textual5.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/textual5.h Wed Apr 27<br>
</span>> +++ 16:57:05 2016<br>
<span class="">> @@ -0,0 +1 @@<br>
> +extern int textual5;<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/useprivate1.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/useprivate1.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/useprivate1.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/useprivate1.h Wed Apr<br>
</span>> +++ 27 16:57:05 2016<br>
<span class="">> @@ -0,0 +1 @@<br>
> +#include "private1.h"<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/useprivate3.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/useprivate3.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/useprivate3.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/useprivate3.h Wed Apr<br>
</span>> +++ 27 16:57:05 2016<br>
<span class="">> @@ -0,0 +1 @@<br>
> +#include "private3.h"<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/usetextual1.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/usetextual1.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/usetextual1.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/usetextual1.h Wed Apr<br>
</span>> +++ 27 16:57:05 2016<br>
<span class="">> @@ -0,0 +1,2 @@<br>
> +#include "textual1.h"<br>
> +FOO(extern int usetextual1;)<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/usetextual2.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/usetextual2.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/usetextual2.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/usetextual2.h Wed Apr<br>
</span>> +++ 27 16:57:05 2016<br>
> @@ -0,0 +1,2 @@<br>
> +#define EXPAND_MACRO extern int usetextual2; #include "textual2.h"<br>
<span class="">><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/usetextual3.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/usetextual3.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/usetextual3.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/usetextual3.h Wed Apr<br>
</span>> +++ 27 16:57:05 2016<br>
<span class="">> @@ -0,0 +1 @@<br>
> +#include "textual3.h"<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/usetextual4.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/usetextual4.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/usetextual4.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/usetextual4.h Wed Apr<br>
</span>> +++ 27 16:57:05 2016<br>
<span class="">> @@ -0,0 +1 @@<br>
> +#include "textual4.h"<br>
><br>
> Added: cfe/trunk/test/Modules/Inputs/suggest-include/usetextual5.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/cfe/trunk/test/Modules/Inputs/suggest-<br>
> include/usetextual5.h?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/Inputs/suggest-include/usetextual5.h (added)<br>
> +++ cfe/trunk/test/Modules/Inputs/suggest-include/usetextual5.h Wed Apr<br>
</span>> +++ 27 16:57:05 2016<br>
<span class="">> @@ -0,0 +1 @@<br>
> +#include "textual5.h"<br>
><br>
> Added: cfe/trunk/test/Modules/suggest-include.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/suggest-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/suggest-</a><br>
> include.cpp?rev=267802&view=auto<br>
> ==========================================================<br>
> ====================<br>
> --- cfe/trunk/test/Modules/suggest-include.cpp (added)<br>
> +++ cfe/trunk/test/Modules/suggest-include.cpp Wed Apr 27 16:57:05 2016<br>
> @@ -0,0 +1,33 @@<br>
> +// RUN: rm -rf %t<br>
> +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t<br>
</span>> +-fimplicit-module-maps -I%S/Inputs/suggest-include %s -verify<br>
<span class="">> +<br>
> +#include "empty.h" // import the module file<br>
> +<br>
</span>> +// expected-note@usetextual1.h:2 {{previous}} //<br>
> +expected-note@textual2.h:1 {{previous}} // expected-note@textual3.h:1<br>
> +{{previous}} // expected-note@textual4.h:1 {{previous}} //<br>
> +expected-note@textual5.h:1 {{previous}} // expected-note@private1.h:1<br>
> +{{previous}} // expected-note@private2.h:1 {{previous}} //<br>
> +expected-note@private3.h:1 {{previous}}<br>
<span class="">> +<br>
> +void f() {<br>
> + (void)::usetextual1; // expected-error {{missing '#include<br>
</span>> +"usetextual1.h"'}}<br>
<span class="">> + (void)::usetextual2; // expected-error {{missing '#include<br>
</span>> +"usetextual2.h"'}}<br>
<span class="">> + (void)::textual3; // expected-error-re {{{{^}}missing '#include<br>
</span>> +"usetextual3.h"'}}<br>
<span class="">> + // Don't suggest a #include that includes the entity via a path that<br>
</span>> +leaves<br>
<span class="">> + // the module. In that case we can't be sure that we've picked the right<br>
> header.<br>
> + (void)::textual4; // expected-error-re {{{{^}}declaration of<br>
</span>> +'textual4'}}<br>
<span class="">> + (void)::textual5; // expected-error-re {{{{^}}declaration of<br>
</span>> +'textual5'}}<br>
<span class="">> +<br>
> + // Don't suggest #including a private header.<br>
> + // FIXME: We could suggest including "useprivate1.h" here, as it's<br>
</span>> +the only<br>
<span class="">> + // public way to get at this declaration.<br>
> + (void)::private1; // expected-error-re {{{{^}}declaration of<br>
</span>> +'private1'}}<br>
<span class="">> + // FIXME: Should we be suggesting an import at all here? Should<br>
</span>> +declarations<br>
<span class="">> + // in private headers be visible when the surrounding module is imported?<br>
> + (void)::private2; // expected-error-re {{{{^}}declaration of<br>
</span>> +'private2'}}<br>
<span class="">> + // Even if we suggest an include for private1, we should not do so here.<br>
> + (void)::private3; // expected-error-re {{{{^}}declaration of<br>
</span>> +'private3'}} }<br>
<span class="">><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">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>
</span>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div></div>