diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-12-31 04:05:44 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-12-31 04:05:44 +0000 |
commit | 1fb5c3a63a88e4758b196f1bda64eecce9b29d3f (patch) | |
tree | 0da4770b525e3b6a77a4b54bd828262d2bda7dfa /clang/lib/Frontend/CompilerInstance.cpp | |
parent | 84a5dfdf727df09432aaa40ac72aa94e500326e4 (diff) | |
download | bcm5719-llvm-1fb5c3a63a88e4758b196f1bda64eecce9b29d3f.tar.gz bcm5719-llvm-1fb5c3a63a88e4758b196f1bda64eecce9b29d3f.zip |
Implement support for module requirements, which indicate the language
features needed for a particular module to be available. This allows
mixed-language modules, where certain headers only work under some
language variants (e.g., in C++, std.tuple might only be available in
C++11 mode).
llvm-svn: 147387
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 12d368501ce..498f6fbfc09 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -252,7 +252,8 @@ void CompilerInstance::createPreprocessor() { // Create the Preprocessor. HeaderSearch *HeaderInfo = new HeaderSearch(getFileManager(), - getDiagnostics()); + getDiagnostics(), + getLangOpts()); PP = new Preprocessor(getDiagnostics(), getLangOpts(), &getTarget(), getSourceManager(), *HeaderInfo, *this, PTHMgr, /*OwnsHeaderSearch=*/true); @@ -1284,6 +1285,19 @@ Module *CompilerInstance::loadModule(SourceLocation ImportLoc, return 0; } + + // Check whether this module is available. + StringRef Feature; + if (!Module->isAvailable(getLangOpts(), Feature)) { + getDiagnostics().Report(ImportLoc, diag::err_module_unavailable) + << Module->getFullModuleName() + << Feature + << SourceRange(Path.front().second, Path.back().second); + LastModuleImportLoc = ImportLoc; + LastModuleImportResult = 0; + return 0; + } + ModuleManager->makeModuleVisible(Module, Visibility); } |