73977fc10a641cfad3c1c0ae1382cd42c0a010ba
[oota-llvm.git] / lib / Transforms / Instrumentation / BlackList.h
1 //===-- BlackList.h - blacklist for sanitizers ------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //===----------------------------------------------------------------------===//
8 //
9 // This is a utility class for instrumentation passes (like AddressSanitizer
10 // or ThreadSanitizer) to avoid instrumenting some functions or global
11 // variables based on a user-supplied blacklist.
12 //
13 // The blacklist disables instrumentation of various functions and global
14 // variables.  Each line contains a prefix, followed by a wild card expression.
15 // ---
16 // fun:*_ZN4base6subtle*
17 // global:*global_with_bad_access_or_initialization*
18 // global-init:*global_with_initialization_issues*
19 // src:file_with_tricky_code.cc
20 // ---
21 // Note that the wild card is in fact an llvm::Regex, but * is automatically
22 // replaced with .*
23 // This is similar to the "ignore" feature of ThreadSanitizer.
24 // http://code.google.com/p/data-race-test/wiki/ThreadSanitizerIgnores
25 //
26 //===----------------------------------------------------------------------===//
27 //
28
29 #include "llvm/ADT/StringMap.h"
30
31 namespace llvm {
32 class Function;
33 class GlobalVariable;
34 class Module;
35 class Regex;
36 class StringRef;
37
38 class BlackList {
39  public:
40   BlackList(const StringRef Path);
41   // Returns whether either this function or it's source file are blacklisted.
42   bool isIn(const Function &F);
43   // Returns whether either this global or it's source file are blacklisted.
44   bool isIn(const GlobalVariable &G);
45   // Returns whether this module is blacklisted by filename.
46   bool isIn(const Module &M);
47   // Returns whether a global should be excluded from initialization checking.
48   bool isInInit(const GlobalVariable &G);
49  private:
50   StringMap<Regex*> Entries;
51
52   bool inSection(const StringRef Section, const StringRef Query);
53 };
54
55 }  // namespace llvm