summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-12-02 23:23:56 +0000
committerDouglas Gregor <dgregor@apple.com>2011-12-02 23:23:56 +0000
commitba34552e79aaf7ac5db21a7b6e9c00aab75f4732 (patch)
tree73d479ee4d1220393f08cd83e51bb3d97f872004 /clang/lib/Sema
parent45ccba64ab34275cf272df01ae838524b94f5e2b (diff)
downloadbcm5719-llvm-ba34552e79aaf7ac5db21a7b6e9c00aab75f4732.tar.gz
bcm5719-llvm-ba34552e79aaf7ac5db21a7b6e9c00aab75f4732.zip
Introduce a module import declaration, so that we properly represent, e.g.,
__import_module__ std.vector; in the AST. llvm-svn: 145725
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 1e57a00f1f1..01c7906e800 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9897,9 +9897,24 @@ DeclResult Sema::ActOnModuleImport(SourceLocation ImportLoc, ModuleIdPath Path)
if (!Mod)
return true;
- // FIXME: Actually create a declaration to describe the module import.
- (void)Mod;
- return DeclResult((Decl *)0);
+ llvm::SmallVector<SourceLocation, 2> IdentifierLocs;
+ Module *ModCheck = Mod;
+ for (unsigned I = 0, N = Path.size(); I != N; ++I) {
+ // If we've run out of module parents, just drop the remaining identifiers.
+ // We need the length to be consistent.
+ if (!ModCheck)
+ break;
+ ModCheck = ModCheck->Parent;
+
+ IdentifierLocs.push_back(Path[I].second);
+ }
+
+ ImportDecl *Import = ImportDecl::Create(Context,
+ Context.getTranslationUnitDecl(),
+ ImportLoc, Mod,
+ IdentifierLocs);
+ Context.getTranslationUnitDecl()->addDecl(Import);
+ return Import;
}
void
OpenPOWER on IntegriCloud