r203005 - If a #include finds a file relative to the current file, don't forget to check

Evgeniy Stepanov eugeni.stepanov at gmail.com
Thu Mar 6 04:46:02 PST 2014


I think this broke AddressSanitizer bootstrap:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/2521/steps/check-clang%20asan/logs/stdio

ERROR: AddressSanitizer: heap-use-after-free on address 0x60300000dff0
at pc 0x675fd7e bp 0x7fffd300c690 sp 0x7fffd300c688
READ of size 2 at 0x60300000dff0 thread T0
    #0 0x675fd7d in clang::HeaderSearch::LookupFile(llvm::StringRef,
clang::SourceLocation, bool, clang::DirectoryLookup const*,
clang::DirectoryLookup const*&, llvm::ArrayRef<clang::FileEntry
const*>, llvm::SmallVectorImpl<char>*, llvm::SmallVectorImpl<char>*,
clang::ModuleMap::KnownHeader*, bool)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/HeaderSearch.cpp:617
    #1 0x6803045 in
clang::Preprocessor::LookupFile(clang::SourceLocation,
llvm::StringRef, bool, clang::DirectoryLookup const*,
clang::DirectoryLookup const*&, llvm::SmallVectorImpl<char>*,
llvm::SmallVectorImpl<char>*, clang::ModuleMap::KnownHeader*, bool)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/PPDirectives.cpp:598
    #2 0x2aab471 in ParseDirective(llvm::StringRef,
clang::VerifyDiagnosticConsumer::ExpectedData*, clang::SourceManager&,
clang::Preprocessor*, clang::SourceLocation,
clang::VerifyDiagnosticConsumer::DirectiveStatus&)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp:398
    #3 0x2aaa50a in
clang::VerifyDiagnosticConsumer::HandleComment(clang::Preprocessor&,
clang::SourceRange)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp:531
    #4 0x2aae35c in non-virtual thunk to
clang::VerifyDiagnosticConsumer::HandleComment(clang::Preprocessor&,
clang::SourceRange)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp:563
    #5 0x68abe1d in clang::Preprocessor::HandleComment(clang::Token&,
clang::SourceRange)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/Preprocessor.cpp:817
    #6 0x6784d14 in clang::Lexer::SkipLineComment(clang::Token&, char
const*, bool&) /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/Lexer.cpp:2131
    #7 0x678e96c in clang::Lexer::LexTokenInternal(clang::Token&,
bool) /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/Lexer.cpp:3334
    #8 0x67888e6 in clang::Lexer::Lex(clang::Token&)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/Lexer.cpp:2905
    #9 0x68a8d21 in clang::Preprocessor::Lex(clang::Token&)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/Preprocessor.cpp:672
    #10 0x4830852 in clang::ParseAST(clang::Sema&, bool, bool)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Parse/ParseAST.cpp:123
    #11 0x2a21dd3 in clang::FrontendAction::Execute()
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:403
    #12 0x29a3d47 in
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:722
    #13 0x2bc3b1c in
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:239
    #14 0x773890 in cc1_main(char const**, char const**, char const*,
void*) /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/driver/cc1_main.cpp:101
    #15 0x76e2f4 in main
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/driver/driver.cpp:314
    #16 0x7fbf7fd87ed4 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21ed4)
    #17 0x767d6a in _start
(/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm_build_asan/bin/clang-3.5+0x767d6a)

0x60300000dff0 is located 0 bytes inside of 32-byte region
[0x60300000dff0,0x60300000e010)
freed by thread T0 here:
    #0 0x74bf60 in operator delete(void*)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:94
    #1 0x67671a2 in deallocate
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ext/new_allocator.h:110
    #2 0x67671a2 in _M_deallocate
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:174
    #3 0x67671a2 in std::vector<clang::HeaderFileInfo,
std::allocator<clang::HeaderFileInfo> >::_M_default_append(unsigned
long) /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/vector.tcc:570
    #4 0x67651cc in resize
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:667
    #5 0x67651cc in
clang::HeaderSearch::MarkFileModuleHeader(clang::FileEntry const*,
clang::ModuleMap::ModuleHeaderRole, bool)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/HeaderSearch.cpp:989
    #6 0x67d115c in clang::ModuleMap::addHeader(clang::Module*,
clang::FileEntry const*, clang::ModuleMap::ModuleHeaderRole)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/ModuleMap.cpp:738
    #7 0x67e5843 in
