~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/include/llvm/Support/IRReader.h

  • 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
//===---- llvm/Support/IRReader.h - Reader for LLVM IR files ----*- C++ -*-===//
 
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 defines functions for reading LLVM IR. They support both
 
11
// Bitcode and Assembly, automatically detecting the input format.
 
12
//
 
13
// These functions must be defined in a header file in order to avoid
 
14
// library dependencies, since they reference both Bitcode and Assembly
 
15
// functions.
 
16
//
 
17
//===----------------------------------------------------------------------===//
 
18
 
 
19
#ifndef LLVM_SUPPORT_IRREADER_H
 
20
#define LLVM_SUPPORT_IRREADER_H
 
21
 
 
22
#include "llvm/Assembly/Parser.h"
 
23
#include "llvm/Bitcode/ReaderWriter.h"
 
24
#include "llvm/Support/MemoryBuffer.h"
 
25
#include "llvm/Support/SourceMgr.h"
 
26
 
 
27
namespace llvm {
 
28
 
 
29
  /// If the given MemoryBuffer holds a bitcode image, return a Module for it
 
30
  /// which does lazy deserialization of function bodies.  Otherwise, attempt to
 
31
  /// parse it as LLVM Assembly and return a fully populated Module. This
 
32
  /// function *always* takes ownership of the given MemoryBuffer.
 
33
  inline Module *getLazyIRModule(MemoryBuffer *Buffer,
 
34
                                 SMDiagnostic &Err,
 
35
                                 LLVMContext &Context) {
 
36
    if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
 
37
                  (const unsigned char *)Buffer->getBufferEnd())) {
 
38
      std::string ErrMsg;
 
39
      Module *M = getLazyBitcodeModule(Buffer, Context, &ErrMsg);
 
40
      if (M == 0) {
 
41
        Err = SMDiagnostic(Buffer->getBufferIdentifier(), -1, -1, ErrMsg, "");
 
42
        // ParseBitcodeFile does not take ownership of the Buffer in the
 
43
        // case of an error.
 
44
        delete Buffer;
 
45
      }
 
46
      return M;
 
47
    }
 
48
 
 
49
    return ParseAssembly(Buffer, 0, Err, Context);
 
50
  }
 
51
 
 
52
  /// If the given file holds a bitcode image, return a Module
 
53
  /// for it which does lazy deserialization of function bodies.  Otherwise,
 
54
  /// attempt to parse it as LLVM Assembly and return a fully populated
 
55
  /// Module.
 
56
  inline Module *getLazyIRFileModule(const std::string &Filename,
 
57
                                     SMDiagnostic &Err,
 
58
                                     LLVMContext &Context) {
 
59
    std::string ErrMsg;
 
60
    MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrMsg);
 
61
    if (F == 0) {
 
62
      Err = SMDiagnostic(Filename, -1, -1,
 
63
                         "Could not open input file '" + Filename + "'", "");
 
64
      return 0;
 
65
    }
 
66
 
 
67
    return getLazyIRModule(F, Err, Context);
 
68
  }
 
69
 
 
70
  /// If the given MemoryBuffer holds a bitcode image, return a Module
 
71
  /// for it.  Otherwise, attempt to parse it as LLVM Assembly and return
 
72
  /// a Module for it. This function *always* takes ownership of the given
 
73
  /// MemoryBuffer.
 
74
  inline Module *ParseIR(MemoryBuffer *Buffer,
 
75
                         SMDiagnostic &Err,
 
76
                         LLVMContext &Context) {
 
77
    if (isBitcode((const unsigned char *)Buffer->getBufferStart(),
 
78
                  (const unsigned char *)Buffer->getBufferEnd())) {
 
79
      std::string ErrMsg;
 
80
      Module *M = ParseBitcodeFile(Buffer, Context, &ErrMsg);
 
81
      // ParseBitcodeFile does not take ownership of the Buffer.
 
82
      delete Buffer;
 
83
      if (M == 0)
 
84
        Err = SMDiagnostic(Buffer->getBufferIdentifier(), -1, -1, ErrMsg, "");
 
85
      return M;
 
86
    }
 
87
 
 
88
    return ParseAssembly(Buffer, 0, Err, Context);
 
89
  }
 
90
 
 
91
  /// If the given file holds a bitcode image, return a Module for it.
 
92
  /// Otherwise, attempt to parse it as LLVM Assembly and return a Module
 
93
  /// for it.
 
94
  inline Module *ParseIRFile(const std::string &Filename,
 
95
                             SMDiagnostic &Err,
 
96
                             LLVMContext &Context) {
 
97
    std::string ErrMsg;
 
98
    MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrMsg);
 
99
    if (F == 0) {
 
100
      Err = SMDiagnostic(Filename, -1, -1,
 
101
                         "Could not open input file '" + Filename + "'", "");
 
102
      return 0;
 
103
    }
 
104
 
 
105
    return ParseIR(F, Err, Context);
 
106
  }
 
107
 
 
108
}
 
109
 
 
110
#endif