~ubuntu-branches/ubuntu/saucy/clamav/saucy-backports

« back to all changes in this revision

Viewing changes to libclamav/c++/ClamBCRTChecks.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2014-07-15 01:08:10 UTC
  • mfrom: (0.35.47 sid)
  • Revision ID: package-import@ubuntu.com-20140715010810-ru66ek4fun2iseba
Tags: 0.98.4+dfsg-2~ubuntu13.10.1
No-change backport to saucy (LP: #1341962)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "llvm/ADT/SCCIterator.h"
28
28
#include "llvm/Analysis/CallGraph.h"
29
29
#include "llvm/Analysis/Verifier.h"
30
 
#include "llvm/Analysis/DebugInfo.h"
31
30
#include "llvm/Analysis/Dominators.h"
32
31
#include "llvm/Analysis/ConstantFolding.h"
33
32
//#include "llvm/Analysis/LiveValues.h"
42
41
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
43
42
#include "llvm/Analysis/ScalarEvolutionExpander.h"
44
43
#include "llvm/Config/config.h"
45
 
#include "llvm/DerivedTypes.h"
46
 
#include "llvm/Instructions.h"
47
 
#include "llvm/IntrinsicInst.h"
48
 
#include "llvm/Intrinsics.h"
49
 
#include "llvm/LLVMContext.h"
50
 
#include "llvm/Module.h"
51
44
#include "llvm/Pass.h"
52
45
#include "llvm/Support/CommandLine.h"
53
46
#include "llvm/Support/DataFlow.h"
54
47
#include "llvm/Support/InstIterator.h"
55
 
#include "llvm/Support/InstVisitor.h"
56
48
#include "llvm/Support/GetElementPtrTypeIterator.h"
57
49
#include "llvm/ADT/DepthFirstIterator.h"
58
 
#include "llvm/Target/TargetData.h"
59
50
#include "llvm/Transforms/Scalar.h"
60
51
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
61
52
#include "llvm/Support/Debug.h"
62
53
#include "llvm30_compat.h"
63
54
 
 
55
#if LLVM_VERSION < 32
 
56
#include "llvm/Analysis/DebugInfo.h"
 
57
#else
 
58
#include "llvm/DebugInfo.h"
 
59
#endif
 
60
 
 
61
#if LLVM_VERSION < 32
 
62
#include "llvm/Target/TargetData.h"
 
63
#elif LLVM_VERSION < 33
 
64
#include "llvm/DataLayout.h"
 
65
#else
 
66
#include "llvm/IR/DataLayout.h"
 
67
#endif
 
68
 
 
69
#if LLVM_VERSION < 33
 
70
#include "llvm/DerivedTypes.h"
 
71
#include "llvm/Instructions.h"
 
72
#include "llvm/IntrinsicInst.h"
 
73
#include "llvm/Intrinsics.h"
 
74
#include "llvm/LLVMContext.h"
 
75
#include "llvm/Module.h"
 
76
#include "llvm/Support/InstVisitor.h"
 
77
#else
 
78
#include "llvm/IR/DerivedTypes.h"
 
79
#include "llvm/IR/Instructions.h"
 
80
#include "llvm/IR/IntrinsicInst.h"
 
81
#include "llvm/IR/Intrinsics.h"
 
82
#include "llvm/IR/LLVMContext.h"
 
83
#include "llvm/IR/Module.h"
 
84
#include "llvm/InstVisitor.h"
 
85
#endif
 
86
 
64
87
#ifndef LLVM28
65
88
#define LLVM28
66
89
#endif
72
95
 
73
96
using namespace llvm;
74
97
#ifndef LLVM29
 
98
#if LLVM_VERSION < 32
75
99
static Value *GetUnderlyingObject(Value *P, TargetData *TD)
 
100
#else
 
101
static Value *GetUnderlyingObject(Value *P, DataLayout *TD)
 
102
#endif
76
103
{
77
104
    return P->getUnderlyingObject();
78
105
}
137
164
      BasicBlock::iterator It = F.getEntryBlock().begin();
138
165
      while (isa<AllocaInst>(It) || isa<PHINode>(It)) ++It;
139
166
      EP = &*It;
140
 
 
 
167
#if LLVM_VERSION < 32
141
168
      TD = &getAnalysis<TargetData>();
 
169
#else
 
170
      TD = &getAnalysis<DataLayout>();
 
171
#endif
142
172
      SE = &getAnalysis<ScalarEvolution>();
143
173
      PT = &getAnalysis<PointerTracking>();
144
174
      DT = &getAnalysis<DominatorTree>();
247
277
        CallInst *AbrtC = CallInst::Create(func_abort, "", UI);
248
278
        AbrtC->setCallingConv(CallingConv::C);
249
279
        AbrtC->setTailCall(true);
 
280
#if LLVM_VERSION < 32
250
281
        AbrtC->setDoesNotReturn(true);
251
282
        AbrtC->setDoesNotThrow(true);
 
283
#else
 
284
        AbrtC->setDoesNotReturn();
 
285
        AbrtC->setDoesNotThrow();
 
286
#endif
252
287
        // remove all instructions from entry
253
288
        BasicBlock::iterator BBI = I, BBE=BB->end();
254
289
        while (BBI != BBE) {
265
300
    }
266
301
 
267
302
    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
 
303
#if LLVM_VERSION < 32
268
304
      AU.addRequired<TargetData>();
 
305
#else
 
306
      AU.addRequired<DataLayout>();
 
307
#endif
269
308
      AU.addRequired<DominatorTree>();
270
309
      AU.addRequired<ScalarEvolution>();
271
310
      AU.addRequired<PointerTracking>();
275
314
    bool isValid() const { return valid; }
276
315
  private:
277
316
    PointerTracking *PT;
 
317
#if LLVM_VERSION < 32
278
318
    TargetData *TD;
 
319
#else
 
320
    DataLayout *TD;
 
321
#endif
279
322
    ScalarEvolution *SE;
280
323
    DominatorTree *DT;
281
324
    DenseMap<Value*, Value*> BaseMap;
511
554
          CallInst *RtErrCall = CallInst::Create(func_rterr, PN, "", AbrtBB);
512
555
          RtErrCall->setCallingConv(CallingConv::C);
513
556
          RtErrCall->setTailCall(true);
 
557
#if LLVM_VERSION < 32
514
558
          RtErrCall->setDoesNotThrow(true);
 
559
#else
 
560
          RtErrCall->setDoesNotThrow();
 
561
#endif
515
562
        }