clang::ModuleMapParser::parseHeaderDecl(clang::MMToken::TokenKind,
clang::SourceLocation)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/ModuleMap.cpp:1664
    #8 0x67d8bc3 in clang::ModuleMapParser::parseModuleDecl()
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/ModuleMap.cpp:1414
    #9 0x67ea326 in clang::ModuleMapParser::parseModuleMapFile()
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/ModuleMap.cpp:2177
    #10 0x67cf18b in
clang::ModuleMap::parseModuleMapFile(clang::FileEntry const*, bool)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/ModuleMap.cpp:2224
    #11 0x6757924 in
clang::HeaderSearch::loadModuleMapFile(clang::DirectoryEntry const*,
bool) /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/HeaderSearch.cpp:1189
    #12 0x6765802 in
clang::HeaderSearch::hasModuleMap(llvm::StringRef,
clang::DirectoryEntry const*, bool)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/HeaderSearch.cpp:1066
    #13 0x675a8fc in getFileAndSuggestModule(clang::HeaderSearch&,
llvm::StringRef, clang::DirectoryEntry const*, bool,
clang::ModuleMap::KnownHeader*)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/HeaderSearch.cpp:228
    #14 0x675dd85 in clang::HeaderSearch::LookupFile(llvm::StringRef,
clang::SourceLocation, bool, clang::DirectoryLookup const*,
clang::DirectoryLookup const*&, llvm::ArrayRef<clang::FileEntry
const*>, llvm::SmallVectorImpl<char>*, llvm::SmallVectorImpl<char>*,
clang::ModuleMap::KnownHeader*, bool)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/HeaderSearch.cpp:608
    #15 0x6803045 in
clang::Preprocessor::LookupFile(clang::SourceLocation,
llvm::StringRef, bool, clang::DirectoryLookup const*,
clang::DirectoryLookup const*&, llvm::SmallVectorImpl<char>*,
llvm::SmallVectorImpl<char>*, clang::ModuleMap::KnownHeader*, bool)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/PPDirectives.cpp:598
    #16 0x2aab471 in ParseDirective(llvm::StringRef,
clang::VerifyDiagnosticConsumer::ExpectedData*, clang::SourceManager&,
clang::Preprocessor*, clang::SourceLocation,
clang::VerifyDiagnosticConsumer::DirectiveStatus&)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp:398
    #17 0x2aaa50a in
clang::VerifyDiagnosticConsumer::HandleComment(clang::Preprocessor&,
clang::SourceRange)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp:531
    #18 0x2aae35c in non-virtual thunk to
clang::VerifyDiagnosticConsumer::HandleComment(clang::Preprocessor&,
clang::SourceRange)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp:563
    #19 0x68abe1d in clang::Preprocessor::HandleComment(clang::Token&,
clang::SourceRange)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/Preprocessor.cpp:817
    #20 0x6784d14 in clang::Lexer::SkipLineComment(clang::Token&, char
const*, bool&) /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/Lexer.cpp:2131
    #21 0x678e96c in clang::Lexer::LexTokenInternal(clang::Token&,
bool) /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/Lexer.cpp:3334
    #22 0x67888e6 in clang::Lexer::Lex(clang::Token&)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/Lexer.cpp:2905
    #23 0x68a8d21 in clang::Preprocessor::Lex(clang::Token&)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/Preprocessor.cpp:672
    #24 0x4830852 in clang::ParseAST(clang::Sema&, bool, bool)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Parse/ParseAST.cpp:123
    #25 0x2a21dd3 in clang::FrontendAction::Execute()
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:403
    #26 0x29a3d47 in
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:722
    #27 0x2bc3b1c in
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:239
    #28 0x773890 in cc1_main(char const**, char const**, char const*,
void*) /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/driver/cc1_main.cpp:101
    #29 0x76e2f4 in main
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/driver/driver.cpp:314
    #30 0x7fbf7fd87ed4 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21ed4)

previously allocated by thread T0 here:
    #0 0x74b9e0 in operator new(unsigned long)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:62
    #1 0x6766fcd in allocate
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ext/new_allocator.h:104
    #2 0x6766fcd in _M_allocate
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:168
    #3 0x6766fcd in std::vector<clang::HeaderFileInfo,
