clang API Documentation
00001 //===--- SanitizerArgs.h - Arguments for sanitizer tools -------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 #ifndef LLVM_CLANG_DRIVER_SANITIZERARGS_H 00010 #define LLVM_CLANG_DRIVER_SANITIZERARGS_H 00011 00012 #include "clang/Basic/Sanitizers.h" 00013 #include "llvm/Option/Arg.h" 00014 #include "llvm/Option/ArgList.h" 00015 #include <string> 00016 00017 namespace clang { 00018 namespace driver { 00019 00020 class Driver; 00021 class ToolChain; 00022 00023 class SanitizerArgs { 00024 SanitizerSet Sanitizers; 00025 bool SanitizeRecover; 00026 00027 std::string BlacklistFile; 00028 int SanitizeCoverage; 00029 int MsanTrackOrigins; 00030 int AsanFieldPadding; 00031 bool AsanZeroBaseShadow; 00032 bool UbsanTrapOnError; 00033 bool AsanSharedRuntime; 00034 bool LinkCXXRuntimes; 00035 00036 public: 00037 /// Parses the sanitizer arguments from an argument list. 00038 SanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args); 00039 00040 bool needsAsanRt() const { return Sanitizers.has(SanitizerKind::Address); } 00041 bool needsSharedAsanRt() const { return AsanSharedRuntime; } 00042 bool needsTsanRt() const { return Sanitizers.has(SanitizerKind::Thread); } 00043 bool needsMsanRt() const { return Sanitizers.has(SanitizerKind::Memory); } 00044 bool needsLsanRt() const { 00045 return Sanitizers.has(SanitizerKind::Leak) && 00046 !Sanitizers.has(SanitizerKind::Address); 00047 } 00048 bool needsUbsanRt() const; 00049 bool needsDfsanRt() const { return Sanitizers.has(SanitizerKind::DataFlow); } 00050 00051 bool sanitizesVptr() const { return Sanitizers.has(SanitizerKind::Vptr); } 00052 bool hasZeroBaseShadow() const; 00053 bool needsUnwindTables() const; 00054 bool linkCXXRuntimes() const { return LinkCXXRuntimes; } 00055 void addArgs(const llvm::opt::ArgList &Args, 00056 llvm::opt::ArgStringList &CmdArgs) const; 00057 00058 private: 00059 void clear(); 00060 bool getDefaultBlacklist(const Driver &D, std::string &BLPath); 00061 }; 00062 00063 } // namespace driver 00064 } // namespace clang 00065 00066 #endif