516
563
        CallInst* AbrtC = CallInst::Create(func_abort, "", AbrtBB);
517
564
        AbrtC->setCallingConv(CallingConv::C);
518
565
        AbrtC->setTailCall(true);
 
566
#if LLVM_VERSION < 32
519
567
        AbrtC->setDoesNotReturn(true);
520
568
        AbrtC->setDoesNotThrow(true);
 
569
#else
 
570
        AbrtC->setDoesNotReturn();
 
571
        AbrtC->setDoesNotThrow();
 
572
#endif
521
573
        new UnreachableInst(BB->getContext(), AbrtBB);
522
574
        DT->addNewBlock(AbrtBB, BB);
523
575
        //verifyFunction(*BB->getParent());
732
784
}
733
785
#ifdef LLVM30
734
786
INITIALIZE_PASS_BEGIN(PtrVerifier, "", "", false, false)
 
787
#if LLVM_VERSION < 32
735
788
INITIALIZE_PASS_DEPENDENCY(TargetData)
 
789
#else
 
790
INITIALIZE_PASS_DEPENDENCY(DataLayout)
 
791
#endif
736
792
INITIALIZE_PASS_DEPENDENCY(DominatorTree)
737
793
INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
 
794
#if LLVM_VERSION < 34
738
795
INITIALIZE_AG_DEPENDENCY(CallGraph)
 
796
#else
 
797
INITIALIZE_PASS_DEPENDENCY(CallGraph)
 
798
#endif
739
799
INITIALIZE_PASS_DEPENDENCY(PointerTracking)
740
800
INITIALIZE_PASS_END(PtrVerifier, "clambcrtchecks", "ClamBC RTchecks", false, false)
741
801
#endif