~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/lib/ExecutionEngine/Interpreter/Interpreter.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
//===- Interpreter.cpp - Top-Level LLVM Interpreter Implementation --------===//
 
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 the top-level functionality for the LLVM interpreter.
 
11
// This interpreter is designed to be a very simple, portable, inefficient
 
12
// interpreter.
 
13
//
 
14
//===----------------------------------------------------------------------===//
 
15
 
 
16
#include "Interpreter.h"
 
17
#include "llvm/CodeGen/IntrinsicLowering.h"
 
18
#include "llvm/DerivedTypes.h"
 
19
#include "llvm/Module.h"
 
20
#include <cstring>
 
21
using namespace llvm;
 
22
 
 
23
namespace {
 
24
 
 
25
static struct RegisterInterp {
 
26
  RegisterInterp() { Interpreter::Register(); }
 
27
} InterpRegistrator;
 
28
 
 
29
}
 
30
 
 
31
extern "C" void LLVMLinkInInterpreter() { }
 
32
 
 
33
/// create - Create a new interpreter object.  This can never fail.
 
34
///
 
35
ExecutionEngine *Interpreter::create(Module *M, std::string* ErrStr) {
 
36
  // Tell this Module to materialize everything and release the GVMaterializer.
 
37
  if (M->MaterializeAllPermanently(ErrStr))
 
38
    // We got an error, just return 0
 
39
    return 0;
 
40
 
 
41
  return new Interpreter(M);
 
42
}
 
43
 
 
44
//===----------------------------------------------------------------------===//
 
45
// Interpreter ctor - Initialize stuff
 
46
//
 
47
Interpreter::Interpreter(Module *M)
 
48
  : ExecutionEngine(M), TD(M) {
 
49
      
 
50
  memset(&ExitValue.Untyped, 0, sizeof(ExitValue.Untyped));
 
51
  setTargetData(&TD);
 
52
  // Initialize the "backend"
 
53
  initializeExecutionEngine();
 
54
  initializeExternalFunctions();
 
55
  emitGlobals();
 
56
 
 
57
  IL = new IntrinsicLowering(TD);
 
58
}
 
59
 
 
60
Interpreter::~Interpreter() {
 
61
  delete IL;
 
62
}
 
63
 
 
64
void Interpreter::runAtExitHandlers () {
 
65
  while (!AtExitHandlers.empty()) {
 
66
    callFunction(AtExitHandlers.back(), std::vector<GenericValue>());
 
67
    AtExitHandlers.pop_back();
 
68
    run();
 
69
  }
 
70
}
 
71
 
 
72
/// run - Start execution with the specified function and arguments.
 
73
///
 
74
GenericValue
 
75
Interpreter::runFunction(Function *F,
 
76
                         const std::vector<GenericValue> &ArgValues) {
 
77
  assert (F && "Function *F was null at entry to run()");
 
78
 
 
79
  // Try extra hard not to pass extra args to a function that isn't
 
80
  // expecting them.  C programmers frequently bend the rules and
 
81
  // declare main() with fewer parameters than it actually gets
 
82
  // passed, and the interpreter barfs if you pass a function more
 
83
  // parameters than it is declared to take. This does not attempt to
 
84
  // take into account gratuitous differences in declared types,
 
85
  // though.
 
86
  std::vector<GenericValue> ActualArgs;
 
87
  const unsigned ArgCount = F->getFunctionType()->getNumParams();
 
88
  for (unsigned i = 0; i < ArgCount; ++i)
 
89
    ActualArgs.push_back(ArgValues[i]);
 
90
 
 
91
  // Set up the function call.
 
92
  callFunction(F, ActualArgs);
 
93
 
 
94
  // Start executing the function.
 
95
  run();
 
96
 
 
97
  return ExitValue;
 
98
}