From 2c5380666a15f21e0eedebeb77d3e557f861143f Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Fri, 24 Aug 2012 16:40:11 +0000 Subject: [asan/tsan] extend the functionality of FunctionBlackList to globals and modules. Patch by Reid Watson. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162565 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/FunctionBlackList.h | 41 +++++++++++++++------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'lib/Transforms/Instrumentation/FunctionBlackList.h') diff --git a/lib/Transforms/Instrumentation/FunctionBlackList.h b/lib/Transforms/Instrumentation/FunctionBlackList.h index c1239b9..52f2dbd 100644 --- a/lib/Transforms/Instrumentation/FunctionBlackList.h +++ b/lib/Transforms/Instrumentation/FunctionBlackList.h @@ -1,4 +1,4 @@ -//===-- FunctionBlackList.cpp - blacklist of functions ----------*- C++ -*-===// +//===-- FunctionBlackList.h - blacklist for sanitizers ----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,31 +7,46 @@ //===----------------------------------------------------------------------===// // // This is a utility class for instrumentation passes (like AddressSanitizer -// or ThreadSanitizer) to avoid instrumenting some functions based on -// user-supplied blacklist. +// or ThreadSanitizer) to avoid instrumenting some functions or global +// variables based on a user-supplied blacklist. +// +// The blacklist disables instrumentation of various functions and global +// variables. Each line contains a prefix, followed by a wild card expression. +// --- +// fun:*_ZN4base6subtle* +// global:*global_with_initialization_problems* +// src:file_with_tricky_code.cc +// --- +// Note that the wild card is in fact an llvm::Regex, but * is automatically +// replaced with .* +// This is similar to the "ignore" feature of ThreadSanitizer. +// http://code.google.com/p/data-race-test/wiki/ThreadSanitizerIgnores // //===----------------------------------------------------------------------===// // -#include +#include "llvm/ADT/StringMap.h" namespace llvm { class Function; +class GlobalVariable; +class Module; class Regex; +class StringRef; -// Blacklisted functions are not instrumented. -// The blacklist file contains one or more lines like this: -// --- -// fun:FunctionWildCard -// --- -// This is similar to the "ignore" feature of ThreadSanitizer. -// http://code.google.com/p/data-race-test/wiki/ThreadSanitizerIgnores class FunctionBlackList { public: - FunctionBlackList(const std::string &Path); + FunctionBlackList(const StringRef Path); + // Returns whether either this function or it's source file are blacklisted. bool isIn(const Function &F); + // Returns whether either this global or it's source file are blacklisted. + bool isIn(const GlobalVariable &G); + // Returns whether this module is blacklisted by filename. + bool isIn(const Module &M); private: - Regex *Functions; + StringMap Entries; + + bool inSection(const StringRef Section, const StringRef Query); }; } // namespace llvm -- cgit v1.1 From b5b86d263a651566cb25c0f406f75ceffb771029 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Fri, 24 Aug 2012 16:44:47 +0000 Subject: [asan/tsan] rename FunctionBlackList* to BlackList* as this class is not limited to functions any more git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162566 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Instrumentation/FunctionBlackList.h | 52 ---------------------- 1 file changed, 52 deletions(-) delete mode 100644 lib/Transforms/Instrumentation/FunctionBlackList.h (limited to 'lib/Transforms/Instrumentation/FunctionBlackList.h') diff --git a/lib/Transforms/Instrumentation/FunctionBlackList.h b/lib/Transforms/Instrumentation/FunctionBlackList.h deleted file mode 100644 index 52f2dbd..0000000 --- a/lib/Transforms/Instrumentation/FunctionBlackList.h +++ /dev/null @@ -1,52 +0,0 @@ -//===-- FunctionBlackList.h - blacklist for sanitizers ----------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -//===----------------------------------------------------------------------===// -// -// This is a utility class for instrumentation passes (like AddressSanitizer -// or ThreadSanitizer) to avoid instrumenting some functions or global -// variables based on a user-supplied blacklist. -// -// The blacklist disables instrumentation of various functions and global -// variables. Each line contains a prefix, followed by a wild card expression. -// --- -// fun:*_ZN4base6subtle* -// global:*global_with_initialization_problems* -// src:file_with_tricky_code.cc -// --- -// Note that the wild card is in fact an llvm::Regex, but * is automatically -// replaced with .* -// This is similar to the "ignore" feature of ThreadSanitizer. -// http://code.google.com/p/data-race-test/wiki/ThreadSanitizerIgnores -// -//===----------------------------------------------------------------------===// -// - -#include "llvm/ADT/StringMap.h" - -namespace llvm { -class Function; -class GlobalVariable; -class Module; -class Regex; -class StringRef; - -class FunctionBlackList { - public: - FunctionBlackList(const StringRef Path); - // Returns whether either this function or it's source file are blacklisted. - bool isIn(const Function &F); - // Returns whether either this global or it's source file are blacklisted. - bool isIn(const GlobalVariable &G); - // Returns whether this module is blacklisted by filename. - bool isIn(const Module &M); - private: - StringMap Entries; - - bool inSection(const StringRef Section, const StringRef Query); -}; - -} // namespace llvm -- cgit v1.1