diff options
| author | Daniel Jasper <djasper@google.com> | 2013-08-05 20:26:17 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-08-05 20:26:17 +0000 |
| commit | 07e6c407bc67ed4f5fc88d2382df26bb7b3def4f (patch) | |
| tree | 2cc95b66272fe5cd0df57f1989510ede226e5bc4 /clang/lib/Lex | |
| parent | dffe59932b42afb2236f5187f7553cbc80145701 (diff) | |
| download | bcm5719-llvm-07e6c407bc67ed4f5fc88d2382df26bb7b3def4f.tar.gz bcm5719-llvm-07e6c407bc67ed4f5fc88d2382df26bb7b3def4f.zip | |
Add option to disable module loading.
This patch was created by Lawrence Crowl and reviewed in:
http://llvm-reviews.chandlerc.com/D963
llvm-svn: 187738
Diffstat (limited to 'clang/lib/Lex')
| -rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 21 | ||||
| -rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 2 |
2 files changed, 13 insertions, 10 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index c70019ffb09..ef0cbd656f9 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -17,6 +17,7 @@ #include "clang/Basic/SourceManager.h" #include "clang/Lex/CodeCompletionHandler.h" #include "clang/Lex/HeaderSearch.h" +#include "clang/Lex/HeaderSearchOptions.h" #include "clang/Lex/LexDiagnostic.h" #include "clang/Lex/LiteralSupport.h" #include "clang/Lex/MacroInfo.h" @@ -1421,7 +1422,7 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, const FileEntry *File = LookupFile( FilenameLoc, Filename, isAngled, LookupFrom, CurDir, Callbacks ? &SearchPath : NULL, Callbacks ? &RelativePath : NULL, - getLangOpts().Modules? &SuggestedModule : 0); + HeaderInfo.getHeaderSearchOpts().ModuleMaps ? &SuggestedModule : 0); if (Callbacks) { if (!File) { @@ -1435,13 +1436,15 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, // Try the lookup again, skipping the cache. File = LookupFile(FilenameLoc, Filename, isAngled, LookupFrom, CurDir, - 0, 0, getLangOpts().Modules? &SuggestedModule : 0, - /*SkipCache*/true); + 0, 0, HeaderInfo.getHeaderSearchOpts().ModuleMaps + ? &SuggestedModule + : 0, + /*SkipCache*/ true); } } } - if (!SuggestedModule) { + if (!SuggestedModule || !getLangOpts().Modules) { // Notify the callback object that we've seen an inclusion directive. Callbacks->InclusionDirective(HashLoc, IncludeTok, Filename, isAngled, FilenameRange, File, @@ -1456,10 +1459,10 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, // brackets, we can attempt a lookup as though it were a quoted path to // provide the user with a possible fixit. if (isAngled) { - File = LookupFile(FilenameLoc, Filename, false, LookupFrom, CurDir, - Callbacks ? &SearchPath : 0, - Callbacks ? &RelativePath : 0, - getLangOpts().Modules ? &SuggestedModule : 0); + File = LookupFile( + FilenameLoc, Filename, false, LookupFrom, CurDir, + Callbacks ? &SearchPath : 0, Callbacks ? &RelativePath : 0, + HeaderInfo.getHeaderSearchOpts().ModuleMaps ? &SuggestedModule : 0); if (File) { SourceRange Range(FilenameTok.getLocation(), CharEnd); Diag(FilenameTok, diag::err_pp_file_not_found_not_fatal) << @@ -1477,7 +1480,7 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc, // If we are supposed to import a module rather than including the header, // do so now. - if (SuggestedModule) { + if (SuggestedModule && getLangOpts().Modules) { // Compute the module access path corresponding to this module. // FIXME: Should we have a second loadModule() overload to avoid this // extra lookup step? diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 66f23f10188..035f751d0d2 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -734,7 +734,7 @@ void Preprocessor::LexAfterModuleImport(Token &Result) { } // If we have a non-empty module path, load the named module. - if (!ModuleImportPath.empty()) { + if (!ModuleImportPath.empty() && getLangOpts().Modules) { Module *Imported = TheModuleLoader.loadModule(ModuleImportLoc, ModuleImportPath, Module::MacrosVisible, |

