diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-11-29 23:55:25 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-11-29 23:55:25 +0000 |
commit | 463d90986ec54c62bf8fe31193ef5db701db48a5 (patch) | |
tree | 70dae4bd00311bdd08f2e1f4007c7042375dea12 /include/clang/Lex/ModuleLoader.h | |
parent | db748a380ab89b1c0b6e751e55291f57605cccce (diff) |
Keep track of modules that have failed to build. If we encounter an
import of that module elsewhere, don't try to build the module again:
it won't work, and the experience is quite dreadful. We track this
information somewhat globally, shared among all of the related
CompilerInvocations used to build modules on-the-fly, so that a
particular Clang instance will only try to build a given module once.
Fixes <rdar://problem/12552849>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168961 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Lex/ModuleLoader.h')
-rw-r--r-- | include/clang/Lex/ModuleLoader.h | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/include/clang/Lex/ModuleLoader.h b/include/clang/Lex/ModuleLoader.h index 36d03c0aa2..3a5f41d510 100644 --- a/include/clang/Lex/ModuleLoader.h +++ b/include/clang/Lex/ModuleLoader.h @@ -17,16 +17,37 @@ #include "clang/Basic/Module.h" #include "clang/Basic/SourceLocation.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/PointerIntPair.h" namespace clang { class IdentifierInfo; - +class Module; + /// \brief A sequence of identifier/location pairs used to describe a particular /// module or submodule, e.g., std.vector. typedef llvm::ArrayRef<std::pair<IdentifierInfo*, SourceLocation> > ModuleIdPath; - + +/// \brief Describes the result of attempting to load a module. +class ModuleLoadResult { + llvm::PointerIntPair<Module *, 1, bool> Storage; + +public: + ModuleLoadResult() : Storage() { } + + ModuleLoadResult(Module *module, bool missingExpected) + : Storage(module, missingExpected) { } + + operator Module *() const { return Storage.getPointer(); } + + /// \brief Determines whether the module, which failed to load, was + /// actually a submodule that we expected to see (based on implying the + /// submodule from header structure), but didn't materialize in the actual + /// module. + bool isMissingExpected() const { return Storage.getInt(); } +}; + /// \brief Abstract interface for a module loader. /// /// This abstract interface describes a module loader, which is responsible @@ -55,9 +76,10 @@ public: /// /// \returns If successful, returns the loaded module. Otherwise, returns /// NULL to indicate that the module could not be loaded. - virtual Module *loadModule(SourceLocation ImportLoc, ModuleIdPath Path, - Module::NameVisibilityKind Visibility, - bool IsInclusionDirective) = 0; + virtual ModuleLoadResult loadModule(SourceLocation ImportLoc, + ModuleIdPath Path, + Module::NameVisibilityKind Visibility, + bool IsInclusionDirective) = 0; }; } |