std::allocator<clang::HeaderFileInfo> >::_M_default_append(unsigned
long) /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/vector.tcc:549
    #4 0x67615a2 in resize
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_vector.h:667
    #5 0x67615a2 in clang::HeaderSearch::getFileInfo(clang::FileEntry
const*) /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/HeaderSearch.cpp:963
    #6 0x68a5df1 in IncrementIncludeCount
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/include/clang/Lex/HeaderSearch.h:438
    #7 0x68a5df1 in clang::Preprocessor::EnterMainSourceFile()
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Lex/Preprocessor.cpp:481
    #8 0x4830845 in clang::ParseAST(clang::Sema&, bool, bool)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Parse/ParseAST.cpp:122
    #9 0x2a21dd3 in clang::FrontendAction::Execute()
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Frontend/FrontendAction.cpp:403
    #10 0x29a3d47 in
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/Frontend/CompilerInstance.cpp:722
    #11 0x2bc3b1c in
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:239
    #12 0x773890 in cc1_main(char const**, char const**, char const*,
void*) /home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/driver/cc1_main.cpp:101
    #13 0x76e2f4 in main
/home/dtoolsbot/build/sanitizer-x86_64-linux-bootstrap/build/llvm/tools/clang/tools/driver/driver.cpp:314
    #14 0x7fbf7fd87ed4 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21ed4)


