1 //===- InstrumentationBindings.cpp - instrumentation bindings -------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines C bindings for the instrumentation component.
11 //===----------------------------------------------------------------------===//
13 #include "InstrumentationBindings.h"
14 #include "llvm-c/Core.h"
15 #include "llvm/IR/LegacyPassManager.h"
16 #include "llvm/IR/Module.h"
17 #include "llvm/Transforms/Instrumentation.h"
18 #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
19 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
20 #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
24 void LLVMAddAddressSanitizerFunctionPass(LLVMPassManagerRef PM
) {
25 unwrap(PM
)->add(createAddressSanitizerFunctionPass());
28 void LLVMAddAddressSanitizerModulePass(LLVMPassManagerRef PM
) {
29 unwrap(PM
)->add(createModuleAddressSanitizerLegacyPassPass());
32 void LLVMAddThreadSanitizerPass(LLVMPassManagerRef PM
) {
33 unwrap(PM
)->add(createThreadSanitizerLegacyPassPass());
36 void LLVMAddMemorySanitizerLegacyPassPass(LLVMPassManagerRef PM
) {
37 unwrap(PM
)->add(createMemorySanitizerLegacyPassPass());
40 void LLVMAddDataFlowSanitizerPass(LLVMPassManagerRef PM
,
42 const char **ABIListFiles
) {
43 std::vector
<std::string
> ABIListFilesVec
;
44 for (int i
= 0; i
!= ABIListFilesNum
; ++i
) {
45 ABIListFilesVec
.push_back(ABIListFiles
[i
]);
47 unwrap(PM
)->add(createDataFlowSanitizerPass(ABIListFilesVec
));