r203006 - When building a module from the command line via -emit-module, add an entry to
Richard Smith
richard-llvm at metafoo.co.uk
Wed Mar 5 12:55:36 PST 2014
Author: rsmith
Date: Wed Mar 5 14:55:36 2014
New Revision: 203006
URL: http://llvm.org/viewvc/llvm-project?rev=203006&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/test/Modules/recursive.c
Modified: cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp?rev=203006&r1=203005&r2=203006&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp (original)
+++ cfe/trunk/lib/Frontend/DiagnosticRenderer.cpp Wed Mar 5 14:55:36 2014
@@ -499,8 +499,11 @@ DiagnosticNoteRenderer::emitBuildingModu
// Generate a note indicating the include location.
SmallString<200> MessageStorage;
llvm::raw_svector_ostream Message(MessageStorage);
- Message << "while building module '" << ModuleName << "' imported from "
- << PLoc.getFilename() << ':' << PLoc.getLine() << ":";
+ if (PLoc.getFilename())
+ Message << "while building module '" << ModuleName << "' imported from "
+ << PLoc.getFilename() << ':' << PLoc.getLine() << ":";
+ else
+ Message << "while building module '" << ModuleName << ":";
emitNote(Loc, Message.str(), &SM);
}
Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=203006&r1=203005&r2=203006&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Wed Mar 5 14:55:36 2014
@@ -240,7 +240,15 @@ bool GenerateModuleAction::BeginSourceFi
// 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);
Modified: cfe/trunk/test/Modules/recursive.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/recursive.c?rev=203006&r1=203005&r2=203006&view=diff
==============================================================================
--- cfe/trunk/test/Modules/recursive.c (original)
+++ cfe/trunk/test/Modules/recursive.c Wed Mar 5 14:55:36 2014
@@ -2,8 +2,8 @@
// RUN: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -I %S/Inputs %s 2>&1 | FileCheck %s
#include "recursive1.h"
-// FIXME: rm -rf %t
-// FIXME: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=recursive1 %S/Inputs/module.map 2>&1 | FileCheck %s
+// RUN: rm -rf %t
+// RUN: not %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -emit-module -fmodule-name=recursive1 %S/Inputs/module.map 2>&1 | FileCheck %s
// CHECK: While building module 'recursive1'{{( imported from .*/recursive.c:3)?}}:
// CHECK-NEXT: While building module 'recursive2' imported from {{.*}}Inputs/recursive1.h:1:
More information about the cfe-commits
mailing list