diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-05-18 05:35:52 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-05-18 05:35:52 +0000 |
commit | bca31b731b3eb6d4614e25c003355ec2446fc027 (patch) | |
tree | ae277f3400c417b00ddd6b115f572e7f56b2d65d /clang/lib/Sema/SemaDecl.cpp | |
parent | e3acc8bc56dce55a79f5c7fa5d3c02c97c11a6fc (diff) | |
download | bcm5719-llvm-bca31b731b3eb6d4614e25c003355ec2446fc027.tar.gz bcm5719-llvm-bca31b731b3eb6d4614e25c003355ec2446fc027.zip |
[modules] Move implicit creation of ImportDecls for #includes transformed into module imports from the frontend into Sema where it belongs.
llvm-svn: 237555
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 8c079f8647d..316700dc3d5 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -14113,7 +14113,26 @@ DeclResult Sema::ActOnModuleImport(SourceLocation AtLoc, void Sema::ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod) { checkModuleImportContext(*this, Mod, DirectiveLoc, CurContext); - // FIXME: Should we synthesize an ImportDecl here? + // Determine whether we're in the #include buffer for a module. The #includes + // in that buffer do not qualify as module imports; they're just an + // implementation detail of us building the module. + // + // FIXME: Should we even get ActOnModuleInclude calls for those? + bool IsInModuleIncludes = + TUKind == TU_Module && + getSourceManager().isWrittenInMainFile(DirectiveLoc); + + // If this module import was due to an inclusion directive, create an + // implicit import declaration to capture it in the AST. + if (!IsInModuleIncludes) { + TranslationUnitDecl *TU = getASTContext().getTranslationUnitDecl(); + ImportDecl *ImportD = ImportDecl::CreateImplicit(getASTContext(), TU, + DirectiveLoc, Mod, + DirectiveLoc); + TU->addDecl(ImportD); + Consumer.HandleImplicitImportDecl(ImportD); + } + getModuleLoader().makeModuleVisible(Mod, Module::AllVisible, DirectiveLoc); VisibleModules.setVisible(Mod, DirectiveLoc); } |