Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. //===--------- Definition of the SanitizerCoverage class --------*- C++ -*-===//
  2. //
  3. //                     The LLVM Compiler Infrastructure
  4. //
  5. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  6. // See https://llvm.org/LICENSE.txt for license information.
  7. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  8. //
  9. //===----------------------------------------------------------------------===//
  10. //
  11. // SanitizerCoverage is a simple code coverage implementation.
  12. //
  13. //===----------------------------------------------------------------------===//
  14.  
  15. #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_SANITIZERCOVERAGE_H
  16. #define LLVM_TRANSFORMS_INSTRUMENTATION_SANITIZERCOVERAGE_H
  17.  
  18. #include "llvm/IR/PassManager.h"
  19. #include "llvm/Support/SpecialCaseList.h"
  20. #include "llvm/Support/VirtualFileSystem.h"
  21. #include "llvm/Transforms/Instrumentation.h"
  22.  
  23. namespace llvm {
  24. class Module;
  25.  
  26. /// This is the ModuleSanitizerCoverage pass used in the new pass manager. The
  27. /// pass instruments functions for coverage, adds initialization calls to the
  28. /// module for trace PC guards and 8bit counters if they are requested, and
  29. /// appends globals to llvm.compiler.used.
  30. class SanitizerCoveragePass : public PassInfoMixin<SanitizerCoveragePass> {
  31. public:
  32.   explicit SanitizerCoveragePass(
  33.       SanitizerCoverageOptions Options = SanitizerCoverageOptions(),
  34.       const std::vector<std::string> &AllowlistFiles =
  35.           std::vector<std::string>(),
  36.       const std::vector<std::string> &BlocklistFiles =
  37.           std::vector<std::string>())
  38.       : Options(Options) {
  39.     if (AllowlistFiles.size() > 0)
  40.       Allowlist = SpecialCaseList::createOrDie(AllowlistFiles,
  41.                                                *vfs::getRealFileSystem());
  42.     if (BlocklistFiles.size() > 0)
  43.       Blocklist = SpecialCaseList::createOrDie(BlocklistFiles,
  44.                                                *vfs::getRealFileSystem());
  45.   }
  46.   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
  47.   static bool isRequired() { return true; }
  48.  
  49. private:
  50.   SanitizerCoverageOptions Options;
  51.  
  52.   std::unique_ptr<SpecialCaseList> Allowlist;
  53.   std::unique_ptr<SpecialCaseList> Blocklist;
  54. };
  55.  
  56. } // namespace llvm
  57.  
  58. #endif
  59.