aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Basic/SourceManager.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-11-30 18:38:50 +0000
committerDouglas Gregor <dgregor@apple.com>2012-11-30 18:38:50 +0000
commit830ea5b7c75413526c19531f0180fa6e45b98919 (patch)
treefbc998f5090d858324e3c4d014248eccf2f87863 /include/clang/Basic/SourceManager.h
parent7f2d4804510799a1a19d72b2b089e48370ab8686 (diff)
When an error occurs while building a module on demand, provide "While
building module 'Foo' imported from..." notes (the same we we provide "In file included from..." notes) in the diagnostic, so that we know how this module got included in the first place. This is part of <rdar://problem/12696425>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169021 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/SourceManager.h')
-rw-r--r--include/clang/Basic/SourceManager.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index 5717816ff9..bd31c79ba2 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -40,6 +40,7 @@
#include "clang/Basic/SourceLocation.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/DataTypes.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
@@ -508,6 +509,11 @@ public:
};
+/// \brief The path used when building modules on demand, which is used
+/// to provide a link between the source managers of the different compiler
+/// instances.
+typedef llvm::ArrayRef<std::pair<std::string, FullSourceLoc> > ModuleBuildPath;
+
/// \brief This class handles loading and caching of source files into memory.
///
/// This object owns the MemoryBuffer objects for all of the loaded
@@ -645,6 +651,15 @@ class SourceManager : public RefCountedBase<SourceManager> {
mutable llvm::DenseMap<FileID, MacroArgsMap *> MacroArgsCacheMap;
+ /// \brief The path of modules being built, which is used to detect
+ /// cycles in the module dependency graph as modules are being built, as
+ /// well as to describe
+ ///
+ /// There is no way to set this value from the command line. If we ever need
+ /// to do so (e.g., if on-demand module construction moves out-of-process),
+ /// we can add a cc1-level option to do so.
+ SmallVector<std::pair<std::string, FullSourceLoc>, 2> StoredModuleBuildPath;
+
// SourceManager doesn't support copy construction.
explicit SourceManager(const SourceManager&) LLVM_DELETED_FUNCTION;
void operator=(const SourceManager&) LLVM_DELETED_FUNCTION;
@@ -669,6 +684,22 @@ public:
/// (likely to change while trying to use them).
bool userFilesAreVolatile() const { return UserFilesAreVolatile; }
+ /// \brief Retrieve the module build path.
+ ModuleBuildPath getModuleBuildPath() const {
+ return StoredModuleBuildPath;
+ }
+
+ /// \brief Set the module build path.
+ void setModuleBuildPath(ModuleBuildPath path) {
+ StoredModuleBuildPath.clear();
+ StoredModuleBuildPath.append(path.begin(), path.end());
+ }
+
+ /// \brief Append an entry to the module build path.
+ void appendModuleBuildPath(StringRef moduleName, FullSourceLoc importLoc) {
+ StoredModuleBuildPath.push_back(std::make_pair(moduleName.str(),importLoc));
+ }
+
/// \brief Create the FileID for a memory buffer that will represent the
/// FileID for the main source.
///