Rename BlackList class to SpecialCaseList and move it to Transforms/Utils.
[oota-llvm.git] / include / llvm / Transforms / Utils / SpecialCaseList.h
1 //===-- SpecialCaseList.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 // Empty lines and lines starting with "#" are ignored.
16 // ---
17 // # Blacklisted items:
18 // fun:*_ZN4base6subtle*
19 // global:*global_with_bad_access_or_initialization*
20 // global-init:*global_with_initialization_issues*
21 // global-init-type:*Namespace::ClassName*
22 // src:file_with_tricky_code.cc
23 // global-init-src:ignore-global-initializers-issues.cc
24 // ---
25 // Note that the wild card is in fact an llvm::Regex, but * is automatically
26 // replaced with .*
27 // This is similar to the "ignore" feature of ThreadSanitizer.
28 // http://code.google.com/p/data-race-test/wiki/ThreadSanitizerIgnores
29 //
30 //===----------------------------------------------------------------------===//
31 //
32
33 #include "llvm/ADT/StringMap.h"
34
35 namespace llvm {
36 class Function;
37 class GlobalVariable;
38 class Module;
39 class Regex;
40 class StringRef;
41
42 class SpecialCaseList {
43  public:
44   SpecialCaseList(const StringRef Path);
45   // Returns whether either this function or it's source file are blacklisted.
46   bool isIn(const Function &F) const;
47   // Returns whether either this global or it's source file are blacklisted.
48   bool isIn(const GlobalVariable &G) const;
49   // Returns whether this module is blacklisted by filename.
50   bool isIn(const Module &M) const;
51   // Returns whether a global should be excluded from initialization checking.
52   bool isInInit(const GlobalVariable &G) const;
53  private:
54   StringMap<Regex*> Entries;
55
56   bool inSection(const StringRef Section, const StringRef Query) const;
57 };
58
59 }  // namespace llvm