diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Basic/Module.cpp | 13 | ||||
-rw-r--r-- | lib/Frontend/ASTUnit.cpp | 3 | ||||
-rw-r--r-- | lib/Frontend/CompilerInstance.cpp | 5 | ||||
-rw-r--r-- | lib/Frontend/FrontendActions.cpp | 2 | ||||
-rw-r--r-- | lib/Lex/HeaderSearch.cpp | 9 | ||||
-rw-r--r-- | lib/Lex/ModuleMap.cpp | 13 | ||||
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 4 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 3 |
8 files changed, 36 insertions, 16 deletions
diff --git a/lib/Basic/Module.cpp b/lib/Basic/Module.cpp index 015f421f9d..3052532650 100644 --- a/lib/Basic/Module.cpp +++ b/lib/Basic/Module.cpp @@ -47,7 +47,8 @@ Module::~Module() { /// \brief Determine whether a translation unit built using the current /// language options has the given feature. -static bool hasFeature(StringRef Feature, const LangOptions &LangOpts) { +static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, + const TargetInfo &Target) { return llvm::StringSwitch<bool>(Feature) .Case("blocks", LangOpts.Blocks) .Case("cplusplus", LangOpts.CPlusPlus) @@ -58,13 +59,14 @@ static bool hasFeature(StringRef Feature, const LangOptions &LangOpts) { } bool -Module::isAvailable(const LangOptions &LangOpts, StringRef &Feature) const { +Module::isAvailable(const LangOptions &LangOpts, const TargetInfo &Target, + StringRef &Feature) const { if (IsAvailable) return true; for (const Module *Current = this; Current; Current = Current->Parent) { for (unsigned I = 0, N = Current->Requires.size(); I != N; ++I) { - if (!hasFeature(Current->Requires[I], LangOpts)) { + if (!hasFeature(Current->Requires[I], LangOpts, Target)) { Feature = Current->Requires[I]; return false; } @@ -121,11 +123,12 @@ const DirectoryEntry *Module::getUmbrellaDir() const { return Umbrella.dyn_cast<const DirectoryEntry *>(); } -void Module::addRequirement(StringRef Feature, const LangOptions &LangOpts) { +void Module::addRequirement(StringRef Feature, const LangOptions &LangOpts, + const TargetInfo &Target) { Requires.push_back(Feature); // If this feature is currently available, we're done. - if (hasFeature(Feature, LangOpts)) + if (hasFeature(Feature, LangOpts, Target)) return; if (!IsAvailable) diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index abeb3174bd..ff75e3a4f2 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -673,7 +673,8 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename, AST->getFileManager()); AST->HeaderInfo.reset(new HeaderSearch(AST->getFileManager(), AST->getDiagnostics(), - AST->ASTFileLangOpts)); + AST->ASTFileLangOpts, + /*Target=*/0)); for (unsigned I = 0; I != NumRemappedFiles; ++I) { FilenameOrMemBuf fileOrBuf = RemappedFiles[I].second; diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index e8afe6dba1..1501da4ff4 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -242,7 +242,8 @@ void CompilerInstance::createPreprocessor() { // Create the Preprocessor. HeaderSearch *HeaderInfo = new HeaderSearch(getFileManager(), getDiagnostics(), - getLangOpts()); + getLangOpts(), + &getTarget()); PP = new Preprocessor(getDiagnostics(), getLangOpts(), &getTarget(), getSourceManager(), *HeaderInfo, *this, PTHMgr, /*OwnsHeaderSearch=*/true); @@ -1045,7 +1046,7 @@ Module *CompilerInstance::loadModule(SourceLocation ImportLoc, // Check whether this module is available. StringRef Feature; - if (!Module->isAvailable(getLangOpts(), Feature)) { + if (!Module->isAvailable(getLangOpts(), getTarget(), Feature)) { getDiagnostics().Report(ImportLoc, diag::err_module_unavailable) << Module->getFullModuleName() << Feature diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp index 669fe4acb3..c0302329c1 100644 --- a/lib/Frontend/FrontendActions.cpp +++ b/lib/Frontend/FrontendActions.cpp @@ -237,7 +237,7 @@ bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI, // Check whether we can build this module at all. StringRef Feature; - if (!Module->isAvailable(CI.getLangOpts(), Feature)) { + if (!Module->isAvailable(CI.getLangOpts(), CI.getTarget(), Feature)) { CI.getDiagnostics().Report(diag::err_module_unavailable) << Module->getFullModuleName() << Feature; diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index e56eb6c915..e3a6c52ff4 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -39,9 +39,10 @@ HeaderFileInfo::getControllingMacro(ExternalIdentifierLookup *External) { ExternalHeaderFileInfoSource::~ExternalHeaderFileInfoSource() {} HeaderSearch::HeaderSearch(FileManager &FM, DiagnosticsEngine &Diags, - const LangOptions &LangOpts) + const LangOptions &LangOpts, + const TargetInfo *Target) : FileMgr(FM), Diags(Diags), FrameworkMap(64), - ModMap(FileMgr, *Diags.getClient(), LangOpts) + ModMap(FileMgr, *Diags.getClient(), LangOpts, Target) { AngledDirIdx = 0; SystemDirIdx = 0; @@ -365,6 +366,10 @@ const FileEntry *DirectoryLookup::DoFrameworkLookup( return FE; } +void HeaderSearch::setTarget(const TargetInfo &Target) { + ModMap.setTarget(Target); +} + //===----------------------------------------------------------------------===// // Header File Location. diff --git a/lib/Lex/ModuleMap.cpp b/lib/Lex/ModuleMap.cpp index 708da94585..3583b034d5 100644 --- a/lib/Lex/ModuleMap.cpp +++ b/lib/Lex/ModuleMap.cpp @@ -70,8 +70,8 @@ ModuleMap::resolveExport(Module *Mod, } ModuleMap::ModuleMap(FileManager &FileMgr, const DiagnosticConsumer &DC, - const LangOptions &LangOpts) - : LangOpts(LangOpts) + const LangOptions &LangOpts, const TargetInfo *Target) + : LangOpts(LangOpts), Target(Target) { llvm::IntrusiveRefCntPtr<DiagnosticIDs> DiagIDs(new DiagnosticIDs); Diags = llvm::IntrusiveRefCntPtr<DiagnosticsEngine>( @@ -90,6 +90,12 @@ ModuleMap::~ModuleMap() { delete SourceMgr; } +void ModuleMap::setTarget(const TargetInfo &Target) { + assert((!this->Target || this->Target == &Target) && + "Improper target override"); + this->Target = &Target; +} + Module *ModuleMap::findModuleForHeader(const FileEntry *File) { llvm::DenseMap<const FileEntry *, Module *>::iterator Known = Headers.find(File); @@ -992,7 +998,7 @@ void ModuleMapParser::parseRequiresDecl() { consumeToken(); // Add this feature. - ActiveModule->addRequirement(Feature, Map.LangOpts); + ActiveModule->addRequirement(Feature, Map.LangOpts, *Map.Target); if (!Tok.is(MMToken::Comma)) break; @@ -1360,6 +1366,7 @@ bool ModuleMapParser::parseModuleMapFile() { } bool ModuleMap::parseModuleMapFile(const FileEntry *File) { + assert(Target != 0 && "Missing target information"); FileID ID = SourceMgr->createFileID(File, SourceLocation(), SrcMgr::C_User); const llvm::MemoryBuffer *Buffer = SourceMgr->getBuffer(ID); if (!Buffer) diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 05cbffdfd1..fc6efb6068 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -167,7 +167,9 @@ void Preprocessor::Initialize(const TargetInfo &Target) { Ident__exception_info = Ident__exception_code = Ident__abnormal_termination = 0; Ident___exception_info = Ident___exception_code = Ident___abnormal_termination = 0; Ident_GetExceptionInfo = Ident_GetExceptionCode = Ident_AbnormalTermination = 0; - } + } + + HeaderInfo.setTarget(Target); } void Preprocessor::setPTHManager(PTHManager* pm) { diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 71734027bf..0bf1da75be 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -3307,7 +3307,8 @@ ASTReader::ASTReadResult ASTReader::ReadSubmoduleBlock(ModuleFile &F) { break; CurrentModule->addRequirement(StringRef(BlobStart, BlobLen), - Context.getLangOptions()); + Context.getLangOptions(), + Context.getTargetInfo()); break; } } |