1 //===- InstrumentationBindings.cpp - instrumentation bindings -------------===//
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 C bindings for the instrumentation component.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "InstrumentationBindings.h"
15 #include "llvm-c/Core.h"
16 #include "llvm/IR/LegacyPassManager.h"
17 #include "llvm/IR/Module.h"
18 #include "llvm/Transforms/Instrumentation.h"
19 
20 using namespace llvm;
21 
LLVMAddAddressSanitizerFunctionPass(LLVMPassManagerRef PM)22 void LLVMAddAddressSanitizerFunctionPass(LLVMPassManagerRef PM) {
23   unwrap(PM)->add(createAddressSanitizerFunctionPass());
24 }
25 
LLVMAddAddressSanitizerModulePass(LLVMPassManagerRef PM)26 void LLVMAddAddressSanitizerModulePass(LLVMPassManagerRef PM) {
27   unwrap(PM)->add(createAddressSanitizerModulePass());
28 }
29 
LLVMAddThreadSanitizerPass(LLVMPassManagerRef PM)30 void LLVMAddThreadSanitizerPass(LLVMPassManagerRef PM) {
31   unwrap(PM)->add(createThreadSanitizerPass());
32 }
33 
LLVMAddMemorySanitizerPass(LLVMPassManagerRef PM)34 void LLVMAddMemorySanitizerPass(LLVMPassManagerRef PM) {
35   unwrap(PM)->add(createMemorySanitizerPass());
36 }
37 
LLVMAddDataFlowSanitizerPass(LLVMPassManagerRef PM,int ABIListFilesNum,const char ** ABIListFiles)38 void LLVMAddDataFlowSanitizerPass(LLVMPassManagerRef PM,
39                                   int ABIListFilesNum,
40                                   const char **ABIListFiles) {
41   std::vector<std::string> ABIListFilesVec;
42   for (int i = 0; i != ABIListFilesNum; ++i) {
43     ABIListFilesVec.push_back(ABIListFiles[i]);
44   }
45   unwrap(PM)->add(createDataFlowSanitizerPass(ABIListFilesVec));
46 }
47