aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2009-05-14 18:16:46 +0000
committerBill Wendling <isanbard@gmail.com>2009-05-14 18:16:46 +0000
commite66b2912405d91dbc4d3e7f7b5e955c87d597406 (patch)
tree9876f8f471c463d6543aaf6e99c55eeb94f39670 /lib
parent4bb3374b6d11a8a4ec1b174f0404bd6cbd2d00b9 (diff)
downloadexternal_llvm-e66b2912405d91dbc4d3e7f7b5e955c87d597406.zip
external_llvm-e66b2912405d91dbc4d3e7f7b5e955c87d597406.tar.gz
external_llvm-e66b2912405d91dbc4d3e7f7b5e955c87d597406.tar.bz2
Clean up this file fixing 80-column violations, bad formatting, etc. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71781 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/DbgInfoPrinter.cpp129
1 files changed, 69 insertions, 60 deletions
diff --git a/lib/Analysis/DbgInfoPrinter.cpp b/lib/Analysis/DbgInfoPrinter.cpp
index e43bc81..d80d581 100644
--- a/lib/Analysis/DbgInfoPrinter.cpp
+++ b/lib/Analysis/DbgInfoPrinter.cpp
@@ -1,4 +1,4 @@
-//===- DbgInfoPrinter.cpp - Print debug info in a human readable form -----==//
+//===- DbgInfoPrinter.cpp - Print debug info in a human readable form ------==//
//
// The LLVM Compiler Infrastructure
//
@@ -9,150 +9,159 @@
//
// This file implements a pass that prints instructions, and associated debug
// info:
+//
// - source/line/col information
// - original variable name
// - original type name
//
//===----------------------------------------------------------------------===//
+
#include "llvm/Pass.h"
#include "llvm/Function.h"
-#include "llvm/Module.h"
-#include "llvm/Value.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/Analysis/DebugInfo.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Support/CFG.h"
-#include "llvm/Support/Compiler.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"
+
using namespace llvm;
static cl::opt<bool>
-PrintDirectory("print-fullpath", cl::desc("Print fullpath when printing debug info"), cl::Hidden);
+PrintDirectory("print-fullpath",
+ cl::desc("Print fullpath when printing debug info"),
+ cl::Hidden);
namespace {
- struct VISIBILITY_HIDDEN PrintDbgInfo : public FunctionPass {
- private:
- raw_ostream &Out;
- void printStopPoint(const DbgStopPointInst *DSI);
- void printFuncStart(const DbgFuncStartInst *FS);
- void printVariableDeclaration(const Value *V);
- public:
- static char ID; // Pass identification
- PrintDbgInfo() : FunctionPass(&ID), Out(outs()) {}
-
- virtual bool runOnFunction(Function &F);
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesAll();
- }
-
- };
- char PrintDbgInfo::ID = 0;
- static RegisterPass<PrintDbgInfo> X("print-dbginfo",
- "Print debug info in human readable form");
+ class VISIBILITY_HIDDEN PrintDbgInfo : public FunctionPass {
+ raw_ostream &Out;
+ void printStopPoint(const DbgStopPointInst *DSI);
+ void printFuncStart(const DbgFuncStartInst *FS);
+ void printVariableDeclaration(const Value *V);
+ public:
+ static char ID; // Pass identification
+ PrintDbgInfo() : FunctionPass(&ID), Out(outs()) {}
+
+ virtual bool runOnFunction(Function &F);
+ virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.setPreservesAll();
+ }
+ };
+ char PrintDbgInfo::ID = 0;
+ static RegisterPass<PrintDbgInfo> X("print-dbginfo",
+ "Print debug info in human readable form");
}
FunctionPass *llvm::createDbgInfoPrinterPass() { return new PrintDbgInfo(); }
-void PrintDbgInfo::printVariableDeclaration(const Value *V)
-{
+void PrintDbgInfo::printVariableDeclaration(const Value *V) {
std::string DisplayName, File, Directory, Type;
unsigned LineNo;
- if (getLocationInfo(V, DisplayName, Type, LineNo, File, Directory)) {
- Out << "; ";
- WriteAsOperand(Out, V, false, 0);
- Out << " is variable " << DisplayName
+
+ if (!getLocationInfo(V, DisplayName, Type, LineNo, File, Directory))
+ return;
+
+ Out << "; ";
+ WriteAsOperand(Out, V, false, 0);
+ Out << " is variable " << DisplayName
<< " of type " << Type << " declared at ";
- if (PrintDirectory) {
- Out << Directory << "/";
- }
- Out << File << ":" << LineNo << "\n";
- }
+
+ if (PrintDirectory)
+ Out << Directory << "/";
+
+ Out << File << ":" << LineNo << "\n";
}
-void PrintDbgInfo::printStopPoint(const DbgStopPointInst *DSI)
-{
+void PrintDbgInfo::printStopPoint(const DbgStopPointInst *DSI) {
if (PrintDirectory) {
std::string dir;
- GetConstantStringInfo(DSI->getDirectory(), dir);
+ GetConstantStringInfo(DSI->getDirectory(), dir);
Out << dir << "/";
}
+
std::string file;
GetConstantStringInfo(DSI->getFileName(), file);
Out << file << ":" << DSI->getLine();
- if (unsigned Col = DSI->getColumn()) {
+
+ if (unsigned Col = DSI->getColumn())
Out << ":" << Col;
- }
}
-void PrintDbgInfo::printFuncStart(const DbgFuncStartInst *FS)
-{
+void PrintDbgInfo::printFuncStart(const DbgFuncStartInst *FS) {
DISubprogram Subprogram(cast<GlobalVariable>(FS->getSubprogram()));
std::string Res1, Res2;
- Out << ";fully qualified function name: " << Subprogram.getDisplayName(Res1)
- << " return type: " << Subprogram.getType().getName(Res2)
- << " at line " << Subprogram.getLineNumber()
- << "\n\n";
+ Out << "; fully qualified function name: " << Subprogram.getDisplayName(Res1)
+ << " return type: " << Subprogram.getType().getName(Res2)
+ << " at line " << Subprogram.getLineNumber()
+ << "\n\n";
}
-bool PrintDbgInfo::runOnFunction(Function &F)
-{
+bool PrintDbgInfo::runOnFunction(Function &F) {
if (F.isDeclaration())
return false;
+
Out << "function " << F.getName() << "\n\n";
+
for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) {
BasicBlock *BB = I;
+
if (I != F.begin() && (pred_begin(BB) == pred_end(BB)))
// Skip dead blocks.
continue;
+
const DbgStopPointInst *DSI = findBBStopPoint(BB);
Out << BB->getName();
Out << ":";
+
if (DSI) {
Out << "; (";
printStopPoint(DSI);
Out << ")";
}
+
Out << "\n";
+
// A dbgstoppoint's information is valid until we encounter a new one.
const DbgStopPointInst *LastDSP = DSI;
- bool printed = DSI != 0;
- for (BasicBlock::const_iterator i = BB->begin(), e = BB->end(); i != e; ++i) {
+ bool Printed = DSI != 0;
+ for (BasicBlock::const_iterator i = BB->begin(), e = BB->end();
+ i != e; ++i) {
if (isa<DbgInfoIntrinsic>(i)) {
if ((DSI = dyn_cast<DbgStopPointInst>(i))) {
-
if (DSI->getContext() == LastDSP->getContext() &&
DSI->getLineValue() == LastDSP->getLineValue() &&
- DSI->getColumnValue() == LastDSP->getColumnValue()) {
+ DSI->getColumnValue() == LastDSP->getColumnValue())
// Don't print same location twice.
continue;
- }
+
LastDSP = cast<DbgStopPointInst>(i);
- // Don't print consecutive stoppoints, use a flag
- // to know which one we printed.
- printed = false;
+ // Don't print consecutive stoppoints, use a flag to know which one we
+ // printed.
+ Printed = false;
} else if (const DbgFuncStartInst *FS = dyn_cast<DbgFuncStartInst>(i)) {
printFuncStart(FS);
}
} else {
- if (!printed && LastDSP) {
+ if (!Printed && LastDSP) {
Out << "; ";
printStopPoint(LastDSP);
Out << "\n";
- printed = true;
+ Printed = true;
}
+
Out << *i;
printVariableDeclaration(i);
+
if (const User *U = dyn_cast<User>(i)) {
- for(unsigned i=0;i<U->getNumOperands();i++) {
+ for(unsigned i=0;i<U->getNumOperands();i++)
printVariableDeclaration(U->getOperand(i));
- }
}
}
}
}
+
return false;
}