diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-05 20:55:36 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-03-05 20:55:36 +0000 |
commit | 7bea1d42d8cd8c90496b1a3306fc56814cebbde7 (patch) | |
tree | 2807499439264556600b66dac094f257f9bc8635 /clang/lib/Frontend/FrontendActions.cpp | |
parent | 8c71eba19f267c5ea6561d9d92fbc963cfc88a9c (diff) | |
download | bcm5719-llvm-7bea1d42d8cd8c90496b1a3306fc56814cebbde7.tar.gz bcm5719-llvm-7bea1d42d8cd8c90496b1a3306fc56814cebbde7.zip |
When building a module from the command line via -emit-module, add an entry to
the module build stack for the module being built, so we can correctly detect
recursive module builds.
llvm-svn: 203006
Diffstat (limited to 'clang/lib/Frontend/FrontendActions.cpp')
-rw-r--r-- | clang/lib/Frontend/FrontendActions.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index f587d829b39..4ed2df3a25c 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -240,7 +240,15 @@ bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI, // map with a single module (the common case). return false; } - + + // If we're being run from the command-line, the module build stack will not + // have been filled in yet, so complete it now in order to allow us to detect + // module cycles. + SourceManager &SourceMgr = CI.getSourceManager(); + if (SourceMgr.getModuleBuildStack().empty()) + SourceMgr.pushModuleBuildStack(CI.getLangOpts().CurrentModule, + FullSourceLoc(SourceLocation(), SourceMgr)); + // Dig out the module definition. Module = HS.lookupModule(CI.getLangOpts().CurrentModule, /*AllowSearch=*/false); |