~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/Analysis/DbgInfoPrinter.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//===- DbgInfoPrinter.cpp - Print debug info in a human readable form ------==//
 
2
//
 
3
//                     The LLVM Compiler Infrastructure
 
4
//
 
5
// This file is distributed under the University of Illinois Open Source
 
6
// License. See LICENSE.TXT for details.
 
7
//
 
8
//===----------------------------------------------------------------------===//
 
9
//
 
10
// This file implements a pass that prints instructions, and associated debug
 
11
// info:
 
12
// 
 
13
//   - source/line/col information
 
14
//   - original variable name
 
15
//   - original type name
 
16
//
 
17
//===----------------------------------------------------------------------===//
 
18
 
 
19
#include "llvm/Pass.h"
 
20
#include "llvm/Function.h"
 
21
#include "llvm/IntrinsicInst.h"
 
22
#include "llvm/Metadata.h"
 
23
#include "llvm/Assembly/Writer.h"
 
24
#include "llvm/Analysis/DebugInfo.h"
 
25
#include "llvm/Analysis/Passes.h"
 
26
#include "llvm/Support/CFG.h"
 
27
#include "llvm/Support/CommandLine.h"
 
28
#include "llvm/Support/raw_ostream.h"
 
29
 
 
30
using namespace llvm;
 
31
 
 
32
static cl::opt<bool>
 
33
PrintDirectory("print-fullpath",
 
34
               cl::desc("Print fullpath when printing debug info"),
 
35
               cl::Hidden);
 
36
 
 
37
namespace {
 
38
  class PrintDbgInfo : public FunctionPass {
 
39
    raw_ostream &Out;
 
40
    void printVariableDeclaration(const Value *V);
 
41
  public:
 
42
    static char ID; // Pass identification
 
43
    PrintDbgInfo() : FunctionPass(&ID), Out(outs()) {}
 
44
 
 
45
    virtual bool runOnFunction(Function &F);
 
46
    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
 
47
      AU.setPreservesAll();
 
48
    }
 
49
  };
 
50
  char PrintDbgInfo::ID = 0;
 
51
  static RegisterPass<PrintDbgInfo> X("print-dbginfo",
 
52
                                     "Print debug info in human readable form");
 
53
}
 
54
 
 
55
FunctionPass *llvm::createDbgInfoPrinterPass() { return new PrintDbgInfo(); }
 
56
 
 
57
void PrintDbgInfo::printVariableDeclaration(const Value *V) {
 
58
  std::string DisplayName, File, Directory, Type;
 
59
  unsigned LineNo;
 
60
 
 
61
  if (!getLocationInfo(V, DisplayName, Type, LineNo, File, Directory))
 
62
    return;
 
63
 
 
64
  Out << "; ";
 
65
  WriteAsOperand(Out, V, false, 0);
 
66
  Out << " is variable " << DisplayName
 
67
      << " of type " << Type << " declared at ";
 
68
 
 
69
  if (PrintDirectory)
 
70
    Out << Directory << "/";
 
71
 
 
72
  Out << File << ":" << LineNo << "\n";
 
73
}
 
74
 
 
75
bool PrintDbgInfo::runOnFunction(Function &F) {
 
76
  if (F.isDeclaration())
 
77
    return false;
 
78
 
 
79
  Out << "function " << F.getName() << "\n\n";
 
80
 
 
81
  for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) {
 
82
    BasicBlock *BB = I;
 
83
 
 
84
    if (I != F.begin() && (pred_begin(BB) == pred_end(BB)))
 
85
      // Skip dead blocks.
 
86
      continue;
 
87
 
 
88
    Out << BB->getName();
 
89
    Out << ":";
 
90
 
 
91
    Out << "\n";
 
92
 
 
93
    for (BasicBlock::const_iterator i = BB->begin(), e = BB->end();
 
94
         i != e; ++i) {
 
95
 
 
96
        printVariableDeclaration(i);
 
97
 
 
98
        if (const User *U = dyn_cast<User>(i)) {
 
99
          for(unsigned i=0;i<U->getNumOperands();i++)
 
100
            printVariableDeclaration(U->getOperand(i));
 
101
        }
 
102
    }
 
103
  }
 
104
  return false;
 
105
}