diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2014-11-24 18:11:16 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2014-11-24 18:11:16 +0000 | 
| commit | 59d1ed5b206db2a86b3b5bb851f393c43b568ce2 (patch) | |
| tree | d4426858455f04d0d8c25a2f9eb9ea5582ffe1b6 /contrib/llvm/tools/clang/lib/Basic/Module.cpp | |
| parent | 91bc56ed825ba56b3cc264aa5c95ab84f86832ab (diff) | |
| parent | 9f4dbff6669c8037f3b036bcf580d14f1a4f12a5 (diff) | |
Notes
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Basic/Module.cpp')
| -rw-r--r-- | contrib/llvm/tools/clang/lib/Basic/Module.cpp | 41 | 
1 files changed, 27 insertions, 14 deletions
| diff --git a/contrib/llvm/tools/clang/lib/Basic/Module.cpp b/contrib/llvm/tools/clang/lib/Basic/Module.cpp index d08cef1a1563..f689c733d9c0 100644 --- a/contrib/llvm/tools/clang/lib/Basic/Module.cpp +++ b/contrib/llvm/tools/clang/lib/Basic/Module.cpp @@ -24,20 +24,23 @@  using namespace clang; -Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,  -               bool IsFramework, bool IsExplicit) -  : Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent), -    Umbrella(), ASTFile(0), IsAvailable(true), IsFromModuleFile(false), -    IsFramework(IsFramework), IsExplicit(IsExplicit), IsSystem(false), -    InferSubmodules(false), InferExplicitSubmodules(false),  -    InferExportWildcard(false), ConfigMacrosExhaustive(false), -    NameVisibility(Hidden) -{  +Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent, +               const FileEntry *File, bool IsFramework, bool IsExplicit) +    : Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent), ModuleMap(File), +      Umbrella(), ASTFile(nullptr), IsMissingRequirement(false), +      IsAvailable(true), IsFromModuleFile(false), IsFramework(IsFramework), +      IsExplicit(IsExplicit), IsSystem(false), IsExternC(false), +      IsInferred(false), InferSubmodules(false), InferExplicitSubmodules(false), +      InferExportWildcard(false), ConfigMacrosExhaustive(false), +      NameVisibility(Hidden) {    if (Parent) {      if (!Parent->isAvailable())        IsAvailable = false;      if (Parent->IsSystem)        IsSystem = true; +    if (Parent->IsExternC) +      IsExternC = true; +    IsMissingRequirement = Parent->IsMissingRequirement;      Parent->SubModuleIndex[Name] = Parent->SubModules.size();      Parent->SubModules.push_back(this); @@ -69,11 +72,15 @@ static bool hasFeature(StringRef Feature, const LangOptions &LangOpts,  bool  Module::isAvailable(const LangOptions &LangOpts, const TargetInfo &Target, -                    Requirement &Req) const { +                    Requirement &Req, HeaderDirective &MissingHeader) const {    if (IsAvailable)      return true;    for (const Module *Current = this; Current; Current = Current->Parent) { +    if (!Current->MissingHeaders.empty()) { +      MissingHeader = Current->MissingHeaders.front(); +      return false; +    }      for (unsigned I = 0, N = Current->Requirements.size(); I != N; ++I) {        if (hasFeature(Current->Requirements[I].first, LangOpts, Target) !=                Current->Requirements[I].second) { @@ -86,7 +93,7 @@ Module::isAvailable(const LangOptions &LangOpts, const TargetInfo &Target,    llvm_unreachable("could not find a reason why module is unavailable");  } -bool Module::isSubModuleOf(Module *Other) const { +bool Module::isSubModuleOf(const Module *Other) const {    const Module *This = this;    do {      if (This == Other) @@ -155,6 +162,10 @@ void Module::addRequirement(StringRef Feature, bool RequiredState,    if (hasFeature(Feature, LangOpts, Target) == RequiredState)      return; +  markUnavailable(/*MissingRequirement*/true); +} + +void Module::markUnavailable(bool MissingRequirement) {    if (!IsAvailable)      return; @@ -168,6 +179,7 @@ void Module::addRequirement(StringRef Feature, bool RequiredState,        continue;      Current->IsAvailable = false; +    Current->IsMissingRequirement |= MissingRequirement;      for (submodule_iterator Sub = Current->submodule_begin(),                           SubEnd = Current->submodule_end();           Sub != SubEnd; ++Sub) { @@ -180,8 +192,8 @@ void Module::addRequirement(StringRef Feature, bool RequiredState,  Module *Module::findSubmodule(StringRef Name) const {    llvm::StringMap<unsigned>::const_iterator Pos = SubModuleIndex.find(Name);    if (Pos == SubModuleIndex.end()) -    return 0; -   +    return nullptr; +    return SubModules[Pos->getValue()];  } @@ -349,7 +361,8 @@ void Module::print(raw_ostream &OS, unsigned Indent) const {    for (submodule_const_iterator MI = submodule_begin(), MIEnd = submodule_end();         MI != MIEnd; ++MI) -    (*MI)->print(OS, Indent + 2); +    if (!(*MI)->IsInferred) +      (*MI)->print(OS, Indent + 2);    for (unsigned I = 0, N = Exports.size(); I != N; ++I) {      OS.indent(Indent + 2); | 
