};
-/// \brief The path used when building modules on demand, which is used
+/// \brief The stack 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;
+typedef llvm::ArrayRef<std::pair<std::string, FullSourceLoc> > ModuleBuildStack;
/// \brief This class handles loading and caching of source files into memory.
///
mutable llvm::DenseMap<FileID, MacroArgsMap *> MacroArgsCacheMap;
- /// \brief The path of modules being built, which is used to detect
+ /// \brief The stack 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
+ /// well as to describe why we're rebuilding a particular module.
///
/// 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;
+ SmallVector<std::pair<std::string, FullSourceLoc>, 2> StoredModuleBuildStack;
// SourceManager doesn't support copy construction.
explicit SourceManager(const SourceManager&) LLVM_DELETED_FUNCTION;
/// (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 Retrieve the module build stack.
+ ModuleBuildStack getModuleBuildStack() const {
+ return StoredModuleBuildStack;
}
- /// \brief Set the module build path.
- void setModuleBuildPath(ModuleBuildPath path) {
- StoredModuleBuildPath.clear();
- StoredModuleBuildPath.append(path.begin(), path.end());
+ /// \brief Set the module build stack.
+ void setModuleBuildStack(ModuleBuildStack stack) {
+ StoredModuleBuildStack.clear();
+ StoredModuleBuildStack.append(stack.begin(), stack.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 Push an entry to the module build stack.
+ void pushModuleBuildStack(StringRef moduleName, FullSourceLoc importLoc) {
+ StoredModuleBuildStack.push_back(std::make_pair(moduleName.str(),importLoc));
}
/// \brief Create the FileID for a memory buffer that will represent the
void emitImportStack(SourceLocation Loc, const SourceManager &SM);
void emitImportStackRecursively(SourceLocation Loc, StringRef ModuleName,
const SourceManager &SM);
- void emitModuleBuildPath(const SourceManager &SM);
+ void emitModuleBuildStack(const SourceManager &SM);
void emitMacroExpansionsAndCarets(SourceLocation Loc,
DiagnosticsEngine::Level Level,
SmallVectorImpl<CharSourceRange>& Ranges,
/*ShouldOwnClient=*/true,
/*ShouldCloneClient=*/true);
- // Note that this module is part of the module build path, so that we
+ // Note that this module is part of the module build stack, so that we
// can detect cycles in the module graph.
Instance.createFileManager(); // FIXME: Adopt file manager from importer?
Instance.createSourceManager(Instance.getFileManager());
SourceManager &SourceMgr = Instance.getSourceManager();
- SourceMgr.setModuleBuildPath(
- ImportingInstance.getSourceManager().getModuleBuildPath());
- SourceMgr.appendModuleBuildPath(Module->getTopLevelModuleName(),
+ SourceMgr.setModuleBuildStack(
+ ImportingInstance.getSourceManager().getModuleBuildStack());
+ SourceMgr.pushModuleBuildStack(Module->getTopLevelModuleName(),
FullSourceLoc(ImportLoc, ImportingInstance.getSourceManager()));
// build the module.
// Check whether there is a cycle in the module graph.
- ModuleBuildPath Path = getSourceManager().getModuleBuildPath();
- ModuleBuildPath::iterator Pos = Path.begin(), PosEnd = Path.end();
+ ModuleBuildStack Path = getSourceManager().getModuleBuildStack();
+ ModuleBuildStack::iterator Pos = Path.begin(), PosEnd = Path.end();
for (; Pos != PosEnd; ++Pos) {
if (Pos->first == ModuleName)
break;
if (IncludeLoc.isValid())
emitIncludeStackRecursively(IncludeLoc, SM);
else {
- emitModuleBuildPath(SM);
+ emitModuleBuildStack(SM);
emitImportStack(Loc, SM);
}
}
void DiagnosticRenderer::emitIncludeStackRecursively(SourceLocation Loc,
const SourceManager &SM) {
if (Loc.isInvalid()) {
- emitModuleBuildPath(SM);
+ emitModuleBuildStack(SM);
return;
}
void DiagnosticRenderer::emitImportStack(SourceLocation Loc,
const SourceManager &SM) {
if (Loc.isInvalid()) {
- emitModuleBuildPath(SM);
+ emitModuleBuildStack(SM);
return;
}
emitImportLocation(Loc, PLoc, ModuleName, SM);
}
-/// \brief Emit the module build path, for cases where a module is (re-)built
+/// \brief Emit the module build stack, for cases where a module is (re-)built
/// on demand.
-void DiagnosticRenderer::emitModuleBuildPath(const SourceManager &SM) {
- ModuleBuildPath Path = SM.getModuleBuildPath();
- for (unsigned I = 0, N = Path.size(); I != N; ++I) {
- const SourceManager &CurSM = Path[I].second.getManager();
- SourceLocation CurLoc = Path[I].second;
+void DiagnosticRenderer::emitModuleBuildStack(const SourceManager &SM) {
+ ModuleBuildStack Stack = SM.getModuleBuildStack();
+ for (unsigned I = 0, N = Stack.size(); I != N; ++I) {
+ const SourceManager &CurSM = Stack[I].second.getManager();
+ SourceLocation CurLoc = Stack[I].second;
emitBuildingModuleLocation(CurLoc,
CurSM.getPresumedLoc(CurLoc,
DiagOpts->ShowPresumedLoc),
- Path[I].first,
+ Stack[I].first,
CurSM);
}
}