Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:39

0001 //===--------- Definition of the SanitizerCoverage class --------*- C++ -*-===//
0002 //
0003 //                     The LLVM Compiler Infrastructure
0004 //
0005 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0006 // See https://llvm.org/LICENSE.txt for license information.
0007 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0008 //
0009 //===----------------------------------------------------------------------===//
0010 //
0011 // SanitizerCoverage is a simple code coverage implementation.
0012 //
0013 //===----------------------------------------------------------------------===//
0014 
0015 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_SANITIZERCOVERAGE_H
0016 #define LLVM_TRANSFORMS_INSTRUMENTATION_SANITIZERCOVERAGE_H
0017 
0018 #include "llvm/IR/PassManager.h"
0019 #include "llvm/Support/SpecialCaseList.h"
0020 #include "llvm/Support/VirtualFileSystem.h"
0021 #include "llvm/Transforms/Utils/Instrumentation.h"
0022 
0023 namespace llvm {
0024 class Module;
0025 
0026 /// This is the ModuleSanitizerCoverage pass used in the new pass manager. The
0027 /// pass instruments functions for coverage, adds initialization calls to the
0028 /// module for trace PC guards and 8bit counters if they are requested, and
0029 /// appends globals to llvm.compiler.used.
0030 class SanitizerCoveragePass : public PassInfoMixin<SanitizerCoveragePass> {
0031 public:
0032   explicit SanitizerCoveragePass(
0033       SanitizerCoverageOptions Options = SanitizerCoverageOptions(),
0034       const std::vector<std::string> &AllowlistFiles =
0035           std::vector<std::string>(),
0036       const std::vector<std::string> &BlocklistFiles =
0037           std::vector<std::string>())
0038       : Options(Options) {
0039     if (AllowlistFiles.size() > 0)
0040       Allowlist = SpecialCaseList::createOrDie(AllowlistFiles,
0041                                                *vfs::getRealFileSystem());
0042     if (BlocklistFiles.size() > 0)
0043       Blocklist = SpecialCaseList::createOrDie(BlocklistFiles,
0044                                                *vfs::getRealFileSystem());
0045   }
0046   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
0047   static bool isRequired() { return true; }
0048 
0049 private:
0050   SanitizerCoverageOptions Options;
0051 
0052   std::unique_ptr<SpecialCaseList> Allowlist;
0053   std::unique_ptr<SpecialCaseList> Blocklist;
0054 };
0055 
0056 } // namespace llvm
0057 
0058 #endif