forked from OSchip/llvm-project
Teach subframework header lookup to suggest modules <rdar://problem/13176200>.
llvm-svn: 174683
This commit is contained in:
parent
cff2b27bf4
commit
f5f9452808
|
@ -363,7 +363,8 @@ public:
|
|||
StringRef Filename,
|
||||
const FileEntry *RelativeFileEnt,
|
||||
SmallVectorImpl<char> *SearchPath,
|
||||
SmallVectorImpl<char> *RelativePath);
|
||||
SmallVectorImpl<char> *RelativePath,
|
||||
Module **SuggestedModule);
|
||||
|
||||
/// \brief Look up the specified framework name in our framework cache.
|
||||
/// \returns The DirectoryEntry it is in if we know, null otherwise.
|
||||
|
|
|
@ -665,7 +665,8 @@ const FileEntry *HeaderSearch::
|
|||
LookupSubframeworkHeader(StringRef Filename,
|
||||
const FileEntry *ContextFileEnt,
|
||||
SmallVectorImpl<char> *SearchPath,
|
||||
SmallVectorImpl<char> *RelativePath) {
|
||||
SmallVectorImpl<char> *RelativePath,
|
||||
Module **SuggestedModule) {
|
||||
assert(ContextFileEnt && "No context file?");
|
||||
|
||||
// Framework names must have a '/' in the filename. Find it.
|
||||
|
@ -754,6 +755,26 @@ LookupSubframeworkHeader(StringRef Filename,
|
|||
// of evaluation.
|
||||
unsigned DirInfo = getFileInfo(ContextFileEnt).DirInfo;
|
||||
getFileInfo(FE).DirInfo = DirInfo;
|
||||
|
||||
// If we're supposed to suggest a module, look for one now.
|
||||
if (SuggestedModule) {
|
||||
// Find the top-level framework based on this framework.
|
||||
FrameworkName.pop_back(); // remove the trailing '/'
|
||||
SmallVector<std::string, 4> SubmodulePath;
|
||||
const DirectoryEntry *TopFrameworkDir
|
||||
= ::getTopFrameworkDir(FileMgr, FrameworkName, SubmodulePath);
|
||||
|
||||
// Determine the name of the top-level framework.
|
||||
StringRef ModuleName = llvm::sys::path::stem(TopFrameworkDir->getName());
|
||||
|
||||
// Load this framework module. If that succeeds, find the suggested module
|
||||
// for this header, if any.
|
||||
bool IsSystem = false;
|
||||
if (loadFrameworkModule(ModuleName, TopFrameworkDir, IsSystem)) {
|
||||
*SuggestedModule = findModuleForHeader(FE);
|
||||
}
|
||||
}
|
||||
|
||||
return FE;
|
||||
}
|
||||
|
||||
|
|
|
@ -537,11 +537,11 @@ const FileEntry *Preprocessor::LookupFile(
|
|||
// Otherwise, see if this is a subframework header. If so, this is relative
|
||||
// to one of the headers on the #include stack. Walk the list of the current
|
||||
// headers on the #include stack and pass them to HeaderInfo.
|
||||
// FIXME: SuggestedModule!
|
||||
if (IsFileLexer()) {
|
||||
if ((CurFileEnt = SourceMgr.getFileEntryForID(CurPPLexer->getFileID())))
|
||||
if ((FE = HeaderInfo.LookupSubframeworkHeader(Filename, CurFileEnt,
|
||||
SearchPath, RelativePath)))
|
||||
SearchPath, RelativePath,
|
||||
SuggestedModule)))
|
||||
return FE;
|
||||
}
|
||||
|
||||
|
@ -551,7 +551,8 @@ const FileEntry *Preprocessor::LookupFile(
|
|||
if ((CurFileEnt =
|
||||
SourceMgr.getFileEntryForID(ISEntry.ThePPLexer->getFileID())))
|
||||
if ((FE = HeaderInfo.LookupSubframeworkHeader(
|
||||
Filename, CurFileEnt, SearchPath, RelativePath)))
|
||||
Filename, CurFileEnt, SearchPath, RelativePath,
|
||||
SuggestedModule)))
|
||||
return FE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ int glob;
|
|||
// CHECK-DMOD-NEXT: [ppIncludedFile]: [[DMOD_PRIVATE_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]PrivateHeaders[/\\]DependsOnModulePrivate.h]] | {{.*}} | hash loc: <invalid>
|
||||
// CHECK-DMOD-NEXT: [importedASTFile]: {{.*}}.cache{{[/\\]}}Module.pcm | loc: [[DMOD_MODULE_H]]:1:2 | name: "Module" | isImplicit: 1
|
||||
// CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: depends_on_module_other | {{.*}} | loc: [[DMOD_OTHER_H]]:1:5
|
||||
// CHECK-DMOD-NEXT: [importedASTFile]: {{.*}}.cache/DependsOnModule.pcm | loc: {{.*}}SubFramework.h:1:2 | name: "DependsOnModule.SubFramework.Other" | isImplicit: 1
|
||||
// CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: sub_framework | {{.*}} | loc: [[DMOD_SUB_H]]:2:8
|
||||
// CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: sub_framework_other | {{.*}} | loc: [[DMOD_SUB_OTHER_H]]:1:9
|
||||
// CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: depends_on_module_private | {{.*}} | loc: [[DMOD_PRIVATE_H]]:1:5
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
#include <Sub/Types.h>
|
|
@ -0,0 +1,4 @@
|
|||
struct FrameworkSubStruct {
|
||||
const char * name;
|
||||
unsigned version;
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
#include <Sub/Types.h>
|
|
@ -0,0 +1 @@
|
|||
#import <Sub/Sub.h>
|
|
@ -0,0 +1,2 @@
|
|||
#import <Sub/SubPriv.h>
|
||||
|
|
@ -20,3 +20,10 @@ void testSubFrameworkAgain() {
|
|||
|
||||
CXXOnly cxxonly;
|
||||
#endif
|
||||
|
||||
@import HasSubModules;
|
||||
|
||||
// expected-warning@1{{treating #include as an import of module 'HasSubModules.Sub.Types'}}
|
||||
#import <HasSubModules/HasSubModulesPriv.h>
|
||||
|
||||
struct FrameworkSubStruct ss;
|
||||
|
|
Loading…
Reference in New Issue