aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2012-12-24 18:15:21 +0000
committerBob Wilson <bob.wilson@apple.com>2012-12-24 18:15:21 +0000
commita0be09f511c68a88ee95b73c8f0ebd78156a559e (patch)
tree678964cde398eea6351973aba975ccec327aad3b /lib/Transforms
parentfa45cdf646572cf11b03cfdaa63f75fd74fc7d34 (diff)
Add LLVMContext::emitWarning methods and use them. <rdar://problem/12867368>
When the backend is used from clang, it should produce proper diagnostics instead of just printing messages to errs(). Other clients may also want to register their own error handlers with the LLVMContext, and the same handler should work for warnings in the same way as the existing emitError methods. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171041 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/InstCombine/InstCombineCalls.cpp5
-rw-r--r--lib/Transforms/Instrumentation/EdgeProfiling.cpp5
-rw-r--r--lib/Transforms/Instrumentation/OptimalEdgeProfiling.cpp5
-rw-r--r--lib/Transforms/Instrumentation/PathProfiling.cpp4
4 files changed, 11 insertions, 8 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 7babf32159..4849463b5a 100644
--- a/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1154,8 +1154,9 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
// If we are removing arguments to the function, emit an obnoxious warning.
if (FT->getNumParams() < NumActualArgs) {
if (!FT->isVarArg()) {
- errs() << "WARNING: While resolving call to function '"
- << Callee->getName() << "' arguments were dropped!\n";
+ FT->getContext().emitWarning("while resolving call to function '" +
+ Callee->getName() +
+ "' arguments were dropped");
} else {
// Add all of the arguments in their promoted form to the arg list.
for (unsigned i = FT->getNumParams(); i != NumActualArgs; ++i, ++AI) {
diff --git a/lib/Transforms/Instrumentation/EdgeProfiling.cpp b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
index 41e42aff49..cf12b1f758 100644
--- a/lib/Transforms/Instrumentation/EdgeProfiling.cpp
+++ b/lib/Transforms/Instrumentation/EdgeProfiling.cpp
@@ -21,6 +21,7 @@
#include "llvm/Transforms/Instrumentation.h"
#include "ProfilingUtils.h"
#include "llvm/ADT/Statistic.h"
+#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Pass.h"
#include "llvm/Support/raw_ostream.h"
@@ -54,8 +55,8 @@ ModulePass *llvm::createEdgeProfilerPass() { return new EdgeProfiler(); }
bool EdgeProfiler::runOnModule(Module &M) {
Function *Main = M.getFunction("main");
if (Main == 0) {
- errs() << "WARNING: cannot insert edge profiling into a module"
- << " with no main function!\n";
+ M.getContext().emitWarning("cannot insert edge profiling into a module"
+ " with no main function");
return false; // No main, no instrumentation!
}
diff --git a/lib/Transforms/Instrumentation/OptimalEdgeProfiling.cpp b/lib/Transforms/Instrumentation/OptimalEdgeProfiling.cpp
index 8f8d027dca..3c851681b9 100644
--- a/lib/Transforms/Instrumentation/OptimalEdgeProfiling.cpp
+++ b/lib/Transforms/Instrumentation/OptimalEdgeProfiling.cpp
@@ -22,6 +22,7 @@
#include "llvm/Analysis/ProfileInfo.h"
#include "llvm/Analysis/ProfileInfoLoader.h"
#include "llvm/Constants.h"
+#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
@@ -75,8 +76,8 @@ inline static void printEdgeCounter(ProfileInfo::Edge e,
bool OptimalEdgeProfiler::runOnModule(Module &M) {
Function *Main = M.getFunction("main");
if (Main == 0) {
- errs() << "WARNING: cannot insert edge profiling into a module"
- << " with no main function!\n";
+ M.getContext().emitWarning("cannot insert edge profiling into a module"
+ " with no main function");
return false; // No main, no instrumentation!
}
diff --git a/lib/Transforms/Instrumentation/PathProfiling.cpp b/lib/Transforms/Instrumentation/PathProfiling.cpp
index 2a0e89ce6a..2d324b89b1 100644
--- a/lib/Transforms/Instrumentation/PathProfiling.cpp
+++ b/lib/Transforms/Instrumentation/PathProfiling.cpp
@@ -1345,8 +1345,8 @@ bool PathProfiler::runOnModule(Module &M) {
Main = M.getFunction("MAIN__");
if (!Main) {
- errs() << "WARNING: cannot insert path profiling into a module"
- << " with no main function!\n";
+ Context->emitWarning("cannot insert edge profiling into a module"
+ " with no main function");
return false;
}