On Thu, Mar 6, 2014 at 12:51 AM, Richard Smith
<richard-llvm at metafoo.co.uk> wrote:
> Author: rsmith
> Date: Wed Mar  5 14:51:45 2014
> New Revision: 203005
>
> URL: http://llvm.org/viewvc/llvm-project?rev=203005&view=rev
> Log:
> If a #include finds a file relative to the current file, don't forget to check
> whether it's part of a module.
>
> Added:
>     cfe/trunk/test/Modules/Inputs/recursive1.h
>     cfe/trunk/test/Modules/Inputs/recursive2.h
>     cfe/trunk/test/Modules/recursive.c
> Modified:
>     cfe/trunk/lib/Lex/HeaderSearch.cpp
>     cfe/trunk/lib/Lex/ModuleMap.cpp
>     cfe/trunk/test/Modules/Inputs/module.map
>     cfe/trunk/test/Modules/submodules.cpp
>
> Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=203005&r1=203004&r2=203005&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
> +++ cfe/trunk/lib/Lex/HeaderSearch.cpp Wed Mar  5 14:51:45 2014
> @@ -219,6 +219,32 @@ const char *DirectoryLookup::getName() c
>    return getHeaderMap()->getFileName();
>  }
>
> +static const FileEntry *
> +getFileAndSuggestModule(HeaderSearch &HS, StringRef FileName,
> +                        const DirectoryEntry *Dir, bool IsSystemHeaderDir,
> +                        ModuleMap::KnownHeader *SuggestedModule) {
> +  // If we have a module map that might map this header, load it and
> +  // check whether we'll have a suggestion for a module.
> +  HS.hasModuleMap(FileName, Dir, IsSystemHeaderDir);
> +  if (SuggestedModule) {
> +    const FileEntry *File = HS.getFileMgr().getFile(FileName,
> +                                                    /*OpenFile=*/false);
> +    if (File) {
> +      // If there is a module that corresponds to this header, suggest it.
> +      *SuggestedModule = HS.findModuleForHeader(File);
> +
> +      // FIXME: This appears to be a no-op. We loaded the module map for this
> +      // directory at the start of this function.
> +      if (!SuggestedModule->getModule() &&
> +          HS.hasModuleMap(FileName, Dir, IsSystemHeaderDir))
> +        *SuggestedModule = HS.findModuleForHeader(File);
> +    }
> +
> +    return File;
> +  }
> +
> +  return HS.getFileMgr().getFile(FileName, /*openFile=*/true);
> +}
>
>  /// LookupFile - Lookup the specified file in this search path, returning it
>  /// if it exists or returning null if not.
> @@ -246,25 +272,10 @@ const FileEntry *DirectoryLookup::Lookup
>        RelativePath->clear();
>        RelativePath->append(Filename.begin(), Filename.end());
>      }
> -
> -    // If we have a module map that might map this header, load it and
> -    // check whether we'll have a suggestion for a module.
> -    HS.hasModuleMap(TmpDir, getDir(), isSystemHeaderDirectory());
> -    if (SuggestedModule) {
> -      const FileEntry *File = HS.getFileMgr().getFile(TmpDir.str(),
> -                                                      /*openFile=*/false);
> -      if (!File)
> -        return File;
> -
> -      // If there is a module that corresponds to this header, suggest it.
> -      *SuggestedModule = HS.findModuleForHeader(File);
> -      if (!SuggestedModule->getModule() &&
> -          HS.hasModuleMap(TmpDir, getDir(), isSystemHeaderDirectory()))
> -        *SuggestedModule = HS.findModuleForHeader(File);
> -      return File;
> -    }
> -
> -    return HS.getFileMgr().getFile(TmpDir.str(), /*openFile=*/true);
> +
> +    return getFileAndSuggestModule(HS, TmpDir.str(), getDir(),
> +                                   isSystemHeaderDirectory(),
> +                                   SuggestedModule);
>    }
>
>    if (isFramework())
> @@ -573,6 +584,7 @@ const FileEntry *HeaderSearch::LookupFil
>
>    // This is the header that MSVC's header search would have found.
>    const FileEntry *MSFE = 0;
> +  ModuleMap::KnownHeader MSSuggestedModule;
>
>    // Unless disabled, check to see if the file is in the #includer's
>    // directory.  This cannot be based on CurDir, because each includer could be
> @@ -590,15 +602,18 @@ const FileEntry *HeaderSearch::LookupFil
>        TmpDir = Includer->getDir()->getName();
>        TmpDir.push_back('/');
>        TmpDir.append(Filename.begin(), Filename.end());
> +
> +      HeaderFileInfo &FromHFI = getFileInfo(Includer);
>        if (const FileEntry *FE =
> -              FileMgr.getFile(TmpDir.str(), /*openFile=*/true)) {
> +              getFileAndSuggestModule(*this, TmpDir.str(), Includer->getDir(),
> +                                      FromHFI.DirInfo != SrcMgr::C_User,
> +                                      SuggestedModule)) {
>          // Leave CurDir unset.
>          // This file is a system header or C++ unfriendly if the old file is.
>          //
>          // Note that we only use one of FromHFI/ToHFI at once, due to potential
>          // reallocation of the underlying vector potentially making the first
>          // reference binding dangling.
> -        HeaderFileInfo &FromHFI = getFileInfo(Includer);
>          unsigned DirInfo = FromHFI.DirInfo;
>          bool IndexHeaderMapHeader = FromHFI.IndexHeaderMapHeader;
>          StringRef Framework = FromHFI.Framework;
> @@ -629,6 +644,10 @@ const FileEntry *HeaderSearch::LookupFil
>            return FE;
>          } else {
>            MSFE = FE;
> +          if (SuggestedModule) {
> +            MSSuggestedModule = *SuggestedModule;
> +            *SuggestedModule = ModuleMap::KnownHeader();
> +          }
>            break;
>          }
>        }
> @@ -709,8 +728,11 @@ const FileEntry *HeaderSearch::LookupFil
>        }
>      }
>
> -    if (checkMSVCHeaderSearch(Diags, MSFE, FE, IncludeLoc))
> +    if (checkMSVCHeaderSearch(Diags, MSFE, FE, IncludeLoc)) {
> +      if (SuggestedModule)
> +        *SuggestedModule = MSSuggestedModule;
>        return MSFE;
> +    }
>
>      // Remember this location for the next lookup we do.
>      CacheLookup.second = i;
> @@ -734,19 +756,26 @@ const FileEntry *HeaderSearch::LookupFil
>            ScratchFilename, IncludeLoc, /*isAngled=*/true, FromDir, CurDir,
>            Includers.front(), SearchPath, RelativePath, SuggestedModule);
>
> -      if (checkMSVCHeaderSearch(Diags, MSFE, FE, IncludeLoc))
> +      if (checkMSVCHeaderSearch(Diags, MSFE, FE, IncludeLoc)) {
> +        if (SuggestedModule)
> +          *SuggestedModule = MSSuggestedModule;
>          return MSFE;
> +      }
>
>        std::pair<unsigned, unsigned> &CacheLookup
>          = LookupFileCache.GetOrCreateValue(Filename).getValue();
>        CacheLookup.second
>          = LookupFileCache.GetOrCreateValue(ScratchFilename).getValue().second;
> +      // FIXME: SuggestedModule.
>        return FE;
>      }
>    }
>
> -  if (checkMSVCHeaderSearch(Diags, MSFE, 0, IncludeLoc))
> +  if (checkMSVCHeaderSearch(Diags, MSFE, 0, IncludeLoc)) {
> +    if (SuggestedModule)
> +      *SuggestedModule = MSSuggestedModule;
>      return MSFE;
> +  }
>
>    // Otherwise, didn't find it. Remember we didn't find this.
>    CacheLookup.second = SearchDirs.size();
>
> Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=203005&r1=203004&r2=203005&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
> +++ cfe/trunk/lib/Lex/ModuleMap.cpp Wed Mar  5 14:51:45 2014
> @@ -297,6 +297,8 @@ ModuleMap::findModuleForHeader(const Fil
>        Result = *I;
>        // If 'File' is a public header of this module, this is as good as we
>        // are going to get.
> +      // FIXME: If we have a RequestingModule, we should prefer the header from
> +      // that module.
>        if (I->getRole() == ModuleMap::NormalHeader)
>          break;
>      }
>
> Modified: cfe/trunk/test/Modules/Inputs/module.map
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=203005&r1=203004&r2=203005&view=diff
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/module.map (original)
> +++ cfe/trunk/test/Modules/Inputs/module.map Wed Mar  5 14:51:45 2014
> @@ -290,3 +290,9 @@ module recursive_visibility_b {
>  module recursive_visibility_c {
>    header "recursive_visibility_c.h"
>  }
> +module recursive1 {
> +  header "recursive1.h"
> +}
> +module recursive2 {
> +  header "recursive2.h"
> +}
>
> Added: cfe/trunk/test/Modules/Inputs/recursive1.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/recursive1.h?rev=203005&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/recursive1.h (added)
> +++ cfe/trunk/test/Modules/Inputs/recursive1.h Wed Mar  5 14:51:45 2014
> @@ -0,0 +1 @@
> +#include "recursive2.h"
>
> Added: cfe/trunk/test/Modules/Inputs/recursive2.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/recursive2.h?rev=203005&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/Inputs/recursive2.h (added)
> +++ cfe/trunk/test/Modules/Inputs/recursive2.h Wed Mar  5 14:51:45 2014
> @@ -0,0 +1 @@
> +#include "recursive1.h"
>
> Added: cfe/trunk/test/Modules/recursive.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/recursive.c?rev=203005&view=auto
> ==============================================================================
> --- cfe/trunk/test/Modules/recursive.c (added)
> +++ cfe/trunk/test/Modules/recursive.c Wed Mar  5 14:51:45 2014
> @@ -0,0 +1,11 @@
> +// RUN: rm -rf %t
> +// RUN: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s 2>&1 | FileCheck %s
> +#include "recursive1.h"
> +
> +// FIXME: rm -rf %t
> +// FIXME: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=recursive1 %S/Inputs/module.map 2>&1 | FileCheck %s
> +
> +// CHECK:      While building module 'recursive1'{{( imported from .*/recursive.c:3)?}}:
> +// CHECK-NEXT: While building module 'recursive2' imported from {{.*}}Inputs/recursive1.h:1:
> +// CHECK-NEXT: In file included from <module-includes>:1:
> +// CHECK-NEXT: recursive2.h:1:10: fatal error: cyclic dependency in module 'recursive1': recursive1 -> recursive2 -> recursive1
>
> Modified: cfe/trunk/test/Modules/submodules.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/submodules.cpp?rev=203005&r1=203004&r2=203005&view=diff
> ==============================================================================
> --- cfe/trunk/test/Modules/submodules.cpp (original)
> +++ cfe/trunk/test/Modules/submodules.cpp Wed Mar  5 14:51:45 2014
> @@ -31,9 +31,7 @@ hash_map<int, float> ints_to_floats2;
>  extern MyTypeA import_self_test_a; // expected-error {{must be imported from module 'import_self.a'}}
>  // expected-note at import-self-a.h:1 {{here}}
>  extern MyTypeC import_self_test_c;
> -// FIXME: This should be valid; import_self.b re-exports import_self.d.
> -extern MyTypeD import_self_test_d; // expected-error {{must be imported from module 'import_self.d'}}
> -// expected-note at import-self-d.h:1 {{here}}
> +extern MyTypeD import_self_test_d;
>
>  // expected-error at Inputs/submodules/module.map:15{{header 'missing.h' not found}}
>  @import missing_headers.missing;
>
>
> _______________________________________________
> 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